@vltpkg/query 0.0.0-5 → 0.0.0-7

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 (136) hide show
  1. package/README.md +107 -1
  2. package/dist/esm/index.d.ts +12 -1
  3. package/dist/esm/index.d.ts.map +1 -1
  4. package/dist/esm/index.js +54 -1
  5. package/dist/esm/index.js.map +1 -1
  6. package/dist/esm/pseudo/abandoned.d.ts +5 -0
  7. package/dist/esm/pseudo/abandoned.d.ts.map +1 -0
  8. package/dist/esm/pseudo/abandoned.js +6 -0
  9. package/dist/esm/pseudo/abandoned.js.map +1 -0
  10. package/dist/esm/pseudo/confused.d.ts +5 -0
  11. package/dist/esm/pseudo/confused.d.ts.map +1 -0
  12. package/dist/esm/pseudo/confused.js +6 -0
  13. package/dist/esm/pseudo/confused.js.map +1 -0
  14. package/dist/esm/pseudo/cve.d.ts +10 -0
  15. package/dist/esm/pseudo/cve.d.ts.map +1 -0
  16. package/dist/esm/pseudo/cve.js +47 -0
  17. package/dist/esm/pseudo/cve.js.map +1 -0
  18. package/dist/esm/pseudo/cwe.d.ts +10 -0
  19. package/dist/esm/pseudo/cwe.d.ts.map +1 -0
  20. package/dist/esm/pseudo/cwe.js +46 -0
  21. package/dist/esm/pseudo/cwe.js.map +1 -0
  22. package/dist/esm/pseudo/debug.d.ts +5 -0
  23. package/dist/esm/pseudo/debug.d.ts.map +1 -0
  24. package/dist/esm/pseudo/debug.js +6 -0
  25. package/dist/esm/pseudo/debug.js.map +1 -0
  26. package/dist/esm/pseudo/deprecated.d.ts +5 -0
  27. package/dist/esm/pseudo/deprecated.d.ts.map +1 -0
  28. package/dist/esm/pseudo/deprecated.js +6 -0
  29. package/dist/esm/pseudo/deprecated.js.map +1 -0
  30. package/dist/esm/pseudo/dynamic.d.ts +5 -0
  31. package/dist/esm/pseudo/dynamic.d.ts.map +1 -0
  32. package/dist/esm/pseudo/dynamic.js +6 -0
  33. package/dist/esm/pseudo/dynamic.js.map +1 -0
  34. package/dist/esm/pseudo/entropic.d.ts +5 -0
  35. package/dist/esm/pseudo/entropic.d.ts.map +1 -0
  36. package/dist/esm/pseudo/entropic.js +6 -0
  37. package/dist/esm/pseudo/entropic.js.map +1 -0
  38. package/dist/esm/pseudo/env.d.ts +5 -0
  39. package/dist/esm/pseudo/env.d.ts.map +1 -0
  40. package/dist/esm/pseudo/env.js +6 -0
  41. package/dist/esm/pseudo/env.js.map +1 -0
  42. package/dist/esm/pseudo/eval.d.ts +5 -0
  43. package/dist/esm/pseudo/eval.d.ts.map +1 -0
  44. package/dist/esm/pseudo/eval.js +6 -0
  45. package/dist/esm/pseudo/eval.js.map +1 -0
  46. package/dist/esm/pseudo/fs.d.ts +5 -0
  47. package/dist/esm/pseudo/fs.d.ts.map +1 -0
  48. package/dist/esm/pseudo/fs.js +6 -0
  49. package/dist/esm/pseudo/fs.js.map +1 -0
  50. package/dist/esm/pseudo/helpers.d.ts +4 -0
  51. package/dist/esm/pseudo/helpers.d.ts.map +1 -1
  52. package/dist/esm/pseudo/helpers.js +19 -0
  53. package/dist/esm/pseudo/helpers.js.map +1 -1
  54. package/dist/esm/pseudo/license.d.ts +10 -0
  55. package/dist/esm/pseudo/license.d.ts.map +1 -0
  56. package/dist/esm/pseudo/license.js +61 -0
  57. package/dist/esm/pseudo/license.js.map +1 -0
  58. package/dist/esm/pseudo/malware.d.ts +10 -0
  59. package/dist/esm/pseudo/malware.d.ts.map +1 -0
  60. package/dist/esm/pseudo/malware.js +60 -0
  61. package/dist/esm/pseudo/malware.js.map +1 -0
  62. package/dist/esm/pseudo/minified.d.ts +5 -0
  63. package/dist/esm/pseudo/minified.d.ts.map +1 -0
  64. package/dist/esm/pseudo/minified.js +6 -0
  65. package/dist/esm/pseudo/minified.js.map +1 -0
  66. package/dist/esm/pseudo/native.d.ts +5 -0
  67. package/dist/esm/pseudo/native.d.ts.map +1 -0
  68. package/dist/esm/pseudo/native.js +6 -0
  69. package/dist/esm/pseudo/native.js.map +1 -0
  70. package/dist/esm/pseudo/network.d.ts +5 -0
  71. package/dist/esm/pseudo/network.d.ts.map +1 -0
  72. package/dist/esm/pseudo/network.js +6 -0
  73. package/dist/esm/pseudo/network.js.map +1 -0
  74. package/dist/esm/pseudo/obfuscated.d.ts +5 -0
  75. package/dist/esm/pseudo/obfuscated.d.ts.map +1 -0
  76. package/dist/esm/pseudo/obfuscated.js +6 -0
  77. package/dist/esm/pseudo/obfuscated.js.map +1 -0
  78. package/dist/esm/pseudo/scripts.d.ts +5 -0
  79. package/dist/esm/pseudo/scripts.d.ts.map +1 -0
  80. package/dist/esm/pseudo/scripts.js +6 -0
  81. package/dist/esm/pseudo/scripts.js.map +1 -0
  82. package/dist/esm/pseudo/severity.d.ts +10 -0
  83. package/dist/esm/pseudo/severity.d.ts.map +1 -0
  84. package/dist/esm/pseudo/severity.js +60 -0
  85. package/dist/esm/pseudo/severity.js.map +1 -0
  86. package/dist/esm/pseudo/shell.d.ts +5 -0
  87. package/dist/esm/pseudo/shell.d.ts.map +1 -0
  88. package/dist/esm/pseudo/shell.js +6 -0
  89. package/dist/esm/pseudo/shell.js.map +1 -0
  90. package/dist/esm/pseudo/shrinkwrap.d.ts +5 -0
  91. package/dist/esm/pseudo/shrinkwrap.d.ts.map +1 -0
  92. package/dist/esm/pseudo/shrinkwrap.js +6 -0
  93. package/dist/esm/pseudo/shrinkwrap.js.map +1 -0
  94. package/dist/esm/pseudo/squat.d.ts +10 -0
  95. package/dist/esm/pseudo/squat.d.ts.map +1 -0
  96. package/dist/esm/pseudo/squat.js +57 -0
  97. package/dist/esm/pseudo/squat.js.map +1 -0
  98. package/dist/esm/pseudo/suspicious.d.ts +5 -0
  99. package/dist/esm/pseudo/suspicious.d.ts.map +1 -0
  100. package/dist/esm/pseudo/suspicious.js +6 -0
  101. package/dist/esm/pseudo/suspicious.js.map +1 -0
  102. package/dist/esm/pseudo/tracker.d.ts +5 -0
  103. package/dist/esm/pseudo/tracker.d.ts.map +1 -0
  104. package/dist/esm/pseudo/tracker.js +6 -0
  105. package/dist/esm/pseudo/tracker.js.map +1 -0
  106. package/dist/esm/pseudo/trivial.d.ts +5 -0
  107. package/dist/esm/pseudo/trivial.d.ts.map +1 -0
  108. package/dist/esm/pseudo/trivial.js +6 -0
  109. package/dist/esm/pseudo/trivial.js.map +1 -0
  110. package/dist/esm/pseudo/undesirable.d.ts +5 -0
  111. package/dist/esm/pseudo/undesirable.d.ts.map +1 -0
  112. package/dist/esm/pseudo/undesirable.js +6 -0
  113. package/dist/esm/pseudo/undesirable.js.map +1 -0
  114. package/dist/esm/pseudo/unknown.d.ts +5 -0
  115. package/dist/esm/pseudo/unknown.d.ts.map +1 -0
  116. package/dist/esm/pseudo/unknown.js +6 -0
  117. package/dist/esm/pseudo/unknown.js.map +1 -0
  118. package/dist/esm/pseudo/unmaintained.d.ts +5 -0
  119. package/dist/esm/pseudo/unmaintained.d.ts.map +1 -0
  120. package/dist/esm/pseudo/unmaintained.js +6 -0
  121. package/dist/esm/pseudo/unmaintained.js.map +1 -0
  122. package/dist/esm/pseudo/unpopular.d.ts +5 -0
  123. package/dist/esm/pseudo/unpopular.d.ts.map +1 -0
  124. package/dist/esm/pseudo/unpopular.js +6 -0
  125. package/dist/esm/pseudo/unpopular.js.map +1 -0
  126. package/dist/esm/pseudo/unstable.d.ts +5 -0
  127. package/dist/esm/pseudo/unstable.d.ts.map +1 -0
  128. package/dist/esm/pseudo/unstable.js +6 -0
  129. package/dist/esm/pseudo/unstable.js.map +1 -0
  130. package/dist/esm/pseudo.d.ts.map +1 -1
  131. package/dist/esm/pseudo.js +69 -4
  132. package/dist/esm/pseudo.js.map +1 -1
  133. package/dist/esm/types.d.ts +2 -0
  134. package/dist/esm/types.d.ts.map +1 -1
  135. package/dist/esm/types.js.map +1 -1
  136. package/package.json +8 -7
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **suspiciousStarActivity** report alert.
4
+ */
5
+ export const suspicious = createSecuritySelectorFilter('suspicious', 'suspiciousStarActivity');
6
+ //# sourceMappingURL=suspicious.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suspicious.js","sourceRoot":"","sources":["../../../src/pseudo/suspicious.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,4BAA4B,CACpD,YAAY,EACZ,wBAAwB,CACzB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **suspiciousStarActivity** report alert.\n */\nexport const suspicious = createSecuritySelectorFilter(\n 'suspicious',\n 'suspiciousStarActivity',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **telemetry** report alert.
3
+ */
4
+ export declare const tracker: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=tracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../../src/pseudo/tracker.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,0FAGnB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **telemetry** report alert.
4
+ */
5
+ export const tracker = createSecuritySelectorFilter('tracker', 'telemetry');
6
+ //# sourceMappingURL=tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../../src/pseudo/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CACjD,SAAS,EACT,WAAW,CACZ,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **telemetry** report alert.\n */\nexport const tracker = createSecuritySelectorFilter(\n 'tracker',\n 'telemetry',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **trivialPackage** report alert.
3
+ */
4
+ export declare const trivial: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=trivial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trivial.d.ts","sourceRoot":"","sources":["../../../src/pseudo/trivial.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,0FAGnB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **trivialPackage** report alert.
4
+ */
5
+ export const trivial = createSecuritySelectorFilter('trivial', 'trivialPackage');
6
+ //# sourceMappingURL=trivial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trivial.js","sourceRoot":"","sources":["../../../src/pseudo/trivial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CACjD,SAAS,EACT,gBAAgB,CACjB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **trivialPackage** report alert.\n */\nexport const trivial = createSecuritySelectorFilter(\n 'trivial',\n 'trivialPackage',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **troll** report alert.
3
+ */
4
+ export declare const undesirable: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=undesirable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undesirable.d.ts","sourceRoot":"","sources":["../../../src/pseudo/undesirable.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,WAAW,0FAGvB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **troll** report alert.
4
+ */
5
+ export const undesirable = createSecuritySelectorFilter('undesirable', 'troll');
6
+ //# sourceMappingURL=undesirable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undesirable.js","sourceRoot":"","sources":["../../../src/pseudo/undesirable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CACrD,aAAa,EACb,OAAO,CACR,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **troll** report alert.\n */\nexport const undesirable = createSecuritySelectorFilter(\n 'undesirable',\n 'troll',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **newAuthor** report alert.
3
+ */
4
+ export declare const unknown: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=unknown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown.d.ts","sourceRoot":"","sources":["../../../src/pseudo/unknown.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,0FAGnB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **newAuthor** report alert.
4
+ */
5
+ export const unknown = createSecuritySelectorFilter('unknown', 'newAuthor');
6
+ //# sourceMappingURL=unknown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../src/pseudo/unknown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CACjD,SAAS,EACT,WAAW,CACZ,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **newAuthor** report alert.\n */\nexport const unknown = createSecuritySelectorFilter(\n 'unknown',\n 'newAuthor',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **unmaintained** report alert.
3
+ */
4
+ export declare const unmaintained: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=unmaintained.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unmaintained.d.ts","sourceRoot":"","sources":["../../../src/pseudo/unmaintained.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,YAAY,0FAGxB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **unmaintained** report alert.
4
+ */
5
+ export const unmaintained = createSecuritySelectorFilter('unmaintained', 'unmaintained');
6
+ //# sourceMappingURL=unmaintained.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unmaintained.js","sourceRoot":"","sources":["../../../src/pseudo/unmaintained.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,4BAA4B,CACtD,cAAc,EACd,cAAc,CACf,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **unmaintained** report alert.\n */\nexport const unmaintained = createSecuritySelectorFilter(\n 'unmaintained',\n 'unmaintained',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **unpopularPackage** report alert.
3
+ */
4
+ export declare const unpopular: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=unpopular.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unpopular.d.ts","sourceRoot":"","sources":["../../../src/pseudo/unpopular.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS,0FAGrB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **unpopularPackage** report alert.
4
+ */
5
+ export const unpopular = createSecuritySelectorFilter('unpopular', 'unpopularPackage');
6
+ //# sourceMappingURL=unpopular.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unpopular.js","sourceRoot":"","sources":["../../../src/pseudo/unpopular.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,4BAA4B,CACnD,WAAW,EACX,kBAAkB,CACnB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **unpopularPackage** report alert.\n */\nexport const unpopular = createSecuritySelectorFilter(\n 'unpopular',\n 'unpopularPackage',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **unstableOwnership** report alert.
3
+ */
4
+ export declare const unstable: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=unstable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unstable.d.ts","sourceRoot":"","sources":["../../../src/pseudo/unstable.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ,0FAGpB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **unstableOwnership** report alert.
4
+ */
5
+ export const unstable = createSecuritySelectorFilter('unstable', 'unstableOwnership');
6
+ //# sourceMappingURL=unstable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unstable.js","sourceRoot":"","sources":["../../../src/pseudo/unstable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,4BAA4B,CAClD,UAAU,EACV,mBAAmB,CACpB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **unstableOwnership** report alert.\n */\nexport const unstable = createSecuritySelectorFilter(\n 'unstable',\n 'unstableOwnership',\n)\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,YAAY,CAAA;AA6TvD;;GAEG;AACH,eAAO,MAAM,MAAM,UAAiB,WAAW,yBAiB9C,CAAA"}
1
+ {"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,YAAY,CAAA;AAkYvD;;GAEG;AACH,eAAO,MAAM,MAAM,UAAiB,WAAW,yBAiB9C,CAAA"}
@@ -1,11 +1,42 @@
1
1
  import { splitDepID } from '@vltpkg/dep-id/browser';
2
2
  import { error } from '@vltpkg/error-cause';
3
3
  import { asManifest } from '@vltpkg/types';
4
+ import { removeDanglingEdges, removeNode } from "./pseudo/helpers.js";
5
+ import { asPostcssNodeWithChildren, asPseudoNode, asTagNode, isSelectorNode, } from "./types.js";
6
+ // imported pseudo selectors
7
+ import { abandoned } from "./pseudo/abandoned.js";
4
8
  import { attr } from "./pseudo/attr.js";
9
+ import { confused } from "./pseudo/confused.js";
10
+ import { cve } from "./pseudo/cve.js";
11
+ import { cwe } from "./pseudo/cwe.js";
12
+ import { debug } from "./pseudo/debug.js";
13
+ import { deprecated } from "./pseudo/deprecated.js";
14
+ import { dynamic } from "./pseudo/dynamic.js";
15
+ import { entropic } from "./pseudo/entropic.js";
16
+ import { env } from "./pseudo/env.js";
17
+ import { evalParser } from "./pseudo/eval.js";
18
+ import { fs } from "./pseudo/fs.js";
19
+ import { license } from "./pseudo/license.js";
20
+ import { malware } from "./pseudo/malware.js";
21
+ import { minified } from "./pseudo/minified.js";
22
+ import { nativeParser } from "./pseudo/native.js";
23
+ import { network } from "./pseudo/network.js";
24
+ import { obfuscated } from "./pseudo/obfuscated.js";
5
25
  import { outdated } from "./pseudo/outdated.js";
26
+ import { scripts } from "./pseudo/scripts.js";
27
+ import { shell } from "./pseudo/shell.js";
6
28
  import { semverParser as semver } from "./pseudo/semver.js";
7
- import { removeDanglingEdges, removeNode } from "./pseudo/helpers.js";
8
- import { asPostcssNodeWithChildren, asPseudoNode, asTagNode, isSelectorNode, } from "./types.js";
29
+ import { severity } from "./pseudo/severity.js";
30
+ import { shrinkwrap } from "./pseudo/shrinkwrap.js";
31
+ import { squat } from "./pseudo/squat.js";
32
+ import { suspicious } from "./pseudo/suspicious.js";
33
+ import { tracker } from "./pseudo/tracker.js";
34
+ import { trivial } from "./pseudo/trivial.js";
35
+ import { undesirable } from "./pseudo/undesirable.js";
36
+ import { unknown } from "./pseudo/unknown.js";
37
+ import { unmaintained } from "./pseudo/unmaintained.js";
38
+ import { unpopular } from "./pseudo/unpopular.js";
39
+ import { unstable } from "./pseudo/unstable.js";
9
40
  /**
10
41
  * :empty Pseudo-Selector, matches only nodes that have no children.
11
42
  */
@@ -43,6 +74,7 @@ const has = async (state) => {
43
74
  edges: new Set(state.partial.edges),
44
75
  nodes: new Set(state.partial.nodes),
45
76
  },
77
+ securityArchive: state.securityArchive,
46
78
  specOptions: state.specOptions,
47
79
  });
48
80
  for (const n of nestedState.collect.nodes) {
@@ -117,6 +149,7 @@ const is = async (state) => {
117
149
  edges: new Set(state.partial.edges),
118
150
  },
119
151
  walk: state.walk,
152
+ securityArchive: state.securityArchive,
120
153
  specOptions: state.specOptions,
121
154
  });
122
155
  for (const n of nestedState.collect.nodes) {
@@ -167,6 +200,7 @@ const not = async (state) => {
167
200
  edges: new Set(state.partial.edges),
168
201
  },
169
202
  walk: state.walk,
203
+ securityArchive: state.securityArchive,
170
204
  specOptions: state.specOptions,
171
205
  });
172
206
  for (const n of nestedState.collect.nodes) {
@@ -282,21 +316,52 @@ const typeFn = async (state) => {
282
316
  return state;
283
317
  };
284
318
  const pseudoSelectors = new Map(Object.entries({
319
+ abandoned,
285
320
  attr,
321
+ confused,
322
+ cve,
323
+ cwe,
324
+ debug,
325
+ deprecated,
326
+ dynamic,
327
+ eval: evalParser,
286
328
  empty,
329
+ entropic,
330
+ env,
331
+ fs,
287
332
  has,
288
333
  is,
289
334
  // TODO: link
335
+ license,
336
+ malware,
337
+ minified,
290
338
  missing,
339
+ native: nativeParser,
340
+ network,
291
341
  not,
342
+ obfuscated,
343
+ outdated,
292
344
  // TODO: overridden
293
345
  private: privateFn,
294
346
  project,
295
347
  root,
296
348
  scope,
297
- type: typeFn,
349
+ scripts,
298
350
  semver,
299
- outdated,
351
+ sev: severity,
352
+ severity,
353
+ shell,
354
+ shrinkwrap,
355
+ squat,
356
+ suspicious,
357
+ tracker,
358
+ trivial,
359
+ type: typeFn,
360
+ undesirable,
361
+ unknown,
362
+ unmaintained,
363
+ unpopular,
364
+ unstable,
300
365
  }));
301
366
  /**
302
367
  * Parsers the `pseudo` node types.
@@ -1 +1 @@
1
- {"version":3,"file":"pseudo.js","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,YAAY,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ED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACjD,MAAM,KAAK,CAAC,WAAW,EAAE,CAAA;IAEzB,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACxC,MAAM,QAAQ,GACZ,IAAI,CAAC,KAAK,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAExD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,IAAI,KAAK,CACb,6BAA6B,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CACnD,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import { splitDepID } from '@vltpkg/dep-id/browser'\nimport { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport { asManifest } from '@vltpkg/types'\nimport { attr } from './pseudo/attr.ts'\nimport { outdated } from './pseudo/outdated.ts'\nimport { semverParser as semver } from './pseudo/semver.ts'\nimport { removeDanglingEdges, removeNode } from './pseudo/helpers.ts'\nimport {\n asPostcssNodeWithChildren,\n asPseudoNode,\n asTagNode,\n isSelectorNode,\n} from './types.ts'\nimport type { ParserFn, ParserState } from './types.ts'\n\n/**\n * :empty Pseudo-Selector, matches only nodes that have no children.\n */\nconst empty = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesOut.size > 0) {\n removeNode(state, node)\n }\n }\n return state\n}\n\n/**\n * :has Pseudo-Selector, matches only nodes that have valid results\n * for its nested selector expressions.\n */\nconst has = async (state: ParserState) => {\n const top = asPostcssNodeWithChildren(state.current)\n const collectNodes = new Set<NodeLike>()\n const collectEdges = new Set<EdgeLike>()\n\n for (const node of top.nodes) {\n if (isSelectorNode(node)) {\n const nestedState = await state.walk({\n cancellable: state.cancellable,\n initial: {\n edges: new Set(state.initial.edges),\n nodes: new Set(state.initial.nodes),\n },\n current: node,\n walk: state.walk,\n collect: {\n edges: new Set(),\n nodes: new Set(),\n },\n partial: {\n edges: new Set(state.partial.edges),\n nodes: new Set(state.partial.nodes),\n },\n specOptions: state.specOptions,\n })\n for (const n of nestedState.collect.nodes) {\n collectNodes.add(n)\n }\n for (const e of nestedState.partial.edges) {\n collectEdges.add(e)\n }\n }\n }\n\n // if the nested selector did not match anything, that means\n // no current node has any matches\n if (collectNodes.size === 0) {\n state.partial.edges.clear()\n state.partial.nodes.clear()\n return state\n }\n\n // handles transitive dependencies\n // compareNodes collects a list of all ancestor nodes\n // from the resulting nodes of the nested selector\n const compareNodes = new Set<NodeLike>()\n const traverse = new Set(collectNodes)\n for (const node of traverse) {\n for (const edge of node.edgesIn) {\n compareNodes.add(edge.from)\n if (edge.from.edgesIn.size) {\n traverse.add(edge.from)\n }\n }\n }\n\n // for each node in the current list checks to see if\n // it has a node in the resulting nested state that is\n // a transitive dependency / children.\n nodesLoop: for (const node of state.partial.nodes) {\n if (node.edgesOut.size === 0 || !compareNodes.has(node)) {\n removeNode(state, node)\n continue\n }\n\n for (const edge of node.edgesOut.values()) {\n if (collectEdges.has(edge)) {\n continue nodesLoop\n }\n }\n removeNode(state, node)\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n\n/**\n * :is Pseudo-selector, acts as a shortcut for writing more compact expressions\n * by allowing multiple nested selectors to match on the previous results.\n *\n * It also enables the loose parsing mode, skipping instead of erroring usage\n * of non-existing classes, identifiers, pseudo-classes, etc.\n */\nconst is = async (state: ParserState) => {\n const top = asPostcssNodeWithChildren(state.current)\n const collect = new Set()\n for (const node of top.nodes) {\n if (isSelectorNode(node)) {\n const nestedState = await state.walk({\n cancellable: state.cancellable,\n collect: {\n edges: new Set(),\n nodes: new Set(),\n },\n current: node,\n initial: state.initial,\n loose: true,\n partial: {\n nodes: new Set(state.partial.nodes),\n edges: new Set(state.partial.edges),\n },\n walk: state.walk,\n specOptions: state.specOptions,\n })\n for (const n of nestedState.collect.nodes) {\n collect.add(n)\n }\n }\n }\n for (const node of state.partial.nodes) {\n if (!collect.has(node)) {\n removeNode(state, node)\n }\n }\n return state\n}\n\n/**\n * :missing Pseudo-Selector, matches only\n * edges that are not linked to any node.\n */\nconst missing = async (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n state.partial.nodes.clear()\n return state\n}\n\n/**\n * :not Pseudo-class, serves to create negate expressions, anything that\n * matches selectors declared inside the `:not()` expression is going to be\n * filtered out in the final result.\n */\nconst not = async (state: ParserState) => {\n const top = asPostcssNodeWithChildren(state.current)\n const collect = new Set()\n for (const node of top.nodes) {\n if (isSelectorNode(node)) {\n const nestedState = await state.walk({\n cancellable: state.cancellable,\n collect: {\n edges: new Set(),\n nodes: new Set(),\n },\n current: node,\n initial: state.initial,\n partial: {\n nodes: new Set(state.partial.nodes),\n edges: new Set(state.partial.edges),\n },\n walk: state.walk,\n specOptions: state.specOptions,\n })\n for (const n of nestedState.collect.nodes) {\n collect.add(n)\n }\n /* c8 ignore start - should be impossible */\n } else {\n throw error('Error parsing :not() selectors', {\n wanted: { type: 'selector' },\n found: node,\n })\n }\n /* c8 ignore stop */\n }\n for (const node of state.partial.nodes) {\n if (collect.has(node)) {\n removeNode(state, node)\n }\n }\n return state\n}\n\n/**\n * :private Pseudo-Selector will only match packages that have\n * a `private: true` key set in their `package.json` metadata.\n */\nconst privateFn = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (!node.manifest || !asManifest(node.manifest).private) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n\n/**\n * :root Pseudo-Element will return the project root node for the graph.\n */\nconst root = async (state: ParserState) => {\n const [anyNode] = state.initial.nodes.values()\n const mainImporter = anyNode?.graph.mainImporter\n if (!mainImporter) {\n throw error(':root pseudo-element works on local graphs only')\n }\n for (const edge of state.partial.edges) {\n if (edge.to !== mainImporter) {\n state.partial.edges.delete(edge)\n }\n }\n state.partial.nodes.clear()\n state.partial.nodes.add(mainImporter)\n return state\n}\n\n/**\n * :project Pseudo-Element, returns all graph importers (e.g: the\n * root node along with any configured workspace)\n */\nconst project = async (state: ParserState) => {\n const [anyNode] = state.initial.nodes.values()\n const importers = anyNode?.graph.importers\n if (!importers?.size) {\n throw error(':project pseudo-element works on local graphs only')\n }\n\n // make a list of all edges that are coming from importers\n // so that we can filter out any edges that are not direct\n // dependencies of the importers\n const importersEdgesIn = new Set<EdgeLike>()\n for (const importer of importers) {\n for (const edge of importer.edgesIn) {\n importersEdgesIn.add(edge)\n }\n }\n\n for (const edge of state.partial.edges) {\n if (!edge.to || !importersEdgesIn.has(edge)) {\n state.partial.edges.delete(edge)\n }\n }\n state.partial.nodes.clear()\n for (const importer of importers) {\n state.partial.nodes.add(importer)\n }\n return state\n}\n\n/**\n * :scope Pseudo-Element, returns the original scope of items\n * at the start of a given selector.\n */\nconst scope = async (state: ParserState) => {\n state.partial.edges.clear()\n state.partial.nodes.clear()\n for (const edge of state.initial.edges) {\n state.partial.edges.add(edge)\n }\n for (const node of state.initial.nodes) {\n state.partial.nodes.add(node)\n }\n return state\n}\n\n/**\n * :type(str) Pseudo-Element will match only nodes that are of\n * the same type as the value used\n */\nconst typeFn = async (state: ParserState) => {\n const type = asPostcssNodeWithChildren(state.current)\n const selector = asPostcssNodeWithChildren(type.nodes[0])\n const name = asTagNode(selector.nodes[0]).value\n for (const node of state.partial.nodes) {\n const nodeType = splitDepID(node.id)[0]\n if (nodeType !== name) {\n removeNode(state, node)\n }\n }\n return state\n}\n\nconst pseudoSelectors = new Map<string, ParserFn>(\n Object.entries({\n attr,\n empty,\n has,\n is,\n // TODO: link\n missing,\n not,\n // TODO: overridden\n private: privateFn,\n project,\n root,\n scope,\n type: typeFn,\n semver,\n outdated,\n }),\n)\n\n/**\n * Parsers the `pseudo` node types.\n */\nexport const pseudo = async (state: ParserState) => {\n await state.cancellable()\n\n const curr = asPseudoNode(state.current)\n const parserFn =\n curr.value && pseudoSelectors.get(curr.value.slice(1))\n\n if (!parserFn) {\n if (state.loose) {\n return state\n }\n\n throw new Error(\n `Unsupported pseudo-class: ${state.current.value}`,\n )\n }\n return parserFn(state)\n}\n"]}
1
+ {"version":3,"file":"pseudo.js","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,SAAS,EACT,cAAc,GACf,MAAM,YAAY,CAAA;AAGnB,4BAA4B;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM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IACb,QAAQ;IACR,KAAK;IACL,UAAU;IACV,KAAK;IACL,UAAU;IACV,OAAO;IACP,OAAO;IACP,IAAI,EAAE,MAAM;IACZ,WAAW;IACX,OAAO;IACP,YAAY;IACZ,SAAS;IACT,QAAQ;CACT,CAAC,CACH,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACjD,MAAM,KAAK,CAAC,WAAW,EAAE,CAAA;IAEzB,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACxC,MAAM,QAAQ,GACZ,IAAI,CAAC,KAAK,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAExD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,IAAI,KAAK,CACb,6BAA6B,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CACnD,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import { splitDepID } from '@vltpkg/dep-id/browser'\nimport { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport { asManifest } from '@vltpkg/types'\n\nimport { removeDanglingEdges, removeNode } from './pseudo/helpers.ts'\nimport {\n asPostcssNodeWithChildren,\n asPseudoNode,\n asTagNode,\n isSelectorNode,\n} from './types.ts'\nimport type { ParserFn, ParserState } from './types.ts'\n\n// imported pseudo selectors\nimport { abandoned } from './pseudo/abandoned.ts'\nimport { attr } from './pseudo/attr.ts'\nimport { confused } from './pseudo/confused.ts'\nimport { cve } from './pseudo/cve.ts'\nimport { cwe } from './pseudo/cwe.ts'\nimport { debug } from './pseudo/debug.ts'\nimport { deprecated } from './pseudo/deprecated.ts'\nimport { dynamic } from './pseudo/dynamic.ts'\nimport { entropic } from './pseudo/entropic.ts'\nimport { env } from './pseudo/env.ts'\nimport { evalParser } from './pseudo/eval.ts'\nimport { fs } from './pseudo/fs.ts'\nimport { license } from './pseudo/license.ts'\nimport { malware } from './pseudo/malware.ts'\nimport { minified } from './pseudo/minified.ts'\nimport { nativeParser } from './pseudo/native.ts'\nimport { network } from './pseudo/network.ts'\nimport { obfuscated } from './pseudo/obfuscated.ts'\nimport { outdated } from './pseudo/outdated.ts'\nimport { scripts } from './pseudo/scripts.ts'\nimport { shell } from './pseudo/shell.ts'\nimport { semverParser as semver } from './pseudo/semver.ts'\nimport { severity } from './pseudo/severity.ts'\nimport { shrinkwrap } from './pseudo/shrinkwrap.ts'\nimport { squat } from './pseudo/squat.ts'\nimport { suspicious } from './pseudo/suspicious.ts'\nimport { tracker } from './pseudo/tracker.ts'\nimport { trivial } from './pseudo/trivial.ts'\nimport { undesirable } from './pseudo/undesirable.ts'\nimport { unknown } from './pseudo/unknown.ts'\nimport { unmaintained } from './pseudo/unmaintained.ts'\nimport { unpopular } from './pseudo/unpopular.ts'\nimport { unstable } from './pseudo/unstable.ts'\n\n/**\n * :empty Pseudo-Selector, matches only nodes that have no children.\n */\nconst empty = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesOut.size > 0) {\n removeNode(state, node)\n }\n }\n return state\n}\n\n/**\n * :has Pseudo-Selector, matches only nodes that have valid results\n * for its nested selector expressions.\n */\nconst has = async (state: ParserState) => {\n const top = asPostcssNodeWithChildren(state.current)\n const collectNodes = new Set<NodeLike>()\n const collectEdges = new Set<EdgeLike>()\n\n for (const node of top.nodes) {\n if (isSelectorNode(node)) {\n const nestedState = await state.walk({\n cancellable: state.cancellable,\n initial: {\n edges: new Set(state.initial.edges),\n nodes: new Set(state.initial.nodes),\n },\n current: node,\n walk: state.walk,\n collect: {\n edges: new Set(),\n nodes: new Set(),\n },\n partial: {\n edges: new Set(state.partial.edges),\n nodes: new Set(state.partial.nodes),\n },\n securityArchive: state.securityArchive,\n specOptions: state.specOptions,\n })\n for (const n of nestedState.collect.nodes) {\n collectNodes.add(n)\n }\n for (const e of nestedState.partial.edges) {\n collectEdges.add(e)\n }\n }\n }\n\n // if the nested selector did not match anything, that means\n // no current node has any matches\n if (collectNodes.size === 0) {\n state.partial.edges.clear()\n state.partial.nodes.clear()\n return state\n }\n\n // handles transitive dependencies\n // compareNodes collects a list of all ancestor nodes\n // from the resulting nodes of the nested selector\n const compareNodes = new Set<NodeLike>()\n const traverse = new Set(collectNodes)\n for (const node of traverse) {\n for (const edge of node.edgesIn) {\n compareNodes.add(edge.from)\n if (edge.from.edgesIn.size) {\n traverse.add(edge.from)\n }\n }\n }\n\n // for each node in the current list checks to see if\n // it has a node in the resulting nested state that is\n // a transitive dependency / children.\n nodesLoop: for (const node of state.partial.nodes) {\n if (node.edgesOut.size === 0 || !compareNodes.has(node)) {\n removeNode(state, node)\n continue\n }\n\n for (const edge of node.edgesOut.values()) {\n if (collectEdges.has(edge)) {\n continue nodesLoop\n }\n }\n removeNode(state, node)\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n\n/**\n * :is Pseudo-selector, acts as a shortcut for writing more compact expressions\n * by allowing multiple nested selectors to match on the previous results.\n *\n * It also enables the loose parsing mode, skipping instead of erroring usage\n * of non-existing classes, identifiers, pseudo-classes, etc.\n */\nconst is = async (state: ParserState) => {\n const top = asPostcssNodeWithChildren(state.current)\n const collect = new Set()\n for (const node of top.nodes) {\n if (isSelectorNode(node)) {\n const nestedState = await state.walk({\n cancellable: state.cancellable,\n collect: {\n edges: new Set(),\n nodes: new Set(),\n },\n current: node,\n initial: state.initial,\n loose: true,\n partial: {\n nodes: new Set(state.partial.nodes),\n edges: new Set(state.partial.edges),\n },\n walk: state.walk,\n securityArchive: state.securityArchive,\n specOptions: state.specOptions,\n })\n for (const n of nestedState.collect.nodes) {\n collect.add(n)\n }\n }\n }\n for (const node of state.partial.nodes) {\n if (!collect.has(node)) {\n removeNode(state, node)\n }\n }\n return state\n}\n\n/**\n * :missing Pseudo-Selector, matches only\n * edges that are not linked to any node.\n */\nconst missing = async (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n state.partial.nodes.clear()\n return state\n}\n\n/**\n * :not Pseudo-class, serves to create negate expressions, anything that\n * matches selectors declared inside the `:not()` expression is going to be\n * filtered out in the final result.\n */\nconst not = async (state: ParserState) => {\n const top = asPostcssNodeWithChildren(state.current)\n const collect = new Set()\n for (const node of top.nodes) {\n if (isSelectorNode(node)) {\n const nestedState = await state.walk({\n cancellable: state.cancellable,\n collect: {\n edges: new Set(),\n nodes: new Set(),\n },\n current: node,\n initial: state.initial,\n partial: {\n nodes: new Set(state.partial.nodes),\n edges: new Set(state.partial.edges),\n },\n walk: state.walk,\n securityArchive: state.securityArchive,\n specOptions: state.specOptions,\n })\n for (const n of nestedState.collect.nodes) {\n collect.add(n)\n }\n /* c8 ignore start - should be impossible */\n } else {\n throw error('Error parsing :not() selectors', {\n wanted: { type: 'selector' },\n found: node,\n })\n }\n /* c8 ignore stop */\n }\n for (const node of state.partial.nodes) {\n if (collect.has(node)) {\n removeNode(state, node)\n }\n }\n return state\n}\n\n/**\n * :private Pseudo-Selector will only match packages that have\n * a `private: true` key set in their `package.json` metadata.\n */\nconst privateFn = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (!node.manifest || !asManifest(node.manifest).private) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n\n/**\n * :root Pseudo-Element will return the project root node for the graph.\n */\nconst root = async (state: ParserState) => {\n const [anyNode] = state.initial.nodes.values()\n const mainImporter = anyNode?.graph.mainImporter\n if (!mainImporter) {\n throw error(':root pseudo-element works on local graphs only')\n }\n for (const edge of state.partial.edges) {\n if (edge.to !== mainImporter) {\n state.partial.edges.delete(edge)\n }\n }\n state.partial.nodes.clear()\n state.partial.nodes.add(mainImporter)\n return state\n}\n\n/**\n * :project Pseudo-Element, returns all graph importers (e.g: the\n * root node along with any configured workspace)\n */\nconst project = async (state: ParserState) => {\n const [anyNode] = state.initial.nodes.values()\n const importers = anyNode?.graph.importers\n if (!importers?.size) {\n throw error(':project pseudo-element works on local graphs only')\n }\n\n // make a list of all edges that are coming from importers\n // so that we can filter out any edges that are not direct\n // dependencies of the importers\n const importersEdgesIn = new Set<EdgeLike>()\n for (const importer of importers) {\n for (const edge of importer.edgesIn) {\n importersEdgesIn.add(edge)\n }\n }\n\n for (const edge of state.partial.edges) {\n if (!edge.to || !importersEdgesIn.has(edge)) {\n state.partial.edges.delete(edge)\n }\n }\n state.partial.nodes.clear()\n for (const importer of importers) {\n state.partial.nodes.add(importer)\n }\n return state\n}\n\n/**\n * :scope Pseudo-Element, returns the original scope of items\n * at the start of a given selector.\n */\nconst scope = async (state: ParserState) => {\n state.partial.edges.clear()\n state.partial.nodes.clear()\n for (const edge of state.initial.edges) {\n state.partial.edges.add(edge)\n }\n for (const node of state.initial.nodes) {\n state.partial.nodes.add(node)\n }\n return state\n}\n\n/**\n * :type(str) Pseudo-Element will match only nodes that are of\n * the same type as the value used\n */\nconst typeFn = async (state: ParserState) => {\n const type = asPostcssNodeWithChildren(state.current)\n const selector = asPostcssNodeWithChildren(type.nodes[0])\n const name = asTagNode(selector.nodes[0]).value\n for (const node of state.partial.nodes) {\n const nodeType = splitDepID(node.id)[0]\n if (nodeType !== name) {\n removeNode(state, node)\n }\n }\n return state\n}\n\nconst pseudoSelectors = new Map<string, ParserFn>(\n Object.entries({\n abandoned,\n attr,\n confused,\n cve,\n cwe,\n debug,\n deprecated,\n dynamic,\n eval: evalParser,\n empty,\n entropic,\n env,\n fs,\n has,\n is,\n // TODO: link\n license,\n malware,\n minified,\n missing,\n native: nativeParser,\n network,\n not,\n obfuscated,\n outdated,\n // TODO: overridden\n private: privateFn,\n project,\n root,\n scope,\n scripts,\n semver,\n sev: severity,\n severity,\n shell,\n shrinkwrap,\n squat,\n suspicious,\n tracker,\n trivial,\n type: typeFn,\n undesirable,\n unknown,\n unmaintained,\n unpopular,\n unstable,\n }),\n)\n\n/**\n * Parsers the `pseudo` node types.\n */\nexport const pseudo = async (state: ParserState) => {\n await state.cancellable()\n\n const curr = asPseudoNode(state.current)\n const parserFn =\n curr.value && pseudoSelectors.get(curr.value.slice(1))\n\n if (!parserFn) {\n if (state.loose) {\n return state\n }\n\n throw new Error(\n `Unsupported pseudo-class: ${state.current.value}`,\n )\n }\n return parserFn(state)\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { EdgeLike, NodeLike } from '@vltpkg/graph';
2
2
  import type { SpecOptions } from '@vltpkg/spec/browser';
3
+ import type { SecurityArchiveLike } from '@vltpkg/security-archive';
3
4
  import type { Tag, String, Selector, Root, Pseudo, Nesting, Identifier, Comment, Combinator, ClassName, Attribute, Universal } from 'postcss-selector-parser';
4
5
  export type PostcssNode = Tag | String | Selector | Root | Pseudo | Nesting | Identifier | Comment | Combinator | ClassName | Attribute | Universal;
5
6
  export type PostcssNodeWithChildren = Selector | Root | Pseudo;
@@ -19,6 +20,7 @@ export type ParserState = {
19
20
  signal?: AbortSignal;
20
21
  walk: ParserFn;
21
22
  partial: GraphSelectionState;
23
+ securityArchive: SecurityArchiveLike | undefined;
22
24
  specOptions: SpecOptions;
23
25
  };
24
26
  export type QueryResponse = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EACV,GAAG,EACH,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,OAAO,EACP,UAAU,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,yBAAyB,CAA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,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,CAAC,wBAAwB,EAAE;YACpC,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAa,EAAkB,EAAE,CAC5D,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAA;AAEvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAU,EAAE;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC,wBAAwB,EAAE;YACpC,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { SpecOptions } from '@vltpkg/spec/browser'\nimport type {\n Tag,\n String,\n Selector,\n Root,\n Pseudo,\n Nesting,\n Identifier,\n Comment,\n Combinator,\n ClassName,\n Attribute,\n Universal,\n} from 'postcss-selector-parser'\n\nexport type PostcssNode =\n | Tag\n | String\n | Selector\n | Root\n | Pseudo\n | Nesting\n | Identifier\n | Comment\n | Combinator\n | ClassName\n | Attribute\n | Universal\n\nexport type PostcssNodeWithChildren = Selector | Root | Pseudo\n\nexport type GraphSelectionState = {\n nodes: Set<NodeLike>\n edges: Set<EdgeLike>\n}\n\nexport type ParserState = {\n cancellable: () => Promise<void>\n collect: GraphSelectionState\n current: PostcssNode\n initial: GraphSelectionState\n loose?: boolean\n next?: PostcssNode\n prev?: PostcssNode\n result?: NodeLike[]\n signal?: AbortSignal\n walk: ParserFn\n partial: GraphSelectionState\n specOptions: SpecOptions\n}\n\nexport type QueryResponse = {\n edges: EdgeLike[]\n nodes: NodeLike[]\n}\n\nexport type ParserFn = (opt: ParserState) => Promise<ParserState>\n\nexport const isPostcssNodeWithChildren = (\n node: any,\n): node is PostcssNodeWithChildren =>\n 'type' in node && 'nodes' in node\n\nexport const asPostcssNodeWithChildren = (\n node?: PostcssNode,\n): PostcssNodeWithChildren => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isPostcssNodeWithChildren(node)) {\n throw error('Not a query selector node with children', {\n found: node,\n })\n }\n return node\n}\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\nexport const isAttributeNode = (node: unknown): node is Attribute =>\n isObj(node) && !!node.attribute && node.type === 'attribute'\n\nexport const asAttributeNode = (node?: PostcssNode): Attribute => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isAttributeNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'attribute',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isClassNode = (node: unknown): node is ClassName =>\n isObj(node) && !!node.value && node.type === 'class'\n\nexport const asClassNode = (node?: PostcssNode): ClassName => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isClassNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'class',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isCombinatorNode = (node: unknown): node is Combinator =>\n isObj(node) && !!node.value && node.type === 'combinator'\n\nexport const asCombinatorNode = (node?: PostcssNode): Combinator => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isCombinatorNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'combinator',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isIdentifierNode = (node: any): node is Identifier =>\n isObj(node) && !!node.value && node.type === 'id'\n\nexport const asIdentifierNode = (node?: PostcssNode): Identifier => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isIdentifierNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'id',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isSelectorNode = (node: any): node is Selector =>\n isPostcssNodeWithChildren(node) && node.type === 'selector'\n\nexport const isPseudoNode = (node: unknown): node is Pseudo =>\n isObj(node) && !!node.value && node.type === 'pseudo'\n\nexport const asPseudoNode = (node?: PostcssNode): Pseudo => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isPseudoNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'pseudo',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isTagNode = (node: unknown): node is Tag =>\n isObj(node) && !!node.value && node.type === 'tag'\n\nexport const asTagNode = (node?: PostcssNode): Tag => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isTagNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'tag',\n found: node.type,\n })\n }\n\n return node\n}\n\nexport const isStringNode = (node: unknown): node is String =>\n isObj(node) && !!node.value && node.type === 'string'\n\nexport const asStringNode = (node?: PostcssNode): String => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isStringNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'string',\n found: node.type,\n })\n }\n\n return node\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AA+D3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,IAAS,EACwB,EAAE,CACnC,MAAM,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAA;AAEnC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,IAAkB,EACO,EAAE;IAC3B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,CAAC,yBAA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AAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAa,EAAkB,EAAE,CAC5D,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAA;AAEvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAU,EAAE;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC,wBAAwB,EAAE;YACpC,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { SpecOptions } from '@vltpkg/spec/browser'\nimport type { SecurityArchiveLike } from '@vltpkg/security-archive'\nimport type {\n Tag,\n String,\n Selector,\n Root,\n Pseudo,\n Nesting,\n Identifier,\n Comment,\n Combinator,\n ClassName,\n Attribute,\n Universal,\n} from 'postcss-selector-parser'\n\nexport type PostcssNode =\n | Tag\n | String\n | Selector\n | Root\n | Pseudo\n | Nesting\n | Identifier\n | Comment\n | Combinator\n | ClassName\n | Attribute\n | Universal\n\nexport type PostcssNodeWithChildren = Selector | Root | Pseudo\n\nexport type GraphSelectionState = {\n nodes: Set<NodeLike>\n edges: Set<EdgeLike>\n}\n\nexport type ParserState = {\n cancellable: () => Promise<void>\n collect: GraphSelectionState\n current: PostcssNode\n initial: GraphSelectionState\n loose?: boolean\n next?: PostcssNode\n prev?: PostcssNode\n result?: NodeLike[]\n signal?: AbortSignal\n walk: ParserFn\n partial: GraphSelectionState\n securityArchive: SecurityArchiveLike | undefined\n specOptions: SpecOptions\n}\n\nexport type QueryResponse = {\n edges: EdgeLike[]\n nodes: NodeLike[]\n}\n\nexport type ParserFn = (opt: ParserState) => Promise<ParserState>\n\nexport const isPostcssNodeWithChildren = (\n node: any,\n): node is PostcssNodeWithChildren =>\n 'type' in node && 'nodes' in node\n\nexport const asPostcssNodeWithChildren = (\n node?: PostcssNode,\n): PostcssNodeWithChildren => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isPostcssNodeWithChildren(node)) {\n throw error('Not a query selector node with children', {\n found: node,\n })\n }\n return node\n}\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\nexport const isAttributeNode = (node: unknown): node is Attribute =>\n isObj(node) && !!node.attribute && node.type === 'attribute'\n\nexport const asAttributeNode = (node?: PostcssNode): Attribute => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isAttributeNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'attribute',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isClassNode = (node: unknown): node is ClassName =>\n isObj(node) && !!node.value && node.type === 'class'\n\nexport const asClassNode = (node?: PostcssNode): ClassName => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isClassNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'class',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isCombinatorNode = (node: unknown): node is Combinator =>\n isObj(node) && !!node.value && node.type === 'combinator'\n\nexport const asCombinatorNode = (node?: PostcssNode): Combinator => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isCombinatorNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'combinator',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isIdentifierNode = (node: any): node is Identifier =>\n isObj(node) && !!node.value && node.type === 'id'\n\nexport const asIdentifierNode = (node?: PostcssNode): Identifier => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isIdentifierNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'id',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isSelectorNode = (node: any): node is Selector =>\n isPostcssNodeWithChildren(node) && node.type === 'selector'\n\nexport const isPseudoNode = (node: unknown): node is Pseudo =>\n isObj(node) && !!node.value && node.type === 'pseudo'\n\nexport const asPseudoNode = (node?: PostcssNode): Pseudo => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isPseudoNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'pseudo',\n found: node.type,\n })\n }\n return node\n}\n\nexport const isTagNode = (node: unknown): node is Tag =>\n isObj(node) && !!node.value && node.type === 'tag'\n\nexport const asTagNode = (node?: PostcssNode): Tag => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isTagNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'tag',\n found: node.type,\n })\n }\n\n return node\n}\n\nexport const isStringNode = (node: unknown): node is String =>\n isObj(node) && !!node.value && node.type === 'string'\n\nexport const asStringNode = (node?: PostcssNode): String => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isStringNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'string',\n found: node.type,\n })\n }\n\n return node\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/query",
3
3
  "description": "Query syntax parser that retrieves items from a graph",
4
- "version": "0.0.0-5",
4
+ "version": "0.0.0-7",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -20,11 +20,12 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "postcss-selector-parser": "^6.1.2",
23
- "@vltpkg/dep-id": "0.0.0-5",
24
- "@vltpkg/error-cause": "0.0.0-5",
25
- "@vltpkg/graph": "0.0.0-5",
26
- "@vltpkg/semver": "0.0.0-5",
27
- "@vltpkg/types": "0.0.0-5"
23
+ "@vltpkg/dep-id": "0.0.0-7",
24
+ "@vltpkg/error-cause": "0.0.0-7",
25
+ "@vltpkg/graph": "0.0.0-7",
26
+ "@vltpkg/security-archive": "0.0.0-7",
27
+ "@vltpkg/semver": "0.0.0-7",
28
+ "@vltpkg/types": "0.0.0-7"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@eslint/js": "^9.20.0",
@@ -37,7 +38,7 @@
37
38
  "typedoc": "0.27.6",
38
39
  "typescript": "5.7.3",
39
40
  "typescript-eslint": "^8.23.0",
40
- "@vltpkg/spec": "0.0.0-5"
41
+ "@vltpkg/spec": "0.0.0-7"
41
42
  },
42
43
  "license": "BSD-2-Clause-Patent",
43
44
  "engines": {