@vltpkg/query 0.0.0-14 → 0.0.0-16

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.
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAG3D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,UAAW,MAAM,KAAG,MAItD,CAAA;AAEH,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MACb,CAAA;AAE9B,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,MACf,CAAA;AAgB9B;;;GAGG;AACH,eAAO,MAAM,KAAK,UAAW,MAAM,KAAG,IA0ErC,CAAA"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAG3D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,UAAW,MAAM,KAAG,MAItD,CAAA;AAEH,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MACb,CAAA;AAE9B,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,MACf,CAAA;AAiB9B;;;GAGG;AACH,eAAO,MAAM,KAAK,UAAW,MAAM,KAAG,IA0ErC,CAAA"}
@@ -17,6 +17,7 @@ const pseudoCleanUpNeeded = new Set([
17
17
  ':squat',
18
18
  ':semver',
19
19
  ':v',
20
+ ':path',
20
21
  ]);
21
22
  const hasParamsToEscape = (node) => pseudoCleanUpNeeded.has(node.value);
22
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,SAAS,GAC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ser'\nimport {\n asSelectorNode,\n isCombinatorNode,\n isPseudoNode,\n isTagNode,\n} from '@vltpkg/dss-parser'\nimport type { Pseudo, Root } from 'postcss-selector-parser'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\n\n/**\n * Escapes forward slashes in specific patterns matching @scoped/name paths\n * This will allow usage of unescaped forward slashes necessary for scoped\n * package names in the id selector.\n */\nexport const escapeScopedNamesSlashes = (query: string): string =>\n query.replace(\n /(#@(\\w|-|\\.)+)\\//gm,\n (_, scope: string) => `${scope}\\\\/`,\n )\n\nexport const escapeDots = (query: string): string =>\n query.replaceAll('.', '\\\\.')\n\nexport const unescapeDots = (query: string): string =>\n query.replaceAll('\\\\.', '.')\n\nconst pseudoCleanUpNeeded = new Set([\n ':published',\n ':score',\n ':malware',\n ':severity',\n ':sev',\n ':squat',\n ':semver',\n ':v',\n])\n\nconst hasParamsToEscape = (node: Pseudo) =>\n pseudoCleanUpNeeded.has(node.value)\n\n/**\n * Parses a CSS selector string into an AST\n * Handles escaping of forward slashes in specific patterns\n */\nexport const parse = (query: string): Root => {\n const escapedQuery = escapeDots(escapeScopedNamesSlashes(query))\n const transformAst = (root: Root) => {\n root.walk((node: PostcssNode) => {\n // clean up the escaped dots\n if (node.value && typeof node.value === 'string') {\n node.value = unescapeDots(node.value)\n }\n if (isPseudoNode(node) && hasParamsToEscape(node)) {\n // these are pseudo nodes that should only take strings as\n // parameters, so in this preparse step we clean up anything\n // that was recognized as a postcss node and transform that\n // into something that can be most likely parsed as a string\n for (const n of node.nodes) {\n // the parameters have a selector node that wraps them up\n const selector = asSelectorNode(n)\n selector.nodes.forEach((currentNode, index, arr) => {\n // get the next node, we'll update it later\n const nextNode = arr[index + 1]\n // if the current node is a combinator node, we'll need to\n // escape it, we do so by removing the node entirely and\n // updating the contents of the next node with its value\n if (\n isCombinatorNode(currentNode) &&\n isTagNode(nextNode)\n ) {\n nextNode.value = `${currentNode.spaces.before}${currentNode.value}${currentNode.spaces.after}${nextNode.value}`\n // make sure to also update the source position\n // references, those are used by the syntax highlighter\n if (\n nextNode.source?.start?.line &&\n currentNode.source?.start?.line\n ) {\n nextNode.source.start.line =\n currentNode.source.start.line\n }\n if (\n nextNode.source?.start?.column &&\n currentNode.source?.start?.column\n ) {\n nextNode.source.start.column =\n currentNode.source.start.column\n }\n // removes the current node from the selector node\n arr.splice(index, 1)\n }\n })\n // after removing combinator nodes, if we end up with multiple\n // tags in the selector node, we need to smush them together\n selector.nodes.reduce((acc, currentNode) => {\n if (currentNode === acc) return acc\n acc.value = `${acc.value}${currentNode.spaces.before}${currentNode.value}${currentNode.spaces.after}`\n // make sure to also update the source position refs\n if (\n currentNode.source?.end?.line &&\n acc.source?.end?.line\n ) {\n acc.source.end.line = currentNode.source.end.line\n }\n if (\n currentNode.source?.end?.column &&\n acc.source?.end?.column\n ) {\n acc.source.end.column = currentNode.source.end.column\n }\n return acc\n }, selector.first)\n // the selector wrapper node should have a single node\n selector.nodes.length = 1\n }\n }\n })\n }\n return postcssSelectorParser(transformAst).astSync(escapedQuery)\n}\n"]}
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,MAAM,oBAAoB,CAAA;AAI3B;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAa,EAAU,EAAE,CAChE,KAAK,CAAC,OAAO,CACX,oBAAoB,EACpB,CAAC,CAAC,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,CACpC,CAAA;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAClD,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAE9B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAU,EAAE,CACpD,KA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,KAAK,EAAE,CAAA;wBACrG,oDAAoD;wBACpD,IACE,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI;4BAC7B,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EACrB,CAAC;4BACD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAA;wBACnD,CAAC;wBACD,IACE,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM;4BAC/B,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EACvB,CAAC;4BACD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAA;wBACvD,CAAC;wBACD,OAAO,GAAG,CAAA;oBACZ,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;oBAClB,sDAAsD;oBACtD,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,OAAO,qBAAqB,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;AAClE,CAAC,CAAA","sourcesContent":["import postcssSelectorParser from 'postcss-selector-parser'\nimport {\n asSelectorNode,\n isCombinatorNode,\n isPseudoNode,\n isTagNode,\n} from '@vltpkg/dss-parser'\nimport type { Pseudo, Root } from 'postcss-selector-parser'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\n\n/**\n * Escapes forward slashes in specific patterns matching @scoped/name paths\n * This will allow usage of unescaped forward slashes necessary for scoped\n * package names in the id selector.\n */\nexport const escapeScopedNamesSlashes = (query: string): string =>\n query.replace(\n /(#@(\\w|-|\\.)+)\\//gm,\n (_, scope: string) => `${scope}\\\\/`,\n )\n\nexport const escapeDots = (query: string): string =>\n query.replaceAll('.', '\\\\.')\n\nexport const unescapeDots = (query: string): string =>\n query.replaceAll('\\\\.', '.')\n\nconst pseudoCleanUpNeeded = new Set([\n ':published',\n ':score',\n ':malware',\n ':severity',\n ':sev',\n ':squat',\n ':semver',\n ':v',\n ':path',\n])\n\nconst hasParamsToEscape = (node: Pseudo) =>\n pseudoCleanUpNeeded.has(node.value)\n\n/**\n * Parses a CSS selector string into an AST\n * Handles escaping of forward slashes in specific patterns\n */\nexport const parse = (query: string): Root => {\n const escapedQuery = escapeDots(escapeScopedNamesSlashes(query))\n const transformAst = (root: Root) => {\n root.walk((node: PostcssNode) => {\n // clean up the escaped dots\n if (node.value && typeof node.value === 'string') {\n node.value = unescapeDots(node.value)\n }\n if (isPseudoNode(node) && hasParamsToEscape(node)) {\n // these are pseudo nodes that should only take strings as\n // parameters, so in this preparse step we clean up anything\n // that was recognized as a postcss node and transform that\n // into something that can be most likely parsed as a string\n for (const n of node.nodes) {\n // the parameters have a selector node that wraps them up\n const selector = asSelectorNode(n)\n selector.nodes.forEach((currentNode, index, arr) => {\n // get the next node, we'll update it later\n const nextNode = arr[index + 1]\n // if the current node is a combinator node, we'll need to\n // escape it, we do so by removing the node entirely and\n // updating the contents of the next node with its value\n if (\n isCombinatorNode(currentNode) &&\n isTagNode(nextNode)\n ) {\n nextNode.value = `${currentNode.spaces.before}${currentNode.value}${currentNode.spaces.after}${nextNode.value}`\n // make sure to also update the source position\n // references, those are used by the syntax highlighter\n if (\n nextNode.source?.start?.line &&\n currentNode.source?.start?.line\n ) {\n nextNode.source.start.line =\n currentNode.source.start.line\n }\n if (\n nextNode.source?.start?.column &&\n currentNode.source?.start?.column\n ) {\n nextNode.source.start.column =\n currentNode.source.start.column\n }\n // removes the current node from the selector node\n arr.splice(index, 1)\n }\n })\n // after removing combinator nodes, if we end up with multiple\n // tags in the selector node, we need to smush them together\n selector.nodes.reduce((acc, currentNode) => {\n if (currentNode === acc) return acc\n acc.value = `${acc.value}${currentNode.spaces.before}${currentNode.value}${currentNode.spaces.after}`\n // make sure to also update the source position refs\n if (\n currentNode.source?.end?.line &&\n acc.source?.end?.line\n ) {\n acc.source.end.line = currentNode.source.end.line\n }\n if (\n currentNode.source?.end?.column &&\n acc.source?.end?.column\n ) {\n acc.source.end.column = currentNode.source.end.column\n }\n return acc\n }, selector.first)\n // the selector wrapper node should have a single node\n selector.nodes.length = 1\n }\n }\n })\n }\n return postcssSelectorParser(transformAst).astSync(escapedQuery)\n}\n"]}
@@ -26,6 +26,10 @@ export declare const removeQuotes: (value: string) => string;
26
26
  export declare const assertSecurityArchive: (state: ParserState, name: string) => asserts state is ParserState & {
27
27
  securityArchive: NonNullable<ParserState['securityArchive']>;
28
28
  };
29
+ /**
30
+ * Clears all nodes and edges from the results.
31
+ */
32
+ export declare const clear: (state: ParserState) => ParserState;
29
33
  /**
30
34
  * Reusable security selector alert filter.
31
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,WACR,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAClC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,KAAK,IAAI,WAAW,GAAG;IAClC,eAAe,EAAE,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAA;CAQ7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,4BAA4B,SACjC,MAAM,QACN,MAAM,aAES,WAAW;qBAjBf,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;EAkC7D,CAAA"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,WACR,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAClC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,KAAK,IAAI,WAAW,GAAG;IAClC,eAAe,EAAE,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAA;CAQ7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,UAAW,WAAW,KAAG,WAI1C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,4BAA4B,SACjC,MAAM,QACN,MAAM,aAES,WAAW;qBA1Bf,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;EA2C7D,CAAA"}
@@ -49,6 +49,14 @@ export const assertSecurityArchive = (state, name) => {
49
49
  throw error(`Missing security archive while trying to parse the :${name} selector`, { found: state });
50
50
  }
51
51
  };
52
+ /**
53
+ * Clears all nodes and edges from the results.
54
+ */
55
+ export const clear = (state) => {
56
+ state.partial.nodes.clear();
57
+ state.partial.edges.clear();
58
+ return state;
59
+ };
52
60
  /**
53
61
  * Reusable security selector alert filter.
54
62
  */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrC,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAkB,EAAE,EAAE;IACxD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;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O,EAAE,CAAC;gBACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;QAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { ParserState } from '../types.js'\n\n/**\n * Removes a node and its incoming edges from the results.\n */\nexport const removeNode = (state: ParserState, 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/**\n * Removes an edge and its outgoing node from the results.\n */\nexport const removeEdge = (state: ParserState, edge: EdgeLike) => {\n state.partial.edges.delete(edge)\n if (edge.to) {\n state.partial.nodes.delete(edge.to)\n }\n}\n\n/**\n * Removes any edges that have no destination node from the results.\n */\nexport const removeDanglingEdges = (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n}\n\n/**\n * Removes any nodes that have no incoming edges from the results.\n */\nexport const removeUnlinkedNodes = (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesIn.size === 0) {\n state.partial.nodes.delete(node)\n }\n }\n}\n\n/**\n * Removes quotes from a string value.\n */\nexport const removeQuotes = (value: string) =>\n value.replace(/^\"(.*?)\"$/, '$1')\n\n/**\n * Asserts that the security archive is present.\n */\nexport const assertSecurityArchive: (\n state: ParserState,\n name: string,\n) => asserts state is ParserState & {\n securityArchive: NonNullable<ParserState['securityArchive']>\n} = (state, name) => {\n if (!state.securityArchive) {\n throw error(\n `Missing security archive while trying to parse the :${name} selector`,\n { found: state },\n )\n }\n}\n\n/**\n * Reusable security selector alert filter.\n */\nexport const createSecuritySelectorFilter = (\n name: string,\n type: string,\n) => {\n return async (state: ParserState) => {\n assertSecurityArchive(state, name)\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(\n alert => alert.type === type,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n }\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrC,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAkB,EAAE,EAAE;IACxD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,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AAE,CAAC,CAAA;YACjD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAClC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAC7B,CAAA;YACD,IAAI,OAAO,EAAE,CAAC;gBACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;QAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { ParserState } from '../types.js'\n\n/**\n * Removes a node and its incoming edges from the results.\n */\nexport const removeNode = (state: ParserState, 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/**\n * Removes an edge and its outgoing node from the results.\n */\nexport const removeEdge = (state: ParserState, edge: EdgeLike) => {\n state.partial.edges.delete(edge)\n if (edge.to) {\n state.partial.nodes.delete(edge.to)\n }\n}\n\n/**\n * Removes any edges that have no destination node from the results.\n */\nexport const removeDanglingEdges = (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n}\n\n/**\n * Removes any nodes that have no incoming edges from the results.\n */\nexport const removeUnlinkedNodes = (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesIn.size === 0) {\n state.partial.nodes.delete(node)\n }\n }\n}\n\n/**\n * Removes quotes from a string value.\n */\nexport const removeQuotes = (value: string) =>\n value.replace(/^\"(.*?)\"$/, '$1')\n\n/**\n * Asserts that the security archive is present.\n */\nexport const assertSecurityArchive: (\n state: ParserState,\n name: string,\n) => asserts state is ParserState & {\n securityArchive: NonNullable<ParserState['securityArchive']>\n} = (state, name) => {\n if (!state.securityArchive) {\n throw error(\n `Missing security archive while trying to parse the :${name} selector`,\n { found: state },\n )\n }\n}\n\n/**\n * Clears all nodes and edges from the results.\n */\nexport const clear = (state: ParserState): ParserState => {\n state.partial.nodes.clear()\n state.partial.edges.clear()\n return state\n}\n\n/**\n * Reusable security selector alert filter.\n */\nexport const createSecuritySelectorFilter = (\n name: string,\n type: string,\n) => {\n return async (state: ParserState) => {\n assertSecurityArchive(state, name)\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(\n alert => alert.type === type,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { ParserState } from '../types.ts';
2
+ /**
3
+ * Creates a path matcher function that tests if
4
+ * a given path matches a glob pattern.
5
+ */
6
+ export declare function createPathMatcher(pattern: string, loose?: boolean): (path: string) => boolean;
7
+ /**
8
+ * :path("glob") Pseudo-Selector will match only workspace & file
9
+ * nodes whose file path matches the provided glob pattern relative
10
+ * to the project root. Path patterns must be quoted strings to avoid
11
+ * parser conflicts with special characters.
12
+ */
13
+ export declare const path: (state: ParserState) => Promise<ParserState>;
14
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/pseudo/path.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,UAAQ,UAEhD,MAAM,aAsBrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,UAAiB,WAAW,yBAsE5C,CAAA"}
@@ -0,0 +1,95 @@
1
+ import { minimatch } from 'minimatch';
2
+ import { error } from '@vltpkg/error-cause';
3
+ import { splitDepID } from '@vltpkg/dep-id/browser';
4
+ import { asError } from '@vltpkg/types';
5
+ import { asPostcssNodeWithChildren, asStringNode, isStringNode, } from '@vltpkg/dss-parser';
6
+ import { removeNode, removeDanglingEdges, removeQuotes, clear, } from "./helpers.js";
7
+ /**
8
+ * Creates a path matcher function that tests if
9
+ * a given path matches a glob pattern.
10
+ */
11
+ export function createPathMatcher(pattern, loose = false) {
12
+ const isRoot = pattern === '.';
13
+ return (path) => {
14
+ if (isRoot) {
15
+ return path === '.' || path === '';
16
+ }
17
+ try {
18
+ return minimatch(path, pattern, {
19
+ dot: true,
20
+ nocase: false,
21
+ matchBase: pattern === '*',
22
+ });
23
+ }
24
+ catch (err) {
25
+ // In loose mode, return false for invalid patterns
26
+ if (loose) {
27
+ return false;
28
+ }
29
+ // In strict mode, throw an error
30
+ throw error('Invalid glob pattern in :path selector', asError(err));
31
+ }
32
+ };
33
+ }
34
+ /**
35
+ * :path("glob") Pseudo-Selector will match only workspace & file
36
+ * nodes whose file path matches the provided glob pattern relative
37
+ * to the project root. Path patterns must be quoted strings to avoid
38
+ * parser conflicts with special characters.
39
+ */
40
+ export const path = async (state) => {
41
+ // Extract path container and handle empty parameters
42
+ const pathContainer = asPostcssNodeWithChildren(state.current);
43
+ if (!pathContainer.nodes[0]) {
44
+ return clear(state);
45
+ }
46
+ // Extract the selector node and handle empty selectors
47
+ const selector = asPostcssNodeWithChildren(pathContainer.nodes[0]);
48
+ if (!selector.nodes[0]) {
49
+ return clear(state);
50
+ }
51
+ // Extract and validate the path pattern
52
+ let pathPattern = '';
53
+ if (isStringNode(selector.nodes[0])) {
54
+ pathPattern = removeQuotes(asStringNode(selector.nodes[0]).value);
55
+ }
56
+ else {
57
+ if (state.loose) {
58
+ return clear(state);
59
+ }
60
+ throw error('Failed to parse path pattern in :path selector', new Error('Path pattern must be a quoted string'));
61
+ }
62
+ // If no pattern provided, match nothing
63
+ if (!pathPattern) {
64
+ return clear(state);
65
+ }
66
+ // Check for unmatched brackets
67
+ if (pathPattern === '[' ||
68
+ (pathPattern.includes('[') && !pathPattern.includes(']'))) {
69
+ if (state.loose) {
70
+ return clear(state);
71
+ }
72
+ throw error('Invalid glob pattern in :path selector', new Error(`Unmatched bracket in pattern: ${pathPattern}`));
73
+ }
74
+ // Create path matcher function
75
+ const matchPath = createPathMatcher(pathPattern, state.loose);
76
+ // Filter nodes by path
77
+ for (const node of state.partial.nodes) {
78
+ /* c8 ignore next */
79
+ const nodePath = node.location || '';
80
+ const [type] = splitDepID(node.id);
81
+ // Special case for main importer with root path pattern
82
+ if (pathPattern === '.' && node.mainImporter) {
83
+ continue; // Keep main importer node for root path pattern
84
+ }
85
+ // Only match workspace or file nodes with matching paths
86
+ const pathBased = type === 'workspace' || type === 'file';
87
+ if (!pathBased || !matchPath(nodePath)) {
88
+ removeNode(state, node);
89
+ }
90
+ }
91
+ // Clean up any dangling edges
92
+ removeDanglingEdges(state);
93
+ return state;
94
+ };
95
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/pseudo/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,KAAK,GACN,MAAM,cAAc,CAAA;AAGrB;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,KAAK,GAAG,KAAK;IAC9D,MAAM,MAAM,GAAG,OAAO,KAAK,GAAG,CAAA;IAC9B,OAAO,CAAC,IAAY,EAAE,EAAE;QACtB,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,EAAE,CAAA;QACpC,CAAC;QACD,I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AAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,8BAA8B;IAC9B,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAC1B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { minimatch } from 'minimatch'\nimport { error } from '@vltpkg/error-cause'\nimport { splitDepID } from '@vltpkg/dep-id/browser'\nimport { asError } from '@vltpkg/types'\nimport {\n asPostcssNodeWithChildren,\n asStringNode,\n isStringNode,\n} from '@vltpkg/dss-parser'\nimport {\n removeNode,\n removeDanglingEdges,\n removeQuotes,\n clear,\n} from './helpers.ts'\nimport type { ParserState } from '../types.ts'\n\n/**\n * Creates a path matcher function that tests if\n * a given path matches a glob pattern.\n */\nexport function createPathMatcher(pattern: string, loose = false) {\n const isRoot = pattern === '.'\n return (path: string) => {\n if (isRoot) {\n return path === '.' || path === ''\n }\n try {\n return minimatch(path, pattern, {\n dot: true,\n nocase: false,\n matchBase: pattern === '*',\n })\n } catch (err) {\n // In loose mode, return false for invalid patterns\n if (loose) {\n return false\n }\n // In strict mode, throw an error\n throw error(\n 'Invalid glob pattern in :path selector',\n asError(err),\n )\n }\n }\n}\n\n/**\n * :path(\"glob\") Pseudo-Selector will match only workspace & file\n * nodes whose file path matches the provided glob pattern relative\n * to the project root. Path patterns must be quoted strings to avoid\n * parser conflicts with special characters.\n */\nexport const path = async (state: ParserState) => {\n // Extract path container and handle empty parameters\n const pathContainer = asPostcssNodeWithChildren(state.current)\n if (!pathContainer.nodes[0]) {\n return clear(state)\n }\n\n // Extract the selector node and handle empty selectors\n const selector = asPostcssNodeWithChildren(pathContainer.nodes[0])\n if (!selector.nodes[0]) {\n return clear(state)\n }\n\n // Extract and validate the path pattern\n let pathPattern = ''\n if (isStringNode(selector.nodes[0])) {\n pathPattern = removeQuotes(asStringNode(selector.nodes[0]).value)\n } else {\n if (state.loose) {\n return clear(state)\n }\n throw error(\n 'Failed to parse path pattern in :path selector',\n new Error('Path pattern must be a quoted string'),\n )\n }\n\n // If no pattern provided, match nothing\n if (!pathPattern) {\n return clear(state)\n }\n\n // Check for unmatched brackets\n if (\n pathPattern === '[' ||\n (pathPattern.includes('[') && !pathPattern.includes(']'))\n ) {\n if (state.loose) {\n return clear(state)\n }\n throw error(\n 'Invalid glob pattern in :path selector',\n new Error(`Unmatched bracket in pattern: ${pathPattern}`),\n )\n }\n\n // Create path matcher function\n const matchPath = createPathMatcher(pathPattern, state.loose)\n\n // Filter nodes by path\n for (const node of state.partial.nodes) {\n /* c8 ignore next */\n const nodePath = node.location || ''\n const [type] = splitDepID(node.id)\n\n // Special case for main importer with root path pattern\n if (pathPattern === '.' && node.mainImporter) {\n continue // Keep main importer node for root path pattern\n }\n\n // Only match workspace or file nodes with matching paths\n const pathBased = type === 'workspace' || type === 'file'\n if (!pathBased || !matchPath(nodePath)) {\n removeNode(state, node)\n }\n }\n\n // Clean up any dangling edges\n removeDanglingEdges(state)\n return state\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AA0DA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,YAAY,CAAA;AA4RvD;;GAEG;AACH,eAAO,MAAM,MAAM,UAAiB,WAAW,yBAkC9C,CAAA"}
1
+ {"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../src/pseudo.ts"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,YAAY,CAAA;AA6RvD;;GAEG;AACH,eAAO,MAAM,MAAM,UAAiB,WAAW,yBAkC9C,CAAA"}
@@ -26,6 +26,7 @@ import { network } from "./pseudo/network.js";
26
26
  import { obfuscated } from "./pseudo/obfuscated.js";
27
27
  import { optional } from "./pseudo/optional.js";
28
28
  import { outdated } from "./pseudo/outdated.js";
29
+ import { path } from "./pseudo/path.js";
29
30
  import { peer } from "./pseudo/peer.js";
30
31
  import { published } from "./pseudo/published.js";
31
32
  import { privateParser } from "./pseudo/private.js";
@@ -285,6 +286,7 @@ const pseudoSelectors = new Map(Object.entries({
285
286
  obfuscated,
286
287
  optional,
287
288
  outdated,
289
+ path,
288
290
  peer,
289
291
  published,
290
292
  // TODO: overridden
@@ -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;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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C3B,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 { 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\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 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"]}
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,OA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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 { path } from './pseudo/path.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\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 path,\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/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-14",
4
+ "version": "0.0.0-16",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -19,27 +19,28 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
+ "minimatch": "^10.0.1",
22
23
  "p-retry": "^6.2.1",
23
24
  "postcss-selector-parser": "^7.1.0",
24
- "@vltpkg/dep-id": "0.0.0-14",
25
- "@vltpkg/dss-parser": "0.0.0-14",
26
- "@vltpkg/security-archive": "0.0.0-14",
27
- "@vltpkg/graph": "0.0.0-14",
28
- "@vltpkg/error-cause": "0.0.0-14",
29
- "@vltpkg/types": "0.0.0-14",
30
- "@vltpkg/semver": "0.0.0-14"
25
+ "@vltpkg/dep-id": "0.0.0-16",
26
+ "@vltpkg/graph": "0.0.0-16",
27
+ "@vltpkg/security-archive": "0.0.0-16",
28
+ "@vltpkg/semver": "0.0.0-16",
29
+ "@vltpkg/types": "0.0.0-16",
30
+ "@vltpkg/error-cause": "0.0.0-16",
31
+ "@vltpkg/dss-parser": "0.0.0-16"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@eslint/js": "^9.28.0",
34
35
  "@types/node": "^22.15.29",
35
36
  "eslint": "^9.28.0",
36
- "prettier": "^3.5.3",
37
+ "prettier": "^3.6.0",
37
38
  "tap": "^21.1.0",
38
39
  "tshy": "^3.0.2",
39
40
  "typedoc": "~0.27.9",
40
41
  "typescript": "5.7.3",
41
42
  "typescript-eslint": "^8.33.1",
42
- "@vltpkg/spec": "0.0.0-14"
43
+ "@vltpkg/spec": "0.0.0-16"
43
44
  },
44
45
  "license": "BSD-2-Clause-Patent",
45
46
  "engines": {