@vltpkg/query 0.0.0-9 → 1.0.0-rc.1

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 (117) hide show
  1. package/README.md +38 -268
  2. package/dist/esm/attribute.d.ts +1 -1
  3. package/dist/esm/attribute.d.ts.map +1 -1
  4. package/dist/esm/attribute.js +5 -12
  5. package/dist/esm/attribute.js.map +1 -1
  6. package/dist/esm/combinator.d.ts.map +1 -1
  7. package/dist/esm/combinator.js +1 -1
  8. package/dist/esm/combinator.js.map +1 -1
  9. package/dist/esm/id.d.ts.map +1 -1
  10. package/dist/esm/id.js +3 -1
  11. package/dist/esm/id.js.map +1 -1
  12. package/dist/esm/index.d.ts +24 -7
  13. package/dist/esm/index.d.ts.map +1 -1
  14. package/dist/esm/index.js +87 -21
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/parser.d.ts.map +1 -1
  17. package/dist/esm/parser.js +2 -1
  18. package/dist/esm/parser.js.map +1 -1
  19. package/dist/esm/pseudo/attr.d.ts +2 -1
  20. package/dist/esm/pseudo/attr.d.ts.map +1 -1
  21. package/dist/esm/pseudo/attr.js +1 -1
  22. package/dist/esm/pseudo/attr.js.map +1 -1
  23. package/dist/esm/pseudo/built.d.ts +8 -0
  24. package/dist/esm/pseudo/built.d.ts.map +1 -0
  25. package/dist/esm/pseudo/built.js +16 -0
  26. package/dist/esm/pseudo/built.js.map +1 -0
  27. package/dist/esm/pseudo/confused.d.ts +4 -2
  28. package/dist/esm/pseudo/confused.d.ts.map +1 -1
  29. package/dist/esm/pseudo/confused.js +15 -2
  30. package/dist/esm/pseudo/confused.js.map +1 -1
  31. package/dist/esm/pseudo/cve.d.ts +2 -1
  32. package/dist/esm/pseudo/cve.d.ts.map +1 -1
  33. package/dist/esm/pseudo/cve.js +1 -1
  34. package/dist/esm/pseudo/cve.js.map +1 -1
  35. package/dist/esm/pseudo/cwe.d.ts +2 -1
  36. package/dist/esm/pseudo/cwe.d.ts.map +1 -1
  37. package/dist/esm/pseudo/cwe.js +1 -1
  38. package/dist/esm/pseudo/cwe.js.map +1 -1
  39. package/dist/esm/pseudo/helpers.d.ts +5 -1
  40. package/dist/esm/pseudo/helpers.d.ts.map +1 -1
  41. package/dist/esm/pseudo/helpers.js +8 -0
  42. package/dist/esm/pseudo/helpers.js.map +1 -1
  43. package/dist/esm/pseudo/host.d.ts +20 -0
  44. package/dist/esm/pseudo/host.d.ts.map +1 -0
  45. package/dist/esm/pseudo/host.js +80 -0
  46. package/dist/esm/pseudo/host.js.map +1 -0
  47. package/dist/esm/pseudo/license.d.ts +2 -1
  48. package/dist/esm/pseudo/license.d.ts.map +1 -1
  49. package/dist/esm/pseudo/license.js +19 -2
  50. package/dist/esm/pseudo/license.js.map +1 -1
  51. package/dist/esm/pseudo/malware.d.ts +11 -1
  52. package/dist/esm/pseudo/malware.d.ts.map +1 -1
  53. package/dist/esm/pseudo/malware.js +30 -8
  54. package/dist/esm/pseudo/malware.js.map +1 -1
  55. package/dist/esm/pseudo/outdated.d.ts +4 -4
  56. package/dist/esm/pseudo/outdated.d.ts.map +1 -1
  57. package/dist/esm/pseudo/outdated.js +16 -11
  58. package/dist/esm/pseudo/outdated.js.map +1 -1
  59. package/dist/esm/pseudo/overridden.d.ts +8 -0
  60. package/dist/esm/pseudo/overridden.d.ts.map +1 -0
  61. package/dist/esm/pseudo/overridden.js +17 -0
  62. package/dist/esm/pseudo/overridden.js.map +1 -0
  63. package/dist/esm/pseudo/path.d.ts +19 -0
  64. package/dist/esm/pseudo/path.d.ts.map +1 -0
  65. package/dist/esm/pseudo/path.js +113 -0
  66. package/dist/esm/pseudo/path.js.map +1 -0
  67. package/dist/esm/pseudo/prerelease.d.ts +18 -0
  68. package/dist/esm/pseudo/prerelease.d.ts.map +1 -0
  69. package/dist/esm/pseudo/prerelease.js +41 -0
  70. package/dist/esm/pseudo/prerelease.js.map +1 -0
  71. package/dist/esm/pseudo/published.d.ts +4 -4
  72. package/dist/esm/pseudo/published.d.ts.map +1 -1
  73. package/dist/esm/pseudo/published.js +32 -11
  74. package/dist/esm/pseudo/published.js.map +1 -1
  75. package/dist/esm/pseudo/root.d.ts +7 -0
  76. package/dist/esm/pseudo/root.d.ts.map +1 -0
  77. package/dist/esm/pseudo/root.js +18 -0
  78. package/dist/esm/pseudo/root.js.map +1 -0
  79. package/dist/esm/pseudo/score.d.ts +2 -1
  80. package/dist/esm/pseudo/score.d.ts.map +1 -1
  81. package/dist/esm/pseudo/score.js +16 -2
  82. package/dist/esm/pseudo/score.js.map +1 -1
  83. package/dist/esm/pseudo/scripts.d.ts +7 -4
  84. package/dist/esm/pseudo/scripts.d.ts.map +1 -1
  85. package/dist/esm/pseudo/scripts.js +41 -3
  86. package/dist/esm/pseudo/scripts.js.map +1 -1
  87. package/dist/esm/pseudo/semver.d.ts +2 -1
  88. package/dist/esm/pseudo/semver.d.ts.map +1 -1
  89. package/dist/esm/pseudo/semver.js +3 -2
  90. package/dist/esm/pseudo/semver.js.map +1 -1
  91. package/dist/esm/pseudo/severity.d.ts +2 -1
  92. package/dist/esm/pseudo/severity.d.ts.map +1 -1
  93. package/dist/esm/pseudo/severity.js +1 -1
  94. package/dist/esm/pseudo/severity.js.map +1 -1
  95. package/dist/esm/pseudo/spec.d.ts +17 -0
  96. package/dist/esm/pseudo/spec.d.ts.map +1 -0
  97. package/dist/esm/pseudo/spec.js +102 -0
  98. package/dist/esm/pseudo/spec.js.map +1 -0
  99. package/dist/esm/pseudo/squat.d.ts +2 -1
  100. package/dist/esm/pseudo/squat.d.ts.map +1 -1
  101. package/dist/esm/pseudo/squat.js +14 -3
  102. package/dist/esm/pseudo/squat.js.map +1 -1
  103. package/dist/esm/pseudo/type.d.ts +8 -0
  104. package/dist/esm/pseudo/type.d.ts.map +1 -0
  105. package/dist/esm/pseudo/type.js +22 -0
  106. package/dist/esm/pseudo/type.js.map +1 -0
  107. package/dist/esm/pseudo/workspace.d.ts.map +1 -1
  108. package/dist/esm/pseudo/workspace.js +7 -2
  109. package/dist/esm/pseudo/workspace.js.map +1 -1
  110. package/dist/esm/pseudo.d.ts.map +1 -1
  111. package/dist/esm/pseudo.js +58 -66
  112. package/dist/esm/pseudo.js.map +1 -1
  113. package/dist/esm/types.d.ts +25 -24
  114. package/dist/esm/types.d.ts.map +1 -1
  115. package/dist/esm/types.js +1 -105
  116. package/dist/esm/types.js.map +1 -1
  117. package/package.json +20 -17
package/README.md CHANGED
@@ -4,8 +4,7 @@
4
4
 
5
5
  The **vlt** query syntax engine.
6
6
 
7
- **[Usage](#usage)** · **[Examples](#examples)** ·
8
- **[Supported Syntax Reference](#supported-syntax-reference)**
7
+ **[Usage](#usage)** · **[Examples](#examples)**
9
8
 
10
9
  ## Usage
11
10
 
@@ -13,281 +12,52 @@ The **vlt** query syntax engine.
13
12
  import { Query } from '@vltpkg/query'
14
13
 
15
14
  const query = new Query({ nodes, specOptions, securityArchive })
16
- query.search(':root > *')
15
+ const res = await query.search(':root > *')
17
16
  ```
18
17
 
19
18
  ## Examples
20
19
 
21
- Querying nodes from a local `node_modules` folder.
20
+ ### Querying against an ideal/virtual graph
22
21
 
23
22
  ```js
24
- import { actual } from '@vltpkg/graph'
23
+ import { ideal } from '@vltpkg/graph'
25
24
  import { Query } from '@vltpkg/query'
26
-
27
- const graph = await actual.load({ projectRoot: process.cwd() })
28
- const query = new Query([...graph.nodes.values()])
29
- query.search(':root > *')
25
+ import { PackageJson } from '@vltpkg/package-json'
26
+ const signal = new AbortController().signal
27
+ const projectRoot = process.cwd()
28
+ const packageJson = new PackageJson()
29
+ const graph = await ideal.build({ projectRoot, packageJson })
30
+ const query = new Query({ graph })
31
+ const res = await query.search(':root > *', { signal })
30
32
  ```
31
33
 
32
- ## Supported Syntax Reference
33
-
34
- The vlt query syntax enable usage of css-selector-like strings to
35
- filter packages.
36
-
37
- Many of the common elements of the CSS language are available,
38
- notably:
39
-
40
- - `*` Universal selector, matches all selected items.
41
- - `&` Nesting selector, allows for nesting selectors.
42
- - `{}` Curly braces, when querying can be used to nest selectors.
43
-
44
- Split by group of selectors below is the complete reference to
45
- supported elements.
46
-
47
- ### Attribute selectors
48
-
49
- Attribute selectors are used to match a value found in the
50
- `package.json` metadata for each of the nodes being queried to a
51
- arbitrary value you choose.
52
-
53
- - `[attr]` Matches elements with an `attr` property in its
54
- `package.json`.
55
- - `[attr=value]` Matches elements with a property `attr` whose value
56
- is exactly `value`.
57
- - `[attr^=value]` Matches elements with a property `attr` whose value
58
- starts with `value`.
59
- - `[attr$=value]` Matches elements with a property `attr` whose value
60
- ends with `value`.
61
- - `[attr~=value]` Matches elements with a property `attr` whose value
62
- is a whitespace-separated list of words, one of which is exactly
63
- `value`.
64
- - `[attr|=value]` Matches elements with a property `attr` whose value
65
- is either `value` or starts with `value-`.
66
- - `[attr*=value]` Matches elements with a property `attr`.
67
- - `[attr=value i]` Case-insensitive flag, setting it will cause any
68
- comparison to be case-insensitive.
69
- - `[attr=value s]` Case-sensitive flag, setting it will cause
70
- comparisons to be case-sensitive, this is the default behavior.
71
-
72
- ### Class selectors
73
-
74
- - `.prod` Matches prod dependencies to your current project.
75
- - `.dev` Matches packages that are only used as dev dependencies in
76
- your current project.
77
- - `.optional` Matches packages that are optional to your current
78
- project.
79
- - `.peer` Matches peer dependencies to your current project.
80
- - `.workspace` Matches the current project worksacpes (listed in your
81
- `vlt-workspaces.json` file).
82
-
83
- ### Combinators
84
-
85
- - `>` Child combinator, matches packages that are direct dependencies
86
- of the previously selected nodes.
87
- - ` ` Descendant combinator, matches all packages that are direct &
88
- transitive dependencies of the previously selected nodes.
89
- - `~` Sibling combinator, matches packages that are direct
90
- dependencies of all dependents of the previously selected nodes.
91
-
92
- ### ID Selectors
34
+ ### Querying against a local `node_modules` folder
93
35
 
94
- Identifiers are a shortcut to retrieving packages by name,
95
- unfortunately this shortcut only works for unscoped packages, with
96
- that in mind it's advised to rely on using **Attribute selectors**
97
- (showed above) instead.
98
-
99
- e.g: `#foo` is the same as `[name=foo]`
100
-
101
- ### Pseudo class selectors
102
-
103
- - `:attr(key, [attr=value])` The attribute pseudo-class allows for
104
- selecting packages based on nested properties of its `package.json`
105
- metadata. As an example, here is a query that filters only packages
106
- that declares an optional peer dependency named `foo`:
107
- `:attr(peerDependenciesMeta, foo, [optional=true])`
108
- - `:empty` Matches packages that have no dependencies installed.
109
- - `:has(<selector-list>)` Matches only packages that have valid
110
- results for the selector expression used. As an example, here is a
111
- query that matches all packages that have a peer dependency on
112
- `react`: `:has(.peer[name=react])`
113
- - `:is(<forgiving-selector-list>)` Useful for writing large selectors
114
- in a more compact form, the `:is()` pseudo-class takes a selector
115
- list as its arguments and selects any element that can be selected
116
- by one of the selectors in that list. As an example, let's say I
117
- want to select packages named `a` & `b` that are direct dependencies
118
- of my project root: `:root > [name=a], :root > [name=b]` using the
119
- `:is()` pseudo-class, that same expression can be shortened to:
120
- `:root > :is([name=a], [name=b])`. Similar to the css pseudo-class
121
- of the same name, this selector has a forgiving behavior regarding
122
- its nested selector list ignoring any usage of non-existing ids,
123
- classes, combinators, operators and pseudo-selectors.
124
- - `:link` Matches linked packages only.
125
- - `:not(<selector-list>)` Negation pseudo-class, select packages that
126
- do not match a list of selectors.
127
- - `:outdated(<type>)` Matches packages that are outdated, the type
128
- parameter is optional and can be one of the following:
129
- - `any` (default) a version exists that is greater than the current
130
- one
131
- - `in-range` a version exists that is greater than the current one,
132
- and satisfies at least one if its parent's dependencies
133
- - `out-of-range` a version exists that is greater than the current
134
- one, does not satisfy at least one of its parent's dependencies
135
- - `major` a version exists that is a semver major greater than the
136
- current one
137
- - `minor` a version exists that is a semver minor greater than the
138
- current one
139
- - `patch` a version exists that is a semver patch greater than the
140
- current one
141
- - `:private` Matches packages that have the property `private` set on
142
- their `package.json` file.
143
- - `:published(<date>)` Matches packages based on their publication
144
- date. The date parameter can be prefixed with a comparator (`>`,
145
- `<`, `>=`, `<=`). If no comparator is provided, it will match exact
146
- dates. Please note that the value parameter needs to be quoted if
147
- using a comparator. Examples:
148
- - `:published(2024-01-01)` - Matches packages published exactly on
149
- January 1st, 2024
150
- - `:published(">2024-01-01")` - Matches packages published after
151
- January 1st, 2024
152
- - `:published("<=2023-12-31")` - Matches packages published on or
153
- before December 31st, 2023
154
- - `:semver(<value>, <function>, <custom-attribute-selector>)` Matches
155
- packages based on a semver value, e.g, to retrieve all packages that
156
- have a `version` satisfied by the semver value `^1.0.0`:
157
- `:semver(^1.0.0)`. It's also possible to define the type of semver
158
- comparison function to use by defining a second parameter, e.g:
159
- `:semver(^1.0.0, eq)` for an exact match, valid comparison types
160
- are: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `satisfies` (default). A
161
- third parameter allows for specifying a different `package.json`
162
- property to use for the comparison, e.g:
163
- `:semver(^22, satisfies, :attr(engines, [node]))` for comparing the
164
- value of `engines.node`.
165
- - `:type(registry|file|git|remote|workspace)` Matches packages based
166
- on their type, e.g, to retrieve all git dependencies: `:type(git)`.
167
-
168
- ### Pseudo Elements
169
-
170
- - `:project` Returns both the root node (as defined below) along with
171
- any workspace declared in your project.
172
- - `:root` Returns the root node, that represents the package defined
173
- at the top-level `package.json` of your project folder.
174
- - `:scope` Returns the current scope of a given selector
175
-
176
- ### Security Selectors
36
+ ```js
37
+ import { actual } from '@vltpkg/graph'
38
+ import { Query } from '@vltpkg/query'
39
+ import { PackageJson } from '@vltpkg/package-json'
40
+ import { PathScurry } from 'path-scurry'
41
+ const signal = new AbortController().signal
42
+ const projectRoot = process.cwd()
43
+ const scurry = new PathScurry(projectRoot)
44
+ const packageJson = new PackageJson()
45
+ const graph = await actual.load({ projectRoot, packageJson, scurry })
46
+ const query = new Query({ graph })
47
+ const res = await query.search(':root > *', { signal })
48
+ ```
177
49
 
178
- The following pseudo-selectors rely on security data provided by
179
- [Socket](https://socket.dev/), the usage of any of these selectors is
180
- going to require a network call to hydrate package report data. Keep
181
- in mind that this is going to slow down end-user query usage since the
182
- security data needs to be fetched prior to a `Query` instantiation.
50
+ ### Querying against a lockfile
183
51
 
184
- - `:abandoned` Matches packages that were published by an npm account
185
- that no longer exists.
186
- - `:confused` Matches packages affected by manifest confusion. This
187
- could be malicious or caused by an error when publishing the
188
- package.
189
- - `:cve(<id>)` Matches packages that have a CVE alert with the
190
- specified CVE ID. The ID parameter is required and should be a valid
191
- CVE identifier (e.g., `CVE-2023-1234`). This selector can be used to
192
- find packages affected by specific known vulnerabilities.
193
- - `:cwe(<id>)` Matches packages that have a CWE alert with the
194
- specified CWE ID. The ID parameter is required and should be a valid
195
- CWE identifier (e.g., `CWE-79`).
196
- - `:debug` Matches packages that use debug, reflection and dynamic
197
- code execution features.
198
- - `:deprecated` Matches packages marked as deprecated. This could
199
- indicate that a single version should not be used, or that the
200
- package is no longer maintained and any new vulnerabilities will not
201
- be fixed.
202
- - `:dynamic` Matches packages that uses dynamic imports.
203
- - `:entropic` Matches packages that contains high entropic strings.
204
- This could be a sign of encrypted data, leaked secrets or obfuscated
205
- code.
206
- - `:env` Matches packages that accesses environment variables, which
207
- may be a sign of credential stuffing or data theft.
208
- - `:eval` Matches packages that use dynamic code execution (e.g.,
209
- eval()), which is a dangerous practice. This can prevent the code
210
- from running in certain environments and increases the risk that the
211
- code may contain exploits or malicious behavior.
212
- - `:fs` Matches packages that accesses the file system, and could
213
- potentially read sensitive data.
214
- - `:license(<type>)` Matches packages based on different potential
215
- license issues:
216
- - `:license(unlicensed)` Matches packages with no license.
217
- - `:license(misc)` Matches packages with fine-grained problems.
218
- - `:license(restricted)` Matches packages with a license that is not
219
- permissive.
220
- - `:license(ambiguous)` Matches packages with ambiguous licensing.
221
- - `:license(copyleft)` Matches packages with a copyleft license.
222
- - `:license(unknown)` Matches packages that have potential license
223
- data but its type could not be determined.
224
- - `:license(none)` Matches packages that have no license data.
225
- - `:license(exception)` Matches packages that have SPDX license
226
- exception.
227
- - `:malware(<type>)` Matches packages that may contain malware. The
228
- type parameter is required and can be one of the following:
229
- - `critical` or `0`
230
- - `high` or `1`
231
- - `medium` or `2`
232
- - `low` or `3`
233
- - `:minified` Matches packages that contain minified code. This may be
234
- harmless in some cases where minified code is included in packaged
235
- libraries.
236
- - `:native` Matches packages that contain native code (e.g., compiled
237
- binaries or shared libraries). Including native code can obscure
238
- malicious behavior.
239
- - `:network` Matches packages that access the network.
240
- - `:obfuscated` Matches packages that use obfuscated files,
241
- intentionally packed to hide their behavior. This could be a sign of
242
- malware.
243
- - `:scanned` Matches packages that have insight security metadata.
244
- - `:score(<rate>, <kind>)` Matches packages based on their security
245
- score. The rate parameter is required and should be a value between
246
- 0 and 100 (or 0 and 1). The rate parameter can be prefixed with a
247
- comparator (`>`, `<`, `>=`, `<=`). If no comparator is provided, it
248
- will match exact scores. The kind parameter is optional and defaults
249
- to 'overall'. Valid kinds are: 'overall', 'license', 'maintenance',
250
- 'quality', 'supplyChain', and 'vulnerability'. Examples:
251
- - `:score(80)` - Matches packages with exactly 0.8 overall score
252
- - `:score(">0.8")` - Matches packages with overall score greater
253
- than 0.8
254
- - `:score("<=0.5", "maintenance")` - Matches packages with
255
- maintenance score less than or equal to 0.5
256
- - `:scripts` Matches packages that have scripts that are run when the
257
- package is installed. The majority of malware in npm is hidden in
258
- install scripts.
259
- - `:severity` Matches packages based of the severity level of any
260
- attached CVE. The type paremeter is required and can be one of the
261
- following:
262
- - `critical` or `0`
263
- - `high` or `1`
264
- - `medium` or `2`
265
- - `low` or `3`
266
- - `:shell` Matches packages that accesses the system shell. Accessing
267
- the system shell increases the risk of executing arbitrary code.
268
- - `:shrinkwrap` Matches packages that contains a shrinkwrap file. This
269
- may allow the package to bypass normal install procedures.
270
- - `:squat(<type>)` Matches packages with names similar to other
271
- popular packages and may not be the package you want. The type
272
- parameter is required and can be one of the following:
273
- - `critical` or `0`
274
- - `medium` or `2`
275
- - `:suspicious` Matches packages that may have its GitHub repository
276
- artificially inflated with stars (from bots, crowdsourcing, etc.).
277
- - `:tracker` Matches packages that contains telemetry which tracks how
278
- it is used.
279
- - `:trivial` Matches packages that have less than 10 lines of code.
280
- These packages are easily copied into your own project and may not
281
- warrant the additional supply chain risk of an external dependency.
282
- - `:undesirable` Matches packages that are a joke, parody, or includes
283
- undocumented or hidden behavior unrelated to its primary function.
284
- - `:unknown` Matches packages that have a new npm collaborator
285
- publishing a version of the package for the first time. New
286
- collaborators are usually benign additions to a project, but do
287
- indicate a change to the security surface area of a package.
288
- - `:unmaintained` Matches packages that have not been updated in more
289
- than 5 years and may be unmaintained.
290
- - `:unpopular` Matches packages that are not very popular.
291
- - `:unstable` Matches packages with unstable ownership. This indicates
292
- a new collaborator has begun publishing package versions. Package
293
- stability and security risk may be elevated.
52
+ ```js
53
+ import { lockfile } from '@vltpkg/graph'
54
+ import { Query } from '@vltpkg/query'
55
+ const signal = new AbortController().signal
56
+ const projectRoot = process.cwd()
57
+ const graph = await lockfile.load({
58
+ mainManifest: 'package.json',
59
+ projectRoot,
60
+ })
61
+ const query = new Query({ graph })
62
+ const res = await query.search(':root > *', { signal })
63
+ ```
@@ -1,4 +1,4 @@
1
- import type { NodeLike } from '@vltpkg/graph';
1
+ import type { NodeLike } from '@vltpkg/types';
2
2
  import type { ParserState } from './types.ts';
3
3
  export type ComparatorFn = (attr: string, value?: string) => boolean;
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["../../src/attribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;AAOpE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,SAC9B,QAAQ,cACF,MAAM,EAAE,aACT,MAAM,KAChB,MAAM,EAAE,GAAG,SA+Db,CAAA;AAID,eAAO,MAAM,gBAAgB,UACpB,WAAW,cACN,YAAY,GAAG,SAAS,SAC7B,MAAM,gBACC,MAAM,eACP,OAAO,qBACF,MAAM,EAAE,KACzB,WAgDF,CAAA;AAcD,eAAO,MAAM,qBAAqB,2BAEjC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,UACb,WAAW,KACjB,OAAO,CAAC,WAAW,CAyBrB,CAAA"}
1
+ {"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["../../src/attribute.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAuB,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;AAOpE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,SAC9B,QAAQ,cACF,MAAM,EAAE,aACT,MAAM,KAChB,MAAM,EAAE,GAAG,SA+Db,CAAA;AAID,eAAO,MAAM,gBAAgB,UACpB,WAAW,cACN,YAAY,GAAG,SAAS,SAC7B,MAAM,gBACC,MAAM,eACP,OAAO,qBACF,MAAM,EAAE,KACzB,WAsCF,CAAA;AAcD,eAAO,MAAM,qBAAqB,2BAEjC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,UACb,WAAW,KACjB,OAAO,CAAC,WAAW,CA6BrB,CAAA"}
@@ -1,5 +1,6 @@
1
+ import { asAttributeNode } from '@vltpkg/dss-parser';
1
2
  import { error } from '@vltpkg/error-cause';
2
- import { asAttributeNode } from "./types.js";
3
+ import { removeDanglingEdges } from "./pseudo/helpers.js";
3
4
  // JSONField has a mapped type constituent that would coerce to [object Object]
4
5
  // when stringified, which is what we want in this case.
5
6
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
@@ -93,17 +94,7 @@ export const filterAttributes = (state, comparator, value, propertyName, insensi
93
94
  deleteNode(node);
94
95
  }
95
96
  }
96
- for (const edge of state.partial.edges) {
97
- // edge.name is a special case in order
98
- // to be able to match missing nodes by name
99
- if (propertyName === 'name' && check(edge.name)) {
100
- continue;
101
- }
102
- // remove any remaining dangling edge
103
- if (!edge.to) {
104
- state.partial.edges.delete(edge);
105
- }
106
- }
97
+ removeDanglingEdges(state);
107
98
  return state;
108
99
  };
109
100
  // ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
@@ -135,6 +126,8 @@ export const attribute = async (state) => {
135
126
  const value = curr.value || '';
136
127
  const propertyName = curr.attribute;
137
128
  const insensitive = !!curr.insensitive;
129
+ // Increment the commonCounter for specificity
130
+ state.specificity.commonCounter += 1;
138
131
  return filterAttributes(state, operatorFn, value, propertyName, insensitive);
139
132
  };
140
133
  //# sourceMappingURL=attribute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../src/attribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAK5C,+EAA+E;AAC/E,wDAAwD;AACxD,gEAAgE;AAChE,MAAM,iBAAiB,GAAG,CAAC,CAAY,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,IAAc,EACd,UAAoB,EACpB,SAAiB,EACK,EAAE;IACxB,IAAI,CAAC,IAAI,CAAC,QAAQ;QAAE,OAAM;IAE1B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAY,CAAC,IAAI,CAAC,QAAqB,CAAC,CAAC,CAAA;IACjE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAa,CAAA;IAClC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,4CAA4C;YAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,KAAK,CAAC,y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Like } from '@vltpkg/graph'\nimport type { JSONField, Manifest } from '@vltpkg/types'\nimport { asAttributeNode } from './types.ts'\nimport type { ParserState } from './types.ts'\n\nexport type ComparatorFn = (attr: string, value?: string) => boolean\n\n// JSONField has a mapped type constituent that would coerce to [object Object]\n// when stringified, which is what we want in this case.\n// eslint-disable-next-line @typescript-eslint/no-base-to-string\nconst jsonFieldToString = (v: JSONField) => String(v)\n\n/**\n * Retrieve the {@link Manifest} values found at the given `properties`\n * location for a given {@link Node}.\n */\nexport const getManifestPropertyValues = (\n node: NodeLike,\n properties: string[],\n attribute: string,\n): string[] | undefined => {\n if (!node.manifest) return\n\n const traverse = new Set<JSONField>([node.manifest as JSONField])\n const props = new Set<JSONField>()\n for (const key of properties) {\n for (const prop of traverse) {\n /* c8 ignore start - should be impossible */\n if (!prop) {\n throw error('failed to find nested property in :attr', {\n found: properties,\n })\n }\n /* c8 ignore stop */\n\n // expand the result list to include nested array values\n if (Array.isArray(prop)) {\n for (const p of prop) {\n traverse.add(p)\n }\n continue\n }\n\n // guard for inspecting keys of objects next\n if (\n typeof prop === 'string' ||\n typeof prop === 'number' ||\n typeof prop === 'boolean'\n ) {\n continue\n }\n\n // assign next value when found\n if (key in prop) {\n const nextValue = prop[key]\n if (nextValue) {\n if (key === attribute) {\n props.add(nextValue)\n } else {\n traverse.delete(prop)\n traverse.add(nextValue)\n }\n }\n }\n }\n }\n // if no value was found after trying a given key\n // then there's nothing to be collected\n if (!props.size) return\n\n // expand the result to include array values\n const collect = new Set<string>()\n for (const prop of props) {\n if (Array.isArray(prop)) {\n for (const p of prop) {\n collect.add(p ? jsonFieldToString(p) : '')\n }\n } else {\n collect.add(jsonFieldToString(prop))\n }\n }\n\n return [...collect]\n}\n\n// decorator style of function that will filter `ParserState` results\n// based on a provided `comparator` function\nexport const filterAttributes = (\n state: ParserState,\n comparator: ComparatorFn | undefined,\n value: string,\n propertyName: string,\n insensitive: boolean,\n prefixProperties: string[] = [],\n): ParserState => {\n const check = (attr: JSONField) =>\n comparator?.(\n insensitive ?\n jsonFieldToString(attr).toLowerCase()\n : jsonFieldToString(attr),\n insensitive ? value.toLowerCase() : value,\n )\n const deleteNode = (node: NodeLike) => {\n for (const edge of node.edgesIn) {\n state.partial.edges.delete(edge)\n }\n state.partial.nodes.delete(node)\n }\n\n for (const node of state.partial.nodes) {\n const prefixes =\n prefixProperties.length ? prefixProperties : [propertyName]\n const attrs = getManifestPropertyValues(\n node,\n prefixes,\n propertyName,\n )\n\n // if no attribute value was found, that means the attribute won't match\n if (!attrs?.length) {\n deleteNode(node)\n continue\n }\n\n // if the node attribute value won't match, then remove the node\n if (comparator && !attrs.some(check)) {\n deleteNode(node)\n }\n }\n\n for (const edge of state.partial.edges) {\n // edge.name is a special case in order\n // to be able to match missing nodes by name\n if (propertyName === 'name' && check(edge.name)) {\n continue\n }\n // remove any remaining dangling edge\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n return state\n}\n\n// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors\nconst attributeSelectors: Record<string, ComparatorFn> = {\n '=': (attr: string, value = '') => attr === value,\n '^=': (attr: string, value = '') => attr.startsWith(value),\n '$=': (attr: string, value = '') => attr.endsWith(value),\n '~=': (attr: string, value = '') =>\n new Set<string>(attr.match(/\\w+/g)).has(value),\n '*=': (attr: string, value = '') => attr.includes(value),\n '|=': (attr: string, value = '') =>\n attr === value || attr.startsWith(`${value}-`),\n undefined: (attr: string) => !!attr,\n}\nexport const attributeSelectorsMap = new Map<string, ComparatorFn>(\n Object.entries(attributeSelectors),\n)\n\n/**\n * Parse attributes selectors, e.g: `[name]`, `[name=value]`, etc\n */\nexport const attribute = async (\n state: ParserState,\n): Promise<ParserState> => {\n await state.cancellable()\n\n const curr = asAttributeNode(state.current)\n const operatorFn = attributeSelectorsMap.get(String(curr.operator))\n if (!operatorFn) {\n if (state.loose) {\n return state\n }\n\n throw error(`Unsupported attribute operator: ${curr.operator}`, {\n found: state.current,\n })\n }\n\n const value = curr.value || ''\n const propertyName = curr.attribute\n const insensitive = !!curr.insensitive\n return filterAttributes(\n state,\n operatorFn,\n value,\n propertyName,\n insensitive,\n )\n}\n"]}
1
+ {"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../src/attribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAMzD,+EAA+E;AAC/E,wDAAwD;AACxD,gEAAgE;AAChE,MAAM,iBAAiB,GAAG,CAAC,CAAY,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,IAAc,EACd,UAAoB,EACpB,SAAiB,EACK,EAAE;IACxB,IAAI,CAAC,IAAI,CAAC,QAAQ;QAAE,OAAM;IAE1B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAY,CAAC,IAAI,CAAC,QAAqB,CAAC,CAAC,CAAA;IACjE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAa,CAAA;IAClC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,4CAA4C;YAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,KAAK,CAAC,yCAAyC,EAAE;oBACrD,KAAK,EAAE,UAAU;iBAClB,CAAC,CAAA;YACJ,CAAC;YACD,oBAAoB;YAEpB,wDAAwD;YACxD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;oBACrB,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;gBACjB,CAAC;gBACD,SAAQ;YACV,CAAC;YAED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AAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;IACnE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,KAAK,CAAC,mCAAmC,IAAI,CAAC,QAAQ,EAAE,EAAE;YAC9D,KAAK,EAAE,KAAK,CAAC,OAAO;SACrB,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;IAC9B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAA;IACnC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAA;IAEtC,8CAA8C;IAC9C,KAAK,CAAC,WAAW,CAAC,aAAa,IAAI,CAAC,CAAA;IAEpC,OAAO,gBAAgB,CACrB,KAAK,EACL,UAAU,EACV,KAAK,EACL,YAAY,EACZ,WAAW,CACZ,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { asAttributeNode } from '@vltpkg/dss-parser'\nimport { error } from '@vltpkg/error-cause'\nimport { removeDanglingEdges } from './pseudo/helpers.ts'\nimport type { NodeLike, JSONField, Manifest } from '@vltpkg/types'\nimport type { ParserState } from './types.ts'\n\nexport type ComparatorFn = (attr: string, value?: string) => boolean\n\n// JSONField has a mapped type constituent that would coerce to [object Object]\n// when stringified, which is what we want in this case.\n// eslint-disable-next-line @typescript-eslint/no-base-to-string\nconst jsonFieldToString = (v: JSONField) => String(v)\n\n/**\n * Retrieve the {@link Manifest} values found at the given `properties`\n * location for a given {@link Node}.\n */\nexport const getManifestPropertyValues = (\n node: NodeLike,\n properties: string[],\n attribute: string,\n): string[] | undefined => {\n if (!node.manifest) return\n\n const traverse = new Set<JSONField>([node.manifest as JSONField])\n const props = new Set<JSONField>()\n for (const key of properties) {\n for (const prop of traverse) {\n /* c8 ignore start - should be impossible */\n if (!prop) {\n throw error('failed to find nested property in :attr', {\n found: properties,\n })\n }\n /* c8 ignore stop */\n\n // expand the result list to include nested array values\n if (Array.isArray(prop)) {\n for (const p of prop) {\n traverse.add(p)\n }\n continue\n }\n\n // guard for inspecting keys of objects next\n if (\n typeof prop === 'string' ||\n typeof prop === 'number' ||\n typeof prop === 'boolean'\n ) {\n continue\n }\n\n // assign next value when found\n if (key in prop) {\n const nextValue = prop[key]\n if (nextValue) {\n if (key === attribute) {\n props.add(nextValue)\n } else {\n traverse.delete(prop)\n traverse.add(nextValue)\n }\n }\n }\n }\n }\n // if no value was found after trying a given key\n // then there's nothing to be collected\n if (!props.size) return\n\n // expand the result to include array values\n const collect = new Set<string>()\n for (const prop of props) {\n if (Array.isArray(prop)) {\n for (const p of prop) {\n collect.add(p ? jsonFieldToString(p) : '')\n }\n } else {\n collect.add(jsonFieldToString(prop))\n }\n }\n\n return [...collect]\n}\n\n// decorator style of function that will filter `ParserState` results\n// based on a provided `comparator` function\nexport const filterAttributes = (\n state: ParserState,\n comparator: ComparatorFn | undefined,\n value: string,\n propertyName: string,\n insensitive: boolean,\n prefixProperties: string[] = [],\n): ParserState => {\n const check = (attr: JSONField) =>\n comparator?.(\n insensitive ?\n jsonFieldToString(attr).toLowerCase()\n : jsonFieldToString(attr),\n insensitive ? value.toLowerCase() : value,\n )\n const deleteNode = (node: NodeLike) => {\n for (const edge of node.edgesIn) {\n state.partial.edges.delete(edge)\n }\n state.partial.nodes.delete(node)\n }\n\n for (const node of state.partial.nodes) {\n const prefixes =\n prefixProperties.length ? prefixProperties : [propertyName]\n const attrs = getManifestPropertyValues(\n node,\n prefixes,\n propertyName,\n )\n\n // if no attribute value was found, that means the attribute won't match\n if (!attrs?.length) {\n deleteNode(node)\n continue\n }\n\n // if the node attribute value won't match, then remove the node\n if (comparator && !attrs.some(check)) {\n deleteNode(node)\n }\n }\n\n removeDanglingEdges(state)\n return state\n}\n\n// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors\nconst attributeSelectors: Record<string, ComparatorFn> = {\n '=': (attr: string, value = '') => attr === value,\n '^=': (attr: string, value = '') => attr.startsWith(value),\n '$=': (attr: string, value = '') => attr.endsWith(value),\n '~=': (attr: string, value = '') =>\n new Set<string>(attr.match(/\\w+/g)).has(value),\n '*=': (attr: string, value = '') => attr.includes(value),\n '|=': (attr: string, value = '') =>\n attr === value || attr.startsWith(`${value}-`),\n undefined: (attr: string) => !!attr,\n}\nexport const attributeSelectorsMap = new Map<string, ComparatorFn>(\n Object.entries(attributeSelectors),\n)\n\n/**\n * Parse attributes selectors, e.g: `[name]`, `[name=value]`, etc\n */\nexport const attribute = async (\n state: ParserState,\n): Promise<ParserState> => {\n await state.cancellable()\n\n const curr = asAttributeNode(state.current)\n const operatorFn = attributeSelectorsMap.get(String(curr.operator))\n if (!operatorFn) {\n if (state.loose) {\n return state\n }\n\n throw error(`Unsupported attribute operator: ${curr.operator}`, {\n found: state.current,\n })\n }\n\n const value = curr.value || ''\n const propertyName = curr.attribute\n const insensitive = !!curr.insensitive\n\n // Increment the commonCounter for specificity\n state.specificity.commonCounter += 1\n\n return filterAttributes(\n state,\n operatorFn,\n value,\n propertyName,\n insensitive,\n )\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"combinator.d.ts","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,YAAY,CAAA;AA8GvD;;GAEG;AACH,eAAO,MAAM,UAAU,UAAiB,WAAW,yBAgBlD,CAAA"}
1
+ {"version":3,"file":"combinator.d.ts","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,YAAY,CAAA;AA6GvD;;GAEG;AACH,eAAO,MAAM,UAAU,UAAiB,WAAW,yBAgBlD,CAAA"}
@@ -1,4 +1,4 @@
1
- import { asCombinatorNode } from "./types.js";
1
+ import { asCombinatorNode } from '@vltpkg/dss-parser';
2
2
  import { error } from '@vltpkg/error-cause';
3
3
  /**
4
4
  * Returns a new set of nodes, containing all direct dependencies
@@ -1 +1 @@
1
- {"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,eAAe,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACnD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAE3B,qDAAqD;IACrD,uDAAuD;IACvD,kBAAkB;IAClB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBAC7B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,2BAA2B,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,KAAK,CAAC,OAAO,CAAC,KAA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AC,OAAO;SACrB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport { asCombinatorNode } from './types.ts'\nimport type { ParserState, ParserFn } from './types.ts'\nimport { error } from '@vltpkg/error-cause'\n\n/**\n * Returns a new set of nodes, containing all direct dependencies\n * of the current list of nodes used.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator\n */\nconst childCombinator = async (state: ParserState) => {\n const traverse = new Set(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // visit direct children of the current list of nodes\n // collecting refs to these children and the edges that\n // connected them.\n for (const node of traverse) {\n for (const edge of node.edgesOut.values()) {\n if (edge.to) {\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n }\n\n return state\n}\n\n/**\n * Returns a new set of nodes, containing nodes that are also children\n * of all parent nodes to the current list of nodes used.\n *\n * Note: The subsequent-sibling comparator has a behavior that is\n * somehow approximative of that of its css counterpart, given that\n * in the context of dependency graphs the order of appearance is\n * not necessarily controlled by the end user. The approach for\n * this comparator is to match all siblings of a node.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Subsequent-sibling_combinator\n */\nconst subsequentSiblingCombinator = async (state: ParserState) => {\n const traverse = new Set(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // visits direct parents of the current list of node and then\n // visit their children, collecting refs to all children and edges\n // that are not in the original list of nodes.\n for (const node of traverse) {\n for (const edge of node.edgesIn) {\n const parents: IterableIterator<EdgeLike> =\n edge.from.edgesOut.values()\n for (const edge of parents) {\n if (edge.to && edge.to !== node) {\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n }\n }\n\n return state\n}\n\n/**\n * Returns a new set of nodes containing all nodes that are descendents\n * to items in the current list of nodes.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator\n */\nconst descendentCombinator = async (state: ParserState) => {\n // spaces between tags selectors are a noop\n if (state.prev?.type === 'tag' || state.next?.type === 'tag') {\n return state\n }\n\n const traverse = new Set<NodeLike>(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // breadth-first traversal of the graph, starting from the current\n // list of nodes, collecting all nodes and edges along the way\n for (const node of traverse) {\n const children = new Set<NodeLike>()\n for (const edge of node.edgesOut.values()) {\n if (edge.to) {\n children.add(edge.to)\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n for (const child of children) {\n traverse.add(child)\n }\n }\n\n return state\n}\n\nconst combinatorSelectors = {\n '>': childCombinator,\n '~': subsequentSiblingCombinator,\n ' ': descendentCombinator,\n}\n\nconst combinatorSelectorsMap = new Map<string, ParserFn>(\n Object.entries(combinatorSelectors),\n)\n\n/**\n * Parse css-style combinators, e.g: `>`, `~` and ` `\n */\nexport const combinator = async (state: ParserState) => {\n await state.cancellable()\n\n const curr = asCombinatorNode(state.current)\n const parserFn =\n curr.value && combinatorSelectorsMap.get(curr.value)\n if (!parserFn) {\n if (state.loose) {\n return state\n }\n\n throw error(`Unsupported combinator: ${state.current.value}`, {\n found: state.current,\n })\n }\n return parserFn(state)\n}\n"]}
1
+ {"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C;;;;;GAKG;AACH,MAAM,eAAe,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACnD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,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ACd,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG;IAC1B,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,2BAA2B;IAChC,GAAG,EAAE,oBAAoB;CAC1B,CAAA;AAED,MAAM,sBAAsB,GAAG,IAAI,GAAG,CACpC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CACpC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACrD,MAAM,KAAK,CAAC,WAAW,EAAE,CAAA;IAEzB,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5C,MAAM,QAAQ,GACZ,IAAI,CAAC,KAAK,IAAI,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE;YAC5D,KAAK,EAAE,KAAK,CAAC,OAAO;SACrB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import { asCombinatorNode } from '@vltpkg/dss-parser'\nimport { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/types'\nimport type { ParserState, ParserFn } from './types.ts'\n\n/**\n * Returns a new set of nodes, containing all direct dependencies\n * of the current list of nodes used.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator\n */\nconst childCombinator = async (state: ParserState) => {\n const traverse = new Set(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // visit direct children of the current list of nodes\n // collecting refs to these children and the edges that\n // connected them.\n for (const node of traverse) {\n for (const edge of node.edgesOut.values()) {\n if (edge.to) {\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n }\n\n return state\n}\n\n/**\n * Returns a new set of nodes, containing nodes that are also children\n * of all parent nodes to the current list of nodes used.\n *\n * Note: The subsequent-sibling comparator has a behavior that is\n * somehow approximative of that of its css counterpart, given that\n * in the context of dependency graphs the order of appearance is\n * not necessarily controlled by the end user. The approach for\n * this comparator is to match all siblings of a node.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Subsequent-sibling_combinator\n */\nconst subsequentSiblingCombinator = async (state: ParserState) => {\n const traverse = new Set(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // visits direct parents of the current list of node and then\n // visit their children, collecting refs to all children and edges\n // that are not in the original list of nodes.\n for (const node of traverse) {\n for (const edge of node.edgesIn) {\n const parents: IterableIterator<EdgeLike> =\n edge.from.edgesOut.values()\n for (const edge of parents) {\n if (edge.to && edge.to !== node) {\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n }\n }\n\n return state\n}\n\n/**\n * Returns a new set of nodes containing all nodes that are descendents\n * to items in the current list of nodes.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator\n */\nconst descendentCombinator = async (state: ParserState) => {\n // spaces between tags selectors are a noop\n if (state.prev?.type === 'tag' || state.next?.type === 'tag') {\n return state\n }\n\n const traverse = new Set<NodeLike>(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // breadth-first traversal of the graph, starting from the current\n // list of nodes, collecting all nodes and edges along the way\n for (const node of traverse) {\n const children = new Set<NodeLike>()\n for (const edge of node.edgesOut.values()) {\n if (edge.to) {\n children.add(edge.to)\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n for (const child of children) {\n traverse.add(child)\n }\n }\n\n return state\n}\n\nconst combinatorSelectors = {\n '>': childCombinator,\n '~': subsequentSiblingCombinator,\n ' ': descendentCombinator,\n}\n\nconst combinatorSelectorsMap = new Map<string, ParserFn>(\n Object.entries(combinatorSelectors),\n)\n\n/**\n * Parse css-style combinators, e.g: `>`, `~` and ` `\n */\nexport const combinator = async (state: ParserState) => {\n await state.cancellable()\n\n const curr = asCombinatorNode(state.current)\n const parserFn =\n curr.value && combinatorSelectorsMap.get(curr.value)\n if (!parserFn) {\n if (state.loose) {\n return state\n }\n\n throw error(`Unsupported combinator: ${state.current.value}`, {\n found: state.current,\n })\n }\n return parserFn(state)\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,EAAE,UACN,WAAW,KACjB,OAAO,CAAC,WAAW,CAiCrB,CAAA"}
1
+ {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,EAAE,UACN,WAAW,KACjB,OAAO,CAAC,WAAW,CAoCrB,CAAA"}
package/dist/esm/id.js CHANGED
@@ -1,5 +1,5 @@
1
+ import { asIdentifierNode } from '@vltpkg/dss-parser';
1
2
  import { error } from '@vltpkg/error-cause';
2
- import { asIdentifierNode } from "./types.js";
3
3
  /**
4
4
  * Parse ids, e.g: `#foo`
5
5
  */
@@ -29,6 +29,8 @@ export const id = async (state) => {
29
29
  state.partial.nodes.delete(node);
30
30
  }
31
31
  }
32
+ // Increment the idCounter for specificity
33
+ state.specificity.idCounter += 1;
32
34
  return state;
33
35
  };
34
36
  //# sourceMappingURL=id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAG7C;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,EACrB,KAAkB,EACI,EAAE;IACxB,MAAM,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAEjD,8CAA8C;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAA;IACxC,CAAC;IACD,oBAAoB;IAEpB,wCAAwC;IACxC,yCAAyC;IACzC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAChC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,yDAAyD;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IACE,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;YACvB,IAAI,CAAC,IAAI,KAAK,KAAK;YACnB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAC7B,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { asIdentifierNode } from './types.ts'\nimport type { ParserState } from './types.ts'\n\n/**\n * Parse ids, e.g: `#foo`\n */\nexport const id = async (\n state: ParserState,\n): Promise<ParserState> => {\n const { value } = asIdentifierNode(state.current)\n\n /* c8 ignore start - should not be possible */\n if (!value) {\n throw error('Missing identifier name')\n }\n /* c8 ignore stop */\n\n // Filter out any edges and their linked\n // nodes if they don't match the id value\n for (const edge of state.partial.edges) {\n if (edge.name !== value) {\n state.partial.edges.delete(edge)\n if (edge.to) {\n state.partial.nodes.delete(edge.to)\n }\n }\n }\n\n // Filter out importer nodes, this extra step is needed\n // to filter out nodes that have no edges linking to them\n for (const node of state.partial.nodes) {\n if (\n node.edgesIn.size === 0 &&\n node.name !== value &&\n state.partial.nodes.has(node)\n ) {\n state.partial.nodes.delete(node)\n }\n }\n\n return state\n}\n"]}
1
+ {"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,EACrB,KAAkB,EACI,EAAE;IACxB,MAAM,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAEjD,8CAA8C;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAA;IACxC,CAAC;IACD,oBAAoB;IAEpB,wCAAwC;IACxC,yCAAyC;IACzC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAChC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,yDAAyD;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IACE,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;YACvB,IAAI,CAAC,IAAI,KAAK,KAAK;YACnB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAC7B,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;IAED,0CAA0C;IAC1C,KAAK,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,CAAA;IAEhC,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asIdentifierNode } from '@vltpkg/dss-parser'\nimport { error } from '@vltpkg/error-cause'\nimport type { ParserState } from './types.ts'\n\n/**\n * Parse ids, e.g: `#foo`\n */\nexport const id = async (\n state: ParserState,\n): Promise<ParserState> => {\n const { value } = asIdentifierNode(state.current)\n\n /* c8 ignore start - should not be possible */\n if (!value) {\n throw error('Missing identifier name')\n }\n /* c8 ignore stop */\n\n // Filter out any edges and their linked\n // nodes if they don't match the id value\n for (const edge of state.partial.edges) {\n if (edge.name !== value) {\n state.partial.edges.delete(edge)\n if (edge.to) {\n state.partial.nodes.delete(edge.to)\n }\n }\n }\n\n // Filter out importer nodes, this extra step is needed\n // to filter out nodes that have no edges linking to them\n for (const node of state.partial.nodes) {\n if (\n node.edgesIn.size === 0 &&\n node.name !== value &&\n state.partial.nodes.has(node)\n ) {\n state.partial.nodes.delete(node)\n }\n }\n\n // Increment the idCounter for specificity\n state.specificity.idCounter += 1\n\n return state\n}\n"]}
@@ -1,15 +1,25 @@
1
- import type { GraphLike } from '@vltpkg/graph';
2
- import type { SpecOptions } from '@vltpkg/spec/browser';
1
+ import type { EdgeLike, NodeLike } from '@vltpkg/types';
3
2
  import type { SecurityArchiveLike } from '@vltpkg/security-archive';
4
- import type { ParsedSelectorToken, ParserState, QueryResponse } from './types.ts';
3
+ import type { HostContextsMap, ParsedSelectorToken, ParserState, QueryResponse } from './types.ts';
4
+ import type { DepID } from '@vltpkg/dep-id';
5
5
  export * from './types.ts';
6
+ export type SearchOptions = {
7
+ signal: AbortSignal;
8
+ scopeIDs?: DepID[];
9
+ };
6
10
  export declare const walk: (state: ParserState) => Promise<ParserState>;
7
11
  export type QueryOptions = {
8
- graph: GraphLike;
12
+ edges: Set<EdgeLike>;
13
+ nodes: Set<NodeLike>;
14
+ importers: Set<NodeLike>;
9
15
  retries?: number;
10
- specOptions: SpecOptions;
11
16
  securityArchive: SecurityArchiveLike | undefined;
17
+ hostContexts?: HostContextsMap;
12
18
  };
19
+ /**
20
+ * The Query class is used to search the graph for nodes and edges
21
+ * using the Dependency Selector Syntax (DSS).
22
+ */
13
23
  export declare class Query {
14
24
  #private;
15
25
  /**
@@ -18,11 +28,18 @@ export declare class Query {
18
28
  * skip hydrating the security archive if it's not needed.
19
29
  */
20
30
  static hasSecuritySelectors(query: string): boolean;
21
- constructor({ graph, retries, specOptions, securityArchive, }: QueryOptions);
31
+ /**
32
+ * Sorts an array of QueryResponse objects by specificity. Objects with
33
+ * higher idCounter values come first, if idCounter values are equal,
34
+ * then objects with higher commonCounter values come first. Otherwise,
35
+ * the original order is preserved.
36
+ */
37
+ static specificitySort(responses: QueryResponse[]): QueryResponse[];
38
+ constructor({ edges, nodes, importers, retries, securityArchive, hostContexts, }: QueryOptions);
22
39
  /**
23
40
  * Search the graph for nodes and edges that match the given query.
24
41
  */
25
- search(query: string, signal?: AbortSignal): Promise<QueryResponse>;
42
+ search(query: string, { signal, scopeIDs, }: SearchOptions): Promise<QueryResponse>;
26
43
  /**
27
44
  * Parses a query string in order to retrieve an array of tokens.
28
45
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"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