@vanilla-extract/css
Advanced tools
Comparing version 1.15.4 to 1.15.5
@@ -10,2 +10,3 @@ 'use strict'; | ||
var fileScope_dist_vanillaExtractCssFileScope = require('../fileScope/dist/vanilla-extract-css-fileScope.browser.cjs.js'); | ||
var lruCache = require('lru-cache'); | ||
var _private = require('@vanilla-extract/private'); | ||
@@ -62,74 +63,58 @@ var cssesc = require('cssesc'); | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
var getLastSlashBeforeIndex = (path, index) => { | ||
var pathIndex = index - 1; | ||
while (pathIndex >= 0) { | ||
if (path[pathIndex] === '/') { | ||
return pathIndex; | ||
} | ||
pathIndex--; | ||
} | ||
return -1; | ||
}; | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
/** | ||
* Assumptions: | ||
* - The path is always normalized to use posix file separators (/) (see `addFileScope`) | ||
* - The path is always relative to the project root, i.e. there will never be a leading slash (see `addFileScope`) | ||
* - As long as `.css` is there, we have a valid `.css.*` file path, because otherwise there wouldn't | ||
* be a file scope to begin with | ||
* | ||
* The LRU cache we use can't cache undefined/null values, so we opt to return an empty string, | ||
* rather than using a custom Symbol or something similar. | ||
*/ | ||
var _getDebugFileName = path => { | ||
var file; | ||
var lastIndexOfDotCss = path.lastIndexOf('.css'); | ||
if (lastIndexOfDotCss === -1) { | ||
return ''; | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
var lastSlashIndex = getLastSlashBeforeIndex(path, lastIndexOfDotCss); | ||
file = path.slice(lastSlashIndex + 1, lastIndexOfDotCss); | ||
function _wrapRegExp() { | ||
_wrapRegExp = function (e, r) { | ||
return new BabelRegExp(e, void 0, r); | ||
}; | ||
var e = RegExp.prototype, | ||
r = new WeakMap(); | ||
function BabelRegExp(e, t, p) { | ||
var o = new RegExp(e, t); | ||
return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); | ||
// There are no slashes, therefore theres no directory to extract | ||
if (lastSlashIndex === -1) { | ||
return file; | ||
} | ||
function buildGroups(e, t) { | ||
var p = r.get(t); | ||
return Object.keys(p).reduce(function (r, t) { | ||
var o = p[t]; | ||
if ("number" == typeof o) r[t] = e[o];else { | ||
for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; | ||
r[t] = e[o[i]]; | ||
} | ||
return r; | ||
}, Object.create(null)); | ||
} | ||
return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { | ||
var t = e.exec.call(this, r); | ||
if (t) { | ||
t.groups = buildGroups(t, this); | ||
var p = t.indices; | ||
p && (p.groups = buildGroups(p, this)); | ||
var secondLastSlashIndex = getLastSlashBeforeIndex(path, lastSlashIndex - 1); | ||
// If secondLastSlashIndex is -1, it means that the path looks like `directory/file.css.ts`, | ||
// in which case dir will still be sliced starting at 0, which is what we want | ||
var dir = path.slice(secondLastSlashIndex + 1, lastSlashIndex); | ||
var debugFileName = file !== 'index' ? file : dir; | ||
return debugFileName; | ||
}; | ||
var memoizedGetDebugFileName = () => { | ||
var cache = new lruCache.LRUCache({ | ||
max: 500 | ||
}); | ||
return path => { | ||
var cachedResult = cache.get(path); | ||
if (cachedResult) { | ||
return cachedResult; | ||
} | ||
return t; | ||
}, BabelRegExp.prototype[Symbol.replace] = function (t, p) { | ||
if ("string" == typeof p) { | ||
var o = r.get(this); | ||
return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { | ||
var t = o[r]; | ||
return "$" + (Array.isArray(t) ? t.join("$") : t); | ||
})); | ||
} | ||
if ("function" == typeof p) { | ||
var i = this; | ||
return e[Symbol.replace].call(this, t, function () { | ||
var e = arguments; | ||
return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); | ||
}); | ||
} | ||
return e[Symbol.replace].call(this, t, p); | ||
}, _wrapRegExp.apply(this, arguments); | ||
} | ||
var result = _getDebugFileName(path); | ||
cache.set(path, result); | ||
return result; | ||
}; | ||
}; | ||
var getDebugFileName = memoizedGetDebugFileName(); | ||
@@ -146,12 +131,7 @@ function getDevPrefix(_ref) { | ||
} = fileScope_dist_vanillaExtractCssFileScope.getFileScope(); | ||
var matches = filePath.match( /*#__PURE__*/_wrapRegExp(/([^\/\\]*)?[\/\\]?([^\/\\]*)\.css\.(ts|js|tsx|jsx|cjs|mjs)$/, { | ||
dir: 1, | ||
file: 2 | ||
})); | ||
if (matches && matches.groups) { | ||
var { | ||
dir, | ||
file | ||
} = matches.groups; | ||
parts.unshift(file && file !== 'index' ? file : dir); | ||
var _debugFileName = getDebugFileName(filePath); | ||
// debugFileName could be an empty string | ||
if (_debugFileName) { | ||
parts.unshift(_debugFileName); | ||
} | ||
@@ -158,0 +138,0 @@ } |
@@ -6,2 +6,3 @@ import { injectStyles } from '../injectStyles/dist/vanilla-extract-css-injectStyles.browser.esm.js'; | ||
import { getAndIncrementRefCounter, getFileScope, hasFileScope } from '../fileScope/dist/vanilla-extract-css-fileScope.browser.esm.js'; | ||
import { LRUCache } from 'lru-cache'; | ||
import { walkObject, get } from '@vanilla-extract/private'; | ||
@@ -50,74 +51,58 @@ import cssesc from 'cssesc'; | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
var getLastSlashBeforeIndex = (path, index) => { | ||
var pathIndex = index - 1; | ||
while (pathIndex >= 0) { | ||
if (path[pathIndex] === '/') { | ||
return pathIndex; | ||
} | ||
pathIndex--; | ||
} | ||
return -1; | ||
}; | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
/** | ||
* Assumptions: | ||
* - The path is always normalized to use posix file separators (/) (see `addFileScope`) | ||
* - The path is always relative to the project root, i.e. there will never be a leading slash (see `addFileScope`) | ||
* - As long as `.css` is there, we have a valid `.css.*` file path, because otherwise there wouldn't | ||
* be a file scope to begin with | ||
* | ||
* The LRU cache we use can't cache undefined/null values, so we opt to return an empty string, | ||
* rather than using a custom Symbol or something similar. | ||
*/ | ||
var _getDebugFileName = path => { | ||
var file; | ||
var lastIndexOfDotCss = path.lastIndexOf('.css'); | ||
if (lastIndexOfDotCss === -1) { | ||
return ''; | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
var lastSlashIndex = getLastSlashBeforeIndex(path, lastIndexOfDotCss); | ||
file = path.slice(lastSlashIndex + 1, lastIndexOfDotCss); | ||
function _wrapRegExp() { | ||
_wrapRegExp = function (e, r) { | ||
return new BabelRegExp(e, void 0, r); | ||
}; | ||
var e = RegExp.prototype, | ||
r = new WeakMap(); | ||
function BabelRegExp(e, t, p) { | ||
var o = new RegExp(e, t); | ||
return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); | ||
// There are no slashes, therefore theres no directory to extract | ||
if (lastSlashIndex === -1) { | ||
return file; | ||
} | ||
function buildGroups(e, t) { | ||
var p = r.get(t); | ||
return Object.keys(p).reduce(function (r, t) { | ||
var o = p[t]; | ||
if ("number" == typeof o) r[t] = e[o];else { | ||
for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; | ||
r[t] = e[o[i]]; | ||
} | ||
return r; | ||
}, Object.create(null)); | ||
} | ||
return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { | ||
var t = e.exec.call(this, r); | ||
if (t) { | ||
t.groups = buildGroups(t, this); | ||
var p = t.indices; | ||
p && (p.groups = buildGroups(p, this)); | ||
var secondLastSlashIndex = getLastSlashBeforeIndex(path, lastSlashIndex - 1); | ||
// If secondLastSlashIndex is -1, it means that the path looks like `directory/file.css.ts`, | ||
// in which case dir will still be sliced starting at 0, which is what we want | ||
var dir = path.slice(secondLastSlashIndex + 1, lastSlashIndex); | ||
var debugFileName = file !== 'index' ? file : dir; | ||
return debugFileName; | ||
}; | ||
var memoizedGetDebugFileName = () => { | ||
var cache = new LRUCache({ | ||
max: 500 | ||
}); | ||
return path => { | ||
var cachedResult = cache.get(path); | ||
if (cachedResult) { | ||
return cachedResult; | ||
} | ||
return t; | ||
}, BabelRegExp.prototype[Symbol.replace] = function (t, p) { | ||
if ("string" == typeof p) { | ||
var o = r.get(this); | ||
return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { | ||
var t = o[r]; | ||
return "$" + (Array.isArray(t) ? t.join("$") : t); | ||
})); | ||
} | ||
if ("function" == typeof p) { | ||
var i = this; | ||
return e[Symbol.replace].call(this, t, function () { | ||
var e = arguments; | ||
return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); | ||
}); | ||
} | ||
return e[Symbol.replace].call(this, t, p); | ||
}, _wrapRegExp.apply(this, arguments); | ||
} | ||
var result = _getDebugFileName(path); | ||
cache.set(path, result); | ||
return result; | ||
}; | ||
}; | ||
var getDebugFileName = memoizedGetDebugFileName(); | ||
@@ -134,12 +119,7 @@ function getDevPrefix(_ref) { | ||
} = getFileScope(); | ||
var matches = filePath.match( /*#__PURE__*/_wrapRegExp(/([^\/\\]*)?[\/\\]?([^\/\\]*)\.css\.(ts|js|tsx|jsx|cjs|mjs)$/, { | ||
dir: 1, | ||
file: 2 | ||
})); | ||
if (matches && matches.groups) { | ||
var { | ||
dir, | ||
file | ||
} = matches.groups; | ||
parts.unshift(file && file !== 'index' ? file : dir); | ||
var _debugFileName = getDebugFileName(filePath); | ||
// debugFileName could be an empty string | ||
if (_debugFileName) { | ||
parts.unshift(_debugFileName); | ||
} | ||
@@ -146,0 +126,0 @@ } |
@@ -10,2 +10,3 @@ 'use strict'; | ||
var fileScope_dist_vanillaExtractCssFileScope = require('../fileScope/dist/vanilla-extract-css-fileScope.cjs.dev.js'); | ||
var lruCache = require('lru-cache'); | ||
var _private = require('@vanilla-extract/private'); | ||
@@ -62,74 +63,58 @@ var cssesc = require('cssesc'); | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
var getLastSlashBeforeIndex = (path, index) => { | ||
var pathIndex = index - 1; | ||
while (pathIndex >= 0) { | ||
if (path[pathIndex] === '/') { | ||
return pathIndex; | ||
} | ||
pathIndex--; | ||
} | ||
return -1; | ||
}; | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
/** | ||
* Assumptions: | ||
* - The path is always normalized to use posix file separators (/) (see `addFileScope`) | ||
* - The path is always relative to the project root, i.e. there will never be a leading slash (see `addFileScope`) | ||
* - As long as `.css` is there, we have a valid `.css.*` file path, because otherwise there wouldn't | ||
* be a file scope to begin with | ||
* | ||
* The LRU cache we use can't cache undefined/null values, so we opt to return an empty string, | ||
* rather than using a custom Symbol or something similar. | ||
*/ | ||
var _getDebugFileName = path => { | ||
var file; | ||
var lastIndexOfDotCss = path.lastIndexOf('.css'); | ||
if (lastIndexOfDotCss === -1) { | ||
return ''; | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
var lastSlashIndex = getLastSlashBeforeIndex(path, lastIndexOfDotCss); | ||
file = path.slice(lastSlashIndex + 1, lastIndexOfDotCss); | ||
function _wrapRegExp() { | ||
_wrapRegExp = function (e, r) { | ||
return new BabelRegExp(e, void 0, r); | ||
}; | ||
var e = RegExp.prototype, | ||
r = new WeakMap(); | ||
function BabelRegExp(e, t, p) { | ||
var o = new RegExp(e, t); | ||
return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); | ||
// There are no slashes, therefore theres no directory to extract | ||
if (lastSlashIndex === -1) { | ||
return file; | ||
} | ||
function buildGroups(e, t) { | ||
var p = r.get(t); | ||
return Object.keys(p).reduce(function (r, t) { | ||
var o = p[t]; | ||
if ("number" == typeof o) r[t] = e[o];else { | ||
for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; | ||
r[t] = e[o[i]]; | ||
} | ||
return r; | ||
}, Object.create(null)); | ||
} | ||
return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { | ||
var t = e.exec.call(this, r); | ||
if (t) { | ||
t.groups = buildGroups(t, this); | ||
var p = t.indices; | ||
p && (p.groups = buildGroups(p, this)); | ||
var secondLastSlashIndex = getLastSlashBeforeIndex(path, lastSlashIndex - 1); | ||
// If secondLastSlashIndex is -1, it means that the path looks like `directory/file.css.ts`, | ||
// in which case dir will still be sliced starting at 0, which is what we want | ||
var dir = path.slice(secondLastSlashIndex + 1, lastSlashIndex); | ||
var debugFileName = file !== 'index' ? file : dir; | ||
return debugFileName; | ||
}; | ||
var memoizedGetDebugFileName = () => { | ||
var cache = new lruCache.LRUCache({ | ||
max: 500 | ||
}); | ||
return path => { | ||
var cachedResult = cache.get(path); | ||
if (cachedResult) { | ||
return cachedResult; | ||
} | ||
return t; | ||
}, BabelRegExp.prototype[Symbol.replace] = function (t, p) { | ||
if ("string" == typeof p) { | ||
var o = r.get(this); | ||
return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { | ||
var t = o[r]; | ||
return "$" + (Array.isArray(t) ? t.join("$") : t); | ||
})); | ||
} | ||
if ("function" == typeof p) { | ||
var i = this; | ||
return e[Symbol.replace].call(this, t, function () { | ||
var e = arguments; | ||
return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); | ||
}); | ||
} | ||
return e[Symbol.replace].call(this, t, p); | ||
}, _wrapRegExp.apply(this, arguments); | ||
} | ||
var result = _getDebugFileName(path); | ||
cache.set(path, result); | ||
return result; | ||
}; | ||
}; | ||
var getDebugFileName = memoizedGetDebugFileName(); | ||
@@ -146,12 +131,7 @@ function getDevPrefix(_ref) { | ||
} = fileScope_dist_vanillaExtractCssFileScope.getFileScope(); | ||
var matches = filePath.match( /*#__PURE__*/_wrapRegExp(/([^\/\\]*)?[\/\\]?([^\/\\]*)\.css\.(ts|js|tsx|jsx|cjs|mjs)$/, { | ||
dir: 1, | ||
file: 2 | ||
})); | ||
if (matches && matches.groups) { | ||
var { | ||
dir, | ||
file | ||
} = matches.groups; | ||
parts.unshift(file && file !== 'index' ? file : dir); | ||
var _debugFileName = getDebugFileName(filePath); | ||
// debugFileName could be an empty string | ||
if (_debugFileName) { | ||
parts.unshift(_debugFileName); | ||
} | ||
@@ -158,0 +138,0 @@ } |
@@ -10,2 +10,3 @@ 'use strict'; | ||
var fileScope_dist_vanillaExtractCssFileScope = require('../fileScope/dist/vanilla-extract-css-fileScope.cjs.prod.js'); | ||
var lruCache = require('lru-cache'); | ||
var _private = require('@vanilla-extract/private'); | ||
@@ -62,74 +63,58 @@ var cssesc = require('cssesc'); | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
var getLastSlashBeforeIndex = (path, index) => { | ||
var pathIndex = index - 1; | ||
while (pathIndex >= 0) { | ||
if (path[pathIndex] === '/') { | ||
return pathIndex; | ||
} | ||
pathIndex--; | ||
} | ||
return -1; | ||
}; | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
/** | ||
* Assumptions: | ||
* - The path is always normalized to use posix file separators (/) (see `addFileScope`) | ||
* - The path is always relative to the project root, i.e. there will never be a leading slash (see `addFileScope`) | ||
* - As long as `.css` is there, we have a valid `.css.*` file path, because otherwise there wouldn't | ||
* be a file scope to begin with | ||
* | ||
* The LRU cache we use can't cache undefined/null values, so we opt to return an empty string, | ||
* rather than using a custom Symbol or something similar. | ||
*/ | ||
var _getDebugFileName = path => { | ||
var file; | ||
var lastIndexOfDotCss = path.lastIndexOf('.css'); | ||
if (lastIndexOfDotCss === -1) { | ||
return ''; | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
var lastSlashIndex = getLastSlashBeforeIndex(path, lastIndexOfDotCss); | ||
file = path.slice(lastSlashIndex + 1, lastIndexOfDotCss); | ||
function _wrapRegExp() { | ||
_wrapRegExp = function (e, r) { | ||
return new BabelRegExp(e, void 0, r); | ||
}; | ||
var e = RegExp.prototype, | ||
r = new WeakMap(); | ||
function BabelRegExp(e, t, p) { | ||
var o = new RegExp(e, t); | ||
return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); | ||
// There are no slashes, therefore theres no directory to extract | ||
if (lastSlashIndex === -1) { | ||
return file; | ||
} | ||
function buildGroups(e, t) { | ||
var p = r.get(t); | ||
return Object.keys(p).reduce(function (r, t) { | ||
var o = p[t]; | ||
if ("number" == typeof o) r[t] = e[o];else { | ||
for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; | ||
r[t] = e[o[i]]; | ||
} | ||
return r; | ||
}, Object.create(null)); | ||
} | ||
return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { | ||
var t = e.exec.call(this, r); | ||
if (t) { | ||
t.groups = buildGroups(t, this); | ||
var p = t.indices; | ||
p && (p.groups = buildGroups(p, this)); | ||
var secondLastSlashIndex = getLastSlashBeforeIndex(path, lastSlashIndex - 1); | ||
// If secondLastSlashIndex is -1, it means that the path looks like `directory/file.css.ts`, | ||
// in which case dir will still be sliced starting at 0, which is what we want | ||
var dir = path.slice(secondLastSlashIndex + 1, lastSlashIndex); | ||
var debugFileName = file !== 'index' ? file : dir; | ||
return debugFileName; | ||
}; | ||
var memoizedGetDebugFileName = () => { | ||
var cache = new lruCache.LRUCache({ | ||
max: 500 | ||
}); | ||
return path => { | ||
var cachedResult = cache.get(path); | ||
if (cachedResult) { | ||
return cachedResult; | ||
} | ||
return t; | ||
}, BabelRegExp.prototype[Symbol.replace] = function (t, p) { | ||
if ("string" == typeof p) { | ||
var o = r.get(this); | ||
return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { | ||
var t = o[r]; | ||
return "$" + (Array.isArray(t) ? t.join("$") : t); | ||
})); | ||
} | ||
if ("function" == typeof p) { | ||
var i = this; | ||
return e[Symbol.replace].call(this, t, function () { | ||
var e = arguments; | ||
return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); | ||
}); | ||
} | ||
return e[Symbol.replace].call(this, t, p); | ||
}, _wrapRegExp.apply(this, arguments); | ||
} | ||
var result = _getDebugFileName(path); | ||
cache.set(path, result); | ||
return result; | ||
}; | ||
}; | ||
var getDebugFileName = memoizedGetDebugFileName(); | ||
@@ -146,12 +131,7 @@ function getDevPrefix(_ref) { | ||
} = fileScope_dist_vanillaExtractCssFileScope.getFileScope(); | ||
var matches = filePath.match( /*#__PURE__*/_wrapRegExp(/([^\/\\]*)?[\/\\]?([^\/\\]*)\.css\.(ts|js|tsx|jsx|cjs|mjs)$/, { | ||
dir: 1, | ||
file: 2 | ||
})); | ||
if (matches && matches.groups) { | ||
var { | ||
dir, | ||
file | ||
} = matches.groups; | ||
parts.unshift(file && file !== 'index' ? file : dir); | ||
var _debugFileName = getDebugFileName(filePath); | ||
// debugFileName could be an empty string | ||
if (_debugFileName) { | ||
parts.unshift(_debugFileName); | ||
} | ||
@@ -158,0 +138,0 @@ } |
@@ -6,2 +6,3 @@ import { injectStyles } from '../injectStyles/dist/vanilla-extract-css-injectStyles.esm.js'; | ||
import { getAndIncrementRefCounter, getFileScope, hasFileScope } from '../fileScope/dist/vanilla-extract-css-fileScope.esm.js'; | ||
import { LRUCache } from 'lru-cache'; | ||
import { walkObject, get } from '@vanilla-extract/private'; | ||
@@ -50,74 +51,58 @@ import cssesc from 'cssesc'; | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
var getLastSlashBeforeIndex = (path, index) => { | ||
var pathIndex = index - 1; | ||
while (pathIndex >= 0) { | ||
if (path[pathIndex] === '/') { | ||
return pathIndex; | ||
} | ||
pathIndex--; | ||
} | ||
return -1; | ||
}; | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
/** | ||
* Assumptions: | ||
* - The path is always normalized to use posix file separators (/) (see `addFileScope`) | ||
* - The path is always relative to the project root, i.e. there will never be a leading slash (see `addFileScope`) | ||
* - As long as `.css` is there, we have a valid `.css.*` file path, because otherwise there wouldn't | ||
* be a file scope to begin with | ||
* | ||
* The LRU cache we use can't cache undefined/null values, so we opt to return an empty string, | ||
* rather than using a custom Symbol or something similar. | ||
*/ | ||
var _getDebugFileName = path => { | ||
var file; | ||
var lastIndexOfDotCss = path.lastIndexOf('.css'); | ||
if (lastIndexOfDotCss === -1) { | ||
return ''; | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
var lastSlashIndex = getLastSlashBeforeIndex(path, lastIndexOfDotCss); | ||
file = path.slice(lastSlashIndex + 1, lastIndexOfDotCss); | ||
function _wrapRegExp() { | ||
_wrapRegExp = function (e, r) { | ||
return new BabelRegExp(e, void 0, r); | ||
}; | ||
var e = RegExp.prototype, | ||
r = new WeakMap(); | ||
function BabelRegExp(e, t, p) { | ||
var o = new RegExp(e, t); | ||
return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); | ||
// There are no slashes, therefore theres no directory to extract | ||
if (lastSlashIndex === -1) { | ||
return file; | ||
} | ||
function buildGroups(e, t) { | ||
var p = r.get(t); | ||
return Object.keys(p).reduce(function (r, t) { | ||
var o = p[t]; | ||
if ("number" == typeof o) r[t] = e[o];else { | ||
for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; | ||
r[t] = e[o[i]]; | ||
} | ||
return r; | ||
}, Object.create(null)); | ||
} | ||
return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { | ||
var t = e.exec.call(this, r); | ||
if (t) { | ||
t.groups = buildGroups(t, this); | ||
var p = t.indices; | ||
p && (p.groups = buildGroups(p, this)); | ||
var secondLastSlashIndex = getLastSlashBeforeIndex(path, lastSlashIndex - 1); | ||
// If secondLastSlashIndex is -1, it means that the path looks like `directory/file.css.ts`, | ||
// in which case dir will still be sliced starting at 0, which is what we want | ||
var dir = path.slice(secondLastSlashIndex + 1, lastSlashIndex); | ||
var debugFileName = file !== 'index' ? file : dir; | ||
return debugFileName; | ||
}; | ||
var memoizedGetDebugFileName = () => { | ||
var cache = new LRUCache({ | ||
max: 500 | ||
}); | ||
return path => { | ||
var cachedResult = cache.get(path); | ||
if (cachedResult) { | ||
return cachedResult; | ||
} | ||
return t; | ||
}, BabelRegExp.prototype[Symbol.replace] = function (t, p) { | ||
if ("string" == typeof p) { | ||
var o = r.get(this); | ||
return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { | ||
var t = o[r]; | ||
return "$" + (Array.isArray(t) ? t.join("$") : t); | ||
})); | ||
} | ||
if ("function" == typeof p) { | ||
var i = this; | ||
return e[Symbol.replace].call(this, t, function () { | ||
var e = arguments; | ||
return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); | ||
}); | ||
} | ||
return e[Symbol.replace].call(this, t, p); | ||
}, _wrapRegExp.apply(this, arguments); | ||
} | ||
var result = _getDebugFileName(path); | ||
cache.set(path, result); | ||
return result; | ||
}; | ||
}; | ||
var getDebugFileName = memoizedGetDebugFileName(); | ||
@@ -134,12 +119,7 @@ function getDevPrefix(_ref) { | ||
} = getFileScope(); | ||
var matches = filePath.match( /*#__PURE__*/_wrapRegExp(/([^\/\\]*)?[\/\\]?([^\/\\]*)\.css\.(ts|js|tsx|jsx|cjs|mjs)$/, { | ||
dir: 1, | ||
file: 2 | ||
})); | ||
if (matches && matches.groups) { | ||
var { | ||
dir, | ||
file | ||
} = matches.groups; | ||
parts.unshift(file && file !== 'index' ? file : dir); | ||
var _debugFileName = getDebugFileName(filePath); | ||
// debugFileName could be an empty string | ||
if (_debugFileName) { | ||
parts.unshift(_debugFileName); | ||
} | ||
@@ -146,0 +126,0 @@ } |
{ | ||
"name": "@vanilla-extract/css", | ||
"version": "1.15.4", | ||
"version": "1.15.5", | ||
"description": "Zero-runtime Stylesheets-in-TypeScript", | ||
@@ -126,2 +126,3 @@ "sideEffects": true, | ||
"deepmerge": "^4.2.2", | ||
"lru-cache": "^10.4.3", | ||
"media-query-parser": "^2.0.2", | ||
@@ -128,0 +129,0 @@ "modern-ahocorasick": "^1.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
328565
12
8593
+ Addedlru-cache@^10.4.3
+ Addedlru-cache@10.4.3(transitive)