@vltpkg/dss-breadcrumb 0.0.0-14 → 0.0.0-15
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/index.d.ts +10 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +34 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +8 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModifierBreadcrumb, ModifierBreadcrumbItem, ModifierInteractiveBreadcrumb } from './types.ts';
|
|
1
|
+
import type { ModifierBreadcrumb, ModifierBreadcrumbItem, ModifierInteractiveBreadcrumb, BreadcrumbSpecificity } from './types.ts';
|
|
2
2
|
export * from './types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* The Breadcrumb class is used to represent a valid breadcrumb
|
|
@@ -8,7 +8,7 @@ export * from './types.ts';
|
|
|
8
8
|
* as a term used to describe the subset of the query language that uses
|
|
9
9
|
* only root/workspace selectors, id selectors & combinators.
|
|
10
10
|
*
|
|
11
|
-
* The Breadcrumb implements a doubly-linked list of items
|
|
11
|
+
* The Breadcrumb class implements a doubly-linked list of items
|
|
12
12
|
* that can be used to navigate through the breadcrumb.
|
|
13
13
|
* The InteractiveBreadcrumb can also be used to keep track of state
|
|
14
14
|
* of the current breadcrumb item that should be used for checks.
|
|
@@ -20,6 +20,7 @@ export * from './types.ts';
|
|
|
20
20
|
export declare class Breadcrumb implements ModifierBreadcrumb {
|
|
21
21
|
#private;
|
|
22
22
|
comment: string | undefined;
|
|
23
|
+
specificity: BreadcrumbSpecificity;
|
|
23
24
|
/**
|
|
24
25
|
* Initializes the interactive breadcrumb with a query string.
|
|
25
26
|
*/
|
|
@@ -72,4 +73,11 @@ export declare class InteractiveBreadcrumb implements ModifierInteractiveBreadcr
|
|
|
72
73
|
* for a given query string.
|
|
73
74
|
*/
|
|
74
75
|
export declare const parseBreadcrumb: (query: string) => ModifierBreadcrumb;
|
|
76
|
+
/**
|
|
77
|
+
* Sorts an array of Breadcrumb objects by specificity. Objects with
|
|
78
|
+
* higher idCounter values come first, if idCounter values are equal,
|
|
79
|
+
* then objects with higher commonCounter values come first. Otherwise,
|
|
80
|
+
* the original order is preserved.
|
|
81
|
+
*/
|
|
82
|
+
export declare const specificitySort: (breadcrumbs: ModifierBreadcrumb[]) => ModifierBreadcrumb[];
|
|
75
83
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAEnB,cAAc,YAAY,CAAA;AAE1B;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAW,YAAW,kBAAkB;;IAEnD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,EAAE,qBAAqB,CAAA;IAElC;;OAEG;gBACS,KAAK,EAAE,MAAM;IA8HzB;;OAEG;IACH,IAAI,KAAK,IAAI,sBAAsB,CAKlC;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,sBAAsB,CAMjC;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIjB;;OAEG;IACH,KAAK;IAQL;;;OAGG;IACH,WAAW;CAGZ;AAED;;;GAGG;AACH,qBAAa,qBACX,YAAW,6BAA6B;;gBAG5B,UAAU,EAAE,UAAU;IAIlC;;OAEG;IACH,IAAI,OAAO,IAAI,sBAAsB,GAAG,SAAS,CAEhD;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI;CAIb;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,kBACzB,CAAA;AAEvB;;;;;GAKG;AACH,eAAO,MAAM,eAAe,gBACb,kBAAkB,EAAE,KAChC,kBAAkB,EAepB,CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export * from "./types.js";
|
|
|
9
9
|
* as a term used to describe the subset of the query language that uses
|
|
10
10
|
* only root/workspace selectors, id selectors & combinators.
|
|
11
11
|
*
|
|
12
|
-
* The Breadcrumb implements a doubly-linked list of items
|
|
12
|
+
* The Breadcrumb class implements a doubly-linked list of items
|
|
13
13
|
* that can be used to navigate through the breadcrumb.
|
|
14
14
|
* The InteractiveBreadcrumb can also be used to keep track of state
|
|
15
15
|
* of the current breadcrumb item that should be used for checks.
|
|
@@ -21,11 +21,13 @@ export * from "./types.js";
|
|
|
21
21
|
export class Breadcrumb {
|
|
22
22
|
#items;
|
|
23
23
|
comment;
|
|
24
|
+
specificity;
|
|
24
25
|
/**
|
|
25
26
|
* Initializes the interactive breadcrumb with a query string.
|
|
26
27
|
*/
|
|
27
28
|
constructor(query) {
|
|
28
29
|
this.#items = [];
|
|
30
|
+
this.specificity = { idCounter: 0, commonCounter: 0 };
|
|
29
31
|
const ast = parse(query);
|
|
30
32
|
// Keep track of the previous AST node for consolidation
|
|
31
33
|
let prevNode;
|
|
@@ -84,6 +86,8 @@ export class Breadcrumb {
|
|
|
84
86
|
// Modify the last item to include the ID
|
|
85
87
|
lastItem.name = item.value;
|
|
86
88
|
lastItem.value = `${lastItem.value}#${item.value}`;
|
|
89
|
+
// Update specificity for the ID part
|
|
90
|
+
this.specificity.idCounter++;
|
|
87
91
|
prevNode = undefined;
|
|
88
92
|
continue;
|
|
89
93
|
}
|
|
@@ -94,6 +98,8 @@ export class Breadcrumb {
|
|
|
94
98
|
// Modify the last item to include the pseudo
|
|
95
99
|
lastItem.value = `${lastItem.value}${item.value}`;
|
|
96
100
|
lastItem.importer = true;
|
|
101
|
+
// Update specificity for the pseudo part
|
|
102
|
+
this.specificity.commonCounter++;
|
|
97
103
|
prevNode = undefined;
|
|
98
104
|
continue;
|
|
99
105
|
}
|
|
@@ -109,6 +115,13 @@ export class Breadcrumb {
|
|
|
109
115
|
lastItem.next = newItem;
|
|
110
116
|
}
|
|
111
117
|
this.#items.push(newItem);
|
|
118
|
+
// Update specificity counters
|
|
119
|
+
if (isIdentifierNode(item)) {
|
|
120
|
+
this.specificity.idCounter++;
|
|
121
|
+
}
|
|
122
|
+
else if (isPseudoNode(item)) {
|
|
123
|
+
this.specificity.commonCounter++;
|
|
124
|
+
}
|
|
112
125
|
prevNode = item;
|
|
113
126
|
}
|
|
114
127
|
}
|
|
@@ -200,4 +213,24 @@ export class InteractiveBreadcrumb {
|
|
|
200
213
|
* for a given query string.
|
|
201
214
|
*/
|
|
202
215
|
export const parseBreadcrumb = (query) => new Breadcrumb(query);
|
|
216
|
+
/**
|
|
217
|
+
* Sorts an array of Breadcrumb objects by specificity. Objects with
|
|
218
|
+
* higher idCounter values come first, if idCounter values are equal,
|
|
219
|
+
* then objects with higher commonCounter values come first. Otherwise,
|
|
220
|
+
* the original order is preserved.
|
|
221
|
+
*/
|
|
222
|
+
export const specificitySort = (breadcrumbs) => {
|
|
223
|
+
return [...breadcrumbs].sort((a, b) => {
|
|
224
|
+
// First compare by idCounter (higher comes first)
|
|
225
|
+
if (a.specificity.idCounter !== b.specificity.idCounter) {
|
|
226
|
+
return b.specificity.idCounter - a.specificity.idCounter;
|
|
227
|
+
}
|
|
228
|
+
// If idCounter values are equal, compare by commonCounter
|
|
229
|
+
if (a.specificity.commonCounter !== b.specificity.commonCounter) {
|
|
230
|
+
return b.specificity.commonCounter - a.specificity.commonCounter;
|
|
231
|
+
}
|
|
232
|
+
// If both counters are equal, preserve original order
|
|
233
|
+
return 0;
|
|
234
|
+
});
|
|
235
|
+
};
|
|
203
236
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,KAAK,GACN,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAQ3C,cAAc,YAAY,CAAA;AAE1B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,UAAU;IACrB,MAAM,CAA0B;IAChC,OAAO,CAAoB;IAE3B;;OAEG;IACH,YAAY,KAAa;QACvB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;QAExB,wDAAwD;QACxD,IAAI,QAAiC,CAAA;QAErC,oDAAoD;QACpD,sCAAsC;QACtC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnC,MAAM,oBAAoB,GACxB,YAAY,CAAC,IAAI,CAAC;gBAClB,CAAC,IAAI,CAAC,KAAK,KAAK,YAAY,IAAI,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,CAAA;YAE5D,MAAM,kBAAkB,GACtB,YAAY,CAAC,IAAI,CAAC;gBAClB,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO;oBACrB,IAAI,CAAC,KAAK,KAAK,YAAY;oBAC3B,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,CAAA;YAE9B,MAAM,YAAY,GAChB,gBAAgB,CAAC,IAAI,CAAC;gBACtB,kBAAkB;gBAClB,CAAC,gBAAgB,CAAC,IAAI,C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CAAC;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;IACxB,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAGhC,QAAQ,CAAoC;IAC5C,YAAY,UAAsB;QAChC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAA;IAClC,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAsB,EAAE,CACnE,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA","sourcesContent":["import {\n isPostcssNodeWithChildren,\n isPseudoNode,\n isIdentifierNode,\n isCombinatorNode,\n isCommentNode,\n parse,\n} from '@vltpkg/dss-parser'\nimport { error } from '@vltpkg/error-cause'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\nimport type {\n ModifierBreadcrumb,\n ModifierBreadcrumbItem,\n ModifierInteractiveBreadcrumb,\n} from './types.ts'\n\nexport * from './types.ts'\n\n/**\n * The Breadcrumb class is used to represent a valid breadcrumb\n * path that helps you traverse a graph and find a specific node or edge.\n *\n * Alongside the traditional analogy, \"Breadcrumb\" is also being used here\n * as a term used to describe the subset of the query language that uses\n * only root/workspace selectors, id selectors & combinators.\n *\n * The Breadcrumb implements a doubly-linked list of items\n * that can be used to navigate through the breadcrumb.\n * The InteractiveBreadcrumb can also be used to keep track of state\n * of the current breadcrumb item that should be used for checks.\n *\n * It also validates that each element of the provided query string is\n * valid according to the previous definition of a \"Breadcrumb\" query\n * language subset.\n */\nexport class Breadcrumb implements ModifierBreadcrumb {\n #items: ModifierBreadcrumbItem[]\n comment: string | undefined\n\n /**\n * Initializes the interactive breadcrumb with a query string.\n */\n constructor(query: string) {\n this.#items = []\n const ast = parse(query)\n\n // Keep track of the previous AST node for consolidation\n let prevNode: PostcssNode | undefined\n\n // iterates only at the first level of the AST since\n // any nested nodes are invalid syntax\n for (const item of ast.first.nodes) {\n const isWorkspaceOrProject =\n isPseudoNode(item) &&\n (item.value === ':workspace' || item.value === ':project')\n\n const allowedPseudoNodes =\n isPseudoNode(item) &&\n (item.value === ':root' ||\n item.value === ':workspace' ||\n item.value === ':project')\n\n const allowedTypes =\n isIdentifierNode(item) ||\n allowedPseudoNodes ||\n (isCombinatorNode(item) && item.value === '>') ||\n isCommentNode(item)\n\n // Check if this is a nested selector that's not an allowed pseudo\n const isNestedSelector =\n isPostcssNodeWithChildren(item) &&\n !(allowedPseudoNodes && item.nodes.length === 0)\n\n // validation, only the root/workspace selectors, id selectors\n // and combinators are valid ast node items\n if (isNestedSelector || !allowedTypes) {\n throw error('Invalid query', { found: query })\n }\n\n // combinators and comments are skipped\n if (isCombinatorNode(item)) {\n prevNode = undefined\n continue\n } else if (isCommentNode(item)) {\n const cleanComment = item.value\n .replace(/^\\/\\*/, '')\n .replace(/\\*\\/$/, '')\n .trim()\n this.comment = cleanComment\n prevNode = undefined\n } else {\n // check if we need to consolidate with previous item\n const isPrevWorkspaceOrProject =\n prevNode &&\n isPseudoNode(prevNode) &&\n (prevNode.value === ':workspace' ||\n prevNode.value === ':project')\n\n const isPrevId = prevNode && isIdentifierNode(prevNode)\n const isCurrentId = isIdentifierNode(item)\n\n // we define the last item as we iterate through the list of\n // breadcrumb items so that this value can also be used to\n // update previous items when needed\n const lastItem =\n this.#items.length > 0 ?\n this.#items[this.#items.length - 1]\n : undefined\n\n // current node is ID, previous was workspace/project\n // we fold the current node value into the same object\n // and move on to the next ast item\n if (isCurrentId && isPrevWorkspaceOrProject && lastItem) {\n // Modify the last item to include the ID\n lastItem.name = item.value\n lastItem.value = `${lastItem.value}#${item.value}`\n prevNode = undefined\n continue\n }\n\n // current node is workspace/project, previous was ID\n // we fold the current node value into the same object\n // and move on to the next ast item\n if (isWorkspaceOrProject && isPrevId && lastItem) {\n // Modify the last item to include the pseudo\n lastItem.value = `${lastItem.value}${item.value}`\n lastItem.importer = true\n prevNode = undefined\n continue\n }\n\n const newItem = {\n value: item.type === 'id' ? `#${item.value}` : item.value,\n name: item.type === 'id' ? item.value : undefined,\n type: item.type,\n prev: lastItem,\n next: undefined,\n importer: allowedPseudoNodes,\n }\n if (lastItem) {\n lastItem.next = newItem\n }\n this.#items.push(newItem)\n prevNode = item\n }\n }\n // the parsed query should have at least one item\n // that is then going to be set as the current item\n if (!this.#items[0]) {\n throw error('Failed to parse query', {\n found: query,\n })\n }\n }\n\n /**\n * Retrieves the first breadcrumb item.\n */\n get first(): ModifierBreadcrumbItem {\n if (!this.#items[0]) {\n throw error('Failed to find first breadcrumb item')\n }\n return this.#items[0]\n }\n\n /**\n * Retrieves the last breadcrumb item.\n */\n get last(): ModifierBreadcrumbItem {\n const lastItem = this.#items[this.#items.length - 1]\n if (!lastItem) {\n throw error('Failed to find first breadcrumb item')\n }\n return lastItem\n }\n\n /**\n * Returns `true` if the breadcrumb is composed of a single item.\n */\n get single(): boolean {\n return this.#items.length === 1\n }\n\n [Symbol.iterator]() {\n return this.#items.values()\n }\n\n /**\n * Empties the current breadcrumb list.\n */\n clear() {\n for (const item of this.#items) {\n item.prev = undefined\n item.next = undefined\n }\n this.#items.length = 0\n }\n\n /**\n * Gets an {@link InteractiveBreadcrumb} instance that can be\n * used to track state of the current breadcrumb item.\n */\n interactive() {\n return new InteractiveBreadcrumb(this)\n }\n}\n\n/**\n * The InteractiveBreadcrumb is used to keep track of state\n * of the current breadcrumb item that should be used for checks.\n */\nexport class InteractiveBreadcrumb\n implements ModifierInteractiveBreadcrumb\n{\n #current: ModifierBreadcrumbItem | undefined\n constructor(breadcrumb: Breadcrumb) {\n this.#current = breadcrumb.first\n }\n\n /**\n * The current breadcrumb item.\n */\n get current(): ModifierBreadcrumbItem | undefined {\n return this.#current\n }\n\n /**\n * Returns `true` if the current breadcrumb has no more items left.\n */\n get done(): boolean {\n return !this.#current\n }\n\n /**\n * The next breadcrumb item.\n */\n next(): this {\n this.#current = this.#current?.next\n return this\n }\n}\n\n/**\n * Returns an {@link Breadcrumb} list of items\n * for a given query string.\n */\nexport const parseBreadcrumb = (query: string): ModifierBreadcrumb =>\n new Breadcrumb(query)\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,KAAK,GACN,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAS3C,cAAc,YAAY,CAAA;AAE1B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,UAAU;IACrB,MAAM,CAA0B;IAChC,OAAO,CAAoB;IAC3B,WAAW,CAAuB;IAElC;;OAEG;IACH,YAAY,KAAa;QACvB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAA;QACrD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;QAExB,wDAAwD;QACxD,IAAI,QAAiC,CAAA;QAErC,oDAAoD;QACpD,sCAAsC;QACtC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnC,MAAM,oBAAoB,GACxB,YAAY,CAAC,IAAI,CAAC;gBAClB,CAAC,IAAI,CAAC,K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AAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAsB,EAAE,CACnE,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,WAAiC,EACX,EAAE;IACxB,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpC,kDAAkD;QAClD,IAAI,CAAC,CAAC,WAAW,CAAC,SAAS,KAAK,CAAC,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;YACxD,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC,SAAS,CAAA;QAC1D,CAAC;QAED,0DAA0D;QAC1D,IAAI,CAAC,CAAC,WAAW,CAAC,aAAa,KAAK,CAAC,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC;YAChE,OAAO,CAAC,CAAC,WAAW,CAAC,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,aAAa,CAAA;QAClE,CAAC;QAED,sDAAsD;QACtD,OAAO,CAAC,CAAA;IACV,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import {\n isPostcssNodeWithChildren,\n isPseudoNode,\n isIdentifierNode,\n isCombinatorNode,\n isCommentNode,\n parse,\n} from '@vltpkg/dss-parser'\nimport { error } from '@vltpkg/error-cause'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\nimport type {\n ModifierBreadcrumb,\n ModifierBreadcrumbItem,\n ModifierInteractiveBreadcrumb,\n BreadcrumbSpecificity,\n} from './types.ts'\n\nexport * from './types.ts'\n\n/**\n * The Breadcrumb class is used to represent a valid breadcrumb\n * path that helps you traverse a graph and find a specific node or edge.\n *\n * Alongside the traditional analogy, \"Breadcrumb\" is also being used here\n * as a term used to describe the subset of the query language that uses\n * only root/workspace selectors, id selectors & combinators.\n *\n * The Breadcrumb class implements a doubly-linked list of items\n * that can be used to navigate through the breadcrumb.\n * The InteractiveBreadcrumb can also be used to keep track of state\n * of the current breadcrumb item that should be used for checks.\n *\n * It also validates that each element of the provided query string is\n * valid according to the previous definition of a \"Breadcrumb\" query\n * language subset.\n */\nexport class Breadcrumb implements ModifierBreadcrumb {\n #items: ModifierBreadcrumbItem[]\n comment: string | undefined\n specificity: BreadcrumbSpecificity\n\n /**\n * Initializes the interactive breadcrumb with a query string.\n */\n constructor(query: string) {\n this.#items = []\n this.specificity = { idCounter: 0, commonCounter: 0 }\n const ast = parse(query)\n\n // Keep track of the previous AST node for consolidation\n let prevNode: PostcssNode | undefined\n\n // iterates only at the first level of the AST since\n // any nested nodes are invalid syntax\n for (const item of ast.first.nodes) {\n const isWorkspaceOrProject =\n isPseudoNode(item) &&\n (item.value === ':workspace' || item.value === ':project')\n\n const allowedPseudoNodes =\n isPseudoNode(item) &&\n (item.value === ':root' ||\n item.value === ':workspace' ||\n item.value === ':project')\n\n const allowedTypes =\n isIdentifierNode(item) ||\n allowedPseudoNodes ||\n (isCombinatorNode(item) && item.value === '>') ||\n isCommentNode(item)\n\n // Check if this is a nested selector that's not an allowed pseudo\n const isNestedSelector =\n isPostcssNodeWithChildren(item) &&\n !(allowedPseudoNodes && item.nodes.length === 0)\n\n // validation, only the root/workspace selectors, id selectors\n // and combinators are valid ast node items\n if (isNestedSelector || !allowedTypes) {\n throw error('Invalid query', { found: query })\n }\n\n // combinators and comments are skipped\n if (isCombinatorNode(item)) {\n prevNode = undefined\n continue\n } else if (isCommentNode(item)) {\n const cleanComment = item.value\n .replace(/^\\/\\*/, '')\n .replace(/\\*\\/$/, '')\n .trim()\n this.comment = cleanComment\n prevNode = undefined\n } else {\n // check if we need to consolidate with previous item\n const isPrevWorkspaceOrProject =\n prevNode &&\n isPseudoNode(prevNode) &&\n (prevNode.value === ':workspace' ||\n prevNode.value === ':project')\n\n const isPrevId = prevNode && isIdentifierNode(prevNode)\n const isCurrentId = isIdentifierNode(item)\n\n // we define the last item as we iterate through the list of\n // breadcrumb items so that this value can also be used to\n // update previous items when needed\n const lastItem =\n this.#items.length > 0 ?\n this.#items[this.#items.length - 1]\n : undefined\n\n // current node is ID, previous was workspace/project\n // we fold the current node value into the same object\n // and move on to the next ast item\n if (isCurrentId && isPrevWorkspaceOrProject && lastItem) {\n // Modify the last item to include the ID\n lastItem.name = item.value\n lastItem.value = `${lastItem.value}#${item.value}`\n // Update specificity for the ID part\n this.specificity.idCounter++\n prevNode = undefined\n continue\n }\n\n // current node is workspace/project, previous was ID\n // we fold the current node value into the same object\n // and move on to the next ast item\n if (isWorkspaceOrProject && isPrevId && lastItem) {\n // Modify the last item to include the pseudo\n lastItem.value = `${lastItem.value}${item.value}`\n lastItem.importer = true\n // Update specificity for the pseudo part\n this.specificity.commonCounter++\n prevNode = undefined\n continue\n }\n\n const newItem = {\n value: item.type === 'id' ? `#${item.value}` : item.value,\n name: item.type === 'id' ? item.value : undefined,\n type: item.type,\n prev: lastItem,\n next: undefined,\n importer: allowedPseudoNodes,\n }\n if (lastItem) {\n lastItem.next = newItem\n }\n this.#items.push(newItem)\n\n // Update specificity counters\n if (isIdentifierNode(item)) {\n this.specificity.idCounter++\n } else if (isPseudoNode(item)) {\n this.specificity.commonCounter++\n }\n\n prevNode = item\n }\n }\n // the parsed query should have at least one item\n // that is then going to be set as the current item\n if (!this.#items[0]) {\n throw error('Failed to parse query', {\n found: query,\n })\n }\n }\n\n /**\n * Retrieves the first breadcrumb item.\n */\n get first(): ModifierBreadcrumbItem {\n if (!this.#items[0]) {\n throw error('Failed to find first breadcrumb item')\n }\n return this.#items[0]\n }\n\n /**\n * Retrieves the last breadcrumb item.\n */\n get last(): ModifierBreadcrumbItem {\n const lastItem = this.#items[this.#items.length - 1]\n if (!lastItem) {\n throw error('Failed to find first breadcrumb item')\n }\n return lastItem\n }\n\n /**\n * Returns `true` if the breadcrumb is composed of a single item.\n */\n get single(): boolean {\n return this.#items.length === 1\n }\n\n [Symbol.iterator]() {\n return this.#items.values()\n }\n\n /**\n * Empties the current breadcrumb list.\n */\n clear() {\n for (const item of this.#items) {\n item.prev = undefined\n item.next = undefined\n }\n this.#items.length = 0\n }\n\n /**\n * Gets an {@link InteractiveBreadcrumb} instance that can be\n * used to track state of the current breadcrumb item.\n */\n interactive() {\n return new InteractiveBreadcrumb(this)\n }\n}\n\n/**\n * The InteractiveBreadcrumb is used to keep track of state\n * of the current breadcrumb item that should be used for checks.\n */\nexport class InteractiveBreadcrumb\n implements ModifierInteractiveBreadcrumb\n{\n #current: ModifierBreadcrumbItem | undefined\n constructor(breadcrumb: Breadcrumb) {\n this.#current = breadcrumb.first\n }\n\n /**\n * The current breadcrumb item.\n */\n get current(): ModifierBreadcrumbItem | undefined {\n return this.#current\n }\n\n /**\n * Returns `true` if the current breadcrumb has no more items left.\n */\n get done(): boolean {\n return !this.#current\n }\n\n /**\n * The next breadcrumb item.\n */\n next(): this {\n this.#current = this.#current?.next\n return this\n }\n}\n\n/**\n * Returns an {@link Breadcrumb} list of items\n * for a given query string.\n */\nexport const parseBreadcrumb = (query: string): ModifierBreadcrumb =>\n new Breadcrumb(query)\n\n/**\n * Sorts an array of Breadcrumb objects by specificity. Objects with\n * higher idCounter values come first, if idCounter values are equal,\n * then objects with higher commonCounter values come first. Otherwise,\n * the original order is preserved.\n */\nexport const specificitySort = (\n breadcrumbs: ModifierBreadcrumb[],\n): ModifierBreadcrumb[] => {\n return [...breadcrumbs].sort((a, b) => {\n // First compare by idCounter (higher comes first)\n if (a.specificity.idCounter !== b.specificity.idCounter) {\n return b.specificity.idCounter - a.specificity.idCounter\n }\n\n // If idCounter values are equal, compare by commonCounter\n if (a.specificity.commonCounter !== b.specificity.commonCounter) {\n return b.specificity.commonCounter - a.specificity.commonCounter\n }\n\n // If both counters are equal, preserve original order\n return 0\n })\n}\n"]}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The specificity of a breadcrumb, used for sorting.
|
|
3
|
+
*/
|
|
4
|
+
export type BreadcrumbSpecificity = {
|
|
5
|
+
idCounter: number;
|
|
6
|
+
commonCounter: number;
|
|
7
|
+
};
|
|
1
8
|
/**
|
|
2
9
|
* A valid item of a given breadcrumb.
|
|
3
10
|
*/
|
|
@@ -19,6 +26,7 @@ export interface ModifierBreadcrumb extends Iterable<ModifierBreadcrumbItem> {
|
|
|
19
26
|
first: ModifierBreadcrumbItem;
|
|
20
27
|
last: ModifierBreadcrumbItem;
|
|
21
28
|
single: boolean;
|
|
29
|
+
specificity: BreadcrumbSpecificity;
|
|
22
30
|
interactive: () => ModifierInteractiveBreadcrumb;
|
|
23
31
|
}
|
|
24
32
|
/**
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,sBAAsB,GAAG,SAAS,CAAA;IACxC,IAAI,EAAE,sBAAsB,GAAG,SAAS,CAAA;CACzC,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,kBACf,SAAQ,QAAQ,CAAC,sBAAsB,CAAC;IACxC,KAAK,IAAI,IAAI,CAAA;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,EAAE,sBAAsB,CAAA;IAC7B,IAAI,EAAE,sBAAsB,CAAA;IAC5B,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,6BAA6B,CAAA;CACjD;AAED;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAAA;IAC3C,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,6BAA6B,CAAA;CAC1C,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,sBAAsB,GAAG,SAAS,CAAA;IACxC,IAAI,EAAE,sBAAsB,GAAG,SAAS,CAAA;CACzC,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,kBACf,SAAQ,QAAQ,CAAC,sBAAsB,CAAC;IACxC,KAAK,IAAI,IAAI,CAAA;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,EAAE,sBAAsB,CAAA;IAC7B,IAAI,EAAE,sBAAsB,CAAA;IAC5B,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,qBAAqB,CAAA;IAClC,WAAW,EAAE,MAAM,6BAA6B,CAAA;CACjD;AAED;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAAA;IAC3C,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,6BAA6B,CAAA;CAC1C,CAAA"}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A valid item of a given breadcrumb.\n */\nexport type ModifierBreadcrumbItem = {\n name?: string\n value: string\n type: string\n importer: boolean\n prev: ModifierBreadcrumbItem | undefined\n next: ModifierBreadcrumbItem | undefined\n}\n\n/**\n * A breadcrumb is a linked list of items, where\n * each item has a value and a type.\n */\nexport interface ModifierBreadcrumb\n extends Iterable<ModifierBreadcrumbItem> {\n clear(): void\n comment: string | undefined\n first: ModifierBreadcrumbItem\n last: ModifierBreadcrumbItem\n single: boolean\n interactive: () => ModifierInteractiveBreadcrumb\n}\n\n/**\n * An interactive breadcrumb that holds state on what is the current item.\n */\nexport type ModifierInteractiveBreadcrumb = {\n current: ModifierBreadcrumbItem | undefined\n done: boolean\n next: () => ModifierInteractiveBreadcrumb\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The specificity of a breadcrumb, used for sorting.\n */\nexport type BreadcrumbSpecificity = {\n idCounter: number\n commonCounter: number\n}\n\n/**\n * A valid item of a given breadcrumb.\n */\nexport type ModifierBreadcrumbItem = {\n name?: string\n value: string\n type: string\n importer: boolean\n prev: ModifierBreadcrumbItem | undefined\n next: ModifierBreadcrumbItem | undefined\n}\n\n/**\n * A breadcrumb is a linked list of items, where\n * each item has a value and a type.\n */\nexport interface ModifierBreadcrumb\n extends Iterable<ModifierBreadcrumbItem> {\n clear(): void\n comment: string | undefined\n first: ModifierBreadcrumbItem\n last: ModifierBreadcrumbItem\n single: boolean\n specificity: BreadcrumbSpecificity\n interactive: () => ModifierInteractiveBreadcrumb\n}\n\n/**\n * An interactive breadcrumb that holds state on what is the current item.\n */\nexport type ModifierInteractiveBreadcrumb = {\n current: ModifierBreadcrumbItem | undefined\n done: boolean\n next: () => ModifierInteractiveBreadcrumb\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/dss-breadcrumb",
|
|
3
3
|
"description": "The Dependency Selector Syntax (DSS) breadcrumb utilities",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-15",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@vltpkg/dss-parser": "0.0.0-
|
|
23
|
-
"@vltpkg/error-cause": "0.0.0-
|
|
22
|
+
"@vltpkg/dss-parser": "0.0.0-15",
|
|
23
|
+
"@vltpkg/error-cause": "0.0.0-15"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@eslint/js": "^9.28.0",
|