@blackglory/match 0.3.3
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/CHANGELOG.md +62 -0
- package/LICENSE +21 -0
- package/README.md +273 -0
- package/dist/es2015/index.min.mjs +2 -0
- package/dist/es2015/index.min.mjs.map +1 -0
- package/dist/es2015/index.mjs +3918 -0
- package/dist/es2015/index.mjs.map +1 -0
- package/dist/es2015/index.umd.js +3944 -0
- package/dist/es2015/index.umd.js.map +1 -0
- package/dist/es2015/index.umd.min.js +2 -0
- package/dist/es2015/index.umd.min.js.map +1 -0
- package/dist/es2018/index.min.mjs +2 -0
- package/dist/es2018/index.min.mjs.map +1 -0
- package/dist/es2018/index.mjs +3926 -0
- package/dist/es2018/index.mjs.map +1 -0
- package/dist/es2018/index.umd.js +3952 -0
- package/dist/es2018/index.umd.js.map +1 -0
- package/dist/es2018/index.umd.min.js +2 -0
- package/dist/es2018/index.umd.min.js.map +1 -0
- package/lib/es2015/index.d.ts +17 -0
- package/lib/es2015/index.js +38 -0
- package/lib/es2015/index.js.map +1 -0
- package/lib/es2015/match-element.d.ts +4 -0
- package/lib/es2015/match-element.js +22 -0
- package/lib/es2015/match-element.js.map +1 -0
- package/lib/es2015/match.d.ts +4 -0
- package/lib/es2015/match.js +22 -0
- package/lib/es2015/match.js.map +1 -0
- package/lib/es2015/matchers/any-of.d.ts +6 -0
- package/lib/es2015/matchers/any-of.js +10 -0
- package/lib/es2015/matchers/any-of.js.map +1 -0
- package/lib/es2015/matchers/child-nodes.d.ts +2 -0
- package/lib/es2015/matchers/child-nodes.js +23 -0
- package/lib/es2015/matchers/child-nodes.js.map +1 -0
- package/lib/es2015/matchers/children.d.ts +2 -0
- package/lib/es2015/matchers/children.js +23 -0
- package/lib/es2015/matchers/children.js.map +1 -0
- package/lib/es2015/matchers/css.d.ts +3 -0
- package/lib/es2015/matchers/css.js +18 -0
- package/lib/es2015/matchers/css.js.map +1 -0
- package/lib/es2015/matchers/element.d.ts +4 -0
- package/lib/es2015/matchers/element.js +34 -0
- package/lib/es2015/matchers/element.js.map +1 -0
- package/lib/es2015/matchers/multiple.d.ts +10 -0
- package/lib/es2015/matchers/multiple.js +42 -0
- package/lib/es2015/matchers/multiple.js.map +1 -0
- package/lib/es2015/matchers/node.d.ts +4 -0
- package/lib/es2015/matchers/node.js +31 -0
- package/lib/es2015/matchers/node.js.map +1 -0
- package/lib/es2015/matchers/optional.d.ts +2 -0
- package/lib/es2015/matchers/optional.js +9 -0
- package/lib/es2015/matchers/optional.js.map +1 -0
- package/lib/es2015/matchers/repeat.d.ts +2 -0
- package/lib/es2015/matchers/repeat.js +20 -0
- package/lib/es2015/matchers/repeat.js.map +1 -0
- package/lib/es2015/matchers/tap.d.ts +2 -0
- package/lib/es2015/matchers/tap.js +12 -0
- package/lib/es2015/matchers/tap.js.map +1 -0
- package/lib/es2015/matchers/text-content-equals.d.ts +7 -0
- package/lib/es2015/matchers/text-content-equals.js +20 -0
- package/lib/es2015/matchers/text-content-equals.js.map +1 -0
- package/lib/es2015/matchers/text-content-includes.d.ts +7 -0
- package/lib/es2015/matchers/text-content-includes.js +20 -0
- package/lib/es2015/matchers/text-content-includes.js.map +1 -0
- package/lib/es2015/matchers/text-content-matches.d.ts +6 -0
- package/lib/es2015/matchers/text-content-matches.js +16 -0
- package/lib/es2015/matchers/text-content-matches.js.map +1 -0
- package/lib/es2015/matchers/text-node.d.ts +4 -0
- package/lib/es2015/matchers/text-node.js +34 -0
- package/lib/es2015/matchers/text-node.js.map +1 -0
- package/lib/es2015/matchers/xpath.d.ts +3 -0
- package/lib/es2015/matchers/xpath.js +34 -0
- package/lib/es2015/matchers/xpath.js.map +1 -0
- package/lib/es2015/types.d.ts +18 -0
- package/lib/es2015/types.js +3 -0
- package/lib/es2015/types.js.map +1 -0
- package/lib/es2015/utils/concat.d.ts +1 -0
- package/lib/es2015/utils/concat.js +14 -0
- package/lib/es2015/utils/concat.js.map +1 -0
- package/lib/es2015/utils/match-multiple.d.ts +2 -0
- package/lib/es2015/utils/match-multiple.js +21 -0
- package/lib/es2015/utils/match-multiple.js.map +1 -0
- package/lib/es2015/utils/match-one-by-one.d.ts +2 -0
- package/lib/es2015/utils/match-one-by-one.js +38 -0
- package/lib/es2015/utils/match-one-by-one.js.map +1 -0
- package/lib/es2015/utils/merge.d.ts +5 -0
- package/lib/es2015/utils/merge.js +30 -0
- package/lib/es2015/utils/merge.js.map +1 -0
- package/lib/es2015/utils/next-element-sibling.d.ts +1 -0
- package/lib/es2015/utils/next-element-sibling.js +11 -0
- package/lib/es2015/utils/next-element-sibling.js.map +1 -0
- package/lib/es2015/utils/next-sibling.d.ts +1 -0
- package/lib/es2015/utils/next-sibling.js +11 -0
- package/lib/es2015/utils/next-sibling.js.map +1 -0
- package/lib/es2018/index.d.ts +17 -0
- package/lib/es2018/index.js +38 -0
- package/lib/es2018/index.js.map +1 -0
- package/lib/es2018/match-element.d.ts +4 -0
- package/lib/es2018/match-element.js +22 -0
- package/lib/es2018/match-element.js.map +1 -0
- package/lib/es2018/match.d.ts +4 -0
- package/lib/es2018/match.js +22 -0
- package/lib/es2018/match.js.map +1 -0
- package/lib/es2018/matchers/any-of.d.ts +6 -0
- package/lib/es2018/matchers/any-of.js +10 -0
- package/lib/es2018/matchers/any-of.js.map +1 -0
- package/lib/es2018/matchers/child-nodes.d.ts +2 -0
- package/lib/es2018/matchers/child-nodes.js +27 -0
- package/lib/es2018/matchers/child-nodes.js.map +1 -0
- package/lib/es2018/matchers/children.d.ts +2 -0
- package/lib/es2018/matchers/children.js +27 -0
- package/lib/es2018/matchers/children.js.map +1 -0
- package/lib/es2018/matchers/css.d.ts +3 -0
- package/lib/es2018/matchers/css.js +18 -0
- package/lib/es2018/matchers/css.js.map +1 -0
- package/lib/es2018/matchers/element.d.ts +4 -0
- package/lib/es2018/matchers/element.js +34 -0
- package/lib/es2018/matchers/element.js.map +1 -0
- package/lib/es2018/matchers/multiple.d.ts +10 -0
- package/lib/es2018/matchers/multiple.js +42 -0
- package/lib/es2018/matchers/multiple.js.map +1 -0
- package/lib/es2018/matchers/node.d.ts +4 -0
- package/lib/es2018/matchers/node.js +31 -0
- package/lib/es2018/matchers/node.js.map +1 -0
- package/lib/es2018/matchers/optional.d.ts +2 -0
- package/lib/es2018/matchers/optional.js +9 -0
- package/lib/es2018/matchers/optional.js.map +1 -0
- package/lib/es2018/matchers/repeat.d.ts +2 -0
- package/lib/es2018/matchers/repeat.js +20 -0
- package/lib/es2018/matchers/repeat.js.map +1 -0
- package/lib/es2018/matchers/tap.d.ts +2 -0
- package/lib/es2018/matchers/tap.js +12 -0
- package/lib/es2018/matchers/tap.js.map +1 -0
- package/lib/es2018/matchers/text-content-equals.d.ts +7 -0
- package/lib/es2018/matchers/text-content-equals.js +20 -0
- package/lib/es2018/matchers/text-content-equals.js.map +1 -0
- package/lib/es2018/matchers/text-content-includes.d.ts +7 -0
- package/lib/es2018/matchers/text-content-includes.js +20 -0
- package/lib/es2018/matchers/text-content-includes.js.map +1 -0
- package/lib/es2018/matchers/text-content-matches.d.ts +6 -0
- package/lib/es2018/matchers/text-content-matches.js +16 -0
- package/lib/es2018/matchers/text-content-matches.js.map +1 -0
- package/lib/es2018/matchers/text-node.d.ts +4 -0
- package/lib/es2018/matchers/text-node.js +34 -0
- package/lib/es2018/matchers/text-node.js.map +1 -0
- package/lib/es2018/matchers/xpath.d.ts +3 -0
- package/lib/es2018/matchers/xpath.js +34 -0
- package/lib/es2018/matchers/xpath.js.map +1 -0
- package/lib/es2018/types.d.ts +18 -0
- package/lib/es2018/types.js +3 -0
- package/lib/es2018/types.js.map +1 -0
- package/lib/es2018/utils/concat.d.ts +1 -0
- package/lib/es2018/utils/concat.js +14 -0
- package/lib/es2018/utils/concat.js.map +1 -0
- package/lib/es2018/utils/match-multiple.d.ts +2 -0
- package/lib/es2018/utils/match-multiple.js +21 -0
- package/lib/es2018/utils/match-multiple.js.map +1 -0
- package/lib/es2018/utils/match-one-by-one.d.ts +2 -0
- package/lib/es2018/utils/match-one-by-one.js +38 -0
- package/lib/es2018/utils/match-one-by-one.js.map +1 -0
- package/lib/es2018/utils/merge.d.ts +5 -0
- package/lib/es2018/utils/merge.js +30 -0
- package/lib/es2018/utils/merge.js.map +1 -0
- package/lib/es2018/utils/next-element-sibling.d.ts +1 -0
- package/lib/es2018/utils/next-element-sibling.js +11 -0
- package/lib/es2018/utils/next-element-sibling.js.map +1 -0
- package/lib/es2018/utils/next-sibling.d.ts +1 -0
- package/lib/es2018/utils/next-sibling.js +11 -0
- package/lib/es2018/utils/next-sibling.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.xpath = exports.textNode = exports.textContentMatches = exports.textContentIncludes = exports.textContentEquals = exports.tap = exports.repeat = exports.optional = exports.node = exports.multiple = exports.element = exports.css = exports.children = exports.childNodes = exports.anyOf = exports.matchElement = exports.match = void 0;
|
|
4
|
+
var match_1 = require("./match");
|
|
5
|
+
Object.defineProperty(exports, "match", { enumerable: true, get: function () { return match_1.match; } });
|
|
6
|
+
var match_element_1 = require("./match-element");
|
|
7
|
+
Object.defineProperty(exports, "matchElement", { enumerable: true, get: function () { return match_element_1.matchElement; } });
|
|
8
|
+
var any_of_1 = require("./matchers/any-of");
|
|
9
|
+
Object.defineProperty(exports, "anyOf", { enumerable: true, get: function () { return any_of_1.anyOf; } });
|
|
10
|
+
var child_nodes_1 = require("./matchers/child-nodes");
|
|
11
|
+
Object.defineProperty(exports, "childNodes", { enumerable: true, get: function () { return child_nodes_1.childNodes; } });
|
|
12
|
+
var children_1 = require("./matchers/children");
|
|
13
|
+
Object.defineProperty(exports, "children", { enumerable: true, get: function () { return children_1.children; } });
|
|
14
|
+
var css_1 = require("./matchers/css");
|
|
15
|
+
Object.defineProperty(exports, "css", { enumerable: true, get: function () { return css_1.css; } });
|
|
16
|
+
var element_1 = require("./matchers/element");
|
|
17
|
+
Object.defineProperty(exports, "element", { enumerable: true, get: function () { return element_1.element; } });
|
|
18
|
+
var multiple_1 = require("./matchers/multiple");
|
|
19
|
+
Object.defineProperty(exports, "multiple", { enumerable: true, get: function () { return multiple_1.multiple; } });
|
|
20
|
+
var node_1 = require("./matchers/node");
|
|
21
|
+
Object.defineProperty(exports, "node", { enumerable: true, get: function () { return node_1.node; } });
|
|
22
|
+
var optional_1 = require("./matchers/optional");
|
|
23
|
+
Object.defineProperty(exports, "optional", { enumerable: true, get: function () { return optional_1.optional; } });
|
|
24
|
+
var repeat_1 = require("./matchers/repeat");
|
|
25
|
+
Object.defineProperty(exports, "repeat", { enumerable: true, get: function () { return repeat_1.repeat; } });
|
|
26
|
+
var tap_1 = require("./matchers/tap");
|
|
27
|
+
Object.defineProperty(exports, "tap", { enumerable: true, get: function () { return tap_1.tap; } });
|
|
28
|
+
var text_content_equals_1 = require("./matchers/text-content-equals");
|
|
29
|
+
Object.defineProperty(exports, "textContentEquals", { enumerable: true, get: function () { return text_content_equals_1.textContentEquals; } });
|
|
30
|
+
var text_content_includes_1 = require("./matchers/text-content-includes");
|
|
31
|
+
Object.defineProperty(exports, "textContentIncludes", { enumerable: true, get: function () { return text_content_includes_1.textContentIncludes; } });
|
|
32
|
+
var text_content_matches_1 = require("./matchers/text-content-matches");
|
|
33
|
+
Object.defineProperty(exports, "textContentMatches", { enumerable: true, get: function () { return text_content_matches_1.textContentMatches; } });
|
|
34
|
+
var text_node_1 = require("./matchers/text-node");
|
|
35
|
+
Object.defineProperty(exports, "textNode", { enumerable: true, get: function () { return text_node_1.textNode; } });
|
|
36
|
+
var xpath_1 = require("./matchers/xpath");
|
|
37
|
+
Object.defineProperty(exports, "xpath", { enumerable: true, get: function () { return xpath_1.xpath; } });
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,iDAA8C;AAArC,6GAAA,YAAY,OAAA;AAErB,2CAAwC;AAA/B,+FAAA,KAAK,OAAA;AACd,qDAAkD;AAAzC,yGAAA,UAAU,OAAA;AACnB,+CAA6C;AAApC,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,0FAAA,GAAG,OAAA;AACZ,6CAA2C;AAAlC,kGAAA,OAAO,OAAA;AAChB,+CAA6C;AAApC,oGAAA,QAAQ,OAAA;AACjB,uCAAqC;AAA5B,4FAAA,IAAI,OAAA;AACb,+CAA6C;AAApC,oGAAA,QAAQ,OAAA;AACjB,2CAAyC;AAAhC,gGAAA,MAAM,OAAA;AACf,qCAAmC;AAA1B,0FAAA,GAAG,OAAA;AACZ,qEAAiE;AAAxD,wHAAA,iBAAiB,OAAA;AAC1B,yEAAqE;AAA5D,4HAAA,mBAAmB,OAAA;AAC5B,uEAAmE;AAA1D,0HAAA,kBAAkB,OAAA;AAC3B,iDAA8C;AAArC,qGAAA,QAAQ,OAAA;AACjB,yCAAuC;AAA9B,8FAAA,KAAK,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchElement = void 0;
|
|
4
|
+
const extra_dom_1 = require("extra-dom");
|
|
5
|
+
const match_one_by_one_1 = require("./utils/match-one-by-one");
|
|
6
|
+
const next_element_sibling_1 = require("./utils/next-element-sibling");
|
|
7
|
+
function matchElement(element, ...matchers) {
|
|
8
|
+
const document = (0, extra_dom_1.isDocument)(this) ? this : globalThis.document;
|
|
9
|
+
const context = {
|
|
10
|
+
document,
|
|
11
|
+
collection: {},
|
|
12
|
+
next: next_element_sibling_1.nextElementSibling
|
|
13
|
+
};
|
|
14
|
+
if ((0, match_one_by_one_1.matchOneByOne)(context, element, ...matchers)) {
|
|
15
|
+
return context.collection;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.matchElement = matchElement;
|
|
22
|
+
//# sourceMappingURL=match-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-element.js","sourceRoot":"","sources":["../../src/match-element.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAEtC,8DAAuD;AACvD,sEAAgE;AAEhE,SAAgB,YAAY,CAE1B,OAAgB,EAChB,GAAG,QAAkC;IAErC,MAAM,QAAQ,GAAG,IAAA,sBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAA;IAC9D,MAAM,OAAO,GAAa;QACxB,QAAQ;QACR,UAAU,EAAE,EAAE;QACd,IAAI,EAAE,yCAAkB;KACzB,CAAA;IAED,IAAI,IAAA,gCAAa,EAAC,OAAO,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,EAAE;QAChD,OAAO,OAAO,CAAC,UAAU,CAAA;KAC1B;SAAM;QACL,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAjBD,oCAiBC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.match = void 0;
|
|
4
|
+
const extra_dom_1 = require("extra-dom");
|
|
5
|
+
const match_one_by_one_1 = require("./utils/match-one-by-one");
|
|
6
|
+
const next_sibling_1 = require("./utils/next-sibling");
|
|
7
|
+
function match(node, ...matchers) {
|
|
8
|
+
const document = (0, extra_dom_1.isDocument)(this) ? this : globalThis.document;
|
|
9
|
+
const context = {
|
|
10
|
+
document,
|
|
11
|
+
collection: {},
|
|
12
|
+
next: next_sibling_1.nextSibling
|
|
13
|
+
};
|
|
14
|
+
if ((0, match_one_by_one_1.matchOneByOne)(context, node, ...matchers)) {
|
|
15
|
+
return context.collection;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.match = match;
|
|
22
|
+
//# sourceMappingURL=match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/match.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAEtC,8DAAuD;AACvD,sDAAiD;AAEjD,SAAgB,KAAK,CAEnB,IAAU,EACV,GAAG,QAA+B;IAElC,MAAM,QAAQ,GAAG,IAAA,sBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAA;IAC9D,MAAM,OAAO,GAAa;QACxB,QAAQ;QACR,UAAU,EAAE,EAAE;QACd,IAAI,EAAE,0BAAW;KAClB,CAAA;IAED,IAAI,IAAA,gCAAa,EAAC,OAAO,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE;QAC7C,OAAO,OAAO,CAAC,UAAU,CAAA;KAC1B;SAAM;QACL,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAjBD,sBAiBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ITerminalMatcher, INestedMatcher } from '../types';
|
|
2
|
+
export declare function anyOf<T extends Node>(...matchers: [
|
|
3
|
+
INestedMatcher<T> | ITerminalMatcher<T>,
|
|
4
|
+
INestedMatcher<T> | ITerminalMatcher<T>,
|
|
5
|
+
...Array<INestedMatcher<T> | ITerminalMatcher<T>>
|
|
6
|
+
]): INestedMatcher<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.anyOf = void 0;
|
|
4
|
+
function anyOf(...matchers) {
|
|
5
|
+
return function (node) {
|
|
6
|
+
return matchers.some(match => match.call(this, node));
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
exports.anyOf = anyOf;
|
|
10
|
+
//# sourceMappingURL=any-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"any-of.js","sourceRoot":"","sources":["../../../src/matchers/any-of.ts"],"names":[],"mappings":";;;AAEA,SAAgB,KAAK,CACnB,GAAG,QAIF;IAED,OAAO,UAAkC,IAAO;QAC9C,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACvD,CAAC,CAAA;AACH,CAAC;AAVD,sBAUC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.childNodes = void 0;
|
|
4
|
+
const match_one_by_one_1 = require("../utils/match-one-by-one");
|
|
5
|
+
const merge_1 = require("../utils/merge");
|
|
6
|
+
const next_sibling_1 = require("../utils/next-sibling");
|
|
7
|
+
function childNodes(...matchers) {
|
|
8
|
+
return function (node) {
|
|
9
|
+
if (matchers.length === 0) {
|
|
10
|
+
return node.childNodes.length === 0;
|
|
11
|
+
}
|
|
12
|
+
if (node.childNodes.length === 0)
|
|
13
|
+
return false;
|
|
14
|
+
const context = Object.assign(Object.assign({}, this), { collection: {}, next: next_sibling_1.nextSibling });
|
|
15
|
+
const result = (0, match_one_by_one_1.matchOneByOne)(context, node.childNodes[0], ...matchers);
|
|
16
|
+
if (result) {
|
|
17
|
+
(0, merge_1.merge)(this.collection, context.collection);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.childNodes = childNodes;
|
|
23
|
+
//# sourceMappingURL=child-nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-nodes.js","sourceRoot":"","sources":["../../../src/matchers/child-nodes.ts"],"names":[],"mappings":";;;AACA,8DAAuD;AACvD,wCAAoC;AACpC,sDAAiD;AAEjD,SAAgB,UAAU,CAAC,GAAG,QAA+B;IAC3D,OAAO,UAAkC,IAAU;QAEjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAA;SACpC;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;QAE9C,MAAM,OAAO,mCACR,IAAI,KACP,UAAU,EAAE,EAAE,EACd,IAAI,EAAE,0BAAW,GAClB,CAAA;QAED,MAAM,MAAM,GAAG,IAAA,gCAAa,EAC1B,OAAO,EACP,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAClB,GAAG,QAAQ,CACZ,CAAA;QAED,IAAI,MAAM,EAAE;YACV,IAAA,aAAK,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;SAC3C;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AA3BD,gCA2BC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.children = void 0;
|
|
4
|
+
const match_one_by_one_1 = require("../utils/match-one-by-one");
|
|
5
|
+
const merge_1 = require("../utils/merge");
|
|
6
|
+
const next_element_sibling_1 = require("../utils/next-element-sibling");
|
|
7
|
+
function children(...matchers) {
|
|
8
|
+
return function (element) {
|
|
9
|
+
if (matchers.length === 0) {
|
|
10
|
+
return element.children.length === 0;
|
|
11
|
+
}
|
|
12
|
+
if (element.children.length === 0)
|
|
13
|
+
return false;
|
|
14
|
+
const context = Object.assign(Object.assign({}, this), { collection: {}, next: next_element_sibling_1.nextElementSibling });
|
|
15
|
+
const result = (0, match_one_by_one_1.matchOneByOne)(context, element.children[0], ...matchers);
|
|
16
|
+
if (result) {
|
|
17
|
+
(0, merge_1.merge)(this.collection, context.collection);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.children = children;
|
|
23
|
+
//# sourceMappingURL=children.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children.js","sourceRoot":"","sources":["../../../src/matchers/children.ts"],"names":[],"mappings":";;;AACA,8DAAuD;AACvD,wCAAoC;AACpC,sEAAgE;AAEhE,SAAgB,QAAQ,CACtB,GAAG,QAAkC;IAErC,OAAO,UAAkC,OAAgB;QAEvD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAA;SACrC;QAED,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;QAE/C,MAAM,OAAO,mCACR,IAAI,KACP,UAAU,EAAE,EAAE,EACd,IAAI,EAAE,yCAAkB,GACzB,CAAA;QAED,MAAM,MAAM,GAAG,IAAA,gCAAa,EAC1B,OAAO,EACP,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EACnB,GAAG,QAAQ,CACZ,CAAA;QAED,IAAI,MAAM,EAAE;YACV,IAAA,aAAK,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;SAC3C;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AA7BD,4BA6BC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.css = void 0;
|
|
4
|
+
const concat_1 = require("../utils/concat");
|
|
5
|
+
const types_1 = require("@blackglory/types");
|
|
6
|
+
function css(...args) {
|
|
7
|
+
if ((0, types_1.isString)(args[0])) {
|
|
8
|
+
const [selector] = args;
|
|
9
|
+
return (element) => element.matches(selector);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
const [strings, ...values] = args;
|
|
13
|
+
const selector = (0, concat_1.concat)(strings, values).join('');
|
|
14
|
+
return css(selector);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.css = css;
|
|
18
|
+
//# sourceMappingURL=css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.js","sourceRoot":"","sources":["../../../src/matchers/css.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AAEtC,6CAA4C;AAO5C,SAAgB,GAAG,CAAC,GAAG,IAE+B;IAEpD,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAA;QAEvB,OAAO,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;KACvD;SAAM;QACL,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,CAAA;QACjC,MAAM,QAAQ,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAEjD,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAA;KACrB;AACH,CAAC;AAdD,kBAcC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher } from '../types';
|
|
2
|
+
export declare function element(strings: TemplateStringsArray, ...values: string[]): (...matchers: Array<INestedMatcher<Element> | ITerminalMatcher<Element>>) => INestedMatcher<Node>;
|
|
3
|
+
export declare function element(name: string, ...matchers: Array<INestedMatcher<Element>>): INestedMatcher<Node>;
|
|
4
|
+
export declare function element(...matchers: Array<INestedMatcher<Element>>): INestedMatcher<Node>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.element = void 0;
|
|
4
|
+
const extra_dom_1 = require("extra-dom");
|
|
5
|
+
const types_1 = require("@blackglory/types");
|
|
6
|
+
const concat_1 = require("../utils/concat");
|
|
7
|
+
const merge_1 = require("../utils/merge");
|
|
8
|
+
function element(...args) {
|
|
9
|
+
if (Array.isArray(args[0])) {
|
|
10
|
+
const [strings, ...values] = args;
|
|
11
|
+
const name = (0, concat_1.concat)(strings, values).join('');
|
|
12
|
+
return (...matchers) => element(name, ...matchers);
|
|
13
|
+
}
|
|
14
|
+
if ((0, types_1.isString)(args[0])) {
|
|
15
|
+
const [name, ...matchers] = args;
|
|
16
|
+
return function (_element) {
|
|
17
|
+
const result = element(...matchers).call(this, _element);
|
|
18
|
+
if (result) {
|
|
19
|
+
(0, merge_1.merge)(this.collection, { [name]: _element });
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const [...matchers] = args;
|
|
25
|
+
return function (element) {
|
|
26
|
+
if ((0, extra_dom_1.isntElement)(element))
|
|
27
|
+
return false;
|
|
28
|
+
if (matchers.length === 0)
|
|
29
|
+
return true;
|
|
30
|
+
return matchers.every(match => match.call(this, element));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.element = element;
|
|
34
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/matchers/element.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AAEvC,6CAA4C;AAC5C,0CAAsC;AACtC,wCAAoC;AAUpC,SAAgB,OAAO,CAAC,GAAG,IAGgD;IAEzE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1B,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GACxB,IAA4D,CAAA;QAC9D,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAE7C,OAAO,CAAC,GAAG,QAAoE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAA;KAC/G;IAED,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,GACvB,IAA+F,CAAA;QAEjG,OAAO,UAAkC,QAAiB;YACxD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YACxD,IAAI,MAAM,EAAE;gBACV,IAAA,aAAK,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;aAC7C;YACD,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;KACF;IAED,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,IAAiF,CAAA;IAEvG,OAAO,UAAkC,OAAgB;QACvD,IAAI,IAAA,uBAAW,EAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAA;QACtC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QAEtC,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IAC3D,CAAC,CAAA;AACH,CAAC;AAlCD,0BAkCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher, ISkipMatcher } from '../types';
|
|
2
|
+
export declare enum Range {
|
|
3
|
+
Min = 0,
|
|
4
|
+
Max = 1
|
|
5
|
+
}
|
|
6
|
+
interface IMultipleOptions {
|
|
7
|
+
greedy: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function multiple<T extends Node>([min, max]: [min: number, max: number], matcher: INestedMatcher<T> | ITerminalMatcher<T>, options?: IMultipleOptions): ISkipMatcher<T>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.multiple = exports.Range = void 0;
|
|
4
|
+
const extra_generator_1 = require("extra-generator");
|
|
5
|
+
const errors_1 = require("@blackglory/errors");
|
|
6
|
+
const match_multiple_1 = require("../utils/match-multiple");
|
|
7
|
+
var Range;
|
|
8
|
+
(function (Range) {
|
|
9
|
+
Range[Range["Min"] = 0] = "Min";
|
|
10
|
+
Range[Range["Max"] = 1] = "Max";
|
|
11
|
+
})(Range = exports.Range || (exports.Range = {}));
|
|
12
|
+
function multiple([min, max], matcher, options = { greedy: true }) {
|
|
13
|
+
(0, errors_1.assert)(Number.isInteger(min), 'parameter min must be an integer');
|
|
14
|
+
(0, errors_1.assert)(Number.isInteger(max) || max === Infinity, 'parameter max must be an integer or Infinity');
|
|
15
|
+
(0, errors_1.assert)(min >= 0, 'parameter min must be greater than or equal to 0');
|
|
16
|
+
(0, errors_1.assert)(min <= max, 'parameter max must be greater than or equal to min');
|
|
17
|
+
return function* (node) {
|
|
18
|
+
if (options.greedy) {
|
|
19
|
+
let ubound = max;
|
|
20
|
+
while (true) {
|
|
21
|
+
const round = match_multiple_1.matchMultiple.call(this, node, ubound, matcher);
|
|
22
|
+
if (round < min)
|
|
23
|
+
break;
|
|
24
|
+
yield round;
|
|
25
|
+
ubound = round - 1;
|
|
26
|
+
if (ubound < min)
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
for (const ubound of (0, extra_generator_1.countup)(min, max)) {
|
|
32
|
+
const result = match_multiple_1.matchMultiple.call(this, node, ubound, matcher);
|
|
33
|
+
if (result < ubound)
|
|
34
|
+
break;
|
|
35
|
+
if (result === ubound)
|
|
36
|
+
yield ubound;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.multiple = multiple;
|
|
42
|
+
//# sourceMappingURL=multiple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiple.js","sourceRoot":"","sources":["../../../src/matchers/multiple.ts"],"names":[],"mappings":";;;AACA,qDAAyC;AACzC,+CAA2C;AAC3C,0DAAqD;AAErD,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,+BAAO,CAAA;IACP,+BAAO,CAAA;AACT,CAAC,EAHW,KAAK,GAAL,aAAK,KAAL,aAAK,QAGhB;AAOD,SAAgB,QAAQ,CACtB,CAAC,GAAG,EAAE,GAAG,CAA6B,EACtC,OAAgD,EAChD,UAA4B,EAAE,MAAM,EAAE,IAAI,EAAE;IAE5C,IAAA,eAAM,EAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,kCAAkC,CAAC,CAAA;IACjE,IAAA,eAAM,EAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,QAAQ,EAAE,8CAA8C,CAAC,CAAA;IACjG,IAAA,eAAM,EAAC,GAAG,IAAI,CAAC,EAAE,kDAAkD,CAAC,CAAA;IACpE,IAAA,eAAM,EAAC,GAAG,IAAI,GAAG,EAAE,oDAAoD,CAAC,CAAA;IAExE,OAAO,QAAQ,CAAC,EAA0B,IAAO;QAC/C,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,IAAI,MAAM,GAAG,GAAG,CAAA;YAChB,OAAO,IAAI,EAAE;gBACX,MAAM,KAAK,GAAG,8BAAa,CAAC,IAAI,CAC9B,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAwD,CACzD,CAAA;gBAED,IAAI,KAAK,GAAG,GAAG;oBAAE,MAAK;gBACtB,MAAM,KAAK,CAAA;gBAEX,MAAM,GAAG,KAAK,GAAG,CAAC,CAAA;gBAClB,IAAI,MAAM,GAAG,GAAG;oBAAE,MAAK;aACxB;SACF;aAAM;YACL,KAAK,MAAM,MAAM,IAAI,IAAA,yBAAO,EAAC,GAAG,EAAE,GAAG,CAAC,EAAE;gBACtC,MAAM,MAAM,GAAG,8BAAa,CAAC,IAAI,CAC/B,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAsD,CACvD,CAAA;gBAGD,IAAI,MAAM,GAAG,MAAM;oBAAE,MAAK;gBAE1B,IAAI,MAAM,KAAK,MAAM;oBAAE,MAAM,MAAM,CAAA;aACpC;SACF;IACH,CAAC,CAAA;AACH,CAAC;AA3CD,4BA2CC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher } from '../types';
|
|
2
|
+
export declare function node(strings: TemplateStringsArray, ...values: string[]): (...matchers: Array<INestedMatcher<Node> | ITerminalMatcher<Node>>) => INestedMatcher<Node>;
|
|
3
|
+
export declare function node(name: string, ...matchers: Array<INestedMatcher<Node> | ITerminalMatcher<Node>>): INestedMatcher<Node>;
|
|
4
|
+
export declare function node(...matchers: Array<INestedMatcher<Node> | ITerminalMatcher<Node>>): INestedMatcher<Node>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.node = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
const concat_1 = require("../utils/concat");
|
|
6
|
+
const merge_1 = require("../utils/merge");
|
|
7
|
+
function node(...args) {
|
|
8
|
+
if (Array.isArray(args[0])) {
|
|
9
|
+
const [strings, ...values] = args;
|
|
10
|
+
const name = (0, concat_1.concat)(strings, values).join('');
|
|
11
|
+
return (...matchers) => node(name, ...matchers);
|
|
12
|
+
}
|
|
13
|
+
if ((0, types_1.isString)(args[0])) {
|
|
14
|
+
const [name, ...matchers] = args;
|
|
15
|
+
return function (_node) {
|
|
16
|
+
const result = node(...matchers).call(this, _node);
|
|
17
|
+
if (result) {
|
|
18
|
+
(0, merge_1.merge)(this.collection, { [name]: _node });
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const [...matchers] = args;
|
|
24
|
+
return function (node) {
|
|
25
|
+
if (matchers.length === 0)
|
|
26
|
+
return true;
|
|
27
|
+
return matchers.every(match => match.call(this, node));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.node = node;
|
|
31
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/matchers/node.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAC5C,0CAAsC;AACtC,wCAAoC;AAapC,SAAgB,IAAI,CAAC,GAAG,IAG6C;IAEnE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1B,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GACxB,IAA4D,CAAA;QAC9D,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAE7C,OAAO,CAAC,GAAG,QAA8D,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAA;KACtG;IAED,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,GACvB,IAAyF,CAAA;QAE3F,OAAO,UAAkC,KAAW;YAClD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;YAClD,IAAI,MAAM,EAAE;gBACV,IAAA,aAAK,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;aAC1C;YACD,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;KACF;IAED,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,IAA2E,CAAA;IAEjG,OAAO,UAAkC,IAAU;QACjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QAEtC,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC,CAAA;AACH,CAAC;AAjCD,oBAiCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.optional = void 0;
|
|
4
|
+
const multiple_1 = require("./multiple");
|
|
5
|
+
function optional(matcher) {
|
|
6
|
+
return (0, multiple_1.multiple)([0, 1], matcher, { greedy: true });
|
|
7
|
+
}
|
|
8
|
+
exports.optional = optional;
|
|
9
|
+
//# sourceMappingURL=optional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../src/matchers/optional.ts"],"names":[],"mappings":";;;AACA,yCAAqC;AAErC,SAAgB,QAAQ,CAAiB,OAAgD;IACvF,OAAO,IAAA,mBAAQ,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AACpD,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repeat = void 0;
|
|
4
|
+
const errors_1 = require("@blackglory/errors");
|
|
5
|
+
const match_multiple_1 = require("../utils/match-multiple");
|
|
6
|
+
function repeat(times, matcher) {
|
|
7
|
+
(0, errors_1.assert)(Number.isInteger(times), 'parameter times must be an integer');
|
|
8
|
+
(0, errors_1.assert)(times >= 0, 'parameter number must be greater than or equal to 0');
|
|
9
|
+
return function (node) {
|
|
10
|
+
const result = match_multiple_1.matchMultiple.call(this, node, times, matcher);
|
|
11
|
+
if (result === times) {
|
|
12
|
+
return times;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.repeat = repeat;
|
|
20
|
+
//# sourceMappingURL=repeat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeat.js","sourceRoot":"","sources":["../../../src/matchers/repeat.ts"],"names":[],"mappings":";;;AACA,+CAA2C;AAC3C,0DAAqD;AAErD,SAAgB,MAAM,CACpB,KAAa,EACb,OAAgD;IAEhD,IAAA,eAAM,EAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,oCAAoC,CAAC,CAAA;IACrE,IAAA,eAAM,EAAC,KAAK,IAAI,CAAC,EAAE,qDAAqD,CAAC,CAAA;IAEzE,OAAO,UAAkC,IAAO;QAC9C,MAAM,MAAM,GAAG,8BAAa,CAAC,IAAI,CAC/B,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAwD,CACzD,CAAA;QACD,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,OAAO,KAAK,CAAA;SACb;aAAM;YACL,OAAO,KAAK,CAAA;SACb;IACH,CAAC,CAAA;AACH,CAAC;AApBD,wBAoBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tap = void 0;
|
|
4
|
+
function tap(matcher, callback) {
|
|
5
|
+
return function (node) {
|
|
6
|
+
const result = matcher.call(this, node);
|
|
7
|
+
callback(result);
|
|
8
|
+
return result;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.tap = tap;
|
|
12
|
+
//# sourceMappingURL=tap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../../src/matchers/tap.ts"],"names":[],"mappings":";;;AAEA,SAAgB,GAAG,CACjB,OAA+C,EAC/C,QAA4B;IAE5B,OAAO,UAAkC,IAAO;QAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACvC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAChB,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AATD,kBASC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ITerminalMatcher } from '../types';
|
|
2
|
+
interface ITextContentEqualsOptions {
|
|
3
|
+
caseSensitive?: boolean;
|
|
4
|
+
trim?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function textContentEquals(text: string, { caseSensitive, trim }?: ITextContentEqualsOptions): ITerminalMatcher<Node>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textContentEquals = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
function textContentEquals(text, { caseSensitive = true, trim = false } = {}) {
|
|
6
|
+
return (node) => {
|
|
7
|
+
if ((0, types_1.isNull)(node.textContent))
|
|
8
|
+
return false;
|
|
9
|
+
let textContent = node.textContent;
|
|
10
|
+
if (!caseSensitive) {
|
|
11
|
+
textContent = textContent.toLowerCase();
|
|
12
|
+
text = text.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
if (trim)
|
|
15
|
+
textContent = textContent.trim();
|
|
16
|
+
return textContent === text;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.textContentEquals = textContentEquals;
|
|
20
|
+
//# sourceMappingURL=text-content-equals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content-equals.js","sourceRoot":"","sources":["../../../src/matchers/text-content-equals.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAO1C,SAAgB,iBAAiB,CAC/B,IAAY,EACZ,EACE,aAAa,GAAG,IAAI,EACpB,IAAI,GAAG,KAAK,KACiB,EAAE;IAEjC,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAA;QAE1C,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QAClC,IAAI,CAAC,aAAa,EAAE;YAClB,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAA;YACvC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;SAC1B;QACD,IAAI,IAAI;YAAE,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,WAAW,KAAK,IAAI,CAAA;IAC7B,CAAC,CAAA;AACH,CAAC;AAnBD,8CAmBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ITerminalMatcher } from '../types';
|
|
2
|
+
interface ITextContentIncludesOptions {
|
|
3
|
+
caseSensitive?: boolean;
|
|
4
|
+
trim?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function textContentIncludes(searchString: string, { caseSensitive, trim }?: ITextContentIncludesOptions): ITerminalMatcher<Node>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textContentIncludes = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
function textContentIncludes(searchString, { caseSensitive = true, trim = false } = {}) {
|
|
6
|
+
return (node) => {
|
|
7
|
+
if ((0, types_1.isNull)(node.textContent))
|
|
8
|
+
return false;
|
|
9
|
+
let textContent = node.textContent;
|
|
10
|
+
if (!caseSensitive) {
|
|
11
|
+
textContent = textContent.toLowerCase();
|
|
12
|
+
searchString = searchString.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
if (trim)
|
|
15
|
+
textContent = textContent.trim();
|
|
16
|
+
return textContent.includes(searchString);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.textContentIncludes = textContentIncludes;
|
|
20
|
+
//# sourceMappingURL=text-content-includes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content-includes.js","sourceRoot":"","sources":["../../../src/matchers/text-content-includes.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAO1C,SAAgB,mBAAmB,CACjC,YAAoB,EACpB,EACE,aAAa,GAAG,IAAI,EACpB,IAAI,GAAG,KAAK,KACmB,EAAE;IAEnC,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAA;QAE1C,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QAClC,IAAI,CAAC,aAAa,EAAE;YAClB,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAA;YACvC,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE,CAAA;SAC1C;QACD,IAAI,IAAI;YAAE,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IAC3C,CAAC,CAAA;AACH,CAAC;AAnBD,kDAmBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textContentMatches = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
function textContentMatches(pattern, { trim = false } = {}) {
|
|
6
|
+
return (node) => {
|
|
7
|
+
if ((0, types_1.isNull)(node.textContent))
|
|
8
|
+
return false;
|
|
9
|
+
let textContent = node.textContent;
|
|
10
|
+
if (trim)
|
|
11
|
+
textContent = textContent.trim();
|
|
12
|
+
return pattern.test(textContent);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.textContentMatches = textContentMatches;
|
|
16
|
+
//# sourceMappingURL=text-content-matches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content-matches.js","sourceRoot":"","sources":["../../../src/matchers/text-content-matches.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAM1C,SAAgB,kBAAkB,CAChC,OAAe,EACf,EAAE,IAAI,GAAG,KAAK,KAAiC,EAAE;IAEjD,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAA;QAE1C,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QAClC,IAAI,IAAI;YAAE,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC,CAAA;AACH,CAAC;AAZD,gDAYC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher } from '../types';
|
|
2
|
+
export declare function textNode(strings: TemplateStringsArray, ...values: string[]): (...matchers: Array<ITerminalMatcher<Node>>) => INestedMatcher<Node>;
|
|
3
|
+
export declare function textNode(name: string, ...matchers: Array<ITerminalMatcher<Node>>): INestedMatcher<Node>;
|
|
4
|
+
export declare function textNode(...matchers: Array<ITerminalMatcher<Node>>): INestedMatcher<Node>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textNode = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
const concat_1 = require("../utils/concat");
|
|
6
|
+
const extra_dom_1 = require("extra-dom");
|
|
7
|
+
const merge_1 = require("../utils/merge");
|
|
8
|
+
function textNode(...args) {
|
|
9
|
+
if (Array.isArray(args[0])) {
|
|
10
|
+
const [strings, ...values] = args;
|
|
11
|
+
const name = (0, concat_1.concat)(strings, values).join('');
|
|
12
|
+
return (...matchers) => textNode(name, ...matchers);
|
|
13
|
+
}
|
|
14
|
+
if ((0, types_1.isString)(args[0])) {
|
|
15
|
+
const [name, ...matchers] = args;
|
|
16
|
+
return function (node) {
|
|
17
|
+
const result = textNode(...matchers).call(this, node);
|
|
18
|
+
if (result) {
|
|
19
|
+
(0, merge_1.merge)(this.collection, { [name]: node });
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const [...matchers] = args;
|
|
25
|
+
return function (node) {
|
|
26
|
+
if ((0, extra_dom_1.isntTextNode)(node))
|
|
27
|
+
return false;
|
|
28
|
+
if (matchers.length === 0)
|
|
29
|
+
return true;
|
|
30
|
+
return matchers.every(match => match.call(this, node));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.textNode = textNode;
|
|
34
|
+
//# sourceMappingURL=text-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-node.js","sourceRoot":"","sources":["../../../src/matchers/text-node.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAC5C,0CAAsC;AACtC,yCAAwC;AACxC,wCAAoC;AAapC,SAAgB,QAAQ,CAAC,GAAG,IAGkB;IAE5C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1B,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GACxB,IAA4D,CAAA;QAC9D,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAE7C,OAAO,CAAC,GAAG,QAAuC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAA;KACnF;IAED,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,GACvB,IAAkE,CAAA;QAEpE,OAAO,UAAkC,IAAU;YACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACrD,IAAI,MAAM,EAAE;gBACV,IAAA,aAAK,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;aACzC;YACD,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;KACF;IAED,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,IAAoD,CAAA;IAE1E,OAAO,UAAkC,IAAU;QACjD,IAAI,IAAA,wBAAY,EAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAA;QACpC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QAEtC,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC,CAAA;AACH,CAAC;AAlCD,4BAkCC"}
|