Skip to content

Commit

Permalink
fix: overwrite dataTypes.js file
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jul 17, 2024
1 parent ddd37e6 commit d678eda
Show file tree
Hide file tree
Showing 25 changed files with 688 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function findAstNode(content: string, options: ILengthUnitsPatchOptions) {
}
}

export function monkeyPatchForSupportingCustomUnit(rootDir: string, options?: ILengthUnitsPatchOptions) {
export function monkeyPatchForSupportingCustomUnit(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>) {
const opts = defu<Required<ILengthUnitsPatchOptions>, ILengthUnitsPatchOptions[]>(options, {
units: ['rpx'],
lengthUnitsFilePath: 'lib/util/dataTypes.js',
Expand Down
4 changes: 3 additions & 1 deletion packages/tailwindcss-patch/src/core/runtime-patcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export function internalPatch(pkgJsonPath: string | undefined, options: Internal

if (options.applyPatches?.extendLengthUnits) {
try {
monkeyPatchForSupportingCustomUnit(twDir)
monkeyPatchForSupportingCustomUnit(twDir, {
overwrite: options.overwrite,
})
}
catch {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,24 @@ function percentage(value) {
return /%$/g.test(value) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?%`).test(value)
);
}
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'vw', 'vh', 'vmin', 'vmax', 'rpx'];
let lengthUnits = [
'cm',
'mm',
'Q',
'in',
'pc',
'pt',
'px',
'em',
'ex',
'ch',
'rem',
'lh',
'vw',
'vh',
'vmin',
'vmax',
];
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`;
function length(value) {
return value.split(UNDERSCORE).every((part)=>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,24 @@ function number(value) {
function percentage(value) {
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
}
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'vw', 'vh', 'vmin', 'vmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"vw",
"vh",
"vmin",
"vmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,24 @@ function number(value) {
function percentage(value) {
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
}
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'vw', 'vh', 'vmin', 'vmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"vw",
"vh",
"vmin",
"vmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,24 @@ function number(value) {
function percentage(value) {
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
}
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'vw', 'vh', 'vmin', 'vmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"vw",
"vh",
"vmin",
"vmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,24 @@ function number(value) {
function percentage(value) {
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
}
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'vw', 'vh', 'vmin', 'vmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"vw",
"vh",
"vmin",
"vmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,39 @@ function percentage(value) {
// Please refer to MDN when updating this list:
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'rlh', 'vw', 'vh', 'vmin', 'vmax', 'vb', 'vi', 'svw', 'svh', 'lvw', 'lvh', 'dvw', 'dvh', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"rlh",
"vw",
"vh",
"vmin",
"vmax",
"vb",
"vi",
"svw",
"svh",
"lvw",
"lvh",
"dvw",
"dvh",
"cqw",
"cqh",
"cqi",
"cqb",
"cqmin",
"cqmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,39 @@ function percentage(value) {
// Please refer to MDN when updating this list:
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'rlh', 'vw', 'vh', 'vmin', 'vmax', 'vb', 'vi', 'svw', 'svh', 'lvw', 'lvh', 'dvw', 'dvh', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"rlh",
"vw",
"vh",
"vmin",
"vmax",
"vb",
"vi",
"svw",
"svh",
"lvw",
"lvh",
"dvw",
"dvh",
"cqw",
"cqh",
"cqi",
"cqb",
"cqmin",
"cqmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,39 @@ function percentage(value) {
// Please refer to MDN when updating this list:
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'rlh', 'vw', 'vh', 'vmin', 'vmax', 'vb', 'vi', 'svw', 'svh', 'lvw', 'lvh', 'dvw', 'dvh', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"rlh",
"vw",
"vh",
"vmin",
"vmax",
"vb",
"vi",
"svw",
"svh",
"lvw",
"lvh",
"dvw",
"dvh",
"cqw",
"cqh",
"cqi",
"cqb",
"cqmin",
"cqmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,39 @@ function percentage(value) {
// Please refer to MDN when updating this list:
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'rlh', 'vw', 'vh', 'vmin', 'vmax', 'vb', 'vi', 'svw', 'svh', 'lvw', 'lvh', 'dvw', 'dvh', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"rlh",
"vw",
"vh",
"vmin",
"vmax",
"vb",
"vi",
"svw",
"svh",
"lvw",
"lvh",
"dvw",
"dvh",
"cqw",
"cqh",
"cqi",
"cqb",
"cqmin",
"cqmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,39 @@ function percentage(value) {
// Please refer to MDN when updating this list:
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'rlh', 'vw', 'vh', 'vmin', 'vmax', 'vb', 'vi', 'svw', 'svh', 'lvw', 'lvh', 'dvw', 'dvh', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"rlh",
"vw",
"vh",
"vmin",
"vmax",
"vb",
"vi",
"svw",
"svh",
"lvw",
"lvh",
"dvw",
"dvh",
"cqw",
"cqh",
"cqi",
"cqb",
"cqmin",
"cqmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,39 @@ function percentage(value) {
// Please refer to MDN when updating this list:
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
let lengthUnits = ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'rlh', 'vw', 'vh', 'vmin', 'vmax', 'vb', 'vi', 'svw', 'svh', 'lvw', 'lvh', 'dvw', 'dvh', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'rpx'];
let lengthUnits = [
"cm",
"mm",
"Q",
"in",
"pc",
"pt",
"px",
"em",
"ex",
"ch",
"rem",
"lh",
"rlh",
"vw",
"vh",
"vmin",
"vmax",
"vb",
"vi",
"svw",
"svh",
"lvw",
"lvh",
"dvw",
"dvh",
"cqw",
"cqh",
"cqi",
"cqb",
"cqmin",
"cqmax"
];
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
function length(value) {
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
Expand Down
Loading

0 comments on commit d678eda

Please sign in to comment.