@vltpkg/query 0.0.0-11 → 0.0.0-13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/attribute.d.ts.map +1 -1
- package/dist/esm/attribute.js +4 -11
- package/dist/esm/attribute.js.map +1 -1
- package/dist/esm/id.d.ts.map +1 -1
- package/dist/esm/id.js +2 -0
- package/dist/esm/id.js.map +1 -1
- package/dist/esm/index.d.ts +69 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +209 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pseudo/outdated.d.ts.map +1 -1
- package/dist/esm/pseudo/outdated.js +3 -3
- package/dist/esm/pseudo/outdated.js.map +1 -1
- package/dist/esm/pseudo/published.d.ts.map +1 -1
- package/dist/esm/pseudo/published.js +1 -2
- package/dist/esm/pseudo/published.js.map +1 -1
- package/dist/esm/pseudo/root.d.ts +8 -0
- package/dist/esm/pseudo/root.d.ts.map +1 -0
- package/dist/esm/pseudo/root.js +22 -0
- package/dist/esm/pseudo/root.js.map +1 -0
- package/dist/esm/pseudo/semver.d.ts.map +1 -1
- package/dist/esm/pseudo/semver.js +2 -1
- package/dist/esm/pseudo/semver.js.map +1 -1
- package/dist/esm/pseudo/type.d.ts +8 -0
- package/dist/esm/pseudo/type.d.ts.map +1 -0
- package/dist/esm/pseudo/type.js +22 -0
- package/dist/esm/pseudo/type.js.map +1 -0
- package/dist/esm/pseudo/workspace.d.ts.map +1 -1
- package/dist/esm/pseudo/workspace.js +5 -2
- package/dist/esm/pseudo/workspace.js.map +1 -1
- package/dist/esm/pseudo.d.ts.map +1 -1
- package/dist/esm/pseudo.js +32 -44
- package/dist/esm/pseudo.js.map +1 -1
- package/dist/esm/types.d.ts +13 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +13 -0
- package/dist/esm/types.js.map +1 -1
- package/package.json +8 -8
package/dist/esm/pseudo.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { splitDepID } from '@vltpkg/dep-id/browser';
|
|
2
1
|
import { error } from '@vltpkg/error-cause';
|
|
3
2
|
import { removeDanglingEdges, removeNode } from "./pseudo/helpers.js";
|
|
4
|
-
import { asPostcssNodeWithChildren, asPseudoNode,
|
|
3
|
+
import { asPostcssNodeWithChildren, asPseudoNode, isSelectorNode, } from "./types.js";
|
|
5
4
|
// imported pseudo selectors
|
|
6
5
|
import { abandoned } from "./pseudo/abandoned.js";
|
|
7
6
|
import { attr } from "./pseudo/attr.js";
|
|
@@ -31,6 +30,7 @@ import { peer } from "./pseudo/peer.js";
|
|
|
31
30
|
import { published } from "./pseudo/published.js";
|
|
32
31
|
import { privateParser } from "./pseudo/private.js";
|
|
33
32
|
import { prod } from "./pseudo/prod.js";
|
|
33
|
+
import { root } from "./pseudo/root.js";
|
|
34
34
|
import { scanned } from "./pseudo/scanned.js";
|
|
35
35
|
import { score } from "./pseudo/score.js";
|
|
36
36
|
import { scripts } from "./pseudo/scripts.js";
|
|
@@ -42,6 +42,7 @@ import { squat } from "./pseudo/squat.js";
|
|
|
42
42
|
import { suspicious } from "./pseudo/suspicious.js";
|
|
43
43
|
import { tracker } from "./pseudo/tracker.js";
|
|
44
44
|
import { trivial } from "./pseudo/trivial.js";
|
|
45
|
+
import { type } from "./pseudo/type.js";
|
|
45
46
|
import { undesirable } from "./pseudo/undesirable.js";
|
|
46
47
|
import { unknown } from "./pseudo/unknown.js";
|
|
47
48
|
import { unmaintained } from "./pseudo/unmaintained.js";
|
|
@@ -77,6 +78,10 @@ const has = async (state) => {
|
|
|
77
78
|
retries: state.retries,
|
|
78
79
|
securityArchive: state.securityArchive,
|
|
79
80
|
specOptions: state.specOptions,
|
|
81
|
+
signal: state.signal,
|
|
82
|
+
scopeIDs: state.scopeIDs,
|
|
83
|
+
comment: state.comment,
|
|
84
|
+
specificity: { ...state.specificity },
|
|
80
85
|
});
|
|
81
86
|
for (const n of nestedState.collect.nodes) {
|
|
82
87
|
collectNodes.add(n);
|
|
@@ -153,6 +158,10 @@ const is = async (state) => {
|
|
|
153
158
|
retries: state.retries,
|
|
154
159
|
securityArchive: state.securityArchive,
|
|
155
160
|
specOptions: state.specOptions,
|
|
161
|
+
signal: state.signal,
|
|
162
|
+
scopeIDs: state.scopeIDs,
|
|
163
|
+
comment: state.comment,
|
|
164
|
+
specificity: { ...state.specificity },
|
|
156
165
|
});
|
|
157
166
|
for (const n of nestedState.collect.nodes) {
|
|
158
167
|
collect.add(n);
|
|
@@ -192,6 +201,10 @@ const not = async (state) => {
|
|
|
192
201
|
retries: state.retries,
|
|
193
202
|
securityArchive: state.securityArchive,
|
|
194
203
|
specOptions: state.specOptions,
|
|
204
|
+
signal: state.signal,
|
|
205
|
+
scopeIDs: state.scopeIDs,
|
|
206
|
+
comment: state.comment,
|
|
207
|
+
specificity: { ...state.specificity },
|
|
195
208
|
});
|
|
196
209
|
for (const n of nestedState.collect.nodes) {
|
|
197
210
|
collect.add(n);
|
|
@@ -213,24 +226,6 @@ const not = async (state) => {
|
|
|
213
226
|
}
|
|
214
227
|
return state;
|
|
215
228
|
};
|
|
216
|
-
/**
|
|
217
|
-
* :root Pseudo-Element will return the project root node for the graph.
|
|
218
|
-
*/
|
|
219
|
-
const root = async (state) => {
|
|
220
|
-
const [anyNode] = state.initial.nodes.values();
|
|
221
|
-
const mainImporter = anyNode?.graph.mainImporter;
|
|
222
|
-
if (!mainImporter) {
|
|
223
|
-
throw error(':root pseudo-element works on local graphs only');
|
|
224
|
-
}
|
|
225
|
-
for (const edge of state.partial.edges) {
|
|
226
|
-
if (edge.to !== mainImporter) {
|
|
227
|
-
state.partial.edges.delete(edge);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
state.partial.nodes.clear();
|
|
231
|
-
state.partial.nodes.add(mainImporter);
|
|
232
|
-
return state;
|
|
233
|
-
};
|
|
234
229
|
/**
|
|
235
230
|
* :project Pseudo-Class, matches only graph importers (e.g: the
|
|
236
231
|
* root node along with any configured workspace)
|
|
@@ -249,34 +244,17 @@ const project = async (state) => {
|
|
|
249
244
|
return state;
|
|
250
245
|
};
|
|
251
246
|
/**
|
|
252
|
-
* :scope Pseudo-Element, returns the
|
|
253
|
-
*
|
|
247
|
+
* :scope Pseudo-Element, returns only the nodes that match the provided scopeIDs
|
|
248
|
+
* from the Query.search method.
|
|
254
249
|
*/
|
|
255
250
|
const scope = async (state) => {
|
|
256
|
-
state.
|
|
257
|
-
state.partial.nodes.clear();
|
|
258
|
-
for (const edge of state.initial.edges) {
|
|
259
|
-
state.partial.edges.add(edge);
|
|
260
|
-
}
|
|
261
|
-
for (const node of state.initial.nodes) {
|
|
262
|
-
state.partial.nodes.add(node);
|
|
263
|
-
}
|
|
264
|
-
return state;
|
|
265
|
-
};
|
|
266
|
-
/**
|
|
267
|
-
* :type(str) Pseudo-Element will match only nodes that are of
|
|
268
|
-
* the same type as the value used
|
|
269
|
-
*/
|
|
270
|
-
const typeFn = async (state) => {
|
|
271
|
-
const type = asPostcssNodeWithChildren(state.current);
|
|
272
|
-
const selector = asPostcssNodeWithChildren(type.nodes[0]);
|
|
273
|
-
const name = asTagNode(selector.nodes[0]).value;
|
|
251
|
+
const scopeIDSet = new Set(state.scopeIDs);
|
|
274
252
|
for (const node of state.partial.nodes) {
|
|
275
|
-
|
|
276
|
-
if (nodeType !== name) {
|
|
253
|
+
if (!scopeIDSet.has(node.id)) {
|
|
277
254
|
removeNode(state, node);
|
|
278
255
|
}
|
|
279
256
|
}
|
|
257
|
+
removeDanglingEdges(state);
|
|
280
258
|
return state;
|
|
281
259
|
};
|
|
282
260
|
const pseudoSelectors = new Map(Object.entries({
|
|
@@ -327,7 +305,7 @@ const pseudoSelectors = new Map(Object.entries({
|
|
|
327
305
|
suspicious,
|
|
328
306
|
tracker,
|
|
329
307
|
trivial,
|
|
330
|
-
type
|
|
308
|
+
type,
|
|
331
309
|
undesirable,
|
|
332
310
|
unknown,
|
|
333
311
|
unmaintained,
|
|
@@ -353,6 +331,16 @@ export const pseudo = async (state) => {
|
|
|
353
331
|
found: state.current,
|
|
354
332
|
});
|
|
355
333
|
}
|
|
356
|
-
|
|
334
|
+
const result = await parserFn(state);
|
|
335
|
+
// Increment the commonCounter for specificity, except for
|
|
336
|
+
// nesting selectors which don't contribute to specificity
|
|
337
|
+
const pseudoValue = curr.value.slice(1);
|
|
338
|
+
if (pseudoValue &&
|
|
339
|
+
pseudoValue !== 'not' &&
|
|
340
|
+
pseudoValue !== 'is' &&
|
|
341
|
+
pseudoValue !== 'has') {
|
|
342
|
+
result.specificity.commonCounter += 1;
|
|
343
|
+
}
|
|
344
|
+
return result;
|
|
357
345
|
};
|
|
358
346
|
//# sourceMappingURL=pseudo.js.map
|
package/dist/esm/pseudo.js.map
CHANGED
|
@@ -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;AAG3C,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,GAAG,EAAE,M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AE,CAAA;YAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YAC3B,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE;YAC9D,KAAK,EAAE,KAAK,CAAC,OAAO;SACrB,CAAC,CAAA;IACJ,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'\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 { dev } from './pseudo/dev.ts'\nimport { dynamic } from './pseudo/dynamic.ts'\nimport { empty } from './pseudo/empty.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 { link } from './pseudo/link.ts'\nimport { malware } from './pseudo/malware.ts'\nimport { minified } from './pseudo/minified.ts'\nimport { missing } from './pseudo/missing.ts'\nimport { nativeParser } from './pseudo/native.ts'\nimport { network } from './pseudo/network.ts'\nimport { obfuscated } from './pseudo/obfuscated.ts'\nimport { optional } from './pseudo/optional.ts'\nimport { outdated } from './pseudo/outdated.ts'\nimport { peer } from './pseudo/peer.ts'\nimport { published } from './pseudo/published.ts'\nimport { privateParser } from './pseudo/private.ts'\nimport { prod } from './pseudo/prod.ts'\nimport { scanned } from './pseudo/scanned.ts'\nimport { score } from './pseudo/score.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'\nimport { workspace } from './pseudo/workspace.ts'\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 retries: state.retries,\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 retries: state.retries,\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 * :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 retries: state.retries,\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 * :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-Class, matches only graph importers (e.g: the\n * root node along with any configured workspace)\n */\nconst project = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (!node.importer) {\n removeNode(state, node)\n }\n }\n for (const edge of state.partial.edges) {\n if (!edge.to?.importer) {\n state.partial.edges.delete(edge)\n }\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 dev,\n dynamic,\n eval: evalParser,\n empty,\n entropic,\n env,\n fs,\n has,\n is,\n license,\n link,\n malware,\n minified,\n missing,\n native: nativeParser,\n network,\n not,\n obfuscated,\n optional,\n outdated,\n peer,\n published,\n // TODO: overridden\n private: privateParser,\n prod,\n project,\n root,\n scanned,\n scope,\n score,\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 v: semver,\n workspace,\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 state.partial.edges.clear()\n state.partial.nodes.clear()\n return state\n }\n\n throw error(`Unsupported pseudo-class: ${state.current.value}`, {\n found: state.current,\n })\n }\n return parserFn(state)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pseudo.js","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,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,GAA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":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\n\nimport { removeDanglingEdges, removeNode } from './pseudo/helpers.ts'\nimport {\n asPostcssNodeWithChildren,\n asPseudoNode,\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 { dev } from './pseudo/dev.ts'\nimport { dynamic } from './pseudo/dynamic.ts'\nimport { empty } from './pseudo/empty.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 { link } from './pseudo/link.ts'\nimport { malware } from './pseudo/malware.ts'\nimport { minified } from './pseudo/minified.ts'\nimport { missing } from './pseudo/missing.ts'\nimport { nativeParser } from './pseudo/native.ts'\nimport { network } from './pseudo/network.ts'\nimport { obfuscated } from './pseudo/obfuscated.ts'\nimport { optional } from './pseudo/optional.ts'\nimport { outdated } from './pseudo/outdated.ts'\nimport { peer } from './pseudo/peer.ts'\nimport { published } from './pseudo/published.ts'\nimport { privateParser } from './pseudo/private.ts'\nimport { prod } from './pseudo/prod.ts'\nimport { root } from './pseudo/root.ts'\nimport { scanned } from './pseudo/scanned.ts'\nimport { score } from './pseudo/score.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 { type } from './pseudo/type.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'\nimport { workspace } from './pseudo/workspace.ts'\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 retries: state.retries,\n securityArchive: state.securityArchive,\n specOptions: state.specOptions,\n signal: state.signal,\n scopeIDs: state.scopeIDs,\n comment: state.comment,\n specificity: { ...state.specificity },\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 retries: state.retries,\n securityArchive: state.securityArchive,\n specOptions: state.specOptions,\n signal: state.signal,\n scopeIDs: state.scopeIDs,\n comment: state.comment,\n specificity: { ...state.specificity },\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 * :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 retries: state.retries,\n securityArchive: state.securityArchive,\n specOptions: state.specOptions,\n signal: state.signal,\n scopeIDs: state.scopeIDs,\n comment: state.comment,\n specificity: { ...state.specificity },\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 * :project Pseudo-Class, matches only graph importers (e.g: the\n * root node along with any configured workspace)\n */\nconst project = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (!node.importer) {\n removeNode(state, node)\n }\n }\n for (const edge of state.partial.edges) {\n if (!edge.to?.importer) {\n state.partial.edges.delete(edge)\n }\n }\n return state\n}\n\n/**\n * :scope Pseudo-Element, returns only the nodes that match the provided scopeIDs\n * from the Query.search method.\n */\nconst scope = async (state: ParserState) => {\n const scopeIDSet = new Set(state.scopeIDs)\n\n for (const node of state.partial.nodes) {\n if (!scopeIDSet.has(node.id)) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\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 dev,\n dynamic,\n eval: evalParser,\n empty,\n entropic,\n env,\n fs,\n has,\n is,\n license,\n link,\n malware,\n minified,\n missing,\n native: nativeParser,\n network,\n not,\n obfuscated,\n optional,\n outdated,\n peer,\n published,\n // TODO: overridden\n private: privateParser,\n prod,\n project,\n root,\n scanned,\n scope,\n score,\n scripts,\n semver,\n sev: severity,\n severity,\n shell,\n shrinkwrap,\n squat,\n suspicious,\n tracker,\n trivial,\n type,\n undesirable,\n unknown,\n unmaintained,\n unpopular,\n unstable,\n v: semver,\n workspace,\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 state.partial.edges.clear()\n state.partial.nodes.clear()\n return state\n }\n\n throw error(`Unsupported pseudo-class: ${state.current.value}`, {\n found: state.current,\n })\n }\n\n const result = await parserFn(state)\n\n // Increment the commonCounter for specificity, except for\n // nesting selectors which don't contribute to specificity\n const pseudoValue = curr.value.slice(1)\n if (\n pseudoValue &&\n pseudoValue !== 'not' &&\n pseudoValue !== 'is' &&\n pseudoValue !== 'has'\n ) {\n result.specificity.commonCounter += 1\n }\n\n return result\n}\n"]}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { EdgeLike, NodeLike } from '@vltpkg/graph';
|
|
2
2
|
import type { SpecOptions } from '@vltpkg/spec/browser';
|
|
3
3
|
import type { SecurityArchiveLike, PackageScore } from '@vltpkg/security-archive';
|
|
4
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
4
5
|
import type { Tag, String, Selector, Root, Pseudo, Nesting, Identifier, Comment, Combinator, ClassName, Attribute, Universal } from 'postcss-selector-parser';
|
|
6
|
+
export type Specificity = {
|
|
7
|
+
idCounter: number;
|
|
8
|
+
commonCounter: number;
|
|
9
|
+
};
|
|
5
10
|
export type PostcssNode = Tag | String | Selector | Root | Pseudo | Nesting | Identifier | Comment | Combinator | ClassName | Attribute | Universal;
|
|
6
11
|
export type PostcssNodeWithChildren = Selector | Root | Pseudo;
|
|
7
12
|
export type GraphSelectionState = {
|
|
@@ -11,22 +16,27 @@ export type GraphSelectionState = {
|
|
|
11
16
|
export type ParserState = {
|
|
12
17
|
cancellable: () => Promise<void>;
|
|
13
18
|
collect: GraphSelectionState;
|
|
19
|
+
comment: string;
|
|
14
20
|
current: PostcssNode;
|
|
15
21
|
initial: GraphSelectionState;
|
|
16
22
|
loose?: boolean;
|
|
17
23
|
next?: PostcssNode;
|
|
18
24
|
prev?: PostcssNode;
|
|
19
25
|
result?: NodeLike[];
|
|
20
|
-
signal
|
|
26
|
+
signal: AbortSignal;
|
|
21
27
|
walk: ParserFn;
|
|
22
28
|
partial: GraphSelectionState;
|
|
23
29
|
retries: number;
|
|
24
30
|
securityArchive: SecurityArchiveLike | undefined;
|
|
25
31
|
specOptions: SpecOptions;
|
|
32
|
+
scopeIDs?: DepID[];
|
|
33
|
+
specificity: Specificity;
|
|
26
34
|
};
|
|
27
35
|
export type QueryResponse = {
|
|
28
36
|
edges: QueryResponseEdge[];
|
|
29
37
|
nodes: QueryResponseNode[];
|
|
38
|
+
comment: string;
|
|
39
|
+
specificity: Specificity;
|
|
30
40
|
};
|
|
31
41
|
export type QueryResponseEdge = Omit<EdgeLike, 'from' | 'to'> & {
|
|
32
42
|
from: QueryResponseNode;
|
|
@@ -114,4 +124,6 @@ export declare const isTagNode: (node: unknown) => node is Tag;
|
|
|
114
124
|
export declare const asTagNode: (node?: PostcssNode) => Tag;
|
|
115
125
|
export declare const isStringNode: (node: unknown) => node is String;
|
|
116
126
|
export declare const asStringNode: (node?: PostcssNode) => String;
|
|
127
|
+
export declare const isCommentNode: (node: unknown) => node is Comment;
|
|
128
|
+
export declare const asCommentNode: (node?: PostcssNode) => Comment;
|
|
117
129
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -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,mBAAmB,EACnB,YAAY,EACb,MAAM,0BAA0B,CAAA;AACjC,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,CAAA;AAEhC,MAA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,MAAM,aAAa,SAAU,OAAO,KAAG,IAAI,IAAI,OACE,CAAA;AAExD,eAAO,MAAM,aAAa,UAAW,WAAW,KAAG,OAalD,CAAA"}
|
package/dist/esm/types.js
CHANGED
|
@@ -103,4 +103,17 @@ export const asStringNode = (node) => {
|
|
|
103
103
|
}
|
|
104
104
|
return node;
|
|
105
105
|
};
|
|
106
|
+
export const isCommentNode = (node) => isObj(node) && !!node.value && node.type === 'comment';
|
|
107
|
+
export const asCommentNode = (node) => {
|
|
108
|
+
if (!node) {
|
|
109
|
+
throw error('Expected a query node');
|
|
110
|
+
}
|
|
111
|
+
if (!isCommentNode(node)) {
|
|
112
|
+
throw error('Mismatching query node', {
|
|
113
|
+
wanted: 'comment',
|
|
114
|
+
found: node.type,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return node;
|
|
118
|
+
};
|
|
106
119
|
//# sourceMappingURL=types.js.map
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAkK3C,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,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,KAAK,CAAC,yCAAyC,EAAE;YACrD,KAAK,EAAE,IAAI;SACZ,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,CAAU,EAA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E,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 SecurityArchiveLike,\n PackageScore,\n} 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 retries: number\n securityArchive: SecurityArchiveLike | undefined\n specOptions: SpecOptions\n}\n\nexport type QueryResponse = {\n edges: QueryResponseEdge[]\n nodes: QueryResponseNode[]\n}\n\nexport type QueryResponseEdge = Omit<EdgeLike, 'from' | 'to'> & {\n from: QueryResponseNode\n to?: QueryResponseNode\n}\n\nexport type QueryResponseNode = Omit<\n NodeLike,\n 'edgesIn' | 'edgesOut'\n> & {\n edgesIn: Set<QueryResponseEdge>\n edgesOut: Map<string, QueryResponseEdge>\n insights: Insights\n toJSON: () => Pick<\n QueryResponseNode,\n | 'id'\n | 'name'\n | 'version'\n | 'location'\n | 'importer'\n | 'manifest'\n | 'projectRoot'\n | 'integrity'\n | 'resolved'\n | 'dev'\n | 'optional'\n | 'insights'\n | 'confused'\n >\n}\n\nexport type Insights = {\n abandoned?: boolean\n confused?: boolean\n cve?: `CVE-${string}`[]\n cwe?: `CWE-${string}`[]\n debug?: boolean\n deprecated?: boolean\n dynamic?: boolean\n entropic?: boolean\n env?: boolean\n eval?: boolean\n fs?: boolean\n license?: LicenseInsights\n malware?: MalwareInsights\n minified?: boolean\n native?: boolean\n network?: boolean\n obfuscated?: boolean\n scanned: boolean\n score?: PackageScore\n scripts?: boolean\n severity?: SeverityInsights\n shell?: boolean\n shrinkwrap?: boolean\n squat?: SquatInsights\n suspicious?: boolean\n tracker?: boolean\n trivial?: boolean\n undesirable?: boolean\n unknown?: boolean\n unmaintained?: boolean\n unpopular?: boolean\n unstable?: boolean\n}\n\nexport type LicenseInsights = {\n unlicensed: boolean\n misc: boolean\n restricted: boolean\n ambiguous: boolean\n copyleft: boolean\n unknown: boolean\n none: boolean\n exception: boolean\n}\n\nexport type LeveledInsights = {\n low: boolean\n medium: boolean\n high: boolean\n critical: boolean\n}\n\nexport type MalwareInsights = LeveledInsights\nexport type SeverityInsights = LeveledInsights\n\nexport type SquatInsights = {\n medium: boolean\n critical: boolean\n}\n\nexport type ParserFn = (opt: ParserState) => Promise<ParserState>\n\nexport type ParsedSelectorToken = PostcssNode & {\n token: string\n}\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 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 asSelectorNode = (node?: PostcssNode): Selector => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isSelectorNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'selector',\n found: node.type,\n })\n }\n return node\n}\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;AA6K3C,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,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,KAAK,CAAC,yCAAyC,EAAE;YACrD,KAAK,EAAE,IAAI;SACZ,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,CAAU,EAAgC,EAAE,CACzD,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAA;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAa,EAAqB,EAAE,CAClE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,CAAA;AAE9D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAkB,EAAa,EAAE;IAC/D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,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E,CAAC;QACV,MAAM,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,CAAC,wBAAwB,EAAE;YACpC,MAAM,EAAE,SAAS;YACjB,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 SecurityArchiveLike,\n PackageScore,\n} from '@vltpkg/security-archive'\nimport type { DepID } from '@vltpkg/dep-id'\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 Specificity = {\n idCounter: number\n commonCounter: number\n}\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 comment: string\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 retries: number\n securityArchive: SecurityArchiveLike | undefined\n specOptions: SpecOptions\n scopeIDs?: DepID[]\n specificity: Specificity\n}\n\nexport type QueryResponse = {\n edges: QueryResponseEdge[]\n nodes: QueryResponseNode[]\n comment: string\n specificity: Specificity\n}\n\nexport type QueryResponseEdge = Omit<EdgeLike, 'from' | 'to'> & {\n from: QueryResponseNode\n to?: QueryResponseNode\n}\n\nexport type QueryResponseNode = Omit<\n NodeLike,\n 'edgesIn' | 'edgesOut'\n> & {\n edgesIn: Set<QueryResponseEdge>\n edgesOut: Map<string, QueryResponseEdge>\n insights: Insights\n toJSON: () => Pick<\n QueryResponseNode,\n | 'id'\n | 'name'\n | 'version'\n | 'location'\n | 'importer'\n | 'manifest'\n | 'projectRoot'\n | 'integrity'\n | 'resolved'\n | 'dev'\n | 'optional'\n | 'insights'\n | 'confused'\n >\n}\n\nexport type Insights = {\n abandoned?: boolean\n confused?: boolean\n cve?: `CVE-${string}`[]\n cwe?: `CWE-${string}`[]\n debug?: boolean\n deprecated?: boolean\n dynamic?: boolean\n entropic?: boolean\n env?: boolean\n eval?: boolean\n fs?: boolean\n license?: LicenseInsights\n malware?: MalwareInsights\n minified?: boolean\n native?: boolean\n network?: boolean\n obfuscated?: boolean\n scanned: boolean\n score?: PackageScore\n scripts?: boolean\n severity?: SeverityInsights\n shell?: boolean\n shrinkwrap?: boolean\n squat?: SquatInsights\n suspicious?: boolean\n tracker?: boolean\n trivial?: boolean\n undesirable?: boolean\n unknown?: boolean\n unmaintained?: boolean\n unpopular?: boolean\n unstable?: boolean\n}\n\nexport type LicenseInsights = {\n unlicensed: boolean\n misc: boolean\n restricted: boolean\n ambiguous: boolean\n copyleft: boolean\n unknown: boolean\n none: boolean\n exception: boolean\n}\n\nexport type LeveledInsights = {\n low: boolean\n medium: boolean\n high: boolean\n critical: boolean\n}\n\nexport type MalwareInsights = LeveledInsights\nexport type SeverityInsights = LeveledInsights\n\nexport type SquatInsights = {\n medium: boolean\n critical: boolean\n}\n\nexport type ParserFn = (opt: ParserState) => Promise<ParserState>\n\nexport type ParsedSelectorToken = PostcssNode & {\n token: string\n}\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 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 asSelectorNode = (node?: PostcssNode): Selector => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isSelectorNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'selector',\n found: node.type,\n })\n }\n return node\n}\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\nexport const isCommentNode = (node: unknown): node is Comment =>\n isObj(node) && !!node.value && node.type === 'comment'\n\nexport const asCommentNode = (node?: PostcssNode): Comment => {\n if (!node) {\n throw error('Expected a query node')\n }\n\n if (!isCommentNode(node)) {\n throw error('Mismatching query node', {\n wanted: 'comment',\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-
|
|
4
|
+
"version": "0.0.0-13",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"p-retry": "^6.2.1",
|
|
23
23
|
"postcss-selector-parser": "^7.1.0",
|
|
24
|
-
"@vltpkg/dep-id": "0.0.0-
|
|
25
|
-
"@vltpkg/
|
|
26
|
-
"@vltpkg/
|
|
27
|
-
"@vltpkg/
|
|
28
|
-
"@vltpkg/
|
|
29
|
-
"@vltpkg/
|
|
24
|
+
"@vltpkg/dep-id": "0.0.0-13",
|
|
25
|
+
"@vltpkg/graph": "0.0.0-13",
|
|
26
|
+
"@vltpkg/security-archive": "0.0.0-13",
|
|
27
|
+
"@vltpkg/error-cause": "0.0.0-13",
|
|
28
|
+
"@vltpkg/semver": "0.0.0-13",
|
|
29
|
+
"@vltpkg/types": "0.0.0-13"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@eslint/js": "^9.25.1",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typedoc": "~0.27.9",
|
|
39
39
|
"typescript": "5.7.3",
|
|
40
40
|
"typescript-eslint": "^8.31.1",
|
|
41
|
-
"@vltpkg/spec": "0.0.0-
|
|
41
|
+
"@vltpkg/spec": "0.0.0-13"
|
|
42
42
|
},
|
|
43
43
|
"license": "BSD-2-Clause-Patent",
|
|
44
44
|
"engines": {
|