@vltpkg/query 0.0.0-20 → 0.0.0-22
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/pseudo/spec.d.ts +17 -0
- package/dist/esm/pseudo/spec.d.ts.map +1 -0
- package/dist/esm/pseudo/spec.js +102 -0
- package/dist/esm/pseudo/spec.js.map +1 -0
- package/dist/esm/pseudo.d.ts.map +1 -1
- package/dist/esm/pseudo.js +2 -0
- package/dist/esm/pseudo.js.map +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
import type { PostcssNode } from '@vltpkg/dss-parser';
|
|
3
|
+
export type SpecInternals = {
|
|
4
|
+
specValue: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => SpecInternals;
|
|
7
|
+
/**
|
|
8
|
+
* :spec Pseudo-Selector, matches edges where edge.spec.bareSpec equals the provided value.
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* - :spec("*") matches edges with a package specifier equal to "*"
|
|
12
|
+
* - :spec(^1.0.0) matches edges with a package specifier equal to "^1.0.0"
|
|
13
|
+
* - :spec("catalog:") matches edges with a package specifier equal to "catalog:"
|
|
14
|
+
* - :spec("workspace:dev") matches edges with a package specifier equal to "workspace:dev"
|
|
15
|
+
*/
|
|
16
|
+
export declare const spec: (state: ParserState) => Promise<ParserState>;
|
|
17
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../src/pseudo/spec.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB,aAyEF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,UAAiB,WAAW,yBAwB5C,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { asError } from '@vltpkg/types';
|
|
3
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isTagNode, } from '@vltpkg/dss-parser';
|
|
4
|
+
import { removeEdge, removeUnlinkedNodes, removeQuotes, } from "./helpers.js";
|
|
5
|
+
export const parseInternals = (nodes) => {
|
|
6
|
+
// tries to parse the first param as a string node, otherwise defaults
|
|
7
|
+
// to reading all postcss nodes as just strings, since it just means
|
|
8
|
+
// the value was defined as an unquoted string
|
|
9
|
+
let specValue = '';
|
|
10
|
+
if (nodes.length === 0) {
|
|
11
|
+
throw new Error('No nodes provided to parseInternals');
|
|
12
|
+
}
|
|
13
|
+
const firstNode = asPostcssNodeWithChildren(nodes[0]);
|
|
14
|
+
if (firstNode.nodes.length === 0) {
|
|
15
|
+
throw new Error('First node has no child nodes');
|
|
16
|
+
}
|
|
17
|
+
// Try to parse as a quoted string first (single string node)
|
|
18
|
+
if (firstNode.nodes.length === 1) {
|
|
19
|
+
const targetNode = firstNode.nodes[0];
|
|
20
|
+
try {
|
|
21
|
+
specValue = removeQuotes(asStringNode(targetNode).value);
|
|
22
|
+
return { specValue };
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (asError(err).message === 'Mismatching query node' &&
|
|
26
|
+
isTagNode(targetNode)
|
|
27
|
+
/* c8 ignore start */
|
|
28
|
+
) {
|
|
29
|
+
// Handle simple unquoted single-token values like "1"
|
|
30
|
+
const tagNode = asTagNode(targetNode);
|
|
31
|
+
specValue = tagNode.value;
|
|
32
|
+
return { specValue };
|
|
33
|
+
/* c8 ignore stop */
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Handle unquoted complex values that get parsed into multiple nodes
|
|
41
|
+
// This happens when unquoted values contain dots, like ^1.0.0 which becomes:
|
|
42
|
+
// - Tag: "^1"
|
|
43
|
+
// - ClassName: "0" (from .0)
|
|
44
|
+
// - ClassName: "0" (from .0)
|
|
45
|
+
// We need to reconstruct the original value by concatenating all nodes
|
|
46
|
+
const parts = [];
|
|
47
|
+
for (const node of firstNode.nodes) {
|
|
48
|
+
switch (node.type) {
|
|
49
|
+
case 'tag':
|
|
50
|
+
parts.push(asTagNode(node).value);
|
|
51
|
+
break;
|
|
52
|
+
case 'class':
|
|
53
|
+
// Class nodes represent .className in CSS, so we need to add the dot back
|
|
54
|
+
parts.push('.' + node.value);
|
|
55
|
+
break;
|
|
56
|
+
case 'id':
|
|
57
|
+
// ID nodes represent #idName in CSS, so we need to add the hash back
|
|
58
|
+
parts.push('#' + node.value);
|
|
59
|
+
break;
|
|
60
|
+
case 'string':
|
|
61
|
+
parts.push(removeQuotes(asStringNode(node).value));
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
// For other node types, try to get the value property or convert to string
|
|
65
|
+
/* c8 ignore next */
|
|
66
|
+
parts.push(node.value ?? String(node));
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
specValue = parts.join('');
|
|
71
|
+
return { specValue };
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* :spec Pseudo-Selector, matches edges where edge.spec.bareSpec equals the provided value.
|
|
75
|
+
*
|
|
76
|
+
* Examples:
|
|
77
|
+
* - :spec("*") matches edges with a package specifier equal to "*"
|
|
78
|
+
* - :spec(^1.0.0) matches edges with a package specifier equal to "^1.0.0"
|
|
79
|
+
* - :spec("catalog:") matches edges with a package specifier equal to "catalog:"
|
|
80
|
+
* - :spec("workspace:dev") matches edges with a package specifier equal to "workspace:dev"
|
|
81
|
+
*/
|
|
82
|
+
export const spec = async (state) => {
|
|
83
|
+
let internals;
|
|
84
|
+
try {
|
|
85
|
+
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
throw error('Failed to parse :spec selector', {
|
|
89
|
+
cause: err,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const { specValue } = internals;
|
|
93
|
+
for (const edge of state.partial.edges) {
|
|
94
|
+
if (edge.spec.bareSpec !== specValue) {
|
|
95
|
+
removeEdge(state, edge);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Clean up unlinked nodes after removing edges
|
|
99
|
+
removeUnlinkedNodes(state);
|
|
100
|
+
return state;
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/pseudo/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,SAAS,EACT,SAAS,GACV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,YAAY,GACb,MAAM,cAAc,CAAA;AAQrB,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACL,EAAE;IACjB,sEAAsE;IACtE,oEAAoE;IACpE,8CAA8C;IAC9C,IAAI,SAAS,GAAG,EAAE,CAAA;IAElB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;IACxD,CAAC;IAED,MAAM,SAAS,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAErD,IAAI,SAAS,CAAC,KAAK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,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { asError } from '@vltpkg/types'\nimport {\n asPostcssNodeWithChildren,\n asStringNode,\n asTagNode,\n isTagNode,\n} from '@vltpkg/dss-parser'\nimport {\n removeEdge,\n removeUnlinkedNodes,\n removeQuotes,\n} from './helpers.ts'\nimport type { ParserState } from '../types.ts'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\n\nexport type SpecInternals = {\n specValue: string\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): SpecInternals => {\n // tries to parse the first param as a string node, otherwise defaults\n // to reading all postcss nodes as just strings, since it just means\n // the value was defined as an unquoted string\n let specValue = ''\n\n if (nodes.length === 0) {\n throw new Error('No nodes provided to parseInternals')\n }\n\n const firstNode = asPostcssNodeWithChildren(nodes[0])\n\n if (firstNode.nodes.length === 0) {\n throw new Error('First node has no child nodes')\n }\n\n // Try to parse as a quoted string first (single string node)\n if (firstNode.nodes.length === 1) {\n const targetNode = firstNode.nodes[0]\n try {\n specValue = removeQuotes(asStringNode(targetNode).value)\n return { specValue }\n } catch (err) {\n if (\n asError(err).message === 'Mismatching query node' &&\n isTagNode(targetNode)\n /* c8 ignore start */\n ) {\n // Handle simple unquoted single-token values like \"1\"\n const tagNode = asTagNode(targetNode)\n specValue = tagNode.value\n return { specValue }\n /* c8 ignore stop */\n } else {\n throw err\n }\n }\n }\n\n // Handle unquoted complex values that get parsed into multiple nodes\n // This happens when unquoted values contain dots, like ^1.0.0 which becomes:\n // - Tag: \"^1\"\n // - ClassName: \"0\" (from .0)\n // - ClassName: \"0\" (from .0)\n // We need to reconstruct the original value by concatenating all nodes\n const parts: string[] = []\n\n for (const node of firstNode.nodes) {\n switch (node.type) {\n case 'tag':\n parts.push(asTagNode(node).value)\n break\n case 'class':\n // Class nodes represent .className in CSS, so we need to add the dot back\n parts.push('.' + node.value)\n break\n case 'id':\n // ID nodes represent #idName in CSS, so we need to add the hash back\n parts.push('#' + node.value)\n break\n case 'string':\n parts.push(removeQuotes(asStringNode(node).value))\n break\n default:\n // For other node types, try to get the value property or convert to string\n /* c8 ignore next */\n parts.push(node.value ?? String(node))\n break\n }\n }\n\n specValue = parts.join('')\n return { specValue }\n}\n\n/**\n * :spec Pseudo-Selector, matches edges where edge.spec.bareSpec equals the provided value.\n *\n * Examples:\n * - :spec(\"*\") matches edges with a package specifier equal to \"*\"\n * - :spec(^1.0.0) matches edges with a package specifier equal to \"^1.0.0\"\n * - :spec(\"catalog:\") matches edges with a package specifier equal to \"catalog:\"\n * - :spec(\"workspace:dev\") matches edges with a package specifier equal to \"workspace:dev\"\n */\nexport const spec = async (state: ParserState) => {\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :spec selector', {\n cause: err,\n })\n }\n\n const { specValue } = internals\n\n for (const edge of state.partial.edges) {\n if (edge.spec.bareSpec !== specValue) {\n removeEdge(state, edge)\n }\n }\n\n // Clean up unlinked nodes after removing edges\n removeUnlinkedNodes(state)\n\n return state\n}\n"]}
|
package/dist/esm/pseudo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AA8DA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,YAAY,CAAA;AA+RvD;;GAEG;AACH,eAAO,MAAM,MAAM,UAAiB,WAAW,yBAkC9C,CAAA"}
|
package/dist/esm/pseudo.js
CHANGED
|
@@ -40,6 +40,7 @@ import { scripts } from "./pseudo/scripts.js";
|
|
|
40
40
|
import { shell } from "./pseudo/shell.js";
|
|
41
41
|
import { semverParser as semver } from "./pseudo/semver.js";
|
|
42
42
|
import { severity } from "./pseudo/severity.js";
|
|
43
|
+
import { spec } from "./pseudo/spec.js";
|
|
43
44
|
import { shrinkwrap } from "./pseudo/shrinkwrap.js";
|
|
44
45
|
import { squat } from "./pseudo/squat.js";
|
|
45
46
|
import { suspicious } from "./pseudo/suspicious.js";
|
|
@@ -303,6 +304,7 @@ const pseudoSelectors = new Map(Object.entries({
|
|
|
303
304
|
scripts,
|
|
304
305
|
semver,
|
|
305
306
|
sev: severity,
|
|
307
|
+
spec,
|
|
306
308
|
severity,
|
|
307
309
|
shell,
|
|
308
310
|
shrinkwrap,
|
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,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAA;AAE3B,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,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA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,CAAA;IAEzB,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACxC,MAAM,QAAQ,GACZ,IAAI,CAAC,KAAK,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAExD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,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;IAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEpC,0DAA0D;IAC1D,0DAA0D;IAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACvC,IACE,WAAW;QACX,WAAW,KAAK,KAAK;QACrB,WAAW,KAAK,IAAI;QACpB,WAAW,KAAK,KAAK,EACrB,CAAC;QACD,MAAM,CAAC,WAAW,CAAC,aAAa,IAAI,CAAC,CAAA;IACvC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { removeDanglingEdges, removeNode } from './pseudo/helpers.ts'\nimport {\n asPostcssNodeWithChildren,\n asPseudoNode,\n isSelectorNode,\n} from '@vltpkg/dss-parser'\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 { overridden } from './pseudo/overridden.ts'\nimport { path } from './pseudo/path.ts'\nimport { peer } from './pseudo/peer.ts'\nimport { prerelease } from './pseudo/prerelease.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\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { ParserFn, ParserState } from './types.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 overridden,\n path,\n peer,\n prerelease,\n published,\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"]}
|
|
1
|
+
{"version":3,"file":"pseudo.js","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAA;AAE3B,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,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE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I,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAExD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,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;IAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEpC,0DAA0D;IAC1D,0DAA0D;IAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACvC,IACE,WAAW;QACX,WAAW,KAAK,KAAK;QACrB,WAAW,KAAK,IAAI;QACpB,WAAW,KAAK,KAAK,EACrB,CAAC;QACD,MAAM,CAAC,WAAW,CAAC,aAAa,IAAI,CAAC,CAAA;IACvC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { removeDanglingEdges, removeNode } from './pseudo/helpers.ts'\nimport {\n asPostcssNodeWithChildren,\n asPseudoNode,\n isSelectorNode,\n} from '@vltpkg/dss-parser'\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 { overridden } from './pseudo/overridden.ts'\nimport { path } from './pseudo/path.ts'\nimport { peer } from './pseudo/peer.ts'\nimport { prerelease } from './pseudo/prerelease.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 { spec } from './pseudo/spec.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\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { ParserFn, ParserState } from './types.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 overridden,\n path,\n peer,\n prerelease,\n published,\n private: privateParser,\n prod,\n project,\n root,\n scanned,\n scope,\n score,\n scripts,\n semver,\n sev: severity,\n spec,\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/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-22",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"minimatch": "^10.0.1",
|
|
23
23
|
"p-retry": "^6.2.1",
|
|
24
24
|
"postcss-selector-parser": "^7.1.0",
|
|
25
|
-
"@vltpkg/dep-id": "0.0.0-
|
|
26
|
-
"@vltpkg/dss-parser": "0.0.0-
|
|
27
|
-
"@vltpkg/error-cause": "0.0.0-
|
|
28
|
-
"@vltpkg/
|
|
29
|
-
"@vltpkg/
|
|
30
|
-
"@vltpkg/semver": "0.0.0-
|
|
31
|
-
"@vltpkg/types": "0.0.0-
|
|
25
|
+
"@vltpkg/dep-id": "0.0.0-22",
|
|
26
|
+
"@vltpkg/dss-parser": "0.0.0-22",
|
|
27
|
+
"@vltpkg/error-cause": "0.0.0-22",
|
|
28
|
+
"@vltpkg/graph": "0.0.0-22",
|
|
29
|
+
"@vltpkg/security-archive": "0.0.0-22",
|
|
30
|
+
"@vltpkg/semver": "0.0.0-22",
|
|
31
|
+
"@vltpkg/types": "0.0.0-22"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@eslint/js": "^9.28.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"typedoc": "~0.27.9",
|
|
41
41
|
"typescript": "5.7.3",
|
|
42
42
|
"typescript-eslint": "^8.33.1",
|
|
43
|
-
"@vltpkg/spec": "0.0.0-
|
|
43
|
+
"@vltpkg/spec": "0.0.0-22"
|
|
44
44
|
},
|
|
45
45
|
"license": "BSD-2-Clause-Patent",
|
|
46
46
|
"engines": {
|