"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.io/license */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCleanHelperName = exports.isHelperName = exports.hasPureComment = exports.addPureComment = exports.collectDeepNodes = void 0; const tslib = __importStar(require("tslib")); const ts = __importStar(require("typescript")); const pureFunctionComment = '@__PURE__'; // We include only exports that start with '__' because tslib helpers // all start with a suffix of two underscores. const tslibHelpers = new Set(Object.keys(tslib).filter((h) => h.startsWith('__'))); // Find all nodes from the AST in the subtree of node of SyntaxKind kind. function collectDeepNodes(node, kind) { const nodes = []; const helper = (child) => { if (child.kind === kind) { nodes.push(child); } ts.forEachChild(child, helper); }; ts.forEachChild(node, helper); return nodes; } exports.collectDeepNodes = collectDeepNodes; function addPureComment(node) { return ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, pureFunctionComment, false); } exports.addPureComment = addPureComment; function hasPureComment(node) { if (!node) { return false; } const leadingComment = ts.getSyntheticLeadingComments(node); return !!leadingComment && leadingComment.some((comment) => comment.text === pureFunctionComment); } exports.hasPureComment = hasPureComment; function isHelperName(name) { return tslibHelpers.has(name); } exports.isHelperName = isHelperName; /** * In FESM's when not using `importHelpers` there might be multiple in the same file. @example ``` var __decorate$1 = ''; var __decorate$2 = ''; ``` * @returns Helper name without the '$' and number suffix or `undefined` if it's not a helper. */ function getCleanHelperName(name) { const parts = name.split('$'); const cleanName = parts[0]; if (parts.length > 2 || (parts.length === 2 && isNaN(+parts[1]))) { return undefined; } return isHelperName(cleanName) ? cleanName : undefined; } exports.getCleanHelperName = getCleanHelperName;