Tim van der Lippe | 652ccb7 | 2021-05-27 17:07:12 +0100 | [diff] [blame^] | 1 | "use strict"; |
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 | exports.parseLiterals = void 0; |
| 4 | const typescript_1 = require("./strategies/typescript"); |
| 5 | function parseLiterals(source, options = {}) { |
| 6 | const strategy = { |
| 7 | ...typescript_1.default, |
| 8 | ...(options.strategy || {}) |
| 9 | }; |
| 10 | const literals = []; |
| 11 | const visitedTemplates = []; |
| 12 | strategy.walkNodes(strategy.getRootNode(source, options.fileName), node => { |
| 13 | if (strategy.isTaggedTemplate(node)) { |
| 14 | const template = strategy.getTaggedTemplateTemplate(node); |
| 15 | visitedTemplates.push(template); |
| 16 | literals.push({ |
| 17 | tag: strategy.getTagText(node), |
| 18 | parts: strategy.getTemplateParts(template) |
| 19 | }); |
| 20 | } |
| 21 | else if (strategy.isTemplate(node) && !visitedTemplates.includes(node)) { |
| 22 | literals.push({ |
| 23 | parts: strategy.getTemplateParts(node) |
| 24 | }); |
| 25 | } |
| 26 | }); |
| 27 | return literals; |
| 28 | } |
| 29 | exports.parseLiterals = parseLiterals; |
| 30 | //# sourceMappingURL=parseLiterals.js.map |