tailwindcss
Advanced tools
Comparing version 3.3.5 to 3.3.6
@@ -195,2 +195,6 @@ // @ts-check | ||
getContext ({ createContext , cliConfigPath , root , result , content }) { | ||
_sharedState.env.DEBUG && console.time("Searching for config"); | ||
var _findAtConfigPath1; | ||
let configPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : cliConfigPath; | ||
_sharedState.env.DEBUG && console.timeEnd("Searching for config"); | ||
if (this.context) { | ||
@@ -200,6 +204,2 @@ this.context.changedContent = this.changedContent.splice(0); | ||
} | ||
_sharedState.env.DEBUG && console.time("Searching for config"); | ||
var _findAtConfigPath1; | ||
let configPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : cliConfigPath; | ||
_sharedState.env.DEBUG && console.timeEnd("Searching for config"); | ||
_sharedState.env.DEBUG && console.time("Loading config"); | ||
@@ -206,0 +206,0 @@ let config = this.loadConfig(configPath, content); |
@@ -88,3 +88,8 @@ "use strict"; | ||
// Arbitrary values | ||
/-(?:\w+-)*\[[^\s:]+\]/, | ||
_regex.any([ | ||
/-(?:\w+-)*\['[^\s]+'\]/, | ||
/-(?:\w+-)*\["[^\s]+"\]/, | ||
/-(?:\w+-)*\[`[^\s]+`\]/, | ||
/-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s:\[\]]+\]/ | ||
]), | ||
// Not immediately followed by an `{[(` | ||
@@ -97,3 +102,8 @@ /(?![{([]])/, | ||
// Arbitrary values | ||
/-(?:\w+-)*\[[^\s]+\]/, | ||
_regex.any([ | ||
/-(?:\w+-)*\['[^\s]+'\]/, | ||
/-(?:\w+-)*\["[^\s]+"\]/, | ||
/-(?:\w+-)*\[`[^\s]+`\]/, | ||
/-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s\[\]]+\]/ | ||
]), | ||
// Not immediately followed by an `{[(` | ||
@@ -100,0 +110,0 @@ /(?![{([]])/, |
@@ -263,2 +263,5 @@ "use strict"; | ||
} | ||
var _root_source_end; | ||
// TODO: Why is the root node having no source location for `end` possible? | ||
root.source.end = (_root_source_end = root.source.end) !== null && _root_source_end !== void 0 ? _root_source_end : root.source.start; | ||
// If we've got a utility layer and no utilities are generated there's likely something wrong | ||
@@ -265,0 +268,0 @@ const hasUtilityVariants = variantNodes.some((node)=>{ |
@@ -816,2 +816,6 @@ "use strict"; | ||
} | ||
// If all rules have been eliminated we can skip this candidate entirely | ||
if (container.nodes.length === 0) { | ||
return null; | ||
} | ||
match[1] = container.nodes[0]; | ||
@@ -818,0 +822,0 @@ return match; |
@@ -5,5 +5,13 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "loadConfig", { | ||
enumerable: true, | ||
get: function() { | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
useCustomJiti: function() { | ||
return useCustomJiti; | ||
}, | ||
loadConfig: function() { | ||
return loadConfig; | ||
@@ -20,2 +28,5 @@ } | ||
let jiti = null; | ||
function useCustomJiti(_jiti) { | ||
jiti = _jiti; | ||
} | ||
function lazyJiti() { | ||
@@ -22,0 +33,0 @@ return jiti !== null && jiti !== void 0 ? jiti : jiti = (0, _jiti.default)(__filename, { |
@@ -194,2 +194,6 @@ "use strict"; | ||
getContext ({ createContext , cliConfigPath , root , result , content }) { | ||
_sharedState.env.DEBUG && console.time("Searching for config"); | ||
var _findAtConfigPath1; | ||
let configPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : cliConfigPath; | ||
_sharedState.env.DEBUG && console.timeEnd("Searching for config"); | ||
if (this.context) { | ||
@@ -199,6 +203,2 @@ this.context.changedContent = this.changedContent.splice(0); | ||
} | ||
_sharedState.env.DEBUG && console.time("Searching for config"); | ||
var _findAtConfigPath1; | ||
let configPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : cliConfigPath; | ||
_sharedState.env.DEBUG && console.timeEnd("Searching for config"); | ||
_sharedState.env.DEBUG && console.time("Loading config"); | ||
@@ -205,0 +205,0 @@ let config = this.loadConfig(configPath, content); |
@@ -1,2 +0,7 @@ | ||
"use strict"; | ||
/** | ||
* @param {import('postcss').Container[]} nodes | ||
* @param {any} source | ||
* @param {any} raws | ||
* @returns {import('postcss').Container[]} | ||
*/ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -13,15 +18,3 @@ value: true | ||
return nodes.map((node)=>{ | ||
var _node_raws_tailwind; | ||
let cloned = node.clone(); | ||
// We always want override the source map | ||
// except when explicitly told not to | ||
let shouldOverwriteSource = ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.preserveSource) !== true || !cloned.source; | ||
if (source !== undefined && shouldOverwriteSource) { | ||
cloned.source = source; | ||
if ("walk" in cloned) { | ||
cloned.walk((child)=>{ | ||
child.source = source; | ||
}); | ||
} | ||
} | ||
if (raws !== undefined) { | ||
@@ -33,4 +26,31 @@ cloned.raws.tailwind = { | ||
} | ||
if (source !== undefined) { | ||
traverse(cloned, (node)=>{ | ||
var _node_raws_tailwind; | ||
// Do not traverse nodes that have opted | ||
// to preserve their original source | ||
let shouldPreserveSource = ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.preserveSource) === true && node.source; | ||
if (shouldPreserveSource) { | ||
return false; | ||
} | ||
// Otherwise we can safely replace the source | ||
// And continue traversing | ||
node.source = source; | ||
}); | ||
} | ||
return cloned; | ||
}); | ||
} | ||
/** | ||
* Traverse a tree of nodes and don't traverse children if the callback | ||
* returns false. Ideally we'd use Container#walk instead of this | ||
* function but it stops traversing siblings too. | ||
* | ||
* @param {import('postcss').Container} node | ||
* @param {(node: import('postcss').Container) => boolean} onNode | ||
*/ function traverse(node, onNode) { | ||
if (onNode(node) !== false) { | ||
var _node_each; | ||
(_node_each = node.each) === null || _node_each === void 0 ? void 0 : _node_each.call(node, (child)=>traverse(child, onNode)); | ||
} | ||
} |
@@ -117,3 +117,3 @@ "use strict"; | ||
* Add spaces around operators inside math functions | ||
* like calc() that do not follow an operator or '('. | ||
* like calc() that do not follow an operator, '(', or `,`. | ||
* | ||
@@ -200,3 +200,4 @@ * @param {string} value | ||
"*", | ||
"/" | ||
"/", | ||
"," | ||
].includes(lastChar())) { | ||
@@ -203,0 +204,0 @@ result += ` ${char} `; |
@@ -95,2 +95,15 @@ "use strict"; | ||
let slashIdx = modifier.lastIndexOf("/"); | ||
// If the `/` is inside an arbitrary, we want to find the previous one if any | ||
// This logic probably isn't perfect but it should work for most cases | ||
let arbitraryStartIdx = modifier.lastIndexOf("[", slashIdx); | ||
let arbitraryEndIdx = modifier.indexOf("]", slashIdx); | ||
let isNextToArbitrary = modifier[slashIdx - 1] === "]" || modifier[slashIdx + 1] === "["; | ||
// Backtrack to the previous `/` if the one we found was inside an arbitrary | ||
if (!isNextToArbitrary) { | ||
if (arbitraryStartIdx !== -1 && arbitraryEndIdx !== -1) { | ||
if (arbitraryStartIdx < slashIdx && slashIdx < arbitraryEndIdx) { | ||
slashIdx = modifier.lastIndexOf("/", arbitraryStartIdx); | ||
} | ||
} | ||
} | ||
if (slashIdx === -1 || slashIdx === modifier.length - 1) { | ||
@@ -97,0 +110,0 @@ return [ |
{ | ||
"name": "tailwindcss", | ||
"version": "3.3.5", | ||
"version": "3.3.6", | ||
"description": "A utility-first CSS framework for rapidly building custom user interfaces.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,3 +0,12 @@ | ||
import type { Config, ResolvableTo } from './types/config' | ||
import { Config, ResolvableTo, ThemeConfig } from './types/config' | ||
import { DefaultTheme } from './types/generated/default-theme' | ||
import { DefaultColors } from './types/generated/colors' | ||
type ResolvedConfig<T extends Config> = Omit<T, 'theme'> & { | ||
theme: MergeThemes< | ||
UnwrapResolvables<Omit<T['theme'], 'extend'>>, | ||
T['theme'] extends { extend: infer TExtend } ? UnwrapResolvables<TExtend> : {} | ||
> | ||
} | ||
type UnwrapResolvables<T> = { | ||
@@ -7,4 +16,14 @@ [K in keyof T]: T[K] extends ResolvableTo<infer R> ? R : T[K] | ||
type ResolvedConfig<T extends Config> = Omit<T, 'theme'> & { | ||
theme: UnwrapResolvables<T['theme']> | ||
type ThemeConfigResolved = UnwrapResolvables<ThemeConfig> | ||
type DefaultThemeFull = DefaultTheme & { colors: DefaultColors } | ||
type MergeThemes<Overrides extends object, Extensions extends object> = { | ||
[K in keyof ThemeConfigResolved | keyof Overrides]: (K extends keyof Overrides | ||
? Overrides[K] | ||
: K extends keyof DefaultThemeFull | ||
? DefaultThemeFull[K] | ||
: K extends keyof ThemeConfigResolved | ||
? ThemeConfigResolved[K] | ||
: never) & | ||
(K extends keyof Extensions ? Extensions[K] : {}) | ||
} | ||
@@ -11,0 +30,0 @@ |
@@ -94,5 +94,4 @@ import prettier from 'prettier' | ||
` | ||
import { Config } from '../../types' | ||
type CSSDeclarationList = Record<string, string> | ||
export type DefaultTheme = Config['theme'] & { ${defaultThemeTypes} } | ||
export type DefaultTheme = { ${defaultThemeTypes} } | ||
`, | ||
@@ -99,0 +98,0 @@ { |
@@ -214,2 +214,6 @@ // @ts-check | ||
getContext({ createContext, cliConfigPath, root, result, content }) { | ||
env.DEBUG && console.time('Searching for config') | ||
let configPath = findAtConfigPath(root, result) ?? cliConfigPath | ||
env.DEBUG && console.timeEnd('Searching for config') | ||
if (this.context) { | ||
@@ -221,6 +225,2 @@ this.context.changedContent = this.changedContent.splice(0) | ||
env.DEBUG && console.time('Searching for config') | ||
let configPath = findAtConfigPath(root, result) ?? cliConfigPath | ||
env.DEBUG && console.timeEnd('Searching for config') | ||
env.DEBUG && console.time('Loading config') | ||
@@ -227,0 +227,0 @@ let config = this.loadConfig(configPath, content) |
@@ -22,6 +22,3 @@ import colors from 'picocolors' | ||
], | ||
experimental: [ | ||
'optimizeUniversalDefaults', | ||
'generalizedModifiers', | ||
], | ||
experimental: ['optimizeUniversalDefaults', 'generalizedModifiers'], | ||
} | ||
@@ -28,0 +25,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { flagEnabled } from '../featureFlags' | ||
import * as regex from './regex' | ||
@@ -51,3 +50,8 @@ | ||
// Arbitrary values | ||
/-(?:\w+-)*\[[^\s:]+\]/, | ||
regex.any([ | ||
/-(?:\w+-)*\['[^\s]+'\]/, | ||
/-(?:\w+-)*\["[^\s]+"\]/, | ||
/-(?:\w+-)*\[`[^\s]+`\]/, | ||
/-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s:\[\]]+\]/, | ||
]), | ||
@@ -63,3 +67,8 @@ // Not immediately followed by an `{[(` | ||
// Arbitrary values | ||
/-(?:\w+-)*\[[^\s]+\]/, | ||
regex.any([ | ||
/-(?:\w+-)*\['[^\s]+'\]/, | ||
/-(?:\w+-)*\["[^\s]+"\]/, | ||
/-(?:\w+-)*\[`[^\s]+`\]/, | ||
/-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s\[\]]+\]/, | ||
]), | ||
@@ -66,0 +75,0 @@ // Not immediately followed by an `{[(` |
@@ -268,2 +268,5 @@ import fs from 'fs' | ||
// TODO: Why is the root node having no source location for `end` possible? | ||
root.source.end = root.source.end ?? root.source.start | ||
// If we've got a utility layer and no utilities are generated there's likely something wrong | ||
@@ -270,0 +273,0 @@ const hasUtilityVariants = variantNodes.some( |
@@ -848,2 +848,7 @@ import postcss from 'postcss' | ||
// If all rules have been eliminated we can skip this candidate entirely | ||
if (container.nodes.length === 0) { | ||
return null | ||
} | ||
match[1] = container.nodes[0] | ||
@@ -850,0 +855,0 @@ |
@@ -7,2 +7,10 @@ import jitiFactory from 'jiti' | ||
let jiti: ReturnType<typeof jitiFactory> | null = null | ||
// @internal | ||
// This WILL be removed in some future release | ||
// If you rely on this your stuff WILL break | ||
export function useCustomJiti(_jiti: ReturnType<typeof jitiFactory>) { | ||
jiti = _jiti | ||
} | ||
function lazyJiti() { | ||
@@ -9,0 +17,0 @@ return ( |
@@ -213,2 +213,6 @@ import path from 'path' | ||
getContext({ createContext, cliConfigPath, root, result, content }) { | ||
env.DEBUG && console.time('Searching for config') | ||
let configPath = findAtConfigPath(root, result) ?? cliConfigPath | ||
env.DEBUG && console.timeEnd('Searching for config') | ||
if (this.context) { | ||
@@ -220,6 +224,2 @@ this.context.changedContent = this.changedContent.splice(0) | ||
env.DEBUG && console.time('Searching for config') | ||
let configPath = findAtConfigPath(root, result) ?? cliConfigPath | ||
env.DEBUG && console.timeEnd('Searching for config') | ||
env.DEBUG && console.time('Loading config') | ||
@@ -226,0 +226,0 @@ let config = this.loadConfig(configPath, content) |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @param {import('postcss').Container[]} nodes | ||
* @param {any} source | ||
* @param {any} raws | ||
* @returns {import('postcss').Container[]} | ||
*/ | ||
export default function cloneNodes(nodes, source = undefined, raws = undefined) { | ||
@@ -5,16 +11,2 @@ return nodes.map((node) => { | ||
// We always want override the source map | ||
// except when explicitly told not to | ||
let shouldOverwriteSource = node.raws.tailwind?.preserveSource !== true || !cloned.source | ||
if (source !== undefined && shouldOverwriteSource) { | ||
cloned.source = source | ||
if ('walk' in cloned) { | ||
cloned.walk((child) => { | ||
child.source = source | ||
}) | ||
} | ||
} | ||
if (raws !== undefined) { | ||
@@ -27,4 +19,33 @@ cloned.raws.tailwind = { | ||
if (source !== undefined) { | ||
traverse(cloned, (node) => { | ||
// Do not traverse nodes that have opted | ||
// to preserve their original source | ||
let shouldPreserveSource = node.raws.tailwind?.preserveSource === true && node.source | ||
if (shouldPreserveSource) { | ||
return false | ||
} | ||
// Otherwise we can safely replace the source | ||
// And continue traversing | ||
node.source = source | ||
}) | ||
} | ||
return cloned | ||
}) | ||
} | ||
/** | ||
* Traverse a tree of nodes and don't traverse children if the callback | ||
* returns false. Ideally we'd use Container#walk instead of this | ||
* function but it stops traversing siblings too. | ||
* | ||
* @param {import('postcss').Container} node | ||
* @param {(node: import('postcss').Container) => boolean} onNode | ||
*/ | ||
function traverse(node, onNode) { | ||
if (onNode(node) !== false) { | ||
node.each?.((child) => traverse(child, onNode)) | ||
} | ||
} |
@@ -80,3 +80,3 @@ import { parseColor } from './color' | ||
* Add spaces around operators inside math functions | ||
* like calc() that do not follow an operator or '('. | ||
* like calc() that do not follow an operator, '(', or `,`. | ||
* | ||
@@ -168,3 +168,3 @@ * @param {string} value | ||
['+', '-', '*', '/'].includes(char) && | ||
!['(', '+', '-', '*', '/'].includes(lastChar()) | ||
!['(', '+', '-', '*', '/', ','].includes(lastChar()) | ||
) { | ||
@@ -171,0 +171,0 @@ result += ` ${char} ` |
@@ -91,2 +91,18 @@ import escapeCommas from './escapeCommas' | ||
// If the `/` is inside an arbitrary, we want to find the previous one if any | ||
// This logic probably isn't perfect but it should work for most cases | ||
let arbitraryStartIdx = modifier.lastIndexOf('[', slashIdx) | ||
let arbitraryEndIdx = modifier.indexOf(']', slashIdx) | ||
let isNextToArbitrary = modifier[slashIdx - 1] === ']' || modifier[slashIdx + 1] === '[' | ||
// Backtrack to the previous `/` if the one we found was inside an arbitrary | ||
if (!isNextToArbitrary) { | ||
if (arbitraryStartIdx !== -1 && arbitraryEndIdx !== -1) { | ||
if (arbitraryStartIdx < slashIdx && slashIdx < arbitraryEndIdx) { | ||
slashIdx = modifier.lastIndexOf('/', arbitraryStartIdx) | ||
} | ||
} | ||
} | ||
if (slashIdx === -1 || slashIdx === modifier.length - 1) { | ||
@@ -93,0 +109,0 @@ return [modifier, undefined] |
@@ -82,3 +82,3 @@ import type { CorePluginList } from './generated/corePluginList' | ||
// Theme related config | ||
interface ThemeConfig { | ||
export interface ThemeConfig { | ||
// Responsiveness | ||
@@ -238,4 +238,5 @@ screens: ResolvableTo<ScreensConfig> | ||
content: ResolvableTo<KeyValuePair> | ||
} | ||
// Custom | ||
interface CustomThemeConfig extends ThemeConfig { | ||
[key: string]: any | ||
@@ -363,3 +364,3 @@ } | ||
darkMode: Partial<DarkModeConfig> | ||
theme: Partial<ThemeConfig & { extend: Partial<ThemeConfig> }> | ||
theme: Partial<CustomThemeConfig & { extend: Partial<CustomThemeConfig> }> | ||
corePlugins: Partial<CorePluginsConfig> | ||
@@ -366,0 +367,0 @@ plugins: Partial<PluginsConfig> |
@@ -1,4 +0,3 @@ | ||
import { Config } from '../../types' | ||
type CSSDeclarationList = Record<string, string> | ||
export type DefaultTheme = Config['theme'] & { | ||
export type DefaultTheme = { | ||
animation: Record<'none' | 'spin' | 'ping' | 'pulse' | 'bounce', string> | ||
@@ -5,0 +4,0 @@ aria: Record< |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
5574436
34347