@blackglory/match 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +21 -32
  2. package/lib/index.d.ts +17 -17
  3. package/lib/index.js +17 -37
  4. package/lib/index.js.map +1 -1
  5. package/lib/match-element.d.ts +1 -1
  6. package/lib/match-element.js +7 -11
  7. package/lib/match-element.js.map +1 -1
  8. package/lib/match.d.ts +1 -1
  9. package/lib/match.js +7 -11
  10. package/lib/match.js.map +1 -1
  11. package/lib/matchers/any-of.d.ts +1 -1
  12. package/lib/matchers/any-of.js +1 -5
  13. package/lib/matchers/any-of.js.map +1 -1
  14. package/lib/matchers/child-nodes.d.ts +1 -1
  15. package/lib/matchers/child-nodes.js +8 -11
  16. package/lib/matchers/child-nodes.js.map +1 -1
  17. package/lib/matchers/children.d.ts +1 -1
  18. package/lib/matchers/children.js +8 -11
  19. package/lib/matchers/children.js.map +1 -1
  20. package/lib/matchers/css.d.ts +1 -1
  21. package/lib/matchers/css.js +5 -9
  22. package/lib/matchers/css.js.map +1 -1
  23. package/lib/matchers/element.d.ts +1 -1
  24. package/lib/matchers/element.js +10 -14
  25. package/lib/matchers/element.js.map +1 -1
  26. package/lib/matchers/multiple.d.ts +1 -1
  27. package/lib/matchers/multiple.js +14 -17
  28. package/lib/matchers/multiple.js.map +1 -1
  29. package/lib/matchers/node.d.ts +1 -1
  30. package/lib/matchers/node.js +8 -12
  31. package/lib/matchers/node.js.map +1 -1
  32. package/lib/matchers/optional.d.ts +1 -1
  33. package/lib/matchers/optional.js +3 -7
  34. package/lib/matchers/optional.js.map +1 -1
  35. package/lib/matchers/repeat.d.ts +1 -1
  36. package/lib/matchers/repeat.js +6 -10
  37. package/lib/matchers/repeat.js.map +1 -1
  38. package/lib/matchers/tap.d.ts +1 -1
  39. package/lib/matchers/tap.js +1 -5
  40. package/lib/matchers/tap.js.map +1 -1
  41. package/lib/matchers/text-content-equals.d.ts +1 -1
  42. package/lib/matchers/text-content-equals.js +3 -7
  43. package/lib/matchers/text-content-equals.js.map +1 -1
  44. package/lib/matchers/text-content-includes.d.ts +1 -1
  45. package/lib/matchers/text-content-includes.js +3 -7
  46. package/lib/matchers/text-content-includes.js.map +1 -1
  47. package/lib/matchers/text-content-matches.d.ts +1 -1
  48. package/lib/matchers/text-content-matches.js +3 -7
  49. package/lib/matchers/text-content-matches.js.map +1 -1
  50. package/lib/matchers/text-node.d.ts +1 -1
  51. package/lib/matchers/text-node.js +10 -14
  52. package/lib/matchers/text-node.js.map +1 -1
  53. package/lib/matchers/xpath.d.ts +1 -1
  54. package/lib/matchers/xpath.js +7 -11
  55. package/lib/matchers/xpath.js.map +1 -1
  56. package/lib/types.d.ts +4 -4
  57. package/lib/types.js +1 -2
  58. package/lib/utils/concat.js +1 -5
  59. package/lib/utils/concat.js.map +1 -1
  60. package/lib/utils/match-multiple.d.ts +4 -1
  61. package/lib/utils/match-multiple.js +6 -7
  62. package/lib/utils/match-multiple.js.map +1 -1
  63. package/lib/utils/match-one-by-one.d.ts +1 -1
  64. package/lib/utils/match-one-by-one.js +9 -9
  65. package/lib/utils/match-one-by-one.js.map +1 -1
  66. package/lib/utils/merge-in-place.d.ts +1 -5
  67. package/lib/utils/merge-in-place.js +5 -9
  68. package/lib/utils/merge-in-place.js.map +1 -1
  69. package/lib/utils/next-element-sibling.js +2 -6
  70. package/lib/utils/next-element-sibling.js.map +1 -1
  71. package/lib/utils/next-sibling.js +2 -6
  72. package/lib/utils/next-sibling.js.map +1 -1
  73. package/package.json +30 -29
  74. package/src/index.ts +17 -17
  75. package/src/match-element.ts +3 -3
  76. package/src/match.ts +3 -3
  77. package/src/matchers/any-of.ts +1 -1
  78. package/src/matchers/child-nodes.ts +4 -4
  79. package/src/matchers/children.ts +4 -4
  80. package/src/matchers/css.ts +3 -3
  81. package/src/matchers/element.ts +4 -4
  82. package/src/matchers/multiple.ts +3 -3
  83. package/src/matchers/node.ts +4 -4
  84. package/src/matchers/optional.ts +2 -2
  85. package/src/matchers/repeat.ts +3 -3
  86. package/src/matchers/tap.ts +1 -1
  87. package/src/matchers/text-content-equals.ts +2 -2
  88. package/src/matchers/text-content-includes.ts +2 -2
  89. package/src/matchers/text-content-matches.ts +2 -2
  90. package/src/matchers/text-node.ts +4 -4
  91. package/src/matchers/xpath.ts +4 -4
  92. package/src/utils/match-multiple.ts +1 -1
  93. package/src/utils/match-one-by-one.ts +2 -2
  94. package/src/utils/merge-in-place.ts +3 -3
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeInPlace = void 0;
4
- const types_1 = require("@blackglory/types");
5
- function mergeInPlace(target, source) {
1
+ import { isArray } from '@blackglory/prelude';
2
+ export function mergeInPlace(target, source) {
6
3
  for (const [key, value] of Object.entries(source)) {
7
4
  if (target[key]) {
8
- if ((0, types_1.isArray)(target[key])) {
9
- if ((0, types_1.isArray)(value)) {
5
+ if (isArray(target[key])) {
6
+ if (isArray(value)) {
10
7
  target[key] = [...target[key], ...value];
11
8
  }
12
9
  else {
@@ -14,7 +11,7 @@ function mergeInPlace(target, source) {
14
11
  }
15
12
  }
16
13
  else {
17
- if ((0, types_1.isArray)(value)) {
14
+ if (isArray(value)) {
18
15
  target[key] = [target[key], ...value];
19
16
  }
20
17
  else {
@@ -27,5 +24,4 @@ function mergeInPlace(target, source) {
27
24
  }
28
25
  }
29
26
  }
30
- exports.mergeInPlace = mergeInPlace;
31
27
  //# sourceMappingURL=merge-in-place.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge-in-place.js","sourceRoot":"","sources":["../../src/utils/merge-in-place.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAE3C,SAAgB,YAAY,CAC1B,MAAkC,EAClC,MAAkC;IAElC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACjD,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;YACf,IAAI,IAAA,eAAO,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACxB,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,EAAE;oBAClB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,GAAG,KAAK,CAAC,CAAA;iBAChD;qBAAM;oBACL,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,KAAK,CAAC,CAAA;iBAC7C;aACF;iBAAM;gBACL,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,EAAE;oBAClB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,GAAG,KAAK,CAAC,CAAA;iBAC3C;qBAAM;oBACL,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,KAAK,CAAC,CAAA;iBACxC;aACF;SACF;aAAM;YACL,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACpB;KACF;AACH,CAAC;AAvBD,oCAuBC"}
1
+ {"version":3,"file":"merge-in-place.js","sourceRoot":"","sources":["../../src/utils/merge-in-place.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,MAAM,UAAU,YAAY,CAC1B,MAA+B,EAC/B,MAA+B;IAE/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAChB,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACzB,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,GAAG,KAAK,CAAC,CAAA;gBACjD,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,KAAK,CAAC,CAAA;gBAC9C,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,GAAG,KAAK,CAAC,CAAA;gBAC5C,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,KAAK,CAAC,CAAA;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACrB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nextElementSibling = void 0;
4
- const ExtraDOM = require("extra-dom");
5
- function nextElementSibling(node, distance = 1) {
1
+ import * as ExtraDOM from 'extra-dom';
2
+ export function nextElementSibling(node, distance = 1) {
6
3
  if (distance === 0)
7
4
  return node;
8
5
  return ExtraDOM.nextElementSibling(node, distance);
9
6
  }
10
- exports.nextElementSibling = nextElementSibling;
11
7
  //# sourceMappingURL=next-element-sibling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"next-element-sibling.js","sourceRoot":"","sources":["../../src/utils/next-element-sibling.ts"],"names":[],"mappings":";;;AAAA,sCAAqC;AAErC,SAAgB,kBAAkB,CAChC,IAAU,EACV,WAAmB,CAAC;IAEpB,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAE/B,OAAO,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACpD,CAAC;AAPD,gDAOC"}
1
+ {"version":3,"file":"next-element-sibling.js","sourceRoot":"","sources":["../../src/utils/next-element-sibling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AAErC,MAAM,UAAU,kBAAkB,CAChC,IAAU,EACV,WAAmB,CAAC;IAEpB,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAE/B,OAAO,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACpD,CAAC"}
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nextSibling = void 0;
4
- const ExtraDOM = require("extra-dom");
5
- function nextSibling(node, distance = 1) {
1
+ import * as ExtraDOM from 'extra-dom';
2
+ export function nextSibling(node, distance = 1) {
6
3
  if (distance === 0)
7
4
  return node;
8
5
  return ExtraDOM.nextSibling(node, distance);
9
6
  }
10
- exports.nextSibling = nextSibling;
11
7
  //# sourceMappingURL=next-sibling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"next-sibling.js","sourceRoot":"","sources":["../../src/utils/next-sibling.ts"],"names":[],"mappings":";;;AAAA,sCAAqC;AAErC,SAAgB,WAAW,CAAC,IAAU,EAAE,WAAmB,CAAC;IAC1D,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAE/B,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7C,CAAC;AAJD,kCAIC"}
1
+ {"version":3,"file":"next-sibling.js","sourceRoot":"","sources":["../../src/utils/next-sibling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AAErC,MAAM,UAAU,WAAW,CAAC,IAAU,EAAE,WAAmB,CAAC;IAC1D,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAE/B,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackglory/match",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "description": "A module for matching nodes from pages",
5
5
  "keywords": [
6
6
  "query",
@@ -11,53 +11,54 @@
11
11
  "lib",
12
12
  "src"
13
13
  ],
14
+ "type": "module",
14
15
  "main": "lib/index.js",
15
16
  "types": "lib/index.d.ts",
17
+ "sideEffects": false,
18
+ "engines": {
19
+ "node": ">=22"
20
+ },
16
21
  "repository": "git@github.com:BlackGlory/match.git",
17
22
  "author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
18
23
  "license": "MIT",
19
- "sideEffects": false,
20
24
  "scripts": {
25
+ "prepare": "ts-patch install -s",
21
26
  "lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
22
- "test": "jest --config jest.config.js",
23
- "test:coverage": "jest --coverage --config jest.config.js",
24
- "prepublishOnly": "run-s clean build",
27
+ "test": "vitest --run",
28
+ "prepublishOnly": "run-s prepare clean build",
25
29
  "clean": "rimraf lib",
26
- "build": "run-s build:*",
27
- "build:compile": "tsc --project tsconfig.build.json --module commonjs --target es2018 --outDir lib",
28
- "build:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib",
30
+ "build": "tsc --project tsconfig.build.json",
29
31
  "release": "standard-version"
30
32
  },
31
33
  "husky": {
32
34
  "hooks": {
33
- "pre-commit": "run-s lint build test",
35
+ "pre-commit": "run-s prepare lint build test",
34
36
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
35
37
  }
36
38
  },
37
39
  "devDependencies": {
38
- "@commitlint/cli": "^15.0.0",
39
- "@commitlint/config-conventional": "^15.0.0",
40
- "@types/jest": "^27.0.3",
41
- "@types/jsdom": "^16.2.13",
42
- "@typescript-eslint/eslint-plugin": "^5.6.0",
43
- "@typescript-eslint/parser": "^5.6.0",
44
- "eslint": "^8.4.1",
40
+ "@commitlint/cli": "^20.3.1",
41
+ "@commitlint/config-conventional": "^20.3.1",
42
+ "@eslint/js": "^9.39.2",
43
+ "@types/jsdom": "^27.0.0",
44
+ "eslint": "^9.39.2",
45
45
  "husky": "^4.3.8",
46
- "iterable-operator": "^0.14.4",
47
- "jest": "^27.4.4",
48
- "jsdom": "^19.0.0",
46
+ "iterable-operator": "^5.1.0",
47
+ "jsdom": "^27.4.0",
49
48
  "npm-run-all": "^4.1.5",
50
- "rimraf": "^3.0.2",
51
- "standard-version": "^9.3.2",
52
- "ts-jest": "^27.1.1",
53
- "tscpaths": "^0.0.9",
54
- "tslib": "^2.3.1",
55
- "typescript": "^4.5.3"
49
+ "rimraf": "^6.1.2",
50
+ "standard-version": "^9.5.0",
51
+ "ts-patch": "^3.3.0",
52
+ "tslib": "^2.8.1",
53
+ "typescript": "^5.9.3",
54
+ "typescript-eslint": "^8.53.0",
55
+ "typescript-transform-paths": "^3.5.6",
56
+ "vite-tsconfig-paths": "^6.0.4",
57
+ "vitest": "^4.0.17"
56
58
  },
57
59
  "dependencies": {
58
- "@blackglory/errors": "^1.1.2",
59
- "@blackglory/types": "^0.5.2",
60
- "extra-dom": "^0.4.4",
61
- "extra-generator": "^0.2.15"
60
+ "@blackglory/prelude": "^0.4.0",
61
+ "extra-dom": "^0.7.0",
62
+ "extra-generator": "^0.5.9"
62
63
  }
63
64
  }
package/src/index.ts CHANGED
@@ -1,18 +1,18 @@
1
- export { match } from './match'
2
- export { matchElement } from './match-element'
1
+ export { match } from './match.js'
2
+ export { matchElement } from './match-element.js'
3
3
 
4
- export { anyOf } from '@matchers/any-of'
5
- export { childNodes } from '@matchers/child-nodes'
6
- export { children } from '@matchers/children'
7
- export { css } from '@matchers/css'
8
- export { element } from '@matchers/element'
9
- export { multiple } from '@matchers/multiple'
10
- export { node } from '@matchers/node'
11
- export { optional } from '@matchers/optional'
12
- export { repeat } from '@matchers/repeat'
13
- export { tap } from '@matchers/tap'
14
- export { textContentEquals } from '@matchers/text-content-equals'
15
- export { textContentIncludes } from '@matchers/text-content-includes'
16
- export { textContentMatches } from '@matchers/text-content-matches'
17
- export { textNode } from '@matchers/text-node'
18
- export { xpath } from '@matchers/xpath'
4
+ export { anyOf } from '@matchers/any-of.js'
5
+ export { childNodes } from '@matchers/child-nodes.js'
6
+ export { children } from '@matchers/children.js'
7
+ export { css } from '@matchers/css.js'
8
+ export { element } from '@matchers/element.js'
9
+ export { multiple } from '@matchers/multiple.js'
10
+ export { node } from '@matchers/node.js'
11
+ export { optional } from '@matchers/optional.js'
12
+ export { repeat } from '@matchers/repeat.js'
13
+ export { tap } from '@matchers/tap.js'
14
+ export { textContentEquals } from '@matchers/text-content-equals.js'
15
+ export { textContentIncludes } from '@matchers/text-content-includes.js'
16
+ export { textContentMatches } from '@matchers/text-content-matches.js'
17
+ export { textNode } from '@matchers/text-node.js'
18
+ export { xpath } from '@matchers/xpath.js'
@@ -1,7 +1,7 @@
1
1
  import { isDocument } from 'extra-dom'
2
- import { IMatcher, IContext } from './types'
3
- import { matchOneByOne } from '@utils/match-one-by-one'
4
- import { nextElementSibling } from '@utils/next-element-sibling'
2
+ import { IMatcher, IContext } from './types.js'
3
+ import { matchOneByOne } from '@utils/match-one-by-one.js'
4
+ import { nextElementSibling } from '@utils/next-element-sibling.js'
5
5
 
6
6
  export function matchElement(
7
7
  this: void | Document
package/src/match.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isDocument } from 'extra-dom'
2
- import { IMatcher, IContext } from './types'
3
- import { matchOneByOne } from '@utils/match-one-by-one'
4
- import { nextSibling } from '@utils/next-sibling'
2
+ import { IMatcher, IContext } from './types.js'
3
+ import { matchOneByOne } from '@utils/match-one-by-one.js'
4
+ import { nextSibling } from '@utils/next-sibling.js'
5
5
 
6
6
  export function match(
7
7
  this: void | Document
@@ -1,4 +1,4 @@
1
- import { ITerminalMatcher, INestedMatcher, IReadonlyContext } from '@src/types'
1
+ import { ITerminalMatcher, INestedMatcher, IReadonlyContext } from '@src/types.js'
2
2
 
3
3
  export function anyOf<T extends Node>(
4
4
  ...matchers: [
@@ -1,7 +1,7 @@
1
- import { INestedMatcher, IMatcher, IReadonlyContext } from '@src/types'
2
- import { matchOneByOne } from '@utils/match-one-by-one'
3
- import { mergeInPlace } from '@utils/merge-in-place'
4
- import { nextSibling } from '@utils/next-sibling'
1
+ import { INestedMatcher, IMatcher, IReadonlyContext } from '@src/types.js'
2
+ import { matchOneByOne } from '@utils/match-one-by-one.js'
3
+ import { mergeInPlace } from '@utils/merge-in-place.js'
4
+ import { nextSibling } from '@utils/next-sibling.js'
5
5
 
6
6
  export function childNodes(...matchers: Array<IMatcher<Node>>): INestedMatcher<Node> {
7
7
  return function (this: IReadonlyContext, node: Node) {
@@ -1,7 +1,7 @@
1
- import { IMatcher, INestedMatcher, IReadonlyContext } from '@src/types'
2
- import { matchOneByOne } from '@utils/match-one-by-one'
3
- import { mergeInPlace } from '@utils/merge-in-place'
4
- import { nextElementSibling } from '@utils/next-element-sibling'
1
+ import { IMatcher, INestedMatcher, IReadonlyContext } from '@src/types.js'
2
+ import { matchOneByOne } from '@utils/match-one-by-one.js'
3
+ import { mergeInPlace } from '@utils/merge-in-place.js'
4
+ import { nextElementSibling } from '@utils/next-element-sibling.js'
5
5
 
6
6
  export function children(
7
7
  ...matchers: Array<IMatcher<Element>>
@@ -1,6 +1,6 @@
1
- import { concat } from '@utils/concat'
2
- import { ITerminalMatcher } from '@src/types'
3
- import { isString } from '@blackglory/types'
1
+ import { concat } from '@utils/concat.js'
2
+ import { ITerminalMatcher } from '@src/types.js'
3
+ import { isString } from '@blackglory/prelude'
4
4
 
5
5
  export function css(
6
6
  strings: TemplateStringsArray
@@ -1,8 +1,8 @@
1
1
  import { isntElement } from 'extra-dom'
2
- import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
3
- import { isArray, isString } from '@blackglory/types'
4
- import { concat } from '@utils/concat'
5
- import { mergeInPlace } from '@utils/merge-in-place'
2
+ import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
3
+ import { isArray, isString } from '@blackglory/prelude'
4
+ import { concat } from '@utils/concat.js'
5
+ import { mergeInPlace } from '@utils/merge-in-place.js'
6
6
 
7
7
  export function element(
8
8
  strings: TemplateStringsArray
@@ -1,7 +1,7 @@
1
- import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types'
1
+ import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types.js'
2
2
  import { countup } from 'extra-generator'
3
- import { assert } from '@blackglory/errors'
4
- import { matchMultiple } from '@utils/match-multiple'
3
+ import { assert } from '@blackglory/prelude'
4
+ import { matchMultiple } from '@utils/match-multiple.js'
5
5
 
6
6
  export enum Range {
7
7
  Min = 0
@@ -1,7 +1,7 @@
1
- import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
2
- import { isArray, isString } from '@blackglory/types'
3
- import { concat } from '@utils/concat'
4
- import { mergeInPlace } from '@utils/merge-in-place'
1
+ import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
2
+ import { isArray, isString } from '@blackglory/prelude'
3
+ import { concat } from '@utils/concat.js'
4
+ import { mergeInPlace } from '@utils/merge-in-place.js'
5
5
 
6
6
  export function node(
7
7
  strings: TemplateStringsArray
@@ -1,5 +1,5 @@
1
- import { INestedMatcher, ITerminalMatcher, ISkipMatcher } from '@src/types'
2
- import { multiple } from './multiple'
1
+ import { INestedMatcher, ITerminalMatcher, ISkipMatcher } from '@src/types.js'
2
+ import { multiple } from './multiple.js'
3
3
 
4
4
  export function optional<T extends Node>(matcher: INestedMatcher<T> | ITerminalMatcher<T>): ISkipMatcher<T> {
5
5
  return multiple([0, 1], matcher, { greedy: true })
@@ -1,6 +1,6 @@
1
- import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types'
2
- import { assert } from '@blackglory/errors'
3
- import { matchMultiple } from '@utils/match-multiple'
1
+ import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types.js'
2
+ import { assert } from '@blackglory/prelude'
3
+ import { matchMultiple } from '@utils/match-multiple.js'
4
4
 
5
5
  export function repeat<T extends Node>(
6
6
  times: number
@@ -1,4 +1,4 @@
1
- import { IReadonlyContext, IMatcher } from '@src/types'
1
+ import { IReadonlyContext, IMatcher } from '@src/types.js'
2
2
 
3
3
  export function tap<T extends Node, U extends ReturnType<IMatcher<any>>>(
4
4
  matcher: (this: IReadonlyContext, node: T) => U
@@ -1,5 +1,5 @@
1
- import { ITerminalMatcher } from '@src/types'
2
- import { isNull } from '@blackglory/types'
1
+ import { ITerminalMatcher } from '@src/types.js'
2
+ import { isNull } from '@blackglory/prelude'
3
3
 
4
4
  interface ITextContentEqualsOptions {
5
5
  caseSensitive?: boolean
@@ -1,5 +1,5 @@
1
- import { ITerminalMatcher } from '@src/types'
2
- import { isNull } from '@blackglory/types'
1
+ import { ITerminalMatcher } from '@src/types.js'
2
+ import { isNull } from '@blackglory/prelude'
3
3
 
4
4
  interface ITextContentIncludesOptions {
5
5
  caseSensitive?: boolean
@@ -1,5 +1,5 @@
1
- import { ITerminalMatcher } from '@src/types'
2
- import { isNull } from '@blackglory/types'
1
+ import { ITerminalMatcher } from '@src/types.js'
2
+ import { isNull } from '@blackglory/prelude'
3
3
 
4
4
  interface ITextContentMatchesOptions {
5
5
  trim?: boolean
@@ -1,8 +1,8 @@
1
- import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
2
- import { isArray, isString } from '@blackglory/types'
3
- import { concat } from '@utils/concat'
1
+ import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
2
+ import { isArray, isString } from '@blackglory/prelude'
3
+ import { concat } from '@utils/concat.js'
4
4
  import { isntTextNode } from 'extra-dom'
5
- import { mergeInPlace } from '@utils/merge-in-place'
5
+ import { mergeInPlace } from '@utils/merge-in-place.js'
6
6
 
7
7
  export function textNode(
8
8
  strings: TemplateStringsArray
@@ -1,7 +1,7 @@
1
- import { ITerminalMatcher, IReadonlyContext } from '@src/types'
2
- import { isString } from '@blackglory/types'
3
- import { concat } from '@utils/concat'
4
- import { assert } from '@blackglory/errors'
1
+ import { ITerminalMatcher, IReadonlyContext } from '@src/types.js'
2
+ import { isString } from '@blackglory/prelude'
3
+ import { concat } from '@utils/concat.js'
4
+ import { assert } from '@blackglory/prelude'
5
5
 
6
6
  const UNORDERED_NODE_ITERATOR_TYPE =
7
7
  'XPathResult' in globalThis
@@ -1,5 +1,5 @@
1
1
  import { countup } from 'extra-generator'
2
- import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
2
+ import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
3
3
 
4
4
  /**
5
5
  * @returns {number} 返回值为成功匹配的元素个数, 当此值等于ubound时, 代表匹配成功.
@@ -1,5 +1,5 @@
1
- import { IMatcher, IReadonlyContext } from '@src/types'
2
- import { isBoolean, isNumber, isIterable } from '@blackglory/types'
1
+ import { IMatcher, IReadonlyContext } from '@src/types.js'
2
+ import { isBoolean, isNumber, isIterable } from '@blackglory/prelude'
3
3
 
4
4
  export function matchOneByOne<T extends Node>(
5
5
  context: IReadonlyContext
@@ -1,8 +1,8 @@
1
- import { isArray } from '@blackglory/types'
1
+ import { isArray } from '@blackglory/prelude'
2
2
 
3
3
  export function mergeInPlace<T>(
4
- target: { [key: string]: T | T[] }
5
- , source: { [key: string]: T | T[] }
4
+ target: Record<string, T | T[]>
5
+ , source: Record<string, T | T[]>
6
6
  ): void {
7
7
  for (const [key, value] of Object.entries(source)) {
8
8
  if (target[key]) {