const fs = require('fs') const path = require('path') const { sanitizeDir, sanitizeWxssSource, rewriteSelectorList } = require('./sanitize-wxss-plugin.cjs') const samples = [ '.connection-copy h1', '.social-home .nav-links:not(.open)', '.social-cafe-grid .social-card > :not(.social-cafe-art)', '.social-meetup-faces > *:first-child', '.social-home :is(a, button):focus-visible', ] for (const s of samples) { console.log(s, '=>', rewriteSelectorList(s) || '(dropped)') } const dist = path.resolve(__dirname, '../dist') const t0 = Date.now() const r = sanitizeDir(dist) console.log('sanitizeDir', r, 'ms', Date.now() - t0) const vendors = path.join(dist, 'pages/social/sub-vendors.wxss') if (fs.existsSync(vendors)) { const s = fs.readFileSync(vendors, 'utf8') console.log({ bytes: s.length, asH1: (s.match(/\.as-h1/g) || []).length, asA: (s.match(/\.as-a/g) || []).length, asButton: (s.match(/\.as-button/g) || []).length, connectionCopy: (s.match(/\.connection-copy\s+\.as-h1/g) || []).length, rawTagH1: (s.match(/(^|[^\w-])h1(\s|,|\{|>)/gm) || []).length, notLeft: (s.match(/:not\(/g) || []).length, hasLeft: (s.match(/:has\(/g) || []).length, }) const idx = s.indexOf('.connection-copy .as-h1') console.log('snippet', s.slice(Math.max(0, idx), idx + 180)) }