@iconify/tools 2.0.18 → 2.1.0-beta.3
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/lib/colors/parse.d.ts +2 -2
- package/lib/colors/validate.d.ts +2 -2
- package/lib/download/git/branch.cjs +2 -3
- package/lib/download/git/branch.mjs +2 -3
- package/lib/download/git/hash.cjs +1 -0
- package/lib/download/git/hash.mjs +1 -0
- package/lib/download/git/index.cjs +4 -3
- package/lib/download/git/index.mjs +4 -3
- package/lib/download/git/reset.cjs +4 -3
- package/lib/download/git/reset.mjs +4 -3
- package/lib/download/index.cjs +4 -3
- package/lib/download/index.mjs +4 -3
- package/lib/download/npm/index.cjs +1 -0
- package/lib/download/npm/index.mjs +1 -0
- package/lib/download/npm/version.cjs +1 -0
- package/lib/download/npm/version.mjs +1 -0
- package/lib/export/directory.d.ts +3 -2
- package/lib/export/helpers/types-version.cjs +3 -13
- package/lib/export/helpers/types-version.mjs +3 -13
- package/lib/export/icon-package.cjs +1 -3
- package/lib/export/icon-package.d.ts +3 -2
- package/lib/export/icon-package.mjs +1 -3
- package/lib/export/json-package.cjs +3 -5
- package/lib/export/json-package.d.ts +3 -2
- package/lib/export/json-package.mjs +3 -5
- package/lib/icon-set/index.cjs +94 -103
- package/lib/icon-set/index.d.ts +22 -4
- package/lib/icon-set/index.mjs +95 -104
- package/lib/icon-set/match.cjs +5 -5
- package/lib/icon-set/match.d.ts +4 -3
- package/lib/icon-set/match.mjs +2 -2
- package/lib/icon-set/merge.cjs +10 -3
- package/lib/icon-set/merge.d.ts +3 -2
- package/lib/icon-set/merge.mjs +10 -3
- package/lib/icon-set/modified.cjs +27 -0
- package/lib/icon-set/modified.d.ts +15 -0
- package/lib/icon-set/modified.mjs +23 -0
- package/lib/icon-set/props.cjs +8 -18
- package/lib/icon-set/props.d.ts +5 -6
- package/lib/icon-set/props.mjs +9 -18
- package/lib/icon-set/types.d.ts +1 -1
- package/lib/import/directory.cjs +4 -3
- package/lib/import/directory.d.ts +3 -2
- package/lib/import/directory.mjs +4 -3
- package/lib/import/figma/index.cjs +4 -3
- package/lib/import/figma/index.d.ts +3 -2
- package/lib/import/figma/index.mjs +4 -3
- package/lib/import/figma/nodes.d.ts +3 -2
- package/lib/import/figma/query.d.ts +3 -2
- package/lib/import/figma/types/nodes.d.ts +3 -2
- package/lib/import/figma/types/options.d.ts +3 -2
- package/lib/import/figma/types/result.d.ts +3 -2
- package/lib/index.cjs +5 -4
- package/lib/index.d.ts +4 -2
- package/lib/index.mjs +5 -4
- package/lib/misc/bump-version.cjs +2 -2
- package/lib/misc/bump-version.mjs +2 -2
- package/lib/misc/cheerio.cjs +2 -0
- package/lib/misc/cheerio.d.ts +7 -0
- package/lib/misc/cheerio.mjs +1 -0
- package/lib/misc/exec.cjs +7 -2
- package/lib/misc/exec.mjs +7 -2
- package/lib/optimise/flags.cjs +8 -8
- package/lib/optimise/flags.d.ts +2 -2
- package/lib/optimise/flags.mjs +8 -8
- package/lib/optimise/global-style.d.ts +2 -2
- package/lib/optimise/scale.cjs +3 -3
- package/lib/optimise/scale.d.ts +3 -3
- package/lib/optimise/scale.mjs +3 -3
- package/lib/optimise/svgo.cjs +1 -1
- package/lib/optimise/svgo.d.ts +3 -3
- package/lib/optimise/svgo.mjs +1 -1
- package/lib/svg/analyse.d.ts +2 -2
- package/lib/svg/cleanup/attribs.d.ts +2 -2
- package/lib/svg/cleanup/bad-tags.d.ts +2 -2
- package/lib/svg/cleanup/inline-style.d.ts +2 -2
- package/lib/svg/cleanup/root-svg.d.ts +2 -2
- package/lib/svg/cleanup/svgo-style.cjs +1 -1
- package/lib/svg/cleanup/svgo-style.d.ts +2 -2
- package/lib/svg/cleanup/svgo-style.mjs +1 -1
- package/lib/svg/cleanup.d.ts +2 -2
- package/lib/svg/index.cjs +9 -9
- package/lib/svg/index.d.ts +4 -4
- package/lib/svg/index.mjs +10 -10
- package/lib/svg/parse-style.d.ts +3 -2
- package/lib/svg/parse.d.ts +4 -8
- package/lib/types-f0980297.d.ts +258 -0
- package/package.json +10 -3
package/lib/icon-set/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultIconDimensions, defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
|
2
2
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
|
3
|
-
import {
|
|
3
|
+
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
4
4
|
import { minifyIconSet } from '@iconify/utils/lib/icon-set/minify';
|
|
5
5
|
import { convertIconSetInfo } from '@iconify/utils/lib/icon-set/convert-info';
|
|
6
|
-
import { filterProps,
|
|
6
|
+
import { filterProps, defaultCommonProps } from './props.mjs';
|
|
7
7
|
import { SVG } from '../svg/index.mjs';
|
|
8
|
+
import { mergeIconData } from '@iconify/utils';
|
|
9
|
+
import '@iconify/utils/lib/misc/objects';
|
|
8
10
|
import 'cheerio';
|
|
9
|
-
import '@iconify/utils';
|
|
10
11
|
|
|
11
|
-
const maxIteration = 6;
|
|
12
12
|
const themeKeys = ["prefixes", "suffixes"];
|
|
13
13
|
function sortThemeKeys(keys) {
|
|
14
14
|
return keys.sort((a, b) => a.length === b.length ? a.localeCompare(b) : b.length - a.length);
|
|
@@ -19,7 +19,7 @@ class IconSet {
|
|
|
19
19
|
}
|
|
20
20
|
load(data) {
|
|
21
21
|
this.prefix = data.prefix;
|
|
22
|
-
const defaultProps = filterProps(data, true);
|
|
22
|
+
const defaultProps = filterProps(data, defaultIconDimensions, true);
|
|
23
23
|
this.entries = /* @__PURE__ */ Object.create(null);
|
|
24
24
|
const entries = this.entries;
|
|
25
25
|
for (const name in data.icons) {
|
|
@@ -30,7 +30,7 @@ class IconSet {
|
|
|
30
30
|
props: filterProps({
|
|
31
31
|
...defaultProps,
|
|
32
32
|
...item
|
|
33
|
-
}, true),
|
|
33
|
+
}, defaultCommonProps, true),
|
|
34
34
|
chars: /* @__PURE__ */ new Set(),
|
|
35
35
|
categories: /* @__PURE__ */ new Set()
|
|
36
36
|
};
|
|
@@ -43,7 +43,7 @@ class IconSet {
|
|
|
43
43
|
}
|
|
44
44
|
const item = data.aliases[name];
|
|
45
45
|
const parent = item.parent;
|
|
46
|
-
const props = filterProps(item, false);
|
|
46
|
+
const props = filterProps(item, defaultCommonProps, false);
|
|
47
47
|
const chars = /* @__PURE__ */ new Set();
|
|
48
48
|
if (Object.keys(props).length) {
|
|
49
49
|
const entry = {
|
|
@@ -120,6 +120,10 @@ class IconSet {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
|
+
this.lastModified = data.lastModified || 0;
|
|
124
|
+
}
|
|
125
|
+
updateLastModified(value) {
|
|
126
|
+
this.lastModified = value || Math.floor(Date.now() / 1e3);
|
|
123
127
|
}
|
|
124
128
|
list(types = ["icon", "variation"]) {
|
|
125
129
|
return Object.keys(this.entries).filter((name) => {
|
|
@@ -143,60 +147,53 @@ class IconSet {
|
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
|
-
|
|
150
|
+
getTree(names) {
|
|
147
151
|
const entries = this.entries;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
const resolved = /* @__PURE__ */ Object.create(null);
|
|
153
|
+
function resolve(name) {
|
|
154
|
+
const item = entries[name];
|
|
155
|
+
if (!item) {
|
|
156
|
+
return resolved[name] = null;
|
|
151
157
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
case "alias":
|
|
162
|
-
return getIcon(item.parent, iteration + 1);
|
|
163
|
-
case "variation": {
|
|
164
|
-
const parent = getIcon(item.parent, iteration + 1);
|
|
165
|
-
if (!parent) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
for (const key in item.props) {
|
|
169
|
-
const attr = key;
|
|
170
|
-
const value = item.props[attr];
|
|
171
|
-
if (value) {
|
|
172
|
-
if (parent[attr] === void 0) {
|
|
173
|
-
parent[attr] = value;
|
|
174
|
-
} else {
|
|
175
|
-
switch (attr) {
|
|
176
|
-
case "rotate":
|
|
177
|
-
parent[attr] = (parent[attr] + value) % 4;
|
|
178
|
-
break;
|
|
179
|
-
case "hFlip":
|
|
180
|
-
case "vFlip":
|
|
181
|
-
parent[attr] = !parent[attr];
|
|
182
|
-
break;
|
|
183
|
-
default:
|
|
184
|
-
parent[attr] = value;
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return parent;
|
|
158
|
+
if (item.type === "icon") {
|
|
159
|
+
return resolved[name] = [];
|
|
160
|
+
}
|
|
161
|
+
if (resolved[name] === void 0) {
|
|
162
|
+
resolved[name] = null;
|
|
163
|
+
const parent = item.parent;
|
|
164
|
+
const value = parent && resolve(parent);
|
|
165
|
+
if (value) {
|
|
166
|
+
resolved[name] = [parent].concat(value);
|
|
191
167
|
}
|
|
192
|
-
|
|
193
|
-
|
|
168
|
+
}
|
|
169
|
+
return resolved[name];
|
|
170
|
+
}
|
|
171
|
+
(names || Object.keys(entries)).forEach(resolve);
|
|
172
|
+
return resolved;
|
|
173
|
+
}
|
|
174
|
+
resolve(name, full = false) {
|
|
175
|
+
const entries = this.entries;
|
|
176
|
+
const item = entries[name];
|
|
177
|
+
const tree = item && (item.type === "icon" ? [] : this.getTree([name])[name]);
|
|
178
|
+
if (!tree) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
let result = {};
|
|
182
|
+
function parse(name2) {
|
|
183
|
+
const item2 = entries[name2];
|
|
184
|
+
if (item2.type === "alias") {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
result = mergeIconData(item2.props, result);
|
|
188
|
+
if (item2.type === "icon") {
|
|
189
|
+
result.body = item2.body;
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
|
-
|
|
197
|
-
|
|
192
|
+
parse(name);
|
|
193
|
+
tree.forEach(parse);
|
|
194
|
+
return result && full ? { ...defaultIconProps, ...result } : result;
|
|
198
195
|
}
|
|
199
|
-
toString(name,
|
|
196
|
+
toString(name, customisations = {
|
|
200
197
|
width: "auto",
|
|
201
198
|
height: "auto"
|
|
202
199
|
}) {
|
|
@@ -205,8 +202,8 @@ class IconSet {
|
|
|
205
202
|
return null;
|
|
206
203
|
}
|
|
207
204
|
const result = iconToSVG(item, {
|
|
208
|
-
...
|
|
209
|
-
...
|
|
205
|
+
...defaultIconCustomisations,
|
|
206
|
+
...customisations
|
|
210
207
|
});
|
|
211
208
|
const attributes = Object.keys(result.attributes).map((key) => ` ${key}="${result.attributes[key]}"`).join("");
|
|
212
209
|
return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"${attributes}>${result.body}</svg>`;
|
|
@@ -218,6 +215,7 @@ class IconSet {
|
|
|
218
215
|
export(validate = true) {
|
|
219
216
|
const icons = /* @__PURE__ */ Object.create(null);
|
|
220
217
|
const aliases = /* @__PURE__ */ Object.create(null);
|
|
218
|
+
const tree = validate ? this.getTree() : /* @__PURE__ */ Object.create(null);
|
|
221
219
|
const names = Object.keys(this.entries);
|
|
222
220
|
names.sort((a, b) => a.localeCompare(b));
|
|
223
221
|
names.forEach((name) => {
|
|
@@ -233,7 +231,7 @@ class IconSet {
|
|
|
233
231
|
}
|
|
234
232
|
case "alias":
|
|
235
233
|
case "variation": {
|
|
236
|
-
if (validate && !
|
|
234
|
+
if (validate && !tree[name]) {
|
|
237
235
|
break;
|
|
238
236
|
}
|
|
239
237
|
const props = item.type === "variation" ? item.props : {};
|
|
@@ -257,6 +255,9 @@ class IconSet {
|
|
|
257
255
|
if (info) {
|
|
258
256
|
result.info = info;
|
|
259
257
|
}
|
|
258
|
+
if (this.lastModified) {
|
|
259
|
+
result.lastModified = this.lastModified;
|
|
260
|
+
}
|
|
260
261
|
result.icons = icons;
|
|
261
262
|
if (Object.keys(aliases).length) {
|
|
262
263
|
result.aliases = aliases;
|
|
@@ -379,51 +380,45 @@ class IconSet {
|
|
|
379
380
|
}
|
|
380
381
|
remove(name, removeDependencies = true) {
|
|
381
382
|
const entries = this.entries;
|
|
382
|
-
const names = /* @__PURE__ */ new Set();
|
|
383
383
|
if (typeof removeDependencies === "string") {
|
|
384
|
-
|
|
384
|
+
const item2 = entries[removeDependencies];
|
|
385
|
+
if (name === removeDependencies || item2?.type !== "icon") {
|
|
385
386
|
return 0;
|
|
386
387
|
}
|
|
387
|
-
names.add(removeDependencies);
|
|
388
388
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
names.add(name2);
|
|
394
|
-
if (removeDependencies === true || !iteration && typeof removeDependencies === "string") {
|
|
395
|
-
for (const key in entries) {
|
|
396
|
-
const item = entries[key];
|
|
397
|
-
switch (item.type) {
|
|
398
|
-
case "icon":
|
|
399
|
-
break;
|
|
400
|
-
case "alias":
|
|
401
|
-
case "variation":
|
|
402
|
-
if (item.parent === name2) {
|
|
403
|
-
if (removeDependencies === true) {
|
|
404
|
-
if (!del(key, iteration + 1)) {
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
break;
|
|
408
|
-
}
|
|
409
|
-
item.parent = removeDependencies;
|
|
410
|
-
}
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
return true;
|
|
389
|
+
const item = entries[name];
|
|
390
|
+
if (!item) {
|
|
391
|
+
return 0;
|
|
416
392
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
393
|
+
this.updateLastModified();
|
|
394
|
+
if (typeof removeDependencies === "string") {
|
|
395
|
+
for (const key in entries) {
|
|
396
|
+
const item2 = entries[key];
|
|
397
|
+
if (item2.type !== "icon" && item2.parent === name) {
|
|
398
|
+
item2.parent = removeDependencies;
|
|
399
|
+
}
|
|
420
400
|
}
|
|
421
|
-
|
|
422
|
-
|
|
401
|
+
return 0;
|
|
402
|
+
}
|
|
403
|
+
delete entries[name];
|
|
404
|
+
let count = 1;
|
|
405
|
+
function remove(parent) {
|
|
406
|
+
const list = Object.keys(entries).filter((name2) => {
|
|
407
|
+
const item2 = entries[name2];
|
|
408
|
+
return item2.type !== "icon" && item2.parent === parent;
|
|
423
409
|
});
|
|
424
|
-
|
|
410
|
+
list.forEach((name2) => {
|
|
411
|
+
if (entries[name2]) {
|
|
412
|
+
delete entries[name2];
|
|
413
|
+
count++;
|
|
414
|
+
remove(name2);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
if (removeDependencies === true) {
|
|
419
|
+
remove(name);
|
|
425
420
|
}
|
|
426
|
-
return
|
|
421
|
+
return count;
|
|
427
422
|
}
|
|
428
423
|
rename(oldName, newName) {
|
|
429
424
|
const entries = this.entries;
|
|
@@ -450,6 +445,7 @@ class IconSet {
|
|
|
450
445
|
break;
|
|
451
446
|
}
|
|
452
447
|
}
|
|
448
|
+
this.updateLastModified();
|
|
453
449
|
return true;
|
|
454
450
|
}
|
|
455
451
|
setItem(name, item) {
|
|
@@ -462,13 +458,14 @@ class IconSet {
|
|
|
462
458
|
}
|
|
463
459
|
}
|
|
464
460
|
this.entries[name] = item;
|
|
461
|
+
this.updateLastModified();
|
|
465
462
|
return true;
|
|
466
463
|
}
|
|
467
464
|
setIcon(name, icon) {
|
|
468
465
|
return this.setItem(name, {
|
|
469
466
|
type: "icon",
|
|
470
467
|
body: icon.body,
|
|
471
|
-
props: filterProps(icon, true),
|
|
468
|
+
props: filterProps(icon, defaultCommonProps, true),
|
|
472
469
|
chars: /* @__PURE__ */ new Set(),
|
|
473
470
|
categories: /* @__PURE__ */ new Set()
|
|
474
471
|
});
|
|
@@ -489,18 +486,12 @@ class IconSet {
|
|
|
489
486
|
});
|
|
490
487
|
}
|
|
491
488
|
fromSVG(name, svg) {
|
|
492
|
-
const props = svg.viewBox;
|
|
489
|
+
const props = { ...svg.viewBox };
|
|
493
490
|
const body = svg.getBody();
|
|
494
491
|
const item = this.entries[name];
|
|
495
492
|
switch (item?.type) {
|
|
496
493
|
case "icon":
|
|
497
494
|
case "variation": {
|
|
498
|
-
for (const key in extraDefaultProps) {
|
|
499
|
-
const prop = key;
|
|
500
|
-
if (item.props[prop]) {
|
|
501
|
-
props[prop] = item.props[prop];
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
495
|
return this.setItem(name, {
|
|
505
496
|
type: "icon",
|
|
506
497
|
body,
|
package/lib/icon-set/match.cjs
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const defaults = require('@iconify/utils/lib/icon/defaults');
|
|
6
6
|
|
|
7
7
|
const maxIteration = 5;
|
|
8
|
-
function findMatchingIcon(iconSet, icon
|
|
9
|
-
const body = icon
|
|
8
|
+
function findMatchingIcon(iconSet, icon) {
|
|
9
|
+
const body = icon.body;
|
|
10
10
|
let hiddenMatch = null;
|
|
11
11
|
function isMatching(data) {
|
|
12
|
-
for (const key in
|
|
12
|
+
for (const key in defaults.defaultIconProps) {
|
|
13
13
|
const attr = key;
|
|
14
|
-
if (data[attr] !== icon
|
|
14
|
+
if (data[attr] !== icon[attr]) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
}
|
package/lib/icon-set/match.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
|
1
|
+
import { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
|
|
2
2
|
import { IconSet } from './index.js';
|
|
3
|
-
import '
|
|
4
|
-
import '@iconify/utils/lib/customisations';
|
|
3
|
+
import '../types-f0980297.js';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
5
|
import './types.js';
|
|
6
6
|
import '../svg/index.js';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Find matching icon in icon set
|
package/lib/icon-set/match.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
|
2
2
|
|
|
3
3
|
const maxIteration = 5;
|
|
4
4
|
function findMatchingIcon(iconSet, icon) {
|
|
5
5
|
const body = icon.body;
|
|
6
6
|
let hiddenMatch = null;
|
|
7
7
|
function isMatching(data) {
|
|
8
|
-
for (const key in
|
|
8
|
+
for (const key in defaultIconProps) {
|
|
9
9
|
const attr = key;
|
|
10
10
|
if (data[attr] !== icon[attr]) {
|
|
11
11
|
return false;
|
package/lib/icon-set/merge.cjs
CHANGED
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const iconSet_index = require('./index.cjs');
|
|
6
6
|
const iconSet_match = require('./match.cjs');
|
|
7
|
-
require('
|
|
7
|
+
const iconSet_modified = require('./modified.cjs');
|
|
8
|
+
require('@iconify/utils/lib/icon/defaults');
|
|
8
9
|
require('@iconify/utils/lib/svg/build');
|
|
9
|
-
require('@iconify/utils/lib/customisations');
|
|
10
|
+
require('@iconify/utils/lib/customisations/defaults');
|
|
10
11
|
require('@iconify/utils/lib/icon-set/minify');
|
|
11
12
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
12
13
|
require('./props.cjs');
|
|
14
|
+
require('@iconify/utils/lib/misc/objects');
|
|
15
|
+
require('@iconify/utils');
|
|
13
16
|
require('../svg/index.cjs');
|
|
14
17
|
require('cheerio');
|
|
15
|
-
require('@iconify/utils');
|
|
16
18
|
|
|
17
19
|
function mergeIconSets(oldIcons, newIcons) {
|
|
18
20
|
const mergedIcons = new iconSet_index.IconSet(newIcons.export());
|
|
@@ -77,6 +79,11 @@ function mergeIconSets(oldIcons, newIcons) {
|
|
|
77
79
|
for (const name in oldEntries) {
|
|
78
80
|
add(name);
|
|
79
81
|
}
|
|
82
|
+
const lastModified1 = oldIcons.lastModified;
|
|
83
|
+
const lastModified2 = newIcons.lastModified;
|
|
84
|
+
if ((lastModified1 || lastModified2) && !iconSet_modified.hasIconDataBeenModified(oldIcons, newIcons)) {
|
|
85
|
+
mergedIcons.updateLastModified(lastModified2 ? lastModified1 ? Math.min(lastModified1, lastModified2) : lastModified2 : lastModified1);
|
|
86
|
+
}
|
|
80
87
|
return mergedIcons;
|
|
81
88
|
}
|
|
82
89
|
|
package/lib/icon-set/merge.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IconSet } from './index.js';
|
|
2
|
-
import '
|
|
3
|
-
import '@iconify/utils/lib/customisations';
|
|
2
|
+
import '../types-f0980297.js';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
4
|
import './types.js';
|
|
5
5
|
import '../svg/index.js';
|
|
6
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Merge icon sets
|
package/lib/icon-set/merge.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { IconSet } from './index.mjs';
|
|
2
2
|
import { findMatchingIcon } from './match.mjs';
|
|
3
|
-
import '
|
|
3
|
+
import { hasIconDataBeenModified } from './modified.mjs';
|
|
4
|
+
import '@iconify/utils/lib/icon/defaults';
|
|
4
5
|
import '@iconify/utils/lib/svg/build';
|
|
5
|
-
import '@iconify/utils/lib/customisations';
|
|
6
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
7
|
import '@iconify/utils/lib/icon-set/minify';
|
|
7
8
|
import '@iconify/utils/lib/icon-set/convert-info';
|
|
8
9
|
import './props.mjs';
|
|
10
|
+
import '@iconify/utils/lib/misc/objects';
|
|
11
|
+
import '@iconify/utils';
|
|
9
12
|
import '../svg/index.mjs';
|
|
10
13
|
import 'cheerio';
|
|
11
|
-
import '@iconify/utils';
|
|
12
14
|
|
|
13
15
|
function mergeIconSets(oldIcons, newIcons) {
|
|
14
16
|
const mergedIcons = new IconSet(newIcons.export());
|
|
@@ -73,6 +75,11 @@ function mergeIconSets(oldIcons, newIcons) {
|
|
|
73
75
|
for (const name in oldEntries) {
|
|
74
76
|
add(name);
|
|
75
77
|
}
|
|
78
|
+
const lastModified1 = oldIcons.lastModified;
|
|
79
|
+
const lastModified2 = newIcons.lastModified;
|
|
80
|
+
if ((lastModified1 || lastModified2) && !hasIconDataBeenModified(oldIcons, newIcons)) {
|
|
81
|
+
mergedIcons.updateLastModified(lastModified2 ? lastModified1 ? Math.min(lastModified1, lastModified2) : lastModified2 : lastModified1);
|
|
82
|
+
}
|
|
76
83
|
return mergedIcons;
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function hasIconDataBeenModified(set1, set2) {
|
|
6
|
+
const entries1 = set1.entries;
|
|
7
|
+
const entries2 = set2.entries;
|
|
8
|
+
const keys1 = Object.keys(entries1);
|
|
9
|
+
const keys2 = Object.keys(entries2);
|
|
10
|
+
if (keys1.length !== keys2.length) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
14
|
+
if (!entries2[keys1[i]]) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
19
|
+
const name = keys1[i];
|
|
20
|
+
if (set1.toString(name) !== set2.toString(name)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.hasIconDataBeenModified = hasIconDataBeenModified;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconSet } from './index.js';
|
|
2
|
+
import '../types-f0980297.js';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.js';
|
|
5
|
+
import '../svg/index.js';
|
|
6
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check if icons in an icon set were updated.
|
|
10
|
+
*
|
|
11
|
+
* This function checks only icons, not metadata. It also ignores icon visibility.
|
|
12
|
+
*/
|
|
13
|
+
declare function hasIconDataBeenModified(set1: IconSet, set2: IconSet): boolean;
|
|
14
|
+
|
|
15
|
+
export { hasIconDataBeenModified };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function hasIconDataBeenModified(set1, set2) {
|
|
2
|
+
const entries1 = set1.entries;
|
|
3
|
+
const entries2 = set2.entries;
|
|
4
|
+
const keys1 = Object.keys(entries1);
|
|
5
|
+
const keys2 = Object.keys(entries2);
|
|
6
|
+
if (keys1.length !== keys2.length) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
10
|
+
if (!entries2[keys1[i]]) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
15
|
+
const name = keys1[i];
|
|
16
|
+
if (set1.toString(name) !== set2.toString(name)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { hasIconDataBeenModified };
|
package/lib/icon-set/props.cjs
CHANGED
|
@@ -2,27 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const objects = require('@iconify/utils/lib/misc/objects');
|
|
6
|
+
const utils = require('@iconify/utils');
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
+
const defaultCommonProps = Object.freeze({
|
|
9
|
+
...utils.defaultIconProps,
|
|
8
10
|
hidden: false
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
const props = Object.keys(defaultCommonProps);
|
|
15
|
-
function filterProps(data, compareDefaultValues) {
|
|
16
|
-
const result = {};
|
|
17
|
-
props.forEach((attr) => {
|
|
18
|
-
const value = data[attr];
|
|
19
|
-
if (value !== void 0 && (!compareDefaultValues || value !== defaultCommonProps[attr])) {
|
|
20
|
-
result[attr] = value;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return result;
|
|
11
|
+
});
|
|
12
|
+
function filterProps(data, reference, compareDefaultValues) {
|
|
13
|
+
const result = objects.commonObjectProps(data, reference);
|
|
14
|
+
return compareDefaultValues ? objects.unmergeObjects(result, reference) : result;
|
|
24
15
|
}
|
|
25
16
|
|
|
26
17
|
exports.defaultCommonProps = defaultCommonProps;
|
|
27
|
-
exports.extraDefaultProps = extraDefaultProps;
|
|
28
18
|
exports.filterProps = filterProps;
|
package/lib/icon-set/props.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
1
|
+
import { CommonIconProps } from './types.js';
|
|
2
|
+
import '../types-f0980297.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Common properties for icon and alias
|
|
6
6
|
*/
|
|
7
|
-
declare const extraDefaultProps: Required<ExtraIconProps>;
|
|
8
7
|
declare const defaultCommonProps: Required<CommonIconProps>;
|
|
9
8
|
/**
|
|
10
9
|
* Filter icon props: copies properties, removing undefined and default entries
|
|
11
10
|
*/
|
|
12
|
-
declare function filterProps(data: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
|
|
11
|
+
declare function filterProps(data: CommonIconProps, reference: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
|
|
13
12
|
|
|
14
|
-
export { defaultCommonProps,
|
|
13
|
+
export { defaultCommonProps, filterProps };
|
package/lib/icon-set/props.mjs
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { commonObjectProps, unmergeObjects } from '@iconify/utils/lib/misc/objects';
|
|
2
|
+
import { defaultIconProps } from '@iconify/utils';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const defaultCommonProps = Object.freeze({
|
|
5
|
+
...defaultIconProps,
|
|
4
6
|
hidden: false
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
const props = Object.keys(defaultCommonProps);
|
|
11
|
-
function filterProps(data, compareDefaultValues) {
|
|
12
|
-
const result = {};
|
|
13
|
-
props.forEach((attr) => {
|
|
14
|
-
const value = data[attr];
|
|
15
|
-
if (value !== void 0 && (!compareDefaultValues || value !== defaultCommonProps[attr])) {
|
|
16
|
-
result[attr] = value;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return result;
|
|
7
|
+
});
|
|
8
|
+
function filterProps(data, reference, compareDefaultValues) {
|
|
9
|
+
const result = commonObjectProps(data, reference);
|
|
10
|
+
return compareDefaultValues ? unmergeObjects(result, reference) : result;
|
|
20
11
|
}
|
|
21
12
|
|
|
22
|
-
export { defaultCommonProps,
|
|
13
|
+
export { defaultCommonProps, filterProps };
|
package/lib/icon-set/types.d.ts
CHANGED
package/lib/import/directory.cjs
CHANGED
|
@@ -8,14 +8,15 @@ const misc_keyword = require('../misc/keyword.cjs');
|
|
|
8
8
|
const misc_scan = require('../misc/scan.cjs');
|
|
9
9
|
const svg_index = require('../svg/index.cjs');
|
|
10
10
|
const svg_cleanup = require('../svg/cleanup.cjs');
|
|
11
|
-
require('@iconify/utils/lib/icon');
|
|
11
|
+
require('@iconify/utils/lib/icon/defaults');
|
|
12
12
|
require('@iconify/utils/lib/svg/build');
|
|
13
|
-
require('@iconify/utils/lib/customisations');
|
|
13
|
+
require('@iconify/utils/lib/customisations/defaults');
|
|
14
14
|
require('@iconify/utils/lib/icon-set/minify');
|
|
15
15
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
16
16
|
require('../icon-set/props.cjs');
|
|
17
|
-
require('
|
|
17
|
+
require('@iconify/utils/lib/misc/objects');
|
|
18
18
|
require('@iconify/utils');
|
|
19
|
+
require('cheerio');
|
|
19
20
|
require('../svg/cleanup/attribs.cjs');
|
|
20
21
|
require('../svg/data/attributes.cjs');
|
|
21
22
|
require('../svg/data/tags.cjs');
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IconSet } from '../icon-set/index.js';
|
|
2
|
-
import '
|
|
3
|
-
import '@iconify/utils/lib/customisations';
|
|
2
|
+
import '../types-f0980297.js';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
4
|
import '../icon-set/types.js';
|
|
5
5
|
import '../svg/index.js';
|
|
6
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Entry for file
|
package/lib/import/directory.mjs
CHANGED
|
@@ -4,14 +4,15 @@ import { cleanupIconKeyword } from '../misc/keyword.mjs';
|
|
|
4
4
|
import { scanDirectory } from '../misc/scan.mjs';
|
|
5
5
|
import { SVG } from '../svg/index.mjs';
|
|
6
6
|
import { cleanupSVG } from '../svg/cleanup.mjs';
|
|
7
|
-
import '@iconify/utils/lib/icon';
|
|
7
|
+
import '@iconify/utils/lib/icon/defaults';
|
|
8
8
|
import '@iconify/utils/lib/svg/build';
|
|
9
|
-
import '@iconify/utils/lib/customisations';
|
|
9
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
10
10
|
import '@iconify/utils/lib/icon-set/minify';
|
|
11
11
|
import '@iconify/utils/lib/icon-set/convert-info';
|
|
12
12
|
import '../icon-set/props.mjs';
|
|
13
|
-
import '
|
|
13
|
+
import '@iconify/utils/lib/misc/objects';
|
|
14
14
|
import '@iconify/utils';
|
|
15
|
+
import 'cheerio';
|
|
15
16
|
import '../svg/cleanup/attribs.mjs';
|
|
16
17
|
import '../svg/data/attributes.mjs';
|
|
17
18
|
import '../svg/data/tags.mjs';
|