Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/vite/dist/node/chunks/dep-Ba1kN6Mp.js
rd565449 r0c6b92a 1 import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep- mCdpKltl.js';1 import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-CB_7IfJ-.js'; 2 2 import require$$0__default from 'fs'; 3 3 import require$$0 from 'postcss'; … … 1328 1328 1329 1329 root.walkDecls(/^composes$/, (declaration) => { 1330 const matches = declaration.value.match(matchImports$1); 1331 1332 if (!matches) { 1333 return; 1334 } 1335 1336 let tmpSymbols; 1337 let [ 1338 , 1339 /*match*/ symbols, 1340 doubleQuotePath, 1341 singleQuotePath, 1342 global, 1343 ] = matches; 1344 1345 if (global) { 1346 // Composing globals simply means changing these classes to wrap them in global(name) 1347 tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`); 1348 } else { 1349 const importPath = doubleQuotePath || singleQuotePath; 1350 1351 let parent = declaration.parent; 1352 let parentIndexes = ""; 1353 1354 while (parent.type !== "root") { 1355 parentIndexes = 1356 parent.parent.index(parent) + "_" + parentIndexes; 1357 parent = parent.parent; 1330 const multiple = declaration.value.split(","); 1331 const values = []; 1332 1333 multiple.forEach((value) => { 1334 const matches = value.trim().match(matchImports$1); 1335 1336 if (!matches) { 1337 values.push(value); 1338 1339 return; 1358 1340 } 1359 1341 1360 const { selector } = declaration.parent; 1361 const parentRule = `_${parentIndexes}${selector}`; 1362 1363 addImportToGraph(importPath, parentRule, graph, visited); 1364 1365 importDecls[importPath] = declaration; 1366 imports[importPath] = imports[importPath] || {}; 1367 1368 tmpSymbols = symbols.split(/\s+/).map((s) => { 1369 if (!imports[importPath][s]) { 1370 imports[importPath][s] = createImportedName(s, importPath); 1342 let tmpSymbols; 1343 let [ 1344 , 1345 /*match*/ symbols, 1346 doubleQuotePath, 1347 singleQuotePath, 1348 global, 1349 ] = matches; 1350 1351 if (global) { 1352 // Composing globals simply means changing these classes to wrap them in global(name) 1353 tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`); 1354 } else { 1355 const importPath = doubleQuotePath || singleQuotePath; 1356 1357 let parent = declaration.parent; 1358 let parentIndexes = ""; 1359 1360 while (parent.type !== "root") { 1361 parentIndexes = 1362 parent.parent.index(parent) + "_" + parentIndexes; 1363 parent = parent.parent; 1371 1364 } 1372 1365 1373 return imports[importPath][s]; 1374 }); 1375 } 1376 1377 declaration.value = tmpSymbols.join(" "); 1366 const { selector } = declaration.parent; 1367 const parentRule = `_${parentIndexes}${selector}`; 1368 1369 addImportToGraph(importPath, parentRule, graph, visited); 1370 1371 importDecls[importPath] = declaration; 1372 imports[importPath] = imports[importPath] || {}; 1373 1374 tmpSymbols = symbols.split(/\s+/).map((s) => { 1375 if (!imports[importPath][s]) { 1376 imports[importPath][s] = createImportedName(s, importPath); 1377 } 1378 1379 return imports[importPath][s]; 1380 }); 1381 } 1382 1383 values.push(tmpSymbols.join(" ")); 1384 }); 1385 1386 declaration.value = values.join(", "); 1378 1387 }); 1379 1388 … … 2220 2229 exports.__esModule = true; 2221 2230 exports["default"] = unesc; 2222 2223 2231 // Many thanks for this post which made this migration much easier. 2224 2232 // https://mathiasbynens.be/notes/css-escapes … … 2233 2241 var hex = ''; 2234 2242 var spaceTerminated = false; 2235 2236 2243 for (var i = 0; i < 6 && lower[i] !== undefined; i++) { 2237 var code = lower.charCodeAt(i); // check to see if we are dealing with a valid hex char [a-f|0-9]2238 2239 var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point2240 2244 var code = lower.charCodeAt(i); 2245 // check to see if we are dealing with a valid hex char [a-f|0-9] 2246 var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; 2247 // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point 2241 2248 spaceTerminated = code === 32; 2242 2243 2249 if (!valid) { 2244 2250 break; 2245 2251 } 2246 2247 2252 hex += lower[i]; 2248 2253 } 2249 2250 2254 if (hex.length === 0) { 2251 2255 return undefined; 2252 2256 } 2253 2254 2257 var codePoint = parseInt(hex, 16); 2255 var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF; // Add special case for 2258 var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF; 2259 // Add special case for 2256 2260 // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point" 2257 2261 // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point 2258 2259 2262 if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) { 2260 2263 return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)]; 2261 2264 } 2262 2263 2265 return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)]; 2264 2266 } 2265 2266 2267 var CONTAINS_ESCAPE = /\\/; 2267 2268 2268 function unesc(str) { 2269 2269 var needToProcess = CONTAINS_ESCAPE.test(str); 2270 2271 2270 if (!needToProcess) { 2272 2271 return str; 2273 2272 } 2274 2275 2273 var ret = ""; 2276 2277 2274 for (var i = 0; i < str.length; i++) { 2278 2275 if (str[i] === "\\") { 2279 2276 var gobbled = gobbleHex(str.slice(i + 1, i + 7)); 2280 2281 2277 if (gobbled !== undefined) { 2282 2278 ret += gobbled[0]; 2283 2279 i += gobbled[1]; 2284 2280 continue; 2285 } // Retain a pair of \\ if double escaped `\\\\` 2281 } 2282 2283 // Retain a pair of \\ if double escaped `\\\\` 2286 2284 // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e 2287 2288 2289 2285 if (str[i + 1] === "\\") { 2290 2286 ret += "\\"; 2291 2287 i++; 2292 2288 continue; 2293 } // if \\ is at the end of the string retain it 2289 } 2290 2291 // if \\ is at the end of the string retain it 2294 2292 // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb 2295 2296 2297 2293 if (str.length === i + 1) { 2298 2294 ret += str[i]; 2299 2295 } 2300 2301 2296 continue; 2302 2297 } 2303 2304 2298 ret += str[i]; 2305 2299 } 2306 2307 2300 return ret; 2308 2301 } 2309 2310 2302 module.exports = exports.default; 2311 2303 } (unesc, unesc.exports)); … … 2319 2311 exports.__esModule = true; 2320 2312 exports["default"] = getProp; 2321 2322 2313 function getProp(obj) { 2323 2314 for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 2324 2315 props[_key - 1] = arguments[_key]; 2325 2316 } 2326 2327 2317 while (props.length > 0) { 2328 2318 var prop = props.shift(); 2329 2330 2319 if (!obj[prop]) { 2331 2320 return undefined; 2332 2321 } 2333 2334 2322 obj = obj[prop]; 2335 2323 } 2336 2337 2324 return obj; 2338 2325 } 2339 2340 2326 module.exports = exports.default; 2341 2327 } (getProp, getProp.exports)); … … 2349 2335 exports.__esModule = true; 2350 2336 exports["default"] = ensureObject; 2351 2352 2337 function ensureObject(obj) { 2353 2338 for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 2354 2339 props[_key - 1] = arguments[_key]; 2355 2340 } 2356 2357 2341 while (props.length > 0) { 2358 2342 var prop = props.shift(); 2359 2360 2343 if (!obj[prop]) { 2361 2344 obj[prop] = {}; 2362 2345 } 2363 2364 2346 obj = obj[prop]; 2365 2347 } 2366 2348 } 2367 2368 2349 module.exports = exports.default; 2369 2350 } (ensureObject, ensureObject.exports)); … … 2377 2358 exports.__esModule = true; 2378 2359 exports["default"] = stripComments; 2379 2380 2360 function stripComments(str) { 2381 2361 var s = ""; 2382 2362 var commentStart = str.indexOf("/*"); 2383 2363 var lastEnd = 0; 2384 2385 2364 while (commentStart >= 0) { 2386 2365 s = s + str.slice(lastEnd, commentStart); 2387 2366 var commentEnd = str.indexOf("*/", commentStart + 2); 2388 2389 2367 if (commentEnd < 0) { 2390 2368 return s; 2391 2369 } 2392 2393 2370 lastEnd = commentEnd + 2; 2394 2371 commentStart = str.indexOf("/*", lastEnd); 2395 2372 } 2396 2397 2373 s = s + str.slice(lastEnd); 2398 2374 return s; 2399 2375 } 2400 2401 2376 module.exports = exports.default; 2402 2377 } (stripComments, stripComments.exports)); … … 2405 2380 2406 2381 util.__esModule = true; 2407 util.stripComments = util.ensureObject = util.getProp = util.unesc = void 0; 2408 2382 util.unesc = util.stripComments = util.getProp = util.ensureObject = void 0; 2409 2383 var _unesc = _interopRequireDefault$3(unescExports); 2410 2411 2384 util.unesc = _unesc["default"]; 2412 2413 2385 var _getProp = _interopRequireDefault$3(getPropExports); 2414 2415 2386 util.getProp = _getProp["default"]; 2416 2417 2387 var _ensureObject = _interopRequireDefault$3(ensureObjectExports); 2418 2419 2388 util.ensureObject = _ensureObject["default"]; 2420 2421 2389 var _stripComments = _interopRequireDefault$3(stripCommentsExports); 2422 2423 2390 util.stripComments = _stripComments["default"]; 2424 2425 2391 function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 2426 2392 … … 2429 2395 exports.__esModule = true; 2430 2396 exports["default"] = void 0; 2431 2432 2397 var _util = util; 2433 2434 2398 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 2435 2436 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; } 2437 2399 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 2438 2400 var cloneNode = function cloneNode(obj, parent) { 2439 2401 if (typeof obj !== 'object' || obj === null) { 2440 2402 return obj; 2441 2403 } 2442 2443 2404 var cloned = new obj.constructor(); 2444 2445 2405 for (var i in obj) { 2446 2406 if (!obj.hasOwnProperty(i)) { 2447 2407 continue; 2448 2408 } 2449 2450 2409 var value = obj[i]; 2451 2410 var type = typeof value; 2452 2453 2411 if (i === 'parent' && type === 'object') { 2454 2412 if (parent) { … … 2463 2421 } 2464 2422 } 2465 2466 2423 return cloned; 2467 2424 }; 2468 2469 2425 var Node = /*#__PURE__*/function () { 2470 2426 function Node(opts) { … … 2472 2428 opts = {}; 2473 2429 } 2474 2475 2430 Object.assign(this, opts); 2476 2431 this.spaces = this.spaces || {}; … … 2478 2433 this.spaces.after = this.spaces.after || ''; 2479 2434 } 2480 2481 2435 var _proto = Node.prototype; 2482 2483 2436 _proto.remove = function remove() { 2484 2437 if (this.parent) { 2485 2438 this.parent.removeChild(this); 2486 2439 } 2487 2488 2440 this.parent = undefined; 2489 2441 return this; 2490 2442 }; 2491 2492 2443 _proto.replaceWith = function replaceWith() { 2493 2444 if (this.parent) { … … 2495 2446 this.parent.insertBefore(this, arguments[index]); 2496 2447 } 2497 2498 2448 this.remove(); 2499 2449 } 2500 2501 2450 return this; 2502 2451 }; 2503 2504 2452 _proto.next = function next() { 2505 2453 return this.parent.at(this.parent.index(this) + 1); 2506 2454 }; 2507 2508 2455 _proto.prev = function prev() { 2509 2456 return this.parent.at(this.parent.index(this) - 1); 2510 2457 }; 2511 2512 2458 _proto.clone = function clone(overrides) { 2513 2459 if (overrides === void 0) { 2514 2460 overrides = {}; 2515 2461 } 2516 2517 2462 var cloned = cloneNode(this); 2518 2519 2463 for (var name in overrides) { 2520 2464 cloned[name] = overrides[name]; 2521 2465 } 2522 2523 2466 return cloned; 2524 2467 } 2468 2525 2469 /** 2526 2470 * Some non-standard syntax doesn't follow normal escaping rules for css. … … 2531 2475 * @param {any} value the unescaped value of the property 2532 2476 * @param {string} valueEscaped optional. the escaped value of the property. 2533 */ 2534 ; 2535 2477 */; 2536 2478 _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) { 2537 2479 if (!this.raws) { 2538 2480 this.raws = {}; 2539 2481 } 2540 2541 2482 var originalValue = this[name]; 2542 2483 var originalEscaped = this.raws[name]; 2543 2484 this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first. 2544 2545 2485 if (originalEscaped || valueEscaped !== value) { 2546 2486 this.raws[name] = (originalEscaped || originalValue) + valueEscaped; … … 2549 2489 } 2550 2490 } 2491 2551 2492 /** 2552 2493 * Some non-standard syntax doesn't follow normal escaping rules for css. … … 2556 2497 * @param {any} value the unescaped value of the property 2557 2498 * @param {string} valueEscaped the escaped value of the property. 2558 */ 2559 ; 2560 2499 */; 2561 2500 _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) { 2562 2501 if (!this.raws) { 2563 2502 this.raws = {}; 2564 2503 } 2565 2566 2504 this[name] = value; // this may trigger a setter that updates raws, so it has to be set first. 2567 2568 2505 this.raws[name] = valueEscaped; 2569 2506 } 2507 2570 2508 /** 2571 2509 * When you want a value to passed through to CSS directly. This method … … 2574 2512 * @param {string} name the property to set. 2575 2513 * @param {any} value The value that is both escaped and unescaped. 2576 */ 2577 ; 2578 2514 */; 2579 2515 _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) { 2580 2516 this[name] = value; // this may trigger a setter that updates raws, so it has to be set first. 2581 2582 2517 if (this.raws) { 2583 2518 delete this.raws[name]; 2584 2519 } 2585 2520 } 2521 2586 2522 /** 2587 2523 * 2588 2524 * @param {number} line The number (starting with 1) 2589 2525 * @param {number} column The column number (starting with 1) 2590 */ 2591 ; 2592 2526 */; 2593 2527 _proto.isAtPosition = function isAtPosition(line, column) { 2594 2528 if (this.source && this.source.start && this.source.end) { … … 2596 2530 return false; 2597 2531 } 2598 2599 2532 if (this.source.end.line < line) { 2600 2533 return false; 2601 2534 } 2602 2603 2535 if (this.source.start.line === line && this.source.start.column > column) { 2604 2536 return false; 2605 2537 } 2606 2607 2538 if (this.source.end.line === line && this.source.end.column < column) { 2608 2539 return false; 2609 2540 } 2610 2611 2541 return true; 2612 2542 } 2613 2614 2543 return undefined; 2615 2544 }; 2616 2617 2545 _proto.stringifyProperty = function stringifyProperty(name) { 2618 2546 return this.raws && this.raws[name] || this[name]; 2619 2547 }; 2620 2621 2548 _proto.valueToString = function valueToString() { 2622 2549 return String(this.stringifyProperty("value")); 2623 2550 }; 2624 2625 2551 _proto.toString = function toString() { 2626 2552 return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join(''); 2627 2553 }; 2628 2629 2554 _createClass(Node, [{ 2630 2555 key: "rawSpaceBefore", 2631 2556 get: function get() { 2632 2557 var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before; 2633 2634 2558 if (rawSpace === undefined) { 2635 2559 rawSpace = this.spaces && this.spaces.before; 2636 2560 } 2637 2638 2561 return rawSpace || ""; 2639 2562 }, … … 2646 2569 get: function get() { 2647 2570 var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after; 2648 2649 2571 if (rawSpace === undefined) { 2650 2572 rawSpace = this.spaces.after; 2651 2573 } 2652 2653 2574 return rawSpace || ""; 2654 2575 }, … … 2658 2579 } 2659 2580 }]); 2660 2661 2581 return Node; 2662 2582 }(); 2663 2664 2583 exports["default"] = Node; 2665 2584 module.exports = exports.default; … … 2671 2590 2672 2591 types.__esModule = true; 2673 types.UNIVERSAL = types. ATTRIBUTE = types.CLASS = types.COMBINATOR = types.COMMENT = types.ID = types.NESTING = types.PSEUDO = types.ROOT = types.SELECTOR = types.STRING = types.TAG= void 0;2592 types.UNIVERSAL = types.TAG = types.STRING = types.SELECTOR = types.ROOT = types.PSEUDO = types.NESTING = types.ID = types.COMMENT = types.COMBINATOR = types.CLASS = types.ATTRIBUTE = void 0; 2674 2593 var TAG = 'tag'; 2675 2594 types.TAG = TAG; … … 2701 2620 exports.__esModule = true; 2702 2621 exports["default"] = void 0; 2703 2704 2622 var _node = _interopRequireDefault(nodeExports); 2705 2706 2623 var types$1 = _interopRequireWildcard(types); 2707 2708 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } 2709 2710 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 2711 2624 function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 2625 function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 2712 2626 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 2713 2714 function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); } 2715 2627 function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 2716 2628 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 2717 2718 2629 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } 2719 2720 2630 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 2721 2722 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; } 2723 2631 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 2724 2632 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 2725 2726 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 2727 2633 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 2728 2634 var Container = /*#__PURE__*/function (_Node) { 2729 2635 _inheritsLoose(Container, _Node); 2730 2731 2636 function Container(opts) { 2732 2637 var _this; 2733 2734 2638 _this = _Node.call(this, opts) || this; 2735 2736 2639 if (!_this.nodes) { 2737 2640 _this.nodes = []; 2738 2641 } 2739 2740 2642 return _this; 2741 2643 } 2742 2743 2644 var _proto = Container.prototype; 2744 2745 2645 _proto.append = function append(selector) { 2746 2646 selector.parent = this; … … 2748 2648 return this; 2749 2649 }; 2750 2751 2650 _proto.prepend = function prepend(selector) { 2752 2651 selector.parent = this; … … 2754 2653 return this; 2755 2654 }; 2756 2757 2655 _proto.at = function at(index) { 2758 2656 return this.nodes[index]; 2759 2657 }; 2760 2761 2658 _proto.index = function index(child) { 2762 2659 if (typeof child === 'number') { 2763 2660 return child; 2764 2661 } 2765 2766 2662 return this.nodes.indexOf(child); 2767 2663 }; 2768 2769 2664 _proto.removeChild = function removeChild(child) { 2770 2665 child = this.index(child); … … 2772 2667 this.nodes.splice(child, 1); 2773 2668 var index; 2774 2775 2669 for (var id in this.indexes) { 2776 2670 index = this.indexes[id]; 2777 2778 2671 if (index >= child) { 2779 2672 this.indexes[id] = index - 1; 2780 2673 } 2781 2674 } 2782 2783 2675 return this; 2784 2676 }; 2785 2786 2677 _proto.removeAll = function removeAll() { 2787 2678 for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) { … … 2789 2680 node.parent = undefined; 2790 2681 } 2791 2792 2682 this.nodes = []; 2793 2683 return this; 2794 2684 }; 2795 2796 2685 _proto.empty = function empty() { 2797 2686 return this.removeAll(); 2798 2687 }; 2799 2800 2688 _proto.insertAfter = function insertAfter(oldNode, newNode) { 2801 2689 newNode.parent = this; … … 2804 2692 newNode.parent = this; 2805 2693 var index; 2806 2807 2694 for (var id in this.indexes) { 2808 2695 index = this.indexes[id]; 2809 2810 2696 if (oldIndex <= index) { 2811 2697 this.indexes[id] = index + 1; 2812 2698 } 2813 2699 } 2814 2815 2700 return this; 2816 2701 }; 2817 2818 2702 _proto.insertBefore = function insertBefore(oldNode, newNode) { 2819 2703 newNode.parent = this; … … 2822 2706 newNode.parent = this; 2823 2707 var index; 2824 2825 2708 for (var id in this.indexes) { 2826 2709 index = this.indexes[id]; 2827 2828 2710 if (index <= oldIndex) { 2829 2711 this.indexes[id] = index + 1; 2830 2712 } 2831 2713 } 2832 2833 2714 return this; 2834 2715 }; 2835 2836 2716 _proto._findChildAtPosition = function _findChildAtPosition(line, col) { 2837 2717 var found = undefined; … … 2839 2719 if (node.atPosition) { 2840 2720 var foundChild = node.atPosition(line, col); 2841 2842 2721 if (foundChild) { 2843 2722 found = foundChild; … … 2851 2730 return found; 2852 2731 } 2732 2853 2733 /** 2854 2734 * Return the most specific node at the line and column number given. … … 2863 2743 * @param {number} line The line number of the node to find. (1-based index) 2864 2744 * @param {number} col The column number of the node to find. (1-based index) 2865 */ 2866 ; 2867 2745 */; 2868 2746 _proto.atPosition = function atPosition(line, col) { 2869 2747 if (this.isAtPosition(line, col)) { … … 2873 2751 } 2874 2752 }; 2875 2876 2753 _proto._inferEndPosition = function _inferEndPosition() { 2877 2754 if (this.last && this.last.source && this.last.source.end) { … … 2881 2758 } 2882 2759 }; 2883 2884 2760 _proto.each = function each(callback) { 2885 2761 if (!this.lastEach) { 2886 2762 this.lastEach = 0; 2887 2763 } 2888 2889 2764 if (!this.indexes) { 2890 2765 this.indexes = {}; 2891 2766 } 2892 2893 2767 this.lastEach++; 2894 2768 var id = this.lastEach; 2895 2769 this.indexes[id] = 0; 2896 2897 2770 if (!this.length) { 2898 2771 return undefined; 2899 2772 } 2900 2901 2773 var index, result; 2902 2903 2774 while (this.indexes[id] < this.length) { 2904 2775 index = this.indexes[id]; 2905 2776 result = callback(this.at(index), index); 2906 2907 2777 if (result === false) { 2908 2778 break; 2909 2779 } 2910 2911 2780 this.indexes[id] += 1; 2912 2781 } 2913 2914 2782 delete this.indexes[id]; 2915 2916 2783 if (result === false) { 2917 2784 return false; 2918 2785 } 2919 2786 }; 2920 2921 2787 _proto.walk = function walk(callback) { 2922 2788 return this.each(function (node, i) { 2923 2789 var result = callback(node, i); 2924 2925 2790 if (result !== false && node.length) { 2926 2791 result = node.walk(callback); 2927 2792 } 2928 2929 2793 if (result === false) { 2930 2794 return false; … … 2932 2796 }); 2933 2797 }; 2934 2935 2798 _proto.walkAttributes = function walkAttributes(callback) { 2936 2799 var _this2 = this; 2937 2938 2800 return this.walk(function (selector) { 2939 2801 if (selector.type === types$1.ATTRIBUTE) { … … 2942 2804 }); 2943 2805 }; 2944 2945 2806 _proto.walkClasses = function walkClasses(callback) { 2946 2807 var _this3 = this; 2947 2948 2808 return this.walk(function (selector) { 2949 2809 if (selector.type === types$1.CLASS) { … … 2952 2812 }); 2953 2813 }; 2954 2955 2814 _proto.walkCombinators = function walkCombinators(callback) { 2956 2815 var _this4 = this; 2957 2958 2816 return this.walk(function (selector) { 2959 2817 if (selector.type === types$1.COMBINATOR) { … … 2962 2820 }); 2963 2821 }; 2964 2965 2822 _proto.walkComments = function walkComments(callback) { 2966 2823 var _this5 = this; 2967 2968 2824 return this.walk(function (selector) { 2969 2825 if (selector.type === types$1.COMMENT) { … … 2972 2828 }); 2973 2829 }; 2974 2975 2830 _proto.walkIds = function walkIds(callback) { 2976 2831 var _this6 = this; 2977 2978 2832 return this.walk(function (selector) { 2979 2833 if (selector.type === types$1.ID) { … … 2982 2836 }); 2983 2837 }; 2984 2985 2838 _proto.walkNesting = function walkNesting(callback) { 2986 2839 var _this7 = this; 2987 2988 2840 return this.walk(function (selector) { 2989 2841 if (selector.type === types$1.NESTING) { … … 2992 2844 }); 2993 2845 }; 2994 2995 2846 _proto.walkPseudos = function walkPseudos(callback) { 2996 2847 var _this8 = this; 2997 2998 2848 return this.walk(function (selector) { 2999 2849 if (selector.type === types$1.PSEUDO) { … … 3002 2852 }); 3003 2853 }; 3004 3005 2854 _proto.walkTags = function walkTags(callback) { 3006 2855 var _this9 = this; 3007 3008 2856 return this.walk(function (selector) { 3009 2857 if (selector.type === types$1.TAG) { … … 3012 2860 }); 3013 2861 }; 3014 3015 2862 _proto.walkUniversals = function walkUniversals(callback) { 3016 2863 var _this10 = this; 3017 3018 2864 return this.walk(function (selector) { 3019 2865 if (selector.type === types$1.UNIVERSAL) { … … 3022 2868 }); 3023 2869 }; 3024 3025 2870 _proto.split = function split(callback) { 3026 2871 var _this11 = this; 3027 3028 2872 var current = []; 3029 2873 return this.reduce(function (memo, node, index) { 3030 2874 var split = callback.call(_this11, node); 3031 2875 current.push(node); 3032 3033 2876 if (split) { 3034 2877 memo.push(current); … … 3037 2880 memo.push(current); 3038 2881 } 3039 3040 2882 return memo; 3041 2883 }, []); 3042 2884 }; 3043 3044 2885 _proto.map = function map(callback) { 3045 2886 return this.nodes.map(callback); 3046 2887 }; 3047 3048 2888 _proto.reduce = function reduce(callback, memo) { 3049 2889 return this.nodes.reduce(callback, memo); 3050 2890 }; 3051 3052 2891 _proto.every = function every(callback) { 3053 2892 return this.nodes.every(callback); 3054 2893 }; 3055 3056 2894 _proto.some = function some(callback) { 3057 2895 return this.nodes.some(callback); 3058 2896 }; 3059 3060 2897 _proto.filter = function filter(callback) { 3061 2898 return this.nodes.filter(callback); 3062 2899 }; 3063 3064 2900 _proto.sort = function sort(callback) { 3065 2901 return this.nodes.sort(callback); 3066 2902 }; 3067 3068 2903 _proto.toString = function toString() { 3069 2904 return this.map(String).join(''); 3070 2905 }; 3071 3072 2906 _createClass(Container, [{ 3073 2907 key: "first", … … 3086 2920 } 3087 2921 }]); 3088 3089 2922 return Container; 3090 2923 }(_node["default"]); 3091 3092 2924 exports["default"] = Container; 3093 2925 module.exports = exports.default; … … 3100 2932 exports.__esModule = true; 3101 2933 exports["default"] = void 0; 3102 3103 2934 var _container = _interopRequireDefault(containerExports); 3104 3105 2935 var _types = types; 3106 3107 2936 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3108 3109 2937 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 3110 3111 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; } 3112 2938 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 3113 2939 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3114 3115 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3116 2940 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3117 2941 var Root = /*#__PURE__*/function (_Container) { 3118 2942 _inheritsLoose(Root, _Container); 3119 3120 2943 function Root(opts) { 3121 2944 var _this; 3122 3123 2945 _this = _Container.call(this, opts) || this; 3124 2946 _this.type = _types.ROOT; 3125 2947 return _this; 3126 2948 } 3127 3128 2949 var _proto = Root.prototype; 3129 3130 2950 _proto.toString = function toString() { 3131 2951 var str = this.reduce(function (memo, selector) { … … 3135 2955 return this.trailingComma ? str + ',' : str; 3136 2956 }; 3137 3138 2957 _proto.error = function error(message, options) { 3139 2958 if (this._error) { … … 3143 2962 } 3144 2963 }; 3145 3146 2964 _createClass(Root, [{ 3147 2965 key: "errorGenerator", … … 3150 2968 } 3151 2969 }]); 3152 3153 2970 return Root; 3154 2971 }(_container["default"]); 3155 3156 2972 exports["default"] = Root; 3157 2973 module.exports = exports.default; … … 3166 2982 exports.__esModule = true; 3167 2983 exports["default"] = void 0; 3168 3169 2984 var _container = _interopRequireDefault(containerExports); 3170 3171 2985 var _types = types; 3172 3173 2986 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3174 3175 2987 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3176 3177 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3178 2988 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3179 2989 var Selector = /*#__PURE__*/function (_Container) { 3180 2990 _inheritsLoose(Selector, _Container); 3181 3182 2991 function Selector(opts) { 3183 2992 var _this; 3184 3185 2993 _this = _Container.call(this, opts) || this; 3186 2994 _this.type = _types.SELECTOR; 3187 2995 return _this; 3188 2996 } 3189 3190 2997 return Selector; 3191 2998 }(_container["default"]); 3192 3193 2999 exports["default"] = Selector; 3194 3000 module.exports = exports.default; … … 3312 3118 exports.__esModule = true; 3313 3119 exports["default"] = void 0; 3314 3315 3120 var _cssesc = _interopRequireDefault(cssesc_1); 3316 3317 3121 var _util = util; 3318 3319 3122 var _node = _interopRequireDefault(nodeExports); 3320 3321 3123 var _types = types; 3322 3323 3124 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3324 3325 3125 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 3326 3327 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; } 3328 3126 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 3329 3127 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3330 3331 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3332 3128 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3333 3129 var ClassName = /*#__PURE__*/function (_Node) { 3334 3130 _inheritsLoose(ClassName, _Node); 3335 3336 3131 function ClassName(opts) { 3337 3132 var _this; 3338 3339 3133 _this = _Node.call(this, opts) || this; 3340 3134 _this.type = _types.CLASS; … … 3342 3136 return _this; 3343 3137 } 3344 3345 3138 var _proto = ClassName.prototype; 3346 3347 3139 _proto.valueToString = function valueToString() { 3348 3140 return '.' + _Node.prototype.valueToString.call(this); 3349 3141 }; 3350 3351 3142 _createClass(ClassName, [{ 3352 3143 key: "value", … … 3359 3150 isIdentifier: true 3360 3151 }); 3361 3362 3152 if (escaped !== v) { 3363 3153 (0, _util.ensureObject)(this, "raws"); … … 3367 3157 } 3368 3158 } 3369 3370 3159 this._value = v; 3371 3160 } 3372 3161 }]); 3373 3374 3162 return ClassName; 3375 3163 }(_node["default"]); 3376 3377 3164 exports["default"] = ClassName; 3378 3165 module.exports = exports.default; … … 3387 3174 exports.__esModule = true; 3388 3175 exports["default"] = void 0; 3389 3390 3176 var _node = _interopRequireDefault(nodeExports); 3391 3392 3177 var _types = types; 3393 3394 3178 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3395 3396 3179 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3397 3398 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3399 3180 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3400 3181 var Comment = /*#__PURE__*/function (_Node) { 3401 3182 _inheritsLoose(Comment, _Node); 3402 3403 3183 function Comment(opts) { 3404 3184 var _this; 3405 3406 3185 _this = _Node.call(this, opts) || this; 3407 3186 _this.type = _types.COMMENT; 3408 3187 return _this; 3409 3188 } 3410 3411 3189 return Comment; 3412 3190 }(_node["default"]); 3413 3414 3191 exports["default"] = Comment; 3415 3192 module.exports = exports.default; … … 3424 3201 exports.__esModule = true; 3425 3202 exports["default"] = void 0; 3426 3427 3203 var _node = _interopRequireDefault(nodeExports); 3428 3429 3204 var _types = types; 3430 3431 3205 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3432 3433 3206 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3434 3435 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3436 3207 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3437 3208 var ID = /*#__PURE__*/function (_Node) { 3438 3209 _inheritsLoose(ID, _Node); 3439 3440 3210 function ID(opts) { 3441 3211 var _this; 3442 3443 3212 _this = _Node.call(this, opts) || this; 3444 3213 _this.type = _types.ID; 3445 3214 return _this; 3446 3215 } 3447 3448 3216 var _proto = ID.prototype; 3449 3450 3217 _proto.valueToString = function valueToString() { 3451 3218 return '#' + _Node.prototype.valueToString.call(this); 3452 3219 }; 3453 3454 3220 return ID; 3455 3221 }(_node["default"]); 3456 3457 3222 exports["default"] = ID; 3458 3223 module.exports = exports.default; … … 3469 3234 exports.__esModule = true; 3470 3235 exports["default"] = void 0; 3471 3472 3236 var _cssesc = _interopRequireDefault(cssesc_1); 3473 3474 3237 var _util = util; 3475 3476 3238 var _node = _interopRequireDefault(nodeExports); 3477 3478 3239 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3479 3480 3240 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 3481 3482 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; } 3483 3241 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 3484 3242 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3485 3486 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3487 3243 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3488 3244 var Namespace = /*#__PURE__*/function (_Node) { 3489 3245 _inheritsLoose(Namespace, _Node); 3490 3491 3246 function Namespace() { 3492 3247 return _Node.apply(this, arguments) || this; 3493 3248 } 3494 3495 3249 var _proto = Namespace.prototype; 3496 3497 3250 _proto.qualifiedName = function qualifiedName(value) { 3498 3251 if (this.namespace) { … … 3502 3255 } 3503 3256 }; 3504 3505 3257 _proto.valueToString = function valueToString() { 3506 3258 return this.qualifiedName(_Node.prototype.valueToString.call(this)); 3507 3259 }; 3508 3509 3260 _createClass(Namespace, [{ 3510 3261 key: "namespace", … … 3515 3266 if (namespace === true || namespace === "*" || namespace === "&") { 3516 3267 this._namespace = namespace; 3517 3518 3268 if (this.raws) { 3519 3269 delete this.raws.namespace; 3520 3270 } 3521 3522 3271 return; 3523 3272 } 3524 3525 3273 var escaped = (0, _cssesc["default"])(namespace, { 3526 3274 isIdentifier: true 3527 3275 }); 3528 3276 this._namespace = namespace; 3529 3530 3277 if (escaped !== namespace) { 3531 3278 (0, _util.ensureObject)(this, "raws"); … … 3548 3295 if (this.namespace) { 3549 3296 var ns = this.stringifyProperty("namespace"); 3550 3551 3297 if (ns === true) { 3552 3298 return ''; … … 3559 3305 } 3560 3306 }]); 3561 3562 3307 return Namespace; 3563 3308 }(_node["default"]); 3564 3565 3309 exports["default"] = Namespace; 3566 3310 module.exports = exports.default; … … 3573 3317 exports.__esModule = true; 3574 3318 exports["default"] = void 0; 3575 3576 3319 var _namespace = _interopRequireDefault(namespaceExports); 3577 3578 3320 var _types = types; 3579 3580 3321 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3581 3582 3322 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3583 3584 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3585 3323 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3586 3324 var Tag = /*#__PURE__*/function (_Namespace) { 3587 3325 _inheritsLoose(Tag, _Namespace); 3588 3589 3326 function Tag(opts) { 3590 3327 var _this; 3591 3592 3328 _this = _Namespace.call(this, opts) || this; 3593 3329 _this.type = _types.TAG; 3594 3330 return _this; 3595 3331 } 3596 3597 3332 return Tag; 3598 3333 }(_namespace["default"]); 3599 3600 3334 exports["default"] = Tag; 3601 3335 module.exports = exports.default; … … 3610 3344 exports.__esModule = true; 3611 3345 exports["default"] = void 0; 3612 3613 3346 var _node = _interopRequireDefault(nodeExports); 3614 3615 3347 var _types = types; 3616 3617 3348 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3618 3619 3349 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3620 3621 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3622 3350 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3623 3351 var String = /*#__PURE__*/function (_Node) { 3624 3352 _inheritsLoose(String, _Node); 3625 3626 3353 function String(opts) { 3627 3354 var _this; 3628 3629 3355 _this = _Node.call(this, opts) || this; 3630 3356 _this.type = _types.STRING; 3631 3357 return _this; 3632 3358 } 3633 3634 3359 return String; 3635 3360 }(_node["default"]); 3636 3637 3361 exports["default"] = String; 3638 3362 module.exports = exports.default; … … 3647 3371 exports.__esModule = true; 3648 3372 exports["default"] = void 0; 3649 3650 3373 var _container = _interopRequireDefault(containerExports); 3651 3652 3374 var _types = types; 3653 3654 3375 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3655 3656 3376 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3657 3658 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3659 3377 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3660 3378 var Pseudo = /*#__PURE__*/function (_Container) { 3661 3379 _inheritsLoose(Pseudo, _Container); 3662 3663 3380 function Pseudo(opts) { 3664 3381 var _this; 3665 3666 3382 _this = _Container.call(this, opts) || this; 3667 3383 _this.type = _types.PSEUDO; 3668 3384 return _this; 3669 3385 } 3670 3671 3386 var _proto = Pseudo.prototype; 3672 3673 3387 _proto.toString = function toString() { 3674 3388 var params = this.length ? '(' + this.map(String).join(',') + ')' : ''; 3675 3389 return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join(''); 3676 3390 }; 3677 3678 3391 return Pseudo; 3679 3392 }(_container["default"]); 3680 3681 3393 exports["default"] = Pseudo; 3682 3394 module.exports = exports.default; … … 3696 3408 3697 3409 exports.__esModule = true; 3410 exports["default"] = void 0; 3698 3411 exports.unescapeValue = unescapeValue; 3699 exports["default"] = void 0;3700 3701 3412 var _cssesc = _interopRequireDefault(cssesc_1); 3702 3703 3413 var _unesc = _interopRequireDefault(unescExports); 3704 3705 3414 var _namespace = _interopRequireDefault(namespaceExports); 3706 3707 3415 var _types = types; 3708 3709 3416 var _CSSESC_QUOTE_OPTIONS; 3710 3711 3417 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 3712 3713 3418 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 3714 3715 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; } 3716 3419 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 3717 3420 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 3718 3719 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3720 3421 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 3721 3422 var deprecate = node; 3722 3723 3423 var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/; 3724 3424 var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead."); 3725 3425 var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead."); 3726 3426 var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now."); 3727 3728 3427 function unescapeValue(value) { 3729 3428 var deprecatedUsage = false; … … 3731 3430 var unescaped = value; 3732 3431 var m = unescaped.match(WRAPPED_IN_QUOTES); 3733 3734 3432 if (m) { 3735 3433 quoteMark = m[1]; 3736 3434 unescaped = m[2]; 3737 3435 } 3738 3739 3436 unescaped = (0, _unesc["default"])(unescaped); 3740 3741 3437 if (unescaped !== value) { 3742 3438 deprecatedUsage = true; 3743 3439 } 3744 3745 3440 return { 3746 3441 deprecatedUsage: deprecatedUsage, … … 3749 3444 }; 3750 3445 } 3751 3752 3446 function handleDeprecatedContructorOpts(opts) { 3753 3447 if (opts.quoteMark !== undefined) { 3754 3448 return opts; 3755 3449 } 3756 3757 3450 if (opts.value === undefined) { 3758 3451 return opts; 3759 3452 } 3760 3761 3453 warnOfDeprecatedConstructor(); 3762 3763 3454 var _unescapeValue = unescapeValue(opts.value), 3764 quoteMark = _unescapeValue.quoteMark, 3765 unescaped = _unescapeValue.unescaped; 3766 3455 quoteMark = _unescapeValue.quoteMark, 3456 unescaped = _unescapeValue.unescaped; 3767 3457 if (!opts.raws) { 3768 3458 opts.raws = {}; 3769 3459 } 3770 3771 3460 if (opts.raws.value === undefined) { 3772 3461 opts.raws.value = opts.value; 3773 3462 } 3774 3775 3463 opts.value = unescaped; 3776 3464 opts.quoteMark = quoteMark; 3777 3465 return opts; 3778 3466 } 3779 3780 3467 var Attribute = /*#__PURE__*/function (_Namespace) { 3781 3468 _inheritsLoose(Attribute, _Namespace); 3782 3783 3469 function Attribute(opts) { 3784 3470 var _this; 3785 3786 3471 if (opts === void 0) { 3787 3472 opts = {}; 3788 3473 } 3789 3790 3474 _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this; 3791 3475 _this.type = _types.ATTRIBUTE; … … 3802 3486 return _this; 3803 3487 } 3488 3804 3489 /** 3805 3490 * Returns the Attribute's value quoted such that it would be legal to use … … 3823 3508 * method. 3824 3509 **/ 3825 3826 3827 3510 var _proto = Attribute.prototype; 3828 3829 3511 _proto.getQuotedValue = function getQuotedValue(options) { 3830 3512 if (options === void 0) { 3831 3513 options = {}; 3832 3514 } 3833 3834 3515 var quoteMark = this._determineQuoteMark(options); 3835 3836 3516 var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark]; 3837 3517 var escaped = (0, _cssesc["default"])(this._value, cssescopts); 3838 3518 return escaped; 3839 3519 }; 3840 3841 3520 _proto._determineQuoteMark = function _determineQuoteMark(options) { 3842 3521 return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options); 3843 3522 } 3523 3844 3524 /** 3845 3525 * Set the unescaped value with the specified quotation options. The value 3846 3526 * provided must not include any wrapping quote marks -- those quotes will 3847 3527 * be interpreted as part of the value and escaped accordingly. 3848 */ 3849 ; 3850 3528 */; 3851 3529 _proto.setValue = function setValue(value, options) { 3852 3530 if (options === void 0) { 3853 3531 options = {}; 3854 3532 } 3855 3856 3533 this._value = value; 3857 3534 this._quoteMark = this._determineQuoteMark(options); 3858 3859 3535 this._syncRawValue(); 3860 3536 } 3537 3861 3538 /** 3862 3539 * Intelligently select a quoteMark value based on the value's contents. If … … 3870 3547 * @param options This takes the quoteMark and preferCurrentQuoteMark options 3871 3548 * from the quoteValue method. 3872 */ 3873 ; 3874 3549 */; 3875 3550 _proto.smartQuoteMark = function smartQuoteMark(options) { 3876 3551 var v = this.value; 3877 3552 var numSingleQuotes = v.replace(/[^']/g, '').length; 3878 3553 var numDoubleQuotes = v.replace(/[^"]/g, '').length; 3879 3880 3554 if (numSingleQuotes + numDoubleQuotes === 0) { 3881 3555 var escaped = (0, _cssesc["default"])(v, { 3882 3556 isIdentifier: true 3883 3557 }); 3884 3885 3558 if (escaped === v) { 3886 3559 return Attribute.NO_QUOTE; 3887 3560 } else { 3888 3561 var pref = this.preferredQuoteMark(options); 3889 3890 3562 if (pref === Attribute.NO_QUOTE) { 3891 3563 // pick a quote mark that isn't none and see if it's smaller … … 3893 3565 var opts = CSSESC_QUOTE_OPTIONS[quote]; 3894 3566 var quoteValue = (0, _cssesc["default"])(v, opts); 3895 3896 3567 if (quoteValue.length < escaped.length) { 3897 3568 return quote; 3898 3569 } 3899 3570 } 3900 3901 3571 return pref; 3902 3572 } … … 3909 3579 } 3910 3580 } 3581 3911 3582 /** 3912 3583 * Selects the preferred quote mark based on the options and the current quote mark value. 3913 3584 * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)` 3914 3585 * instead. 3915 */ 3916 ; 3917 3586 */; 3918 3587 _proto.preferredQuoteMark = function preferredQuoteMark(options) { 3919 3588 var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark; 3920 3921 3589 if (quoteMark === undefined) { 3922 3590 quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark; 3923 3591 } 3924 3925 3592 if (quoteMark === undefined) { 3926 3593 quoteMark = Attribute.DOUBLE_QUOTE; 3927 3594 } 3928 3929 3595 return quoteMark; 3930 3596 }; 3931 3932 3597 _proto._syncRawValue = function _syncRawValue() { 3933 3598 var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]); 3934 3935 3599 if (rawValue === this._value) { 3936 3600 if (this.raws) { … … 3941 3605 } 3942 3606 }; 3943 3944 3607 _proto._handleEscapes = function _handleEscapes(prop, value) { 3945 3608 if (this._constructed) { … … 3947 3610 isIdentifier: true 3948 3611 }); 3949 3950 3612 if (escaped !== value) { 3951 3613 this.raws[prop] = escaped; … … 3955 3617 } 3956 3618 }; 3957 3958 3619 _proto._spacesFor = function _spacesFor(name) { 3959 3620 var attrSpaces = { … … 3965 3626 return Object.assign(attrSpaces, spaces, rawSpaces); 3966 3627 }; 3967 3968 3628 _proto._stringFor = function _stringFor(name, spaceName, concat) { 3969 3629 if (spaceName === void 0) { 3970 3630 spaceName = name; 3971 3631 } 3972 3973 3632 if (concat === void 0) { 3974 3633 concat = defaultAttrConcat; 3975 3634 } 3976 3977 3635 var attrSpaces = this._spacesFor(spaceName); 3978 3979 3636 return concat(this.stringifyProperty(name), attrSpaces); 3980 3637 } 3638 3981 3639 /** 3982 3640 * returns the offset of the attribute part specified relative to the … … 3992 3650 * @param part One of the possible values inside an attribute. 3993 3651 * @returns -1 if the name is invalid or the value doesn't exist in this attribute. 3994 */ 3995 ; 3996 3652 */; 3997 3653 _proto.offsetOf = function offsetOf(name) { 3998 3654 var count = 1; 3999 4000 3655 var attributeSpaces = this._spacesFor("attribute"); 4001 4002 3656 count += attributeSpaces.before.length; 4003 4004 3657 if (name === "namespace" || name === "ns") { 4005 3658 return this.namespace ? count : -1; 4006 3659 } 4007 4008 3660 if (name === "attributeNS") { 4009 3661 return count; 4010 3662 } 4011 4012 3663 count += this.namespaceString.length; 4013 4014 3664 if (this.namespace) { 4015 3665 count += 1; 4016 3666 } 4017 4018 3667 if (name === "attribute") { 4019 3668 return count; 4020 3669 } 4021 4022 3670 count += this.stringifyProperty("attribute").length; 4023 3671 count += attributeSpaces.after.length; 4024 4025 3672 var operatorSpaces = this._spacesFor("operator"); 4026 4027 3673 count += operatorSpaces.before.length; 4028 3674 var operator = this.stringifyProperty("operator"); 4029 4030 3675 if (name === "operator") { 4031 3676 return operator ? count : -1; 4032 3677 } 4033 4034 3678 count += operator.length; 4035 3679 count += operatorSpaces.after.length; 4036 4037 3680 var valueSpaces = this._spacesFor("value"); 4038 4039 3681 count += valueSpaces.before.length; 4040 3682 var value = this.stringifyProperty("value"); 4041 4042 3683 if (name === "value") { 4043 3684 return value ? count : -1; 4044 3685 } 4045 4046 3686 count += value.length; 4047 3687 count += valueSpaces.after.length; 4048 4049 3688 var insensitiveSpaces = this._spacesFor("insensitive"); 4050 4051 3689 count += insensitiveSpaces.before.length; 4052 4053 3690 if (name === "insensitive") { 4054 3691 return this.insensitive ? count : -1; 4055 3692 } 4056 4057 3693 return -1; 4058 3694 }; 4059 4060 3695 _proto.toString = function toString() { 4061 3696 var _this2 = this; 4062 4063 3697 var selector = [this.rawSpaceBefore, '[']; 4064 3698 selector.push(this._stringFor('qualifiedAttribute', 'attribute')); 4065 4066 3699 if (this.operator && (this.value || this.value === '')) { 4067 3700 selector.push(this._stringFor('operator')); … … 4071 3704 attrSpaces.before = " "; 4072 3705 } 4073 4074 3706 return defaultAttrConcat(attrValue, attrSpaces); 4075 3707 })); 4076 3708 } 4077 4078 3709 selector.push(']'); 4079 3710 selector.push(this.rawSpaceAfter); 4080 3711 return selector.join(''); 4081 3712 }; 4082 4083 3713 _createClass(Attribute, [{ 4084 3714 key: "quoted", … … 4090 3720 warnOfDeprecatedQuotedAssignment(); 4091 3721 } 3722 4092 3723 /** 4093 3724 * returns a single (`'`) or double (`"`) quote character if the value is quoted. … … 4096 3727 * the attribute is constructed without specifying a quote mark.) 4097 3728 */ 4098 4099 3729 }, { 4100 3730 key: "quoteMark", … … 4102 3732 return this._quoteMark; 4103 3733 } 3734 4104 3735 /** 4105 3736 * Set the quote mark to be used by this attribute's value. … … 4108 3739 * 4109 3740 * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted. 4110 */ 4111 , 3741 */, 4112 3742 set: function set(quoteMark) { 4113 3743 if (!this._constructed) { … … 4115 3745 return; 4116 3746 } 4117 4118 3747 if (this._quoteMark !== quoteMark) { 4119 3748 this._quoteMark = quoteMark; 4120 4121 3749 this._syncRawValue(); 4122 3750 } … … 4153 3781 if (this._constructed) { 4154 3782 var _unescapeValue2 = unescapeValue(v), 4155 deprecatedUsage = _unescapeValue2.deprecatedUsage, 4156 unescaped = _unescapeValue2.unescaped, 4157 quoteMark = _unescapeValue2.quoteMark; 4158 3783 deprecatedUsage = _unescapeValue2.deprecatedUsage, 3784 unescaped = _unescapeValue2.unescaped, 3785 quoteMark = _unescapeValue2.quoteMark; 4159 3786 if (deprecatedUsage) { 4160 3787 warnOfDeprecatedValueAssignment(); 4161 3788 } 4162 4163 3789 if (unescaped === this._value && quoteMark === this._quoteMark) { 4164 3790 return; 4165 3791 } 4166 4167 3792 this._value = unescaped; 4168 3793 this._quoteMark = quoteMark; 4169 4170 3794 this._syncRawValue(); 4171 3795 } else { … … 4178 3802 return this._insensitive; 4179 3803 } 3804 4180 3805 /** 4181 3806 * Set the case insensitive flag. … … 4184 3809 * 4185 3810 * @param {true | false} insensitive true if the attribute should match case-insensitively. 4186 */ 4187 , 3811 */, 4188 3812 set: function set(insensitive) { 4189 3813 if (!insensitive) { 4190 this._insensitive = false; // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation. 3814 this._insensitive = false; 3815 3816 // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation. 4191 3817 // When setting `attr.insensitive = false` both should be erased to ensure correct serialization. 4192 4193 3818 if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) { 4194 3819 this.raws.insensitiveFlag = undefined; 4195 3820 } 4196 3821 } 4197 4198 3822 this._insensitive = insensitive; 4199 3823 } … … 4205 3829 set: function set(name) { 4206 3830 this._handleEscapes("attribute", name); 4207 4208 3831 this._attribute = name; 4209 3832 } 4210 3833 }]); 4211 4212 3834 return Attribute; 4213 3835 }(_namespace["default"]); 4214 4215 3836 exports["default"] = Attribute; 4216 3837 Attribute.NO_QUOTE = null; … … 4229 3850 isIdentifier: true 4230 3851 }, _CSSESC_QUOTE_OPTIONS); 4231 4232 3852 function defaultAttrConcat(attrValue, attrSpaces) { 4233 3853 return "" + attrSpaces.before + attrValue + attrSpaces.after; … … 4241 3861 exports.__esModule = true; 4242 3862 exports["default"] = void 0; 4243 4244 3863 var _namespace = _interopRequireDefault(namespaceExports); 4245 4246 3864 var _types = types; 4247 4248 3865 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 4249 4250 3866 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 4251 4252 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 4253 3867 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 4254 3868 var Universal = /*#__PURE__*/function (_Namespace) { 4255 3869 _inheritsLoose(Universal, _Namespace); 4256 4257 3870 function Universal(opts) { 4258 3871 var _this; 4259 4260 3872 _this = _Namespace.call(this, opts) || this; 4261 3873 _this.type = _types.UNIVERSAL; … … 4263 3875 return _this; 4264 3876 } 4265 4266 3877 return Universal; 4267 3878 }(_namespace["default"]); 4268 4269 3879 exports["default"] = Universal; 4270 3880 module.exports = exports.default; … … 4279 3889 exports.__esModule = true; 4280 3890 exports["default"] = void 0; 4281 4282 3891 var _node = _interopRequireDefault(nodeExports); 4283 4284 3892 var _types = types; 4285 4286 3893 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 4287 4288 3894 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 4289 4290 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 4291 3895 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 4292 3896 var Combinator = /*#__PURE__*/function (_Node) { 4293 3897 _inheritsLoose(Combinator, _Node); 4294 4295 3898 function Combinator(opts) { 4296 3899 var _this; 4297 4298 3900 _this = _Node.call(this, opts) || this; 4299 3901 _this.type = _types.COMBINATOR; 4300 3902 return _this; 4301 3903 } 4302 4303 3904 return Combinator; 4304 3905 }(_node["default"]); 4305 4306 3906 exports["default"] = Combinator; 4307 3907 module.exports = exports.default; … … 4316 3916 exports.__esModule = true; 4317 3917 exports["default"] = void 0; 4318 4319 3918 var _node = _interopRequireDefault(nodeExports); 4320 4321 3919 var _types = types; 4322 4323 3920 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 4324 4325 3921 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } 4326 4327 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 4328 3922 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 4329 3923 var Nesting = /*#__PURE__*/function (_Node) { 4330 3924 _inheritsLoose(Nesting, _Node); 4331 4332 3925 function Nesting(opts) { 4333 3926 var _this; 4334 4335 3927 _this = _Node.call(this, opts) || this; 4336 3928 _this.type = _types.NESTING; … … 4338 3930 return _this; 4339 3931 } 4340 4341 3932 return Nesting; 4342 3933 }(_node["default"]); 4343 4344 3934 exports["default"] = Nesting; 4345 3935 module.exports = exports.default; … … 4354 3944 exports.__esModule = true; 4355 3945 exports["default"] = sortAscending; 4356 4357 3946 function sortAscending(list) { 4358 3947 return list.sort(function (a, b) { … … 4370 3959 4371 3960 tokenTypes.__esModule = true; 4372 tokenTypes. combinator = tokenTypes.word = tokenTypes.comment = tokenTypes.str = tokenTypes.tab = tokenTypes.newline = tokenTypes.feed = tokenTypes.cr = tokenTypes.backslash = tokenTypes.bang = tokenTypes.slash = tokenTypes.doubleQuote = tokenTypes.singleQuote = tokenTypes.space = tokenTypes.greaterThan = tokenTypes.pipe = tokenTypes.equals = tokenTypes.plus = tokenTypes.caret = tokenTypes.tilde = tokenTypes.dollar = tokenTypes.closeSquare = tokenTypes.openSquare = tokenTypes.closeParenthesis = tokenTypes.openParenthesis = tokenTypes.semicolon = tokenTypes.colon = tokenTypes.comma= tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;3961 tokenTypes.word = tokenTypes.tilde = tokenTypes.tab = tokenTypes.str = tokenTypes.space = tokenTypes.slash = tokenTypes.singleQuote = tokenTypes.semicolon = tokenTypes.plus = tokenTypes.pipe = tokenTypes.openSquare = tokenTypes.openParenthesis = tokenTypes.newline = tokenTypes.greaterThan = tokenTypes.feed = tokenTypes.equals = tokenTypes.doubleQuote = tokenTypes.dollar = tokenTypes.cr = tokenTypes.comment = tokenTypes.comma = tokenTypes.combinator = tokenTypes.colon = tokenTypes.closeSquare = tokenTypes.closeParenthesis = tokenTypes.caret = tokenTypes.bang = tokenTypes.backslash = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0; 4373 3962 var ampersand = 38; // `&`.charCodeAt(0); 4374 4375 3963 tokenTypes.ampersand = ampersand; 4376 3964 var asterisk = 42; // `*`.charCodeAt(0); 4377 4378 3965 tokenTypes.asterisk = asterisk; 4379 3966 var at = 64; // `@`.charCodeAt(0); 4380 4381 3967 tokenTypes.at = at; 4382 3968 var comma = 44; // `,`.charCodeAt(0); 4383 4384 3969 tokenTypes.comma = comma; 4385 3970 var colon = 58; // `:`.charCodeAt(0); 4386 4387 3971 tokenTypes.colon = colon; 4388 3972 var semicolon = 59; // `;`.charCodeAt(0); 4389 4390 3973 tokenTypes.semicolon = semicolon; 4391 3974 var openParenthesis = 40; // `(`.charCodeAt(0); 4392 4393 3975 tokenTypes.openParenthesis = openParenthesis; 4394 3976 var closeParenthesis = 41; // `)`.charCodeAt(0); 4395 4396 3977 tokenTypes.closeParenthesis = closeParenthesis; 4397 3978 var openSquare = 91; // `[`.charCodeAt(0); 4398 4399 3979 tokenTypes.openSquare = openSquare; 4400 3980 var closeSquare = 93; // `]`.charCodeAt(0); 4401 4402 3981 tokenTypes.closeSquare = closeSquare; 4403 3982 var dollar = 36; // `$`.charCodeAt(0); 4404 4405 3983 tokenTypes.dollar = dollar; 4406 3984 var tilde = 126; // `~`.charCodeAt(0); 4407 4408 3985 tokenTypes.tilde = tilde; 4409 3986 var caret = 94; // `^`.charCodeAt(0); 4410 4411 3987 tokenTypes.caret = caret; 4412 3988 var plus = 43; // `+`.charCodeAt(0); 4413 4414 3989 tokenTypes.plus = plus; 4415 3990 var equals = 61; // `=`.charCodeAt(0); 4416 4417 3991 tokenTypes.equals = equals; 4418 3992 var pipe = 124; // `|`.charCodeAt(0); 4419 4420 3993 tokenTypes.pipe = pipe; 4421 3994 var greaterThan = 62; // `>`.charCodeAt(0); 4422 4423 3995 tokenTypes.greaterThan = greaterThan; 4424 3996 var space = 32; // ` `.charCodeAt(0); 4425 4426 3997 tokenTypes.space = space; 4427 3998 var singleQuote = 39; // `'`.charCodeAt(0); 4428 4429 3999 tokenTypes.singleQuote = singleQuote; 4430 4000 var doubleQuote = 34; // `"`.charCodeAt(0); 4431 4432 4001 tokenTypes.doubleQuote = doubleQuote; 4433 4002 var slash = 47; // `/`.charCodeAt(0); 4434 4435 4003 tokenTypes.slash = slash; 4436 4004 var bang = 33; // `!`.charCodeAt(0); 4437 4438 4005 tokenTypes.bang = bang; 4439 4006 var backslash = 92; // '\\'.charCodeAt(0); 4440 4441 4007 tokenTypes.backslash = backslash; 4442 4008 var cr = 13; // '\r'.charCodeAt(0); 4443 4444 4009 tokenTypes.cr = cr; 4445 4010 var feed = 12; // '\f'.charCodeAt(0); 4446 4447 4011 tokenTypes.feed = feed; 4448 4012 var newline = 10; // '\n'.charCodeAt(0); 4449 4450 4013 tokenTypes.newline = newline; 4451 4014 var tab = 9; // '\t'.charCodeAt(0); 4015 4452 4016 // Expose aliases primarily for readability. 4453 4454 4017 tokenTypes.tab = tab; 4455 var str = singleQuote; // No good single character representation! 4456 4018 var str = singleQuote; 4019 4020 // No good single character representation! 4457 4021 tokenTypes.str = str; 4458 4022 var comment$1 = -1; … … 4466 4030 4467 4031 exports.__esModule = true; 4032 exports.FIELDS = void 0; 4468 4033 exports["default"] = tokenize; 4469 exports.FIELDS = void 0;4470 4471 4034 var t = _interopRequireWildcard(tokenTypes); 4472 4473 4035 var _unescapable, _wordDelimiters; 4474 4475 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } 4476 4477 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 4478 4036 function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 4037 function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 4479 4038 var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable); 4480 4039 var wordDelimiters = (_wordDelimiters = {}, _wordDelimiters[t.space] = true, _wordDelimiters[t.tab] = true, _wordDelimiters[t.newline] = true, _wordDelimiters[t.cr] = true, _wordDelimiters[t.feed] = true, _wordDelimiters[t.ampersand] = true, _wordDelimiters[t.asterisk] = true, _wordDelimiters[t.bang] = true, _wordDelimiters[t.comma] = true, _wordDelimiters[t.colon] = true, _wordDelimiters[t.semicolon] = true, _wordDelimiters[t.openParenthesis] = true, _wordDelimiters[t.closeParenthesis] = true, _wordDelimiters[t.openSquare] = true, _wordDelimiters[t.closeSquare] = true, _wordDelimiters[t.singleQuote] = true, _wordDelimiters[t.doubleQuote] = true, _wordDelimiters[t.plus] = true, _wordDelimiters[t.pipe] = true, _wordDelimiters[t.tilde] = true, _wordDelimiters[t.greaterThan] = true, _wordDelimiters[t.equals] = true, _wordDelimiters[t.dollar] = true, _wordDelimiters[t.caret] = true, _wordDelimiters[t.slash] = true, _wordDelimiters); 4481 4040 var hex = {}; 4482 4041 var hexChars = "0123456789abcdefABCDEF"; 4483 4484 4042 for (var i = 0; i < hexChars.length; i++) { 4485 4043 hex[hexChars.charCodeAt(i)] = true; 4486 4044 } 4045 4487 4046 /** 4488 4047 * Returns the last index of the bar css word … … 4490 4049 * @param {number} start The index into the string where word's first letter occurs 4491 4050 */ 4492 4493 4494 4051 function consumeWord(css, start) { 4495 4052 var next = start; 4496 4053 var code; 4497 4498 4054 do { 4499 4055 code = css.charCodeAt(next); 4500 4501 4056 if (wordDelimiters[code]) { 4502 4057 return next - 1; … … 4508 4063 } 4509 4064 } while (next < css.length); 4510 4511 4065 return next - 1; 4512 4066 } 4067 4513 4068 /** 4514 4069 * Returns the last index of the escape sequence … … 4516 4071 * @param {number} start The index into the string where escape character (`\`) occurs. 4517 4072 */ 4518 4519 4520 4073 function consumeEscape(css, start) { 4521 4074 var next = start; 4522 4075 var code = css.charCodeAt(next + 1); 4523 4524 4076 if (unescapable[code]) ; else if (hex[code]) { 4525 var hexDigits = 0; // consume up to 6 hex chars4526 4077 var hexDigits = 0; 4078 // consume up to 6 hex chars 4527 4079 do { 4528 4080 next++; 4529 4081 hexDigits++; 4530 4082 code = css.charCodeAt(next + 1); 4531 } while (hex[code] && hexDigits < 6); // if fewer than 6 hex chars, a trailing space ends the escape 4532 4533 4083 } while (hex[code] && hexDigits < 6); 4084 // if fewer than 6 hex chars, a trailing space ends the escape 4534 4085 if (hexDigits < 6 && code === t.space) { 4535 4086 next++; … … 4539 4090 next++; 4540 4091 } 4541 4542 4092 return next; 4543 4093 } 4544 4545 4094 var FIELDS = { 4546 4095 TYPE: 0, … … 4553 4102 }; 4554 4103 exports.FIELDS = FIELDS; 4555 4556 4104 function tokenize(input) { 4557 4105 var tokens = []; 4558 4106 var css = input.css.valueOf(); 4559 4107 var _css = css, 4560 4108 length = _css.length; 4561 4109 var offset = -1; 4562 4110 var line = 1; … … 4564 4112 var end = 0; 4565 4113 var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType; 4566 4567 4114 function unclosed(what, fix) { 4568 4115 if (input.safe) { … … 4574 4121 } 4575 4122 } 4576 4577 4123 while (start < length) { 4578 4124 code = css.charCodeAt(start); 4579 4580 4125 if (code === t.newline) { 4581 4126 offset = start; 4582 4127 line += 1; 4583 4128 } 4584 4585 4129 switch (code) { 4586 4130 case t.space: … … 4590 4134 case t.feed: 4591 4135 next = start; 4592 4593 4136 do { 4594 4137 next += 1; 4595 4138 code = css.charCodeAt(next); 4596 4597 4139 if (code === t.newline) { 4598 4140 offset = next; … … 4600 4142 } 4601 4143 } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed); 4602 4603 4144 tokenType = t.space; 4604 4145 endLine = line; … … 4606 4147 end = next; 4607 4148 break; 4608 4609 4149 case t.plus: 4610 4150 case t.greaterThan: … … 4612 4152 case t.pipe: 4613 4153 next = start; 4614 4615 4154 do { 4616 4155 next += 1; 4617 4156 code = css.charCodeAt(next); 4618 4157 } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe); 4619 4620 4158 tokenType = t.combinator; 4621 4159 endLine = line; … … 4623 4161 end = next; 4624 4162 break; 4163 4625 4164 // Consume these characters as single tokens. 4626 4627 4165 case t.asterisk: 4628 4166 case t.ampersand: … … 4644 4182 end = next + 1; 4645 4183 break; 4646 4647 4184 case t.singleQuote: 4648 4185 case t.doubleQuote: 4649 4186 quote = code === t.singleQuote ? "'" : '"'; 4650 4187 next = start; 4651 4652 4188 do { 4653 4189 escaped = false; 4654 4190 next = css.indexOf(quote, next + 1); 4655 4656 4191 if (next === -1) { 4657 4192 unclosed('quote', quote); 4658 4193 } 4659 4660 4194 escapePos = next; 4661 4662 4195 while (css.charCodeAt(escapePos - 1) === t.backslash) { 4663 4196 escapePos -= 1; … … 4665 4198 } 4666 4199 } while (escaped); 4667 4668 4200 tokenType = t.str; 4669 4201 endLine = line; … … 4671 4203 end = next + 1; 4672 4204 break; 4673 4674 4205 default: 4675 4206 if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) { 4676 4207 next = css.indexOf('*/', start + 2) + 1; 4677 4678 4208 if (next === 0) { 4679 4209 unclosed('comment', '*/'); 4680 4210 } 4681 4682 4211 content = css.slice(start, next + 1); 4683 4212 lines = content.split('\n'); 4684 4213 last = lines.length - 1; 4685 4686 4214 if (last > 0) { 4687 4215 nextLine = line + last; … … 4691 4219 nextOffset = offset; 4692 4220 } 4693 4694 4221 tokenType = t.comment; 4695 4222 line = nextLine; … … 4708 4235 endColumn = next - offset; 4709 4236 } 4710 4711 4237 end = next + 1; 4712 4238 break; 4713 } // Ensure that the token structure remains consistent 4714 4715 4716 tokens.push([tokenType, // [0] Token type 4717 line, // [1] Starting line 4718 start - offset, // [2] Starting column 4719 endLine, // [3] Ending line 4720 endColumn, // [4] Ending column 4721 start, // [5] Start position / Source index 4239 } 4240 4241 // Ensure that the token structure remains consistent 4242 tokens.push([tokenType, 4243 // [0] Token type 4244 line, 4245 // [1] Starting line 4246 start - offset, 4247 // [2] Starting column 4248 endLine, 4249 // [3] Ending line 4250 endColumn, 4251 // [4] Ending column 4252 start, 4253 // [5] Start position / Source index 4722 4254 end // [6] End position 4723 ]); // Reset offset for the next token 4724 4255 ]); 4256 4257 // Reset offset for the next token 4725 4258 if (nextOffset) { 4726 4259 offset = nextOffset; 4727 4260 nextOffset = null; 4728 4261 } 4729 4730 4262 start = end; 4731 4263 } 4732 4733 4264 return tokens; 4734 4265 } … … 4739 4270 exports.__esModule = true; 4740 4271 exports["default"] = void 0; 4741 4742 4272 var _root = _interopRequireDefault(rootExports); 4743 4744 4273 var _selector = _interopRequireDefault(selectorExports); 4745 4746 4274 var _className = _interopRequireDefault(classNameExports); 4747 4748 4275 var _comment = _interopRequireDefault(commentExports); 4749 4750 4276 var _id = _interopRequireDefault(idExports); 4751 4752 4277 var _tag = _interopRequireDefault(tagExports); 4753 4754 4278 var _string = _interopRequireDefault(stringExports); 4755 4756 4279 var _pseudo = _interopRequireDefault(pseudoExports); 4757 4758 4280 var _attribute = _interopRequireWildcard(attribute$1); 4759 4760 4281 var _universal = _interopRequireDefault(universalExports); 4761 4762 4282 var _combinator = _interopRequireDefault(combinatorExports); 4763 4764 4283 var _nesting = _interopRequireDefault(nestingExports); 4765 4766 4284 var _sortAscending = _interopRequireDefault(sortAscendingExports); 4767 4768 4285 var _tokenize = _interopRequireWildcard(tokenize); 4769 4770 4286 var tokens = _interopRequireWildcard(tokenTypes); 4771 4772 4287 var types$1 = _interopRequireWildcard(types); 4773 4774 4288 var _util = util; 4775 4776 4289 var _WHITESPACE_TOKENS, _Object$assign; 4777 4778 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } 4779 4780 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 4781 4290 function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 4291 function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 4782 4292 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 4783 4784 4293 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 4785 4786 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; } 4787 4294 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 4788 4295 var WHITESPACE_TOKENS = (_WHITESPACE_TOKENS = {}, _WHITESPACE_TOKENS[tokens.space] = true, _WHITESPACE_TOKENS[tokens.cr] = true, _WHITESPACE_TOKENS[tokens.feed] = true, _WHITESPACE_TOKENS[tokens.newline] = true, _WHITESPACE_TOKENS[tokens.tab] = true, _WHITESPACE_TOKENS); 4789 4296 var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign)); 4790 4791 4297 function tokenStart(token) { 4792 4298 return { … … 4795 4301 }; 4796 4302 } 4797 4798 4303 function tokenEnd(token) { 4799 4304 return { … … 4802 4307 }; 4803 4308 } 4804 4805 4309 function getSource(startLine, startColumn, endLine, endColumn) { 4806 4310 return { … … 4815 4319 }; 4816 4320 } 4817 4818 4321 function getTokenSource(token) { 4819 4322 return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]); 4820 4323 } 4821 4822 4324 function getTokenSourceSpan(startToken, endToken) { 4823 4325 if (!startToken) { 4824 4326 return undefined; 4825 4327 } 4826 4827 4328 return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]); 4828 4329 } 4829 4830 4330 function unescapeProp(node, prop) { 4831 4331 var value = node[prop]; 4832 4833 4332 if (typeof value !== "string") { 4834 4333 return; 4835 4334 } 4836 4837 4335 if (value.indexOf("\\") !== -1) { 4838 4336 (0, _util.ensureObject)(node, 'raws'); 4839 4337 node[prop] = (0, _util.unesc)(value); 4840 4841 4338 if (node.raws[prop] === undefined) { 4842 4339 node.raws[prop] = value; 4843 4340 } 4844 4341 } 4845 4846 4342 return node; 4847 4343 } 4848 4849 4344 function indexesOf(array, item) { 4850 4345 var i = -1; 4851 4346 var indexes = []; 4852 4853 4347 while ((i = array.indexOf(item, i + 1)) !== -1) { 4854 4348 indexes.push(i); 4855 4349 } 4856 4857 4350 return indexes; 4858 4351 } 4859 4860 4352 function uniqs() { 4861 4353 var list = Array.prototype.concat.apply([], arguments); … … 4864 4356 }); 4865 4357 } 4866 4867 4358 var Parser = /*#__PURE__*/function () { 4868 4359 function Parser(rule, options) { … … 4870 4361 options = {}; 4871 4362 } 4872 4873 4363 this.rule = rule; 4874 4364 this.options = Object.assign({ … … 4894 4384 column: 1 4895 4385 } 4896 } 4386 }, 4387 sourceIndex: 0 4897 4388 }); 4898 4389 this.root.append(selector); … … 4900 4391 this.loop(); 4901 4392 } 4902 4903 4393 var _proto = Parser.prototype; 4904 4905 4394 _proto._errorGenerator = function _errorGenerator() { 4906 4395 var _this = this; 4907 4908 4396 return function (message, errorOptions) { 4909 4397 if (typeof _this.rule === 'string') { 4910 4398 return new Error(message); 4911 4399 } 4912 4913 4400 return _this.rule.error(message, errorOptions); 4914 4401 }; 4915 4402 }; 4916 4917 4403 _proto.attribute = function attribute() { 4918 4404 var attr = []; 4919 4405 var startingToken = this.currToken; 4920 4406 this.position++; 4921 4922 4407 while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) { 4923 4408 attr.push(this.currToken); 4924 4409 this.position++; 4925 4410 } 4926 4927 4411 if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) { 4928 4412 return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]); 4929 4413 } 4930 4931 4414 var len = attr.length; 4932 4415 var node = { … … 4934 4417 sourceIndex: startingToken[_tokenize.FIELDS.START_POS] 4935 4418 }; 4936 4937 4419 if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) { 4938 4420 return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]); 4939 4421 } 4940 4941 4422 var pos = 0; 4942 4423 var spaceBefore = ''; … … 4944 4425 var lastAdded = null; 4945 4426 var spaceAfterMeaningfulToken = false; 4946 4947 4427 while (pos < len) { 4948 4428 var token = attr[pos]; 4949 4429 var content = this.content(token); 4950 4430 var next = attr[pos + 1]; 4951 4952 4431 switch (token[_tokenize.FIELDS.TYPE]) { 4953 4432 case tokens.space: … … 4959 4438 // } 4960 4439 spaceAfterMeaningfulToken = true; 4961 4962 4440 if (this.options.lossy) { 4963 4441 break; 4964 4442 } 4965 4966 4443 if (lastAdded) { 4967 4444 (0, _util.ensureObject)(node, 'spaces', lastAdded); … … 4969 4446 node.spaces[lastAdded].after = prevContent + content; 4970 4447 var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null; 4971 4972 4448 if (existingComment) { 4973 4449 node.raws.spaces[lastAdded].after = existingComment + content; … … 4977 4453 commentBefore = commentBefore + content; 4978 4454 } 4979 4980 4455 break; 4981 4982 4456 case tokens.asterisk: 4983 4457 if (next[_tokenize.FIELDS.TYPE] === tokens.equals) { … … 4990 4464 spaceBefore = ''; 4991 4465 } 4992 4993 4466 if (commentBefore) { 4994 4467 (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute'); … … 4996 4469 commentBefore = ''; 4997 4470 } 4998 4999 4471 node.namespace = (node.namespace || "") + content; 5000 4472 var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null; 5001 5002 4473 if (rawValue) { 5003 4474 node.raws.namespace += content; 5004 4475 } 5005 5006 4476 lastAdded = 'namespace'; 5007 4477 } 5008 5009 4478 spaceAfterMeaningfulToken = false; 5010 4479 break; 5011 5012 4480 case tokens.dollar: 5013 4481 if (lastAdded === "value") { 5014 4482 var oldRawValue = (0, _util.getProp)(node, 'raws', 'value'); 5015 4483 node.value += "$"; 5016 5017 4484 if (oldRawValue) { 5018 4485 node.raws.value = oldRawValue + "$"; 5019 4486 } 5020 5021 4487 break; 5022 4488 } 5023 5024 4489 // Falls through 5025 5026 4490 case tokens.caret: 5027 4491 if (next[_tokenize.FIELDS.TYPE] === tokens.equals) { … … 5029 4493 lastAdded = 'operator'; 5030 4494 } 5031 5032 4495 spaceAfterMeaningfulToken = false; 5033 4496 break; 5034 5035 4497 case tokens.combinator: 5036 4498 if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) { … … 5038 4500 lastAdded = 'operator'; 5039 4501 } 5040 5041 4502 if (content !== '|') { 5042 4503 spaceAfterMeaningfulToken = false; 5043 4504 break; 5044 4505 } 5045 5046 4506 if (next[_tokenize.FIELDS.TYPE] === tokens.equals) { 5047 4507 node.operator = content; … … 5050 4510 node.namespace = true; 5051 4511 } 5052 5053 4512 spaceAfterMeaningfulToken = false; 5054 4513 break; 5055 5056 4514 case tokens.word: 5057 if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals && // this look-ahead probably fails with comment nodes involved. 4515 if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals && 4516 // this look-ahead probably fails with comment nodes involved. 5058 4517 !node.operator && !node.namespace) { 5059 4518 node.namespace = content; … … 5065 4524 spaceBefore = ''; 5066 4525 } 5067 5068 4526 if (commentBefore) { 5069 4527 (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute'); … … 5071 4529 commentBefore = ''; 5072 4530 } 5073 5074 4531 node.attribute = (node.attribute || "") + content; 5075 5076 4532 var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null; 5077 5078 4533 if (_rawValue) { 5079 4534 node.raws.attribute += content; 5080 4535 } 5081 5082 4536 lastAdded = 'attribute'; 5083 4537 } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) { 5084 4538 var _unescaped = (0, _util.unesc)(content); 5085 5086 4539 var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || ''; 5087 5088 4540 var oldValue = node.value || ''; 5089 4541 node.value = oldValue + _unescaped; 5090 4542 node.quoteMark = null; 5091 5092 4543 if (_unescaped !== content || _oldRawValue) { 5093 4544 (0, _util.ensureObject)(node, 'raws'); 5094 4545 node.raws.value = (_oldRawValue || oldValue) + content; 5095 4546 } 5096 5097 4547 lastAdded = 'value'; 5098 4548 } else { 5099 4549 var insensitive = content === 'i' || content === "I"; 5100 5101 4550 if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) { 5102 4551 node.insensitive = insensitive; 5103 5104 4552 if (!insensitive || content === "I") { 5105 4553 (0, _util.ensureObject)(node, 'raws'); 5106 4554 node.raws.insensitiveFlag = content; 5107 4555 } 5108 5109 4556 lastAdded = 'insensitive'; 5110 5111 4557 if (spaceBefore) { 5112 4558 (0, _util.ensureObject)(node, 'spaces', 'insensitive'); … … 5114 4560 spaceBefore = ''; 5115 4561 } 5116 5117 4562 if (commentBefore) { 5118 4563 (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive'); … … 5123 4568 lastAdded = 'value'; 5124 4569 node.value += content; 5125 5126 4570 if (node.raws.value) { 5127 4571 node.raws.value += content; … … 5129 4573 } 5130 4574 } 5131 5132 4575 spaceAfterMeaningfulToken = false; 5133 4576 break; 5134 5135 4577 case tokens.str: 5136 4578 if (!node.attribute || !node.operator) { … … 5139 4581 }); 5140 4582 } 5141 5142 4583 var _unescapeValue = (0, _attribute.unescapeValue)(content), 5143 unescaped = _unescapeValue.unescaped, 5144 quoteMark = _unescapeValue.quoteMark; 5145 4584 unescaped = _unescapeValue.unescaped, 4585 quoteMark = _unescapeValue.quoteMark; 5146 4586 node.value = unescaped; 5147 4587 node.quoteMark = quoteMark; … … 5151 4591 spaceAfterMeaningfulToken = false; 5152 4592 break; 5153 5154 4593 case tokens.equals: 5155 4594 if (!node.attribute) { 5156 4595 return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content); 5157 4596 } 5158 5159 4597 if (node.value) { 5160 4598 return this.error('Unexpected "=" found; an operator was already defined.', { … … 5162 4600 }); 5163 4601 } 5164 5165 4602 node.operator = node.operator ? node.operator + content : content; 5166 4603 lastAdded = 'operator'; 5167 4604 spaceAfterMeaningfulToken = false; 5168 4605 break; 5169 5170 4606 case tokens.comment: 5171 4607 if (lastAdded) { … … 5184 4620 commentBefore = commentBefore + content; 5185 4621 } 5186 5187 4622 break; 5188 5189 4623 default: 5190 4624 return this.error("Unexpected \"" + content + "\" found.", { … … 5192 4626 }); 5193 4627 } 5194 5195 4628 pos++; 5196 4629 } 5197 5198 4630 unescapeProp(node, "attribute"); 5199 4631 unescapeProp(node, "namespace"); … … 5201 4633 this.position++; 5202 4634 } 4635 5203 4636 /** 5204 4637 * return a node containing meaningless garbage up to (but not including) the specified token position. … … 5212 4645 * 5213 4646 * In lossy mode, this returns only comments. 5214 */ 5215 ; 5216 4647 */; 5217 4648 _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) { 5218 4649 if (stopPosition < 0) { 5219 4650 stopPosition = this.tokens.length; 5220 4651 } 5221 5222 4652 var startPosition = this.position; 5223 4653 var nodes = []; 5224 4654 var space = ""; 5225 4655 var lastComment = undefined; 5226 5227 4656 do { 5228 4657 if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) { … … 5232 4661 } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) { 5233 4662 var spaces = {}; 5234 5235 4663 if (space) { 5236 4664 spaces.before = space; 5237 4665 space = ""; 5238 4666 } 5239 5240 4667 lastComment = new _comment["default"]({ 5241 4668 value: this.content(), … … 5247 4674 } 5248 4675 } while (++this.position < stopPosition); 5249 5250 4676 if (space) { 5251 4677 if (lastComment) { … … 5265 4691 } 5266 4692 } 5267 5268 4693 return nodes; 5269 4694 } 4695 5270 4696 /** 5271 4697 * 5272 4698 * @param {*} nodes 5273 */ 5274 ; 5275 4699 */; 5276 4700 _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) { 5277 4701 var _this2 = this; 5278 5279 4702 if (requiredSpace === void 0) { 5280 4703 requiredSpace = false; 5281 4704 } 5282 5283 4705 var space = ""; 5284 4706 var rawSpace = ""; 5285 4707 nodes.forEach(function (n) { 5286 4708 var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace); 5287 5288 4709 var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace); 5289 5290 4710 space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0); 5291 4711 rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0); 5292 4712 }); 5293 5294 4713 if (rawSpace === space) { 5295 4714 rawSpace = undefined; 5296 4715 } 5297 5298 4716 var result = { 5299 4717 space: space, … … 5302 4720 return result; 5303 4721 }; 5304 5305 4722 _proto.isNamedCombinator = function isNamedCombinator(position) { 5306 4723 if (position === void 0) { 5307 4724 position = this.position; 5308 4725 } 5309 5310 4726 return this.tokens[position + 0] && this.tokens[position + 0][_tokenize.FIELDS.TYPE] === tokens.slash && this.tokens[position + 1] && this.tokens[position + 1][_tokenize.FIELDS.TYPE] === tokens.word && this.tokens[position + 2] && this.tokens[position + 2][_tokenize.FIELDS.TYPE] === tokens.slash; 5311 4727 }; 5312 5313 4728 _proto.namedCombinator = function namedCombinator() { 5314 4729 if (this.isNamedCombinator()) { … … 5316 4731 var name = (0, _util.unesc)(nameRaw).toLowerCase(); 5317 4732 var raws = {}; 5318 5319 4733 if (name !== nameRaw) { 5320 4734 raws.value = "/" + nameRaw + "/"; 5321 4735 } 5322 5323 4736 var node = new _combinator["default"]({ 5324 4737 value: "/" + name + "/", … … 5333 4746 } 5334 4747 }; 5335 5336 4748 _proto.combinator = function combinator() { 5337 4749 var _this3 = this; 5338 5339 4750 if (this.content() === '|') { 5340 4751 return this.namespace(); 5341 } // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector. 5342 5343 4752 } 4753 // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector. 5344 4754 var nextSigTokenPos = this.locateNextMeaningfulToken(this.position); 5345 5346 4755 if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) { 5347 4756 var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos); 5348 5349 4757 if (nodes.length > 0) { 5350 4758 var last = this.current.last; 5351 5352 4759 if (last) { 5353 4760 var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes), 5354 space = _this$convertWhitespa.space, 5355 rawSpace = _this$convertWhitespa.rawSpace; 5356 4761 space = _this$convertWhitespa.space, 4762 rawSpace = _this$convertWhitespa.rawSpace; 5357 4763 if (rawSpace !== undefined) { 5358 4764 last.rawSpaceAfter += rawSpace; 5359 4765 } 5360 5361 4766 last.spaces.after += space; 5362 4767 } else { … … 5366 4771 } 5367 4772 } 5368 5369 4773 return; 5370 4774 } 5371 5372 4775 var firstToken = this.currToken; 5373 4776 var spaceOrDescendantSelectorNodes = undefined; 5374 5375 4777 if (nextSigTokenPos > this.position) { 5376 4778 spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos); 5377 4779 } 5378 5379 4780 var node; 5380 5381 4781 if (this.isNamedCombinator()) { 5382 4782 node = this.namedCombinator(); … … 5391 4791 this.unexpected(); 5392 4792 } 5393 5394 4793 if (node) { 5395 4794 if (spaceOrDescendantSelectorNodes) { 5396 4795 var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes), 5397 _space = _this$convertWhitespa2.space, 5398 _rawSpace = _this$convertWhitespa2.rawSpace; 5399 4796 _space = _this$convertWhitespa2.space, 4797 _rawSpace = _this$convertWhitespa2.rawSpace; 5400 4798 node.spaces.before = _space; 5401 4799 node.rawSpaceBefore = _rawSpace; … … 5404 4802 // descendant combinator 5405 4803 var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true), 5406 _space2 = _this$convertWhitespa3.space, 5407 _rawSpace2 = _this$convertWhitespa3.rawSpace; 5408 4804 _space2 = _this$convertWhitespa3.space, 4805 _rawSpace2 = _this$convertWhitespa3.rawSpace; 5409 4806 if (!_rawSpace2) { 5410 4807 _rawSpace2 = _space2; 5411 4808 } 5412 5413 4809 var spaces = {}; 5414 4810 var raws = { 5415 4811 spaces: {} 5416 4812 }; 5417 5418 4813 if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) { 5419 4814 spaces.before = _space2.slice(0, _space2.length - 1); … … 5425 4820 raws.value = _rawSpace2; 5426 4821 } 5427 5428 4822 node = new _combinator["default"]({ 5429 4823 value: ' ', … … 5434 4828 }); 5435 4829 } 5436 5437 4830 if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) { 5438 4831 node.spaces.after = this.optionalSpace(this.content()); 5439 4832 this.position++; 5440 4833 } 5441 5442 4834 return this.newNode(node); 5443 4835 }; 5444 5445 4836 _proto.comma = function comma() { 5446 4837 if (this.position === this.tokens.length - 1) { … … 5449 4840 return; 5450 4841 } 5451 5452 4842 this.current._inferEndPosition(); 5453 5454 4843 var selector = new _selector["default"]({ 5455 4844 source: { 5456 4845 start: tokenStart(this.tokens[this.position + 1]) 5457 } 4846 }, 4847 sourceIndex: this.tokens[this.position + 1][_tokenize.FIELDS.START_POS] 5458 4848 }); 5459 4849 this.current.parent.append(selector); … … 5461 4851 this.position++; 5462 4852 }; 5463 5464 4853 _proto.comment = function comment() { 5465 4854 var current = this.currToken; … … 5471 4860 this.position++; 5472 4861 }; 5473 5474 4862 _proto.error = function error(message, opts) { 5475 4863 throw this.root.error(message, opts); 5476 4864 }; 5477 5478 4865 _proto.missingBackslash = function missingBackslash() { 5479 4866 return this.error('Expected a backslash preceding the semicolon.', { … … 5481 4868 }); 5482 4869 }; 5483 5484 4870 _proto.missingParenthesis = function missingParenthesis() { 5485 4871 return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]); 5486 4872 }; 5487 5488 4873 _proto.missingSquareBracket = function missingSquareBracket() { 5489 4874 return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]); 5490 4875 }; 5491 5492 4876 _proto.unexpected = function unexpected() { 5493 4877 return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]); 5494 4878 }; 5495 4879 _proto.unexpectedPipe = function unexpectedPipe() { 4880 return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]); 4881 }; 5496 4882 _proto.namespace = function namespace() { 5497 4883 var before = this.prevToken && this.content(this.prevToken) || true; 5498 5499 4884 if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) { 5500 4885 this.position++; … … 5504 4889 return this.universal(before); 5505 4890 } 5506 };5507 4891 this.unexpectedPipe(); 4892 }; 5508 4893 _proto.nesting = function nesting() { 5509 4894 if (this.nextToken) { 5510 4895 var nextContent = this.content(this.nextToken); 5511 5512 4896 if (nextContent === "|") { 5513 4897 this.position++; … … 5515 4899 } 5516 4900 } 5517 5518 4901 var current = this.currToken; 5519 4902 this.newNode(new _nesting["default"]({ … … 5524 4907 this.position++; 5525 4908 }; 5526 5527 4909 _proto.parentheses = function parentheses() { 5528 4910 var last = this.current.last; 5529 4911 var unbalanced = 1; 5530 4912 this.position++; 5531 5532 4913 if (last && last.type === types$1.PSEUDO) { 5533 4914 var selector = new _selector["default"]({ 5534 4915 source: { 5535 start: tokenStart(this.tokens[this.position - 1]) 5536 } 4916 start: tokenStart(this.tokens[this.position]) 4917 }, 4918 sourceIndex: this.tokens[this.position][_tokenize.FIELDS.START_POS] 5537 4919 }); 5538 4920 var cache = this.current; 5539 4921 last.append(selector); 5540 4922 this.current = selector; 5541 5542 4923 while (this.position < this.tokens.length && unbalanced) { 5543 4924 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) { 5544 4925 unbalanced++; 5545 4926 } 5546 5547 4927 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) { 5548 4928 unbalanced--; 5549 4929 } 5550 5551 4930 if (unbalanced) { 5552 4931 this.parse(); … … 5557 4936 } 5558 4937 } 5559 5560 4938 this.current = cache; 5561 4939 } else { … … 5565 4943 var parenValue = "("; 5566 4944 var parenEnd; 5567 5568 4945 while (this.position < this.tokens.length && unbalanced) { 5569 4946 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) { 5570 4947 unbalanced++; 5571 4948 } 5572 5573 4949 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) { 5574 4950 unbalanced--; 5575 4951 } 5576 5577 4952 parenEnd = this.currToken; 5578 4953 parenValue += this.parseParenthesisToken(this.currToken); 5579 4954 this.position++; 5580 4955 } 5581 5582 4956 if (last) { 5583 4957 last.appendToPropertyAndEscape("value", parenValue, parenValue); … … 5590 4964 } 5591 4965 } 5592 5593 4966 if (unbalanced) { 5594 4967 return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]); 5595 4968 } 5596 4969 }; 5597 5598 4970 _proto.pseudo = function pseudo() { 5599 4971 var _this4 = this; 5600 5601 4972 var pseudoStr = ''; 5602 4973 var startingToken = this.currToken; 5603 5604 4974 while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) { 5605 4975 pseudoStr += this.content(); 5606 4976 this.position++; 5607 4977 } 5608 5609 4978 if (!this.currToken) { 5610 4979 return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1); 5611 4980 } 5612 5613 4981 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) { 5614 4982 this.splitWord(false, function (first, length) { 5615 4983 pseudoStr += first; 5616 5617 4984 _this4.newNode(new _pseudo["default"]({ 5618 4985 value: pseudoStr, … … 5620 4987 sourceIndex: startingToken[_tokenize.FIELDS.START_POS] 5621 4988 })); 5622 5623 4989 if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) { 5624 4990 _this4.error('Misplaced parenthesis.', { … … 5631 4997 } 5632 4998 }; 5633 5634 4999 _proto.space = function space() { 5635 var content = this.content(); // Handle space before and after the selector5636 5000 var content = this.content(); 5001 // Handle space before and after the selector 5637 5002 if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) { 5638 5003 return node.type === 'comment'; … … 5647 5012 } 5648 5013 }; 5649 5650 5014 _proto.string = function string() { 5651 5015 var current = this.currToken; … … 5657 5021 this.position++; 5658 5022 }; 5659 5660 5023 _proto.universal = function universal(namespace) { 5661 5024 var nextToken = this.nextToken; 5662 5663 5025 if (nextToken && this.content(nextToken) === '|') { 5664 5026 this.position++; 5665 5027 return this.namespace(); 5666 5028 } 5667 5668 5029 var current = this.currToken; 5669 5030 this.newNode(new _universal["default"]({ … … 5674 5035 this.position++; 5675 5036 }; 5676 5677 5037 _proto.splitWord = function splitWord(namespace, firstCallback) { 5678 5038 var _this5 = this; 5679 5680 5039 var nextToken = this.nextToken; 5681 5040 var word = this.content(); 5682 5683 5041 while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) { 5684 5042 this.position++; 5685 5043 var current = this.content(); 5686 5044 word += current; 5687 5688 5045 if (current.lastIndexOf('\\') === current.length - 1) { 5689 5046 var next = this.nextToken; 5690 5691 5047 if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) { 5692 5048 word += this.requiredSpace(this.content(next)); … … 5694 5050 } 5695 5051 } 5696 5697 5052 nextToken = this.nextToken; 5698 5053 } 5699 5700 5054 var hasClass = indexesOf(word, '.').filter(function (i) { 5701 5055 // Allow escaped dot within class name 5702 var escapedDot = word[i - 1] === '\\'; // Allow decimal numbers percent in @keyframes5703 5056 var escapedDot = word[i - 1] === '\\'; 5057 // Allow decimal numbers percent in @keyframes 5704 5058 var isKeyframesPercent = /^\d+\.\d+%$/.test(word); 5705 5059 return !escapedDot && !isKeyframesPercent; … … 5707 5061 var hasId = indexesOf(word, '#').filter(function (i) { 5708 5062 return word[i - 1] !== '\\'; 5709 }); // Eliminate Sass interpolations from the list of id indexes5710 5063 }); 5064 // Eliminate Sass interpolations from the list of id indexes 5711 5065 var interpolations = indexesOf(word, '#{'); 5712 5713 5066 if (interpolations.length) { 5714 5067 hasId = hasId.filter(function (hashIndex) { … … 5716 5069 }); 5717 5070 } 5718 5719 5071 var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId))); 5720 5072 indices.forEach(function (ind, i) { 5721 5073 var index = indices[i + 1] || word.length; 5722 5074 var value = word.slice(ind, index); 5723 5724 5075 if (i === 0 && firstCallback) { 5725 5076 return firstCallback.call(_this5, value, indices.length); 5726 5077 } 5727 5728 5078 var node; 5729 5079 var current = _this5.currToken; 5730 5080 var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i]; 5731 5081 var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1)); 5732 5733 5082 if (~hasClass.indexOf(ind)) { 5734 5083 var classNameOpts = { … … 5754 5103 node = new _tag["default"](tagOpts); 5755 5104 } 5756 5757 _this5.newNode(node, namespace); // Ensure that the namespace is used only once 5758 5759 5105 _this5.newNode(node, namespace); 5106 // Ensure that the namespace is used only once 5760 5107 namespace = null; 5761 5108 }); 5762 5109 this.position++; 5763 5110 }; 5764 5765 5111 _proto.word = function word(namespace) { 5766 5112 var nextToken = this.nextToken; 5767 5768 5113 if (nextToken && this.content(nextToken) === '|') { 5769 5114 this.position++; 5770 5115 return this.namespace(); 5771 5116 } 5772 5773 5117 return this.splitWord(namespace); 5774 5118 }; 5775 5776 5119 _proto.loop = function loop() { 5777 5120 while (this.position < this.tokens.length) { 5778 5121 this.parse(true); 5779 5122 } 5780 5781 5123 this.current._inferEndPosition(); 5782 5783 5124 return this.root; 5784 5125 }; 5785 5786 5126 _proto.parse = function parse(throwOnParenthesis) { 5787 5127 switch (this.currToken[_tokenize.FIELDS.TYPE]) { … … 5789 5129 this.space(); 5790 5130 break; 5791 5792 5131 case tokens.comment: 5793 5132 this.comment(); 5794 5133 break; 5795 5796 5134 case tokens.openParenthesis: 5797 5135 this.parentheses(); 5798 5136 break; 5799 5800 5137 case tokens.closeParenthesis: 5801 5138 if (throwOnParenthesis) { 5802 5139 this.missingParenthesis(); 5803 5140 } 5804 5805 5141 break; 5806 5807 5142 case tokens.openSquare: 5808 5143 this.attribute(); 5809 5144 break; 5810 5811 5145 case tokens.dollar: 5812 5146 case tokens.caret: … … 5815 5149 this.word(); 5816 5150 break; 5817 5818 5151 case tokens.colon: 5819 5152 this.pseudo(); 5820 5153 break; 5821 5822 5154 case tokens.comma: 5823 5155 this.comma(); 5824 5156 break; 5825 5826 5157 case tokens.asterisk: 5827 5158 this.universal(); 5828 5159 break; 5829 5830 5160 case tokens.ampersand: 5831 5161 this.nesting(); 5832 5162 break; 5833 5834 5163 case tokens.slash: 5835 5164 case tokens.combinator: 5836 5165 this.combinator(); 5837 5166 break; 5838 5839 5167 case tokens.str: 5840 5168 this.string(); 5841 5169 break; 5842 5170 // These cases throw; no break needed. 5843 5844 5171 case tokens.closeSquare: 5845 5172 this.missingSquareBracket(); 5846 5847 5173 case tokens.semicolon: 5848 5174 this.missingBackslash(); 5849 5850 5175 default: 5851 5176 this.unexpected(); 5852 5177 } 5853 5178 } 5179 5854 5180 /** 5855 5181 * Helpers 5856 */ 5857 ; 5858 5182 */; 5859 5183 _proto.expected = function expected(description, index, found) { 5860 5184 if (Array.isArray(description)) { … … 5862 5186 description = description.join(', ') + " or " + last; 5863 5187 } 5864 5865 5188 var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a'; 5866 5867 5189 if (!found) { 5868 5190 return this.error("Expected " + an + " " + description + ".", { … … 5870 5192 }); 5871 5193 } 5872 5873 5194 return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", { 5874 5195 index: index 5875 5196 }); 5876 5197 }; 5877 5878 5198 _proto.requiredSpace = function requiredSpace(space) { 5879 5199 return this.options.lossy ? ' ' : space; 5880 5200 }; 5881 5882 5201 _proto.optionalSpace = function optionalSpace(space) { 5883 5202 return this.options.lossy ? '' : space; 5884 5203 }; 5885 5886 5204 _proto.lossySpace = function lossySpace(space, required) { 5887 5205 if (this.options.lossy) { … … 5891 5209 } 5892 5210 }; 5893 5894 5211 _proto.parseParenthesisToken = function parseParenthesisToken(token) { 5895 5212 var content = this.content(token); 5896 5897 5213 if (token[_tokenize.FIELDS.TYPE] === tokens.space) { 5898 5214 return this.requiredSpace(content); … … 5901 5217 } 5902 5218 }; 5903 5904 5219 _proto.newNode = function newNode(node, namespace) { 5905 5220 if (namespace) { … … 5908 5223 this.spaces = (this.spaces || '') + namespace; 5909 5224 } 5910 5911 5225 namespace = true; 5912 5226 } 5913 5914 5227 node.namespace = namespace; 5915 5228 unescapeProp(node, "namespace"); 5916 5229 } 5917 5918 5230 if (this.spaces) { 5919 5231 node.spaces.before = this.spaces; 5920 5232 this.spaces = ''; 5921 5233 } 5922 5923 5234 return this.current.append(node); 5924 5235 }; 5925 5926 5236 _proto.content = function content(token) { 5927 5237 if (token === void 0) { 5928 5238 token = this.currToken; 5929 5239 } 5930 5931 5240 return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]); 5932 5241 }; 5933 5934 5242 /** 5935 5243 * returns the index of the next non-whitespace, non-comment token. … … 5940 5248 startPosition = this.position + 1; 5941 5249 } 5942 5943 5250 var searchPosition = startPosition; 5944 5945 5251 while (searchPosition < this.tokens.length) { 5946 5252 if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) { … … 5951 5257 } 5952 5258 } 5953 5954 5259 return -1; 5955 5260 }; 5956 5957 5261 _createClass(Parser, [{ 5958 5262 key: "currToken", … … 5971 5275 } 5972 5276 }]); 5973 5974 5277 return Parser; 5975 5278 }(); 5976 5977 5279 exports["default"] = Parser; 5978 5280 module.exports = exports.default; … … 5985 5287 exports.__esModule = true; 5986 5288 exports["default"] = void 0; 5987 5988 5289 var _parser = _interopRequireDefault(parserExports); 5989 5990 5290 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 5991 5992 5291 var Processor = /*#__PURE__*/function () { 5993 5292 function Processor(func, options) { 5994 5293 this.func = func || function noop() {}; 5995 5996 5294 this.funcRes = null; 5997 5295 this.options = options; 5998 5296 } 5999 6000 5297 var _proto = Processor.prototype; 6001 6002 5298 _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) { 6003 5299 if (options === void 0) { 6004 5300 options = {}; 6005 5301 } 6006 6007 5302 var merged = Object.assign({}, this.options, options); 6008 6009 5303 if (merged.updateSelector === false) { 6010 5304 return false; … … 6013 5307 } 6014 5308 }; 6015 6016 5309 _proto._isLossy = function _isLossy(options) { 6017 5310 if (options === void 0) { 6018 5311 options = {}; 6019 5312 } 6020 6021 5313 var merged = Object.assign({}, this.options, options); 6022 6023 5314 if (merged.lossless === false) { 6024 5315 return true; … … 6027 5318 } 6028 5319 }; 6029 6030 5320 _proto._root = function _root(rule, options) { 6031 5321 if (options === void 0) { 6032 5322 options = {}; 6033 5323 } 6034 6035 5324 var parser = new _parser["default"](rule, this._parseOptions(options)); 6036 5325 return parser.root; 6037 5326 }; 6038 6039 5327 _proto._parseOptions = function _parseOptions(options) { 6040 5328 return { … … 6042 5330 }; 6043 5331 }; 6044 6045 5332 _proto._run = function _run(rule, options) { 6046 5333 var _this = this; 6047 6048 5334 if (options === void 0) { 6049 5335 options = {}; 6050 5336 } 6051 6052 5337 return new Promise(function (resolve, reject) { 6053 5338 try { 6054 5339 var root = _this._root(rule, options); 6055 6056 5340 Promise.resolve(_this.func(root)).then(function (transform) { 6057 5341 var string = undefined; 6058 6059 5342 if (_this._shouldUpdateSelector(rule, options)) { 6060 5343 string = root.toString(); 6061 5344 rule.selector = string; 6062 5345 } 6063 6064 5346 return { 6065 5347 transform: transform, … … 6074 5356 }); 6075 5357 }; 6076 6077 5358 _proto._runSync = function _runSync(rule, options) { 6078 5359 if (options === void 0) { 6079 5360 options = {}; 6080 5361 } 6081 6082 5362 var root = this._root(rule, options); 6083 6084 5363 var transform = this.func(root); 6085 6086 5364 if (transform && typeof transform.then === "function") { 6087 5365 throw new Error("Selector processor returned a promise to a synchronous call."); 6088 5366 } 6089 6090 5367 var string = undefined; 6091 6092 5368 if (options.updateSelector && typeof rule !== "string") { 6093 5369 string = root.toString(); 6094 5370 rule.selector = string; 6095 5371 } 6096 6097 5372 return { 6098 5373 transform: transform, … … 6101 5376 }; 6102 5377 } 5378 6103 5379 /** 6104 5380 * Process rule into a selector AST. … … 6107 5383 * @param options The options for processing 6108 5384 * @returns {Promise<parser.Root>} The AST of the selector after processing it. 6109 */ 6110 ; 6111 5385 */; 6112 5386 _proto.ast = function ast(rule, options) { 6113 5387 return this._run(rule, options).then(function (result) { … … 6115 5389 }); 6116 5390 } 5391 6117 5392 /** 6118 5393 * Process rule into a selector AST synchronously. … … 6121 5396 * @param options The options for processing 6122 5397 * @returns {parser.Root} The AST of the selector after processing it. 6123 */ 6124 ; 6125 5398 */; 6126 5399 _proto.astSync = function astSync(rule, options) { 6127 5400 return this._runSync(rule, options).root; 6128 5401 } 5402 6129 5403 /** 6130 5404 * Process a selector into a transformed value asynchronously … … 6133 5407 * @param options The options for processing 6134 5408 * @returns {Promise<any>} The value returned by the processor. 6135 */ 6136 ; 6137 5409 */; 6138 5410 _proto.transform = function transform(rule, options) { 6139 5411 return this._run(rule, options).then(function (result) { … … 6141 5413 }); 6142 5414 } 5415 6143 5416 /** 6144 5417 * Process a selector into a transformed value synchronously. … … 6147 5420 * @param options The options for processing 6148 5421 * @returns {any} The value returned by the processor. 6149 */ 6150 ; 6151 5422 */; 6152 5423 _proto.transformSync = function transformSync(rule, options) { 6153 5424 return this._runSync(rule, options).transform; 6154 5425 } 5426 6155 5427 /** 6156 5428 * Process a selector into a new selector string asynchronously. … … 6159 5431 * @param options The options for processing 6160 5432 * @returns {string} the selector after processing. 6161 */ 6162 ; 6163 5433 */; 6164 5434 _proto.process = function process(rule, options) { 6165 5435 return this._run(rule, options).then(function (result) { … … 6167 5437 }); 6168 5438 } 5439 6169 5440 /** 6170 5441 * Process a selector into a new selector string synchronously. … … 6173 5444 * @param options The options for processing 6174 5445 * @returns {string} the selector after processing. 6175 */ 6176 ; 6177 5446 */; 6178 5447 _proto.processSync = function processSync(rule, options) { 6179 5448 var result = this._runSync(rule, options); 6180 6181 5449 return result.string || result.root.toString(); 6182 5450 }; 6183 6184 5451 return Processor; 6185 5452 }(); 6186 6187 5453 exports["default"] = Processor; 6188 5454 module.exports = exports.default; … … 6197 5463 constructors.__esModule = true; 6198 5464 constructors.universal = constructors.tag = constructors.string = constructors.selector = constructors.root = constructors.pseudo = constructors.nesting = constructors.id = constructors.comment = constructors.combinator = constructors.className = constructors.attribute = void 0; 6199 6200 5465 var _attribute = _interopRequireDefault$2(attribute$1); 6201 6202 5466 var _className = _interopRequireDefault$2(classNameExports); 6203 6204 5467 var _combinator = _interopRequireDefault$2(combinatorExports); 6205 6206 5468 var _comment = _interopRequireDefault$2(commentExports); 6207 6208 5469 var _id = _interopRequireDefault$2(idExports); 6209 6210 5470 var _nesting = _interopRequireDefault$2(nestingExports); 6211 6212 5471 var _pseudo = _interopRequireDefault$2(pseudoExports); 6213 6214 5472 var _root = _interopRequireDefault$2(rootExports); 6215 6216 5473 var _selector = _interopRequireDefault$2(selectorExports); 6217 6218 5474 var _string = _interopRequireDefault$2(stringExports); 6219 6220 5475 var _tag = _interopRequireDefault$2(tagExports); 6221 6222 5476 var _universal = _interopRequireDefault$2(universalExports); 6223 6224 5477 function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 6225 6226 5478 var attribute = function attribute(opts) { 6227 5479 return new _attribute["default"](opts); 6228 5480 }; 6229 6230 5481 constructors.attribute = attribute; 6231 6232 5482 var className = function className(opts) { 6233 5483 return new _className["default"](opts); 6234 5484 }; 6235 6236 5485 constructors.className = className; 6237 6238 5486 var combinator = function combinator(opts) { 6239 5487 return new _combinator["default"](opts); 6240 5488 }; 6241 6242 5489 constructors.combinator = combinator; 6243 6244 5490 var comment = function comment(opts) { 6245 5491 return new _comment["default"](opts); 6246 5492 }; 6247 6248 5493 constructors.comment = comment; 6249 6250 5494 var id = function id(opts) { 6251 5495 return new _id["default"](opts); 6252 5496 }; 6253 6254 5497 constructors.id = id; 6255 6256 5498 var nesting = function nesting(opts) { 6257 5499 return new _nesting["default"](opts); 6258 5500 }; 6259 6260 5501 constructors.nesting = nesting; 6261 6262 5502 var pseudo = function pseudo(opts) { 6263 5503 return new _pseudo["default"](opts); 6264 5504 }; 6265 6266 5505 constructors.pseudo = pseudo; 6267 6268 5506 var root = function root(opts) { 6269 5507 return new _root["default"](opts); 6270 5508 }; 6271 6272 5509 constructors.root = root; 6273 6274 5510 var selector = function selector(opts) { 6275 5511 return new _selector["default"](opts); 6276 5512 }; 6277 6278 5513 constructors.selector = selector; 6279 6280 5514 var string = function string(opts) { 6281 5515 return new _string["default"](opts); 6282 5516 }; 6283 6284 5517 constructors.string = string; 6285 6286 5518 var tag = function tag(opts) { 6287 5519 return new _tag["default"](opts); 6288 5520 }; 6289 6290 5521 constructors.tag = tag; 6291 6292 5522 var universal = function universal(opts) { 6293 5523 return new _universal["default"](opts); 6294 5524 }; 6295 6296 5525 constructors.universal = universal; 6297 5526 … … 6299 5528 6300 5529 guards.__esModule = true; 5530 guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0; 5531 guards.isContainer = isContainer; 5532 guards.isIdentifier = void 0; 5533 guards.isNamespace = isNamespace; 5534 guards.isNesting = void 0; 6301 5535 guards.isNode = isNode; 5536 guards.isPseudo = void 0; 5537 guards.isPseudoClass = isPseudoClass; 6302 5538 guards.isPseudoElement = isPseudoElement; 6303 guards.isPseudoClass = isPseudoClass; 6304 guards.isContainer = isContainer; 6305 guards.isNamespace = isNamespace; 6306 guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = guards.isPseudo = guards.isNesting = guards.isIdentifier = guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0; 6307 5539 guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0; 6308 5540 var _types = types; 6309 6310 5541 var _IS_TYPE; 6311 6312 5542 var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[_types.ATTRIBUTE] = true, _IS_TYPE[_types.CLASS] = true, _IS_TYPE[_types.COMBINATOR] = true, _IS_TYPE[_types.COMMENT] = true, _IS_TYPE[_types.ID] = true, _IS_TYPE[_types.NESTING] = true, _IS_TYPE[_types.PSEUDO] = true, _IS_TYPE[_types.ROOT] = true, _IS_TYPE[_types.SELECTOR] = true, _IS_TYPE[_types.STRING] = true, _IS_TYPE[_types.TAG] = true, _IS_TYPE[_types.UNIVERSAL] = true, _IS_TYPE); 6313 6314 5543 function isNode(node) { 6315 5544 return typeof node === "object" && IS_TYPE[node.type]; 6316 5545 } 6317 6318 5546 function isNodeType(type, node) { 6319 5547 return isNode(node) && node.type === type; 6320 5548 } 6321 6322 5549 var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE); 6323 5550 guards.isAttribute = isAttribute; … … 6344 5571 var isUniversal = isNodeType.bind(null, _types.UNIVERSAL); 6345 5572 guards.isUniversal = isUniversal; 6346 6347 5573 function isPseudoElement(node) { 6348 5574 return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line"); 6349 5575 } 6350 6351 5576 function isPseudoClass(node) { 6352 5577 return isPseudo(node) && !isPseudoElement(node); 6353 5578 } 6354 6355 5579 function isContainer(node) { 6356 5580 return !!(isNode(node) && node.walk); 6357 5581 } 6358 6359 5582 function isNamespace(node) { 6360 5583 return isAttribute(node) || isTag(node); … … 6364 5587 6365 5588 exports.__esModule = true; 6366 6367 5589 var _types = types; 6368 6369 5590 Object.keys(_types).forEach(function (key) { 6370 5591 if (key === "default" || key === "__esModule") return; … … 6372 5593 exports[key] = _types[key]; 6373 5594 }); 6374 6375 5595 var _constructors = constructors; 6376 6377 5596 Object.keys(_constructors).forEach(function (key) { 6378 5597 if (key === "default" || key === "__esModule") return; … … 6380 5599 exports[key] = _constructors[key]; 6381 5600 }); 6382 6383 5601 var _guards = guards; 6384 6385 5602 Object.keys(_guards).forEach(function (key) { 6386 5603 if (key === "default" || key === "__esModule") return; … … 6394 5611 exports.__esModule = true; 6395 5612 exports["default"] = void 0; 6396 6397 5613 var _processor = _interopRequireDefault(processorExports); 6398 6399 5614 var selectors$1 = _interopRequireWildcard(selectors); 6400 6401 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } 6402 6403 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 6404 5615 function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 5616 function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 6405 5617 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 6406 6407 5618 var parser = function parser(processor) { 6408 5619 return new _processor["default"](processor); 6409 5620 }; 6410 6411 5621 Object.assign(parser, selectors$1); 6412 5622 delete parser.__esModule; … … 6567 5777 explicit: context.explicit, 6568 5778 }; 6569 newNodes = node.map((childNode) => 6570 transform(childNode, childContext) 6571 ); 5779 newNodes = node.map((childNode) => { 5780 const newContext = { 5781 ...childContext, 5782 enforceNoSpacing: false, 5783 }; 5784 5785 const result = transform(childNode, newContext); 5786 5787 childContext.global = newContext.global; 5788 childContext.hasLocals = newContext.hasLocals; 5789 5790 return result; 5791 }); 6572 5792 6573 5793 node = node.clone(); … … 6638 5858 break; 6639 5859 } 5860 case "nesting": { 5861 if (node.value === "&") { 5862 context.hasLocals = true; 5863 } 5864 } 6640 5865 } 6641 5866 … … 6710 5935 } 6711 5936 6712 function isWordAFunctionArgument(wordNode, functionNode) { 6713 return functionNode 6714 ? functionNode.nodes.some( 6715 (functionNodeChild) => 6716 functionNodeChild.sourceIndex === wordNode.sourceIndex 6717 ) 6718 : false; 6719 } 5937 // `none` is special value, other is global values 5938 const specialKeywords = [ 5939 "none", 5940 "inherit", 5941 "initial", 5942 "revert", 5943 "revert-layer", 5944 "unset", 5945 ]; 6720 5946 6721 5947 function localizeDeclarationValues(localize, declaration, context) { … … 6723 5949 6724 5950 valueNodes.walk((node, index, nodes) => { 5951 if ( 5952 node.type === "function" && 5953 (node.value.toLowerCase() === "var" || node.value.toLowerCase() === "env") 5954 ) { 5955 return false; 5956 } 5957 5958 if ( 5959 node.type === "word" && 5960 specialKeywords.includes(node.value.toLowerCase()) 5961 ) { 5962 return; 5963 } 5964 6725 5965 const subContext = { 6726 5966 options: context.options, … … 6739 5979 6740 5980 if (isAnimation) { 6741 const validIdent = /^-?[_a-z][_a-z0-9-]*$/i; 5981 // letter 5982 // An uppercase letter or a lowercase letter. 5983 // 5984 // ident-start code point 5985 // A letter, a non-ASCII code point, or U+005F LOW LINE (_). 5986 // 5987 // ident code point 5988 // An ident-start code point, a digit, or U+002D HYPHEN-MINUS (-). 5989 5990 // We don't validate `hex digits`, because we don't need it, it is work of linters. 5991 const validIdent = 5992 /^-?([a-z\u0080-\uFFFF_]|(\\[^\r\n\f])|-(?![0-9]))((\\[^\r\n\f])|[a-z\u0080-\uFFFF_0-9-])*$/i; 6742 5993 6743 5994 /* … … 6746 5997 a keyword, it is given priority. Only when all the properties that can take a keyword are 6747 5998 exhausted can the animation name be set to the keyword. I.e. 6748 5999 6749 6000 animation: infinite infinite; 6750 6001 6751 6002 The animation will repeat an infinite number of times from the first argument, and will have an 6752 6003 animation name of infinite from the second. 6753 6004 */ 6754 6005 const animationKeywords = { 6006 // animation-direction 6007 $normal: 1, 6008 $reverse: 1, 6755 6009 $alternate: 1, 6756 6010 "$alternate-reverse": 1, 6011 // animation-fill-mode 6012 $forwards: 1, 6757 6013 $backwards: 1, 6758 6014 $both: 1, 6015 // animation-iteration-count 6016 $infinite: 1, 6017 // animation-play-state 6018 $paused: 1, 6019 $running: 1, 6020 // animation-timing-function 6759 6021 $ease: 1, 6760 6022 "$ease-in": 1, 6023 "$ease-out": 1, 6761 6024 "$ease-in-out": 1, 6762 "$ease-out": 1,6763 $forwards: 1,6764 $infinite: 1,6765 6025 $linear: 1, 6766 $none: Infinity, // No matter how many times you write none, it will never be an animation name6767 $normal: 1,6768 $paused: 1,6769 $reverse: 1,6770 $running: 1,6771 6026 "$step-end": 1, 6772 6027 "$step-start": 1, 6028 // Special 6029 $none: Infinity, // No matter how many times you write none, it will never be an animation name 6030 // Global values 6773 6031 $initial: Infinity, 6774 6032 $inherit: Infinity, 6775 6033 $unset: Infinity, 6034 $revert: Infinity, 6035 "$revert-layer": Infinity, 6776 6036 }; 6777 6037 let parsedAnimationKeywords = {}; 6778 let stepsFunctionNode = null;6779 6038 const valueNodes = valueParser(declaration.value).walk((node) => { 6780 / * If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. */6039 // If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. 6781 6040 if (node.type === "div") { 6782 6041 parsedAnimationKeywords = {}; 6042 6043 return; 6783 6044 } 6784 if (node.type === "function" && node.value.toLowerCase() === "steps") { 6785 stepsFunctionNode = node; 6045 // Do not handle nested functions 6046 else if (node.type === "function") { 6047 return false; 6786 6048 } 6787 const value = 6788 node.type === "word" && 6789 !isWordAFunctionArgument(node, stepsFunctionNode) 6790 ? node.value.toLowerCase() 6791 : null; 6049 // Ignore all except word 6050 else if (node.type !== "word") { 6051 return; 6052 } 6053 6054 const value = node.type === "word" ? node.value.toLowerCase() : null; 6792 6055 6793 6056 let shouldParseAnimationName = false; … … 6814 6077 localAliasMap: context.localAliasMap, 6815 6078 }; 6079 6816 6080 return localizeDeclNode(node, subContext); 6817 6081 }); … … 6888 6152 atRule.params = localMatch[0]; 6889 6153 globalKeyframes = false; 6890 } else if (!globalMode) { 6891 if (atRule.params && !localAliasMap.has(atRule.params)) { 6892 atRule.params = ":local(" + atRule.params + ")"; 6893 } 6154 } else if ( 6155 atRule.params && 6156 !globalMode && 6157 !localAliasMap.has(atRule.params) 6158 ) { 6159 atRule.params = ":local(" + atRule.params + ")"; 6894 6160 } 6895 6161 … … 6900 6166 global: globalKeyframes, 6901 6167 }); 6168 }); 6169 } else if (/scope$/i.test(atRule.name)) { 6170 if (atRule.params) { 6171 atRule.params = atRule.params 6172 .split("to") 6173 .map((item) => { 6174 const selector = item.trim().slice(1, -1).trim(); 6175 const context = localizeNode( 6176 selector, 6177 options.mode, 6178 localAliasMap 6179 ); 6180 6181 context.options = options; 6182 context.localAliasMap = localAliasMap; 6183 6184 if (pureMode && context.hasPureGlobals) { 6185 throw atRule.error( 6186 'Selector in at-rule"' + 6187 selector + 6188 '" is not pure ' + 6189 "(pure selectors must contain at least one local class or id)" 6190 ); 6191 } 6192 6193 return `(${context.selector})`; 6194 }) 6195 .join(" to "); 6196 } 6197 6198 atRule.nodes.forEach((declaration) => { 6199 if (declaration.type === "decl") { 6200 localizeDeclaration(declaration, { 6201 localAliasMap, 6202 options: options, 6203 global: globalMode, 6204 }); 6205 } 6902 6206 }); 6903 6207 } else if (atRule.nodes) { … … 6960 6264 const hasOwnProperty = Object.prototype.hasOwnProperty; 6961 6265 6962 function getSingleLocalNamesForComposes(root) { 6266 function isNestedRule(rule) { 6267 if (!rule.parent || rule.parent.type === "root") { 6268 return false; 6269 } 6270 6271 if (rule.parent.type === "rule") { 6272 return true; 6273 } 6274 6275 return isNestedRule(rule.parent); 6276 } 6277 6278 function getSingleLocalNamesForComposes(root, rule) { 6279 if (isNestedRule(rule)) { 6280 throw new Error(`composition is not allowed in nested rule \n\n${rule}`); 6281 } 6282 6963 6283 return root.nodes.map((node) => { 6964 6284 if (node.type !== "selector" || node.nodes.length !== 1) { … … 7047 6367 const exports = Object.create(null); 7048 6368 7049 function exportScopedName(name, rawName ) {6369 function exportScopedName(name, rawName, node) { 7050 6370 const scopedName = generateScopedName( 7051 6371 rawName ? rawName : name, 7052 6372 root.source.input.from, 7053 root.source.input.css 6373 root.source.input.css, 6374 node 7054 6375 ); 7055 6376 const exportEntry = generateExportEntry( … … 7057 6378 scopedName, 7058 6379 root.source.input.from, 7059 root.source.input.css 6380 root.source.input.css, 6381 node 7060 6382 ); 7061 6383 const { key, value } = exportEntry; … … 7073 6395 switch (node.type) { 7074 6396 case "selector": 7075 node.nodes = node.map( localizeNode);6397 node.nodes = node.map((item) => localizeNode(item)); 7076 6398 return node; 7077 6399 case "class": … … 7079 6401 value: exportScopedName( 7080 6402 node.value, 7081 node.raws && node.raws.value ? node.raws.value : null 6403 node.raws && node.raws.value ? node.raws.value : null, 6404 node 7082 6405 ), 7083 6406 }); … … 7086 6409 value: exportScopedName( 7087 6410 node.value, 7088 node.raws && node.raws.value ? node.raws.value : null 6411 node.raws && node.raws.value ? node.raws.value : null, 6412 node 7089 6413 ), 7090 6414 }); 6415 } 6416 case "attribute": { 6417 if (node.attribute === "class" && node.operator === "=") { 6418 return selectorParser.attribute({ 6419 attribute: node.attribute, 6420 operator: node.operator, 6421 quoteMark: "'", 6422 value: exportScopedName(node.value, null, null), 6423 }); 6424 } 7091 6425 } 7092 6426 } … … 7106 6440 7107 6441 const selector = localizeNode(node.first); 7108 // move the spaces that were around the ps uedo selector to the first6442 // move the spaces that were around the pseudo selector to the first 7109 6443 // non-container node 7110 6444 selector.first.spaces = node.spaces; … … 7128 6462 case "root": 7129 6463 case "selector": { 7130 node.each( traverseNode);6464 node.each((item) => traverseNode(item)); 7131 6465 break; 7132 6466 } … … 7156 6490 rule.selector = traverseNode(parsedSelector.clone()).toString(); 7157 6491 7158 rule.walkDecls(/composes|compose-with/i, (decl) => { 7159 const localNames = getSingleLocalNamesForComposes(parsedSelector); 7160 const classes = decl.value.split(/\s+/); 7161 7162 classes.forEach((className) => { 7163 const global = /^global\(([^)]+)\)$/.exec(className); 7164 7165 if (global) { 7166 localNames.forEach((exportedName) => { 7167 exports[exportedName].push(global[1]); 7168 }); 7169 } else if (hasOwnProperty.call(importedNames, className)) { 7170 localNames.forEach((exportedName) => { 7171 exports[exportedName].push(className); 7172 }); 7173 } else if (hasOwnProperty.call(exports, className)) { 7174 localNames.forEach((exportedName) => { 7175 exports[className].forEach((item) => { 7176 exports[exportedName].push(item); 6492 rule.walkDecls(/^(composes|compose-with)$/i, (decl) => { 6493 const localNames = getSingleLocalNamesForComposes( 6494 parsedSelector, 6495 decl.parent 6496 ); 6497 const multiple = decl.value.split(","); 6498 6499 multiple.forEach((value) => { 6500 const classes = value.trim().split(/\s+/); 6501 6502 classes.forEach((className) => { 6503 const global = /^global\(([^)]+)\)$/.exec(className); 6504 6505 if (global) { 6506 localNames.forEach((exportedName) => { 6507 exports[exportedName].push(global[1]); 7177 6508 }); 7178 }); 7179 } else { 7180 throw decl.error( 7181 `referenced class name "${className}" in ${decl.prop} not found` 7182 ); 7183 } 6509 } else if (hasOwnProperty.call(importedNames, className)) { 6510 localNames.forEach((exportedName) => { 6511 exports[exportedName].push(className); 6512 }); 6513 } else if (hasOwnProperty.call(exports, className)) { 6514 localNames.forEach((exportedName) => { 6515 exports[className].forEach((item) => { 6516 exports[exportedName].push(item); 6517 }); 6518 }); 6519 } else { 6520 throw decl.error( 6521 `referenced class name "${className}" in ${decl.prop} not found` 6522 ); 6523 } 6524 }); 7184 6525 }); 7185 6526 … … 7231 6572 7232 6573 atRule.params = exportScopedName(localMatch[1]); 6574 }); 6575 6576 root.walkAtRules(/scope$/i, (atRule) => { 6577 if (atRule.params) { 6578 atRule.params = atRule.params 6579 .split("to") 6580 .map((item) => { 6581 const selector = item.trim().slice(1, -1).trim(); 6582 6583 const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(selector); 6584 6585 if (!localMatch) { 6586 return `(${selector})`; 6587 } 6588 6589 let parsedSelector = selectorParser().astSync(selector); 6590 6591 return `(${traverseNode(parsedSelector).toString()})`; 6592 }) 6593 .join(" to "); 6594 } 7233 6595 }); 7234 6596
Note:
See TracChangeset
for help on using the changeset viewer.