purgetss 6.2.38 → 6.2.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/purgetss +1 -0
- package/dist/tailwind.tss +1 -1
- package/index.js +29 -19
- package/lib/helpers.js +18 -1
- package/lib/templates/tailwind/template.tss +1 -1
- package/package.json +5 -5
package/bin/purgetss
CHANGED
|
@@ -142,6 +142,7 @@ program
|
|
|
142
142
|
.description(`Generate ${chalk.yellow('fonts.tss')} from font and CSS files in ${chalk.yellow('./purgetss/fonts')}`)
|
|
143
143
|
.help(`Generate a ${chalk.yellow('./purgetss/styles/fonts.tss')} file based on the font and css files located in ${chalk.yellow('./purgetss/fonts')} folder`)
|
|
144
144
|
.option('-m, --module', `To also generate a CommonJS module in ${chalk.yellow('./app/lib/')} folder called ${chalk.yellow('purgetss-fonts.js')}`)
|
|
145
|
+
.option('-p, --prefix', "Apply the style's filename as the prefix in icon fonts for both the `fonts.tss` and `purgetss.fonts.js` files.")
|
|
145
146
|
.action((args, options, logger) => {
|
|
146
147
|
purgetss.buildFonts(options)
|
|
147
148
|
})
|
package/dist/tailwind.tss
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Based on Tailwind CSS v3.3.
|
|
1
|
+
// Based on Tailwind CSS v3.3.5: A utility-first CSS framework for rapidly building custom designs. ( https://tailwindcss.com )
|
|
2
2
|
// Created by Adam Wathan ( https://twitter.com/adamwathan ).
|
|
3
3
|
|
|
4
4
|
// Tailwind-like styles
|
package/index.js
CHANGED
|
@@ -660,8 +660,10 @@ function buildFonts(options) {
|
|
|
660
660
|
// ! Process styles files
|
|
661
661
|
_.each(files, file => {
|
|
662
662
|
if (file.endsWith('.css') || file.endsWith('.CSS')) {
|
|
663
|
+
const cssFile = readCSS(file)
|
|
663
664
|
const theFile = file.split('/')
|
|
664
665
|
const theCSSFile = theFile.pop()
|
|
666
|
+
const prefix = options.prefix ? theCSSFile.split('.').shift() : null
|
|
665
667
|
let theFolder = theFile.pop() + '/'
|
|
666
668
|
if (theFolder === 'fonts/') {
|
|
667
669
|
theFolder = ''
|
|
@@ -672,12 +674,12 @@ function buildFonts(options) {
|
|
|
672
674
|
tssClasses += oneTimeMessage + `\n// ${theCSSFileName}\n`
|
|
673
675
|
oneTimeMessage = ''
|
|
674
676
|
|
|
675
|
-
tssClasses += processFontsCSS(
|
|
677
|
+
tssClasses += processFontsCSS(cssFile, prefix)
|
|
676
678
|
|
|
677
679
|
// ! JavaScript Module
|
|
678
680
|
if (options.module) {
|
|
679
|
-
fontJS += processFontsJS(
|
|
680
|
-
fontFamiliesJS += processFontFamilyNamesJS(
|
|
681
|
+
fontJS += processFontsJS(cssFile, `\n\t// ${theCSSFileName}`, prefix)
|
|
682
|
+
fontFamiliesJS += processFontFamilyNamesJS(cssFile, `\n\t// ${theCSSFileName}`, prefix)
|
|
681
683
|
}
|
|
682
684
|
|
|
683
685
|
// !Done processing stylesheet
|
|
@@ -689,7 +691,7 @@ function buildFonts(options) {
|
|
|
689
691
|
makeSureFolderExists(projectsPurgeTSSFolder)
|
|
690
692
|
makeSureFolderExists(projectsPurge_TSS_Styles_Folder)
|
|
691
693
|
|
|
692
|
-
fs.writeFileSync(cwd
|
|
694
|
+
fs.writeFileSync(`${cwd}/purgetss/styles/fonts.tss`, tssClasses, { encoding: 'utf8' }, err => {
|
|
693
695
|
throw err
|
|
694
696
|
})
|
|
695
697
|
}
|
|
@@ -700,16 +702,18 @@ function buildFonts(options) {
|
|
|
700
702
|
let exportIcons = 'const icons = {'
|
|
701
703
|
exportIcons += fontJS.slice(0, -1)
|
|
702
704
|
exportIcons += '\n};\n'
|
|
705
|
+
exportIcons += 'exports.icon = icons;\n'
|
|
703
706
|
exportIcons += 'exports.icons = icons;\n'
|
|
704
707
|
|
|
705
708
|
exportIcons += '\nconst families = {'
|
|
706
709
|
exportIcons += fontFamiliesJS.slice(0, -1)
|
|
707
710
|
exportIcons += '\n};\n'
|
|
711
|
+
exportIcons += 'exports.family = families;\n'
|
|
708
712
|
exportIcons += 'exports.families = families;\n'
|
|
709
713
|
|
|
710
714
|
exportIcons += '\n// Helper Functions\n' + fs.readFileSync(path.resolve(__dirname, './lib/templates/icon-functions.js'), 'utf8')
|
|
711
715
|
|
|
712
|
-
fs.writeFileSync(`${projectsLibFolder}/purgetss.fonts.js`, exportIcons, err => {
|
|
716
|
+
fs.writeFileSync(`${projectsLibFolder}/purgetss.fonts.js`, exportIcons, { encoding: 'utf8' }, err => {
|
|
713
717
|
throw err
|
|
714
718
|
})
|
|
715
719
|
|
|
@@ -890,50 +894,56 @@ function copyFramework7IconsFonts() {
|
|
|
890
894
|
logger.warn(' - Framework 7')
|
|
891
895
|
}
|
|
892
896
|
|
|
893
|
-
function processFontsCSS(data) {
|
|
897
|
+
function processFontsCSS(data, prefix) {
|
|
894
898
|
const rules = getRules(data)
|
|
899
|
+
const fontsPrefix = findPrefix(rules)
|
|
895
900
|
|
|
896
901
|
let processedRules = ''
|
|
897
|
-
|
|
898
902
|
_.each(rules, rule => {
|
|
899
903
|
if (rule) {
|
|
900
|
-
|
|
904
|
+
if (prefix) {
|
|
905
|
+
processedRules += `'${rule.selector.replace(fontsPrefix, prefix)}': { text: '\\u${rule.property}', title: '\\u${rule.property}' }\n`
|
|
906
|
+
} else {
|
|
907
|
+
processedRules += `'${rule.selector}': { text: '\\u${rule.property}', title: '\\u${rule.property}' }\n`
|
|
908
|
+
}
|
|
901
909
|
}
|
|
902
910
|
})
|
|
903
911
|
|
|
904
912
|
return processedRules
|
|
905
913
|
}
|
|
906
914
|
|
|
907
|
-
function processFontsJS(data, fontFamily = '') {
|
|
915
|
+
function processFontsJS(data, fontFamily = '', prefix) {
|
|
908
916
|
const rules = getRules(data)
|
|
909
917
|
|
|
910
918
|
let exportIcons = '\n'
|
|
911
919
|
|
|
912
|
-
let
|
|
920
|
+
let fontsPrefix = findPrefix(rules)
|
|
913
921
|
|
|
914
922
|
_.each(rules, rule => {
|
|
915
923
|
if (rule) {
|
|
916
|
-
exportIcons += `\t\t'${prettifyFontName(rule.selector.replace('.', ''),
|
|
924
|
+
exportIcons += `\t\t'${prettifyFontName(rule.selector.replace('.', ''), fontsPrefix)}': '\\u${rule.property}',\n`
|
|
917
925
|
}
|
|
918
926
|
})
|
|
919
927
|
|
|
920
|
-
if (
|
|
921
|
-
|
|
928
|
+
if (prefix) {
|
|
929
|
+
fontsPrefix = prefix
|
|
930
|
+
} else if (fontsPrefix === undefined) {
|
|
931
|
+
fontsPrefix = fontFamily
|
|
922
932
|
}
|
|
923
933
|
|
|
924
|
-
return `${fontFamily}\n\t'${_.camelCase(
|
|
934
|
+
return `${fontFamily}\n\t'${_.camelCase(fontsPrefix)}': {${exportIcons}\t},`
|
|
925
935
|
}
|
|
926
936
|
|
|
927
|
-
function processFontFamilyNamesJS(data, fontFamily = '') {
|
|
937
|
+
function processFontFamilyNamesJS(data, fontFamily = '', prefix) {
|
|
928
938
|
const rules = getRules(data)
|
|
929
939
|
|
|
930
|
-
let
|
|
940
|
+
let fontsPrefix = prefix ?? findPrefix(rules)
|
|
931
941
|
|
|
932
|
-
if (
|
|
933
|
-
|
|
942
|
+
if (fontsPrefix === undefined) {
|
|
943
|
+
fontsPrefix = fontFamily
|
|
934
944
|
}
|
|
935
945
|
|
|
936
|
-
return `${fontFamily}\n\t'${_.camelCase(
|
|
946
|
+
return `${fontFamily}\n\t'${_.camelCase(fontsPrefix)}': '${getFontFamily(data)}',`
|
|
937
947
|
}
|
|
938
948
|
|
|
939
949
|
function processFontMeta(fontMeta) {
|
package/lib/helpers.js
CHANGED
|
@@ -6874,9 +6874,26 @@ function parseValue(value, sign = '') {
|
|
|
6874
6874
|
value = 0
|
|
6875
6875
|
}
|
|
6876
6876
|
|
|
6877
|
+
if (value.includes('/')) {
|
|
6878
|
+
/* eslint-disable no-eval */
|
|
6879
|
+
let parsedFloat = parseFloat(eval(value)) * 100
|
|
6880
|
+
const splittedValues = parsedFloat.toString().split('.')
|
|
6881
|
+
|
|
6882
|
+
if (splittedValues[1] && splittedValues[1].length >= 6) {
|
|
6883
|
+
if (`.${splittedValues[1]}` < 0.5) {
|
|
6884
|
+
parsedFloat += 0.000001
|
|
6885
|
+
}
|
|
6886
|
+
parsedFloat = parsedFloat.toFixed(6)
|
|
6887
|
+
}
|
|
6888
|
+
|
|
6889
|
+
value = `${parsedFloat}%`
|
|
6890
|
+
}
|
|
6891
|
+
|
|
6877
6892
|
const unit = isNaN(value) ? checkTitanium(value) : value
|
|
6878
6893
|
|
|
6879
|
-
if (typeof value === 'string' && value.indexOf('-') > -1 || value < 0)
|
|
6894
|
+
if ((typeof value === 'string' && value.indexOf('-') > -1) || value < 0) {
|
|
6895
|
+
sign = ''
|
|
6896
|
+
}
|
|
6880
6897
|
|
|
6881
6898
|
switch (unit) {
|
|
6882
6899
|
case '0':
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Based on Tailwind CSS v3.3.
|
|
1
|
+
// Based on Tailwind CSS v3.3.5: A utility-first CSS framework for rapidly building custom designs. ( https://tailwindcss.com )
|
|
2
2
|
// Created by Adam Wathan ( https://twitter.com/adamwathan ).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "purgetss",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.40",
|
|
4
4
|
"description": "A package that simplifies mobile app creation for Titanium developers.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"path": "^0.12.7",
|
|
59
59
|
"prompts": "^2.4.2",
|
|
60
60
|
"read-css": "^0.3.0",
|
|
61
|
-
"tailwindcss": "^3.3.
|
|
61
|
+
"tailwindcss": "^3.3.5",
|
|
62
62
|
"traverse": "^0.6.7",
|
|
63
63
|
"update-notifier": "^5.1.0",
|
|
64
64
|
"uuid": "^9.0.1",
|
|
65
65
|
"xml-js": "^1.6.11"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"eslint": "^8.
|
|
68
|
+
"eslint": "^8.53.0",
|
|
69
69
|
"eslint-config-standard": "^17.1.0",
|
|
70
|
-
"eslint-plugin-import": "^2.
|
|
71
|
-
"eslint-plugin-n": "^
|
|
70
|
+
"eslint-plugin-import": "^2.29.0",
|
|
71
|
+
"eslint-plugin-n": "^16.3.0"
|
|
72
72
|
}
|
|
73
73
|
}
|