This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/** Finds the specified Angular @Input in the given elements with tag name. */
export declare function findInputsOnElementWithTag(html: string, inputName: string, tagNames: string[]): number[];
/** Finds the specified Angular @Input in elements that have one of the specified attributes. */
export declare function findInputsOnElementWithAttr(html: string, inputName: string, attrs: string[]): number[];
/** Finds the specified Angular @Output in the given elements with tag name. */
export declare function findOutputsOnElementWithTag(html: string, outputName: string, tagNames: string[]): number[];
/** Finds the specified Angular @Output in elements that have one of the specified attributes. */
export declare function findOutputsOnElementWithAttr(html: string, outputName: string, attrs: string[]): number[];

View File

@@ -0,0 +1,51 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.findInputsOnElementWithTag = findInputsOnElementWithTag;
exports.findInputsOnElementWithAttr = findInputsOnElementWithAttr;
exports.findOutputsOnElementWithTag = findOutputsOnElementWithTag;
exports.findOutputsOnElementWithAttr = findOutputsOnElementWithAttr;
const elements_1 = require("./elements");
/** Finds the specified Angular @Input in the given elements with tag name. */
function findInputsOnElementWithTag(html, inputName, tagNames) {
return [
// Inputs can be also used without brackets (e.g. `<mat-toolbar color="primary">`)
...(0, elements_1.findAttributeOnElementWithTag)(html, inputName, tagNames),
// Add one column to the mapped offset because the first bracket for the @Input
// is part of the attribute and therefore also part of the offset. We only want to return
// the offset for the inner name of the bracketed input.
...(0, elements_1.findAttributeOnElementWithTag)(html, `[${inputName}]`, tagNames).map(offset => offset + 1),
];
}
/** Finds the specified Angular @Input in elements that have one of the specified attributes. */
function findInputsOnElementWithAttr(html, inputName, attrs) {
return [
// Inputs can be also used without brackets (e.g. `<button matButton color="primary">`)
...(0, elements_1.findAttributeOnElementWithAttrs)(html, inputName, attrs),
// Add one column to the mapped offset because the first bracket for the @Input
// is part of the attribute and therefore also part of the offset. We only want to return
// the offset for the inner name of the bracketed input.
...(0, elements_1.findAttributeOnElementWithAttrs)(html, `[${inputName}]`, attrs).map(offset => offset + 1),
];
}
/** Finds the specified Angular @Output in the given elements with tag name. */
function findOutputsOnElementWithTag(html, outputName, tagNames) {
// Add one column to the mapped offset because the first parenthesis for the @Output
// is part of the attribute and therefore also part of the offset. We only want to return
// the offset for the inner name of the output.
return (0, elements_1.findAttributeOnElementWithTag)(html, `(${outputName})`, tagNames).map(offset => offset + 1);
}
/** Finds the specified Angular @Output in elements that have one of the specified attributes. */
function findOutputsOnElementWithAttr(html, outputName, attrs) {
// Add one column to the mapped offset because the first bracket for the @Output
// is part of the attribute and therefore also part of the offset. We only want to return
// the offset for the inner name of the output.
return (0, elements_1.findAttributeOnElementWithAttrs)(html, `(${outputName})`, attrs).map(offset => offset + 1);
}
//# sourceMappingURL=angular.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"angular.js","sourceRoot":"","sources":["angular.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAKH,gEASC;AAGD,kEASC;AAGD,kEAKC;AAGD,oEAKC;AAxCD,yCAA0F;AAE1F,8EAA8E;AAC9E,SAAgB,0BAA0B,CAAC,IAAY,EAAE,SAAiB,EAAE,QAAkB;IAC5F,OAAO;QACL,kFAAkF;QAClF,GAAG,IAAA,wCAA6B,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC;QAC3D,+EAA+E;QAC/E,yFAAyF;QACzF,wDAAwD;QACxD,GAAG,IAAA,wCAA6B,EAAC,IAAI,EAAE,IAAI,SAAS,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;KAC7F,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,SAAgB,2BAA2B,CAAC,IAAY,EAAE,SAAiB,EAAE,KAAe;IAC1F,OAAO;QACL,uFAAuF;QACvF,GAAG,IAAA,0CAA+B,EAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC;QAC1D,+EAA+E;QAC/E,yFAAyF;QACzF,wDAAwD;QACxD,GAAG,IAAA,0CAA+B,EAAC,IAAI,EAAE,IAAI,SAAS,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;KAC5F,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,SAAgB,2BAA2B,CAAC,IAAY,EAAE,UAAkB,EAAE,QAAkB;IAC9F,oFAAoF;IACpF,yFAAyF;IACzF,+CAA+C;IAC/C,OAAO,IAAA,wCAA6B,EAAC,IAAI,EAAE,IAAI,UAAU,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpG,CAAC;AAED,iGAAiG;AACjG,SAAgB,4BAA4B,CAAC,IAAY,EAAE,UAAkB,EAAE,KAAe;IAC5F,gFAAgF;IAChF,yFAAyF;IACzF,+CAA+C;IAC/C,OAAO,IAAA,0CAA+B,EAAC,IAAI,EAAE,IAAI,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACnG,CAAC"}

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/**
* Parses a HTML fragment and traverses all AST nodes in order find elements that
* include the specified attribute.
*/
export declare function findElementsWithAttribute(html: string, attributeName: string): import("parse5/dist/tree-adapters/default").Element[];
/**
* Finds elements with explicit tag names that also contain the specified attribute. Returns the
* attribute start offset based on the specified HTML.
*/
export declare function findAttributeOnElementWithTag(html: string, name: string, tagNames: string[]): number[];
/**
* Finds elements that contain the given attribute and contain at least one of the other
* specified attributes. Returns the primary attribute's start offset based on the specified HTML.
*/
export declare function findAttributeOnElementWithAttrs(html: string, name: string, attrs: string[]): number[];
/** Gets the start offset of the given attribute from a Parse5 element. */
export declare function getStartOffsetOfAttribute(element: any, attributeName: string): number;

View File

@@ -0,0 +1,63 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.findElementsWithAttribute = findElementsWithAttribute;
exports.findAttributeOnElementWithTag = findAttributeOnElementWithTag;
exports.findAttributeOnElementWithAttrs = findAttributeOnElementWithAttrs;
exports.getStartOffsetOfAttribute = getStartOffsetOfAttribute;
const parse5_1 = require("parse5");
/**
* Parses a HTML fragment and traverses all AST nodes in order find elements that
* include the specified attribute.
*/
function findElementsWithAttribute(html, attributeName) {
const document = (0, parse5_1.parseFragment)(html, { sourceCodeLocationInfo: true });
const elements = [];
const visitNodes = (nodes) => {
nodes.forEach(n => {
var _a;
const node = n;
if (node.childNodes) {
visitNodes(node.childNodes);
}
if ((_a = node.attrs) === null || _a === void 0 ? void 0 : _a.some(attr => attr.name === attributeName.toLowerCase())) {
elements.push(node);
}
});
};
visitNodes(document.childNodes);
return elements;
}
/**
* Finds elements with explicit tag names that also contain the specified attribute. Returns the
* attribute start offset based on the specified HTML.
*/
function findAttributeOnElementWithTag(html, name, tagNames) {
return findElementsWithAttribute(html, name)
.filter(element => tagNames.includes(element.tagName))
.map(element => getStartOffsetOfAttribute(element, name));
}
/**
* Finds elements that contain the given attribute and contain at least one of the other
* specified attributes. Returns the primary attribute's start offset based on the specified HTML.
*/
function findAttributeOnElementWithAttrs(html, name, attrs) {
return findElementsWithAttribute(html, name)
.filter(element => attrs.some(attr => hasElementAttribute(element, attr)))
.map(element => getStartOffsetOfAttribute(element, name));
}
/** Shorthand function that checks if the specified element contains the given attribute. */
function hasElementAttribute(element, attributeName) {
return element.attrs && element.attrs.some(attr => attr.name === attributeName.toLowerCase());
}
/** Gets the start offset of the given attribute from a Parse5 element. */
function getStartOffsetOfAttribute(element, attributeName) {
return element.sourceCodeLocation.attrs[attributeName.toLowerCase()].startOffset;
}
//# sourceMappingURL=elements.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"elements.js","sourceRoot":"","sources":["elements.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AASH,8DAqBC;AAMD,sEAIC;AAMD,0EAIC;AAQD,8DAEC;AA1DD,mCAAqC;AAGrC;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,IAAY,EAAE,aAAqB;IAC3E,MAAM,QAAQ,GAAG,IAAA,sBAAa,EAAC,IAAI,EAAE,EAAC,sBAAsB,EAAE,IAAI,EAAC,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,EAAE;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;;YAChB,MAAM,IAAI,GAAG,CAAY,CAAC;YAE1B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9B,CAAC;YAED,IAAI,MAAA,IAAI,CAAC,KAAK,0CAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACxE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEhC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,IAAY,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