@vuu-ui/vuu-data-test 0.8.18-debug → 0.8.19-debug
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/cjs/index.js +111 -4639
- package/cjs/index.js.map +4 -4
- package/esm/index.js +112 -4638
- package/esm/index.js.map +4 -4
- package/package.json +3 -3
package/cjs/index.js
CHANGED
|
@@ -902,4658 +902,130 @@ var getSchema = (tableName) => {
|
|
|
902
902
|
throw Error(`getSchema no schema for table ${tableName}`);
|
|
903
903
|
};
|
|
904
904
|
|
|
905
|
-
//
|
|
906
|
-
var
|
|
907
|
-
var nextPropID = 0;
|
|
908
|
-
var Range = class {
|
|
909
|
-
constructor(from, to) {
|
|
910
|
-
this.from = from;
|
|
911
|
-
this.to = to;
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
var NodeProp = class {
|
|
915
|
-
/// Create a new node prop type.
|
|
916
|
-
constructor(config = {}) {
|
|
917
|
-
this.id = nextPropID++;
|
|
918
|
-
this.perNode = !!config.perNode;
|
|
919
|
-
this.deserialize = config.deserialize || (() => {
|
|
920
|
-
throw new Error("This node type doesn't define a deserialize function");
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
/// This is meant to be used with
|
|
924
|
-
/// [`NodeSet.extend`](#common.NodeSet.extend) or
|
|
925
|
-
/// [`LRParser.configure`](#lr.ParserConfig.props) to compute
|
|
926
|
-
/// prop values for each node type in the set. Takes a [match
|
|
927
|
-
/// object](#common.NodeType^match) or function that returns undefined
|
|
928
|
-
/// if the node type doesn't get this prop, and the prop's value if
|
|
929
|
-
/// it does.
|
|
930
|
-
add(match) {
|
|
931
|
-
if (this.perNode)
|
|
932
|
-
throw new RangeError("Can't add per-node props to node types");
|
|
933
|
-
if (typeof match != "function")
|
|
934
|
-
match = NodeType.match(match);
|
|
935
|
-
return (type) => {
|
|
936
|
-
let result = match(type);
|
|
937
|
-
return result === void 0 ? null : [this, result];
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
};
|
|
941
|
-
NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
942
|
-
NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
943
|
-
NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
944
|
-
NodeProp.contextHash = new NodeProp({ perNode: true });
|
|
945
|
-
NodeProp.lookAhead = new NodeProp({ perNode: true });
|
|
946
|
-
NodeProp.mounted = new NodeProp({ perNode: true });
|
|
947
|
-
var noProps = /* @__PURE__ */ Object.create(null);
|
|
948
|
-
var NodeType = class _NodeType {
|
|
949
|
-
/// @internal
|
|
950
|
-
constructor(name, props, id, flags = 0) {
|
|
951
|
-
this.name = name;
|
|
952
|
-
this.props = props;
|
|
953
|
-
this.id = id;
|
|
954
|
-
this.flags = flags;
|
|
955
|
-
}
|
|
956
|
-
/// Define a node type.
|
|
957
|
-
static define(spec) {
|
|
958
|
-
let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps;
|
|
959
|
-
let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
|
|
960
|
-
let type = new _NodeType(spec.name || "", props, spec.id, flags);
|
|
961
|
-
if (spec.props)
|
|
962
|
-
for (let src of spec.props) {
|
|
963
|
-
if (!Array.isArray(src))
|
|
964
|
-
src = src(type);
|
|
965
|
-
if (src) {
|
|
966
|
-
if (src[0].perNode)
|
|
967
|
-
throw new RangeError("Can't store a per-node prop on a node type");
|
|
968
|
-
props[src[0].id] = src[1];
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
return type;
|
|
972
|
-
}
|
|
973
|
-
/// Retrieves a node prop for this type. Will return `undefined` if
|
|
974
|
-
/// the prop isn't present on this node.
|
|
975
|
-
prop(prop) {
|
|
976
|
-
return this.props[prop.id];
|
|
977
|
-
}
|
|
978
|
-
/// True when this is the top node of a grammar.
|
|
979
|
-
get isTop() {
|
|
980
|
-
return (this.flags & 1) > 0;
|
|
981
|
-
}
|
|
982
|
-
/// True when this node is produced by a skip rule.
|
|
983
|
-
get isSkipped() {
|
|
984
|
-
return (this.flags & 2) > 0;
|
|
985
|
-
}
|
|
986
|
-
/// Indicates whether this is an error node.
|
|
987
|
-
get isError() {
|
|
988
|
-
return (this.flags & 4) > 0;
|
|
989
|
-
}
|
|
990
|
-
/// When true, this node type doesn't correspond to a user-declared
|
|
991
|
-
/// named node, for example because it is used to cache repetition.
|
|
992
|
-
get isAnonymous() {
|
|
993
|
-
return (this.flags & 8) > 0;
|
|
994
|
-
}
|
|
995
|
-
/// Returns true when this node's name or one of its
|
|
996
|
-
/// [groups](#common.NodeProp^group) matches the given string.
|
|
997
|
-
is(name) {
|
|
998
|
-
if (typeof name == "string") {
|
|
999
|
-
if (this.name == name)
|
|
1000
|
-
return true;
|
|
1001
|
-
let group = this.prop(NodeProp.group);
|
|
1002
|
-
return group ? group.indexOf(name) > -1 : false;
|
|
1003
|
-
}
|
|
1004
|
-
return this.id == name;
|
|
1005
|
-
}
|
|
1006
|
-
/// Create a function from node types to arbitrary values by
|
|
1007
|
-
/// specifying an object whose property names are node or
|
|
1008
|
-
/// [group](#common.NodeProp^group) names. Often useful with
|
|
1009
|
-
/// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
|
|
1010
|
-
/// names, separated by spaces, in a single property name to map
|
|
1011
|
-
/// multiple node names to a single value.
|
|
1012
|
-
static match(map) {
|
|
1013
|
-
let direct = /* @__PURE__ */ Object.create(null);
|
|
1014
|
-
for (let prop in map)
|
|
1015
|
-
for (let name of prop.split(" "))
|
|
1016
|
-
direct[name] = map[prop];
|
|
1017
|
-
return (node) => {
|
|
1018
|
-
for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
|
|
1019
|
-
let found = direct[i < 0 ? node.name : groups[i]];
|
|
1020
|
-
if (found)
|
|
1021
|
-
return found;
|
|
1022
|
-
}
|
|
1023
|
-
};
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
NodeType.none = new NodeType(
|
|
1027
|
-
"",
|
|
1028
|
-
/* @__PURE__ */ Object.create(null),
|
|
1029
|
-
0,
|
|
1030
|
-
8
|
|
1031
|
-
/* NodeFlag.Anonymous */
|
|
1032
|
-
);
|
|
1033
|
-
var NodeSet = class _NodeSet {
|
|
1034
|
-
/// Create a set with the given types. The `id` property of each
|
|
1035
|
-
/// type should correspond to its position within the array.
|
|
1036
|
-
constructor(types) {
|
|
1037
|
-
this.types = types;
|
|
1038
|
-
for (let i = 0; i < types.length; i++)
|
|
1039
|
-
if (types[i].id != i)
|
|
1040
|
-
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
|
|
1041
|
-
}
|
|
1042
|
-
/// Create a copy of this set with some node properties added. The
|
|
1043
|
-
/// arguments to this method can be created with
|
|
1044
|
-
/// [`NodeProp.add`](#common.NodeProp.add).
|
|
1045
|
-
extend(...props) {
|
|
1046
|
-
let newTypes = [];
|
|
1047
|
-
for (let type of this.types) {
|
|
1048
|
-
let newProps = null;
|
|
1049
|
-
for (let source of props) {
|
|
1050
|
-
let add = source(type);
|
|
1051
|
-
if (add) {
|
|
1052
|
-
if (!newProps)
|
|
1053
|
-
newProps = Object.assign({}, type.props);
|
|
1054
|
-
newProps[add[0].id] = add[1];
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
|
|
1058
|
-
}
|
|
1059
|
-
return new _NodeSet(newTypes);
|
|
1060
|
-
}
|
|
1061
|
-
};
|
|
1062
|
-
var CachedNode = /* @__PURE__ */ new WeakMap();
|
|
1063
|
-
var CachedInnerNode = /* @__PURE__ */ new WeakMap();
|
|
1064
|
-
var IterMode;
|
|
1065
|
-
(function(IterMode2) {
|
|
1066
|
-
IterMode2[IterMode2["ExcludeBuffers"] = 1] = "ExcludeBuffers";
|
|
1067
|
-
IterMode2[IterMode2["IncludeAnonymous"] = 2] = "IncludeAnonymous";
|
|
1068
|
-
IterMode2[IterMode2["IgnoreMounts"] = 4] = "IgnoreMounts";
|
|
1069
|
-
IterMode2[IterMode2["IgnoreOverlays"] = 8] = "IgnoreOverlays";
|
|
1070
|
-
})(IterMode || (IterMode = {}));
|
|
1071
|
-
var Tree = class _Tree {
|
|
1072
|
-
/// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
|
|
1073
|
-
constructor(type, children, positions, length2, props) {
|
|
1074
|
-
this.type = type;
|
|
1075
|
-
this.children = children;
|
|
1076
|
-
this.positions = positions;
|
|
1077
|
-
this.length = length2;
|
|
1078
|
-
this.props = null;
|
|
1079
|
-
if (props && props.length) {
|
|
1080
|
-
this.props = /* @__PURE__ */ Object.create(null);
|
|
1081
|
-
for (let [prop, value] of props)
|
|
1082
|
-
this.props[typeof prop == "number" ? prop : prop.id] = value;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
/// @internal
|
|
1086
|
-
toString() {
|
|
1087
|
-
let mounted = this.prop(NodeProp.mounted);
|
|
1088
|
-
if (mounted && !mounted.overlay)
|
|
1089
|
-
return mounted.tree.toString();
|
|
1090
|
-
let children = "";
|
|
1091
|
-
for (let ch of this.children) {
|
|
1092
|
-
let str = ch.toString();
|
|
1093
|
-
if (str) {
|
|
1094
|
-
if (children)
|
|
1095
|
-
children += ",";
|
|
1096
|
-
children += str;
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
|
|
1100
|
-
}
|
|
1101
|
-
/// Get a [tree cursor](#common.TreeCursor) positioned at the top of
|
|
1102
|
-
/// the tree. Mode can be used to [control](#common.IterMode) which
|
|
1103
|
-
/// nodes the cursor visits.
|
|
1104
|
-
cursor(mode = 0) {
|
|
1105
|
-
return new TreeCursor(this.topNode, mode);
|
|
1106
|
-
}
|
|
1107
|
-
/// Get a [tree cursor](#common.TreeCursor) pointing into this tree
|
|
1108
|
-
/// at the given position and side (see
|
|
1109
|
-
/// [`moveTo`](#common.TreeCursor.moveTo).
|
|
1110
|
-
cursorAt(pos, side = 0, mode = 0) {
|
|
1111
|
-
let scope = CachedNode.get(this) || this.topNode;
|
|
1112
|
-
let cursor = new TreeCursor(scope);
|
|
1113
|
-
cursor.moveTo(pos, side);
|
|
1114
|
-
CachedNode.set(this, cursor._tree);
|
|
1115
|
-
return cursor;
|
|
1116
|
-
}
|
|
1117
|
-
/// Get a [syntax node](#common.SyntaxNode) object for the top of the
|
|
1118
|
-
/// tree.
|
|
1119
|
-
get topNode() {
|
|
1120
|
-
return new TreeNode(this, 0, 0, null);
|
|
1121
|
-
}
|
|
1122
|
-
/// Get the [syntax node](#common.SyntaxNode) at the given position.
|
|
1123
|
-
/// If `side` is -1, this will move into nodes that end at the
|
|
1124
|
-
/// position. If 1, it'll move into nodes that start at the
|
|
1125
|
-
/// position. With 0, it'll only enter nodes that cover the position
|
|
1126
|
-
/// from both sides.
|
|
1127
|
-
///
|
|
1128
|
-
/// Note that this will not enter
|
|
1129
|
-
/// [overlays](#common.MountedTree.overlay), and you often want
|
|
1130
|
-
/// [`resolveInner`](#common.Tree.resolveInner) instead.
|
|
1131
|
-
resolve(pos, side = 0) {
|
|
1132
|
-
let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
|
|
1133
|
-
CachedNode.set(this, node);
|
|
1134
|
-
return node;
|
|
1135
|
-
}
|
|
1136
|
-
/// Like [`resolve`](#common.Tree.resolve), but will enter
|
|
1137
|
-
/// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
|
|
1138
|
-
/// pointing into the innermost overlaid tree at the given position
|
|
1139
|
-
/// (with parent links going through all parent structure, including
|
|
1140
|
-
/// the host trees).
|
|
1141
|
-
resolveInner(pos, side = 0) {
|
|
1142
|
-
let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
|
|
1143
|
-
CachedInnerNode.set(this, node);
|
|
1144
|
-
return node;
|
|
1145
|
-
}
|
|
1146
|
-
/// Iterate over the tree and its children, calling `enter` for any
|
|
1147
|
-
/// node that touches the `from`/`to` region (if given) before
|
|
1148
|
-
/// running over such a node's children, and `leave` (if given) when
|
|
1149
|
-
/// leaving the node. When `enter` returns `false`, that node will
|
|
1150
|
-
/// not have its children iterated over (or `leave` called).
|
|
1151
|
-
iterate(spec) {
|
|
1152
|
-
let { enter, leave, from = 0, to = this.length } = spec;
|
|
1153
|
-
let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
|
|
1154
|
-
for (let c = this.cursor(mode | IterMode.IncludeAnonymous); ; ) {
|
|
1155
|
-
let entered = false;
|
|
1156
|
-
if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
|
|
1157
|
-
if (c.firstChild())
|
|
1158
|
-
continue;
|
|
1159
|
-
entered = true;
|
|
1160
|
-
}
|
|
1161
|
-
for (; ; ) {
|
|
1162
|
-
if (entered && leave && (anon || !c.type.isAnonymous))
|
|
1163
|
-
leave(c);
|
|
1164
|
-
if (c.nextSibling())
|
|
1165
|
-
break;
|
|
1166
|
-
if (!c.parent())
|
|
1167
|
-
return;
|
|
1168
|
-
entered = true;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
/// Get the value of the given [node prop](#common.NodeProp) for this
|
|
1173
|
-
/// node. Works with both per-node and per-type props.
|
|
1174
|
-
prop(prop) {
|
|
1175
|
-
return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
|
|
1176
|
-
}
|
|
1177
|
-
/// Returns the node's [per-node props](#common.NodeProp.perNode) in a
|
|
1178
|
-
/// format that can be passed to the [`Tree`](#common.Tree)
|
|
1179
|
-
/// constructor.
|
|
1180
|
-
get propValues() {
|
|
1181
|
-
let result = [];
|
|
1182
|
-
if (this.props)
|
|
1183
|
-
for (let id in this.props)
|
|
1184
|
-
result.push([+id, this.props[id]]);
|
|
1185
|
-
return result;
|
|
1186
|
-
}
|
|
1187
|
-
/// Balance the direct children of this tree, producing a copy of
|
|
1188
|
-
/// which may have children grouped into subtrees with type
|
|
1189
|
-
/// [`NodeType.none`](#common.NodeType^none).
|
|
1190
|
-
balance(config = {}) {
|
|
1191
|
-
return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length2) => new _Tree(this.type, children, positions, length2, this.propValues), config.makeTree || ((children, positions, length2) => new _Tree(NodeType.none, children, positions, length2)));
|
|
1192
|
-
}
|
|
1193
|
-
/// Build a tree from a postfix-ordered buffer of node information,
|
|
1194
|
-
/// or a cursor over such a buffer.
|
|
1195
|
-
static build(data) {
|
|
1196
|
-
return buildTree(data);
|
|
1197
|
-
}
|
|
1198
|
-
};
|
|
1199
|
-
Tree.empty = new Tree(NodeType.none, [], [], 0);
|
|
1200
|
-
var FlatBufferCursor = class _FlatBufferCursor {
|
|
1201
|
-
constructor(buffer, index) {
|
|
1202
|
-
this.buffer = buffer;
|
|
1203
|
-
this.index = index;
|
|
1204
|
-
}
|
|
1205
|
-
get id() {
|
|
1206
|
-
return this.buffer[this.index - 4];
|
|
1207
|
-
}
|
|
1208
|
-
get start() {
|
|
1209
|
-
return this.buffer[this.index - 3];
|
|
1210
|
-
}
|
|
1211
|
-
get end() {
|
|
1212
|
-
return this.buffer[this.index - 2];
|
|
1213
|
-
}
|
|
1214
|
-
get size() {
|
|
1215
|
-
return this.buffer[this.index - 1];
|
|
1216
|
-
}
|
|
1217
|
-
get pos() {
|
|
1218
|
-
return this.index;
|
|
1219
|
-
}
|
|
1220
|
-
next() {
|
|
1221
|
-
this.index -= 4;
|
|
1222
|
-
}
|
|
1223
|
-
fork() {
|
|
1224
|
-
return new _FlatBufferCursor(this.buffer, this.index);
|
|
1225
|
-
}
|
|
1226
|
-
};
|
|
1227
|
-
var TreeBuffer = class _TreeBuffer {
|
|
1228
|
-
/// Create a tree buffer.
|
|
1229
|
-
constructor(buffer, length2, set) {
|
|
1230
|
-
this.buffer = buffer;
|
|
1231
|
-
this.length = length2;
|
|
1232
|
-
this.set = set;
|
|
1233
|
-
}
|
|
1234
|
-
/// @internal
|
|
1235
|
-
get type() {
|
|
1236
|
-
return NodeType.none;
|
|
1237
|
-
}
|
|
1238
|
-
/// @internal
|
|
1239
|
-
toString() {
|
|
1240
|
-
let result = [];
|
|
1241
|
-
for (let index = 0; index < this.buffer.length; ) {
|
|
1242
|
-
result.push(this.childString(index));
|
|
1243
|
-
index = this.buffer[index + 3];
|
|
1244
|
-
}
|
|
1245
|
-
return result.join(",");
|
|
1246
|
-
}
|
|
1247
|
-
/// @internal
|
|
1248
|
-
childString(index) {
|
|
1249
|
-
let id = this.buffer[index], endIndex = this.buffer[index + 3];
|
|
1250
|
-
let type = this.set.types[id], result = type.name;
|
|
1251
|
-
if (/\W/.test(result) && !type.isError)
|
|
1252
|
-
result = JSON.stringify(result);
|
|
1253
|
-
index += 4;
|
|
1254
|
-
if (endIndex == index)
|
|
1255
|
-
return result;
|
|
1256
|
-
let children = [];
|
|
1257
|
-
while (index < endIndex) {
|
|
1258
|
-
children.push(this.childString(index));
|
|
1259
|
-
index = this.buffer[index + 3];
|
|
1260
|
-
}
|
|
1261
|
-
return result + "(" + children.join(",") + ")";
|
|
1262
|
-
}
|
|
1263
|
-
/// @internal
|
|
1264
|
-
findChild(startIndex, endIndex, dir, pos, side) {
|
|
1265
|
-
let { buffer } = this, pick = -1;
|
|
1266
|
-
for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
|
|
1267
|
-
if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
|
|
1268
|
-
pick = i;
|
|
1269
|
-
if (dir > 0)
|
|
1270
|
-
break;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
return pick;
|
|
1274
|
-
}
|
|
1275
|
-
/// @internal
|
|
1276
|
-
slice(startI, endI, from) {
|
|
1277
|
-
let b = this.buffer;
|
|
1278
|
-
let copy = new Uint16Array(endI - startI), len = 0;
|
|
1279
|
-
for (let i = startI, j = 0; i < endI; ) {
|
|
1280
|
-
copy[j++] = b[i++];
|
|
1281
|
-
copy[j++] = b[i++] - from;
|
|
1282
|
-
let to = copy[j++] = b[i++] - from;
|
|
1283
|
-
copy[j++] = b[i++] - startI;
|
|
1284
|
-
len = Math.max(len, to);
|
|
1285
|
-
}
|
|
1286
|
-
return new _TreeBuffer(copy, len, this.set);
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
function checkSide(side, pos, from, to) {
|
|
1290
|
-
switch (side) {
|
|
1291
|
-
case -2:
|
|
1292
|
-
return from < pos;
|
|
1293
|
-
case -1:
|
|
1294
|
-
return to >= pos && from < pos;
|
|
1295
|
-
case 0:
|
|
1296
|
-
return from < pos && to > pos;
|
|
1297
|
-
case 1:
|
|
1298
|
-
return from <= pos && to > pos;
|
|
1299
|
-
case 2:
|
|
1300
|
-
return to > pos;
|
|
1301
|
-
case 4:
|
|
1302
|
-
return true;
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
function enterUnfinishedNodesBefore(node, pos) {
|
|
1306
|
-
let scan = node.childBefore(pos);
|
|
1307
|
-
while (scan) {
|
|
1308
|
-
let last2 = scan.lastChild;
|
|
1309
|
-
if (!last2 || last2.to != scan.to)
|
|
1310
|
-
break;
|
|
1311
|
-
if (last2.type.isError && last2.from == last2.to) {
|
|
1312
|
-
node = scan;
|
|
1313
|
-
scan = last2.prevSibling;
|
|
1314
|
-
} else {
|
|
1315
|
-
scan = last2;
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
return node;
|
|
1319
|
-
}
|
|
1320
|
-
function resolveNode(node, pos, side, overlays) {
|
|
1321
|
-
var _a;
|
|
1322
|
-
while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
|
|
1323
|
-
let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
|
|
1324
|
-
if (!parent)
|
|
1325
|
-
return node;
|
|
1326
|
-
node = parent;
|
|
1327
|
-
}
|
|
1328
|
-
let mode = overlays ? 0 : IterMode.IgnoreOverlays;
|
|
1329
|
-
if (overlays)
|
|
1330
|
-
for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
|
|
1331
|
-
if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
|
|
1332
|
-
node = parent;
|
|
1333
|
-
}
|
|
1334
|
-
for (; ; ) {
|
|
1335
|
-
let inner = node.enter(pos, side, mode);
|
|
1336
|
-
if (!inner)
|
|
1337
|
-
return node;
|
|
1338
|
-
node = inner;
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
var TreeNode = class _TreeNode {
|
|
1342
|
-
constructor(_tree, from, index, _parent) {
|
|
1343
|
-
this._tree = _tree;
|
|
1344
|
-
this.from = from;
|
|
1345
|
-
this.index = index;
|
|
1346
|
-
this._parent = _parent;
|
|
1347
|
-
}
|
|
1348
|
-
get type() {
|
|
1349
|
-
return this._tree.type;
|
|
1350
|
-
}
|
|
1351
|
-
get name() {
|
|
1352
|
-
return this._tree.type.name;
|
|
1353
|
-
}
|
|
1354
|
-
get to() {
|
|
1355
|
-
return this.from + this._tree.length;
|
|
1356
|
-
}
|
|
1357
|
-
nextChild(i, dir, pos, side, mode = 0) {
|
|
1358
|
-
for (let parent = this; ; ) {
|
|
1359
|
-
for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
|
|
1360
|
-
let next = children[i], start = positions[i] + parent.from;
|
|
1361
|
-
if (!checkSide(side, pos, start, start + next.length))
|
|
1362
|
-
continue;
|
|
1363
|
-
if (next instanceof TreeBuffer) {
|
|
1364
|
-
if (mode & IterMode.ExcludeBuffers)
|
|
1365
|
-
continue;
|
|
1366
|
-
let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
|
|
1367
|
-
if (index > -1)
|
|
1368
|
-
return new BufferNode(new BufferContext(parent, next, i, start), null, index);
|
|
1369
|
-
} else if (mode & IterMode.IncludeAnonymous || (!next.type.isAnonymous || hasChild(next))) {
|
|
1370
|
-
let mounted;
|
|
1371
|
-
if (!(mode & IterMode.IgnoreMounts) && next.props && (mounted = next.prop(NodeProp.mounted)) && !mounted.overlay)
|
|
1372
|
-
return new _TreeNode(mounted.tree, start, i, parent);
|
|
1373
|
-
let inner = new _TreeNode(next, start, i, parent);
|
|
1374
|
-
return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous)
|
|
1378
|
-
return null;
|
|
1379
|
-
if (parent.index >= 0)
|
|
1380
|
-
i = parent.index + dir;
|
|
1381
|
-
else
|
|
1382
|
-
i = dir < 0 ? -1 : parent._parent._tree.children.length;
|
|
1383
|
-
parent = parent._parent;
|
|
1384
|
-
if (!parent)
|
|
1385
|
-
return null;
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
get firstChild() {
|
|
1389
|
-
return this.nextChild(
|
|
1390
|
-
0,
|
|
1391
|
-
1,
|
|
1392
|
-
0,
|
|
1393
|
-
4
|
|
1394
|
-
/* Side.DontCare */
|
|
1395
|
-
);
|
|
1396
|
-
}
|
|
1397
|
-
get lastChild() {
|
|
1398
|
-
return this.nextChild(
|
|
1399
|
-
this._tree.children.length - 1,
|
|
1400
|
-
-1,
|
|
1401
|
-
0,
|
|
1402
|
-
4
|
|
1403
|
-
/* Side.DontCare */
|
|
1404
|
-
);
|
|
1405
|
-
}
|
|
1406
|
-
childAfter(pos) {
|
|
1407
|
-
return this.nextChild(
|
|
1408
|
-
0,
|
|
1409
|
-
1,
|
|
1410
|
-
pos,
|
|
1411
|
-
2
|
|
1412
|
-
/* Side.After */
|
|
1413
|
-
);
|
|
1414
|
-
}
|
|
1415
|
-
childBefore(pos) {
|
|
1416
|
-
return this.nextChild(
|
|
1417
|
-
this._tree.children.length - 1,
|
|
1418
|
-
-1,
|
|
1419
|
-
pos,
|
|
1420
|
-
-2
|
|
1421
|
-
/* Side.Before */
|
|
1422
|
-
);
|
|
1423
|
-
}
|
|
1424
|
-
enter(pos, side, mode = 0) {
|
|
1425
|
-
let mounted;
|
|
1426
|
-
if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp.mounted)) && mounted.overlay) {
|
|
1427
|
-
let rPos = pos - this.from;
|
|
1428
|
-
for (let { from, to } of mounted.overlay) {
|
|
1429
|
-
if ((side > 0 ? from <= rPos : from < rPos) && (side < 0 ? to >= rPos : to > rPos))
|
|
1430
|
-
return new _TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
return this.nextChild(0, 1, pos, side, mode);
|
|
1434
|
-
}
|
|
1435
|
-
nextSignificantParent() {
|
|
1436
|
-
let val = this;
|
|
1437
|
-
while (val.type.isAnonymous && val._parent)
|
|
1438
|
-
val = val._parent;
|
|
1439
|
-
return val;
|
|
1440
|
-
}
|
|
1441
|
-
get parent() {
|
|
1442
|
-
return this._parent ? this._parent.nextSignificantParent() : null;
|
|
1443
|
-
}
|
|
1444
|
-
get nextSibling() {
|
|
1445
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(
|
|
1446
|
-
this.index + 1,
|
|
1447
|
-
1,
|
|
1448
|
-
0,
|
|
1449
|
-
4
|
|
1450
|
-
/* Side.DontCare */
|
|
1451
|
-
) : null;
|
|
1452
|
-
}
|
|
1453
|
-
get prevSibling() {
|
|
1454
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(
|
|
1455
|
-
this.index - 1,
|
|
1456
|
-
-1,
|
|
1457
|
-
0,
|
|
1458
|
-
4
|
|
1459
|
-
/* Side.DontCare */
|
|
1460
|
-
) : null;
|
|
1461
|
-
}
|
|
1462
|
-
cursor(mode = 0) {
|
|
1463
|
-
return new TreeCursor(this, mode);
|
|
1464
|
-
}
|
|
1465
|
-
get tree() {
|
|
1466
|
-
return this._tree;
|
|
1467
|
-
}
|
|
1468
|
-
toTree() {
|
|
1469
|
-
return this._tree;
|
|
1470
|
-
}
|
|
1471
|
-
resolve(pos, side = 0) {
|
|
1472
|
-
return resolveNode(this, pos, side, false);
|
|
1473
|
-
}
|
|
1474
|
-
resolveInner(pos, side = 0) {
|
|
1475
|
-
return resolveNode(this, pos, side, true);
|
|
1476
|
-
}
|
|
1477
|
-
enterUnfinishedNodesBefore(pos) {
|
|
1478
|
-
return enterUnfinishedNodesBefore(this, pos);
|
|
1479
|
-
}
|
|
1480
|
-
getChild(type, before = null, after = null) {
|
|
1481
|
-
let r = getChildren(this, type, before, after);
|
|
1482
|
-
return r.length ? r[0] : null;
|
|
1483
|
-
}
|
|
1484
|
-
getChildren(type, before = null, after = null) {
|
|
1485
|
-
return getChildren(this, type, before, after);
|
|
1486
|
-
}
|
|
1487
|
-
/// @internal
|
|
1488
|
-
toString() {
|
|
1489
|
-
return this._tree.toString();
|
|
1490
|
-
}
|
|
1491
|
-
get node() {
|
|
1492
|
-
return this;
|
|
1493
|
-
}
|
|
1494
|
-
matchContext(context) {
|
|
1495
|
-
return matchNodeContext(this, context);
|
|
1496
|
-
}
|
|
1497
|
-
};
|
|
1498
|
-
function getChildren(node, type, before, after) {
|
|
1499
|
-
let cur = node.cursor(), result = [];
|
|
1500
|
-
if (!cur.firstChild())
|
|
1501
|
-
return result;
|
|
1502
|
-
if (before != null) {
|
|
1503
|
-
while (!cur.type.is(before))
|
|
1504
|
-
if (!cur.nextSibling())
|
|
1505
|
-
return result;
|
|
1506
|
-
}
|
|
1507
|
-
for (; ; ) {
|
|
1508
|
-
if (after != null && cur.type.is(after))
|
|
1509
|
-
return result;
|
|
1510
|
-
if (cur.type.is(type))
|
|
1511
|
-
result.push(cur.node);
|
|
1512
|
-
if (!cur.nextSibling())
|
|
1513
|
-
return after == null ? result : [];
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
function matchNodeContext(node, context, i = context.length - 1) {
|
|
1517
|
-
for (let p = node.parent; i >= 0; p = p.parent) {
|
|
1518
|
-
if (!p)
|
|
1519
|
-
return false;
|
|
1520
|
-
if (!p.type.isAnonymous) {
|
|
1521
|
-
if (context[i] && context[i] != p.name)
|
|
1522
|
-
return false;
|
|
1523
|
-
i--;
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
return true;
|
|
1527
|
-
}
|
|
1528
|
-
var BufferContext = class {
|
|
1529
|
-
constructor(parent, buffer, index, start) {
|
|
1530
|
-
this.parent = parent;
|
|
1531
|
-
this.buffer = buffer;
|
|
1532
|
-
this.index = index;
|
|
1533
|
-
this.start = start;
|
|
1534
|
-
}
|
|
1535
|
-
};
|
|
1536
|
-
var BufferNode = class _BufferNode {
|
|
1537
|
-
get name() {
|
|
1538
|
-
return this.type.name;
|
|
1539
|
-
}
|
|
1540
|
-
get from() {
|
|
1541
|
-
return this.context.start + this.context.buffer.buffer[this.index + 1];
|
|
1542
|
-
}
|
|
1543
|
-
get to() {
|
|
1544
|
-
return this.context.start + this.context.buffer.buffer[this.index + 2];
|
|
1545
|
-
}
|
|
1546
|
-
constructor(context, _parent, index) {
|
|
1547
|
-
this.context = context;
|
|
1548
|
-
this._parent = _parent;
|
|
1549
|
-
this.index = index;
|
|
1550
|
-
this.type = context.buffer.set.types[context.buffer.buffer[index]];
|
|
1551
|
-
}
|
|
1552
|
-
child(dir, pos, side) {
|
|
1553
|
-
let { buffer } = this.context;
|
|
1554
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
|
|
1555
|
-
return index < 0 ? null : new _BufferNode(this.context, this, index);
|
|
1556
|
-
}
|
|
1557
|
-
get firstChild() {
|
|
1558
|
-
return this.child(
|
|
1559
|
-
1,
|
|
1560
|
-
0,
|
|
1561
|
-
4
|
|
1562
|
-
/* Side.DontCare */
|
|
1563
|
-
);
|
|
1564
|
-
}
|
|
1565
|
-
get lastChild() {
|
|
1566
|
-
return this.child(
|
|
1567
|
-
-1,
|
|
1568
|
-
0,
|
|
1569
|
-
4
|
|
1570
|
-
/* Side.DontCare */
|
|
1571
|
-
);
|
|
1572
|
-
}
|
|
1573
|
-
childAfter(pos) {
|
|
1574
|
-
return this.child(
|
|
1575
|
-
1,
|
|
1576
|
-
pos,
|
|
1577
|
-
2
|
|
1578
|
-
/* Side.After */
|
|
1579
|
-
);
|
|
1580
|
-
}
|
|
1581
|
-
childBefore(pos) {
|
|
1582
|
-
return this.child(
|
|
1583
|
-
-1,
|
|
1584
|
-
pos,
|
|
1585
|
-
-2
|
|
1586
|
-
/* Side.Before */
|
|
1587
|
-
);
|
|
1588
|
-
}
|
|
1589
|
-
enter(pos, side, mode = 0) {
|
|
1590
|
-
if (mode & IterMode.ExcludeBuffers)
|
|
1591
|
-
return null;
|
|
1592
|
-
let { buffer } = this.context;
|
|
1593
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
|
|
1594
|
-
return index < 0 ? null : new _BufferNode(this.context, this, index);
|
|
1595
|
-
}
|
|
1596
|
-
get parent() {
|
|
1597
|
-
return this._parent || this.context.parent.nextSignificantParent();
|
|
1598
|
-
}
|
|
1599
|
-
externalSibling(dir) {
|
|
1600
|
-
return this._parent ? null : this.context.parent.nextChild(
|
|
1601
|
-
this.context.index + dir,
|
|
1602
|
-
dir,
|
|
1603
|
-
0,
|
|
1604
|
-
4
|
|
1605
|
-
/* Side.DontCare */
|
|
1606
|
-
);
|
|
1607
|
-
}
|
|
1608
|
-
get nextSibling() {
|
|
1609
|
-
let { buffer } = this.context;
|
|
1610
|
-
let after = buffer.buffer[this.index + 3];
|
|
1611
|
-
if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
|
|
1612
|
-
return new _BufferNode(this.context, this._parent, after);
|
|
1613
|
-
return this.externalSibling(1);
|
|
1614
|
-
}
|
|
1615
|
-
get prevSibling() {
|
|
1616
|
-
let { buffer } = this.context;
|
|
1617
|
-
let parentStart = this._parent ? this._parent.index + 4 : 0;
|
|
1618
|
-
if (this.index == parentStart)
|
|
1619
|
-
return this.externalSibling(-1);
|
|
1620
|
-
return new _BufferNode(this.context, this._parent, buffer.findChild(
|
|
1621
|
-
parentStart,
|
|
1622
|
-
this.index,
|
|
1623
|
-
-1,
|
|
1624
|
-
0,
|
|
1625
|
-
4
|
|
1626
|
-
/* Side.DontCare */
|
|
1627
|
-
));
|
|
1628
|
-
}
|
|
1629
|
-
cursor(mode = 0) {
|
|
1630
|
-
return new TreeCursor(this, mode);
|
|
1631
|
-
}
|
|
1632
|
-
get tree() {
|
|
1633
|
-
return null;
|
|
1634
|
-
}
|
|
1635
|
-
toTree() {
|
|
1636
|
-
let children = [], positions = [];
|
|
1637
|
-
let { buffer } = this.context;
|
|
1638
|
-
let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
|
|
1639
|
-
if (endI > startI) {
|
|
1640
|
-
let from = buffer.buffer[this.index + 1];
|
|
1641
|
-
children.push(buffer.slice(startI, endI, from));
|
|
1642
|
-
positions.push(0);
|
|
1643
|
-
}
|
|
1644
|
-
return new Tree(this.type, children, positions, this.to - this.from);
|
|
1645
|
-
}
|
|
1646
|
-
resolve(pos, side = 0) {
|
|
1647
|
-
return resolveNode(this, pos, side, false);
|
|
1648
|
-
}
|
|
1649
|
-
resolveInner(pos, side = 0) {
|
|
1650
|
-
return resolveNode(this, pos, side, true);
|
|
1651
|
-
}
|
|
1652
|
-
enterUnfinishedNodesBefore(pos) {
|
|
1653
|
-
return enterUnfinishedNodesBefore(this, pos);
|
|
1654
|
-
}
|
|
1655
|
-
/// @internal
|
|
1656
|
-
toString() {
|
|
1657
|
-
return this.context.buffer.childString(this.index);
|
|
1658
|
-
}
|
|
1659
|
-
getChild(type, before = null, after = null) {
|
|
1660
|
-
let r = getChildren(this, type, before, after);
|
|
1661
|
-
return r.length ? r[0] : null;
|
|
1662
|
-
}
|
|
1663
|
-
getChildren(type, before = null, after = null) {
|
|
1664
|
-
return getChildren(this, type, before, after);
|
|
1665
|
-
}
|
|
1666
|
-
get node() {
|
|
1667
|
-
return this;
|
|
1668
|
-
}
|
|
1669
|
-
matchContext(context) {
|
|
1670
|
-
return matchNodeContext(this, context);
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
var TreeCursor = class {
|
|
1674
|
-
/// Shorthand for `.type.name`.
|
|
1675
|
-
get name() {
|
|
1676
|
-
return this.type.name;
|
|
1677
|
-
}
|
|
1678
|
-
/// @internal
|
|
1679
|
-
constructor(node, mode = 0) {
|
|
1680
|
-
this.mode = mode;
|
|
1681
|
-
this.buffer = null;
|
|
1682
|
-
this.stack = [];
|
|
1683
|
-
this.index = 0;
|
|
1684
|
-
this.bufferNode = null;
|
|
1685
|
-
if (node instanceof TreeNode) {
|
|
1686
|
-
this.yieldNode(node);
|
|
1687
|
-
} else {
|
|
1688
|
-
this._tree = node.context.parent;
|
|
1689
|
-
this.buffer = node.context;
|
|
1690
|
-
for (let n = node._parent; n; n = n._parent)
|
|
1691
|
-
this.stack.unshift(n.index);
|
|
1692
|
-
this.bufferNode = node;
|
|
1693
|
-
this.yieldBuf(node.index);
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
yieldNode(node) {
|
|
1697
|
-
if (!node)
|
|
1698
|
-
return false;
|
|
1699
|
-
this._tree = node;
|
|
1700
|
-
this.type = node.type;
|
|
1701
|
-
this.from = node.from;
|
|
1702
|
-
this.to = node.to;
|
|
1703
|
-
return true;
|
|
1704
|
-
}
|
|
1705
|
-
yieldBuf(index, type) {
|
|
1706
|
-
this.index = index;
|
|
1707
|
-
let { start, buffer } = this.buffer;
|
|
1708
|
-
this.type = type || buffer.set.types[buffer.buffer[index]];
|
|
1709
|
-
this.from = start + buffer.buffer[index + 1];
|
|
1710
|
-
this.to = start + buffer.buffer[index + 2];
|
|
1711
|
-
return true;
|
|
1712
|
-
}
|
|
1713
|
-
yield(node) {
|
|
1714
|
-
if (!node)
|
|
1715
|
-
return false;
|
|
1716
|
-
if (node instanceof TreeNode) {
|
|
1717
|
-
this.buffer = null;
|
|
1718
|
-
return this.yieldNode(node);
|
|
1719
|
-
}
|
|
1720
|
-
this.buffer = node.context;
|
|
1721
|
-
return this.yieldBuf(node.index, node.type);
|
|
1722
|
-
}
|
|
1723
|
-
/// @internal
|
|
1724
|
-
toString() {
|
|
1725
|
-
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
|
|
1726
|
-
}
|
|
1727
|
-
/// @internal
|
|
1728
|
-
enterChild(dir, pos, side) {
|
|
1729
|
-
if (!this.buffer)
|
|
1730
|
-
return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
|
|
1731
|
-
let { buffer } = this.buffer;
|
|
1732
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
|
|
1733
|
-
if (index < 0)
|
|
1734
|
-
return false;
|
|
1735
|
-
this.stack.push(this.index);
|
|
1736
|
-
return this.yieldBuf(index);
|
|
1737
|
-
}
|
|
1738
|
-
/// Move the cursor to this node's first child. When this returns
|
|
1739
|
-
/// false, the node has no child, and the cursor has not been moved.
|
|
1740
|
-
firstChild() {
|
|
1741
|
-
return this.enterChild(
|
|
1742
|
-
1,
|
|
1743
|
-
0,
|
|
1744
|
-
4
|
|
1745
|
-
/* Side.DontCare */
|
|
1746
|
-
);
|
|
1747
|
-
}
|
|
1748
|
-
/// Move the cursor to this node's last child.
|
|
1749
|
-
lastChild() {
|
|
1750
|
-
return this.enterChild(
|
|
1751
|
-
-1,
|
|
1752
|
-
0,
|
|
1753
|
-
4
|
|
1754
|
-
/* Side.DontCare */
|
|
1755
|
-
);
|
|
1756
|
-
}
|
|
1757
|
-
/// Move the cursor to the first child that ends after `pos`.
|
|
1758
|
-
childAfter(pos) {
|
|
1759
|
-
return this.enterChild(
|
|
1760
|
-
1,
|
|
1761
|
-
pos,
|
|
1762
|
-
2
|
|
1763
|
-
/* Side.After */
|
|
1764
|
-
);
|
|
1765
|
-
}
|
|
1766
|
-
/// Move to the last child that starts before `pos`.
|
|
1767
|
-
childBefore(pos) {
|
|
1768
|
-
return this.enterChild(
|
|
1769
|
-
-1,
|
|
1770
|
-
pos,
|
|
1771
|
-
-2
|
|
1772
|
-
/* Side.Before */
|
|
1773
|
-
);
|
|
1774
|
-
}
|
|
1775
|
-
/// Move the cursor to the child around `pos`. If side is -1 the
|
|
1776
|
-
/// child may end at that position, when 1 it may start there. This
|
|
1777
|
-
/// will also enter [overlaid](#common.MountedTree.overlay)
|
|
1778
|
-
/// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
|
|
1779
|
-
/// set to false.
|
|
1780
|
-
enter(pos, side, mode = this.mode) {
|
|
1781
|
-
if (!this.buffer)
|
|
1782
|
-
return this.yield(this._tree.enter(pos, side, mode));
|
|
1783
|
-
return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
|
|
1784
|
-
}
|
|
1785
|
-
/// Move to the node's parent node, if this isn't the top node.
|
|
1786
|
-
parent() {
|
|
1787
|
-
if (!this.buffer)
|
|
1788
|
-
return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
|
|
1789
|
-
if (this.stack.length)
|
|
1790
|
-
return this.yieldBuf(this.stack.pop());
|
|
1791
|
-
let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
|
|
1792
|
-
this.buffer = null;
|
|
1793
|
-
return this.yieldNode(parent);
|
|
1794
|
-
}
|
|
1795
|
-
/// @internal
|
|
1796
|
-
sibling(dir) {
|
|
1797
|
-
if (!this.buffer)
|
|
1798
|
-
return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
|
|
1799
|
-
let { buffer } = this.buffer, d = this.stack.length - 1;
|
|
1800
|
-
if (dir < 0) {
|
|
1801
|
-
let parentStart = d < 0 ? 0 : this.stack[d] + 4;
|
|
1802
|
-
if (this.index != parentStart)
|
|
1803
|
-
return this.yieldBuf(buffer.findChild(
|
|
1804
|
-
parentStart,
|
|
1805
|
-
this.index,
|
|
1806
|
-
-1,
|
|
1807
|
-
0,
|
|
1808
|
-
4
|
|
1809
|
-
/* Side.DontCare */
|
|
1810
|
-
));
|
|
1811
|
-
} else {
|
|
1812
|
-
let after = buffer.buffer[this.index + 3];
|
|
1813
|
-
if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
|
|
1814
|
-
return this.yieldBuf(after);
|
|
1815
|
-
}
|
|
1816
|
-
return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
|
|
1817
|
-
}
|
|
1818
|
-
/// Move to this node's next sibling, if any.
|
|
1819
|
-
nextSibling() {
|
|
1820
|
-
return this.sibling(1);
|
|
1821
|
-
}
|
|
1822
|
-
/// Move to this node's previous sibling, if any.
|
|
1823
|
-
prevSibling() {
|
|
1824
|
-
return this.sibling(-1);
|
|
1825
|
-
}
|
|
1826
|
-
atLastNode(dir) {
|
|
1827
|
-
let index, parent, { buffer } = this;
|
|
1828
|
-
if (buffer) {
|
|
1829
|
-
if (dir > 0) {
|
|
1830
|
-
if (this.index < buffer.buffer.buffer.length)
|
|
1831
|
-
return false;
|
|
1832
|
-
} else {
|
|
1833
|
-
for (let i = 0; i < this.index; i++)
|
|
1834
|
-
if (buffer.buffer.buffer[i + 3] < this.index)
|
|
1835
|
-
return false;
|
|
1836
|
-
}
|
|
1837
|
-
({ index, parent } = buffer);
|
|
1838
|
-
} else {
|
|
1839
|
-
({ index, _parent: parent } = this._tree);
|
|
1840
|
-
}
|
|
1841
|
-
for (; parent; { index, _parent: parent } = parent) {
|
|
1842
|
-
if (index > -1)
|
|
1843
|
-
for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
|
|
1844
|
-
let child = parent._tree.children[i];
|
|
1845
|
-
if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child))
|
|
1846
|
-
return false;
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
return true;
|
|
1850
|
-
}
|
|
1851
|
-
move(dir, enter) {
|
|
1852
|
-
if (enter && this.enterChild(
|
|
1853
|
-
dir,
|
|
1854
|
-
0,
|
|
1855
|
-
4
|
|
1856
|
-
/* Side.DontCare */
|
|
1857
|
-
))
|
|
1858
|
-
return true;
|
|
1859
|
-
for (; ; ) {
|
|
1860
|
-
if (this.sibling(dir))
|
|
1861
|
-
return true;
|
|
1862
|
-
if (this.atLastNode(dir) || !this.parent())
|
|
1863
|
-
return false;
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
/// Move to the next node in a
|
|
1867
|
-
/// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
|
|
1868
|
-
/// traversal, going from a node to its first child or, if the
|
|
1869
|
-
/// current node is empty or `enter` is false, its next sibling or
|
|
1870
|
-
/// the next sibling of the first parent node that has one.
|
|
1871
|
-
next(enter = true) {
|
|
1872
|
-
return this.move(1, enter);
|
|
1873
|
-
}
|
|
1874
|
-
/// Move to the next node in a last-to-first pre-order traveral. A
|
|
1875
|
-
/// node is followed by its last child or, if it has none, its
|
|
1876
|
-
/// previous sibling or the previous sibling of the first parent
|
|
1877
|
-
/// node that has one.
|
|
1878
|
-
prev(enter = true) {
|
|
1879
|
-
return this.move(-1, enter);
|
|
1880
|
-
}
|
|
1881
|
-
/// Move the cursor to the innermost node that covers `pos`. If
|
|
1882
|
-
/// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
|
|
1883
|
-
/// it will enter nodes that start at `pos`.
|
|
1884
|
-
moveTo(pos, side = 0) {
|
|
1885
|
-
while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos))
|
|
1886
|
-
if (!this.parent())
|
|
1887
|
-
break;
|
|
1888
|
-
while (this.enterChild(1, pos, side)) {
|
|
1889
|
-
}
|
|
1890
|
-
return this;
|
|
1891
|
-
}
|
|
1892
|
-
/// Get a [syntax node](#common.SyntaxNode) at the cursor's current
|
|
1893
|
-
/// position.
|
|
1894
|
-
get node() {
|
|
1895
|
-
if (!this.buffer)
|
|
1896
|
-
return this._tree;
|
|
1897
|
-
let cache = this.bufferNode, result = null, depth = 0;
|
|
1898
|
-
if (cache && cache.context == this.buffer) {
|
|
1899
|
-
scan:
|
|
1900
|
-
for (let index = this.index, d = this.stack.length; d >= 0; ) {
|
|
1901
|
-
for (let c = cache; c; c = c._parent)
|
|
1902
|
-
if (c.index == index) {
|
|
1903
|
-
if (index == this.index)
|
|
1904
|
-
return c;
|
|
1905
|
-
result = c;
|
|
1906
|
-
depth = d + 1;
|
|
1907
|
-
break scan;
|
|
1908
|
-
}
|
|
1909
|
-
index = this.stack[--d];
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
for (let i = depth; i < this.stack.length; i++)
|
|
1913
|
-
result = new BufferNode(this.buffer, result, this.stack[i]);
|
|
1914
|
-
return this.bufferNode = new BufferNode(this.buffer, result, this.index);
|
|
1915
|
-
}
|
|
1916
|
-
/// Get the [tree](#common.Tree) that represents the current node, if
|
|
1917
|
-
/// any. Will return null when the node is in a [tree
|
|
1918
|
-
/// buffer](#common.TreeBuffer).
|
|
1919
|
-
get tree() {
|
|
1920
|
-
return this.buffer ? null : this._tree._tree;
|
|
1921
|
-
}
|
|
1922
|
-
/// Iterate over the current node and all its descendants, calling
|
|
1923
|
-
/// `enter` when entering a node and `leave`, if given, when leaving
|
|
1924
|
-
/// one. When `enter` returns `false`, any children of that node are
|
|
1925
|
-
/// skipped, and `leave` isn't called for it.
|
|
1926
|
-
iterate(enter, leave) {
|
|
1927
|
-
for (let depth = 0; ; ) {
|
|
1928
|
-
let mustLeave = false;
|
|
1929
|
-
if (this.type.isAnonymous || enter(this) !== false) {
|
|
1930
|
-
if (this.firstChild()) {
|
|
1931
|
-
depth++;
|
|
1932
|
-
continue;
|
|
1933
|
-
}
|
|
1934
|
-
if (!this.type.isAnonymous)
|
|
1935
|
-
mustLeave = true;
|
|
1936
|
-
}
|
|
1937
|
-
for (; ; ) {
|
|
1938
|
-
if (mustLeave && leave)
|
|
1939
|
-
leave(this);
|
|
1940
|
-
mustLeave = this.type.isAnonymous;
|
|
1941
|
-
if (this.nextSibling())
|
|
1942
|
-
break;
|
|
1943
|
-
if (!depth)
|
|
1944
|
-
return;
|
|
1945
|
-
this.parent();
|
|
1946
|
-
depth--;
|
|
1947
|
-
mustLeave = true;
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
/// Test whether the current node matches a given context—a sequence
|
|
1952
|
-
/// of direct parent node names. Empty strings in the context array
|
|
1953
|
-
/// are treated as wildcards.
|
|
1954
|
-
matchContext(context) {
|
|
1955
|
-
if (!this.buffer)
|
|
1956
|
-
return matchNodeContext(this.node, context);
|
|
1957
|
-
let { buffer } = this.buffer, { types } = buffer.set;
|
|
1958
|
-
for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
|
|
1959
|
-
if (d < 0)
|
|
1960
|
-
return matchNodeContext(this.node, context, i);
|
|
1961
|
-
let type = types[buffer.buffer[this.stack[d]]];
|
|
1962
|
-
if (!type.isAnonymous) {
|
|
1963
|
-
if (context[i] && context[i] != type.name)
|
|
1964
|
-
return false;
|
|
1965
|
-
i--;
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
return true;
|
|
1969
|
-
}
|
|
1970
|
-
};
|
|
1971
|
-
function hasChild(tree) {
|
|
1972
|
-
return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
|
|
1973
|
-
}
|
|
1974
|
-
function buildTree(data) {
|
|
1975
|
-
var _a;
|
|
1976
|
-
let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
|
|
1977
|
-
let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
|
|
1978
|
-
let types = nodeSet.types;
|
|
1979
|
-
let contextHash = 0, lookAhead = 0;
|
|
1980
|
-
function takeNode(parentStart, minPos, children2, positions2, inRepeat) {
|
|
1981
|
-
let { id, start, end, size } = cursor;
|
|
1982
|
-
let lookAheadAtStart = lookAhead;
|
|
1983
|
-
while (size < 0) {
|
|
1984
|
-
cursor.next();
|
|
1985
|
-
if (size == -1) {
|
|
1986
|
-
let node2 = reused[id];
|
|
1987
|
-
children2.push(node2);
|
|
1988
|
-
positions2.push(start - parentStart);
|
|
1989
|
-
return;
|
|
1990
|
-
} else if (size == -3) {
|
|
1991
|
-
contextHash = id;
|
|
1992
|
-
return;
|
|
1993
|
-
} else if (size == -4) {
|
|
1994
|
-
lookAhead = id;
|
|
1995
|
-
return;
|
|
1996
|
-
} else {
|
|
1997
|
-
throw new RangeError(`Unrecognized record size: ${size}`);
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
let type = types[id], node, buffer2;
|
|
2001
|
-
let startPos = start - parentStart;
|
|
2002
|
-
if (end - start <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
|
|
2003
|
-
let data2 = new Uint16Array(buffer2.size - buffer2.skip);
|
|
2004
|
-
let endPos = cursor.pos - buffer2.size, index = data2.length;
|
|
2005
|
-
while (cursor.pos > endPos)
|
|
2006
|
-
index = copyToBuffer(buffer2.start, data2, index);
|
|
2007
|
-
node = new TreeBuffer(data2, end - buffer2.start, nodeSet);
|
|
2008
|
-
startPos = buffer2.start - parentStart;
|
|
2009
|
-
} else {
|
|
2010
|
-
let endPos = cursor.pos - size;
|
|
2011
|
-
cursor.next();
|
|
2012
|
-
let localChildren = [], localPositions = [];
|
|
2013
|
-
let localInRepeat = id >= minRepeatType ? id : -1;
|
|
2014
|
-
let lastGroup = 0, lastEnd = end;
|
|
2015
|
-
while (cursor.pos > endPos) {
|
|
2016
|
-
if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
|
|
2017
|
-
if (cursor.end <= lastEnd - maxBufferLength) {
|
|
2018
|
-
makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
|
|
2019
|
-
lastGroup = localChildren.length;
|
|
2020
|
-
lastEnd = cursor.end;
|
|
2021
|
-
}
|
|
2022
|
-
cursor.next();
|
|
2023
|
-
} else {
|
|
2024
|
-
takeNode(start, endPos, localChildren, localPositions, localInRepeat);
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
|
|
2028
|
-
makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
|
|
2029
|
-
localChildren.reverse();
|
|
2030
|
-
localPositions.reverse();
|
|
2031
|
-
if (localInRepeat > -1 && lastGroup > 0) {
|
|
2032
|
-
let make = makeBalanced(type);
|
|
2033
|
-
node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
|
|
2034
|
-
} else {
|
|
2035
|
-
node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
children2.push(node);
|
|
2039
|
-
positions2.push(startPos);
|
|
2040
|
-
}
|
|
2041
|
-
function makeBalanced(type) {
|
|
2042
|
-
return (children2, positions2, length3) => {
|
|
2043
|
-
let lookAhead2 = 0, lastI = children2.length - 1, last2, lookAheadProp;
|
|
2044
|
-
if (lastI >= 0 && (last2 = children2[lastI]) instanceof Tree) {
|
|
2045
|
-
if (!lastI && last2.type == type && last2.length == length3)
|
|
2046
|
-
return last2;
|
|
2047
|
-
if (lookAheadProp = last2.prop(NodeProp.lookAhead))
|
|
2048
|
-
lookAhead2 = positions2[lastI] + last2.length + lookAheadProp;
|
|
2049
|
-
}
|
|
2050
|
-
return makeTree(type, children2, positions2, length3, lookAhead2);
|
|
2051
|
-
};
|
|
2052
|
-
}
|
|
2053
|
-
function makeRepeatLeaf(children2, positions2, base, i, from, to, type, lookAhead2) {
|
|
2054
|
-
let localChildren = [], localPositions = [];
|
|
2055
|
-
while (children2.length > i) {
|
|
2056
|
-
localChildren.push(children2.pop());
|
|
2057
|
-
localPositions.push(positions2.pop() + base - from);
|
|
2058
|
-
}
|
|
2059
|
-
children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to));
|
|
2060
|
-
positions2.push(from - base);
|
|
2061
|
-
}
|
|
2062
|
-
function makeTree(type, children2, positions2, length3, lookAhead2 = 0, props) {
|
|
2063
|
-
if (contextHash) {
|
|
2064
|
-
let pair2 = [NodeProp.contextHash, contextHash];
|
|
2065
|
-
props = props ? [pair2].concat(props) : [pair2];
|
|
2066
|
-
}
|
|
2067
|
-
if (lookAhead2 > 25) {
|
|
2068
|
-
let pair2 = [NodeProp.lookAhead, lookAhead2];
|
|
2069
|
-
props = props ? [pair2].concat(props) : [pair2];
|
|
2070
|
-
}
|
|
2071
|
-
return new Tree(type, children2, positions2, length3, props);
|
|
2072
|
-
}
|
|
2073
|
-
function findBufferSize(maxSize, inRepeat) {
|
|
2074
|
-
let fork = cursor.fork();
|
|
2075
|
-
let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
|
|
2076
|
-
let result = { size: 0, start: 0, skip: 0 };
|
|
2077
|
-
scan:
|
|
2078
|
-
for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
|
|
2079
|
-
let nodeSize2 = fork.size;
|
|
2080
|
-
if (fork.id == inRepeat && nodeSize2 >= 0) {
|
|
2081
|
-
result.size = size;
|
|
2082
|
-
result.start = start;
|
|
2083
|
-
result.skip = skip;
|
|
2084
|
-
skip += 4;
|
|
2085
|
-
size += 4;
|
|
2086
|
-
fork.next();
|
|
2087
|
-
continue;
|
|
2088
|
-
}
|
|
2089
|
-
let startPos = fork.pos - nodeSize2;
|
|
2090
|
-
if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
|
|
2091
|
-
break;
|
|
2092
|
-
let localSkipped = fork.id >= minRepeatType ? 4 : 0;
|
|
2093
|
-
let nodeStart = fork.start;
|
|
2094
|
-
fork.next();
|
|
2095
|
-
while (fork.pos > startPos) {
|
|
2096
|
-
if (fork.size < 0) {
|
|
2097
|
-
if (fork.size == -3)
|
|
2098
|
-
localSkipped += 4;
|
|
2099
|
-
else
|
|
2100
|
-
break scan;
|
|
2101
|
-
} else if (fork.id >= minRepeatType) {
|
|
2102
|
-
localSkipped += 4;
|
|
2103
|
-
}
|
|
2104
|
-
fork.next();
|
|
2105
|
-
}
|
|
2106
|
-
start = nodeStart;
|
|
2107
|
-
size += nodeSize2;
|
|
2108
|
-
skip += localSkipped;
|
|
2109
|
-
}
|
|
2110
|
-
if (inRepeat < 0 || size == maxSize) {
|
|
2111
|
-
result.size = size;
|
|
2112
|
-
result.start = start;
|
|
2113
|
-
result.skip = skip;
|
|
2114
|
-
}
|
|
2115
|
-
return result.size > 4 ? result : void 0;
|
|
2116
|
-
}
|
|
2117
|
-
function copyToBuffer(bufferStart, buffer2, index) {
|
|
2118
|
-
let { id, start, end, size } = cursor;
|
|
2119
|
-
cursor.next();
|
|
2120
|
-
if (size >= 0 && id < minRepeatType) {
|
|
2121
|
-
let startIndex = index;
|
|
2122
|
-
if (size > 4) {
|
|
2123
|
-
let endPos = cursor.pos - (size - 4);
|
|
2124
|
-
while (cursor.pos > endPos)
|
|
2125
|
-
index = copyToBuffer(bufferStart, buffer2, index);
|
|
2126
|
-
}
|
|
2127
|
-
buffer2[--index] = startIndex;
|
|
2128
|
-
buffer2[--index] = end - bufferStart;
|
|
2129
|
-
buffer2[--index] = start - bufferStart;
|
|
2130
|
-
buffer2[--index] = id;
|
|
2131
|
-
} else if (size == -3) {
|
|
2132
|
-
contextHash = id;
|
|
2133
|
-
} else if (size == -4) {
|
|
2134
|
-
lookAhead = id;
|
|
2135
|
-
}
|
|
2136
|
-
return index;
|
|
2137
|
-
}
|
|
2138
|
-
let children = [], positions = [];
|
|
2139
|
-
while (cursor.pos > 0)
|
|
2140
|
-
takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
|
|
2141
|
-
let length2 = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
|
|
2142
|
-
return new Tree(types[data.topID], children.reverse(), positions.reverse(), length2);
|
|
2143
|
-
}
|
|
2144
|
-
var nodeSizeCache = /* @__PURE__ */ new WeakMap();
|
|
2145
|
-
function nodeSize(balanceType, node) {
|
|
2146
|
-
if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
|
|
2147
|
-
return 1;
|
|
2148
|
-
let size = nodeSizeCache.get(node);
|
|
2149
|
-
if (size == null) {
|
|
2150
|
-
size = 1;
|
|
2151
|
-
for (let child of node.children) {
|
|
2152
|
-
if (child.type != balanceType || !(child instanceof Tree)) {
|
|
2153
|
-
size = 1;
|
|
2154
|
-
break;
|
|
2155
|
-
}
|
|
2156
|
-
size += nodeSize(balanceType, child);
|
|
2157
|
-
}
|
|
2158
|
-
nodeSizeCache.set(node, size);
|
|
2159
|
-
}
|
|
2160
|
-
return size;
|
|
2161
|
-
}
|
|
2162
|
-
function balanceRange(balanceType, children, positions, from, to, start, length2, mkTop, mkTree) {
|
|
2163
|
-
let total = 0;
|
|
2164
|
-
for (let i = from; i < to; i++)
|
|
2165
|
-
total += nodeSize(balanceType, children[i]);
|
|
2166
|
-
let maxChild = Math.ceil(
|
|
2167
|
-
total * 1.5 / 8
|
|
2168
|
-
/* Balance.BranchFactor */
|
|
2169
|
-
);
|
|
2170
|
-
let localChildren = [], localPositions = [];
|
|
2171
|
-
function divide(children2, positions2, from2, to2, offset) {
|
|
2172
|
-
for (let i = from2; i < to2; ) {
|
|
2173
|
-
let groupFrom = i, groupStart = positions2[i], groupSize = nodeSize(balanceType, children2[i]);
|
|
2174
|
-
i++;
|
|
2175
|
-
for (; i < to2; i++) {
|
|
2176
|
-
let nextSize = nodeSize(balanceType, children2[i]);
|
|
2177
|
-
if (groupSize + nextSize >= maxChild)
|
|
2178
|
-
break;
|
|
2179
|
-
groupSize += nextSize;
|
|
2180
|
-
}
|
|
2181
|
-
if (i == groupFrom + 1) {
|
|
2182
|
-
if (groupSize > maxChild) {
|
|
2183
|
-
let only = children2[groupFrom];
|
|
2184
|
-
divide(only.children, only.positions, 0, only.children.length, positions2[groupFrom] + offset);
|
|
2185
|
-
continue;
|
|
2186
|
-
}
|
|
2187
|
-
localChildren.push(children2[groupFrom]);
|
|
2188
|
-
} else {
|
|
2189
|
-
let length3 = positions2[i - 1] + children2[i - 1].length - groupStart;
|
|
2190
|
-
localChildren.push(balanceRange(balanceType, children2, positions2, groupFrom, i, groupStart, length3, null, mkTree));
|
|
2191
|
-
}
|
|
2192
|
-
localPositions.push(groupStart + offset - start);
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
divide(children, positions, from, to, 0);
|
|
2196
|
-
return (mkTop || mkTree)(localChildren, localPositions, length2);
|
|
2197
|
-
}
|
|
2198
|
-
var Parser = class {
|
|
2199
|
-
/// Start a parse, returning a [partial parse](#common.PartialParse)
|
|
2200
|
-
/// object. [`fragments`](#common.TreeFragment) can be passed in to
|
|
2201
|
-
/// make the parse incremental.
|
|
2202
|
-
///
|
|
2203
|
-
/// By default, the entire input is parsed. You can pass `ranges`,
|
|
2204
|
-
/// which should be a sorted array of non-empty, non-overlapping
|
|
2205
|
-
/// ranges, to parse only those ranges. The tree returned in that
|
|
2206
|
-
/// case will start at `ranges[0].from`.
|
|
2207
|
-
startParse(input, fragments, ranges) {
|
|
2208
|
-
if (typeof input == "string")
|
|
2209
|
-
input = new StringInput(input);
|
|
2210
|
-
ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
|
|
2211
|
-
return this.createParse(input, fragments || [], ranges);
|
|
2212
|
-
}
|
|
2213
|
-
/// Run a full parse, returning the resulting tree.
|
|
2214
|
-
parse(input, fragments, ranges) {
|
|
2215
|
-
let parse = this.startParse(input, fragments, ranges);
|
|
2216
|
-
for (; ; ) {
|
|
2217
|
-
let done = parse.advance();
|
|
2218
|
-
if (done)
|
|
2219
|
-
return done;
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
};
|
|
2223
|
-
var StringInput = class {
|
|
2224
|
-
constructor(string) {
|
|
2225
|
-
this.string = string;
|
|
2226
|
-
}
|
|
2227
|
-
get length() {
|
|
2228
|
-
return this.string.length;
|
|
2229
|
-
}
|
|
2230
|
-
chunk(from) {
|
|
2231
|
-
return this.string.slice(from);
|
|
2232
|
-
}
|
|
2233
|
-
get lineChunks() {
|
|
2234
|
-
return false;
|
|
2235
|
-
}
|
|
2236
|
-
read(from, to) {
|
|
2237
|
-
return this.string.slice(from, to);
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
var stoppedInner = new NodeProp({ perNode: true });
|
|
2241
|
-
|
|
2242
|
-
// ../../node_modules/@lezer/lr/dist/index.js
|
|
2243
|
-
var Stack = class _Stack {
|
|
2244
|
-
/// @internal
|
|
2245
|
-
constructor(p, stack, state, reducePos, pos, score, buffer, bufferBase, curContext, lookAhead = 0, parent) {
|
|
2246
|
-
this.p = p;
|
|
2247
|
-
this.stack = stack;
|
|
2248
|
-
this.state = state;
|
|
2249
|
-
this.reducePos = reducePos;
|
|
2250
|
-
this.pos = pos;
|
|
2251
|
-
this.score = score;
|
|
2252
|
-
this.buffer = buffer;
|
|
2253
|
-
this.bufferBase = bufferBase;
|
|
2254
|
-
this.curContext = curContext;
|
|
2255
|
-
this.lookAhead = lookAhead;
|
|
2256
|
-
this.parent = parent;
|
|
2257
|
-
}
|
|
2258
|
-
/// @internal
|
|
2259
|
-
toString() {
|
|
2260
|
-
return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
|
|
2261
|
-
}
|
|
2262
|
-
// Start an empty stack
|
|
2263
|
-
/// @internal
|
|
2264
|
-
static start(p, state, pos = 0) {
|
|
2265
|
-
let cx = p.parser.context;
|
|
2266
|
-
return new _Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
|
|
2267
|
-
}
|
|
2268
|
-
/// The stack's current [context](#lr.ContextTracker) value, if
|
|
2269
|
-
/// any. Its type will depend on the context tracker's type
|
|
2270
|
-
/// parameter, or it will be `null` if there is no context
|
|
2271
|
-
/// tracker.
|
|
2272
|
-
get context() {
|
|
2273
|
-
return this.curContext ? this.curContext.context : null;
|
|
2274
|
-
}
|
|
2275
|
-
// Push a state onto the stack, tracking its start position as well
|
|
2276
|
-
// as the buffer base at that point.
|
|
2277
|
-
/// @internal
|
|
2278
|
-
pushState(state, start) {
|
|
2279
|
-
this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
|
|
2280
|
-
this.state = state;
|
|
2281
|
-
}
|
|
2282
|
-
// Apply a reduce action
|
|
2283
|
-
/// @internal
|
|
2284
|
-
reduce(action) {
|
|
2285
|
-
var _a;
|
|
2286
|
-
let depth = action >> 19, type = action & 65535;
|
|
2287
|
-
let { parser: parser2 } = this.p;
|
|
2288
|
-
let dPrec = parser2.dynamicPrecedence(type);
|
|
2289
|
-
if (dPrec)
|
|
2290
|
-
this.score += dPrec;
|
|
2291
|
-
if (depth == 0) {
|
|
2292
|
-
this.pushState(parser2.getGoto(this.state, type, true), this.reducePos);
|
|
2293
|
-
if (type < parser2.minRepeatTerm)
|
|
2294
|
-
this.storeNode(type, this.reducePos, this.reducePos, 4, true);
|
|
2295
|
-
this.reduceContext(type, this.reducePos);
|
|
2296
|
-
return;
|
|
2297
|
-
}
|
|
2298
|
-
let base = this.stack.length - (depth - 1) * 3 - (action & 262144 ? 6 : 0);
|
|
2299
|
-
let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start;
|
|
2300
|
-
if (size >= 2e3 && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) {
|
|
2301
|
-
if (start == this.p.lastBigReductionStart) {
|
|
2302
|
-
this.p.bigReductionCount++;
|
|
2303
|
-
this.p.lastBigReductionSize = size;
|
|
2304
|
-
} else if (this.p.lastBigReductionSize < size) {
|
|
2305
|
-
this.p.bigReductionCount = 1;
|
|
2306
|
-
this.p.lastBigReductionStart = start;
|
|
2307
|
-
this.p.lastBigReductionSize = size;
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
|
|
2311
|
-
if (type < parser2.minRepeatTerm || action & 131072) {
|
|
2312
|
-
let pos = parser2.stateFlag(
|
|
2313
|
-
this.state,
|
|
2314
|
-
1
|
|
2315
|
-
/* StateFlag.Skipped */
|
|
2316
|
-
) ? this.pos : this.reducePos;
|
|
2317
|
-
this.storeNode(type, start, pos, count + 4, true);
|
|
2318
|
-
}
|
|
2319
|
-
if (action & 262144) {
|
|
2320
|
-
this.state = this.stack[base];
|
|
2321
|
-
} else {
|
|
2322
|
-
let baseStateID = this.stack[base - 3];
|
|
2323
|
-
this.state = parser2.getGoto(baseStateID, type, true);
|
|
2324
|
-
}
|
|
2325
|
-
while (this.stack.length > base)
|
|
2326
|
-
this.stack.pop();
|
|
2327
|
-
this.reduceContext(type, start);
|
|
2328
|
-
}
|
|
2329
|
-
// Shift a value into the buffer
|
|
2330
|
-
/// @internal
|
|
2331
|
-
storeNode(term, start, end, size = 4, isReduce = false) {
|
|
2332
|
-
if (term == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
|
|
2333
|
-
let cur = this, top = this.buffer.length;
|
|
2334
|
-
if (top == 0 && cur.parent) {
|
|
2335
|
-
top = cur.bufferBase - cur.parent.bufferBase;
|
|
2336
|
-
cur = cur.parent;
|
|
2337
|
-
}
|
|
2338
|
-
if (top > 0 && cur.buffer[top - 4] == 0 && cur.buffer[top - 1] > -1) {
|
|
2339
|
-
if (start == end)
|
|
2340
|
-
return;
|
|
2341
|
-
if (cur.buffer[top - 2] >= start) {
|
|
2342
|
-
cur.buffer[top - 2] = end;
|
|
2343
|
-
return;
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
if (!isReduce || this.pos == end) {
|
|
2348
|
-
this.buffer.push(term, start, end, size);
|
|
2349
|
-
} else {
|
|
2350
|
-
let index = this.buffer.length;
|
|
2351
|
-
if (index > 0 && this.buffer[index - 4] != 0)
|
|
2352
|
-
while (index > 0 && this.buffer[index - 2] > end) {
|
|
2353
|
-
this.buffer[index] = this.buffer[index - 4];
|
|
2354
|
-
this.buffer[index + 1] = this.buffer[index - 3];
|
|
2355
|
-
this.buffer[index + 2] = this.buffer[index - 2];
|
|
2356
|
-
this.buffer[index + 3] = this.buffer[index - 1];
|
|
2357
|
-
index -= 4;
|
|
2358
|
-
if (size > 4)
|
|
2359
|
-
size -= 4;
|
|
2360
|
-
}
|
|
2361
|
-
this.buffer[index] = term;
|
|
2362
|
-
this.buffer[index + 1] = start;
|
|
2363
|
-
this.buffer[index + 2] = end;
|
|
2364
|
-
this.buffer[index + 3] = size;
|
|
2365
|
-
}
|
|
2366
|
-
}
|
|
2367
|
-
// Apply a shift action
|
|
2368
|
-
/// @internal
|
|
2369
|
-
shift(action, next, nextEnd) {
|
|
2370
|
-
let start = this.pos;
|
|
2371
|
-
if (action & 131072) {
|
|
2372
|
-
this.pushState(action & 65535, this.pos);
|
|
2373
|
-
} else if ((action & 262144) == 0) {
|
|
2374
|
-
let nextState = action, { parser: parser2 } = this.p;
|
|
2375
|
-
if (nextEnd > this.pos || next <= parser2.maxNode) {
|
|
2376
|
-
this.pos = nextEnd;
|
|
2377
|
-
if (!parser2.stateFlag(
|
|
2378
|
-
nextState,
|
|
2379
|
-
1
|
|
2380
|
-
/* StateFlag.Skipped */
|
|
2381
|
-
))
|
|
2382
|
-
this.reducePos = nextEnd;
|
|
2383
|
-
}
|
|
2384
|
-
this.pushState(nextState, start);
|
|
2385
|
-
this.shiftContext(next, start);
|
|
2386
|
-
if (next <= parser2.maxNode)
|
|
2387
|
-
this.buffer.push(next, start, nextEnd, 4);
|
|
2388
|
-
} else {
|
|
2389
|
-
this.pos = nextEnd;
|
|
2390
|
-
this.shiftContext(next, start);
|
|
2391
|
-
if (next <= this.p.parser.maxNode)
|
|
2392
|
-
this.buffer.push(next, start, nextEnd, 4);
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
// Apply an action
|
|
2396
|
-
/// @internal
|
|
2397
|
-
apply(action, next, nextEnd) {
|
|
2398
|
-
if (action & 65536)
|
|
2399
|
-
this.reduce(action);
|
|
2400
|
-
else
|
|
2401
|
-
this.shift(action, next, nextEnd);
|
|
2402
|
-
}
|
|
2403
|
-
// Add a prebuilt (reused) node into the buffer.
|
|
2404
|
-
/// @internal
|
|
2405
|
-
useNode(value, next) {
|
|
2406
|
-
let index = this.p.reused.length - 1;
|
|
2407
|
-
if (index < 0 || this.p.reused[index] != value) {
|
|
2408
|
-
this.p.reused.push(value);
|
|
2409
|
-
index++;
|
|
2410
|
-
}
|
|
2411
|
-
let start = this.pos;
|
|
2412
|
-
this.reducePos = this.pos = start + value.length;
|
|
2413
|
-
this.pushState(next, start);
|
|
2414
|
-
this.buffer.push(
|
|
2415
|
-
index,
|
|
2416
|
-
start,
|
|
2417
|
-
this.reducePos,
|
|
2418
|
-
-1
|
|
2419
|
-
/* size == -1 means this is a reused value */
|
|
2420
|
-
);
|
|
2421
|
-
if (this.curContext)
|
|
2422
|
-
this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
|
|
2423
|
-
}
|
|
2424
|
-
// Split the stack. Due to the buffer sharing and the fact
|
|
2425
|
-
// that `this.stack` tends to stay quite shallow, this isn't very
|
|
2426
|
-
// expensive.
|
|
2427
|
-
/// @internal
|
|
2428
|
-
split() {
|
|
2429
|
-
let parent = this;
|
|
2430
|
-
let off = parent.buffer.length;
|
|
2431
|
-
while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
|
|
2432
|
-
off -= 4;
|
|
2433
|
-
let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
|
|
2434
|
-
while (parent && base == parent.bufferBase)
|
|
2435
|
-
parent = parent.parent;
|
|
2436
|
-
return new _Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
|
|
2437
|
-
}
|
|
2438
|
-
// Try to recover from an error by 'deleting' (ignoring) one token.
|
|
2439
|
-
/// @internal
|
|
2440
|
-
recoverByDelete(next, nextEnd) {
|
|
2441
|
-
let isNode = next <= this.p.parser.maxNode;
|
|
2442
|
-
if (isNode)
|
|
2443
|
-
this.storeNode(next, this.pos, nextEnd, 4);
|
|
2444
|
-
this.storeNode(0, this.pos, nextEnd, isNode ? 8 : 4);
|
|
2445
|
-
this.pos = this.reducePos = nextEnd;
|
|
2446
|
-
this.score -= 190;
|
|
2447
|
-
}
|
|
2448
|
-
/// Check if the given term would be able to be shifted (optionally
|
|
2449
|
-
/// after some reductions) on this stack. This can be useful for
|
|
2450
|
-
/// external tokenizers that want to make sure they only provide a
|
|
2451
|
-
/// given token when it applies.
|
|
2452
|
-
canShift(term) {
|
|
2453
|
-
for (let sim = new SimulatedStack(this); ; ) {
|
|
2454
|
-
let action = this.p.parser.stateSlot(
|
|
2455
|
-
sim.state,
|
|
2456
|
-
4
|
|
2457
|
-
/* ParseState.DefaultReduce */
|
|
2458
|
-
) || this.p.parser.hasAction(sim.state, term);
|
|
2459
|
-
if (action == 0)
|
|
2460
|
-
return false;
|
|
2461
|
-
if ((action & 65536) == 0)
|
|
2462
|
-
return true;
|
|
2463
|
-
sim.reduce(action);
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
// Apply up to Recover.MaxNext recovery actions that conceptually
|
|
2467
|
-
// inserts some missing token or rule.
|
|
2468
|
-
/// @internal
|
|
2469
|
-
recoverByInsert(next) {
|
|
2470
|
-
if (this.stack.length >= 300)
|
|
2471
|
-
return [];
|
|
2472
|
-
let nextStates = this.p.parser.nextStates(this.state);
|
|
2473
|
-
if (nextStates.length > 4 << 1 || this.stack.length >= 120) {
|
|
2474
|
-
let best = [];
|
|
2475
|
-
for (let i = 0, s; i < nextStates.length; i += 2) {
|
|
2476
|
-
if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
|
|
2477
|
-
best.push(nextStates[i], s);
|
|
2478
|
-
}
|
|
2479
|
-
if (this.stack.length < 120)
|
|
2480
|
-
for (let i = 0; best.length < 4 << 1 && i < nextStates.length; i += 2) {
|
|
2481
|
-
let s = nextStates[i + 1];
|
|
2482
|
-
if (!best.some((v, i2) => i2 & 1 && v == s))
|
|
2483
|
-
best.push(nextStates[i], s);
|
|
2484
|
-
}
|
|
2485
|
-
nextStates = best;
|
|
2486
|
-
}
|
|
2487
|
-
let result = [];
|
|
2488
|
-
for (let i = 0; i < nextStates.length && result.length < 4; i += 2) {
|
|
2489
|
-
let s = nextStates[i + 1];
|
|
2490
|
-
if (s == this.state)
|
|
2491
|
-
continue;
|
|
2492
|
-
let stack = this.split();
|
|
2493
|
-
stack.pushState(s, this.pos);
|
|
2494
|
-
stack.storeNode(0, stack.pos, stack.pos, 4, true);
|
|
2495
|
-
stack.shiftContext(nextStates[i], this.pos);
|
|
2496
|
-
stack.score -= 200;
|
|
2497
|
-
result.push(stack);
|
|
2498
|
-
}
|
|
2499
|
-
return result;
|
|
2500
|
-
}
|
|
2501
|
-
// Force a reduce, if possible. Return false if that can't
|
|
2502
|
-
// be done.
|
|
2503
|
-
/// @internal
|
|
2504
|
-
forceReduce() {
|
|
2505
|
-
let { parser: parser2 } = this.p;
|
|
2506
|
-
let reduce = parser2.stateSlot(
|
|
2507
|
-
this.state,
|
|
2508
|
-
5
|
|
2509
|
-
/* ParseState.ForcedReduce */
|
|
2510
|
-
);
|
|
2511
|
-
if ((reduce & 65536) == 0)
|
|
2512
|
-
return false;
|
|
2513
|
-
if (!parser2.validAction(this.state, reduce)) {
|
|
2514
|
-
let depth = reduce >> 19, term = reduce & 65535;
|
|
2515
|
-
let target = this.stack.length - depth * 3;
|
|
2516
|
-
if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0) {
|
|
2517
|
-
let backup = this.findForcedReduction();
|
|
2518
|
-
if (backup == null)
|
|
2519
|
-
return false;
|
|
2520
|
-
reduce = backup;
|
|
2521
|
-
}
|
|
2522
|
-
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
2523
|
-
this.score -= 100;
|
|
2524
|
-
}
|
|
2525
|
-
this.reducePos = this.pos;
|
|
2526
|
-
this.reduce(reduce);
|
|
2527
|
-
return true;
|
|
2528
|
-
}
|
|
2529
|
-
/// Try to scan through the automaton to find some kind of reduction
|
|
2530
|
-
/// that can be applied. Used when the regular ForcedReduce field
|
|
2531
|
-
/// isn't a valid action. @internal
|
|
2532
|
-
findForcedReduction() {
|
|
2533
|
-
let { parser: parser2 } = this.p, seen = [];
|
|
2534
|
-
let explore = (state, depth) => {
|
|
2535
|
-
if (seen.includes(state))
|
|
2536
|
-
return;
|
|
2537
|
-
seen.push(state);
|
|
2538
|
-
return parser2.allActions(state, (action) => {
|
|
2539
|
-
if (action & (262144 | 131072))
|
|
2540
|
-
;
|
|
2541
|
-
else if (action & 65536) {
|
|
2542
|
-
let rDepth = (action >> 19) - depth;
|
|
2543
|
-
if (rDepth > 1) {
|
|
2544
|
-
let term = action & 65535, target = this.stack.length - rDepth * 3;
|
|
2545
|
-
if (target >= 0 && parser2.getGoto(this.stack[target], term, false) >= 0)
|
|
2546
|
-
return rDepth << 19 | 65536 | term;
|
|
2547
|
-
}
|
|
2548
|
-
} else {
|
|
2549
|
-
let found = explore(action, depth + 1);
|
|
2550
|
-
if (found != null)
|
|
2551
|
-
return found;
|
|
2552
|
-
}
|
|
2553
|
-
});
|
|
2554
|
-
};
|
|
2555
|
-
return explore(this.state, 0);
|
|
2556
|
-
}
|
|
2557
|
-
/// @internal
|
|
2558
|
-
forceAll() {
|
|
2559
|
-
while (!this.p.parser.stateFlag(
|
|
2560
|
-
this.state,
|
|
2561
|
-
2
|
|
2562
|
-
/* StateFlag.Accepting */
|
|
2563
|
-
)) {
|
|
2564
|
-
if (!this.forceReduce()) {
|
|
2565
|
-
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
2566
|
-
break;
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
return this;
|
|
2570
|
-
}
|
|
2571
|
-
/// Check whether this state has no further actions (assumed to be a direct descendant of the
|
|
2572
|
-
/// top state, since any other states must be able to continue
|
|
2573
|
-
/// somehow). @internal
|
|
2574
|
-
get deadEnd() {
|
|
2575
|
-
if (this.stack.length != 3)
|
|
2576
|
-
return false;
|
|
2577
|
-
let { parser: parser2 } = this.p;
|
|
2578
|
-
return parser2.data[parser2.stateSlot(
|
|
2579
|
-
this.state,
|
|
2580
|
-
1
|
|
2581
|
-
/* ParseState.Actions */
|
|
2582
|
-
)] == 65535 && !parser2.stateSlot(
|
|
2583
|
-
this.state,
|
|
2584
|
-
4
|
|
2585
|
-
/* ParseState.DefaultReduce */
|
|
2586
|
-
);
|
|
2587
|
-
}
|
|
2588
|
-
/// Restart the stack (put it back in its start state). Only safe
|
|
2589
|
-
/// when this.stack.length == 3 (state is directly below the top
|
|
2590
|
-
/// state). @internal
|
|
2591
|
-
restart() {
|
|
2592
|
-
this.state = this.stack[0];
|
|
2593
|
-
this.stack.length = 0;
|
|
2594
|
-
}
|
|
2595
|
-
/// @internal
|
|
2596
|
-
sameState(other) {
|
|
2597
|
-
if (this.state != other.state || this.stack.length != other.stack.length)
|
|
2598
|
-
return false;
|
|
2599
|
-
for (let i = 0; i < this.stack.length; i += 3)
|
|
2600
|
-
if (this.stack[i] != other.stack[i])
|
|
2601
|
-
return false;
|
|
2602
|
-
return true;
|
|
2603
|
-
}
|
|
2604
|
-
/// Get the parser used by this stack.
|
|
2605
|
-
get parser() {
|
|
2606
|
-
return this.p.parser;
|
|
2607
|
-
}
|
|
2608
|
-
/// Test whether a given dialect (by numeric ID, as exported from
|
|
2609
|
-
/// the terms file) is enabled.
|
|
2610
|
-
dialectEnabled(dialectID) {
|
|
2611
|
-
return this.p.parser.dialect.flags[dialectID];
|
|
2612
|
-
}
|
|
2613
|
-
shiftContext(term, start) {
|
|
2614
|
-
if (this.curContext)
|
|
2615
|
-
this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
|
|
2616
|
-
}
|
|
2617
|
-
reduceContext(term, start) {
|
|
2618
|
-
if (this.curContext)
|
|
2619
|
-
this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
|
|
2620
|
-
}
|
|
2621
|
-
/// @internal
|
|
2622
|
-
emitContext() {
|
|
2623
|
-
let last2 = this.buffer.length - 1;
|
|
2624
|
-
if (last2 < 0 || this.buffer[last2] != -3)
|
|
2625
|
-
this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
|
|
2626
|
-
}
|
|
2627
|
-
/// @internal
|
|
2628
|
-
emitLookAhead() {
|
|
2629
|
-
let last2 = this.buffer.length - 1;
|
|
2630
|
-
if (last2 < 0 || this.buffer[last2] != -4)
|
|
2631
|
-
this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
|
|
2632
|
-
}
|
|
2633
|
-
updateContext(context) {
|
|
2634
|
-
if (context != this.curContext.context) {
|
|
2635
|
-
let newCx = new StackContext(this.curContext.tracker, context);
|
|
2636
|
-
if (newCx.hash != this.curContext.hash)
|
|
2637
|
-
this.emitContext();
|
|
2638
|
-
this.curContext = newCx;
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
/// @internal
|
|
2642
|
-
setLookAhead(lookAhead) {
|
|
2643
|
-
if (lookAhead > this.lookAhead) {
|
|
2644
|
-
this.emitLookAhead();
|
|
2645
|
-
this.lookAhead = lookAhead;
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
/// @internal
|
|
2649
|
-
close() {
|
|
2650
|
-
if (this.curContext && this.curContext.tracker.strict)
|
|
2651
|
-
this.emitContext();
|
|
2652
|
-
if (this.lookAhead > 0)
|
|
2653
|
-
this.emitLookAhead();
|
|
2654
|
-
}
|
|
2655
|
-
};
|
|
2656
|
-
var StackContext = class {
|
|
2657
|
-
constructor(tracker, context) {
|
|
2658
|
-
this.tracker = tracker;
|
|
2659
|
-
this.context = context;
|
|
2660
|
-
this.hash = tracker.strict ? tracker.hash(context) : 0;
|
|
2661
|
-
}
|
|
2662
|
-
};
|
|
2663
|
-
var Recover;
|
|
2664
|
-
(function(Recover2) {
|
|
2665
|
-
Recover2[Recover2["Insert"] = 200] = "Insert";
|
|
2666
|
-
Recover2[Recover2["Delete"] = 190] = "Delete";
|
|
2667
|
-
Recover2[Recover2["Reduce"] = 100] = "Reduce";
|
|
2668
|
-
Recover2[Recover2["MaxNext"] = 4] = "MaxNext";
|
|
2669
|
-
Recover2[Recover2["MaxInsertStackDepth"] = 300] = "MaxInsertStackDepth";
|
|
2670
|
-
Recover2[Recover2["DampenInsertStackDepth"] = 120] = "DampenInsertStackDepth";
|
|
2671
|
-
Recover2[Recover2["MinBigReduction"] = 2e3] = "MinBigReduction";
|
|
2672
|
-
})(Recover || (Recover = {}));
|
|
2673
|
-
var SimulatedStack = class {
|
|
2674
|
-
constructor(start) {
|
|
2675
|
-
this.start = start;
|
|
2676
|
-
this.state = start.state;
|
|
2677
|
-
this.stack = start.stack;
|
|
2678
|
-
this.base = this.stack.length;
|
|
2679
|
-
}
|
|
2680
|
-
reduce(action) {
|
|
2681
|
-
let term = action & 65535, depth = action >> 19;
|
|
2682
|
-
if (depth == 0) {
|
|
2683
|
-
if (this.stack == this.start.stack)
|
|
2684
|
-
this.stack = this.stack.slice();
|
|
2685
|
-
this.stack.push(this.state, 0, 0);
|
|
2686
|
-
this.base += 3;
|
|
2687
|
-
} else {
|
|
2688
|
-
this.base -= (depth - 1) * 3;
|
|
2689
|
-
}
|
|
2690
|
-
let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
|
|
2691
|
-
this.state = goto;
|
|
2692
|
-
}
|
|
2693
|
-
};
|
|
2694
|
-
var StackBufferCursor = class _StackBufferCursor {
|
|
2695
|
-
constructor(stack, pos, index) {
|
|
2696
|
-
this.stack = stack;
|
|
2697
|
-
this.pos = pos;
|
|
2698
|
-
this.index = index;
|
|
2699
|
-
this.buffer = stack.buffer;
|
|
2700
|
-
if (this.index == 0)
|
|
2701
|
-
this.maybeNext();
|
|
2702
|
-
}
|
|
2703
|
-
static create(stack, pos = stack.bufferBase + stack.buffer.length) {
|
|
2704
|
-
return new _StackBufferCursor(stack, pos, pos - stack.bufferBase);
|
|
2705
|
-
}
|
|
2706
|
-
maybeNext() {
|
|
2707
|
-
let next = this.stack.parent;
|
|
2708
|
-
if (next != null) {
|
|
2709
|
-
this.index = this.stack.bufferBase - next.bufferBase;
|
|
2710
|
-
this.stack = next;
|
|
2711
|
-
this.buffer = next.buffer;
|
|
2712
|
-
}
|
|
2713
|
-
}
|
|
2714
|
-
get id() {
|
|
2715
|
-
return this.buffer[this.index - 4];
|
|
2716
|
-
}
|
|
2717
|
-
get start() {
|
|
2718
|
-
return this.buffer[this.index - 3];
|
|
2719
|
-
}
|
|
2720
|
-
get end() {
|
|
2721
|
-
return this.buffer[this.index - 2];
|
|
2722
|
-
}
|
|
2723
|
-
get size() {
|
|
2724
|
-
return this.buffer[this.index - 1];
|
|
2725
|
-
}
|
|
2726
|
-
next() {
|
|
2727
|
-
this.index -= 4;
|
|
2728
|
-
this.pos -= 4;
|
|
2729
|
-
if (this.index == 0)
|
|
2730
|
-
this.maybeNext();
|
|
2731
|
-
}
|
|
2732
|
-
fork() {
|
|
2733
|
-
return new _StackBufferCursor(this.stack, this.pos, this.index);
|
|
2734
|
-
}
|
|
2735
|
-
};
|
|
2736
|
-
function decodeArray(input, Type = Uint16Array) {
|
|
2737
|
-
if (typeof input != "string")
|
|
2738
|
-
return input;
|
|
2739
|
-
let array = null;
|
|
2740
|
-
for (let pos = 0, out = 0; pos < input.length; ) {
|
|
2741
|
-
let value = 0;
|
|
2742
|
-
for (; ; ) {
|
|
2743
|
-
let next = input.charCodeAt(pos++), stop = false;
|
|
2744
|
-
if (next == 126) {
|
|
2745
|
-
value = 65535;
|
|
2746
|
-
break;
|
|
2747
|
-
}
|
|
2748
|
-
if (next >= 92)
|
|
2749
|
-
next--;
|
|
2750
|
-
if (next >= 34)
|
|
2751
|
-
next--;
|
|
2752
|
-
let digit = next - 32;
|
|
2753
|
-
if (digit >= 46) {
|
|
2754
|
-
digit -= 46;
|
|
2755
|
-
stop = true;
|
|
2756
|
-
}
|
|
2757
|
-
value += digit;
|
|
2758
|
-
if (stop)
|
|
2759
|
-
break;
|
|
2760
|
-
value *= 46;
|
|
2761
|
-
}
|
|
2762
|
-
if (array)
|
|
2763
|
-
array[out++] = value;
|
|
2764
|
-
else
|
|
2765
|
-
array = new Type(value);
|
|
2766
|
-
}
|
|
2767
|
-
return array;
|
|
2768
|
-
}
|
|
2769
|
-
var CachedToken = class {
|
|
2770
|
-
constructor() {
|
|
2771
|
-
this.start = -1;
|
|
2772
|
-
this.value = -1;
|
|
2773
|
-
this.end = -1;
|
|
2774
|
-
this.extended = -1;
|
|
2775
|
-
this.lookAhead = 0;
|
|
2776
|
-
this.mask = 0;
|
|
2777
|
-
this.context = 0;
|
|
2778
|
-
}
|
|
2779
|
-
};
|
|
2780
|
-
var nullToken = new CachedToken();
|
|
2781
|
-
var InputStream = class {
|
|
2782
|
-
/// @internal
|
|
2783
|
-
constructor(input, ranges) {
|
|
2784
|
-
this.input = input;
|
|
2785
|
-
this.ranges = ranges;
|
|
2786
|
-
this.chunk = "";
|
|
2787
|
-
this.chunkOff = 0;
|
|
2788
|
-
this.chunk2 = "";
|
|
2789
|
-
this.chunk2Pos = 0;
|
|
2790
|
-
this.next = -1;
|
|
2791
|
-
this.token = nullToken;
|
|
2792
|
-
this.rangeIndex = 0;
|
|
2793
|
-
this.pos = this.chunkPos = ranges[0].from;
|
|
2794
|
-
this.range = ranges[0];
|
|
2795
|
-
this.end = ranges[ranges.length - 1].to;
|
|
2796
|
-
this.readNext();
|
|
2797
|
-
}
|
|
2798
|
-
/// @internal
|
|
2799
|
-
resolveOffset(offset, assoc) {
|
|
2800
|
-
let range = this.range, index = this.rangeIndex;
|
|
2801
|
-
let pos = this.pos + offset;
|
|
2802
|
-
while (pos < range.from) {
|
|
2803
|
-
if (!index)
|
|
2804
|
-
return null;
|
|
2805
|
-
let next = this.ranges[--index];
|
|
2806
|
-
pos -= range.from - next.to;
|
|
2807
|
-
range = next;
|
|
2808
|
-
}
|
|
2809
|
-
while (assoc < 0 ? pos > range.to : pos >= range.to) {
|
|
2810
|
-
if (index == this.ranges.length - 1)
|
|
2811
|
-
return null;
|
|
2812
|
-
let next = this.ranges[++index];
|
|
2813
|
-
pos += next.from - range.to;
|
|
2814
|
-
range = next;
|
|
2815
|
-
}
|
|
2816
|
-
return pos;
|
|
2817
|
-
}
|
|
2818
|
-
/// @internal
|
|
2819
|
-
clipPos(pos) {
|
|
2820
|
-
if (pos >= this.range.from && pos < this.range.to)
|
|
2821
|
-
return pos;
|
|
2822
|
-
for (let range of this.ranges)
|
|
2823
|
-
if (range.to > pos)
|
|
2824
|
-
return Math.max(pos, range.from);
|
|
2825
|
-
return this.end;
|
|
2826
|
-
}
|
|
2827
|
-
/// Look at a code unit near the stream position. `.peek(0)` equals
|
|
2828
|
-
/// `.next`, `.peek(-1)` gives you the previous character, and so
|
|
2829
|
-
/// on.
|
|
2830
|
-
///
|
|
2831
|
-
/// Note that looking around during tokenizing creates dependencies
|
|
2832
|
-
/// on potentially far-away content, which may reduce the
|
|
2833
|
-
/// effectiveness incremental parsing—when looking forward—or even
|
|
2834
|
-
/// cause invalid reparses when looking backward more than 25 code
|
|
2835
|
-
/// units, since the library does not track lookbehind.
|
|
2836
|
-
peek(offset) {
|
|
2837
|
-
let idx = this.chunkOff + offset, pos, result;
|
|
2838
|
-
if (idx >= 0 && idx < this.chunk.length) {
|
|
2839
|
-
pos = this.pos + offset;
|
|
2840
|
-
result = this.chunk.charCodeAt(idx);
|
|
2841
|
-
} else {
|
|
2842
|
-
let resolved = this.resolveOffset(offset, 1);
|
|
2843
|
-
if (resolved == null)
|
|
2844
|
-
return -1;
|
|
2845
|
-
pos = resolved;
|
|
2846
|
-
if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
|
|
2847
|
-
result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
|
|
2848
|
-
} else {
|
|
2849
|
-
let i = this.rangeIndex, range = this.range;
|
|
2850
|
-
while (range.to <= pos)
|
|
2851
|
-
range = this.ranges[++i];
|
|
2852
|
-
this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
|
|
2853
|
-
if (pos + this.chunk2.length > range.to)
|
|
2854
|
-
this.chunk2 = this.chunk2.slice(0, range.to - pos);
|
|
2855
|
-
result = this.chunk2.charCodeAt(0);
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2858
|
-
if (pos >= this.token.lookAhead)
|
|
2859
|
-
this.token.lookAhead = pos + 1;
|
|
2860
|
-
return result;
|
|
2861
|
-
}
|
|
2862
|
-
/// Accept a token. By default, the end of the token is set to the
|
|
2863
|
-
/// current stream position, but you can pass an offset (relative to
|
|
2864
|
-
/// the stream position) to change that.
|
|
2865
|
-
acceptToken(token, endOffset = 0) {
|
|
2866
|
-
let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
|
|
2867
|
-
if (end == null || end < this.token.start)
|
|
2868
|
-
throw new RangeError("Token end out of bounds");
|
|
2869
|
-
this.token.value = token;
|
|
2870
|
-
this.token.end = end;
|
|
2871
|
-
}
|
|
2872
|
-
getChunk() {
|
|
2873
|
-
if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
|
|
2874
|
-
let { chunk, chunkPos } = this;
|
|
2875
|
-
this.chunk = this.chunk2;
|
|
2876
|
-
this.chunkPos = this.chunk2Pos;
|
|
2877
|
-
this.chunk2 = chunk;
|
|
2878
|
-
this.chunk2Pos = chunkPos;
|
|
2879
|
-
this.chunkOff = this.pos - this.chunkPos;
|
|
2880
|
-
} else {
|
|
2881
|
-
this.chunk2 = this.chunk;
|
|
2882
|
-
this.chunk2Pos = this.chunkPos;
|
|
2883
|
-
let nextChunk = this.input.chunk(this.pos);
|
|
2884
|
-
let end = this.pos + nextChunk.length;
|
|
2885
|
-
this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
|
|
2886
|
-
this.chunkPos = this.pos;
|
|
2887
|
-
this.chunkOff = 0;
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
readNext() {
|
|
2891
|
-
if (this.chunkOff >= this.chunk.length) {
|
|
2892
|
-
this.getChunk();
|
|
2893
|
-
if (this.chunkOff == this.chunk.length)
|
|
2894
|
-
return this.next = -1;
|
|
2895
|
-
}
|
|
2896
|
-
return this.next = this.chunk.charCodeAt(this.chunkOff);
|
|
2897
|
-
}
|
|
2898
|
-
/// Move the stream forward N (defaults to 1) code units. Returns
|
|
2899
|
-
/// the new value of [`next`](#lr.InputStream.next).
|
|
2900
|
-
advance(n = 1) {
|
|
2901
|
-
this.chunkOff += n;
|
|
2902
|
-
while (this.pos + n >= this.range.to) {
|
|
2903
|
-
if (this.rangeIndex == this.ranges.length - 1)
|
|
2904
|
-
return this.setDone();
|
|
2905
|
-
n -= this.range.to - this.pos;
|
|
2906
|
-
this.range = this.ranges[++this.rangeIndex];
|
|
2907
|
-
this.pos = this.range.from;
|
|
2908
|
-
}
|
|
2909
|
-
this.pos += n;
|
|
2910
|
-
if (this.pos >= this.token.lookAhead)
|
|
2911
|
-
this.token.lookAhead = this.pos + 1;
|
|
2912
|
-
return this.readNext();
|
|
2913
|
-
}
|
|
2914
|
-
setDone() {
|
|
2915
|
-
this.pos = this.chunkPos = this.end;
|
|
2916
|
-
this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
|
|
2917
|
-
this.chunk = "";
|
|
2918
|
-
return this.next = -1;
|
|
2919
|
-
}
|
|
2920
|
-
/// @internal
|
|
2921
|
-
reset(pos, token) {
|
|
2922
|
-
if (token) {
|
|
2923
|
-
this.token = token;
|
|
2924
|
-
token.start = pos;
|
|
2925
|
-
token.lookAhead = pos + 1;
|
|
2926
|
-
token.value = token.extended = -1;
|
|
2927
|
-
} else {
|
|
2928
|
-
this.token = nullToken;
|
|
2929
|
-
}
|
|
2930
|
-
if (this.pos != pos) {
|
|
2931
|
-
this.pos = pos;
|
|
2932
|
-
if (pos == this.end) {
|
|
2933
|
-
this.setDone();
|
|
2934
|
-
return this;
|
|
2935
|
-
}
|
|
2936
|
-
while (pos < this.range.from)
|
|
2937
|
-
this.range = this.ranges[--this.rangeIndex];
|
|
2938
|
-
while (pos >= this.range.to)
|
|
2939
|
-
this.range = this.ranges[++this.rangeIndex];
|
|
2940
|
-
if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
|
|
2941
|
-
this.chunkOff = pos - this.chunkPos;
|
|
2942
|
-
} else {
|
|
2943
|
-
this.chunk = "";
|
|
2944
|
-
this.chunkOff = 0;
|
|
2945
|
-
}
|
|
2946
|
-
this.readNext();
|
|
2947
|
-
}
|
|
2948
|
-
return this;
|
|
2949
|
-
}
|
|
2950
|
-
/// @internal
|
|
2951
|
-
read(from, to) {
|
|
2952
|
-
if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
|
|
2953
|
-
return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
|
|
2954
|
-
if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
|
|
2955
|
-
return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
|
|
2956
|
-
if (from >= this.range.from && to <= this.range.to)
|
|
2957
|
-
return this.input.read(from, to);
|
|
2958
|
-
let result = "";
|
|
2959
|
-
for (let r of this.ranges) {
|
|
2960
|
-
if (r.from >= to)
|
|
2961
|
-
break;
|
|
2962
|
-
if (r.to > from)
|
|
2963
|
-
result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
|
|
2964
|
-
}
|
|
2965
|
-
return result;
|
|
2966
|
-
}
|
|
2967
|
-
};
|
|
2968
|
-
var TokenGroup = class {
|
|
2969
|
-
constructor(data, id) {
|
|
2970
|
-
this.data = data;
|
|
2971
|
-
this.id = id;
|
|
2972
|
-
}
|
|
2973
|
-
token(input, stack) {
|
|
2974
|
-
let { parser: parser2 } = stack.p;
|
|
2975
|
-
readToken(this.data, input, stack, this.id, parser2.data, parser2.tokenPrecTable);
|
|
2976
|
-
}
|
|
2977
|
-
};
|
|
2978
|
-
TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
|
|
2979
|
-
var LocalTokenGroup = class {
|
|
2980
|
-
constructor(data, precTable, elseToken) {
|
|
2981
|
-
this.precTable = precTable;
|
|
2982
|
-
this.elseToken = elseToken;
|
|
2983
|
-
this.data = typeof data == "string" ? decodeArray(data) : data;
|
|
2984
|
-
}
|
|
2985
|
-
token(input, stack) {
|
|
2986
|
-
let start = input.pos, skipped = 0;
|
|
2987
|
-
for (; ; ) {
|
|
2988
|
-
let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
|
|
2989
|
-
readToken(this.data, input, stack, 0, this.data, this.precTable);
|
|
2990
|
-
if (input.token.value > -1)
|
|
2991
|
-
break;
|
|
2992
|
-
if (this.elseToken == null)
|
|
2993
|
-
return;
|
|
2994
|
-
if (!atEof)
|
|
2995
|
-
skipped++;
|
|
2996
|
-
if (nextPos == null)
|
|
2997
|
-
break;
|
|
2998
|
-
input.reset(nextPos, input.token);
|
|
2999
|
-
}
|
|
3000
|
-
if (skipped) {
|
|
3001
|
-
input.reset(start, input.token);
|
|
3002
|
-
input.acceptToken(this.elseToken, skipped);
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
};
|
|
3006
|
-
LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
|
|
3007
|
-
function readToken(data, input, stack, group, precTable, precOffset) {
|
|
3008
|
-
let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
|
|
3009
|
-
scan:
|
|
3010
|
-
for (; ; ) {
|
|
3011
|
-
if ((groupMask & data[state]) == 0)
|
|
3012
|
-
break;
|
|
3013
|
-
let accEnd = data[state + 1];
|
|
3014
|
-
for (let i = state + 3; i < accEnd; i += 2)
|
|
3015
|
-
if ((data[i + 1] & groupMask) > 0) {
|
|
3016
|
-
let term = data[i];
|
|
3017
|
-
if (dialect.allows(term) && (input.token.value == -1 || input.token.value == term || overrides(term, input.token.value, precTable, precOffset))) {
|
|
3018
|
-
input.acceptToken(term);
|
|
3019
|
-
break;
|
|
3020
|
-
}
|
|
3021
|
-
}
|
|
3022
|
-
let next = input.next, low = 0, high = data[state + 2];
|
|
3023
|
-
if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 && data[accEnd + high * 3 - 3] == 65535) {
|
|
3024
|
-
state = data[accEnd + high * 3 - 1];
|
|
3025
|
-
continue scan;
|
|
3026
|
-
}
|
|
3027
|
-
for (; low < high; ) {
|
|
3028
|
-
let mid = low + high >> 1;
|
|
3029
|
-
let index = accEnd + mid + (mid << 1);
|
|
3030
|
-
let from = data[index], to = data[index + 1] || 65536;
|
|
3031
|
-
if (next < from)
|
|
3032
|
-
high = mid;
|
|
3033
|
-
else if (next >= to)
|
|
3034
|
-
low = mid + 1;
|
|
3035
|
-
else {
|
|
3036
|
-
state = data[index + 2];
|
|
3037
|
-
input.advance();
|
|
3038
|
-
continue scan;
|
|
3039
|
-
}
|
|
3040
|
-
}
|
|
3041
|
-
break;
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
function findOffset(data, start, term) {
|
|
3045
|
-
for (let i = start, next; (next = data[i]) != 65535; i++)
|
|
3046
|
-
if (next == term)
|
|
3047
|
-
return i - start;
|
|
3048
|
-
return -1;
|
|
3049
|
-
}
|
|
3050
|
-
function overrides(token, prev, tableData, tableOffset) {
|
|
3051
|
-
let iPrev = findOffset(tableData, tableOffset, prev);
|
|
3052
|
-
return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
|
|
3053
|
-
}
|
|
3054
|
-
var verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
|
|
3055
|
-
var stackIDs = null;
|
|
3056
|
-
var Safety;
|
|
3057
|
-
(function(Safety2) {
|
|
3058
|
-
Safety2[Safety2["Margin"] = 25] = "Margin";
|
|
3059
|
-
})(Safety || (Safety = {}));
|
|
3060
|
-
function cutAt(tree, pos, side) {
|
|
3061
|
-
let cursor = tree.cursor(IterMode.IncludeAnonymous);
|
|
3062
|
-
cursor.moveTo(pos);
|
|
3063
|
-
for (; ; ) {
|
|
3064
|
-
if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
|
|
3065
|
-
for (; ; ) {
|
|
3066
|
-
if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
|
|
3067
|
-
return side < 0 ? Math.max(0, Math.min(
|
|
3068
|
-
cursor.to - 1,
|
|
3069
|
-
pos - 25
|
|
3070
|
-
/* Safety.Margin */
|
|
3071
|
-
)) : Math.min(tree.length, Math.max(
|
|
3072
|
-
cursor.from + 1,
|
|
3073
|
-
pos + 25
|
|
3074
|
-
/* Safety.Margin */
|
|
3075
|
-
));
|
|
3076
|
-
if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
|
|
3077
|
-
break;
|
|
3078
|
-
if (!cursor.parent())
|
|
3079
|
-
return side < 0 ? 0 : tree.length;
|
|
3080
|
-
}
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
var FragmentCursor = class {
|
|
3084
|
-
constructor(fragments, nodeSet) {
|
|
3085
|
-
this.fragments = fragments;
|
|
3086
|
-
this.nodeSet = nodeSet;
|
|
3087
|
-
this.i = 0;
|
|
3088
|
-
this.fragment = null;
|
|
3089
|
-
this.safeFrom = -1;
|
|
3090
|
-
this.safeTo = -1;
|
|
3091
|
-
this.trees = [];
|
|
3092
|
-
this.start = [];
|
|
3093
|
-
this.index = [];
|
|
3094
|
-
this.nextFragment();
|
|
3095
|
-
}
|
|
3096
|
-
nextFragment() {
|
|
3097
|
-
let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
|
|
3098
|
-
if (fr) {
|
|
3099
|
-
this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
|
|
3100
|
-
this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
|
|
3101
|
-
while (this.trees.length) {
|
|
3102
|
-
this.trees.pop();
|
|
3103
|
-
this.start.pop();
|
|
3104
|
-
this.index.pop();
|
|
3105
|
-
}
|
|
3106
|
-
this.trees.push(fr.tree);
|
|
3107
|
-
this.start.push(-fr.offset);
|
|
3108
|
-
this.index.push(0);
|
|
3109
|
-
this.nextStart = this.safeFrom;
|
|
3110
|
-
} else {
|
|
3111
|
-
this.nextStart = 1e9;
|
|
3112
|
-
}
|
|
3113
|
-
}
|
|
3114
|
-
// `pos` must be >= any previously given `pos` for this cursor
|
|
3115
|
-
nodeAt(pos) {
|
|
3116
|
-
if (pos < this.nextStart)
|
|
3117
|
-
return null;
|
|
3118
|
-
while (this.fragment && this.safeTo <= pos)
|
|
3119
|
-
this.nextFragment();
|
|
3120
|
-
if (!this.fragment)
|
|
3121
|
-
return null;
|
|
3122
|
-
for (; ; ) {
|
|
3123
|
-
let last2 = this.trees.length - 1;
|
|
3124
|
-
if (last2 < 0) {
|
|
3125
|
-
this.nextFragment();
|
|
3126
|
-
return null;
|
|
3127
|
-
}
|
|
3128
|
-
let top = this.trees[last2], index = this.index[last2];
|
|
3129
|
-
if (index == top.children.length) {
|
|
3130
|
-
this.trees.pop();
|
|
3131
|
-
this.start.pop();
|
|
3132
|
-
this.index.pop();
|
|
3133
|
-
continue;
|
|
3134
|
-
}
|
|
3135
|
-
let next = top.children[index];
|
|
3136
|
-
let start = this.start[last2] + top.positions[index];
|
|
3137
|
-
if (start > pos) {
|
|
3138
|
-
this.nextStart = start;
|
|
3139
|
-
return null;
|
|
3140
|
-
}
|
|
3141
|
-
if (next instanceof Tree) {
|
|
3142
|
-
if (start == pos) {
|
|
3143
|
-
if (start < this.safeFrom)
|
|
3144
|
-
return null;
|
|
3145
|
-
let end = start + next.length;
|
|
3146
|
-
if (end <= this.safeTo) {
|
|
3147
|
-
let lookAhead = next.prop(NodeProp.lookAhead);
|
|
3148
|
-
if (!lookAhead || end + lookAhead < this.fragment.to)
|
|
3149
|
-
return next;
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
this.index[last2]++;
|
|
3153
|
-
if (start + next.length >= Math.max(this.safeFrom, pos)) {
|
|
3154
|
-
this.trees.push(next);
|
|
3155
|
-
this.start.push(start);
|
|
3156
|
-
this.index.push(0);
|
|
3157
|
-
}
|
|
3158
|
-
} else {
|
|
3159
|
-
this.index[last2]++;
|
|
3160
|
-
this.nextStart = start + next.length;
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
};
|
|
3165
|
-
var TokenCache = class {
|
|
3166
|
-
constructor(parser2, stream) {
|
|
3167
|
-
this.stream = stream;
|
|
3168
|
-
this.tokens = [];
|
|
3169
|
-
this.mainToken = null;
|
|
3170
|
-
this.actions = [];
|
|
3171
|
-
this.tokens = parser2.tokenizers.map((_) => new CachedToken());
|
|
3172
|
-
}
|
|
3173
|
-
getActions(stack) {
|
|
3174
|
-
let actionIndex = 0;
|
|
3175
|
-
let main = null;
|
|
3176
|
-
let { parser: parser2 } = stack.p, { tokenizers } = parser2;
|
|
3177
|
-
let mask = parser2.stateSlot(
|
|
3178
|
-
stack.state,
|
|
3179
|
-
3
|
|
3180
|
-
/* ParseState.TokenizerMask */
|
|
3181
|
-
);
|
|
3182
|
-
let context = stack.curContext ? stack.curContext.hash : 0;
|
|
3183
|
-
let lookAhead = 0;
|
|
3184
|
-
for (let i = 0; i < tokenizers.length; i++) {
|
|
3185
|
-
if ((1 << i & mask) == 0)
|
|
3186
|
-
continue;
|
|
3187
|
-
let tokenizer = tokenizers[i], token = this.tokens[i];
|
|
3188
|
-
if (main && !tokenizer.fallback)
|
|
3189
|
-
continue;
|
|
3190
|
-
if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
|
|
3191
|
-
this.updateCachedToken(token, tokenizer, stack);
|
|
3192
|
-
token.mask = mask;
|
|
3193
|
-
token.context = context;
|
|
3194
|
-
}
|
|
3195
|
-
if (token.lookAhead > token.end + 25)
|
|
3196
|
-
lookAhead = Math.max(token.lookAhead, lookAhead);
|
|
3197
|
-
if (token.value != 0) {
|
|
3198
|
-
let startIndex = actionIndex;
|
|
3199
|
-
if (token.extended > -1)
|
|
3200
|
-
actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
|
|
3201
|
-
actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
|
|
3202
|
-
if (!tokenizer.extend) {
|
|
3203
|
-
main = token;
|
|
3204
|
-
if (actionIndex > startIndex)
|
|
3205
|
-
break;
|
|
3206
|
-
}
|
|
3207
|
-
}
|
|
3208
|
-
}
|
|
3209
|
-
while (this.actions.length > actionIndex)
|
|
3210
|
-
this.actions.pop();
|
|
3211
|
-
if (lookAhead)
|
|
3212
|
-
stack.setLookAhead(lookAhead);
|
|
3213
|
-
if (!main && stack.pos == this.stream.end) {
|
|
3214
|
-
main = new CachedToken();
|
|
3215
|
-
main.value = stack.p.parser.eofTerm;
|
|
3216
|
-
main.start = main.end = stack.pos;
|
|
3217
|
-
actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
|
|
3218
|
-
}
|
|
3219
|
-
this.mainToken = main;
|
|
3220
|
-
return this.actions;
|
|
3221
|
-
}
|
|
3222
|
-
getMainToken(stack) {
|
|
3223
|
-
if (this.mainToken)
|
|
3224
|
-
return this.mainToken;
|
|
3225
|
-
let main = new CachedToken(), { pos, p } = stack;
|
|
3226
|
-
main.start = pos;
|
|
3227
|
-
main.end = Math.min(pos + 1, p.stream.end);
|
|
3228
|
-
main.value = pos == p.stream.end ? p.parser.eofTerm : 0;
|
|
3229
|
-
return main;
|
|
3230
|
-
}
|
|
3231
|
-
updateCachedToken(token, tokenizer, stack) {
|
|
3232
|
-
let start = this.stream.clipPos(stack.pos);
|
|
3233
|
-
tokenizer.token(this.stream.reset(start, token), stack);
|
|
3234
|
-
if (token.value > -1) {
|
|
3235
|
-
let { parser: parser2 } = stack.p;
|
|
3236
|
-
for (let i = 0; i < parser2.specialized.length; i++)
|
|
3237
|
-
if (parser2.specialized[i] == token.value) {
|
|
3238
|
-
let result = parser2.specializers[i](this.stream.read(token.start, token.end), stack);
|
|
3239
|
-
if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
|
|
3240
|
-
if ((result & 1) == 0)
|
|
3241
|
-
token.value = result >> 1;
|
|
3242
|
-
else
|
|
3243
|
-
token.extended = result >> 1;
|
|
3244
|
-
break;
|
|
3245
|
-
}
|
|
3246
|
-
}
|
|
3247
|
-
} else {
|
|
3248
|
-
token.value = 0;
|
|
3249
|
-
token.end = this.stream.clipPos(start + 1);
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
putAction(action, token, end, index) {
|
|
3253
|
-
for (let i = 0; i < index; i += 3)
|
|
3254
|
-
if (this.actions[i] == action)
|
|
3255
|
-
return index;
|
|
3256
|
-
this.actions[index++] = action;
|
|
3257
|
-
this.actions[index++] = token;
|
|
3258
|
-
this.actions[index++] = end;
|
|
3259
|
-
return index;
|
|
3260
|
-
}
|
|
3261
|
-
addActions(stack, token, end, index) {
|
|
3262
|
-
let { state } = stack, { parser: parser2 } = stack.p, { data } = parser2;
|
|
3263
|
-
for (let set = 0; set < 2; set++) {
|
|
3264
|
-
for (let i = parser2.stateSlot(
|
|
3265
|
-
state,
|
|
3266
|
-
set ? 2 : 1
|
|
3267
|
-
/* ParseState.Actions */
|
|
3268
|
-
); ; i += 3) {
|
|
3269
|
-
if (data[i] == 65535) {
|
|
3270
|
-
if (data[i + 1] == 1) {
|
|
3271
|
-
i = pair(data, i + 2);
|
|
3272
|
-
} else {
|
|
3273
|
-
if (index == 0 && data[i + 1] == 2)
|
|
3274
|
-
index = this.putAction(pair(data, i + 2), token, end, index);
|
|
3275
|
-
break;
|
|
3276
|
-
}
|
|
3277
|
-
}
|
|
3278
|
-
if (data[i] == token)
|
|
3279
|
-
index = this.putAction(pair(data, i + 1), token, end, index);
|
|
3280
|
-
}
|
|
3281
|
-
}
|
|
3282
|
-
return index;
|
|
3283
|
-
}
|
|
3284
|
-
};
|
|
3285
|
-
var Rec;
|
|
3286
|
-
(function(Rec2) {
|
|
3287
|
-
Rec2[Rec2["Distance"] = 5] = "Distance";
|
|
3288
|
-
Rec2[Rec2["MaxRemainingPerStep"] = 3] = "MaxRemainingPerStep";
|
|
3289
|
-
Rec2[Rec2["MinBufferLengthPrune"] = 500] = "MinBufferLengthPrune";
|
|
3290
|
-
Rec2[Rec2["ForceReduceLimit"] = 10] = "ForceReduceLimit";
|
|
3291
|
-
Rec2[Rec2["CutDepth"] = 15e3] = "CutDepth";
|
|
3292
|
-
Rec2[Rec2["CutTo"] = 9e3] = "CutTo";
|
|
3293
|
-
Rec2[Rec2["MaxLeftAssociativeReductionCount"] = 300] = "MaxLeftAssociativeReductionCount";
|
|
3294
|
-
Rec2[Rec2["MaxStackCount"] = 12] = "MaxStackCount";
|
|
3295
|
-
})(Rec || (Rec = {}));
|
|
3296
|
-
var Parse = class {
|
|
3297
|
-
constructor(parser2, input, fragments, ranges) {
|
|
3298
|
-
this.parser = parser2;
|
|
3299
|
-
this.input = input;
|
|
3300
|
-
this.ranges = ranges;
|
|
3301
|
-
this.recovering = 0;
|
|
3302
|
-
this.nextStackID = 9812;
|
|
3303
|
-
this.minStackPos = 0;
|
|
3304
|
-
this.reused = [];
|
|
3305
|
-
this.stoppedAt = null;
|
|
3306
|
-
this.lastBigReductionStart = -1;
|
|
3307
|
-
this.lastBigReductionSize = 0;
|
|
3308
|
-
this.bigReductionCount = 0;
|
|
3309
|
-
this.stream = new InputStream(input, ranges);
|
|
3310
|
-
this.tokens = new TokenCache(parser2, this.stream);
|
|
3311
|
-
this.topTerm = parser2.top[1];
|
|
3312
|
-
let { from } = ranges[0];
|
|
3313
|
-
this.stacks = [Stack.start(this, parser2.top[0], from)];
|
|
3314
|
-
this.fragments = fragments.length && this.stream.end - from > parser2.bufferLength * 4 ? new FragmentCursor(fragments, parser2.nodeSet) : null;
|
|
3315
|
-
}
|
|
3316
|
-
get parsedPos() {
|
|
3317
|
-
return this.minStackPos;
|
|
3318
|
-
}
|
|
3319
|
-
// Move the parser forward. This will process all parse stacks at
|
|
3320
|
-
// `this.pos` and try to advance them to a further position. If no
|
|
3321
|
-
// stack for such a position is found, it'll start error-recovery.
|
|
3322
|
-
//
|
|
3323
|
-
// When the parse is finished, this will return a syntax tree. When
|
|
3324
|
-
// not, it returns `null`.
|
|
3325
|
-
advance() {
|
|
3326
|
-
let stacks = this.stacks, pos = this.minStackPos;
|
|
3327
|
-
let newStacks = this.stacks = [];
|
|
3328
|
-
let stopped, stoppedTokens;
|
|
3329
|
-
if (this.bigReductionCount > 300 && stacks.length == 1) {
|
|
3330
|
-
let [s] = stacks;
|
|
3331
|
-
while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) {
|
|
3332
|
-
}
|
|
3333
|
-
this.bigReductionCount = this.lastBigReductionSize = 0;
|
|
3334
|
-
}
|
|
3335
|
-
for (let i = 0; i < stacks.length; i++) {
|
|
3336
|
-
let stack = stacks[i];
|
|
3337
|
-
for (; ; ) {
|
|
3338
|
-
this.tokens.mainToken = null;
|
|
3339
|
-
if (stack.pos > pos) {
|
|
3340
|
-
newStacks.push(stack);
|
|
3341
|
-
} else if (this.advanceStack(stack, newStacks, stacks)) {
|
|
3342
|
-
continue;
|
|
3343
|
-
} else {
|
|
3344
|
-
if (!stopped) {
|
|
3345
|
-
stopped = [];
|
|
3346
|
-
stoppedTokens = [];
|
|
3347
|
-
}
|
|
3348
|
-
stopped.push(stack);
|
|
3349
|
-
let tok = this.tokens.getMainToken(stack);
|
|
3350
|
-
stoppedTokens.push(tok.value, tok.end);
|
|
3351
|
-
}
|
|
3352
|
-
break;
|
|
3353
|
-
}
|
|
3354
|
-
}
|
|
3355
|
-
if (!newStacks.length) {
|
|
3356
|
-
let finished = stopped && findFinished(stopped);
|
|
3357
|
-
if (finished)
|
|
3358
|
-
return this.stackToTree(finished);
|
|
3359
|
-
if (this.parser.strict) {
|
|
3360
|
-
if (verbose && stopped)
|
|
3361
|
-
console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
|
|
3362
|
-
throw new SyntaxError("No parse at " + pos);
|
|
3363
|
-
}
|
|
3364
|
-
if (!this.recovering)
|
|
3365
|
-
this.recovering = 5;
|
|
3366
|
-
}
|
|
3367
|
-
if (this.recovering && stopped) {
|
|
3368
|
-
let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0] : this.runRecovery(stopped, stoppedTokens, newStacks);
|
|
3369
|
-
if (finished)
|
|
3370
|
-
return this.stackToTree(finished.forceAll());
|
|
3371
|
-
}
|
|
3372
|
-
if (this.recovering) {
|
|
3373
|
-
let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3;
|
|
3374
|
-
if (newStacks.length > maxRemaining) {
|
|
3375
|
-
newStacks.sort((a, b) => b.score - a.score);
|
|
3376
|
-
while (newStacks.length > maxRemaining)
|
|
3377
|
-
newStacks.pop();
|
|
3378
|
-
}
|
|
3379
|
-
if (newStacks.some((s) => s.reducePos > pos))
|
|
3380
|
-
this.recovering--;
|
|
3381
|
-
} else if (newStacks.length > 1) {
|
|
3382
|
-
outer:
|
|
3383
|
-
for (let i = 0; i < newStacks.length - 1; i++) {
|
|
3384
|
-
let stack = newStacks[i];
|
|
3385
|
-
for (let j = i + 1; j < newStacks.length; j++) {
|
|
3386
|
-
let other = newStacks[j];
|
|
3387
|
-
if (stack.sameState(other) || stack.buffer.length > 500 && other.buffer.length > 500) {
|
|
3388
|
-
if ((stack.score - other.score || stack.buffer.length - other.buffer.length) > 0) {
|
|
3389
|
-
newStacks.splice(j--, 1);
|
|
3390
|
-
} else {
|
|
3391
|
-
newStacks.splice(i--, 1);
|
|
3392
|
-
continue outer;
|
|
3393
|
-
}
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
|
-
}
|
|
3397
|
-
if (newStacks.length > 12)
|
|
3398
|
-
newStacks.splice(
|
|
3399
|
-
12,
|
|
3400
|
-
newStacks.length - 12
|
|
3401
|
-
/* Rec.MaxStackCount */
|
|
3402
|
-
);
|
|
3403
|
-
}
|
|
3404
|
-
this.minStackPos = newStacks[0].pos;
|
|
3405
|
-
for (let i = 1; i < newStacks.length; i++)
|
|
3406
|
-
if (newStacks[i].pos < this.minStackPos)
|
|
3407
|
-
this.minStackPos = newStacks[i].pos;
|
|
3408
|
-
return null;
|
|
3409
|
-
}
|
|
3410
|
-
stopAt(pos) {
|
|
3411
|
-
if (this.stoppedAt != null && this.stoppedAt < pos)
|
|
3412
|
-
throw new RangeError("Can't move stoppedAt forward");
|
|
3413
|
-
this.stoppedAt = pos;
|
|
3414
|
-
}
|
|
3415
|
-
// Returns an updated version of the given stack, or null if the
|
|
3416
|
-
// stack can't advance normally. When `split` and `stacks` are
|
|
3417
|
-
// given, stacks split off by ambiguous operations will be pushed to
|
|
3418
|
-
// `split`, or added to `stacks` if they move `pos` forward.
|
|
3419
|
-
advanceStack(stack, stacks, split) {
|
|
3420
|
-
let start = stack.pos, { parser: parser2 } = this;
|
|
3421
|
-
let base = verbose ? this.stackID(stack) + " -> " : "";
|
|
3422
|
-
if (this.stoppedAt != null && start > this.stoppedAt)
|
|
3423
|
-
return stack.forceReduce() ? stack : null;
|
|
3424
|
-
if (this.fragments) {
|
|
3425
|
-
let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
|
|
3426
|
-
for (let cached = this.fragments.nodeAt(start); cached; ) {
|
|
3427
|
-
let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser2.getGoto(stack.state, cached.type.id) : -1;
|
|
3428
|
-
if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
|
|
3429
|
-
stack.useNode(cached, match);
|
|
3430
|
-
if (verbose)
|
|
3431
|
-
console.log(base + this.stackID(stack) + ` (via reuse of ${parser2.getName(cached.type.id)})`);
|
|
3432
|
-
return true;
|
|
3433
|
-
}
|
|
3434
|
-
if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
|
|
3435
|
-
break;
|
|
3436
|
-
let inner = cached.children[0];
|
|
3437
|
-
if (inner instanceof Tree && cached.positions[0] == 0)
|
|
3438
|
-
cached = inner;
|
|
3439
|
-
else
|
|
3440
|
-
break;
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
|
-
let defaultReduce = parser2.stateSlot(
|
|
3444
|
-
stack.state,
|
|
3445
|
-
4
|
|
3446
|
-
/* ParseState.DefaultReduce */
|
|
3447
|
-
);
|
|
3448
|
-
if (defaultReduce > 0) {
|
|
3449
|
-
stack.reduce(defaultReduce);
|
|
3450
|
-
if (verbose)
|
|
3451
|
-
console.log(base + this.stackID(stack) + ` (via always-reduce ${parser2.getName(
|
|
3452
|
-
defaultReduce & 65535
|
|
3453
|
-
/* Action.ValueMask */
|
|
3454
|
-
)})`);
|
|
3455
|
-
return true;
|
|
3456
|
-
}
|
|
3457
|
-
if (stack.stack.length >= 15e3) {
|
|
3458
|
-
while (stack.stack.length > 9e3 && stack.forceReduce()) {
|
|
3459
|
-
}
|
|
3460
|
-
}
|
|
3461
|
-
let actions = this.tokens.getActions(stack);
|
|
3462
|
-
for (let i = 0; i < actions.length; ) {
|
|
3463
|
-
let action = actions[i++], term = actions[i++], end = actions[i++];
|
|
3464
|
-
let last2 = i == actions.length || !split;
|
|
3465
|
-
let localStack = last2 ? stack : stack.split();
|
|
3466
|
-
localStack.apply(action, term, end);
|
|
3467
|
-
if (verbose)
|
|
3468
|
-
console.log(base + this.stackID(localStack) + ` (via ${(action & 65536) == 0 ? "shift" : `reduce of ${parser2.getName(
|
|
3469
|
-
action & 65535
|
|
3470
|
-
/* Action.ValueMask */
|
|
3471
|
-
)}`} for ${parser2.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
|
|
3472
|
-
if (last2)
|
|
3473
|
-
return true;
|
|
3474
|
-
else if (localStack.pos > start)
|
|
3475
|
-
stacks.push(localStack);
|
|
3476
|
-
else
|
|
3477
|
-
split.push(localStack);
|
|
3478
|
-
}
|
|
3479
|
-
return false;
|
|
3480
|
-
}
|
|
3481
|
-
// Advance a given stack forward as far as it will go. Returns the
|
|
3482
|
-
// (possibly updated) stack if it got stuck, or null if it moved
|
|
3483
|
-
// forward and was given to `pushStackDedup`.
|
|
3484
|
-
advanceFully(stack, newStacks) {
|
|
3485
|
-
let pos = stack.pos;
|
|
3486
|
-
for (; ; ) {
|
|
3487
|
-
if (!this.advanceStack(stack, null, null))
|
|
3488
|
-
return false;
|
|
3489
|
-
if (stack.pos > pos) {
|
|
3490
|
-
pushStackDedup(stack, newStacks);
|
|
3491
|
-
return true;
|
|
3492
|
-
}
|
|
3493
|
-
}
|
|
3494
|
-
}
|
|
3495
|
-
runRecovery(stacks, tokens, newStacks) {
|
|
3496
|
-
let finished = null, restarted = false;
|
|
3497
|
-
for (let i = 0; i < stacks.length; i++) {
|
|
3498
|
-
let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
|
|
3499
|
-
let base = verbose ? this.stackID(stack) + " -> " : "";
|
|
3500
|
-
if (stack.deadEnd) {
|
|
3501
|
-
if (restarted)
|
|
3502
|
-
continue;
|
|
3503
|
-
restarted = true;
|
|
3504
|
-
stack.restart();
|
|
3505
|
-
if (verbose)
|
|
3506
|
-
console.log(base + this.stackID(stack) + " (restarted)");
|
|
3507
|
-
let done = this.advanceFully(stack, newStacks);
|
|
3508
|
-
if (done)
|
|
3509
|
-
continue;
|
|
3510
|
-
}
|
|
3511
|
-
let force = stack.split(), forceBase = base;
|
|
3512
|
-
for (let j = 0; force.forceReduce() && j < 10; j++) {
|
|
3513
|
-
if (verbose)
|
|
3514
|
-
console.log(forceBase + this.stackID(force) + " (via force-reduce)");
|
|
3515
|
-
let done = this.advanceFully(force, newStacks);
|
|
3516
|
-
if (done)
|
|
3517
|
-
break;
|
|
3518
|
-
if (verbose)
|
|
3519
|
-
forceBase = this.stackID(force) + " -> ";
|
|
3520
|
-
}
|
|
3521
|
-
for (let insert of stack.recoverByInsert(token)) {
|
|
3522
|
-
if (verbose)
|
|
3523
|
-
console.log(base + this.stackID(insert) + " (via recover-insert)");
|
|
3524
|
-
this.advanceFully(insert, newStacks);
|
|
3525
|
-
}
|
|
3526
|
-
if (this.stream.end > stack.pos) {
|
|
3527
|
-
if (tokenEnd == stack.pos) {
|
|
3528
|
-
tokenEnd++;
|
|
3529
|
-
token = 0;
|
|
3530
|
-
}
|
|
3531
|
-
stack.recoverByDelete(token, tokenEnd);
|
|
3532
|
-
if (verbose)
|
|
3533
|
-
console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
|
|
3534
|
-
pushStackDedup(stack, newStacks);
|
|
3535
|
-
} else if (!finished || finished.score < stack.score) {
|
|
3536
|
-
finished = stack;
|
|
3537
|
-
}
|
|
3538
|
-
}
|
|
3539
|
-
return finished;
|
|
3540
|
-
}
|
|
3541
|
-
// Convert the stack's buffer to a syntax tree.
|
|
3542
|
-
stackToTree(stack) {
|
|
3543
|
-
stack.close();
|
|
3544
|
-
return Tree.build({
|
|
3545
|
-
buffer: StackBufferCursor.create(stack),
|
|
3546
|
-
nodeSet: this.parser.nodeSet,
|
|
3547
|
-
topID: this.topTerm,
|
|
3548
|
-
maxBufferLength: this.parser.bufferLength,
|
|
3549
|
-
reused: this.reused,
|
|
3550
|
-
start: this.ranges[0].from,
|
|
3551
|
-
length: stack.pos - this.ranges[0].from,
|
|
3552
|
-
minRepeatType: this.parser.minRepeatTerm
|
|
3553
|
-
});
|
|
3554
|
-
}
|
|
3555
|
-
stackID(stack) {
|
|
3556
|
-
let id = (stackIDs || (stackIDs = /* @__PURE__ */ new WeakMap())).get(stack);
|
|
3557
|
-
if (!id)
|
|
3558
|
-
stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
|
|
3559
|
-
return id + stack;
|
|
3560
|
-
}
|
|
3561
|
-
};
|
|
3562
|
-
function pushStackDedup(stack, newStacks) {
|
|
3563
|
-
for (let i = 0; i < newStacks.length; i++) {
|
|
3564
|
-
let other = newStacks[i];
|
|
3565
|
-
if (other.pos == stack.pos && other.sameState(stack)) {
|
|
3566
|
-
if (newStacks[i].score < stack.score)
|
|
3567
|
-
newStacks[i] = stack;
|
|
3568
|
-
return;
|
|
3569
|
-
}
|
|
3570
|
-
}
|
|
3571
|
-
newStacks.push(stack);
|
|
3572
|
-
}
|
|
3573
|
-
var Dialect = class {
|
|
3574
|
-
constructor(source, flags, disabled) {
|
|
3575
|
-
this.source = source;
|
|
3576
|
-
this.flags = flags;
|
|
3577
|
-
this.disabled = disabled;
|
|
3578
|
-
}
|
|
3579
|
-
allows(term) {
|
|
3580
|
-
return !this.disabled || this.disabled[term] == 0;
|
|
3581
|
-
}
|
|
3582
|
-
};
|
|
3583
|
-
var LRParser = class _LRParser extends Parser {
|
|
3584
|
-
/// @internal
|
|
3585
|
-
constructor(spec) {
|
|
3586
|
-
super();
|
|
3587
|
-
this.wrappers = [];
|
|
3588
|
-
if (spec.version != 14)
|
|
3589
|
-
throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14})`);
|
|
3590
|
-
let nodeNames = spec.nodeNames.split(" ");
|
|
3591
|
-
this.minRepeatTerm = nodeNames.length;
|
|
3592
|
-
for (let i = 0; i < spec.repeatNodeCount; i++)
|
|
3593
|
-
nodeNames.push("");
|
|
3594
|
-
let topTerms = Object.keys(spec.topRules).map((r) => spec.topRules[r][1]);
|
|
3595
|
-
let nodeProps = [];
|
|
3596
|
-
for (let i = 0; i < nodeNames.length; i++)
|
|
3597
|
-
nodeProps.push([]);
|
|
3598
|
-
function setProp(nodeID, prop, value) {
|
|
3599
|
-
nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
|
|
3600
|
-
}
|
|
3601
|
-
if (spec.nodeProps)
|
|
3602
|
-
for (let propSpec of spec.nodeProps) {
|
|
3603
|
-
let prop = propSpec[0];
|
|
3604
|
-
if (typeof prop == "string")
|
|
3605
|
-
prop = NodeProp[prop];
|
|
3606
|
-
for (let i = 1; i < propSpec.length; ) {
|
|
3607
|
-
let next = propSpec[i++];
|
|
3608
|
-
if (next >= 0) {
|
|
3609
|
-
setProp(next, prop, propSpec[i++]);
|
|
3610
|
-
} else {
|
|
3611
|
-
let value = propSpec[i + -next];
|
|
3612
|
-
for (let j = -next; j > 0; j--)
|
|
3613
|
-
setProp(propSpec[i++], prop, value);
|
|
3614
|
-
i++;
|
|
3615
|
-
}
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType.define({
|
|
3619
|
-
name: i >= this.minRepeatTerm ? void 0 : name,
|
|
3620
|
-
id: i,
|
|
3621
|
-
props: nodeProps[i],
|
|
3622
|
-
top: topTerms.indexOf(i) > -1,
|
|
3623
|
-
error: i == 0,
|
|
3624
|
-
skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
|
|
3625
|
-
})));
|
|
3626
|
-
if (spec.propSources)
|
|
3627
|
-
this.nodeSet = this.nodeSet.extend(...spec.propSources);
|
|
3628
|
-
this.strict = false;
|
|
3629
|
-
this.bufferLength = DefaultBufferLength;
|
|
3630
|
-
let tokenArray = decodeArray(spec.tokenData);
|
|
3631
|
-
this.context = spec.context;
|
|
3632
|
-
this.specializerSpecs = spec.specialized || [];
|
|
3633
|
-
this.specialized = new Uint16Array(this.specializerSpecs.length);
|
|
3634
|
-
for (let i = 0; i < this.specializerSpecs.length; i++)
|
|
3635
|
-
this.specialized[i] = this.specializerSpecs[i].term;
|
|
3636
|
-
this.specializers = this.specializerSpecs.map(getSpecializer);
|
|
3637
|
-
this.states = decodeArray(spec.states, Uint32Array);
|
|
3638
|
-
this.data = decodeArray(spec.stateData);
|
|
3639
|
-
this.goto = decodeArray(spec.goto);
|
|
3640
|
-
this.maxTerm = spec.maxTerm;
|
|
3641
|
-
this.tokenizers = spec.tokenizers.map((value) => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
|
|
3642
|
-
this.topRules = spec.topRules;
|
|
3643
|
-
this.dialects = spec.dialects || {};
|
|
3644
|
-
this.dynamicPrecedences = spec.dynamicPrecedences || null;
|
|
3645
|
-
this.tokenPrecTable = spec.tokenPrec;
|
|
3646
|
-
this.termNames = spec.termNames || null;
|
|
3647
|
-
this.maxNode = this.nodeSet.types.length - 1;
|
|
3648
|
-
this.dialect = this.parseDialect();
|
|
3649
|
-
this.top = this.topRules[Object.keys(this.topRules)[0]];
|
|
3650
|
-
}
|
|
3651
|
-
createParse(input, fragments, ranges) {
|
|
3652
|
-
let parse = new Parse(this, input, fragments, ranges);
|
|
3653
|
-
for (let w of this.wrappers)
|
|
3654
|
-
parse = w(parse, input, fragments, ranges);
|
|
3655
|
-
return parse;
|
|
3656
|
-
}
|
|
3657
|
-
/// Get a goto table entry @internal
|
|
3658
|
-
getGoto(state, term, loose = false) {
|
|
3659
|
-
let table = this.goto;
|
|
3660
|
-
if (term >= table[0])
|
|
3661
|
-
return -1;
|
|
3662
|
-
for (let pos = table[term + 1]; ; ) {
|
|
3663
|
-
let groupTag = table[pos++], last2 = groupTag & 1;
|
|
3664
|
-
let target = table[pos++];
|
|
3665
|
-
if (last2 && loose)
|
|
3666
|
-
return target;
|
|
3667
|
-
for (let end = pos + (groupTag >> 1); pos < end; pos++)
|
|
3668
|
-
if (table[pos] == state)
|
|
3669
|
-
return target;
|
|
3670
|
-
if (last2)
|
|
3671
|
-
return -1;
|
|
3672
|
-
}
|
|
3673
|
-
}
|
|
3674
|
-
/// Check if this state has an action for a given terminal @internal
|
|
3675
|
-
hasAction(state, terminal) {
|
|
3676
|
-
let data = this.data;
|
|
3677
|
-
for (let set = 0; set < 2; set++) {
|
|
3678
|
-
for (let i = this.stateSlot(
|
|
3679
|
-
state,
|
|
3680
|
-
set ? 2 : 1
|
|
3681
|
-
/* ParseState.Actions */
|
|
3682
|
-
), next; ; i += 3) {
|
|
3683
|
-
if ((next = data[i]) == 65535) {
|
|
3684
|
-
if (data[i + 1] == 1)
|
|
3685
|
-
next = data[i = pair(data, i + 2)];
|
|
3686
|
-
else if (data[i + 1] == 2)
|
|
3687
|
-
return pair(data, i + 2);
|
|
3688
|
-
else
|
|
3689
|
-
break;
|
|
3690
|
-
}
|
|
3691
|
-
if (next == terminal || next == 0)
|
|
3692
|
-
return pair(data, i + 1);
|
|
3693
|
-
}
|
|
3694
|
-
}
|
|
3695
|
-
return 0;
|
|
3696
|
-
}
|
|
3697
|
-
/// @internal
|
|
3698
|
-
stateSlot(state, slot) {
|
|
3699
|
-
return this.states[state * 6 + slot];
|
|
3700
|
-
}
|
|
3701
|
-
/// @internal
|
|
3702
|
-
stateFlag(state, flag) {
|
|
3703
|
-
return (this.stateSlot(
|
|
3704
|
-
state,
|
|
3705
|
-
0
|
|
3706
|
-
/* ParseState.Flags */
|
|
3707
|
-
) & flag) > 0;
|
|
3708
|
-
}
|
|
3709
|
-
/// @internal
|
|
3710
|
-
validAction(state, action) {
|
|
3711
|
-
return !!this.allActions(state, (a) => a == action ? true : null);
|
|
3712
|
-
}
|
|
3713
|
-
/// @internal
|
|
3714
|
-
allActions(state, action) {
|
|
3715
|
-
let deflt = this.stateSlot(
|
|
3716
|
-
state,
|
|
3717
|
-
4
|
|
3718
|
-
/* ParseState.DefaultReduce */
|
|
3719
|
-
);
|
|
3720
|
-
let result = deflt ? action(deflt) : void 0;
|
|
3721
|
-
for (let i = this.stateSlot(
|
|
3722
|
-
state,
|
|
3723
|
-
1
|
|
3724
|
-
/* ParseState.Actions */
|
|
3725
|
-
); result == null; i += 3) {
|
|
3726
|
-
if (this.data[i] == 65535) {
|
|
3727
|
-
if (this.data[i + 1] == 1)
|
|
3728
|
-
i = pair(this.data, i + 2);
|
|
3729
|
-
else
|
|
3730
|
-
break;
|
|
3731
|
-
}
|
|
3732
|
-
result = action(pair(this.data, i + 1));
|
|
3733
|
-
}
|
|
3734
|
-
return result;
|
|
3735
|
-
}
|
|
3736
|
-
/// Get the states that can follow this one through shift actions or
|
|
3737
|
-
/// goto jumps. @internal
|
|
3738
|
-
nextStates(state) {
|
|
3739
|
-
let result = [];
|
|
3740
|
-
for (let i = this.stateSlot(
|
|
3741
|
-
state,
|
|
3742
|
-
1
|
|
3743
|
-
/* ParseState.Actions */
|
|
3744
|
-
); ; i += 3) {
|
|
3745
|
-
if (this.data[i] == 65535) {
|
|
3746
|
-
if (this.data[i + 1] == 1)
|
|
3747
|
-
i = pair(this.data, i + 2);
|
|
3748
|
-
else
|
|
3749
|
-
break;
|
|
3750
|
-
}
|
|
3751
|
-
if ((this.data[i + 2] & 65536 >> 16) == 0) {
|
|
3752
|
-
let value = this.data[i + 1];
|
|
3753
|
-
if (!result.some((v, i2) => i2 & 1 && v == value))
|
|
3754
|
-
result.push(this.data[i], value);
|
|
3755
|
-
}
|
|
3756
|
-
}
|
|
3757
|
-
return result;
|
|
3758
|
-
}
|
|
3759
|
-
/// Configure the parser. Returns a new parser instance that has the
|
|
3760
|
-
/// given settings modified. Settings not provided in `config` are
|
|
3761
|
-
/// kept from the original parser.
|
|
3762
|
-
configure(config) {
|
|
3763
|
-
let copy = Object.assign(Object.create(_LRParser.prototype), this);
|
|
3764
|
-
if (config.props)
|
|
3765
|
-
copy.nodeSet = this.nodeSet.extend(...config.props);
|
|
3766
|
-
if (config.top) {
|
|
3767
|
-
let info = this.topRules[config.top];
|
|
3768
|
-
if (!info)
|
|
3769
|
-
throw new RangeError(`Invalid top rule name ${config.top}`);
|
|
3770
|
-
copy.top = info;
|
|
3771
|
-
}
|
|
3772
|
-
if (config.tokenizers)
|
|
3773
|
-
copy.tokenizers = this.tokenizers.map((t) => {
|
|
3774
|
-
let found = config.tokenizers.find((r) => r.from == t);
|
|
3775
|
-
return found ? found.to : t;
|
|
3776
|
-
});
|
|
3777
|
-
if (config.specializers) {
|
|
3778
|
-
copy.specializers = this.specializers.slice();
|
|
3779
|
-
copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
|
|
3780
|
-
let found = config.specializers.find((r) => r.from == s.external);
|
|
3781
|
-
if (!found)
|
|
3782
|
-
return s;
|
|
3783
|
-
let spec = Object.assign(Object.assign({}, s), { external: found.to });
|
|
3784
|
-
copy.specializers[i] = getSpecializer(spec);
|
|
3785
|
-
return spec;
|
|
3786
|
-
});
|
|
3787
|
-
}
|
|
3788
|
-
if (config.contextTracker)
|
|
3789
|
-
copy.context = config.contextTracker;
|
|
3790
|
-
if (config.dialect)
|
|
3791
|
-
copy.dialect = this.parseDialect(config.dialect);
|
|
3792
|
-
if (config.strict != null)
|
|
3793
|
-
copy.strict = config.strict;
|
|
3794
|
-
if (config.wrap)
|
|
3795
|
-
copy.wrappers = copy.wrappers.concat(config.wrap);
|
|
3796
|
-
if (config.bufferLength != null)
|
|
3797
|
-
copy.bufferLength = config.bufferLength;
|
|
3798
|
-
return copy;
|
|
3799
|
-
}
|
|
3800
|
-
/// Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
|
|
3801
|
-
/// are registered for this parser.
|
|
3802
|
-
hasWrappers() {
|
|
3803
|
-
return this.wrappers.length > 0;
|
|
3804
|
-
}
|
|
3805
|
-
/// Returns the name associated with a given term. This will only
|
|
3806
|
-
/// work for all terms when the parser was generated with the
|
|
3807
|
-
/// `--names` option. By default, only the names of tagged terms are
|
|
3808
|
-
/// stored.
|
|
3809
|
-
getName(term) {
|
|
3810
|
-
return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
|
|
3811
|
-
}
|
|
3812
|
-
/// The eof term id is always allocated directly after the node
|
|
3813
|
-
/// types. @internal
|
|
3814
|
-
get eofTerm() {
|
|
3815
|
-
return this.maxNode + 1;
|
|
3816
|
-
}
|
|
3817
|
-
/// The type of top node produced by the parser.
|
|
3818
|
-
get topNode() {
|
|
3819
|
-
return this.nodeSet.types[this.top[1]];
|
|
3820
|
-
}
|
|
3821
|
-
/// @internal
|
|
3822
|
-
dynamicPrecedence(term) {
|
|
3823
|
-
let prec = this.dynamicPrecedences;
|
|
3824
|
-
return prec == null ? 0 : prec[term] || 0;
|
|
3825
|
-
}
|
|
3826
|
-
/// @internal
|
|
3827
|
-
parseDialect(dialect) {
|
|
3828
|
-
let values = Object.keys(this.dialects), flags = values.map(() => false);
|
|
3829
|
-
if (dialect)
|
|
3830
|
-
for (let part of dialect.split(" ")) {
|
|
3831
|
-
let id = values.indexOf(part);
|
|
3832
|
-
if (id >= 0)
|
|
3833
|
-
flags[id] = true;
|
|
3834
|
-
}
|
|
3835
|
-
let disabled = null;
|
|
3836
|
-
for (let i = 0; i < values.length; i++)
|
|
3837
|
-
if (!flags[i]) {
|
|
3838
|
-
for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535; )
|
|
3839
|
-
(disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
|
|
3840
|
-
}
|
|
3841
|
-
return new Dialect(dialect, flags, disabled);
|
|
3842
|
-
}
|
|
3843
|
-
/// Used by the output of the parser generator. Not available to
|
|
3844
|
-
/// user code. @hide
|
|
3845
|
-
static deserialize(spec) {
|
|
3846
|
-
return new _LRParser(spec);
|
|
3847
|
-
}
|
|
3848
|
-
};
|
|
3849
|
-
function pair(data, off) {
|
|
3850
|
-
return data[off] | data[off + 1] << 16;
|
|
3851
|
-
}
|
|
3852
|
-
function findFinished(stacks) {
|
|
3853
|
-
let best = null;
|
|
3854
|
-
for (let stack of stacks) {
|
|
3855
|
-
let stopped = stack.p.stoppedAt;
|
|
3856
|
-
if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) && stack.p.parser.stateFlag(
|
|
3857
|
-
stack.state,
|
|
3858
|
-
2
|
|
3859
|
-
/* StateFlag.Accepting */
|
|
3860
|
-
) && (!best || best.score < stack.score))
|
|
3861
|
-
best = stack;
|
|
3862
|
-
}
|
|
3863
|
-
return best;
|
|
3864
|
-
}
|
|
3865
|
-
function getSpecializer(spec) {
|
|
3866
|
-
if (spec.external) {
|
|
3867
|
-
let mask = spec.extend ? 1 : 0;
|
|
3868
|
-
return (value, stack) => spec.external(value, stack) << 1 | mask;
|
|
3869
|
-
}
|
|
3870
|
-
return spec.get;
|
|
3871
|
-
}
|
|
3872
|
-
|
|
3873
|
-
// ../vuu-filter-parser/src/generated/filter-parser.js
|
|
3874
|
-
var parser = LRParser.deserialize({
|
|
3875
|
-
version: 14,
|
|
3876
|
-
states: "%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",
|
|
3877
|
-
stateData: "#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",
|
|
3878
|
-
goto: "#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",
|
|
3879
|
-
nodeNames: "\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",
|
|
3880
|
-
maxTerm: 39,
|
|
3881
|
-
skippedNodes: [0],
|
|
3882
|
-
repeatNodeCount: 1,
|
|
3883
|
-
tokenData: "6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",
|
|
3884
|
-
tokenizers: [0, 1],
|
|
3885
|
-
topRules: { "Filter": [0, 1] },
|
|
3886
|
-
tokenPrec: 0
|
|
3887
|
-
});
|
|
3888
|
-
|
|
3889
|
-
// ../vuu-utils/src/array-utils.ts
|
|
3890
|
-
var getAddedItems = (values, newValues) => {
|
|
3891
|
-
const isNew = (v) => !(values == null ? void 0 : values.includes(v));
|
|
3892
|
-
if (values === void 0) {
|
|
3893
|
-
return newValues;
|
|
3894
|
-
} else if (newValues.some(isNew)) {
|
|
3895
|
-
return newValues.filter(isNew);
|
|
3896
|
-
} else {
|
|
3897
|
-
return [];
|
|
3898
|
-
}
|
|
3899
|
-
};
|
|
3900
|
-
var getMissingItems = (sourceItems, items, identity) => items.filter((i) => sourceItems.findIndex((s) => identity(s) === i) === -1);
|
|
3901
|
-
|
|
3902
|
-
// ../vuu-utils/src/filter-utils.ts
|
|
3903
|
-
var singleValueFilterOps = /* @__PURE__ */ new Set([
|
|
3904
|
-
"=",
|
|
3905
|
-
"!=",
|
|
3906
|
-
">",
|
|
3907
|
-
">=",
|
|
3908
|
-
"<",
|
|
3909
|
-
"<=",
|
|
3910
|
-
"starts",
|
|
3911
|
-
"ends"
|
|
3912
|
-
]);
|
|
3913
|
-
var isSingleValueFilter = (f) => f !== void 0 && singleValueFilterOps.has(f.op);
|
|
3914
|
-
var isMultiValueFilter = (f) => f !== void 0 && f.op === "in";
|
|
3915
|
-
function isMultiClauseFilter(f) {
|
|
3916
|
-
return f !== void 0 && (f.op === "and" || f.op === "or");
|
|
3917
|
-
}
|
|
3918
|
-
|
|
3919
|
-
// ../vuu-utils/src/column-utils.ts
|
|
3920
|
-
var isKeyedColumn = (column) => {
|
|
3921
|
-
return typeof column.key === "number";
|
|
3922
|
-
};
|
|
3923
|
-
var EMPTY_COLUMN_MAP = {};
|
|
3924
|
-
function buildColumnMap(columns) {
|
|
3925
|
-
const start = metadataKeys.count;
|
|
3926
|
-
if (columns) {
|
|
3927
|
-
return columns.reduce((map, column, i) => {
|
|
3928
|
-
if (typeof column === "string") {
|
|
3929
|
-
map[column] = start + i;
|
|
3930
|
-
} else if (isKeyedColumn(column)) {
|
|
3931
|
-
map[column.name] = column.key;
|
|
3932
|
-
} else {
|
|
3933
|
-
map[column.name] = start + i;
|
|
3934
|
-
}
|
|
3935
|
-
return map;
|
|
3936
|
-
}, {});
|
|
3937
|
-
} else {
|
|
3938
|
-
return EMPTY_COLUMN_MAP;
|
|
3939
|
-
}
|
|
3940
|
-
}
|
|
3941
|
-
var metadataKeys = {
|
|
3942
|
-
IDX: 0,
|
|
3943
|
-
RENDER_IDX: 1,
|
|
3944
|
-
IS_LEAF: 2,
|
|
3945
|
-
IS_EXPANDED: 3,
|
|
3946
|
-
DEPTH: 4,
|
|
3947
|
-
COUNT: 5,
|
|
3948
|
-
KEY: 6,
|
|
3949
|
-
SELECTED: 7,
|
|
3950
|
-
count: 8,
|
|
3951
|
-
// TODO following only used in datamodel
|
|
3952
|
-
PARENT_IDX: "parent_idx",
|
|
3953
|
-
IDX_POINTER: "idx_pointer",
|
|
3954
|
-
FILTER_COUNT: "filter_count",
|
|
3955
|
-
NEXT_FILTER_IDX: "next_filter_idx"
|
|
3956
|
-
};
|
|
3957
|
-
var { DEPTH, IS_LEAF } = metadataKeys;
|
|
3958
|
-
|
|
3959
|
-
// ../vuu-utils/src/cookie-utils.ts
|
|
3960
|
-
var getCookieValue = (name) => {
|
|
3961
|
-
var _a, _b;
|
|
3962
|
-
if (((_a = globalThis.document) == null ? void 0 : _a.cookie) !== void 0) {
|
|
3963
|
-
return (_b = globalThis.document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _b.split("=")[1];
|
|
3964
|
-
}
|
|
3965
|
-
};
|
|
3966
|
-
|
|
3967
|
-
// ../vuu-utils/src/range-utils.ts
|
|
3968
|
-
var NULL_RANGE = { from: 0, to: 0 };
|
|
3969
|
-
function resetRange({ from, to, bufferSize = 0 }) {
|
|
3970
|
-
return {
|
|
3971
|
-
from: 0,
|
|
3972
|
-
to: to - from,
|
|
3973
|
-
bufferSize,
|
|
3974
|
-
reset: true
|
|
3975
|
-
};
|
|
3976
|
-
}
|
|
3977
|
-
var rangeNewItems = ({ from: from1, to: to1 }, newRange) => {
|
|
3978
|
-
const { from: from2, to: to2 } = newRange;
|
|
3979
|
-
const noOverlap = from2 >= to1 || to2 <= from1;
|
|
3980
|
-
const newFullySubsumesOld = from2 < from1 && to2 > to1;
|
|
3981
|
-
return noOverlap || newFullySubsumesOld ? newRange : to2 > to1 ? { from: to1, to: to2 } : { from: from2, to: from1 };
|
|
3982
|
-
};
|
|
3983
|
-
|
|
3984
|
-
// ../vuu-utils/src/datasource-utils.ts
|
|
3985
|
-
var NoFilter = { filter: "" };
|
|
3986
|
-
var NoSort = { sortDefs: [] };
|
|
3987
|
-
var vanillaConfig = {
|
|
3988
|
-
aggregations: [],
|
|
3989
|
-
columns: [],
|
|
3990
|
-
filter: NoFilter,
|
|
3991
|
-
groupBy: [],
|
|
3992
|
-
sort: NoSort
|
|
3993
|
-
};
|
|
3994
|
-
var equivalentAggregations = ({ aggregations: agg1 }, { aggregations: agg2 }) => agg1 === void 0 && (agg2 == null ? void 0 : agg2.length) === 0 || agg2 === void 0 && (agg1 == null ? void 0 : agg1.length) === 0;
|
|
3995
|
-
var equivalentColumns = ({ columns: cols1 }, { columns: cols2 }) => cols1 === void 0 && (cols2 == null ? void 0 : cols2.length) === 0 || cols2 === void 0 && (cols1 == null ? void 0 : cols1.length) === 0;
|
|
3996
|
-
var equivalentFilter = ({ filter: f1 }, { filter: f2 }) => f1 === void 0 && (f2 == null ? void 0 : f2.filter) === "" || f2 === void 0 && (f1 == null ? void 0 : f1.filter) === "";
|
|
3997
|
-
var equivalentGroupBy = ({ groupBy: val1 }, { groupBy: val2 }) => val1 === void 0 && (val2 == null ? void 0 : val2.length) === 0 || val2 === void 0 && (val1 == null ? void 0 : val1.length) === 0;
|
|
3998
|
-
var equivalentSort = ({ sort: s1 }, { sort: s2 }) => s1 === void 0 && (s2 == null ? void 0 : s2.sortDefs.length) === 0 || s2 === void 0 && (s1 == null ? void 0 : s1.sortDefs.length) === 0;
|
|
3999
|
-
var exactlyTheSame = (a, b) => {
|
|
4000
|
-
if (a === b) {
|
|
4001
|
-
return true;
|
|
4002
|
-
} else if (a === void 0 && b === void 0) {
|
|
4003
|
-
return true;
|
|
4004
|
-
} else {
|
|
4005
|
-
return false;
|
|
4006
|
-
}
|
|
4007
|
-
};
|
|
4008
|
-
var aggregationsChanged = (config, newConfig) => {
|
|
4009
|
-
const { aggregations: agg1 } = config;
|
|
4010
|
-
const { aggregations: agg2 } = newConfig;
|
|
4011
|
-
if (exactlyTheSame(agg1, agg2) || equivalentAggregations(config, newConfig)) {
|
|
4012
|
-
return false;
|
|
4013
|
-
} else if (agg1 === void 0 || agg2 === void 0) {
|
|
4014
|
-
return true;
|
|
4015
|
-
} else if (agg1.length !== agg2.length) {
|
|
4016
|
-
return true;
|
|
4017
|
-
}
|
|
4018
|
-
return agg1.some(
|
|
4019
|
-
({ column, aggType }, i) => column !== agg2[i].column || aggType !== agg2[i].aggType
|
|
4020
|
-
);
|
|
4021
|
-
};
|
|
4022
|
-
var columnsChanged = (config, newConfig) => {
|
|
4023
|
-
const { columns: cols1 } = config;
|
|
4024
|
-
const { columns: cols2 } = newConfig;
|
|
4025
|
-
if (exactlyTheSame(cols1, cols2) || equivalentColumns(config, newConfig)) {
|
|
4026
|
-
return false;
|
|
4027
|
-
} else if (cols1 === void 0 || cols2 === void 0) {
|
|
4028
|
-
return true;
|
|
4029
|
-
} else if ((cols1 == null ? void 0 : cols1.length) !== (cols2 == null ? void 0 : cols2.length)) {
|
|
4030
|
-
return true;
|
|
4031
|
-
}
|
|
4032
|
-
return cols1.some((column, i) => column !== (cols2 == null ? void 0 : cols2[i]));
|
|
4033
|
-
};
|
|
4034
|
-
var filterChanged = (c1, c2) => {
|
|
4035
|
-
var _a, _b;
|
|
4036
|
-
if (equivalentFilter(c1, c2)) {
|
|
4037
|
-
return false;
|
|
4038
|
-
} else {
|
|
4039
|
-
return ((_a = c1.filter) == null ? void 0 : _a.filter) !== ((_b = c2.filter) == null ? void 0 : _b.filter);
|
|
4040
|
-
}
|
|
4041
|
-
};
|
|
4042
|
-
var groupByChanged = (config, newConfig) => {
|
|
4043
|
-
const { groupBy: g1 } = config;
|
|
4044
|
-
const { groupBy: g2 } = newConfig;
|
|
4045
|
-
if (exactlyTheSame(g1, g2) || equivalentGroupBy(config, newConfig)) {
|
|
4046
|
-
return false;
|
|
4047
|
-
} else if (g1 === void 0 || g2 === void 0) {
|
|
4048
|
-
return true;
|
|
4049
|
-
} else if ((g1 == null ? void 0 : g1.length) !== (g2 == null ? void 0 : g2.length)) {
|
|
4050
|
-
return true;
|
|
4051
|
-
}
|
|
4052
|
-
return g1.some((column, i) => column !== (g2 == null ? void 0 : g2[i]));
|
|
4053
|
-
};
|
|
4054
|
-
var sortChanged = (config, newConfig) => {
|
|
4055
|
-
const { sort: s1 } = config;
|
|
4056
|
-
const { sort: s2 } = newConfig;
|
|
4057
|
-
if (exactlyTheSame(s1, s2) || equivalentSort(config, newConfig)) {
|
|
4058
|
-
return false;
|
|
4059
|
-
} else if (s1 === void 0 || s2 === void 0) {
|
|
4060
|
-
return true;
|
|
4061
|
-
} else if ((s1 == null ? void 0 : s1.sortDefs.length) !== (s2 == null ? void 0 : s2.sortDefs.length)) {
|
|
4062
|
-
return true;
|
|
4063
|
-
}
|
|
4064
|
-
return s1.sortDefs.some(
|
|
4065
|
-
({ column, sortType }, i) => column !== s2.sortDefs[i].column || sortType !== s2.sortDefs[i].sortType
|
|
4066
|
-
);
|
|
4067
|
-
};
|
|
4068
|
-
var visualLinkChanged = () => {
|
|
4069
|
-
return false;
|
|
4070
|
-
};
|
|
4071
|
-
var configChanged = (config, newConfig) => {
|
|
4072
|
-
if (exactlyTheSame(config, newConfig)) {
|
|
4073
|
-
return false;
|
|
4074
|
-
}
|
|
4075
|
-
if (config === void 0 || newConfig === void 0) {
|
|
4076
|
-
return true;
|
|
4077
|
-
}
|
|
4078
|
-
return aggregationsChanged(config, newConfig) || columnsChanged(config, newConfig) || filterChanged(config, newConfig) || groupByChanged(config, newConfig) || sortChanged(config, newConfig) || visualLinkChanged(config, newConfig);
|
|
4079
|
-
};
|
|
4080
|
-
var hasGroupBy = (config) => config !== void 0 && config.groupBy !== void 0 && config.groupBy.length > 0;
|
|
4081
|
-
var hasFilter = (config) => (config == null ? void 0 : config.filter) !== void 0 && config.filter.filter.length > 0;
|
|
4082
|
-
var hasSort = (config) => {
|
|
4083
|
-
var _a;
|
|
4084
|
-
return (config == null ? void 0 : config.sort) !== void 0 && Array.isArray((_a = config.sort) == null ? void 0 : _a.sortDefs) && config.sort.sortDefs.length > 0;
|
|
4085
|
-
};
|
|
4086
|
-
var withConfigDefaults = (config) => {
|
|
4087
|
-
if (config.aggregations && config.columns && config.filter && config.groupBy && config.sort) {
|
|
4088
|
-
return config;
|
|
4089
|
-
} else {
|
|
4090
|
-
const {
|
|
4091
|
-
aggregations = [],
|
|
4092
|
-
columns = [],
|
|
4093
|
-
filter = { filter: "" },
|
|
4094
|
-
groupBy = [],
|
|
4095
|
-
sort = { sortDefs: [] },
|
|
4096
|
-
visualLink
|
|
4097
|
-
} = config;
|
|
4098
|
-
return {
|
|
4099
|
-
aggregations,
|
|
4100
|
-
columns,
|
|
4101
|
-
filter,
|
|
4102
|
-
groupBy,
|
|
4103
|
-
sort,
|
|
4104
|
-
visualLink
|
|
4105
|
-
};
|
|
4106
|
-
}
|
|
4107
|
-
};
|
|
4108
|
-
|
|
4109
|
-
// ../vuu-utils/src/logging-utils.ts
|
|
4110
|
-
var logLevels = ["error", "warn", "info", "debug"];
|
|
4111
|
-
var isValidLogLevel = (value) => typeof value === "string" && logLevels.includes(value);
|
|
4112
|
-
var DEFAULT_LOG_LEVEL = "error";
|
|
4113
|
-
var NO_OP = () => void 0;
|
|
4114
|
-
var DEFAULT_DEBUG_LEVEL = false ? "error" : "info";
|
|
4115
|
-
var { loggingLevel = DEFAULT_DEBUG_LEVEL } = getLoggingSettings();
|
|
4116
|
-
var logger = (category) => {
|
|
4117
|
-
const debugEnabled = loggingLevel === "debug";
|
|
4118
|
-
const infoEnabled = debugEnabled || loggingLevel === "info";
|
|
4119
|
-
const warnEnabled = infoEnabled || loggingLevel === "warn";
|
|
4120
|
-
const errorEnabled = warnEnabled || loggingLevel === "error";
|
|
4121
|
-
const info = infoEnabled ? (message) => console.info(`[${category}] ${message}`) : NO_OP;
|
|
4122
|
-
const warn = warnEnabled ? (message) => console.warn(`[${category}] ${message}`) : NO_OP;
|
|
4123
|
-
const debug2 = debugEnabled ? (message) => console.debug(`[${category}] ${message}`) : NO_OP;
|
|
4124
|
-
const error = errorEnabled ? (message) => console.error(`[${category}] ${message}`) : NO_OP;
|
|
4125
|
-
if (false) {
|
|
4126
|
-
return {
|
|
4127
|
-
errorEnabled,
|
|
4128
|
-
error
|
|
4129
|
-
};
|
|
4130
|
-
} else {
|
|
4131
|
-
return {
|
|
4132
|
-
debugEnabled,
|
|
4133
|
-
infoEnabled,
|
|
4134
|
-
warnEnabled,
|
|
4135
|
-
errorEnabled,
|
|
4136
|
-
info,
|
|
4137
|
-
warn,
|
|
4138
|
-
debug: debug2,
|
|
4139
|
-
error
|
|
4140
|
-
};
|
|
4141
|
-
}
|
|
4142
|
-
};
|
|
4143
|
-
function getLoggingSettings() {
|
|
4144
|
-
if (typeof loggingSettings !== "undefined") {
|
|
4145
|
-
return loggingSettings;
|
|
4146
|
-
} else {
|
|
4147
|
-
return {
|
|
4148
|
-
loggingLevel: getLoggingLevelFromCookie()
|
|
4149
|
-
};
|
|
4150
|
-
}
|
|
4151
|
-
}
|
|
4152
|
-
function getLoggingLevelFromCookie() {
|
|
4153
|
-
const value = getCookieValue("vuu-logging-level");
|
|
4154
|
-
if (isValidLogLevel(value)) {
|
|
4155
|
-
return value;
|
|
4156
|
-
} else {
|
|
4157
|
-
return DEFAULT_LOG_LEVEL;
|
|
4158
|
-
}
|
|
4159
|
-
}
|
|
4160
|
-
|
|
4161
|
-
// ../vuu-utils/src/event-emitter.ts
|
|
4162
|
-
function isArrayOfListeners(listeners) {
|
|
4163
|
-
return Array.isArray(listeners);
|
|
4164
|
-
}
|
|
4165
|
-
function isOnlyListener(listeners) {
|
|
4166
|
-
return !Array.isArray(listeners);
|
|
4167
|
-
}
|
|
4168
|
-
var _events;
|
|
4169
|
-
var EventEmitter = class {
|
|
4170
|
-
constructor() {
|
|
4171
|
-
__privateAdd(this, _events, /* @__PURE__ */ new Map());
|
|
4172
|
-
}
|
|
4173
|
-
addListener(event, listener) {
|
|
4174
|
-
const listeners = __privateGet(this, _events).get(event);
|
|
4175
|
-
if (!listeners) {
|
|
4176
|
-
__privateGet(this, _events).set(event, listener);
|
|
4177
|
-
} else if (isArrayOfListeners(listeners)) {
|
|
4178
|
-
listeners.push(listener);
|
|
4179
|
-
} else if (isOnlyListener(listeners)) {
|
|
4180
|
-
__privateGet(this, _events).set(event, [listeners, listener]);
|
|
4181
|
-
}
|
|
4182
|
-
}
|
|
4183
|
-
removeListener(event, listener) {
|
|
4184
|
-
if (!__privateGet(this, _events).has(event)) {
|
|
4185
|
-
return;
|
|
4186
|
-
}
|
|
4187
|
-
const listenerOrListeners = __privateGet(this, _events).get(event);
|
|
4188
|
-
let position = -1;
|
|
4189
|
-
if (listenerOrListeners === listener) {
|
|
4190
|
-
__privateGet(this, _events).delete(event);
|
|
4191
|
-
} else if (Array.isArray(listenerOrListeners)) {
|
|
4192
|
-
for (let i = length; i-- > 0; ) {
|
|
4193
|
-
if (listenerOrListeners[i] === listener) {
|
|
4194
|
-
position = i;
|
|
4195
|
-
break;
|
|
4196
|
-
}
|
|
4197
|
-
}
|
|
4198
|
-
if (position < 0) {
|
|
4199
|
-
return;
|
|
4200
|
-
}
|
|
4201
|
-
if (listenerOrListeners.length === 1) {
|
|
4202
|
-
listenerOrListeners.length = 0;
|
|
4203
|
-
__privateGet(this, _events).delete(event);
|
|
4204
|
-
} else {
|
|
4205
|
-
listenerOrListeners.splice(position, 1);
|
|
4206
|
-
}
|
|
4207
|
-
}
|
|
4208
|
-
}
|
|
4209
|
-
removeAllListeners(event) {
|
|
4210
|
-
if (event && __privateGet(this, _events).has(event)) {
|
|
4211
|
-
__privateGet(this, _events).delete(event);
|
|
4212
|
-
} else if (event === void 0) {
|
|
4213
|
-
__privateGet(this, _events).clear();
|
|
4214
|
-
}
|
|
4215
|
-
}
|
|
4216
|
-
emit(event, ...args) {
|
|
4217
|
-
if (__privateGet(this, _events)) {
|
|
4218
|
-
const handler = __privateGet(this, _events).get(event);
|
|
4219
|
-
if (handler) {
|
|
4220
|
-
this.invokeHandler(handler, args);
|
|
4221
|
-
}
|
|
4222
|
-
}
|
|
4223
|
-
}
|
|
4224
|
-
once(event, listener) {
|
|
4225
|
-
const handler = (...args) => {
|
|
4226
|
-
this.removeListener(event, handler);
|
|
4227
|
-
listener(...args);
|
|
4228
|
-
};
|
|
4229
|
-
this.on(event, handler);
|
|
4230
|
-
}
|
|
4231
|
-
on(event, listener) {
|
|
4232
|
-
this.addListener(event, listener);
|
|
4233
|
-
}
|
|
4234
|
-
hasListener(event, listener) {
|
|
4235
|
-
const listeners = __privateGet(this, _events).get(event);
|
|
4236
|
-
if (Array.isArray(listeners)) {
|
|
4237
|
-
return listeners.includes(listener);
|
|
4238
|
-
} else {
|
|
4239
|
-
return listeners === listener;
|
|
4240
|
-
}
|
|
4241
|
-
}
|
|
4242
|
-
invokeHandler(handler, args) {
|
|
4243
|
-
if (isArrayOfListeners(handler)) {
|
|
4244
|
-
handler.slice().forEach((listener) => this.invokeHandler(listener, args));
|
|
4245
|
-
} else {
|
|
4246
|
-
switch (args.length) {
|
|
4247
|
-
case 0:
|
|
4248
|
-
handler();
|
|
4249
|
-
break;
|
|
4250
|
-
case 1:
|
|
4251
|
-
handler(args[0]);
|
|
4252
|
-
break;
|
|
4253
|
-
case 2:
|
|
4254
|
-
handler(args[0], args[1]);
|
|
4255
|
-
break;
|
|
4256
|
-
default:
|
|
4257
|
-
handler.call(null, ...args);
|
|
4258
|
-
}
|
|
4259
|
-
}
|
|
4260
|
-
}
|
|
4261
|
-
};
|
|
4262
|
-
_events = new WeakMap();
|
|
4263
|
-
|
|
4264
|
-
// ../vuu-utils/src/keyset.ts
|
|
4265
|
-
var KeySet = class {
|
|
4266
|
-
constructor(range) {
|
|
4267
|
-
this.keys = /* @__PURE__ */ new Map();
|
|
4268
|
-
this.free = [];
|
|
4269
|
-
this.nextKeyValue = 0;
|
|
4270
|
-
this.reset(range);
|
|
4271
|
-
}
|
|
4272
|
-
next() {
|
|
4273
|
-
if (this.free.length > 0) {
|
|
4274
|
-
return this.free.pop();
|
|
4275
|
-
} else {
|
|
4276
|
-
return this.nextKeyValue++;
|
|
4277
|
-
}
|
|
4278
|
-
}
|
|
4279
|
-
reset({ from, to }) {
|
|
4280
|
-
this.keys.forEach((keyValue, rowIndex) => {
|
|
4281
|
-
if (rowIndex < from || rowIndex >= to) {
|
|
4282
|
-
this.free.push(keyValue);
|
|
4283
|
-
this.keys.delete(rowIndex);
|
|
4284
|
-
}
|
|
4285
|
-
});
|
|
4286
|
-
const size = to - from;
|
|
4287
|
-
if (this.keys.size + this.free.length > size) {
|
|
4288
|
-
this.free.length = Math.max(0, size - this.keys.size);
|
|
4289
|
-
}
|
|
4290
|
-
for (let rowIndex = from; rowIndex < to; rowIndex++) {
|
|
4291
|
-
if (!this.keys.has(rowIndex)) {
|
|
4292
|
-
const nextKeyValue = this.next();
|
|
4293
|
-
this.keys.set(rowIndex, nextKeyValue);
|
|
4294
|
-
}
|
|
4295
|
-
}
|
|
4296
|
-
if (this.nextKeyValue > this.keys.size) {
|
|
4297
|
-
this.nextKeyValue = this.keys.size;
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
keyFor(rowIndex) {
|
|
4301
|
-
const key = this.keys.get(rowIndex);
|
|
4302
|
-
if (key === void 0) {
|
|
4303
|
-
console.log(`key not found
|
|
4304
|
-
keys: ${this.toDebugString()}
|
|
4305
|
-
free : ${this.free.join(",")}
|
|
4306
|
-
`);
|
|
4307
|
-
throw Error(`KeySet, no key found for rowIndex ${rowIndex}`);
|
|
4308
|
-
}
|
|
4309
|
-
return key;
|
|
4310
|
-
}
|
|
4311
|
-
toDebugString() {
|
|
4312
|
-
return Array.from(this.keys.entries()).map((k, v) => `${k}=>${v}`).join(",");
|
|
4313
|
-
}
|
|
4314
|
-
};
|
|
4315
|
-
|
|
4316
|
-
// ../vuu-utils/src/nanoid/index.ts
|
|
4317
|
-
var uuid = (size = 21) => {
|
|
4318
|
-
let id = "";
|
|
4319
|
-
const bytes = crypto.getRandomValues(new Uint8Array(size));
|
|
4320
|
-
while (size--) {
|
|
4321
|
-
const byte = bytes[size] & 63;
|
|
4322
|
-
if (byte < 36) {
|
|
4323
|
-
id += byte.toString(36);
|
|
4324
|
-
} else if (byte < 62) {
|
|
4325
|
-
id += (byte - 26).toString(36).toUpperCase();
|
|
4326
|
-
} else if (byte < 63) {
|
|
4327
|
-
id += "_";
|
|
4328
|
-
} else {
|
|
4329
|
-
id += "-";
|
|
4330
|
-
}
|
|
4331
|
-
}
|
|
4332
|
-
return id;
|
|
4333
|
-
};
|
|
4334
|
-
|
|
4335
|
-
// ../vuu-utils/src/selection-utils.ts
|
|
4336
|
-
var { SELECTED } = metadataKeys;
|
|
4337
|
-
var RowSelected = {
|
|
4338
|
-
False: 0,
|
|
4339
|
-
True: 1,
|
|
4340
|
-
First: 2,
|
|
4341
|
-
Last: 4
|
|
4342
|
-
};
|
|
4343
|
-
var rangeIncludes = (range, index) => index >= range[0] && index <= range[1];
|
|
4344
|
-
var SINGLE_SELECTED_ROW = RowSelected.True + RowSelected.First + RowSelected.Last;
|
|
4345
|
-
var FIRST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.First;
|
|
4346
|
-
var LAST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.Last;
|
|
4347
|
-
var getSelectionStatus = (selected, itemIndex) => {
|
|
4348
|
-
for (const item of selected) {
|
|
4349
|
-
if (typeof item === "number") {
|
|
4350
|
-
if (item === itemIndex) {
|
|
4351
|
-
return SINGLE_SELECTED_ROW;
|
|
4352
|
-
}
|
|
4353
|
-
} else if (rangeIncludes(item, itemIndex)) {
|
|
4354
|
-
if (itemIndex === item[0]) {
|
|
4355
|
-
return FIRST_SELECTED_ROW_OF_BLOCK;
|
|
4356
|
-
} else if (itemIndex === item[1]) {
|
|
4357
|
-
return LAST_SELECTED_ROW_OF_BLOCK;
|
|
4358
|
-
} else {
|
|
4359
|
-
return RowSelected.True;
|
|
4360
|
-
}
|
|
4361
|
-
}
|
|
4362
|
-
}
|
|
4363
|
-
return RowSelected.False;
|
|
4364
|
-
};
|
|
4365
|
-
|
|
4366
|
-
// ../vuu-filter-parser/src/FilterTreeWalker.ts
|
|
4367
|
-
var _filter;
|
|
4368
|
-
var FilterExpression = class {
|
|
4369
|
-
constructor() {
|
|
4370
|
-
__privateAdd(this, _filter, void 0);
|
|
4371
|
-
}
|
|
4372
|
-
setFilterCombinatorOp(op, filter = __privateGet(this, _filter)) {
|
|
4373
|
-
if (isMultiClauseFilter(filter) && filter.op === op) {
|
|
4374
|
-
return;
|
|
4375
|
-
} else {
|
|
4376
|
-
__privateSet(this, _filter, {
|
|
4377
|
-
op,
|
|
4378
|
-
filters: [__privateGet(this, _filter)]
|
|
4379
|
-
});
|
|
4380
|
-
}
|
|
4381
|
-
}
|
|
4382
|
-
add(filter) {
|
|
4383
|
-
if (__privateGet(this, _filter) === void 0) {
|
|
4384
|
-
__privateSet(this, _filter, filter);
|
|
4385
|
-
} else if (isMultiClauseFilter(__privateGet(this, _filter))) {
|
|
4386
|
-
__privateGet(this, _filter).filters.push(filter);
|
|
4387
|
-
} else {
|
|
4388
|
-
throw Error(`Invalid filter passed to FilterExpression`);
|
|
4389
|
-
}
|
|
4390
|
-
}
|
|
4391
|
-
setColumn(column, filter = __privateGet(this, _filter)) {
|
|
4392
|
-
if (isMultiClauseFilter(filter)) {
|
|
4393
|
-
const target = filter.filters.at(-1);
|
|
4394
|
-
if (target) {
|
|
4395
|
-
this.setColumn(column, target);
|
|
4396
|
-
}
|
|
4397
|
-
} else if (filter) {
|
|
4398
|
-
filter.column = column;
|
|
4399
|
-
}
|
|
4400
|
-
}
|
|
4401
|
-
setOp(value, filter = __privateGet(this, _filter)) {
|
|
4402
|
-
if (isMultiClauseFilter(filter)) {
|
|
4403
|
-
const target = filter.filters.at(-1);
|
|
4404
|
-
if (target) {
|
|
4405
|
-
this.setOp(value, target);
|
|
4406
|
-
}
|
|
4407
|
-
} else if (filter) {
|
|
4408
|
-
filter.op = value;
|
|
4409
|
-
}
|
|
4410
|
-
}
|
|
4411
|
-
setValue(value, filter = __privateGet(this, _filter)) {
|
|
4412
|
-
var _a;
|
|
4413
|
-
if (isMultiClauseFilter(filter)) {
|
|
4414
|
-
const target = filter.filters.at(-1);
|
|
4415
|
-
if (target) {
|
|
4416
|
-
this.setValue(value, target);
|
|
4417
|
-
}
|
|
4418
|
-
} else if (isMultiValueFilter(filter)) {
|
|
4419
|
-
(_a = filter.values) != null ? _a : filter.values = [];
|
|
4420
|
-
filter.values.push(value);
|
|
4421
|
-
} else if (isSingleValueFilter(filter)) {
|
|
4422
|
-
filter.value = value;
|
|
4423
|
-
}
|
|
4424
|
-
}
|
|
4425
|
-
toJSON(filter = __privateGet(this, _filter)) {
|
|
4426
|
-
if (this.name) {
|
|
4427
|
-
return {
|
|
4428
|
-
...filter,
|
|
4429
|
-
name: this.name
|
|
4430
|
-
};
|
|
4431
|
-
} else {
|
|
4432
|
-
return filter;
|
|
4433
|
-
}
|
|
4434
|
-
}
|
|
4435
|
-
};
|
|
4436
|
-
_filter = new WeakMap();
|
|
4437
|
-
var walkTree = (tree, source) => {
|
|
4438
|
-
const filterExpression = new FilterExpression();
|
|
4439
|
-
const cursor = tree.cursor();
|
|
4440
|
-
do {
|
|
4441
|
-
const { name, from, to } = cursor;
|
|
4442
|
-
switch (name) {
|
|
4443
|
-
case "ColumnValueExpression":
|
|
4444
|
-
filterExpression.add({});
|
|
4445
|
-
break;
|
|
4446
|
-
case "ColumnSetExpression":
|
|
4447
|
-
filterExpression.add({ op: "in" });
|
|
4448
|
-
break;
|
|
4449
|
-
case "Or":
|
|
4450
|
-
case "And":
|
|
4451
|
-
filterExpression.setFilterCombinatorOp(source.substring(from, to));
|
|
4452
|
-
break;
|
|
4453
|
-
case "Column":
|
|
4454
|
-
filterExpression.setColumn(source.substring(from, to));
|
|
4455
|
-
break;
|
|
4456
|
-
case "Operator":
|
|
4457
|
-
filterExpression.setOp(source.substring(from, to));
|
|
4458
|
-
break;
|
|
4459
|
-
case "String":
|
|
4460
|
-
filterExpression.setValue(source.substring(from + 1, to - 1));
|
|
4461
|
-
break;
|
|
4462
|
-
case "Number":
|
|
4463
|
-
filterExpression.setValue(parseFloat(source.substring(from, to)));
|
|
4464
|
-
break;
|
|
4465
|
-
case "True":
|
|
4466
|
-
filterExpression.setValue(true);
|
|
4467
|
-
break;
|
|
4468
|
-
case "False":
|
|
4469
|
-
filterExpression.setValue(false);
|
|
4470
|
-
break;
|
|
4471
|
-
case "FilterName":
|
|
4472
|
-
filterExpression.name = source.substring(from, to);
|
|
4473
|
-
break;
|
|
4474
|
-
default:
|
|
4475
|
-
}
|
|
4476
|
-
} while (cursor.next());
|
|
4477
|
-
return filterExpression.toJSON();
|
|
4478
|
-
};
|
|
4479
|
-
|
|
4480
|
-
// ../vuu-filter-parser/src/FilterParser.ts
|
|
4481
|
-
var strictParser = parser.configure({ strict: true });
|
|
4482
|
-
var parseFilter = (filterQuery) => {
|
|
4483
|
-
const parseTree = strictParser.parse(filterQuery);
|
|
4484
|
-
const filter = walkTree(parseTree, filterQuery);
|
|
4485
|
-
return filter;
|
|
4486
|
-
};
|
|
4487
|
-
|
|
4488
|
-
// ../vuu-filter-parser/src/filter-evaluation-utils.ts
|
|
4489
|
-
function filterPredicate(columnMap, filter) {
|
|
4490
|
-
switch (filter.op) {
|
|
4491
|
-
case "in":
|
|
4492
|
-
return testInclude(columnMap, filter);
|
|
4493
|
-
case "=":
|
|
4494
|
-
return testEQ(columnMap, filter);
|
|
4495
|
-
case ">":
|
|
4496
|
-
return testGT(columnMap, filter);
|
|
4497
|
-
case ">=":
|
|
4498
|
-
return testGE(columnMap, filter);
|
|
4499
|
-
case "<":
|
|
4500
|
-
return testLT(columnMap, filter);
|
|
4501
|
-
case "<=":
|
|
4502
|
-
return testLE(columnMap, filter);
|
|
4503
|
-
case "starts":
|
|
4504
|
-
return testSW(columnMap, filter);
|
|
4505
|
-
case "and":
|
|
4506
|
-
return testAND(columnMap, filter);
|
|
4507
|
-
case "or":
|
|
4508
|
-
return testOR(columnMap, filter);
|
|
4509
|
-
default:
|
|
4510
|
-
console.log(`unrecognized filter type ${filter.op}`);
|
|
4511
|
-
return () => true;
|
|
4512
|
-
}
|
|
4513
|
-
}
|
|
4514
|
-
var testInclude = (columnMap, filter) => {
|
|
4515
|
-
return (row) => filter.values.indexOf(row[columnMap[filter.column]]) !== -1;
|
|
4516
|
-
};
|
|
4517
|
-
var testEQ = (columnMap, filter) => {
|
|
4518
|
-
return (row) => row[columnMap[filter.column]] === filter.value;
|
|
4519
|
-
};
|
|
4520
|
-
var testGT = (columnMap, filter) => {
|
|
4521
|
-
return (row) => row[columnMap[filter.column]] > filter.value;
|
|
4522
|
-
};
|
|
4523
|
-
var testGE = (columnMap, filter) => {
|
|
4524
|
-
return (row) => row[columnMap[filter.column]] >= filter.value;
|
|
4525
|
-
};
|
|
4526
|
-
var testLT = (columnMap, filter) => {
|
|
4527
|
-
return (row) => row[columnMap[filter.column]] < filter.value;
|
|
4528
|
-
};
|
|
4529
|
-
var testLE = (columnMap, filter) => {
|
|
4530
|
-
return (row) => row[columnMap[filter.column]] <= filter.value;
|
|
4531
|
-
};
|
|
4532
|
-
var testSW = (columnMap, filter) => {
|
|
4533
|
-
const filterValue = filter.value;
|
|
4534
|
-
if (typeof filterValue !== "string") {
|
|
4535
|
-
throw Error("string filter applied to value of wrong type");
|
|
4536
|
-
}
|
|
4537
|
-
return (row) => {
|
|
4538
|
-
const rowValue = row[columnMap[filter.column]];
|
|
4539
|
-
if (typeof rowValue !== "string") {
|
|
4540
|
-
throw Error("string filter applied to value of wrong type");
|
|
4541
|
-
}
|
|
4542
|
-
return rowValue.toLowerCase().startsWith(filterValue.toLowerCase());
|
|
4543
|
-
};
|
|
4544
|
-
};
|
|
4545
|
-
var testAND = (columnMap, filter) => {
|
|
4546
|
-
const filters = filter.filters.map((f1) => filterPredicate(columnMap, f1));
|
|
4547
|
-
return (row) => filters.every((fn) => fn(row));
|
|
4548
|
-
};
|
|
4549
|
-
function testOR(columnMap, filter) {
|
|
4550
|
-
const filters = filter.filters.map((f1) => filterPredicate(columnMap, f1));
|
|
4551
|
-
return (row) => filters.some((fn) => fn(row));
|
|
4552
|
-
}
|
|
4553
|
-
|
|
4554
|
-
// ../vuu-data-local/src/array-data-source/aggregate-utils.ts
|
|
4555
|
-
var aggregateData = (aggregations, targetData, groupBy, leafData, columnMap, groupMap) => {
|
|
4556
|
-
const aggColumn = getAggColumn(columnMap, aggregations);
|
|
4557
|
-
const aggType = aggregations[aggregations.length - 1].aggType;
|
|
4558
|
-
const groupIndices = groupBy.map((column) => columnMap[column]);
|
|
4559
|
-
switch (aggType) {
|
|
4560
|
-
case 1:
|
|
4561
|
-
return aggregateSum(
|
|
4562
|
-
groupMap,
|
|
4563
|
-
leafData,
|
|
4564
|
-
columnMap,
|
|
4565
|
-
aggregations,
|
|
4566
|
-
targetData,
|
|
4567
|
-
groupIndices
|
|
4568
|
-
);
|
|
4569
|
-
case 2:
|
|
4570
|
-
return aggregateAverage(
|
|
4571
|
-
groupMap,
|
|
4572
|
-
leafData,
|
|
4573
|
-
columnMap,
|
|
4574
|
-
aggregations,
|
|
4575
|
-
targetData,
|
|
4576
|
-
groupIndices
|
|
4577
|
-
);
|
|
4578
|
-
case 3:
|
|
4579
|
-
return aggregateCount(
|
|
4580
|
-
groupMap,
|
|
4581
|
-
columnMap,
|
|
4582
|
-
aggregations,
|
|
4583
|
-
targetData,
|
|
4584
|
-
groupIndices
|
|
4585
|
-
);
|
|
4586
|
-
case 4:
|
|
4587
|
-
return aggregateHigh(
|
|
4588
|
-
groupMap,
|
|
4589
|
-
leafData,
|
|
4590
|
-
columnMap,
|
|
4591
|
-
aggregations,
|
|
4592
|
-
targetData,
|
|
4593
|
-
groupIndices
|
|
4594
|
-
);
|
|
4595
|
-
case 5:
|
|
4596
|
-
return aggregateLow(
|
|
4597
|
-
groupMap,
|
|
4598
|
-
leafData,
|
|
4599
|
-
columnMap,
|
|
4600
|
-
aggregations,
|
|
4601
|
-
targetData,
|
|
4602
|
-
groupIndices
|
|
4603
|
-
);
|
|
4604
|
-
case 6:
|
|
4605
|
-
return aggregateDistinct(
|
|
4606
|
-
groupMap,
|
|
4607
|
-
leafData,
|
|
4608
|
-
columnMap,
|
|
4609
|
-
aggregations,
|
|
4610
|
-
targetData,
|
|
4611
|
-
groupIndices
|
|
4612
|
-
);
|
|
4613
|
-
}
|
|
4614
|
-
};
|
|
4615
|
-
function aggregateCount(groupMap, columnMap, aggregations, targetData, groupIndices) {
|
|
4616
|
-
const counts = {};
|
|
4617
|
-
const aggColumn = getAggColumn(columnMap, aggregations);
|
|
4618
|
-
function countRecursive(map) {
|
|
4619
|
-
if (Array.isArray(map)) {
|
|
4620
|
-
return map.length;
|
|
4621
|
-
} else {
|
|
4622
|
-
let count = 0;
|
|
4623
|
-
for (const key in map) {
|
|
4624
|
-
count += 1 + countRecursive(map[key]);
|
|
4625
|
-
}
|
|
4626
|
-
return count;
|
|
4627
|
-
}
|
|
4628
|
-
}
|
|
4629
|
-
for (const key in groupMap) {
|
|
4630
|
-
const count = countRecursive(groupMap[key]);
|
|
4631
|
-
counts[key] = count;
|
|
4632
|
-
}
|
|
4633
|
-
for (let index = 0; index < targetData.length; index++) {
|
|
4634
|
-
for (const key in counts) {
|
|
4635
|
-
if (targetData[index][groupIndices[0]] === key) {
|
|
4636
|
-
targetData[index][aggColumn] = counts[key];
|
|
4637
|
-
}
|
|
4638
|
-
}
|
|
4639
|
-
}
|
|
4640
|
-
console.log("!!!! targetData", targetData);
|
|
4641
|
-
console.log("!!!! counts", counts);
|
|
4642
|
-
return counts;
|
|
4643
|
-
}
|
|
4644
|
-
function getAggColumn(columnMap, aggregations) {
|
|
4645
|
-
console.log("!!!! aggregation length", aggregations.length);
|
|
4646
|
-
const columnName = aggregations[aggregations.length - 1].column;
|
|
4647
|
-
const columnNumber = columnMap[columnName];
|
|
4648
|
-
return columnNumber;
|
|
4649
|
-
}
|
|
4650
|
-
function aggregateSum(groupMap, leafData, columnMap, aggregations, targetData, groupIndices) {
|
|
4651
|
-
const sums = {};
|
|
4652
|
-
const aggColumn = getAggColumn(columnMap, aggregations);
|
|
4653
|
-
function sumRecursive(map, leafData2, aggColumn2) {
|
|
4654
|
-
if (Array.isArray(map)) {
|
|
4655
|
-
let sum = 0;
|
|
4656
|
-
for (const key of map) {
|
|
4657
|
-
sum += Number(leafData2[key][aggColumn2]);
|
|
4658
|
-
}
|
|
4659
|
-
return sum;
|
|
4660
|
-
} else {
|
|
4661
|
-
let sum = 0;
|
|
4662
|
-
for (const key in map) {
|
|
4663
|
-
sum += sumRecursive(map[key], leafData2, aggColumn2);
|
|
4664
|
-
}
|
|
4665
|
-
return sum;
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4668
|
-
for (const key in groupMap) {
|
|
4669
|
-
console.log(key);
|
|
4670
|
-
const sum = Number(sumRecursive(groupMap[key], leafData, aggColumn));
|
|
4671
|
-
sums[key] = sum;
|
|
4672
|
-
}
|
|
4673
|
-
for (let index = 0; index < targetData.length; index++) {
|
|
4674
|
-
for (const key in sums) {
|
|
4675
|
-
if (targetData[index][groupIndices[0]] === key) {
|
|
4676
|
-
targetData[index][aggColumn] = sums[key];
|
|
4677
|
-
}
|
|
4678
|
-
}
|
|
4679
|
-
}
|
|
4680
|
-
console.log("!!!! targetData", targetData);
|
|
4681
|
-
console.log("!!!! sums", sums);
|
|
4682
|
-
return sums;
|
|
4683
|
-
}
|
|
4684
|
-
function aggregateAverage(groupMap, leafData, columnMap, aggregations, targetData, groupIndices) {
|
|
4685
|
-
const averages = {};
|
|
4686
|
-
const aggColumn = getAggColumn(columnMap, aggregations);
|
|
4687
|
-
const count = aggregateCount(
|
|
4688
|
-
groupMap,
|
|
4689
|
-
columnMap,
|
|
4690
|
-
aggregations,
|
|
4691
|
-
targetData,
|
|
4692
|
-
groupIndices
|
|
4693
|
-
);
|
|
4694
|
-
const sum = aggregateSum(
|
|
4695
|
-
groupMap,
|
|
4696
|
-
leafData,
|
|
4697
|
-
columnMap,
|
|
4698
|
-
aggregations,
|
|
4699
|
-
targetData,
|
|
4700
|
-
groupIndices
|
|
4701
|
-
);
|
|
4702
|
-
for (const key in count) {
|
|
4703
|
-
let average = 0;
|
|
4704
|
-
average = sum[key] / count[key];
|
|
4705
|
-
averages[key] = average;
|
|
4706
|
-
}
|
|
4707
|
-
for (let index = 0; index < targetData.length; index++) {
|
|
4708
|
-
for (const key in averages) {
|
|
4709
|
-
if (targetData[index][groupIndices[0]] === key) {
|
|
4710
|
-
targetData[index][aggColumn] = averages[key];
|
|
4711
|
-
}
|
|
4712
|
-
}
|
|
4713
|
-
}
|
|
4714
|
-
console.log("!!!! targetData", targetData);
|
|
4715
|
-
console.log("!!!! averages", averages);
|
|
4716
|
-
return averages;
|
|
4717
|
-
}
|
|
4718
|
-
function getLeafColumnData(map, leafData, aggColumn) {
|
|
4719
|
-
const data = [];
|
|
4720
|
-
if (Array.isArray(map)) {
|
|
4721
|
-
for (const key of map) {
|
|
4722
|
-
data.push(leafData[key][aggColumn]);
|
|
4723
|
-
}
|
|
4724
|
-
} else {
|
|
4725
|
-
for (const key in map) {
|
|
4726
|
-
data.push(...getLeafColumnData(map[key], leafData, aggColumn));
|
|
4727
|
-
}
|
|
4728
|
-
}
|
|
4729
|
-
return data;
|
|
4730
|
-
}
|
|
4731
|
-
function aggregateDistinct(groupMap, leafData, columnMap, aggregations, targetData, groupIndices) {
|
|
4732
|
-
const distincts = {};
|
|
4733
|
-
const aggColumn = getAggColumn(columnMap, aggregations);
|
|
4734
|
-
for (const key in groupMap) {
|
|
4735
|
-
const leafColumnData = getLeafColumnData(
|
|
4736
|
-
groupMap[key],
|
|
4737
|
-
leafData,
|
|
4738
|
-
aggColumn
|
|
4739
|
-
);
|
|
4740
|
-
const distinct = [...new Set(leafColumnData)];
|
|
4741
|
-
distincts[key] = distinct;
|
|
4742
|
-
}
|
|
4743
|
-
for (let index = 0; index < targetData.length; index++) {
|
|
4744
|
-
for (const key in distincts) {
|
|
4745
|
-
if (targetData[index][groupIndices[0]] === key) {
|
|
4746
|
-
targetData[index][aggColumn] = distincts[key];
|
|
4747
|
-
}
|
|
4748
|
-
}
|
|
4749
|
-
}
|
|
4750
|
-
return distincts;
|
|
4751
|
-
}
|
|
4752
|
-
function aggregateHigh(groupMap, leafData, columnMap, aggregations, targetData, groupIndices) {
|
|
4753
|
-
const highs = {};
|
|
4754
|
-
const aggColumn = getAggColumn(columnMap, aggregations);
|
|
4755
|
-
for (const key in groupMap) {
|
|
4756
|
-
const leafColumnData = getLeafColumnData(
|
|
4757
|
-
groupMap[key],
|
|
4758
|
-
leafData,
|
|
4759
|
-
aggColumn
|
|
4760
|
-
);
|
|
4761
|
-
const maxNumber = Math.max(...leafColumnData);
|
|
4762
|
-
highs[key] = maxNumber;
|
|
4763
|
-
}
|
|
4764
|
-
for (let index = 0; index < targetData.length; index++) {
|
|
4765
|
-
for (const key in highs) {
|
|
4766
|
-
if (targetData[index][groupIndices[0]] === key) {
|
|
4767
|
-
targetData[index][aggColumn] = highs[key];
|
|
4768
|
-
}
|
|
4769
|
-
}
|
|
4770
|
-
}
|
|
4771
|
-
return highs;
|
|
4772
|
-
}
|
|
4773
|
-
function aggregateLow(groupMap, leafData, columnMap, aggregations, targetData, groupIndices) {
|
|
4774
|
-
const mins = {};
|
|
4775
|
-
const aggColumn = getAggColumn(columnMap, aggregations);
|
|
4776
|
-
for (const key in groupMap) {
|
|
4777
|
-
const leafColumnData = getLeafColumnData(
|
|
4778
|
-
groupMap[key],
|
|
4779
|
-
leafData,
|
|
4780
|
-
aggColumn
|
|
4781
|
-
);
|
|
4782
|
-
const minNumber = Math.min(...leafColumnData);
|
|
4783
|
-
mins[key] = minNumber;
|
|
4784
|
-
}
|
|
4785
|
-
for (let index = 0; index < targetData.length; index++) {
|
|
4786
|
-
for (const key in mins) {
|
|
4787
|
-
if (targetData[index][groupIndices[0]] === key) {
|
|
4788
|
-
targetData[index][aggColumn] = mins[key];
|
|
4789
|
-
}
|
|
4790
|
-
}
|
|
4791
|
-
}
|
|
4792
|
-
return mins;
|
|
4793
|
-
}
|
|
905
|
+
// src/TickingArrayDataSource.ts
|
|
906
|
+
var import_vuu_data_local = require("@vuu-ui/vuu-data-local");
|
|
4794
907
|
|
|
4795
|
-
// ../vuu-
|
|
4796
|
-
var
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
if (dataMap) {
|
|
4812
|
-
const { count: mapOffset } = metadataKeys;
|
|
4813
|
-
for (const [columnName, index] of Object.entries(columnMap)) {
|
|
4814
|
-
const dataIdx = dataMap[columnName];
|
|
4815
|
-
if (dataIdx === void 0) {
|
|
4816
|
-
throw Error(
|
|
4817
|
-
`ArrayDataSource column ${columnName} is not in underlying data set`
|
|
4818
|
-
);
|
|
4819
|
-
} else if (dataIdx !== index - mapOffset) {
|
|
4820
|
-
return true;
|
|
4821
|
-
}
|
|
4822
|
-
}
|
|
4823
|
-
}
|
|
4824
|
-
return false;
|
|
4825
|
-
};
|
|
4826
|
-
var getDataIndices = (columnMap, dataMap) => {
|
|
4827
|
-
const { count: mapOffset } = metadataKeys;
|
|
4828
|
-
const result = [];
|
|
4829
|
-
Object.entries(columnMap).forEach(([columnName]) => {
|
|
4830
|
-
result.push(dataMap[columnName] + mapOffset);
|
|
4831
|
-
});
|
|
4832
|
-
return result;
|
|
4833
|
-
};
|
|
4834
|
-
var buildDataToClientMap = (columnMap, dataMap) => {
|
|
4835
|
-
if (dataMap && divergentMaps(columnMap, dataMap)) {
|
|
4836
|
-
return getDataIndices(columnMap, dataMap);
|
|
4837
|
-
}
|
|
4838
|
-
return void 0;
|
|
908
|
+
// ../vuu-utils/src/column-utils.ts
|
|
909
|
+
var metadataKeys = {
|
|
910
|
+
IDX: 0,
|
|
911
|
+
RENDER_IDX: 1,
|
|
912
|
+
IS_LEAF: 2,
|
|
913
|
+
IS_EXPANDED: 3,
|
|
914
|
+
DEPTH: 4,
|
|
915
|
+
COUNT: 5,
|
|
916
|
+
KEY: 6,
|
|
917
|
+
SELECTED: 7,
|
|
918
|
+
count: 8,
|
|
919
|
+
// TODO following only used in datamodel
|
|
920
|
+
PARENT_IDX: "parent_idx",
|
|
921
|
+
IDX_POINTER: "idx_pointer",
|
|
922
|
+
FILTER_COUNT: "filter_count",
|
|
923
|
+
NEXT_FILTER_IDX: "next_filter_idx"
|
|
4839
924
|
};
|
|
925
|
+
var { DEPTH, IS_LEAF } = metadataKeys;
|
|
4840
926
|
|
|
4841
|
-
// ../vuu-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
const rows = [];
|
|
4845
|
-
for (let i = 0, idx = 0, collapsed = false, len = groupedRows.length; i < len; i++) {
|
|
4846
|
-
const row = groupedRows[i];
|
|
4847
|
-
const { [DEPTH2]: depth, [KEY]: rowKey } = row;
|
|
4848
|
-
if (rowKey === key) {
|
|
4849
|
-
const collapsedRow = row.slice();
|
|
4850
|
-
collapsedRow[IS_EXPANDED] = false;
|
|
4851
|
-
rows.push(collapsedRow);
|
|
4852
|
-
idx += 1;
|
|
4853
|
-
collapsed = true;
|
|
4854
|
-
while (i < len - 1 && groupedRows[i + 1][DEPTH2] > depth) {
|
|
4855
|
-
i += 1;
|
|
4856
|
-
}
|
|
4857
|
-
} else if (collapsed) {
|
|
4858
|
-
const newRow = row.slice();
|
|
4859
|
-
newRow[0] = idx;
|
|
4860
|
-
newRow[1] = idx;
|
|
4861
|
-
rows.push(newRow);
|
|
4862
|
-
idx += 1;
|
|
4863
|
-
} else {
|
|
4864
|
-
rows.push(row);
|
|
4865
|
-
idx += 1;
|
|
4866
|
-
}
|
|
4867
|
-
}
|
|
4868
|
-
return rows;
|
|
4869
|
-
};
|
|
4870
|
-
var expandGroup = (keys, sourceRows, groupBy, columnMap, groupMap, processedData) => {
|
|
4871
|
-
const groupIndices = groupBy.map((column) => columnMap[column]);
|
|
4872
|
-
return dataRowsFromGroups2(
|
|
4873
|
-
groupMap,
|
|
4874
|
-
groupIndices,
|
|
4875
|
-
keys,
|
|
4876
|
-
sourceRows,
|
|
4877
|
-
void 0,
|
|
4878
|
-
void 0,
|
|
4879
|
-
void 0,
|
|
4880
|
-
processedData
|
|
4881
|
-
);
|
|
4882
|
-
};
|
|
4883
|
-
var dataRowsFromGroups2 = (groupMap, groupIndices, openKeys, sourceRows = [], root = "$root", depth = 1, rows = [], processedData) => {
|
|
4884
|
-
console.log(`dataRowsFromGroups2 1)`);
|
|
4885
|
-
const keys = Object.keys(groupMap).sort();
|
|
4886
|
-
for (const key of keys) {
|
|
4887
|
-
const idx = rows.length;
|
|
4888
|
-
const groupKey = `${root}|${key}`;
|
|
4889
|
-
const row = [idx, idx, false, false, depth, 0, groupKey, 0];
|
|
4890
|
-
row[groupIndices[depth - 1]] = key;
|
|
4891
|
-
rows.push(row);
|
|
4892
|
-
if (openKeys.includes(groupKey)) {
|
|
4893
|
-
row[IS_EXPANDED] = true;
|
|
4894
|
-
if (Array.isArray(groupMap[key])) {
|
|
4895
|
-
pushChildren(
|
|
4896
|
-
rows,
|
|
4897
|
-
groupMap[key],
|
|
4898
|
-
sourceRows,
|
|
4899
|
-
groupKey,
|
|
4900
|
-
depth + 1
|
|
4901
|
-
);
|
|
4902
|
-
} else {
|
|
4903
|
-
dataRowsFromGroups2(
|
|
4904
|
-
groupMap[key],
|
|
4905
|
-
groupIndices,
|
|
4906
|
-
openKeys,
|
|
4907
|
-
sourceRows,
|
|
4908
|
-
groupKey,
|
|
4909
|
-
depth + 1,
|
|
4910
|
-
rows,
|
|
4911
|
-
processedData
|
|
4912
|
-
);
|
|
4913
|
-
}
|
|
4914
|
-
}
|
|
4915
|
-
}
|
|
4916
|
-
console.log(`dataRowsFromGroups2 2)`);
|
|
4917
|
-
for (const key in rows) {
|
|
4918
|
-
for (const index in rows) {
|
|
4919
|
-
if (rows[key][2] === false && processedData[index] != void 0) {
|
|
4920
|
-
if (rows[key][groupIndices[0]] === processedData[index][groupIndices[0]]) {
|
|
4921
|
-
rows[key] = rows[key].splice(0, 8).concat(
|
|
4922
|
-
processedData[index].slice(
|
|
4923
|
-
8,
|
|
4924
|
-
// groupIndices[0] + 1,
|
|
4925
|
-
processedData[index].length
|
|
4926
|
-
)
|
|
4927
|
-
);
|
|
4928
|
-
break;
|
|
4929
|
-
}
|
|
4930
|
-
}
|
|
4931
|
-
}
|
|
4932
|
-
}
|
|
4933
|
-
console.log(`dataRowsFromGroups2 3)`);
|
|
4934
|
-
return rows;
|
|
4935
|
-
};
|
|
4936
|
-
var pushChildren = (rows, tree, sourceRows, parentKey, depth) => {
|
|
4937
|
-
for (const rowIdx of tree) {
|
|
4938
|
-
const idx = rows.length;
|
|
4939
|
-
const sourceRow = sourceRows[rowIdx].slice();
|
|
4940
|
-
sourceRow[0] = idx;
|
|
4941
|
-
sourceRow[1] = idx;
|
|
4942
|
-
sourceRow[DEPTH2] = depth;
|
|
4943
|
-
sourceRow[KEY] = `${parentKey}|${sourceRow[KEY]}`;
|
|
4944
|
-
rows.push(sourceRow);
|
|
4945
|
-
}
|
|
4946
|
-
};
|
|
4947
|
-
var groupRows = (rows, groupBy, columnMap) => {
|
|
4948
|
-
const groupIndices = groupBy.map((column) => columnMap[column]);
|
|
4949
|
-
const groupTree = groupLeafRows(rows, groupIndices);
|
|
4950
|
-
const groupedDataRows = dataRowsFromGroups(groupTree, groupIndices);
|
|
4951
|
-
return [groupedDataRows, groupTree];
|
|
4952
|
-
};
|
|
4953
|
-
var dataRowsFromGroups = (groupTree, groupIndices) => {
|
|
4954
|
-
const depth = 0;
|
|
4955
|
-
const rows = [];
|
|
4956
|
-
let idx = 0;
|
|
4957
|
-
const keys = Object.keys(groupTree).sort();
|
|
4958
|
-
for (const key of keys) {
|
|
4959
|
-
const row = [
|
|
4960
|
-
idx,
|
|
4961
|
-
idx,
|
|
4962
|
-
false,
|
|
4963
|
-
false,
|
|
4964
|
-
1,
|
|
4965
|
-
0,
|
|
4966
|
-
`$root|${key}`,
|
|
4967
|
-
0
|
|
4968
|
-
];
|
|
4969
|
-
row[groupIndices[depth]] = key;
|
|
4970
|
-
rows.push(row);
|
|
4971
|
-
idx += 1;
|
|
4972
|
-
}
|
|
4973
|
-
return rows;
|
|
4974
|
-
};
|
|
4975
|
-
function groupLeafRows(leafRows, groupby) {
|
|
4976
|
-
const groups = {};
|
|
4977
|
-
const levels = groupby.length;
|
|
4978
|
-
const lastLevel = levels - 1;
|
|
4979
|
-
for (let i = 0, len = leafRows.length; i < len; i++) {
|
|
4980
|
-
const leafRow = leafRows[i];
|
|
4981
|
-
let target = groups;
|
|
4982
|
-
let targetNode;
|
|
4983
|
-
let key;
|
|
4984
|
-
for (let level = 0; level < levels; level++) {
|
|
4985
|
-
const colIdx = groupby[level];
|
|
4986
|
-
key = leafRow[colIdx].toString();
|
|
4987
|
-
targetNode = target[key];
|
|
4988
|
-
if (targetNode && level === lastLevel) {
|
|
4989
|
-
targetNode.push(i);
|
|
4990
|
-
} else if (targetNode) {
|
|
4991
|
-
target = targetNode;
|
|
4992
|
-
} else if (!targetNode && level < lastLevel) {
|
|
4993
|
-
target = target[key] = {};
|
|
4994
|
-
} else if (!targetNode) {
|
|
4995
|
-
target[key] = [i];
|
|
4996
|
-
}
|
|
4997
|
-
}
|
|
4998
|
-
}
|
|
4999
|
-
console.log("!! groups", groups);
|
|
5000
|
-
return groups;
|
|
927
|
+
// ../vuu-utils/src/event-emitter.ts
|
|
928
|
+
function isArrayOfListeners(listeners) {
|
|
929
|
+
return Array.isArray(listeners);
|
|
5001
930
|
}
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
} else if (val2 === null || val1 > val2) {
|
|
5010
|
-
return 1;
|
|
5011
|
-
} else {
|
|
5012
|
-
return -1;
|
|
5013
|
-
}
|
|
5014
|
-
};
|
|
5015
|
-
var sortComparator = (sortDefs) => {
|
|
5016
|
-
if (sortDefs.length === 1) {
|
|
5017
|
-
return singleColComparator(sortDefs);
|
|
5018
|
-
} else if (sortDefs.length === 2) {
|
|
5019
|
-
return twoColComparator(sortDefs);
|
|
5020
|
-
} else {
|
|
5021
|
-
return multiColComparator(sortDefs);
|
|
931
|
+
function isOnlyListener(listeners) {
|
|
932
|
+
return !Array.isArray(listeners);
|
|
933
|
+
}
|
|
934
|
+
var _events;
|
|
935
|
+
var EventEmitter = class {
|
|
936
|
+
constructor() {
|
|
937
|
+
__privateAdd(this, _events, /* @__PURE__ */ new Map());
|
|
5022
938
|
}
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
const v2 = direction1 === "D" ? r1[idx1] : r2[idx1];
|
|
5032
|
-
const v3 = direction2 === "D" ? r2[idx2] : r1[idx2];
|
|
5033
|
-
const v4 = direction2 === "D" ? r1[idx2] : r2[idx2];
|
|
5034
|
-
return v1 > v2 ? 1 : v2 > v1 ? -1 : v3 > v4 ? 1 : v4 > v3 ? -1 : 0;
|
|
5035
|
-
};
|
|
5036
|
-
var multiColComparator = (sortDefs, test = defaultSortPredicate) => (r1, r2) => {
|
|
5037
|
-
for (const sortDef of sortDefs) {
|
|
5038
|
-
const result = test(r1, r2, sortDef);
|
|
5039
|
-
if (result !== 0) {
|
|
5040
|
-
return result;
|
|
939
|
+
addListener(event, listener) {
|
|
940
|
+
const listeners = __privateGet(this, _events).get(event);
|
|
941
|
+
if (!listeners) {
|
|
942
|
+
__privateGet(this, _events).set(event, listener);
|
|
943
|
+
} else if (isArrayOfListeners(listeners)) {
|
|
944
|
+
listeners.push(listener);
|
|
945
|
+
} else if (isOnlyListener(listeners)) {
|
|
946
|
+
__privateGet(this, _events).set(event, [listeners, listener]);
|
|
5041
947
|
}
|
|
5042
948
|
}
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
var { debug } = logger("ArrayDataSource");
|
|
5057
|
-
var toDataSourceRow = (key) => (data, index) => {
|
|
5058
|
-
return [index, index, true, false, 1, 0, String(data[key]), 0, ...data];
|
|
5059
|
-
};
|
|
5060
|
-
var buildTableSchema = (columns, keyColumn) => {
|
|
5061
|
-
const schema = {
|
|
5062
|
-
columns: columns.map(({ name, serverDataType = "string" }) => ({
|
|
5063
|
-
name,
|
|
5064
|
-
serverDataType
|
|
5065
|
-
})),
|
|
5066
|
-
key: keyColumn != null ? keyColumn : columns[0].name,
|
|
5067
|
-
table: { module: "", table: "Array" }
|
|
5068
|
-
};
|
|
5069
|
-
return schema;
|
|
5070
|
-
};
|
|
5071
|
-
var _columnMap, _config, _data, _links, _range, _selectedRowsCount, _size, _status, _title;
|
|
5072
|
-
var ArrayDataSource = class extends EventEmitter {
|
|
5073
|
-
constructor({
|
|
5074
|
-
aggregations,
|
|
5075
|
-
// different from RemoteDataSource
|
|
5076
|
-
columnDescriptors,
|
|
5077
|
-
data,
|
|
5078
|
-
dataMap,
|
|
5079
|
-
filter,
|
|
5080
|
-
groupBy,
|
|
5081
|
-
keyColumn,
|
|
5082
|
-
rangeChangeRowset = "delta",
|
|
5083
|
-
sort,
|
|
5084
|
-
title,
|
|
5085
|
-
viewport
|
|
5086
|
-
}) {
|
|
5087
|
-
super();
|
|
5088
|
-
this.lastRangeServed = { from: 0, to: 0 };
|
|
5089
|
-
this.openTreeNodes = [];
|
|
5090
|
-
/** Map reflecting positions of columns in client data sent to user */
|
|
5091
|
-
__privateAdd(this, _columnMap, void 0);
|
|
5092
|
-
__privateAdd(this, _config, vanillaConfig);
|
|
5093
|
-
__privateAdd(this, _data, void 0);
|
|
5094
|
-
__privateAdd(this, _links, void 0);
|
|
5095
|
-
__privateAdd(this, _range, NULL_RANGE);
|
|
5096
|
-
__privateAdd(this, _selectedRowsCount, 0);
|
|
5097
|
-
__privateAdd(this, _size, 0);
|
|
5098
|
-
__privateAdd(this, _status, "initialising");
|
|
5099
|
-
__privateAdd(this, _title, void 0);
|
|
5100
|
-
this.selectedRows = [];
|
|
5101
|
-
this.keys = new KeySet(__privateGet(this, _range));
|
|
5102
|
-
this.processedData = void 0;
|
|
5103
|
-
this.insert = (row) => {
|
|
5104
|
-
const dataSourceRow = toDataSourceRow(this.key)(row, this.size);
|
|
5105
|
-
__privateGet(this, _data).push(dataSourceRow);
|
|
5106
|
-
const { from, to } = __privateGet(this, _range);
|
|
5107
|
-
const [rowIdx] = dataSourceRow;
|
|
5108
|
-
if (rowIdx >= from && rowIdx < to) {
|
|
5109
|
-
this.sendRowsToClient();
|
|
5110
|
-
}
|
|
5111
|
-
};
|
|
5112
|
-
this.update = (row, columnName) => {
|
|
5113
|
-
var _a;
|
|
5114
|
-
const keyValue = row[this.key];
|
|
5115
|
-
const colIndex = __privateGet(this, _columnMap)[columnName];
|
|
5116
|
-
const dataColIndex = (_a = this.dataMap) == null ? void 0 : _a[columnName];
|
|
5117
|
-
const dataIndex = __privateGet(this, _data).findIndex((row2) => row2[KEY2] === keyValue);
|
|
5118
|
-
if (dataIndex !== -1 && dataColIndex !== void 0) {
|
|
5119
|
-
const dataSourceRow = __privateGet(this, _data)[dataIndex];
|
|
5120
|
-
dataSourceRow[colIndex] = row[dataColIndex];
|
|
5121
|
-
const { from, to } = __privateGet(this, _range);
|
|
5122
|
-
const [rowIdx] = dataSourceRow;
|
|
5123
|
-
if (rowIdx >= from && rowIdx < to) {
|
|
5124
|
-
this.sendRowsToClient(false, dataSourceRow);
|
|
5125
|
-
}
|
|
5126
|
-
}
|
|
5127
|
-
};
|
|
5128
|
-
this.updateRow = (row) => {
|
|
5129
|
-
const keyValue = row[this.key];
|
|
5130
|
-
const dataIndex = __privateGet(this, _data).findIndex((row2) => row2[KEY2] === keyValue);
|
|
5131
|
-
if (dataIndex !== -1) {
|
|
5132
|
-
const dataSourceRow = toDataSourceRow(this.key)(row, dataIndex);
|
|
5133
|
-
__privateGet(this, _data)[dataIndex] = dataSourceRow;
|
|
5134
|
-
const { from, to } = __privateGet(this, _range);
|
|
5135
|
-
if (dataIndex >= from && dataIndex < to) {
|
|
5136
|
-
this.sendRowsToClient(false, dataSourceRow);
|
|
949
|
+
removeListener(event, listener) {
|
|
950
|
+
if (!__privateGet(this, _events).has(event)) {
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
const listenerOrListeners = __privateGet(this, _events).get(event);
|
|
954
|
+
let position = -1;
|
|
955
|
+
if (listenerOrListeners === listener) {
|
|
956
|
+
__privateGet(this, _events).delete(event);
|
|
957
|
+
} else if (Array.isArray(listenerOrListeners)) {
|
|
958
|
+
for (let i = length; i-- > 0; ) {
|
|
959
|
+
if (listenerOrListeners[i] === listener) {
|
|
960
|
+
position = i;
|
|
961
|
+
break;
|
|
5137
962
|
}
|
|
5138
963
|
}
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
throw Error(
|
|
5142
|
-
"ArrayDataSource constructor called without data or without columnDescriptors"
|
|
5143
|
-
);
|
|
5144
|
-
}
|
|
5145
|
-
this.columnDescriptors = columnDescriptors;
|
|
5146
|
-
this.dataMap = dataMap;
|
|
5147
|
-
this.key = keyColumn ? this.columnDescriptors.findIndex((col) => col.name === keyColumn) : 0;
|
|
5148
|
-
this.rangeChangeRowset = rangeChangeRowset;
|
|
5149
|
-
this.tableSchema = buildTableSchema(columnDescriptors, keyColumn);
|
|
5150
|
-
this.viewport = viewport || uuid();
|
|
5151
|
-
__privateSet(this, _size, data.length);
|
|
5152
|
-
__privateSet(this, _title, title);
|
|
5153
|
-
const columns = columnDescriptors.map((col) => col.name);
|
|
5154
|
-
__privateSet(this, _columnMap, buildColumnMap(columns));
|
|
5155
|
-
this.dataIndices = buildDataToClientMap(__privateGet(this, _columnMap), this.dataMap);
|
|
5156
|
-
__privateSet(this, _data, data.map(toDataSourceRow(this.key)));
|
|
5157
|
-
this.config = {
|
|
5158
|
-
...__privateGet(this, _config),
|
|
5159
|
-
aggregations: aggregations || __privateGet(this, _config).aggregations,
|
|
5160
|
-
columns,
|
|
5161
|
-
filter: filter || __privateGet(this, _config).filter,
|
|
5162
|
-
groupBy: groupBy || __privateGet(this, _config).groupBy,
|
|
5163
|
-
sort: sort || __privateGet(this, _config).sort
|
|
5164
|
-
};
|
|
5165
|
-
debug == null ? void 0 : debug(`columnMap: ${JSON.stringify(__privateGet(this, _columnMap))}`);
|
|
5166
|
-
}
|
|
5167
|
-
async subscribe({
|
|
5168
|
-
viewport = ((_a) => (_a = this.viewport) != null ? _a : uuid())(),
|
|
5169
|
-
columns,
|
|
5170
|
-
aggregations,
|
|
5171
|
-
range,
|
|
5172
|
-
sort,
|
|
5173
|
-
groupBy,
|
|
5174
|
-
filter
|
|
5175
|
-
}, callback) {
|
|
5176
|
-
var _a2;
|
|
5177
|
-
this.clientCallback = callback;
|
|
5178
|
-
this.viewport = viewport;
|
|
5179
|
-
__privateSet(this, _status, "subscribed");
|
|
5180
|
-
this.lastRangeServed = { from: 0, to: 0 };
|
|
5181
|
-
let config = __privateGet(this, _config);
|
|
5182
|
-
const hasConfigProps = aggregations || columns || filter || groupBy || sort;
|
|
5183
|
-
if (hasConfigProps) {
|
|
5184
|
-
if (range) {
|
|
5185
|
-
__privateSet(this, _range, range);
|
|
964
|
+
if (position < 0) {
|
|
965
|
+
return;
|
|
5186
966
|
}
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
groupBy: groupBy || __privateGet(this, _config).groupBy,
|
|
5193
|
-
sort: sort || __privateGet(this, _config).sort
|
|
5194
|
-
};
|
|
5195
|
-
}
|
|
5196
|
-
(_a2 = this.clientCallback) == null ? void 0 : _a2.call(this, {
|
|
5197
|
-
...config,
|
|
5198
|
-
type: "subscribed",
|
|
5199
|
-
clientViewportId: this.viewport,
|
|
5200
|
-
range: __privateGet(this, _range),
|
|
5201
|
-
tableSchema: this.tableSchema
|
|
5202
|
-
});
|
|
5203
|
-
if (hasConfigProps) {
|
|
5204
|
-
this.config = config;
|
|
5205
|
-
} else {
|
|
5206
|
-
this.clientCallback({
|
|
5207
|
-
clientViewportId: this.viewport,
|
|
5208
|
-
mode: "size-only",
|
|
5209
|
-
type: "viewport-update",
|
|
5210
|
-
size: __privateGet(this, _data).length
|
|
5211
|
-
});
|
|
5212
|
-
if (range) {
|
|
5213
|
-
this.range = range;
|
|
5214
|
-
} else if (__privateGet(this, _range) !== NULL_RANGE) {
|
|
5215
|
-
this.sendRowsToClient();
|
|
967
|
+
if (listenerOrListeners.length === 1) {
|
|
968
|
+
listenerOrListeners.length = 0;
|
|
969
|
+
__privateGet(this, _events).delete(event);
|
|
970
|
+
} else {
|
|
971
|
+
listenerOrListeners.splice(position, 1);
|
|
5216
972
|
}
|
|
5217
973
|
}
|
|
5218
974
|
}
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
}
|
|
5225
|
-
resume() {
|
|
5226
|
-
return this;
|
|
5227
|
-
}
|
|
5228
|
-
disable() {
|
|
5229
|
-
return this;
|
|
5230
|
-
}
|
|
5231
|
-
enable() {
|
|
5232
|
-
return this;
|
|
5233
|
-
}
|
|
5234
|
-
select(selected) {
|
|
5235
|
-
__privateSet(this, _selectedRowsCount, selected.length);
|
|
5236
|
-
debug == null ? void 0 : debug(`select ${JSON.stringify(selected)}`);
|
|
5237
|
-
this.selectedRows = selected;
|
|
5238
|
-
this.setRange(resetRange(__privateGet(this, _range)), true);
|
|
5239
|
-
}
|
|
5240
|
-
openTreeNode(key) {
|
|
5241
|
-
this.openTreeNodes.push(key);
|
|
5242
|
-
this.processedData = expandGroup(
|
|
5243
|
-
this.openTreeNodes,
|
|
5244
|
-
__privateGet(this, _data),
|
|
5245
|
-
__privateGet(this, _config).groupBy,
|
|
5246
|
-
__privateGet(this, _columnMap),
|
|
5247
|
-
this.groupMap,
|
|
5248
|
-
this.processedData
|
|
5249
|
-
);
|
|
5250
|
-
this.setRange(resetRange(__privateGet(this, _range)), true);
|
|
5251
|
-
}
|
|
5252
|
-
closeTreeNode(key) {
|
|
5253
|
-
this.openTreeNodes = this.openTreeNodes.filter((value) => value !== key);
|
|
5254
|
-
if (this.processedData) {
|
|
5255
|
-
this.processedData = collapseGroup(key, this.processedData);
|
|
5256
|
-
this.setRange(resetRange(__privateGet(this, _range)), true);
|
|
5257
|
-
}
|
|
5258
|
-
}
|
|
5259
|
-
get links() {
|
|
5260
|
-
return __privateGet(this, _links);
|
|
5261
|
-
}
|
|
5262
|
-
get menu() {
|
|
5263
|
-
return this._menu;
|
|
5264
|
-
}
|
|
5265
|
-
get status() {
|
|
5266
|
-
return __privateGet(this, _status);
|
|
5267
|
-
}
|
|
5268
|
-
get data() {
|
|
5269
|
-
return __privateGet(this, _data);
|
|
5270
|
-
}
|
|
5271
|
-
// Only used by the UpdateGenerator
|
|
5272
|
-
get currentData() {
|
|
5273
|
-
var _a;
|
|
5274
|
-
return (_a = this.processedData) != null ? _a : __privateGet(this, _data);
|
|
5275
|
-
}
|
|
5276
|
-
get table() {
|
|
5277
|
-
return this.tableSchema.table;
|
|
5278
|
-
}
|
|
5279
|
-
get config() {
|
|
5280
|
-
return __privateGet(this, _config);
|
|
5281
|
-
}
|
|
5282
|
-
set config(config) {
|
|
5283
|
-
var _a;
|
|
5284
|
-
if (this.applyConfig(config)) {
|
|
5285
|
-
if (config) {
|
|
5286
|
-
const originalConfig = __privateGet(this, _config);
|
|
5287
|
-
const newConfig = ((_a = config == null ? void 0 : config.filter) == null ? void 0 : _a.filter) && (config == null ? void 0 : config.filter.filterStruct) === void 0 ? {
|
|
5288
|
-
...config,
|
|
5289
|
-
filter: {
|
|
5290
|
-
filter: config.filter.filter,
|
|
5291
|
-
filterStruct: parseFilter(config.filter.filter)
|
|
5292
|
-
}
|
|
5293
|
-
} : config;
|
|
5294
|
-
__privateSet(this, _config, withConfigDefaults(newConfig));
|
|
5295
|
-
let processedData;
|
|
5296
|
-
if (hasFilter(config)) {
|
|
5297
|
-
const { filter, filterStruct = parseFilter(filter) } = config.filter;
|
|
5298
|
-
if (filterStruct) {
|
|
5299
|
-
const fn = filterPredicate(__privateGet(this, _columnMap), filterStruct);
|
|
5300
|
-
processedData = __privateGet(this, _data).filter(fn);
|
|
5301
|
-
} else {
|
|
5302
|
-
throw Error("filter must include filterStruct");
|
|
5303
|
-
}
|
|
5304
|
-
}
|
|
5305
|
-
if (hasSort(config)) {
|
|
5306
|
-
processedData = sortRows(
|
|
5307
|
-
processedData != null ? processedData : __privateGet(this, _data),
|
|
5308
|
-
config.sort,
|
|
5309
|
-
__privateGet(this, _columnMap)
|
|
5310
|
-
);
|
|
5311
|
-
}
|
|
5312
|
-
if (this.openTreeNodes.length > 0 && groupByChanged(originalConfig, config)) {
|
|
5313
|
-
if (__privateGet(this, _config).groupBy.length === 0) {
|
|
5314
|
-
this.openTreeNodes.length = 0;
|
|
5315
|
-
} else {
|
|
5316
|
-
console.log("adjust the openTReeNodes groupBy changed ", {
|
|
5317
|
-
originalGroupBy: originalConfig.groupBy,
|
|
5318
|
-
newGroupBy: newConfig.groupBy
|
|
5319
|
-
});
|
|
5320
|
-
}
|
|
5321
|
-
}
|
|
5322
|
-
if (hasGroupBy(config)) {
|
|
5323
|
-
const [groupedData, groupMap] = groupRows(
|
|
5324
|
-
processedData != null ? processedData : __privateGet(this, _data),
|
|
5325
|
-
config.groupBy,
|
|
5326
|
-
__privateGet(this, _columnMap)
|
|
5327
|
-
);
|
|
5328
|
-
this.groupMap = groupMap;
|
|
5329
|
-
processedData = groupedData;
|
|
5330
|
-
if (this.openTreeNodes.length > 0) {
|
|
5331
|
-
processedData = expandGroup(
|
|
5332
|
-
this.openTreeNodes,
|
|
5333
|
-
__privateGet(this, _data),
|
|
5334
|
-
__privateGet(this, _config).groupBy,
|
|
5335
|
-
__privateGet(this, _columnMap),
|
|
5336
|
-
this.groupMap,
|
|
5337
|
-
processedData
|
|
5338
|
-
);
|
|
5339
|
-
}
|
|
5340
|
-
}
|
|
5341
|
-
this.processedData = processedData == null ? void 0 : processedData.map((row, i) => {
|
|
5342
|
-
const dolly = row.slice();
|
|
5343
|
-
dolly[0] = i;
|
|
5344
|
-
dolly[1] = i;
|
|
5345
|
-
return dolly;
|
|
5346
|
-
});
|
|
5347
|
-
}
|
|
5348
|
-
this.setRange(resetRange(__privateGet(this, _range)), true);
|
|
5349
|
-
this.emit("config", __privateGet(this, _config));
|
|
975
|
+
removeAllListeners(event) {
|
|
976
|
+
if (event && __privateGet(this, _events).has(event)) {
|
|
977
|
+
__privateGet(this, _events).delete(event);
|
|
978
|
+
} else if (event === void 0) {
|
|
979
|
+
__privateGet(this, _events).clear();
|
|
5350
980
|
}
|
|
5351
981
|
}
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
if (
|
|
5356
|
-
|
|
5357
|
-
...config,
|
|
5358
|
-
filter: {
|
|
5359
|
-
filter: config.filter.filter,
|
|
5360
|
-
filterStruct: parseFilter(config.filter.filter)
|
|
5361
|
-
}
|
|
5362
|
-
} : config;
|
|
5363
|
-
__privateSet(this, _config, withConfigDefaults(newConfig));
|
|
5364
|
-
return true;
|
|
982
|
+
emit(event, ...args) {
|
|
983
|
+
if (__privateGet(this, _events)) {
|
|
984
|
+
const handler = __privateGet(this, _events).get(event);
|
|
985
|
+
if (handler) {
|
|
986
|
+
this.invokeHandler(handler, args);
|
|
5365
987
|
}
|
|
5366
988
|
}
|
|
5367
989
|
}
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
var _a, _b;
|
|
5373
|
-
return (_b = (_a = this.processedData) == null ? void 0 : _a.length) != null ? _b : __privateGet(this, _data).length;
|
|
5374
|
-
}
|
|
5375
|
-
get range() {
|
|
5376
|
-
return __privateGet(this, _range);
|
|
5377
|
-
}
|
|
5378
|
-
set range(range) {
|
|
5379
|
-
if (range.from !== __privateGet(this, _range).from || range.to !== __privateGet(this, _range).to) {
|
|
5380
|
-
this.setRange(range);
|
|
5381
|
-
}
|
|
5382
|
-
}
|
|
5383
|
-
delete(row) {
|
|
5384
|
-
console.log(`delete row ${row.join(",")}`);
|
|
5385
|
-
}
|
|
5386
|
-
setRange(range, forceFullRefresh = false) {
|
|
5387
|
-
__privateSet(this, _range, range);
|
|
5388
|
-
this.keys.reset(range);
|
|
5389
|
-
this.sendRowsToClient(forceFullRefresh);
|
|
5390
|
-
}
|
|
5391
|
-
sendRowsToClient(forceFullRefresh = false, row) {
|
|
5392
|
-
var _a, _b, _c;
|
|
5393
|
-
if (row) {
|
|
5394
|
-
(_a = this.clientCallback) == null ? void 0 : _a.call(this, {
|
|
5395
|
-
clientViewportId: this.viewport,
|
|
5396
|
-
mode: "update",
|
|
5397
|
-
rows: [
|
|
5398
|
-
toClientRow(row, this.keys, this.selectedRows, this.dataIndices)
|
|
5399
|
-
],
|
|
5400
|
-
type: "viewport-update"
|
|
5401
|
-
});
|
|
5402
|
-
} else {
|
|
5403
|
-
const rowRange = this.rangeChangeRowset === "delta" && !forceFullRefresh ? rangeNewItems(this.lastRangeServed, __privateGet(this, _range)) : __privateGet(this, _range);
|
|
5404
|
-
const data = (_b = this.processedData) != null ? _b : __privateGet(this, _data);
|
|
5405
|
-
const rowsWithinViewport = data.slice(rowRange.from, rowRange.to).map(
|
|
5406
|
-
(row2) => toClientRow(row2, this.keys, this.selectedRows, this.dataIndices)
|
|
5407
|
-
);
|
|
5408
|
-
(_c = this.clientCallback) == null ? void 0 : _c.call(this, {
|
|
5409
|
-
clientViewportId: this.viewport,
|
|
5410
|
-
mode: "batch",
|
|
5411
|
-
rows: rowsWithinViewport,
|
|
5412
|
-
size: data.length,
|
|
5413
|
-
type: "viewport-update"
|
|
5414
|
-
});
|
|
5415
|
-
this.lastRangeServed = {
|
|
5416
|
-
from: __privateGet(this, _range).from,
|
|
5417
|
-
to: Math.min(
|
|
5418
|
-
__privateGet(this, _range).to,
|
|
5419
|
-
__privateGet(this, _range).from + rowsWithinViewport.length
|
|
5420
|
-
)
|
|
5421
|
-
};
|
|
5422
|
-
}
|
|
5423
|
-
}
|
|
5424
|
-
get columns() {
|
|
5425
|
-
return __privateGet(this, _config).columns;
|
|
5426
|
-
}
|
|
5427
|
-
set columns(columns) {
|
|
5428
|
-
const addedColumns = getAddedItems(this.config.columns, columns);
|
|
5429
|
-
if (addedColumns.length > 0) {
|
|
5430
|
-
const columnsWithoutDescriptors = getMissingItems(
|
|
5431
|
-
this.columnDescriptors,
|
|
5432
|
-
addedColumns,
|
|
5433
|
-
(col) => col.name
|
|
5434
|
-
);
|
|
5435
|
-
console.log(`columnsWithoutDescriptors`, {
|
|
5436
|
-
columnsWithoutDescriptors
|
|
5437
|
-
});
|
|
5438
|
-
}
|
|
5439
|
-
__privateSet(this, _columnMap, buildColumnMap(columns));
|
|
5440
|
-
this.dataIndices = buildDataToClientMap(__privateGet(this, _columnMap), this.dataMap);
|
|
5441
|
-
this.config = {
|
|
5442
|
-
...__privateGet(this, _config),
|
|
5443
|
-
columns
|
|
5444
|
-
};
|
|
5445
|
-
}
|
|
5446
|
-
get aggregations() {
|
|
5447
|
-
return __privateGet(this, _config).aggregations;
|
|
5448
|
-
}
|
|
5449
|
-
set aggregations(aggregations) {
|
|
5450
|
-
var _a;
|
|
5451
|
-
__privateSet(this, _config, {
|
|
5452
|
-
...__privateGet(this, _config),
|
|
5453
|
-
aggregations
|
|
5454
|
-
});
|
|
5455
|
-
const targetData = (_a = this.processedData) != null ? _a : __privateGet(this, _data);
|
|
5456
|
-
const leafData = __privateGet(this, _data);
|
|
5457
|
-
aggregateData(
|
|
5458
|
-
aggregations,
|
|
5459
|
-
targetData,
|
|
5460
|
-
__privateGet(this, _config).groupBy,
|
|
5461
|
-
leafData,
|
|
5462
|
-
__privateGet(this, _columnMap),
|
|
5463
|
-
this.groupMap
|
|
5464
|
-
);
|
|
5465
|
-
this.setRange(resetRange(__privateGet(this, _range)), true);
|
|
5466
|
-
this.emit("config", __privateGet(this, _config));
|
|
5467
|
-
}
|
|
5468
|
-
get sort() {
|
|
5469
|
-
return __privateGet(this, _config).sort;
|
|
5470
|
-
}
|
|
5471
|
-
set sort(sort) {
|
|
5472
|
-
debug == null ? void 0 : debug(`sort ${JSON.stringify(sort)}`);
|
|
5473
|
-
this.config = {
|
|
5474
|
-
...__privateGet(this, _config),
|
|
5475
|
-
sort
|
|
5476
|
-
};
|
|
5477
|
-
}
|
|
5478
|
-
get filter() {
|
|
5479
|
-
return __privateGet(this, _config).filter;
|
|
5480
|
-
}
|
|
5481
|
-
set filter(filter) {
|
|
5482
|
-
debug == null ? void 0 : debug(`filter ${JSON.stringify(filter)}`);
|
|
5483
|
-
this.config = {
|
|
5484
|
-
...__privateGet(this, _config),
|
|
5485
|
-
filter
|
|
5486
|
-
};
|
|
5487
|
-
}
|
|
5488
|
-
get groupBy() {
|
|
5489
|
-
return __privateGet(this, _config).groupBy;
|
|
5490
|
-
}
|
|
5491
|
-
set groupBy(groupBy) {
|
|
5492
|
-
this.config = {
|
|
5493
|
-
...__privateGet(this, _config),
|
|
5494
|
-
groupBy
|
|
990
|
+
once(event, listener) {
|
|
991
|
+
const handler = (...args) => {
|
|
992
|
+
this.removeListener(event, handler);
|
|
993
|
+
listener(...args);
|
|
5495
994
|
};
|
|
995
|
+
this.on(event, handler);
|
|
5496
996
|
}
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
}
|
|
5500
|
-
set title(title) {
|
|
5501
|
-
__privateSet(this, _title, title);
|
|
5502
|
-
}
|
|
5503
|
-
get _clientCallback() {
|
|
5504
|
-
return this.clientCallback;
|
|
5505
|
-
}
|
|
5506
|
-
createLink({
|
|
5507
|
-
parentVpId,
|
|
5508
|
-
link: { fromColumn, toColumn }
|
|
5509
|
-
}) {
|
|
5510
|
-
console.log("create link", {
|
|
5511
|
-
parentVpId,
|
|
5512
|
-
fromColumn,
|
|
5513
|
-
toColumn
|
|
5514
|
-
});
|
|
5515
|
-
}
|
|
5516
|
-
removeLink() {
|
|
5517
|
-
console.log("remove link");
|
|
997
|
+
on(event, listener) {
|
|
998
|
+
this.addListener(event, listener);
|
|
5518
999
|
}
|
|
5519
|
-
|
|
5520
|
-
const
|
|
5521
|
-
if (
|
|
5522
|
-
return
|
|
1000
|
+
hasListener(event, listener) {
|
|
1001
|
+
const listeners = __privateGet(this, _events).get(event);
|
|
1002
|
+
if (Array.isArray(listeners)) {
|
|
1003
|
+
return listeners.includes(listener);
|
|
5523
1004
|
} else {
|
|
5524
|
-
|
|
1005
|
+
return listeners === listener;
|
|
5525
1006
|
}
|
|
5526
1007
|
}
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
case
|
|
5536
|
-
|
|
5537
|
-
|
|
1008
|
+
invokeHandler(handler, args) {
|
|
1009
|
+
if (isArrayOfListeners(handler)) {
|
|
1010
|
+
handler.slice().forEach((listener) => this.invokeHandler(listener, args));
|
|
1011
|
+
} else {
|
|
1012
|
+
switch (args.length) {
|
|
1013
|
+
case 0:
|
|
1014
|
+
handler();
|
|
1015
|
+
break;
|
|
1016
|
+
case 1:
|
|
1017
|
+
handler(args[0]);
|
|
1018
|
+
break;
|
|
1019
|
+
case 2:
|
|
1020
|
+
handler(args[0], args[1]);
|
|
5538
1021
|
break;
|
|
5539
1022
|
default:
|
|
5540
|
-
|
|
1023
|
+
handler.call(null, ...args);
|
|
5541
1024
|
}
|
|
5542
|
-
}
|
|
1025
|
+
}
|
|
5543
1026
|
}
|
|
5544
1027
|
};
|
|
5545
|
-
|
|
5546
|
-
_config = new WeakMap();
|
|
5547
|
-
_data = new WeakMap();
|
|
5548
|
-
_links = new WeakMap();
|
|
5549
|
-
_range = new WeakMap();
|
|
5550
|
-
_selectedRowsCount = new WeakMap();
|
|
5551
|
-
_size = new WeakMap();
|
|
5552
|
-
_status = new WeakMap();
|
|
5553
|
-
_title = new WeakMap();
|
|
5554
|
-
|
|
5555
|
-
// ../vuu-data-local/src/json-data-source/json-data-source.ts
|
|
5556
|
-
var { DEPTH: DEPTH3, IDX, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2, KEY: KEY3, SELECTED: SELECTED3 } = metadataKeys;
|
|
1028
|
+
_events = new WeakMap();
|
|
5557
1029
|
|
|
5558
1030
|
// src/makeSuggestions.ts
|
|
5559
1031
|
var cachedValues = /* @__PURE__ */ new Map();
|
|
@@ -5591,7 +1063,7 @@ var makeSuggestions = (table, column, pattern) => new Promise((resolve) => {
|
|
|
5591
1063
|
|
|
5592
1064
|
// src/TickingArrayDataSource.ts
|
|
5593
1065
|
var _menuRpcServices, _rpcServices, _table;
|
|
5594
|
-
var TickingArrayDataSource = class extends ArrayDataSource {
|
|
1066
|
+
var TickingArrayDataSource = class extends import_vuu_data_local.ArrayDataSource {
|
|
5595
1067
|
constructor({
|
|
5596
1068
|
data,
|
|
5597
1069
|
menuRpcServices,
|
|
@@ -5774,16 +1246,16 @@ var populateArray = (count, colGen, rowGen, columns) => {
|
|
|
5774
1246
|
};
|
|
5775
1247
|
|
|
5776
1248
|
// src/Table.ts
|
|
5777
|
-
var
|
|
1249
|
+
var _data, _dataMap, _indexOfKey, _index, _schema;
|
|
5778
1250
|
var Table = class extends EventEmitter {
|
|
5779
1251
|
constructor(schema, data, dataMap, updateGenerator) {
|
|
5780
1252
|
super();
|
|
5781
|
-
__privateAdd(this,
|
|
1253
|
+
__privateAdd(this, _data, void 0);
|
|
5782
1254
|
__privateAdd(this, _dataMap, void 0);
|
|
5783
1255
|
__privateAdd(this, _indexOfKey, void 0);
|
|
5784
1256
|
__privateAdd(this, _index, /* @__PURE__ */ new Map());
|
|
5785
1257
|
__privateAdd(this, _schema, void 0);
|
|
5786
|
-
__privateSet(this,
|
|
1258
|
+
__privateSet(this, _data, data);
|
|
5787
1259
|
__privateSet(this, _dataMap, dataMap);
|
|
5788
1260
|
__privateSet(this, _schema, schema);
|
|
5789
1261
|
__privateSet(this, _indexOfKey, dataMap[schema.key]);
|
|
@@ -5792,13 +1264,13 @@ var Table = class extends EventEmitter {
|
|
|
5792
1264
|
updateGenerator == null ? void 0 : updateGenerator.setRange({ from: 0, to: 100 });
|
|
5793
1265
|
}
|
|
5794
1266
|
buildIndex() {
|
|
5795
|
-
for (let i = 0; i < __privateGet(this,
|
|
5796
|
-
const key = __privateGet(this,
|
|
1267
|
+
for (let i = 0; i < __privateGet(this, _data).length; i++) {
|
|
1268
|
+
const key = __privateGet(this, _data)[i][__privateGet(this, _indexOfKey)];
|
|
5797
1269
|
__privateGet(this, _index).set(key, i);
|
|
5798
1270
|
}
|
|
5799
1271
|
}
|
|
5800
1272
|
get data() {
|
|
5801
|
-
return __privateGet(this,
|
|
1273
|
+
return __privateGet(this, _data);
|
|
5802
1274
|
}
|
|
5803
1275
|
get map() {
|
|
5804
1276
|
return __privateGet(this, _dataMap);
|
|
@@ -5807,8 +1279,8 @@ var Table = class extends EventEmitter {
|
|
|
5807
1279
|
return __privateGet(this, _schema);
|
|
5808
1280
|
}
|
|
5809
1281
|
insert(row) {
|
|
5810
|
-
const index = __privateGet(this,
|
|
5811
|
-
__privateGet(this,
|
|
1282
|
+
const index = __privateGet(this, _data).length;
|
|
1283
|
+
__privateGet(this, _data).push(row);
|
|
5812
1284
|
const key = row[__privateGet(this, _indexOfKey)];
|
|
5813
1285
|
__privateGet(this, _index).set(key, index);
|
|
5814
1286
|
this.emit("insert", row);
|
|
@@ -5816,33 +1288,33 @@ var Table = class extends EventEmitter {
|
|
|
5816
1288
|
findByKey(key) {
|
|
5817
1289
|
var _a;
|
|
5818
1290
|
const index = (_a = __privateGet(this, _index).get(key)) != null ? _a : -1;
|
|
5819
|
-
return __privateGet(this,
|
|
1291
|
+
return __privateGet(this, _data)[index];
|
|
5820
1292
|
}
|
|
5821
1293
|
update(key, columnName, value) {
|
|
5822
|
-
const rowIndex = __privateGet(this,
|
|
1294
|
+
const rowIndex = __privateGet(this, _data).findIndex(
|
|
5823
1295
|
(row) => row[__privateGet(this, _indexOfKey)] === key
|
|
5824
1296
|
);
|
|
5825
1297
|
const colIndex = __privateGet(this, _dataMap)[columnName];
|
|
5826
1298
|
if (rowIndex !== -1) {
|
|
5827
|
-
const row = __privateGet(this,
|
|
1299
|
+
const row = __privateGet(this, _data)[rowIndex];
|
|
5828
1300
|
const newRow = row.slice();
|
|
5829
1301
|
newRow[colIndex] = value;
|
|
5830
|
-
__privateGet(this,
|
|
1302
|
+
__privateGet(this, _data)[rowIndex] = newRow;
|
|
5831
1303
|
this.emit("update", newRow, columnName);
|
|
5832
1304
|
}
|
|
5833
1305
|
}
|
|
5834
1306
|
updateRow(row) {
|
|
5835
1307
|
const key = row[__privateGet(this, _indexOfKey)];
|
|
5836
|
-
const rowIndex = __privateGet(this,
|
|
1308
|
+
const rowIndex = __privateGet(this, _data).findIndex(
|
|
5837
1309
|
(row2) => row2[__privateGet(this, _indexOfKey)] === key
|
|
5838
1310
|
);
|
|
5839
1311
|
if (rowIndex !== -1) {
|
|
5840
|
-
__privateGet(this,
|
|
1312
|
+
__privateGet(this, _data)[rowIndex] = row;
|
|
5841
1313
|
this.emit("update", row);
|
|
5842
1314
|
}
|
|
5843
1315
|
}
|
|
5844
1316
|
};
|
|
5845
|
-
|
|
1317
|
+
_data = new WeakMap();
|
|
5846
1318
|
_dataMap = new WeakMap();
|
|
5847
1319
|
_indexOfKey = new WeakMap();
|
|
5848
1320
|
_index = new WeakMap();
|