UNPKG

eslint-plugin-vue-scoped-css

Version:
49 lines (48 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isValidStyleContext = exports.VueComponentContext = exports.CommentDirectivesReporter = void 0; exports.getStyleContexts = getStyleContexts; exports.getCommentDirectivesReporter = getCommentDirectivesReporter; exports.getVueComponentContext = getVueComponentContext; const style_1 = require("./style"); Object.defineProperty(exports, "isValidStyleContext", { enumerable: true, get: function () { return style_1.isValidStyleContext; } }); const comment_directive_1 = require("./comment-directive"); Object.defineProperty(exports, "CommentDirectivesReporter", { enumerable: true, get: function () { return comment_directive_1.CommentDirectivesReporter; } }); const vue_components_1 = require("./vue-components"); Object.defineProperty(exports, "VueComponentContext", { enumerable: true, get: function () { return vue_components_1.VueComponentContext; } }); const compat_1 = require("../../utils/compat"); const CACHE = new WeakMap(); function getCache(context) { const sourceCode = (0, compat_1.getSourceCode)(context); const { ast } = sourceCode; if (CACHE.has(ast)) { return CACHE.get(ast); } const cache = {}; CACHE.set(ast, cache); return cache; } function getStyleContexts(context) { const cache = getCache(context); if (cache.styles) { return cache.styles; } return (cache.styles = (0, style_1.createStyleContexts)(context)); } function getCommentDirectivesReporter(context) { return (0, comment_directive_1.createCommentDirectivesReporter)(context, getCommentDirectives(context)); } function getVueComponentContext(context) { const cache = getCache(context); if (cache.vueComponent) { return cache.vueComponent; } return (cache.vueComponent = (0, vue_components_1.createVueComponentContext)(context)); } function getCommentDirectives(context) { const cache = getCache(context); if (cache.comment) { return cache.comment; } return (cache.comment = (0, comment_directive_1.createCommentDirectives)(getStyleContexts(context))); }