update assets part 3

This commit is contained in:
2022-11-23 08:55:59 +00:00
parent 0470900951
commit e019ec9965
1000 changed files with 6989 additions and 6705 deletions

View File

@@ -1,4 +1,4 @@
console.log(`Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
console.log(`Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
Copyright 2022 Fonticons, Inc.
`)

View File

@@ -1,11 +1,20 @@
import {
IconDefinition,
IconName,
IconStyle,
IconFamily
} from '@fortawesome/fontawesome-common-types';
export type IconMacroParams = {
name: IconName,
style?: IconStyle,
family?: IconFamily
};
export function brands(iconName: IconName): IconDefinition;
export function duotone(iconName: IconName): IconDefinition;
export function light(iconName: IconName): IconDefinition;
export function regular(iconName: IconName): IconDefinition;
export function solid(iconName: IconName): IconDefinition;
export function thin(iconName: IconName): IconDefinition;
export function icon(params: IconMacroParams): IconDefinition;

View File

@@ -14,6 +14,17 @@ const styles = [
'brands'
]
const macroNames = [
...styles,
'icon'
]
const families = [
'classic',
'duotone',
'sharp'
]
function importer ({references, state, babel, source, config}) {
const license = (config !== undefined ? config.license : 'free')
@@ -25,8 +36,8 @@ function importer ({references, state, babel, source, config}) {
Object.keys(references).forEach((key) => {
replace({
style: key,
license: (key === 'brands' ? 'free' : license),
macroName: key,
license,
references: references[key],
state,
babel,
@@ -35,41 +46,65 @@ function importer ({references, state, babel, source, config}) {
})
}
function replace ({ style, license, references, state, babel, source }) {
function replace ({ macroName, license, references, state, babel, source }) {
references.forEach((nodePath) => {
if (canBeReplaced({ nodePath, babel, state, style })) {
const iconName = nodePath.parentPath.node.arguments[0].value
const name = `fa${capitalize(camelCase(iconName))}`
const importFrom = `@fortawesome/${license}-${style}-svg-icons/${name}`
const {iconName, style, family} = resolveReplacement({ nodePath, babel, state, macroName })
const importName = addNamed(nodePath, name, importFrom)
const name = `fa${capitalize(camelCase(iconName))}`
const importFrom = getImport({family, style, license, name})
nodePath.parentPath.replaceWith(importName)
}
const importName = addNamed(nodePath, name, importFrom)
nodePath.parentPath.replaceWith(importName)
})
}
function canBeReplaced ({ nodePath, babel, state, style }) {
function getImport ({family, style, license, name}) {
if (family) {
return `@fortawesome/${family.toLowerCase()}-${style}-svg-icons/${name}`
} else {
return `@fortawesome/${license}-${style}-svg-icons/${name}`
}
}
function resolveReplacement ({ nodePath, babel, state, macroName }) {
if('icon' === macroName) {
return resolveReplacementIcon({ nodePath, babel, state, macroName })
} else {
return resolveReplacementLegacyStyle({ nodePath, babel, state, macroName })
}
}
// The macros corresonding to legacy style names: solid(), regular(), light(), thin(), duotone(), brands().
function resolveReplacementLegacyStyle({ nodePath, babel, state, macroName }) {
const { types: t } = babel
const { parentPath } = nodePath
if (!styles.includes(style)) {
if (!styles.includes(macroName)) {
throw parentPath.buildCodeFrameError(
`${style} is not a valid style. Use one of ${styles.join(', ')}`,
`${macroName} is not a valid macro name. Use one of ${macroNames.join(', ')}`,
MacroError
)
}
if (parentPath.node.arguments) {
if (parentPath.node.arguments.length !== 1) {
if (parentPath.node.arguments.length < 1) {
throw parentPath.buildCodeFrameError(
`Received an invalid number of arguments (must be 1)`,
`Received an invalid number of arguments for ${macroName} macro: must be exactly 1`,
MacroError
)
}
if (parentPath.node.arguments.length > 1) {
throw parentPath.buildCodeFrameError(
`Received an invalid number of arguments for ${macroName} macro: must be exactly 1`,
MacroError
)
}
if (
parentPath.node.arguments.length === 1 &&
(parentPath.node.arguments.length === 1 ||
parentPath.node.arguments.length === 2) &&
t.isStringLiteral(parentPath.node.arguments[0]) &&
nodePath.parentPath.node.arguments[0].value.startsWith('fa-')
) {
@@ -79,7 +114,9 @@ function canBeReplaced ({ nodePath, babel, state, style }) {
)
}
if (parentPath.node.arguments.length === 1 && !t.isStringLiteral(parentPath.node.arguments[0])) {
if ((parentPath.node.arguments.length === 1 ||
parentPath.node.arguments.length === 2) &&
!t.isStringLiteral(parentPath.node.arguments[0])) {
throw parentPath.buildCodeFrameError(
'Only string literals are supported when referencing icons (use a string here instead)',
MacroError
@@ -92,7 +129,147 @@ function canBeReplaced ({ nodePath, babel, state, style }) {
)
}
return true
return {
iconName: nodePath.parentPath.node.arguments[0].value,
style: macroName,
family: undefined
}
}
// The icon() macro.
function resolveReplacementIcon ({ nodePath, babel, state, macroName }) {
const { types: t } = babel
const { parentPath } = nodePath
if ('icon' !== macroName) {
throw parentPath.buildCodeFrameError(
`${macroName} is not a valid macro name. Use one of ${macroNames.join(', ')}`,
MacroError
)
}
if (parentPath.node.arguments.length !== 1) {
throw parentPath.buildCodeFrameError(
`Received an invalid number of arguments for ${macroName} macro: must be exactly 1`,
MacroError
)
}
if (!t.isObjectExpression(parentPath.node.arguments[0])) {
throw parentPath.buildCodeFrameError(
'Only object expressions are supported when referencing icons with this macro, like this: { name: \'star\' }',
MacroError
)
}
const properties = (parentPath.node.arguments[0].properties || [])
const namePropIndex = properties.findIndex((prop) => 'name' === prop.key.name)
const name = namePropIndex >= 0
? getStringLiteralPropertyValue(t, parentPath, parentPath.node.arguments[0].properties[namePropIndex])
: undefined
if(!name) {
throw parentPath.buildCodeFrameError(
'The object argument to the icon() macro must have a name property',
MacroError
)
}
const stylePropIndex = properties.findIndex((prop) => 'style' === prop.key.name)
let style = stylePropIndex >= 0
? getStringLiteralPropertyValue(t, parentPath, parentPath.node.arguments[0].properties[stylePropIndex])
: undefined
if(style && !styles.includes(style)) {
throw parentPath.buildCodeFrameError(
`Invalid style name: ${style}. It must be one of the following: ${styles.join(', ')}`,
MacroError
)
}
const familyPropIndex = properties.findIndex((prop) => 'family' === prop.key.name)
let family = familyPropIndex >= 0
? getStringLiteralPropertyValue(t, parentPath, parentPath.node.arguments[0].properties[familyPropIndex])
: undefined
if(family && !families.includes(family)) {
throw parentPath.buildCodeFrameError(
`Invalid family name: ${family}. It must be one of the following: ${families.join(', ')}`,
MacroError
)
}
if('duotone' === style && family && 'classic' !== family) {
throw parentPath.buildCodeFrameError(
`duotone cannot be used as a style name with any family other than classic`,
MacroError
)
}
if('brands' === style && family && 'classic' !== family) {
throw parentPath.buildCodeFrameError(
`brands cannot be used as a style name with any family other than classic`,
MacroError
)
}
if(family && !style) {
throw parentPath.buildCodeFrameError(
`When a family is specified, a style must also be specified`,
MacroError
)
}
if('duotone' === style || 'duotone' === family) {
family = undefined
style = 'duotone'
}
if('brands' === style) {
family = undefined
}
// defaults
if(!style) {
style = 'solid'
}
if('classic' === family) {
family = undefined
}
return {
iconName: name,
family,
style
}
}
function getStringLiteralPropertyValue(t, parentPath, property) {
if(!('object' === typeof t && 'function' === typeof t.isStringLiteral)) {
throw Error("ERROR: invalid babel-types arg. This is probably a programming error in import.macro")
}
if(!('object' === typeof property && 'object' === typeof property.value && 'object' == typeof property.key)) {
throw Error("ERROR: invalid babel property arg. This is probably a programming error in import.macro")
}
if(!('object' === typeof parentPath && 'function' === typeof parentPath.buildCodeFrameError)) {
throw Error("ERROR: invalid babel parentPath arg. This is probably a programming error in import.macro")
}
if(!t.isStringLiteral(property.value)) {
throw parentPath.buildCodeFrameError(
`Only string literals are supported for the ${property.key.name} property (use a string here instead)`,
MacroError
)
}
return property.value.value
}
function capitalize (str) {

View File

@@ -1,5 +1,5 @@
import {IconDefinition, IconLookup, IconName, IconPrefix, IconPathData, IconPack } from '@fortawesome/fontawesome-common-types';
export {IconDefinition, IconLookup, IconName, IconPrefix, IconPathData, IconPack } from '@fortawesome/fontawesome-common-types';
import {IconDefinition, IconLookup, IconName, IconFamily, IconPrefix, CssStyleClass, IconStyle, IconPathData, IconPack} from '@fortawesome/fontawesome-common-types';
export {IconDefinition, IconLookup, IconName, IconFamily, IconPrefix, CssStyleClass, IconStyle, IconPathData, IconPack} from '@fortawesome/fontawesome-common-types';
export const dom: DOM;
export const library: Library;
export const parse: { transform(transformString: string): Transform, icon(parseIconString: string): IconLookup };
@@ -20,9 +20,12 @@ export function icon(icon: IconName | IconLookup, params?: IconParams): Icon;
export type IconProp = IconName | [IconPrefix, IconName] | IconLookup;
export type FlipProp = "horizontal" | "vertical" | "both";
export type SizeProp =
| "2xs"
| "xs"
| "lg"
| "sm"
| "lg"
| "xl"
| "2xl"
| "1x"
| "2x"
| "3x"
@@ -37,7 +40,10 @@ export type PullProp = "left" | "right";
export type RotateProp = 90 | 180 | 270;
export type FaSymbol = string | boolean;
export interface Config {
familyPrefix: IconPrefix;
familyPrefix: string;
cssPrefix: string;
styleDefault: IconPrefix | CssStyleClass | IconStyle;
familyDefault: IconFamily;
replacementClass: string;
autoReplaceSvg: boolean | 'nest';
autoAddCss: boolean;

File diff suppressed because one or more lines are too long

View File

@@ -21,40 +21,40 @@
"node": ">=6"
},
"dependencies": {
"@fortawesome/fontawesome-common-types": "6.1.1"
"@fortawesome/fontawesome-common-types": "6.2.0"
},
"version": "6.1.1",
"version": "6.2.0",
"name": "@fortawesome/fontawesome-svg-core",
"main": "index.js",
"module": "index.es.js",
"jsnext:main": "index.es.js",
"module": "index.mjs",
"jsnext:main": "index.mjs",
"style": "styles.css",
"license": "MIT",
"types": "./index.d.ts",
"exports": {
".": {
"module": "./index.es.js",
"import": "./index.es.js",
"module": "./index.mjs",
"import": "./index.mjs",
"require": "./index.js",
"style": "./styles.css",
"default": "./index.js"
},
"./index": {
"module": "./index.es.js",
"import": "./index.es.js",
"module": "./index.mjs",
"import": "./index.mjs",
"require": "./index.js",
"default": "./index.js"
},
"./index.js": {
"module": "./index.es.js",
"import": "./index.es.js",
"module": "./index.mjs",
"import": "./index.mjs",
"require": "./index.js",
"default": "./index.js"
},
"./plugins": {
"module": "./plugins.es.js",
"import": "./plugins.es.js",
"default": "./plugins.es.js"
"module": "./plugins.mjs",
"import": "./plugins.mjs",
"default": "./plugins.mjs"
},
"./import.macro": "./import.macro.js",
"./import.macro.js": "./import.macro.js",
@@ -64,7 +64,7 @@
},
"sideEffects": [
"./index.js",
"./index.es.js",
"./index.mjs",
"./styles.css"
],
"scripts": {

View File

@@ -1,10 +1,11 @@
:root, :host {
--fa-font-solid: normal 900 1em/1 "Font Awesome 6 Solid";
--fa-font-regular: normal 400 1em/1 "Font Awesome 6 Regular";
--fa-font-light: normal 300 1em/1 "Font Awesome 6 Light";
--fa-font-thin: normal 100 1em/1 "Font Awesome 6 Thin";
--fa-font-duotone: normal 900 1em/1 "Font Awesome 6 Duotone";
--fa-font-brands: normal 400 1em/1 "Font Awesome 6 Brands"; }
--fa-font-solid: normal 900 1em/1 'Font Awesome 6 Solid';
--fa-font-regular: normal 400 1em/1 'Font Awesome 6 Regular';
--fa-font-light: normal 300 1em/1 'Font Awesome 6 Light';
--fa-font-thin: normal 100 1em/1 'Font Awesome 6 Thin';
--fa-font-duotone: normal 900 1em/1 'Font Awesome 6 Duotone';
--fa-font-sharp-solid: normal 900 1em/1 'Font Awesome 6 Sharp';
--fa-font-brands: normal 400 1em/1 'Font Awesome 6 Brands'; }
svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
overflow: visible;
@@ -221,8 +222,8 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
.fa-beat {
-webkit-animation-name: fa-beat;
animation-name: fa-beat;
-webkit-animation-delay: var(--fa-animation-delay, 0);
animation-delay: var(--fa-animation-delay, 0);
-webkit-animation-delay: var(--fa-animation-delay, 0s);
animation-delay: var(--fa-animation-delay, 0s);
-webkit-animation-direction: var(--fa-animation-direction, normal);
animation-direction: var(--fa-animation-direction, normal);
-webkit-animation-duration: var(--fa-animation-duration, 1s);
@@ -235,8 +236,8 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
.fa-bounce {
-webkit-animation-name: fa-bounce;
animation-name: fa-bounce;
-webkit-animation-delay: var(--fa-animation-delay, 0);
animation-delay: var(--fa-animation-delay, 0);
-webkit-animation-delay: var(--fa-animation-delay, 0s);
animation-delay: var(--fa-animation-delay, 0s);
-webkit-animation-direction: var(--fa-animation-direction, normal);
animation-direction: var(--fa-animation-direction, normal);
-webkit-animation-duration: var(--fa-animation-duration, 1s);
@@ -249,8 +250,8 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
.fa-fade {
-webkit-animation-name: fa-fade;
animation-name: fa-fade;
-webkit-animation-delay: var(--fa-animation-delay, 0);
animation-delay: var(--fa-animation-delay, 0);
-webkit-animation-delay: var(--fa-animation-delay, 0s);
animation-delay: var(--fa-animation-delay, 0s);
-webkit-animation-direction: var(--fa-animation-direction, normal);
animation-direction: var(--fa-animation-direction, normal);
-webkit-animation-duration: var(--fa-animation-duration, 1s);
@@ -263,8 +264,8 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
.fa-beat-fade {
-webkit-animation-name: fa-beat-fade;
animation-name: fa-beat-fade;
-webkit-animation-delay: var(--fa-animation-delay, 0);
animation-delay: var(--fa-animation-delay, 0);
-webkit-animation-delay: var(--fa-animation-delay, 0s);
animation-delay: var(--fa-animation-delay, 0s);
-webkit-animation-direction: var(--fa-animation-direction, normal);
animation-direction: var(--fa-animation-direction, normal);
-webkit-animation-duration: var(--fa-animation-duration, 1s);
@@ -277,8 +278,8 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
.fa-flip {
-webkit-animation-name: fa-flip;
animation-name: fa-flip;
-webkit-animation-delay: var(--fa-animation-delay, 0);
animation-delay: var(--fa-animation-delay, 0);
-webkit-animation-delay: var(--fa-animation-delay, 0s);
animation-delay: var(--fa-animation-delay, 0s);
-webkit-animation-direction: var(--fa-animation-direction, normal);
animation-direction: var(--fa-animation-direction, normal);
-webkit-animation-duration: var(--fa-animation-duration, 1s);
@@ -291,8 +292,8 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
.fa-shake {
-webkit-animation-name: fa-shake;
animation-name: fa-shake;
-webkit-animation-delay: var(--fa-animation-delay, 0);
animation-delay: var(--fa-animation-delay, 0);
-webkit-animation-delay: var(--fa-animation-delay, 0s);
animation-delay: var(--fa-animation-delay, 0s);
-webkit-animation-direction: var(--fa-animation-direction, normal);
animation-direction: var(--fa-animation-direction, normal);
-webkit-animation-duration: var(--fa-animation-duration, 1s);
@@ -305,8 +306,8 @@ svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
.fa-spin {
-webkit-animation-name: fa-spin;
animation-name: fa-spin;
-webkit-animation-delay: var(--fa-animation-delay, 0);
animation-delay: var(--fa-animation-delay, 0);
-webkit-animation-delay: var(--fa-animation-delay, 0s);
animation-delay: var(--fa-animation-delay, 0s);
-webkit-animation-direction: var(--fa-animation-direction, normal);
animation-direction: var(--fa-animation-direction, normal);
-webkit-animation-duration: var(--fa-animation-duration, 2s);