@medely/fontawesome-svg-core 0.0.1
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/LICENSE.txt +165 -0
- package/README.md +27 -0
- package/attribution.js +4 -0
- package/import.macro.d.ts +20 -0
- package/import.macro.js +301 -0
- package/index.d.ts +125 -0
- package/index.js +3800 -0
- package/index.mjs +3777 -0
- package/package.json +77 -0
- package/plugins.mjs +3064 -0
- package/styles.css +634 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Fonticons, Inc. (https://fontawesome.com)
|
|
2
|
+
|
|
3
|
+
--------------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
Font Awesome Free License
|
|
6
|
+
|
|
7
|
+
Font Awesome Free is free, open source, and GPL friendly. You can use it for
|
|
8
|
+
commercial projects, open source projects, or really almost whatever you want.
|
|
9
|
+
Full Font Awesome Free license: https://fontawesome.com/license/free.
|
|
10
|
+
|
|
11
|
+
--------------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
|
|
14
|
+
|
|
15
|
+
The Font Awesome Free download is licensed under a Creative Commons
|
|
16
|
+
Attribution 4.0 International License and applies to all icons packaged
|
|
17
|
+
as SVG and JS file types.
|
|
18
|
+
|
|
19
|
+
--------------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
# Fonts: SIL OFL 1.1 License
|
|
22
|
+
|
|
23
|
+
In the Font Awesome Free download, the SIL OFL license applies to all icons
|
|
24
|
+
packaged as web and desktop font files.
|
|
25
|
+
|
|
26
|
+
Copyright (c) 2023 Fonticons, Inc. (https://fontawesome.com)
|
|
27
|
+
with Reserved Font Name: "Font Awesome".
|
|
28
|
+
|
|
29
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
30
|
+
This license is copied below, and is also available with a FAQ at:
|
|
31
|
+
http://scripts.sil.org/OFL
|
|
32
|
+
|
|
33
|
+
SIL OPEN FONT LICENSE
|
|
34
|
+
Version 1.1 - 26 February 2007
|
|
35
|
+
|
|
36
|
+
PREAMBLE
|
|
37
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
38
|
+
development of collaborative font projects, to support the font creation
|
|
39
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
40
|
+
open framework in which fonts may be shared and improved in partnership
|
|
41
|
+
with others.
|
|
42
|
+
|
|
43
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
44
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
45
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
46
|
+
redistributed and/or sold with any software provided that any reserved
|
|
47
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
48
|
+
however, cannot be released under any other type of license. The
|
|
49
|
+
requirement for fonts to remain under this license does not apply
|
|
50
|
+
to any document created using the fonts or their derivatives.
|
|
51
|
+
|
|
52
|
+
DEFINITIONS
|
|
53
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
54
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
55
|
+
include source files, build scripts and documentation.
|
|
56
|
+
|
|
57
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
58
|
+
copyright statement(s).
|
|
59
|
+
|
|
60
|
+
"Original Version" refers to the collection of Font Software components as
|
|
61
|
+
distributed by the Copyright Holder(s).
|
|
62
|
+
|
|
63
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
64
|
+
or substituting — in part or in whole — any of the components of the
|
|
65
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
66
|
+
new environment.
|
|
67
|
+
|
|
68
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
69
|
+
writer or other person who contributed to the Font Software.
|
|
70
|
+
|
|
71
|
+
PERMISSION & CONDITIONS
|
|
72
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
73
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
74
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
75
|
+
Software, subject to the following conditions:
|
|
76
|
+
|
|
77
|
+
1) Neither the Font Software nor any of its individual components,
|
|
78
|
+
in Original or Modified Versions, may be sold by itself.
|
|
79
|
+
|
|
80
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
81
|
+
redistributed and/or sold with any software, provided that each copy
|
|
82
|
+
contains the above copyright notice and this license. These can be
|
|
83
|
+
included either as stand-alone text files, human-readable headers or
|
|
84
|
+
in the appropriate machine-readable metadata fields within text or
|
|
85
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
86
|
+
|
|
87
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
88
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
89
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
90
|
+
presented to the users.
|
|
91
|
+
|
|
92
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
93
|
+
Software shall not be used to promote, endorse or advertise any
|
|
94
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
95
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
96
|
+
permission.
|
|
97
|
+
|
|
98
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
99
|
+
must be distributed entirely under this license, and must not be
|
|
100
|
+
distributed under any other license. The requirement for fonts to
|
|
101
|
+
remain under this license does not apply to any document created
|
|
102
|
+
using the Font Software.
|
|
103
|
+
|
|
104
|
+
TERMINATION
|
|
105
|
+
This license becomes null and void if any of the above conditions are
|
|
106
|
+
not met.
|
|
107
|
+
|
|
108
|
+
DISCLAIMER
|
|
109
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
110
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
111
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
112
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
113
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
114
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
115
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
116
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
117
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
118
|
+
|
|
119
|
+
--------------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
# Code: MIT License (https://opensource.org/licenses/MIT)
|
|
122
|
+
|
|
123
|
+
In the Font Awesome Free download, the MIT license applies to all non-font and
|
|
124
|
+
non-icon files.
|
|
125
|
+
|
|
126
|
+
Copyright 2023 Fonticons, Inc.
|
|
127
|
+
|
|
128
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
129
|
+
this software and associated documentation files (the "Software"), to deal in the
|
|
130
|
+
Software without restriction, including without limitation the rights to use, copy,
|
|
131
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
132
|
+
and to permit persons to whom the Software is furnished to do so, subject to the
|
|
133
|
+
following conditions:
|
|
134
|
+
|
|
135
|
+
The above copyright notice and this permission notice shall be included in all
|
|
136
|
+
copies or substantial portions of the Software.
|
|
137
|
+
|
|
138
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
139
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
140
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
141
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
142
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
143
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
144
|
+
|
|
145
|
+
--------------------------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
# Attribution
|
|
148
|
+
|
|
149
|
+
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
|
|
150
|
+
Awesome Free files already contain embedded comments with sufficient
|
|
151
|
+
attribution, so you shouldn't need to do anything additional when using these
|
|
152
|
+
files normally.
|
|
153
|
+
|
|
154
|
+
We've kept attribution comments terse, so we ask that you do not actively work
|
|
155
|
+
to remove them from files, especially code. They're a great way for folks to
|
|
156
|
+
learn about Font Awesome.
|
|
157
|
+
|
|
158
|
+
--------------------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
# Brand Icons
|
|
161
|
+
|
|
162
|
+
All brand icons are trademarks of their respective owners. The use of these
|
|
163
|
+
trademarks does not indicate endorsement of the trademark holder by Font
|
|
164
|
+
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
|
|
165
|
+
to represent the company, product, or service to which they refer.**
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# ../fontawesome-svg-core - SVG with JavaScript version
|
|
2
|
+
|
|
3
|
+
> "I came here to chew bubblegum and install Font Awesome 6 - and I'm all out of bubblegum"
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/../fontawesome-svg-core)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
$ npm i --save ../fontawesome-svg-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
$ yarn add ../fontawesome-svg-core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
Get started [here](https://fontawesome.com/how-to-use/on-the-web/setup/getting-started). Continue your journey [here](https://fontawesome.com/how-to-use/on-the-web/advanced).
|
|
22
|
+
|
|
23
|
+
Or go straight to the [API documentation](https://fontawesome.com/how-to-use/with-the-api).
|
|
24
|
+
|
|
25
|
+
## Issues and support
|
|
26
|
+
|
|
27
|
+
Start with [GitHub issues](https://github.com/FortAwesome/Font-Awesome/issues) and ping us on [Twitter](https://twitter.com/fontawesome) if you need to.
|
package/attribution.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IconDefinition,
|
|
3
|
+
IconName,
|
|
4
|
+
IconStyle,
|
|
5
|
+
IconFamily
|
|
6
|
+
} from '../fontawesome-common-types';
|
|
7
|
+
|
|
8
|
+
export type IconMacroParams = {
|
|
9
|
+
name: IconName,
|
|
10
|
+
style?: IconStyle,
|
|
11
|
+
family?: IconFamily
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function brands(iconName: IconName): IconDefinition;
|
|
15
|
+
export function duotone(iconName: IconName): IconDefinition;
|
|
16
|
+
export function light(iconName: IconName): IconDefinition;
|
|
17
|
+
export function regular(iconName: IconName): IconDefinition;
|
|
18
|
+
export function solid(iconName: IconName): IconDefinition;
|
|
19
|
+
export function thin(iconName: IconName): IconDefinition;
|
|
20
|
+
export function icon(params: IconMacroParams): IconDefinition;
|
package/import.macro.js
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
const { createMacro, MacroError } = require('babel-plugin-macros');
|
|
2
|
+
const { addNamed } = require('@babel/helper-module-imports');
|
|
3
|
+
|
|
4
|
+
module.exports = createMacro(importer, {
|
|
5
|
+
configName: 'fontawesome-svg-core',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const styles = ['solid', 'regular', 'light', 'thin', 'duotone', 'brands'];
|
|
9
|
+
|
|
10
|
+
const macroNames = [...styles, 'icon'];
|
|
11
|
+
|
|
12
|
+
const families = ['classic', 'duotone', 'sharp'];
|
|
13
|
+
|
|
14
|
+
function importer({ references, state, babel, source, config }) {
|
|
15
|
+
const license = config !== undefined ? config.license : 'free';
|
|
16
|
+
|
|
17
|
+
if (!['free', 'pro'].includes(license)) {
|
|
18
|
+
throw new Error("config license must be either 'free' or 'pro'");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.keys(references).forEach((key) => {
|
|
22
|
+
replace({
|
|
23
|
+
macroName: key,
|
|
24
|
+
license,
|
|
25
|
+
references: references[key],
|
|
26
|
+
state,
|
|
27
|
+
babel,
|
|
28
|
+
source,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function replace({ macroName, license, references, state, babel, source }) {
|
|
34
|
+
references.forEach((nodePath) => {
|
|
35
|
+
const { iconName, style, family } = resolveReplacement({ nodePath, babel, state, macroName });
|
|
36
|
+
|
|
37
|
+
const name = `fa${capitalize(camelCase(iconName))}`;
|
|
38
|
+
const importFrom = getImport({ family, style, license, name });
|
|
39
|
+
|
|
40
|
+
const importName = addNamed(nodePath, name, importFrom);
|
|
41
|
+
|
|
42
|
+
nodePath.parentPath.replaceWith(importName);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getImport({ family, style, license, name }) {
|
|
47
|
+
if (family) {
|
|
48
|
+
return `../${family.toLowerCase()}-${style}-svg-icons/${name}`;
|
|
49
|
+
} else if (style === 'brands') {
|
|
50
|
+
return `../free-brands-svg-icons/${name}`;
|
|
51
|
+
} else {
|
|
52
|
+
return `../${license}-${style}-svg-icons/${name}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolveReplacement({ nodePath, babel, state, macroName }) {
|
|
57
|
+
if ('icon' === macroName) {
|
|
58
|
+
return resolveReplacementIcon({ nodePath, babel, state, macroName });
|
|
59
|
+
} else {
|
|
60
|
+
return resolveReplacementLegacyStyle({ nodePath, babel, state, macroName });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// The macros corresonding to legacy style names: solid(), regular(), light(), thin(), duotone(), brands().
|
|
65
|
+
function resolveReplacementLegacyStyle({ nodePath, babel, state, macroName }) {
|
|
66
|
+
const { types: t } = babel;
|
|
67
|
+
const { parentPath } = nodePath;
|
|
68
|
+
|
|
69
|
+
if (!styles.includes(macroName)) {
|
|
70
|
+
throw parentPath.buildCodeFrameError(
|
|
71
|
+
`${macroName} is not a valid macro name. Use one of ${macroNames.join(', ')}`,
|
|
72
|
+
MacroError,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (parentPath.node.arguments) {
|
|
77
|
+
if (parentPath.node.arguments.length < 1) {
|
|
78
|
+
throw parentPath.buildCodeFrameError(
|
|
79
|
+
`Received an invalid number of arguments for ${macroName} macro: must be exactly 1`,
|
|
80
|
+
MacroError,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (parentPath.node.arguments.length > 1) {
|
|
85
|
+
throw parentPath.buildCodeFrameError(
|
|
86
|
+
`Received an invalid number of arguments for ${macroName} macro: must be exactly 1`,
|
|
87
|
+
MacroError,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
(parentPath.node.arguments.length === 1 || parentPath.node.arguments.length === 2) &&
|
|
93
|
+
t.isStringLiteral(parentPath.node.arguments[0]) &&
|
|
94
|
+
nodePath.parentPath.node.arguments[0].value.startsWith('fa-')
|
|
95
|
+
) {
|
|
96
|
+
throw parentPath.buildCodeFrameError(
|
|
97
|
+
`Don't begin the icon name with fa-, just use ${nodePath.parentPath.node.arguments[0].value.slice(
|
|
98
|
+
3,
|
|
99
|
+
)}`,
|
|
100
|
+
MacroError,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
(parentPath.node.arguments.length === 1 || parentPath.node.arguments.length === 2) &&
|
|
106
|
+
!t.isStringLiteral(parentPath.node.arguments[0])
|
|
107
|
+
) {
|
|
108
|
+
throw parentPath.buildCodeFrameError(
|
|
109
|
+
'Only string literals are supported when referencing icons (use a string here instead)',
|
|
110
|
+
MacroError,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
throw parentPath.buildCodeFrameError(
|
|
115
|
+
'Pass the icon name you would like to import as an argument.',
|
|
116
|
+
MacroError,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
iconName: nodePath.parentPath.node.arguments[0].value,
|
|
122
|
+
style: macroName,
|
|
123
|
+
family: undefined,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// The icon() macro.
|
|
128
|
+
function resolveReplacementIcon({ nodePath, babel, state, macroName }) {
|
|
129
|
+
const { types: t } = babel;
|
|
130
|
+
const { parentPath } = nodePath;
|
|
131
|
+
|
|
132
|
+
if ('icon' !== macroName) {
|
|
133
|
+
throw parentPath.buildCodeFrameError(
|
|
134
|
+
`${macroName} is not a valid macro name. Use one of ${macroNames.join(', ')}`,
|
|
135
|
+
MacroError,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (parentPath.node.arguments.length !== 1) {
|
|
140
|
+
throw parentPath.buildCodeFrameError(
|
|
141
|
+
`Received an invalid number of arguments for ${macroName} macro: must be exactly 1`,
|
|
142
|
+
MacroError,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!t.isObjectExpression(parentPath.node.arguments[0])) {
|
|
147
|
+
throw parentPath.buildCodeFrameError(
|
|
148
|
+
"Only object expressions are supported when referencing icons with this macro, like this: { name: 'star' }",
|
|
149
|
+
MacroError,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const properties = parentPath.node.arguments[0].properties || [];
|
|
154
|
+
|
|
155
|
+
const namePropIndex = properties.findIndex((prop) => 'name' === prop.key.name);
|
|
156
|
+
|
|
157
|
+
const name =
|
|
158
|
+
namePropIndex >= 0
|
|
159
|
+
? getStringLiteralPropertyValue(
|
|
160
|
+
t,
|
|
161
|
+
parentPath,
|
|
162
|
+
parentPath.node.arguments[0].properties[namePropIndex],
|
|
163
|
+
)
|
|
164
|
+
: undefined;
|
|
165
|
+
|
|
166
|
+
if (!name) {
|
|
167
|
+
throw parentPath.buildCodeFrameError(
|
|
168
|
+
'The object argument to the icon() macro must have a name property',
|
|
169
|
+
MacroError,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const stylePropIndex = properties.findIndex((prop) => 'style' === prop.key.name);
|
|
174
|
+
|
|
175
|
+
let style =
|
|
176
|
+
stylePropIndex >= 0
|
|
177
|
+
? getStringLiteralPropertyValue(
|
|
178
|
+
t,
|
|
179
|
+
parentPath,
|
|
180
|
+
parentPath.node.arguments[0].properties[stylePropIndex],
|
|
181
|
+
)
|
|
182
|
+
: undefined;
|
|
183
|
+
|
|
184
|
+
if (style && !styles.includes(style)) {
|
|
185
|
+
throw parentPath.buildCodeFrameError(
|
|
186
|
+
`Invalid style name: ${style}. It must be one of the following: ${styles.join(', ')}`,
|
|
187
|
+
MacroError,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const familyPropIndex = properties.findIndex((prop) => 'family' === prop.key.name);
|
|
192
|
+
|
|
193
|
+
let family =
|
|
194
|
+
familyPropIndex >= 0
|
|
195
|
+
? getStringLiteralPropertyValue(
|
|
196
|
+
t,
|
|
197
|
+
parentPath,
|
|
198
|
+
parentPath.node.arguments[0].properties[familyPropIndex],
|
|
199
|
+
)
|
|
200
|
+
: undefined;
|
|
201
|
+
|
|
202
|
+
if (family && !families.includes(family)) {
|
|
203
|
+
throw parentPath.buildCodeFrameError(
|
|
204
|
+
`Invalid family name: ${family}. It must be one of the following: ${families.join(', ')}`,
|
|
205
|
+
MacroError,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if ('duotone' === style && family && 'classic' !== family) {
|
|
210
|
+
throw parentPath.buildCodeFrameError(
|
|
211
|
+
`duotone cannot be used as a style name with any family other than classic`,
|
|
212
|
+
MacroError,
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if ('brands' === style && family && 'classic' !== family) {
|
|
217
|
+
throw parentPath.buildCodeFrameError(
|
|
218
|
+
`brands cannot be used as a style name with any family other than classic`,
|
|
219
|
+
MacroError,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (family && !style) {
|
|
224
|
+
throw parentPath.buildCodeFrameError(
|
|
225
|
+
`When a family is specified, a style must also be specified`,
|
|
226
|
+
MacroError,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if ('duotone' === style || 'duotone' === family) {
|
|
231
|
+
family = undefined;
|
|
232
|
+
style = 'duotone';
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if ('brands' === style) {
|
|
236
|
+
family = undefined;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// defaults
|
|
240
|
+
if (!style) {
|
|
241
|
+
style = 'solid';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if ('classic' === family) {
|
|
245
|
+
family = undefined;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
iconName: name,
|
|
250
|
+
family,
|
|
251
|
+
style,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function getStringLiteralPropertyValue(t, parentPath, property) {
|
|
256
|
+
if (!('object' === typeof t && 'function' === typeof t.isStringLiteral)) {
|
|
257
|
+
throw Error(
|
|
258
|
+
'ERROR: invalid babel-types arg. This is probably a programming error in import.macro',
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (
|
|
263
|
+
!(
|
|
264
|
+
'object' === typeof property &&
|
|
265
|
+
'object' === typeof property.value &&
|
|
266
|
+
'object' === typeof property.key
|
|
267
|
+
)
|
|
268
|
+
) {
|
|
269
|
+
throw Error(
|
|
270
|
+
'ERROR: invalid babel property arg. This is probably a programming error in import.macro',
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (!('object' === typeof parentPath && 'function' === typeof parentPath.buildCodeFrameError)) {
|
|
275
|
+
throw Error(
|
|
276
|
+
'ERROR: invalid babel parentPath arg. This is probably a programming error in import.macro',
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (!t.isStringLiteral(property.value)) {
|
|
281
|
+
throw parentPath.buildCodeFrameError(
|
|
282
|
+
`Only string literals are supported for the ${property.key.name} property (use a string here instead)`,
|
|
283
|
+
MacroError,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return property.value.value;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function capitalize(str) {
|
|
291
|
+
return str[0].toUpperCase() + str.slice(1);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function camelCase(str) {
|
|
295
|
+
return str
|
|
296
|
+
.split('-')
|
|
297
|
+
.map((s, index) => {
|
|
298
|
+
return (index === 0 ? s[0].toLowerCase() : s[0].toUpperCase()) + s.slice(1).toLowerCase();
|
|
299
|
+
})
|
|
300
|
+
.join('');
|
|
301
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {IconDefinition, IconLookup, IconName, IconFamily, IconPrefix, CssStyleClass, IconStyle, IconPathData, IconPack} from '../fontawesome-common-types';
|
|
2
|
+
export {IconDefinition, IconLookup, IconName, IconFamily, IconPrefix, CssStyleClass, IconStyle, IconPathData, IconPack} from '../fontawesome-common-types';
|
|
3
|
+
export const dom: DOM;
|
|
4
|
+
export const library: Library;
|
|
5
|
+
export const parse: { transform(transformString: string): Transform, icon(parseIconString: string): IconLookup };
|
|
6
|
+
export const config: Config;
|
|
7
|
+
export function noAuto():void;
|
|
8
|
+
export function findIconDefinition(iconLookup: IconLookup): IconDefinition;
|
|
9
|
+
export function text(content: string, params?: TextParams): Text;
|
|
10
|
+
export function counter(content: string | number, params?: CounterParams): Counter;
|
|
11
|
+
export function toHtml(content: any): string;
|
|
12
|
+
export function toHtml(abstractNodes: AbstractElement): string;
|
|
13
|
+
export function layer(
|
|
14
|
+
assembler: (
|
|
15
|
+
addLayerCallback: (layerToAdd: IconOrText | IconOrText[]) => void
|
|
16
|
+
) => void,
|
|
17
|
+
params?: LayerParams
|
|
18
|
+
): Layer;
|
|
19
|
+
export function icon(icon: IconName | IconLookup, params?: IconParams): Icon;
|
|
20
|
+
export type IconProp = IconName | [IconPrefix, IconName] | IconLookup;
|
|
21
|
+
export type FlipProp = "horizontal" | "vertical" | "both";
|
|
22
|
+
export type SizeProp =
|
|
23
|
+
| "2xs"
|
|
24
|
+
| "xs"
|
|
25
|
+
| "sm"
|
|
26
|
+
| "lg"
|
|
27
|
+
| "xl"
|
|
28
|
+
| "2xl"
|
|
29
|
+
| "1x"
|
|
30
|
+
| "2x"
|
|
31
|
+
| "3x"
|
|
32
|
+
| "4x"
|
|
33
|
+
| "5x"
|
|
34
|
+
| "6x"
|
|
35
|
+
| "7x"
|
|
36
|
+
| "8x"
|
|
37
|
+
| "9x"
|
|
38
|
+
| "10x";
|
|
39
|
+
export type PullProp = "left" | "right";
|
|
40
|
+
export type RotateProp = 90 | 180 | 270;
|
|
41
|
+
export type FaSymbol = string | boolean;
|
|
42
|
+
export interface Config {
|
|
43
|
+
familyPrefix: string;
|
|
44
|
+
cssPrefix: string;
|
|
45
|
+
styleDefault: IconPrefix | CssStyleClass | IconStyle;
|
|
46
|
+
familyDefault: IconFamily;
|
|
47
|
+
replacementClass: string;
|
|
48
|
+
autoReplaceSvg: boolean | 'nest';
|
|
49
|
+
autoAddCss: boolean;
|
|
50
|
+
autoA11y: boolean;
|
|
51
|
+
searchPseudoElements: boolean;
|
|
52
|
+
observeMutations: boolean;
|
|
53
|
+
keepOriginalSource: boolean;
|
|
54
|
+
measurePerformance: boolean;
|
|
55
|
+
showMissingIcons: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface AbstractElement {
|
|
58
|
+
tag: string;
|
|
59
|
+
attributes: any;
|
|
60
|
+
children?: AbstractElement[];
|
|
61
|
+
}
|
|
62
|
+
export interface FontawesomeObject {
|
|
63
|
+
readonly abstract: AbstractElement[];
|
|
64
|
+
readonly html: string[];
|
|
65
|
+
readonly node: HTMLCollection;
|
|
66
|
+
}
|
|
67
|
+
export interface Icon extends FontawesomeObject, IconDefinition {
|
|
68
|
+
readonly type: "icon";
|
|
69
|
+
}
|
|
70
|
+
export interface Text extends FontawesomeObject {
|
|
71
|
+
readonly type: "text";
|
|
72
|
+
}
|
|
73
|
+
export interface Counter extends FontawesomeObject {
|
|
74
|
+
readonly type: "counter";
|
|
75
|
+
}
|
|
76
|
+
export interface Layer extends FontawesomeObject {
|
|
77
|
+
readonly type: "layer";
|
|
78
|
+
}
|
|
79
|
+
type IconOrText = Icon | Text;
|
|
80
|
+
export interface Attributes {
|
|
81
|
+
[key: string]: number | string;
|
|
82
|
+
}
|
|
83
|
+
export interface Styles {
|
|
84
|
+
[key: string]: string;
|
|
85
|
+
}
|
|
86
|
+
export interface Transform {
|
|
87
|
+
size?: number;
|
|
88
|
+
x?: number;
|
|
89
|
+
y?: number;
|
|
90
|
+
rotate?: number;
|
|
91
|
+
flipX?: boolean;
|
|
92
|
+
flipY?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface Params {
|
|
95
|
+
title?: string;
|
|
96
|
+
titleId?: string;
|
|
97
|
+
classes?: string | string[];
|
|
98
|
+
attributes?: Attributes;
|
|
99
|
+
styles?: Styles;
|
|
100
|
+
}
|
|
101
|
+
export interface CounterParams extends Params {
|
|
102
|
+
}
|
|
103
|
+
export interface LayerParams {
|
|
104
|
+
classes?: string | string[];
|
|
105
|
+
}
|
|
106
|
+
export interface TextParams extends Params {
|
|
107
|
+
transform?: Transform;
|
|
108
|
+
}
|
|
109
|
+
export interface IconParams extends Params {
|
|
110
|
+
transform?: Transform;
|
|
111
|
+
symbol?: FaSymbol;
|
|
112
|
+
mask?: IconLookup;
|
|
113
|
+
maskId?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface DOM {
|
|
116
|
+
i2svg(params?: { node: Node; callback?: () => void }): Promise<void>;
|
|
117
|
+
css(): string;
|
|
118
|
+
insertCss(): string;
|
|
119
|
+
watch(): void;
|
|
120
|
+
}
|
|
121
|
+
type IconDefinitionOrPack = IconDefinition | IconPack;
|
|
122
|
+
export interface Library {
|
|
123
|
+
add(...definitions: IconDefinitionOrPack[]): void;
|
|
124
|
+
reset(): void;
|
|
125
|
+
}
|