fastapi-rtk 0.2.26 → 0.2.28
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/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/hooks/useDateProps.cjs +1 -1
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/hooks/useDateProps.mjs +1 -1
- package/dist/.external/cjs/{@iconify_react@6.0.0_react@18.3.1 → @iconify_react@6.0.1_react@18.3.1}/@iconify/react/dist/iconify.cjs +261 -550
- package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/query.cjs +9 -5
- package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/retryer.cjs +3 -2
- package/dist/.external/cjs/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/errorBoundaryUtils.cjs +1 -1
- package/dist/.external/cjs/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/useBaseQuery.cjs +2 -2
- package/dist/.external/cjs/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/useQuery.cjs +1 -1
- package/dist/.external/esm/{@iconify_react@6.0.0_react@18.3.1 → @iconify_react@6.0.1_react@18.3.1}/@iconify/react/dist/iconify.mjs +261 -550
- package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/query.mjs +9 -5
- package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/retryer.mjs +3 -2
- package/dist/.external/esm/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/errorBoundaryUtils.mjs +1 -1
- package/dist/.external/esm/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/useBaseQuery.mjs +2 -2
- package/dist/.external/esm/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/useQuery.mjs +1 -1
- package/dist/core/cjs/ActionIcons/Modals/CommonModal.cjs +1 -1
- package/dist/core/cjs/Tables/DataGrid/Toolbar/Filter/FilterMenu.cjs +1 -1
- package/dist/core/cjs/Tables/NextGenDataGrid/NextGenDataGrid.cjs +1 -1
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/FilterModeDescription.cjs +1 -1
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useToolbar/basicToolbars.cjs +1 -1
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useToolbarAlertBanner/FASTAPI_RTK_ToolbarAlertBanner.cjs +1 -1
- package/dist/core/cjs/Wrappers/ApiProvider/hooks/useProvideApi.cjs +2 -2
- package/dist/core/cjs/Wrappers/Provider/Provider.cjs +2 -2
- package/dist/core/cjs/Wrappers/Provider/hooks/useProvideAuth.cjs +2 -2
- package/dist/core/cjs/Wrappers/Provider/hooks/useProvideInfo.cjs +1 -1
- package/dist/core/esm/ActionIcons/Modals/CommonModal.mjs +1 -1
- package/dist/core/esm/Tables/DataGrid/Toolbar/Filter/FilterMenu.mjs +1 -1
- package/dist/core/esm/Tables/NextGenDataGrid/NextGenDataGrid.mjs +1 -1
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/FilterModeDescription.mjs +1 -1
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useToolbar/basicToolbars.mjs +1 -1
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useToolbarAlertBanner/FASTAPI_RTK_ToolbarAlertBanner.mjs +1 -1
- package/dist/core/esm/Wrappers/ApiProvider/hooks/useProvideApi.mjs +2 -2
- package/dist/core/esm/Wrappers/Provider/Provider.mjs +2 -2
- package/dist/core/esm/Wrappers/Provider/hooks/useProvideAuth.mjs +2 -2
- package/dist/core/esm/Wrappers/Provider/hooks/useProvideInfo.mjs +1 -1
- package/dist/jsonforms/cjs/hooks/useDateProps.cjs +1 -1
- package/dist/jsonforms/esm/hooks/useDateProps.mjs +1 -1
- package/package.json +1 -1
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/focusManager.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/infiniteQueryBehavior.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/mutation.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/mutationCache.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/notifyManager.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/onlineManager.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/queryCache.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/queryClient.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/queryObserver.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/removable.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/subscribable.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/thenable.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/utils.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/IsRestoringProvider.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/QueryClientProvider.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/QueryErrorResetBoundary.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/suspense.cjs +0 -0
- /package/dist/.external/cjs/{mantine-form-yup-resolver@2.0.0_@mantine_form@8.2.7_yup@1.7.0 → mantine-form-yup-resolver@2.0.0_@mantine_form@8.2.8_yup@1.7.0}/mantine-form-yup-resolver/dist/esm/index.cjs +0 -0
- /package/dist/.external/cjs/{mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay → mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._v6brefjjgmgbqbolvm3v6bkbsa}/mantine-react-table/dist/index.esm.cjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/focusManager.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/infiniteQueryBehavior.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/mutation.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/mutationCache.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/notifyManager.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/onlineManager.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/queryCache.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/queryClient.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/queryObserver.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/removable.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/subscribable.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/thenable.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.85.5 → @tanstack_query-core@5.85.6}/@tanstack/query-core/build/modern/utils.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/IsRestoringProvider.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/QueryClientProvider.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/QueryErrorResetBoundary.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.85.5_react@18.3.1 → @tanstack_react-query@5.85.6_react@18.3.1}/@tanstack/react-query/build/modern/suspense.mjs +0 -0
- /package/dist/.external/esm/{mantine-form-yup-resolver@2.0.0_@mantine_form@8.2.7_yup@1.7.0 → mantine-form-yup-resolver@2.0.0_@mantine_form@8.2.8_yup@1.7.0}/mantine-form-yup-resolver/dist/esm/index.mjs +0 -0
- /package/dist/.external/esm/{mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay → mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._v6brefjjgmgbqbolvm3v6bkbsa}/mantine-react-table/dist/index.esm.mjs +0 -0
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { forwardRef, useState, useEffect, createElement } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
function getIconsTree(data, names) {
|
|
3
|
+
const icons = data.icons;
|
|
4
|
+
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
5
|
+
const resolved = /* @__PURE__ */ Object.create(null);
|
|
6
|
+
function resolve(name) {
|
|
7
|
+
if (icons[name]) return resolved[name] = [];
|
|
8
|
+
if (!(name in resolved)) {
|
|
9
|
+
resolved[name] = null;
|
|
10
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
11
|
+
const value = parent && resolve(parent);
|
|
12
|
+
if (value) resolved[name] = [parent].concat(value);
|
|
13
|
+
}
|
|
14
|
+
return resolved[name];
|
|
8
15
|
}
|
|
9
|
-
);
|
|
16
|
+
Object.keys(icons).concat(Object.keys(aliases)).forEach(resolve);
|
|
17
|
+
return resolved;
|
|
18
|
+
}
|
|
19
|
+
const defaultIconDimensions = Object.freeze({
|
|
20
|
+
left: 0,
|
|
21
|
+
top: 0,
|
|
22
|
+
width: 16,
|
|
23
|
+
height: 16
|
|
24
|
+
});
|
|
10
25
|
const defaultIconTransformations = Object.freeze({
|
|
11
26
|
rotate: 0,
|
|
12
27
|
vFlip: false,
|
|
@@ -23,63 +38,26 @@ const defaultExtendedIconProps = Object.freeze({
|
|
|
23
38
|
});
|
|
24
39
|
function mergeIconTransformations(obj1, obj2) {
|
|
25
40
|
const result = {};
|
|
26
|
-
if (!obj1.hFlip !== !obj2.hFlip)
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
if (!obj1.vFlip !== !obj2.vFlip) {
|
|
30
|
-
result.vFlip = true;
|
|
31
|
-
}
|
|
41
|
+
if (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;
|
|
42
|
+
if (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;
|
|
32
43
|
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
33
|
-
if (rotate)
|
|
34
|
-
result.rotate = rotate;
|
|
35
|
-
}
|
|
44
|
+
if (rotate) result.rotate = rotate;
|
|
36
45
|
return result;
|
|
37
46
|
}
|
|
38
47
|
function mergeIconData(parent, child) {
|
|
39
48
|
const result = mergeIconTransformations(parent, child);
|
|
40
|
-
for (const key in defaultExtendedIconProps) {
|
|
41
|
-
if (key in
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
} else if (key in child) {
|
|
46
|
-
result[key] = child[key];
|
|
47
|
-
} else if (key in parent) {
|
|
48
|
-
result[key] = parent[key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
49
|
+
for (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {
|
|
50
|
+
if (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];
|
|
51
|
+
} else if (key in child) result[key] = child[key];
|
|
52
|
+
else if (key in parent) result[key] = parent[key];
|
|
51
53
|
return result;
|
|
52
54
|
}
|
|
53
|
-
function getIconsTree(data, names) {
|
|
54
|
-
const icons = data.icons;
|
|
55
|
-
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
56
|
-
const resolved = /* @__PURE__ */ Object.create(null);
|
|
57
|
-
function resolve(name) {
|
|
58
|
-
if (icons[name]) {
|
|
59
|
-
return resolved[name] = [];
|
|
60
|
-
}
|
|
61
|
-
if (!(name in resolved)) {
|
|
62
|
-
resolved[name] = null;
|
|
63
|
-
const parent = aliases[name] && aliases[name].parent;
|
|
64
|
-
const value = parent && resolve(parent);
|
|
65
|
-
if (value) {
|
|
66
|
-
resolved[name] = [parent].concat(value);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return resolved[name];
|
|
70
|
-
}
|
|
71
|
-
Object.keys(icons).concat(Object.keys(aliases)).forEach(resolve);
|
|
72
|
-
return resolved;
|
|
73
|
-
}
|
|
74
55
|
function internalGetIconData(data, name, tree) {
|
|
75
56
|
const icons = data.icons;
|
|
76
57
|
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
77
58
|
let currentProps = {};
|
|
78
|
-
function parse(
|
|
79
|
-
currentProps = mergeIconData(
|
|
80
|
-
icons[name2] || aliases[name2],
|
|
81
|
-
currentProps
|
|
82
|
-
);
|
|
59
|
+
function parse(name$1) {
|
|
60
|
+
currentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);
|
|
83
61
|
}
|
|
84
62
|
parse(name);
|
|
85
63
|
tree.forEach(parse);
|
|
@@ -87,15 +65,11 @@ function internalGetIconData(data, name, tree) {
|
|
|
87
65
|
}
|
|
88
66
|
function parseIconSet(data, callback) {
|
|
89
67
|
const names = [];
|
|
90
|
-
if (typeof data !== "object" || typeof data.icons !== "object")
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
callback(name, null);
|
|
96
|
-
names.push(name);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
68
|
+
if (typeof data !== "object" || typeof data.icons !== "object") return names;
|
|
69
|
+
if (data.not_found instanceof Array) data.not_found.forEach((name) => {
|
|
70
|
+
callback(name, null);
|
|
71
|
+
names.push(name);
|
|
72
|
+
});
|
|
99
73
|
const tree = getIconsTree(data);
|
|
100
74
|
for (const name in tree) {
|
|
101
75
|
const item = tree[name];
|
|
@@ -113,77 +87,72 @@ const optionalPropertyDefaults = {
|
|
|
113
87
|
...defaultIconDimensions
|
|
114
88
|
};
|
|
115
89
|
function checkOptionalProps(item, defaults) {
|
|
116
|
-
for (const prop in defaults)
|
|
117
|
-
if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
90
|
+
for (const prop in defaults) if (prop in item && typeof item[prop] !== typeof defaults[prop]) return false;
|
|
121
91
|
return true;
|
|
122
92
|
}
|
|
123
93
|
function quicklyValidateIconSet(obj) {
|
|
124
|
-
if (typeof obj !== "object" || obj === null)
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
94
|
+
if (typeof obj !== "object" || obj === null) return null;
|
|
127
95
|
const data = obj;
|
|
128
|
-
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object")
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
96
|
+
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") return null;
|
|
97
|
+
if (!checkOptionalProps(obj, optionalPropertyDefaults)) return null;
|
|
134
98
|
const icons = data.icons;
|
|
135
99
|
for (const name in icons) {
|
|
136
100
|
const icon = icons[name];
|
|
137
|
-
if (
|
|
138
|
-
// Name cannot be empty
|
|
139
|
-
!name || // Must have body
|
|
140
|
-
typeof icon.body !== "string" || // Check other props
|
|
141
|
-
!checkOptionalProps(
|
|
142
|
-
icon,
|
|
143
|
-
defaultExtendedIconProps
|
|
144
|
-
)
|
|
145
|
-
) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
101
|
+
if (!name || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
|
|
148
102
|
}
|
|
149
103
|
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
150
104
|
for (const name in aliases) {
|
|
151
105
|
const icon = aliases[name];
|
|
152
106
|
const parent = icon.parent;
|
|
153
|
-
if (
|
|
154
|
-
// Name cannot be empty
|
|
155
|
-
!name || // Parent must be set and point to existing icon
|
|
156
|
-
typeof parent !== "string" || !icons[parent] && !aliases[parent] || // Check other props
|
|
157
|
-
!checkOptionalProps(
|
|
158
|
-
icon,
|
|
159
|
-
defaultExtendedIconProps
|
|
160
|
-
)
|
|
161
|
-
) {
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
107
|
+
if (!name || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
|
|
164
108
|
}
|
|
165
109
|
return data;
|
|
166
110
|
}
|
|
111
|
+
const dataStorage = /* @__PURE__ */ Object.create(null);
|
|
112
|
+
function newStorage(provider, prefix) {
|
|
113
|
+
return {
|
|
114
|
+
provider,
|
|
115
|
+
prefix,
|
|
116
|
+
icons: /* @__PURE__ */ Object.create(null),
|
|
117
|
+
missing: /* @__PURE__ */ new Set()
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function getStorage(provider, prefix) {
|
|
121
|
+
const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
|
|
122
|
+
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
123
|
+
}
|
|
124
|
+
function addIconSet(storage2, data) {
|
|
125
|
+
if (!quicklyValidateIconSet(data)) return [];
|
|
126
|
+
return parseIconSet(data, (name, icon) => {
|
|
127
|
+
if (icon) storage2.icons[name] = icon;
|
|
128
|
+
else storage2.missing.add(name);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function addIconToStorage(storage2, name, icon) {
|
|
132
|
+
try {
|
|
133
|
+
if (typeof icon.body === "string") {
|
|
134
|
+
storage2.icons[name] = { ...icon };
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
167
141
|
const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
168
142
|
const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
|
|
169
143
|
const colonSeparated = value.split(":");
|
|
170
144
|
if (value.slice(0, 1) === "@") {
|
|
171
|
-
if (colonSeparated.length < 2 || colonSeparated.length > 3)
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
145
|
+
if (colonSeparated.length < 2 || colonSeparated.length > 3) return null;
|
|
174
146
|
provider = colonSeparated.shift().slice(1);
|
|
175
147
|
}
|
|
176
|
-
if (colonSeparated.length > 3 || !colonSeparated.length)
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
148
|
+
if (colonSeparated.length > 3 || !colonSeparated.length) return null;
|
|
179
149
|
if (colonSeparated.length > 1) {
|
|
180
|
-
const
|
|
150
|
+
const name$1 = colonSeparated.pop();
|
|
181
151
|
const prefix = colonSeparated.pop();
|
|
182
152
|
const result = {
|
|
183
|
-
// Allow provider without '@': "provider:prefix:name"
|
|
184
153
|
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
|
|
185
154
|
prefix,
|
|
186
|
-
name:
|
|
155
|
+
name: name$1
|
|
187
156
|
};
|
|
188
157
|
return validate && !validateIconName(result) ? null : result;
|
|
189
158
|
}
|
|
@@ -208,53 +177,12 @@ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
|
|
|
208
177
|
return null;
|
|
209
178
|
};
|
|
210
179
|
const validateIconName = (icon, allowSimpleName) => {
|
|
211
|
-
if (!icon)
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
return !!// Check prefix: cannot be empty, unless allowSimpleName is enabled
|
|
215
|
-
// Check name: cannot be empty
|
|
216
|
-
((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
|
|
180
|
+
if (!icon) return false;
|
|
181
|
+
return !!((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
|
|
217
182
|
};
|
|
218
|
-
const dataStorage = /* @__PURE__ */ Object.create(null);
|
|
219
|
-
function newStorage(provider, prefix) {
|
|
220
|
-
return {
|
|
221
|
-
provider,
|
|
222
|
-
prefix,
|
|
223
|
-
icons: /* @__PURE__ */ Object.create(null),
|
|
224
|
-
missing: /* @__PURE__ */ new Set()
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function getStorage(provider, prefix) {
|
|
228
|
-
const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
|
|
229
|
-
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
230
|
-
}
|
|
231
|
-
function addIconSet(storage2, data) {
|
|
232
|
-
if (!quicklyValidateIconSet(data)) {
|
|
233
|
-
return [];
|
|
234
|
-
}
|
|
235
|
-
return parseIconSet(data, (name, icon) => {
|
|
236
|
-
if (icon) {
|
|
237
|
-
storage2.icons[name] = icon;
|
|
238
|
-
} else {
|
|
239
|
-
storage2.missing.add(name);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
function addIconToStorage(storage2, name, icon) {
|
|
244
|
-
try {
|
|
245
|
-
if (typeof icon.body === "string") {
|
|
246
|
-
storage2.icons[name] = { ...icon };
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
} catch (err) {
|
|
250
|
-
}
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
183
|
let simpleNames = false;
|
|
254
184
|
function allowSimpleNames(allow) {
|
|
255
|
-
if (typeof allow === "boolean")
|
|
256
|
-
simpleNames = allow;
|
|
257
|
-
}
|
|
185
|
+
if (typeof allow === "boolean") simpleNames = allow;
|
|
258
186
|
return simpleNames;
|
|
259
187
|
}
|
|
260
188
|
function getIconData(name) {
|
|
@@ -267,32 +195,23 @@ function getIconData(name) {
|
|
|
267
195
|
}
|
|
268
196
|
function addIcon(name, data) {
|
|
269
197
|
const icon = stringToIcon(name, true, simpleNames);
|
|
270
|
-
if (!icon)
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
198
|
+
if (!icon) return false;
|
|
273
199
|
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
274
|
-
if (data)
|
|
275
|
-
|
|
276
|
-
} else {
|
|
200
|
+
if (data) return addIconToStorage(storage2, icon.name, data);
|
|
201
|
+
else {
|
|
277
202
|
storage2.missing.add(icon.name);
|
|
278
203
|
return true;
|
|
279
204
|
}
|
|
280
205
|
}
|
|
281
206
|
function addCollection(data, provider) {
|
|
282
|
-
if (typeof data !== "object")
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
if (typeof provider !== "string") {
|
|
286
|
-
provider = data.provider || "";
|
|
287
|
-
}
|
|
207
|
+
if (typeof data !== "object") return false;
|
|
208
|
+
if (typeof provider !== "string") provider = data.provider || "";
|
|
288
209
|
if (simpleNames && !provider && !data.prefix) {
|
|
289
210
|
let added = false;
|
|
290
211
|
if (quicklyValidateIconSet(data)) {
|
|
291
212
|
data.prefix = "";
|
|
292
213
|
parseIconSet(data, (name, icon) => {
|
|
293
|
-
if (addIcon(name, icon))
|
|
294
|
-
added = true;
|
|
295
|
-
}
|
|
214
|
+
if (addIcon(name, icon)) added = true;
|
|
296
215
|
});
|
|
297
216
|
}
|
|
298
217
|
return added;
|
|
@@ -301,9 +220,7 @@ function addCollection(data, provider) {
|
|
|
301
220
|
if (!validateIconName({
|
|
302
221
|
prefix,
|
|
303
222
|
name: "a"
|
|
304
|
-
}))
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
223
|
+
})) return false;
|
|
307
224
|
const storage2 = getStorage(provider, prefix);
|
|
308
225
|
return !!addIconSet(storage2, data);
|
|
309
226
|
}
|
|
@@ -312,46 +229,29 @@ const defaultIconSizeCustomisations = Object.freeze({
|
|
|
312
229
|
height: null
|
|
313
230
|
});
|
|
314
231
|
const defaultIconCustomisations = Object.freeze({
|
|
315
|
-
// Dimensions
|
|
316
232
|
...defaultIconSizeCustomisations,
|
|
317
|
-
// Transformations
|
|
318
233
|
...defaultIconTransformations
|
|
319
234
|
});
|
|
320
235
|
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
321
236
|
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
322
237
|
function calculateSize(size, ratio, precision) {
|
|
323
|
-
if (ratio === 1)
|
|
324
|
-
return size;
|
|
325
|
-
}
|
|
238
|
+
if (ratio === 1) return size;
|
|
326
239
|
precision = precision || 100;
|
|
327
|
-
if (typeof size === "number")
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
if (typeof size !== "string") {
|
|
331
|
-
return size;
|
|
332
|
-
}
|
|
240
|
+
if (typeof size === "number") return Math.ceil(size * ratio * precision) / precision;
|
|
241
|
+
if (typeof size !== "string") return size;
|
|
333
242
|
const oldParts = size.split(unitsSplit);
|
|
334
|
-
if (oldParts === null || !oldParts.length)
|
|
335
|
-
return size;
|
|
336
|
-
}
|
|
243
|
+
if (oldParts === null || !oldParts.length) return size;
|
|
337
244
|
const newParts = [];
|
|
338
245
|
let code = oldParts.shift();
|
|
339
246
|
let isNumber = unitsTest.test(code);
|
|
340
247
|
while (true) {
|
|
341
248
|
if (isNumber) {
|
|
342
249
|
const num = parseFloat(code);
|
|
343
|
-
if (isNaN(num))
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
347
|
-
}
|
|
348
|
-
} else {
|
|
349
|
-
newParts.push(code);
|
|
350
|
-
}
|
|
250
|
+
if (isNaN(num)) newParts.push(code);
|
|
251
|
+
else newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
252
|
+
} else newParts.push(code);
|
|
351
253
|
code = oldParts.shift();
|
|
352
|
-
if (code === void 0)
|
|
353
|
-
return newParts.join("");
|
|
354
|
-
}
|
|
254
|
+
if (code === void 0) return newParts.join("");
|
|
355
255
|
isNumber = !isNumber;
|
|
356
256
|
}
|
|
357
257
|
}
|
|
@@ -361,13 +261,9 @@ function splitSVGDefs(content, tag = "defs") {
|
|
|
361
261
|
while (index >= 0) {
|
|
362
262
|
const start = content.indexOf(">", index);
|
|
363
263
|
const end = content.indexOf("</" + tag);
|
|
364
|
-
if (start === -1 || end === -1)
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
264
|
+
if (start === -1 || end === -1) break;
|
|
367
265
|
const endEnd = content.indexOf(">", end);
|
|
368
|
-
if (endEnd === -1)
|
|
369
|
-
break;
|
|
370
|
-
}
|
|
266
|
+
if (endEnd === -1) break;
|
|
371
267
|
defs += content.slice(start + 1, end).trim();
|
|
372
268
|
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
|
|
373
269
|
}
|
|
@@ -405,45 +301,31 @@ function iconToSVG(icon, customisations) {
|
|
|
405
301
|
const hFlip = props.hFlip;
|
|
406
302
|
const vFlip = props.vFlip;
|
|
407
303
|
let rotation = props.rotate;
|
|
408
|
-
if (hFlip)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
box.top = box.left = 0;
|
|
417
|
-
}
|
|
418
|
-
} else if (vFlip) {
|
|
419
|
-
transformations.push(
|
|
420
|
-
"translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
|
|
421
|
-
);
|
|
304
|
+
if (hFlip) if (vFlip) rotation += 2;
|
|
305
|
+
else {
|
|
306
|
+
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
|
|
307
|
+
transformations.push("scale(-1 1)");
|
|
308
|
+
box.top = box.left = 0;
|
|
309
|
+
}
|
|
310
|
+
else if (vFlip) {
|
|
311
|
+
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
|
|
422
312
|
transformations.push("scale(1 -1)");
|
|
423
313
|
box.top = box.left = 0;
|
|
424
314
|
}
|
|
425
315
|
let tempValue;
|
|
426
|
-
if (rotation < 0)
|
|
427
|
-
rotation -= Math.floor(rotation / 4) * 4;
|
|
428
|
-
}
|
|
316
|
+
if (rotation < 0) rotation -= Math.floor(rotation / 4) * 4;
|
|
429
317
|
rotation = rotation % 4;
|
|
430
318
|
switch (rotation) {
|
|
431
319
|
case 1:
|
|
432
320
|
tempValue = box.height / 2 + box.top;
|
|
433
|
-
transformations.unshift(
|
|
434
|
-
"rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
|
|
435
|
-
);
|
|
321
|
+
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
436
322
|
break;
|
|
437
323
|
case 2:
|
|
438
|
-
transformations.unshift(
|
|
439
|
-
"rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
|
|
440
|
-
);
|
|
324
|
+
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
|
|
441
325
|
break;
|
|
442
326
|
case 3:
|
|
443
327
|
tempValue = box.width / 2 + box.left;
|
|
444
|
-
transformations.unshift(
|
|
445
|
-
"rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
|
|
446
|
-
);
|
|
328
|
+
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
447
329
|
break;
|
|
448
330
|
}
|
|
449
331
|
if (rotation % 2 === 1) {
|
|
@@ -458,13 +340,7 @@ function iconToSVG(icon, customisations) {
|
|
|
458
340
|
box.height = tempValue;
|
|
459
341
|
}
|
|
460
342
|
}
|
|
461
|
-
if (transformations.length)
|
|
462
|
-
body = wrapSVGContent(
|
|
463
|
-
body,
|
|
464
|
-
'<g transform="' + transformations.join(" ") + '">',
|
|
465
|
-
"</g>"
|
|
466
|
-
);
|
|
467
|
-
}
|
|
343
|
+
if (transformations.length) body = wrapSVGContent(body, '<g transform="' + transformations.join(" ") + '">', "</g>");
|
|
468
344
|
});
|
|
469
345
|
const customisationsWidth = fullCustomisations.width;
|
|
470
346
|
const customisationsHeight = fullCustomisations.height;
|
|
@@ -481,13 +357,16 @@ function iconToSVG(icon, customisations) {
|
|
|
481
357
|
}
|
|
482
358
|
const attributes = {};
|
|
483
359
|
const setAttr = (prop, value) => {
|
|
484
|
-
if (!isUnsetKeyword(value))
|
|
485
|
-
attributes[prop] = value.toString();
|
|
486
|
-
}
|
|
360
|
+
if (!isUnsetKeyword(value)) attributes[prop] = value.toString();
|
|
487
361
|
};
|
|
488
362
|
setAttr("width", width);
|
|
489
363
|
setAttr("height", height);
|
|
490
|
-
const viewBox = [
|
|
364
|
+
const viewBox = [
|
|
365
|
+
box.left,
|
|
366
|
+
box.top,
|
|
367
|
+
boxWidth,
|
|
368
|
+
boxHeight
|
|
369
|
+
];
|
|
491
370
|
attributes.viewBox = viewBox.join(" ");
|
|
492
371
|
return {
|
|
493
372
|
attributes,
|
|
@@ -501,22 +380,13 @@ let counter = 0;
|
|
|
501
380
|
function replaceIDs(body, prefix = randomPrefix) {
|
|
502
381
|
const ids = [];
|
|
503
382
|
let match;
|
|
504
|
-
while (match = regex.exec(body))
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
if (!ids.length) {
|
|
508
|
-
return body;
|
|
509
|
-
}
|
|
383
|
+
while (match = regex.exec(body)) ids.push(match[1]);
|
|
384
|
+
if (!ids.length) return body;
|
|
510
385
|
const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
|
|
511
386
|
ids.forEach((id) => {
|
|
512
387
|
const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
|
|
513
388
|
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
514
|
-
body = body.replace(
|
|
515
|
-
// Allowed characters before id: [#;"]
|
|
516
|
-
// Allowed characters after id: [)"], .[a-z]
|
|
517
|
-
new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
|
|
518
|
-
"$1" + newID + suffix + "$3"
|
|
519
|
-
);
|
|
389
|
+
body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + suffix + "$3");
|
|
520
390
|
});
|
|
521
391
|
body = body.replace(new RegExp(suffix, "g"), "");
|
|
522
392
|
return body;
|
|
@@ -530,59 +400,33 @@ function getAPIModule(provider) {
|
|
|
530
400
|
}
|
|
531
401
|
function createAPIConfig(source) {
|
|
532
402
|
let resources;
|
|
533
|
-
if (typeof source.resources === "string")
|
|
534
|
-
|
|
535
|
-
} else {
|
|
403
|
+
if (typeof source.resources === "string") resources = [source.resources];
|
|
404
|
+
else {
|
|
536
405
|
resources = source.resources;
|
|
537
|
-
if (!(resources instanceof Array) || !resources.length)
|
|
538
|
-
return null;
|
|
539
|
-
}
|
|
406
|
+
if (!(resources instanceof Array) || !resources.length) return null;
|
|
540
407
|
}
|
|
541
408
|
const result = {
|
|
542
|
-
// API hosts
|
|
543
409
|
resources,
|
|
544
|
-
// Root path
|
|
545
410
|
path: source.path || "/",
|
|
546
|
-
// URL length limit
|
|
547
411
|
maxURL: source.maxURL || 500,
|
|
548
|
-
// Timeout before next host is used.
|
|
549
412
|
rotate: source.rotate || 750,
|
|
550
|
-
// Timeout before failing query.
|
|
551
413
|
timeout: source.timeout || 5e3,
|
|
552
|
-
// Randomise default API end point.
|
|
553
414
|
random: source.random === true,
|
|
554
|
-
// Start index
|
|
555
415
|
index: source.index || 0,
|
|
556
|
-
// Receive data after time out (used if time out kicks in first, then API module sends data anyway).
|
|
557
416
|
dataAfterTimeout: source.dataAfterTimeout !== false
|
|
558
417
|
};
|
|
559
418
|
return result;
|
|
560
419
|
}
|
|
561
420
|
const configStorage = /* @__PURE__ */ Object.create(null);
|
|
562
|
-
const fallBackAPISources = [
|
|
563
|
-
"https://api.simplesvg.com",
|
|
564
|
-
"https://api.unisvg.com"
|
|
565
|
-
];
|
|
421
|
+
const fallBackAPISources = ["https://api.simplesvg.com", "https://api.unisvg.com"];
|
|
566
422
|
const fallBackAPI = [];
|
|
567
|
-
while (fallBackAPISources.length > 0)
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
if (Math.random() > 0.5) {
|
|
572
|
-
fallBackAPI.push(fallBackAPISources.shift());
|
|
573
|
-
} else {
|
|
574
|
-
fallBackAPI.push(fallBackAPISources.pop());
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
configStorage[""] = createAPIConfig({
|
|
579
|
-
resources: ["https://api.iconify.design"].concat(fallBackAPI)
|
|
580
|
-
});
|
|
423
|
+
while (fallBackAPISources.length > 0) if (fallBackAPISources.length === 1) fallBackAPI.push(fallBackAPISources.shift());
|
|
424
|
+
else if (Math.random() > 0.5) fallBackAPI.push(fallBackAPISources.shift());
|
|
425
|
+
else fallBackAPI.push(fallBackAPISources.pop());
|
|
426
|
+
configStorage[""] = createAPIConfig({ resources: ["https://api.iconify.design"].concat(fallBackAPI) });
|
|
581
427
|
function addAPIProvider(provider, customConfig) {
|
|
582
428
|
const config = createAPIConfig(customConfig);
|
|
583
|
-
if (config === null)
|
|
584
|
-
return false;
|
|
585
|
-
}
|
|
429
|
+
if (config === null) return false;
|
|
586
430
|
configStorage[provider] = config;
|
|
587
431
|
return true;
|
|
588
432
|
}
|
|
@@ -593,22 +437,17 @@ const detectFetch = () => {
|
|
|
593
437
|
let callback;
|
|
594
438
|
try {
|
|
595
439
|
callback = fetch;
|
|
596
|
-
if (typeof callback === "function")
|
|
597
|
-
return callback;
|
|
598
|
-
}
|
|
440
|
+
if (typeof callback === "function") return callback;
|
|
599
441
|
} catch (err) {
|
|
600
442
|
}
|
|
601
443
|
};
|
|
602
444
|
let fetchModule = detectFetch();
|
|
603
445
|
function calculateMaxLength(provider, prefix) {
|
|
604
446
|
const config = getAPIConfig(provider);
|
|
605
|
-
if (!config)
|
|
606
|
-
return 0;
|
|
607
|
-
}
|
|
447
|
+
if (!config) return 0;
|
|
608
448
|
let result;
|
|
609
|
-
if (!config.maxURL)
|
|
610
|
-
|
|
611
|
-
} else {
|
|
449
|
+
if (!config.maxURL) result = 0;
|
|
450
|
+
else {
|
|
612
451
|
let maxHostLength = 0;
|
|
613
452
|
config.resources.forEach((item) => {
|
|
614
453
|
const host = item;
|
|
@@ -653,9 +492,7 @@ const prepare = (provider, prefix, icons) => {
|
|
|
653
492
|
function getPath(provider) {
|
|
654
493
|
if (typeof provider === "string") {
|
|
655
494
|
const config = getAPIConfig(provider);
|
|
656
|
-
if (config)
|
|
657
|
-
return config.path;
|
|
658
|
-
}
|
|
495
|
+
if (config) return config.path;
|
|
659
496
|
}
|
|
660
497
|
return "/";
|
|
661
498
|
}
|
|
@@ -670,9 +507,7 @@ const send = (host, params, callback) => {
|
|
|
670
507
|
const prefix = params.prefix;
|
|
671
508
|
const icons = params.icons;
|
|
672
509
|
const iconsList = icons.join(",");
|
|
673
|
-
const urlParams = new URLSearchParams({
|
|
674
|
-
icons: iconsList
|
|
675
|
-
});
|
|
510
|
+
const urlParams = new URLSearchParams({ icons: iconsList });
|
|
676
511
|
path += prefix + ".json?" + urlParams.toString();
|
|
677
512
|
break;
|
|
678
513
|
}
|
|
@@ -699,11 +534,8 @@ const send = (host, params, callback) => {
|
|
|
699
534
|
}).then((data) => {
|
|
700
535
|
if (typeof data !== "object" || data === null) {
|
|
701
536
|
setTimeout(() => {
|
|
702
|
-
if (data === 404)
|
|
703
|
-
|
|
704
|
-
} else {
|
|
705
|
-
callback("next", defaultError);
|
|
706
|
-
}
|
|
537
|
+
if (data === 404) callback("abort", data);
|
|
538
|
+
else callback("next", defaultError);
|
|
707
539
|
});
|
|
708
540
|
return;
|
|
709
541
|
}
|
|
@@ -718,60 +550,10 @@ const fetchAPIModule = {
|
|
|
718
550
|
prepare,
|
|
719
551
|
send
|
|
720
552
|
};
|
|
721
|
-
function sortIcons(icons) {
|
|
722
|
-
const result = {
|
|
723
|
-
loaded: [],
|
|
724
|
-
missing: [],
|
|
725
|
-
pending: []
|
|
726
|
-
};
|
|
727
|
-
const storage2 = /* @__PURE__ */ Object.create(null);
|
|
728
|
-
icons.sort((a, b) => {
|
|
729
|
-
if (a.provider !== b.provider) {
|
|
730
|
-
return a.provider.localeCompare(b.provider);
|
|
731
|
-
}
|
|
732
|
-
if (a.prefix !== b.prefix) {
|
|
733
|
-
return a.prefix.localeCompare(b.prefix);
|
|
734
|
-
}
|
|
735
|
-
return a.name.localeCompare(b.name);
|
|
736
|
-
});
|
|
737
|
-
let lastIcon = {
|
|
738
|
-
provider: "",
|
|
739
|
-
prefix: "",
|
|
740
|
-
name: ""
|
|
741
|
-
};
|
|
742
|
-
icons.forEach((icon) => {
|
|
743
|
-
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
lastIcon = icon;
|
|
747
|
-
const provider = icon.provider;
|
|
748
|
-
const prefix = icon.prefix;
|
|
749
|
-
const name = icon.name;
|
|
750
|
-
const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
|
|
751
|
-
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
752
|
-
let list;
|
|
753
|
-
if (name in localStorage.icons) {
|
|
754
|
-
list = result.loaded;
|
|
755
|
-
} else if (prefix === "" || localStorage.missing.has(name)) {
|
|
756
|
-
list = result.missing;
|
|
757
|
-
} else {
|
|
758
|
-
list = result.pending;
|
|
759
|
-
}
|
|
760
|
-
const item = {
|
|
761
|
-
provider,
|
|
762
|
-
prefix,
|
|
763
|
-
name
|
|
764
|
-
};
|
|
765
|
-
list.push(item);
|
|
766
|
-
});
|
|
767
|
-
return result;
|
|
768
|
-
}
|
|
769
553
|
function removeCallback(storages, id) {
|
|
770
554
|
storages.forEach((storage2) => {
|
|
771
555
|
const items = storage2.loaderCallbacks;
|
|
772
|
-
if (items)
|
|
773
|
-
storage2.loaderCallbacks = items.filter((row) => row.id !== id);
|
|
774
|
-
}
|
|
556
|
+
if (items) storage2.loaderCallbacks = items.filter((row) => row.id !== id);
|
|
775
557
|
});
|
|
776
558
|
}
|
|
777
559
|
function updateCallbacks(storage2) {
|
|
@@ -780,9 +562,7 @@ function updateCallbacks(storage2) {
|
|
|
780
562
|
setTimeout(() => {
|
|
781
563
|
storage2.pendingCallbacksFlag = false;
|
|
782
564
|
const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
|
|
783
|
-
if (!items.length)
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
565
|
+
if (!items.length) return;
|
|
786
566
|
let hasPending = false;
|
|
787
567
|
const provider = storage2.provider;
|
|
788
568
|
const prefix = storage2.prefix;
|
|
@@ -790,38 +570,27 @@ function updateCallbacks(storage2) {
|
|
|
790
570
|
const icons = item.icons;
|
|
791
571
|
const oldLength = icons.pending.length;
|
|
792
572
|
icons.pending = icons.pending.filter((icon) => {
|
|
793
|
-
if (icon.prefix !== prefix)
|
|
794
|
-
return true;
|
|
795
|
-
}
|
|
573
|
+
if (icon.prefix !== prefix) return true;
|
|
796
574
|
const name = icon.name;
|
|
797
|
-
if (storage2.icons[name]) {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
});
|
|
809
|
-
} else {
|
|
575
|
+
if (storage2.icons[name]) icons.loaded.push({
|
|
576
|
+
provider,
|
|
577
|
+
prefix,
|
|
578
|
+
name
|
|
579
|
+
});
|
|
580
|
+
else if (storage2.missing.has(name)) icons.missing.push({
|
|
581
|
+
provider,
|
|
582
|
+
prefix,
|
|
583
|
+
name
|
|
584
|
+
});
|
|
585
|
+
else {
|
|
810
586
|
hasPending = true;
|
|
811
587
|
return true;
|
|
812
588
|
}
|
|
813
589
|
return false;
|
|
814
590
|
});
|
|
815
591
|
if (icons.pending.length !== oldLength) {
|
|
816
|
-
if (!hasPending)
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
item.callback(
|
|
820
|
-
icons.loaded.slice(0),
|
|
821
|
-
icons.missing.slice(0),
|
|
822
|
-
icons.pending.slice(0),
|
|
823
|
-
item.abort
|
|
824
|
-
);
|
|
592
|
+
if (!hasPending) removeCallback([storage2], item.id);
|
|
593
|
+
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
|
|
825
594
|
}
|
|
826
595
|
});
|
|
827
596
|
});
|
|
@@ -831,9 +600,7 @@ let idCounter = 0;
|
|
|
831
600
|
function storeCallback(callback, icons, pendingSources) {
|
|
832
601
|
const id = idCounter++;
|
|
833
602
|
const abort = removeCallback.bind(null, pendingSources, id);
|
|
834
|
-
if (!icons.pending.length)
|
|
835
|
-
return abort;
|
|
836
|
-
}
|
|
603
|
+
if (!icons.pending.length) return abort;
|
|
837
604
|
const item = {
|
|
838
605
|
id,
|
|
839
606
|
icons,
|
|
@@ -845,17 +612,53 @@ function storeCallback(callback, icons, pendingSources) {
|
|
|
845
612
|
});
|
|
846
613
|
return abort;
|
|
847
614
|
}
|
|
615
|
+
function sortIcons(icons) {
|
|
616
|
+
const result = {
|
|
617
|
+
loaded: [],
|
|
618
|
+
missing: [],
|
|
619
|
+
pending: []
|
|
620
|
+
};
|
|
621
|
+
const storage2 = /* @__PURE__ */ Object.create(null);
|
|
622
|
+
icons.sort((a, b) => {
|
|
623
|
+
if (a.provider !== b.provider) return a.provider.localeCompare(b.provider);
|
|
624
|
+
if (a.prefix !== b.prefix) return a.prefix.localeCompare(b.prefix);
|
|
625
|
+
return a.name.localeCompare(b.name);
|
|
626
|
+
});
|
|
627
|
+
let lastIcon = {
|
|
628
|
+
provider: "",
|
|
629
|
+
prefix: "",
|
|
630
|
+
name: ""
|
|
631
|
+
};
|
|
632
|
+
icons.forEach((icon) => {
|
|
633
|
+
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) return;
|
|
634
|
+
lastIcon = icon;
|
|
635
|
+
const provider = icon.provider;
|
|
636
|
+
const prefix = icon.prefix;
|
|
637
|
+
const name = icon.name;
|
|
638
|
+
const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
|
|
639
|
+
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
640
|
+
let list;
|
|
641
|
+
if (name in localStorage.icons) list = result.loaded;
|
|
642
|
+
else if (prefix === "" || localStorage.missing.has(name)) list = result.missing;
|
|
643
|
+
else list = result.pending;
|
|
644
|
+
const item = {
|
|
645
|
+
provider,
|
|
646
|
+
prefix,
|
|
647
|
+
name
|
|
648
|
+
};
|
|
649
|
+
list.push(item);
|
|
650
|
+
});
|
|
651
|
+
return result;
|
|
652
|
+
}
|
|
848
653
|
function listToIcons(list, validate = true, simpleNames2 = false) {
|
|
849
654
|
const result = [];
|
|
850
655
|
list.forEach((item) => {
|
|
851
656
|
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
|
|
852
|
-
if (icon)
|
|
853
|
-
result.push(icon);
|
|
854
|
-
}
|
|
657
|
+
if (icon) result.push(icon);
|
|
855
658
|
});
|
|
856
659
|
return result;
|
|
857
660
|
}
|
|
858
|
-
|
|
661
|
+
const defaultConfig = {
|
|
859
662
|
resources: [],
|
|
860
663
|
index: 0,
|
|
861
664
|
timeout: 2e3,
|
|
@@ -876,9 +679,7 @@ function sendQuery(config, payload, query, done) {
|
|
|
876
679
|
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
|
|
877
680
|
}
|
|
878
681
|
resources = resources.concat(list);
|
|
879
|
-
} else
|
|
880
|
-
resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
881
|
-
}
|
|
682
|
+
} else resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
882
683
|
const startTime = Date.now();
|
|
883
684
|
let status = "pending";
|
|
884
685
|
let queriesSent = 0;
|
|
@@ -886,9 +687,7 @@ function sendQuery(config, payload, query, done) {
|
|
|
886
687
|
let timer = null;
|
|
887
688
|
let queue = [];
|
|
888
689
|
let doneCallbacks = [];
|
|
889
|
-
if (typeof done === "function")
|
|
890
|
-
doneCallbacks.push(done);
|
|
891
|
-
}
|
|
690
|
+
if (typeof done === "function") doneCallbacks.push(done);
|
|
892
691
|
function resetTimer() {
|
|
893
692
|
if (timer) {
|
|
894
693
|
clearTimeout(timer);
|
|
@@ -896,24 +695,16 @@ function sendQuery(config, payload, query, done) {
|
|
|
896
695
|
}
|
|
897
696
|
}
|
|
898
697
|
function abort() {
|
|
899
|
-
if (status === "pending")
|
|
900
|
-
status = "aborted";
|
|
901
|
-
}
|
|
698
|
+
if (status === "pending") status = "aborted";
|
|
902
699
|
resetTimer();
|
|
903
700
|
queue.forEach((item) => {
|
|
904
|
-
if (item.status === "pending")
|
|
905
|
-
item.status = "aborted";
|
|
906
|
-
}
|
|
701
|
+
if (item.status === "pending") item.status = "aborted";
|
|
907
702
|
});
|
|
908
703
|
queue = [];
|
|
909
704
|
}
|
|
910
705
|
function subscribe(callback, overwrite) {
|
|
911
|
-
if (overwrite)
|
|
912
|
-
|
|
913
|
-
}
|
|
914
|
-
if (typeof callback === "function") {
|
|
915
|
-
doneCallbacks.push(callback);
|
|
916
|
-
}
|
|
706
|
+
if (overwrite) doneCallbacks = [];
|
|
707
|
+
if (typeof callback === "function") doneCallbacks.push(callback);
|
|
917
708
|
}
|
|
918
709
|
function getQueryStatus() {
|
|
919
710
|
return {
|
|
@@ -934,9 +725,7 @@ function sendQuery(config, payload, query, done) {
|
|
|
934
725
|
}
|
|
935
726
|
function clearQueue() {
|
|
936
727
|
queue.forEach((item) => {
|
|
937
|
-
if (item.status === "pending")
|
|
938
|
-
item.status = "aborted";
|
|
939
|
-
}
|
|
728
|
+
if (item.status === "pending") item.status = "aborted";
|
|
940
729
|
});
|
|
941
730
|
queue = [];
|
|
942
731
|
}
|
|
@@ -947,9 +736,7 @@ function sendQuery(config, payload, query, done) {
|
|
|
947
736
|
case "pending":
|
|
948
737
|
break;
|
|
949
738
|
case "failed":
|
|
950
|
-
if (isError || !config.dataAfterTimeout)
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
739
|
+
if (isError || !config.dataAfterTimeout) return;
|
|
953
740
|
break;
|
|
954
741
|
default:
|
|
955
742
|
return;
|
|
@@ -961,22 +748,15 @@ function sendQuery(config, payload, query, done) {
|
|
|
961
748
|
}
|
|
962
749
|
if (isError) {
|
|
963
750
|
lastError = data;
|
|
964
|
-
if (!queue.length)
|
|
965
|
-
|
|
966
|
-
failQuery();
|
|
967
|
-
} else {
|
|
968
|
-
execNext();
|
|
969
|
-
}
|
|
970
|
-
}
|
|
751
|
+
if (!queue.length) if (!resources.length) failQuery();
|
|
752
|
+
else execNext();
|
|
971
753
|
return;
|
|
972
754
|
}
|
|
973
755
|
resetTimer();
|
|
974
756
|
clearQueue();
|
|
975
757
|
if (!config.random) {
|
|
976
758
|
const index = config.resources.indexOf(item.resource);
|
|
977
|
-
if (index !== -1 && index !== config.index)
|
|
978
|
-
config.index = index;
|
|
979
|
-
}
|
|
759
|
+
if (index !== -1 && index !== config.index) config.index = index;
|
|
980
760
|
}
|
|
981
761
|
status = "completed";
|
|
982
762
|
doneCallbacks.forEach((callback) => {
|
|
@@ -984,9 +764,7 @@ function sendQuery(config, payload, query, done) {
|
|
|
984
764
|
});
|
|
985
765
|
}
|
|
986
766
|
function execNext() {
|
|
987
|
-
if (status !== "pending")
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
767
|
+
if (status !== "pending") return;
|
|
990
768
|
resetTimer();
|
|
991
769
|
const resource = resources.shift();
|
|
992
770
|
if (resource === void 0) {
|
|
@@ -1006,8 +784,8 @@ function sendQuery(config, payload, query, done) {
|
|
|
1006
784
|
const item = {
|
|
1007
785
|
status: "pending",
|
|
1008
786
|
resource,
|
|
1009
|
-
callback: (
|
|
1010
|
-
moduleResponse(item,
|
|
787
|
+
callback: (status$1, data) => {
|
|
788
|
+
moduleResponse(item, status$1, data);
|
|
1011
789
|
}
|
|
1012
790
|
};
|
|
1013
791
|
queue.push(item);
|
|
@@ -1028,19 +806,12 @@ function initRedundancy(cfg) {
|
|
|
1028
806
|
queries = queries.filter((item) => item().status === "pending");
|
|
1029
807
|
}
|
|
1030
808
|
function query(payload, queryCallback, doneCallback) {
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
if (doneCallback) {
|
|
1038
|
-
doneCallback(data, error);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
);
|
|
1042
|
-
queries.push(query2);
|
|
1043
|
-
return query2;
|
|
809
|
+
const query$1 = sendQuery(config, payload, queryCallback, (data, error) => {
|
|
810
|
+
cleanup();
|
|
811
|
+
if (doneCallback) doneCallback(data, error);
|
|
812
|
+
});
|
|
813
|
+
queries.push(query$1);
|
|
814
|
+
return query$1;
|
|
1044
815
|
}
|
|
1045
816
|
function find(callback) {
|
|
1046
817
|
return queries.find((value) => {
|
|
@@ -1064,9 +835,7 @@ const redundancyCache = /* @__PURE__ */ Object.create(null);
|
|
|
1064
835
|
function getRedundancyCache(provider) {
|
|
1065
836
|
if (!redundancyCache[provider]) {
|
|
1066
837
|
const config = getAPIConfig(provider);
|
|
1067
|
-
if (!config)
|
|
1068
|
-
return;
|
|
1069
|
-
}
|
|
838
|
+
if (!config) return;
|
|
1070
839
|
const redundancy = initRedundancy(config);
|
|
1071
840
|
const cachedReundancy = {
|
|
1072
841
|
config,
|
|
@@ -1087,18 +856,14 @@ function sendAPIQuery(target, query, callback) {
|
|
|
1087
856
|
}
|
|
1088
857
|
send2 = api.send;
|
|
1089
858
|
const cached = getRedundancyCache(target);
|
|
1090
|
-
if (cached)
|
|
1091
|
-
redundancy = cached.redundancy;
|
|
1092
|
-
}
|
|
859
|
+
if (cached) redundancy = cached.redundancy;
|
|
1093
860
|
} else {
|
|
1094
861
|
const config = createAPIConfig(target);
|
|
1095
862
|
if (config) {
|
|
1096
863
|
redundancy = initRedundancy(config);
|
|
1097
864
|
const moduleKey = target.resources ? target.resources[0] : "";
|
|
1098
865
|
const api = getAPIModule(moduleKey);
|
|
1099
|
-
if (api)
|
|
1100
|
-
send2 = api.send;
|
|
1101
|
-
}
|
|
866
|
+
if (api) send2 = api.send;
|
|
1102
867
|
}
|
|
1103
868
|
}
|
|
1104
869
|
if (!redundancy || !send2) {
|
|
@@ -1133,87 +898,64 @@ function parseLoaderResponse(storage2, icons, data) {
|
|
|
1133
898
|
function checkMissing() {
|
|
1134
899
|
const pending = storage2.pendingIcons;
|
|
1135
900
|
icons.forEach((name) => {
|
|
1136
|
-
if (pending)
|
|
1137
|
-
|
|
1138
|
-
}
|
|
1139
|
-
if (!storage2.icons[name]) {
|
|
1140
|
-
storage2.missing.add(name);
|
|
1141
|
-
}
|
|
901
|
+
if (pending) pending.delete(name);
|
|
902
|
+
if (!storage2.icons[name]) storage2.missing.add(name);
|
|
1142
903
|
});
|
|
1143
904
|
}
|
|
1144
|
-
if (data && typeof data === "object") {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
return;
|
|
1150
|
-
}
|
|
1151
|
-
} catch (err) {
|
|
1152
|
-
console.error(err);
|
|
905
|
+
if (data && typeof data === "object") try {
|
|
906
|
+
const parsed = addIconSet(storage2, data);
|
|
907
|
+
if (!parsed.length) {
|
|
908
|
+
checkMissing();
|
|
909
|
+
return;
|
|
1153
910
|
}
|
|
911
|
+
} catch (err) {
|
|
912
|
+
console.error(err);
|
|
1154
913
|
}
|
|
1155
914
|
checkMissing();
|
|
1156
915
|
loadedNewIcons(storage2);
|
|
1157
916
|
}
|
|
1158
917
|
function parsePossiblyAsyncResponse(response, callback) {
|
|
1159
|
-
if (response instanceof Promise) {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
} else {
|
|
1166
|
-
callback(response);
|
|
1167
|
-
}
|
|
918
|
+
if (response instanceof Promise) response.then((data) => {
|
|
919
|
+
callback(data);
|
|
920
|
+
}).catch(() => {
|
|
921
|
+
callback(null);
|
|
922
|
+
});
|
|
923
|
+
else callback(response);
|
|
1168
924
|
}
|
|
1169
925
|
function loadNewIcons(storage2, icons) {
|
|
1170
|
-
if (!storage2.iconsToLoad)
|
|
1171
|
-
|
|
1172
|
-
} else {
|
|
1173
|
-
storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
|
|
1174
|
-
}
|
|
926
|
+
if (!storage2.iconsToLoad) storage2.iconsToLoad = icons;
|
|
927
|
+
else storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
|
|
1175
928
|
if (!storage2.iconsQueueFlag) {
|
|
1176
929
|
storage2.iconsQueueFlag = true;
|
|
1177
930
|
setTimeout(() => {
|
|
1178
931
|
storage2.iconsQueueFlag = false;
|
|
1179
932
|
const { provider, prefix } = storage2;
|
|
1180
|
-
const
|
|
933
|
+
const icons$1 = storage2.iconsToLoad;
|
|
1181
934
|
delete storage2.iconsToLoad;
|
|
1182
|
-
if (!
|
|
1183
|
-
return;
|
|
1184
|
-
}
|
|
935
|
+
if (!icons$1 || !icons$1.length) return;
|
|
1185
936
|
const customIconLoader = storage2.loadIcon;
|
|
1186
|
-
if (storage2.loadIcons && (
|
|
1187
|
-
parsePossiblyAsyncResponse(
|
|
1188
|
-
storage2
|
|
1189
|
-
|
|
1190
|
-
parseLoaderResponse(storage2, icons2, data);
|
|
1191
|
-
}
|
|
1192
|
-
);
|
|
937
|
+
if (storage2.loadIcons && (icons$1.length > 1 || !customIconLoader)) {
|
|
938
|
+
parsePossiblyAsyncResponse(storage2.loadIcons(icons$1, prefix, provider), (data) => {
|
|
939
|
+
parseLoaderResponse(storage2, icons$1, data);
|
|
940
|
+
});
|
|
1193
941
|
return;
|
|
1194
942
|
}
|
|
1195
943
|
if (customIconLoader) {
|
|
1196
|
-
|
|
944
|
+
icons$1.forEach((name) => {
|
|
1197
945
|
const response = customIconLoader(name, prefix, provider);
|
|
1198
946
|
parsePossiblyAsyncResponse(response, (data) => {
|
|
1199
947
|
const iconSet = data ? {
|
|
1200
948
|
prefix,
|
|
1201
|
-
icons: {
|
|
1202
|
-
[name]: data
|
|
1203
|
-
}
|
|
949
|
+
icons: { [name]: data }
|
|
1204
950
|
} : null;
|
|
1205
951
|
parseLoaderResponse(storage2, [name], iconSet);
|
|
1206
952
|
});
|
|
1207
953
|
});
|
|
1208
954
|
return;
|
|
1209
955
|
}
|
|
1210
|
-
const { valid, invalid } = checkIconNamesForAPI(
|
|
1211
|
-
if (invalid.length)
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
if (!valid.length) {
|
|
1215
|
-
return;
|
|
1216
|
-
}
|
|
956
|
+
const { valid, invalid } = checkIconNamesForAPI(icons$1);
|
|
957
|
+
if (invalid.length) parseLoaderResponse(storage2, invalid, null);
|
|
958
|
+
if (!valid.length) return;
|
|
1217
959
|
const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
|
|
1218
960
|
if (!api) {
|
|
1219
961
|
parseLoaderResponse(storage2, valid, null);
|
|
@@ -1233,18 +975,9 @@ const loadIcons = (icons, callback) => {
|
|
|
1233
975
|
const sortedIcons = sortIcons(cleanedIcons);
|
|
1234
976
|
if (!sortedIcons.pending.length) {
|
|
1235
977
|
let callCallback = true;
|
|
1236
|
-
if (callback) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
callback(
|
|
1240
|
-
sortedIcons.loaded,
|
|
1241
|
-
sortedIcons.missing,
|
|
1242
|
-
sortedIcons.pending,
|
|
1243
|
-
emptyCallback
|
|
1244
|
-
);
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
978
|
+
if (callback) setTimeout(() => {
|
|
979
|
+
if (callCallback) callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
|
|
980
|
+
});
|
|
1248
981
|
return () => {
|
|
1249
982
|
callCallback = false;
|
|
1250
983
|
};
|
|
@@ -1254,16 +987,12 @@ const loadIcons = (icons, callback) => {
|
|
|
1254
987
|
let lastProvider, lastPrefix;
|
|
1255
988
|
sortedIcons.pending.forEach((icon) => {
|
|
1256
989
|
const { provider, prefix } = icon;
|
|
1257
|
-
if (prefix === lastPrefix && provider === lastProvider)
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
990
|
+
if (prefix === lastPrefix && provider === lastProvider) return;
|
|
1260
991
|
lastProvider = provider;
|
|
1261
992
|
lastPrefix = prefix;
|
|
1262
993
|
sources.push(getStorage(provider, prefix));
|
|
1263
994
|
const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
|
|
1264
|
-
if (!providerNewIcons[prefix])
|
|
1265
|
-
providerNewIcons[prefix] = [];
|
|
1266
|
-
}
|
|
995
|
+
if (!providerNewIcons[prefix]) providerNewIcons[prefix] = [];
|
|
1267
996
|
});
|
|
1268
997
|
sortedIcons.pending.forEach((icon) => {
|
|
1269
998
|
const { provider, prefix, name } = icon;
|
|
@@ -1276,26 +1005,18 @@ const loadIcons = (icons, callback) => {
|
|
|
1276
1005
|
});
|
|
1277
1006
|
sources.forEach((storage2) => {
|
|
1278
1007
|
const list = newIcons[storage2.provider][storage2.prefix];
|
|
1279
|
-
if (list.length)
|
|
1280
|
-
loadNewIcons(storage2, list);
|
|
1281
|
-
}
|
|
1008
|
+
if (list.length) loadNewIcons(storage2, list);
|
|
1282
1009
|
});
|
|
1283
1010
|
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
|
|
1284
1011
|
};
|
|
1285
1012
|
function mergeCustomisations(defaults, item) {
|
|
1286
|
-
const result = {
|
|
1287
|
-
...defaults
|
|
1288
|
-
};
|
|
1013
|
+
const result = { ...defaults };
|
|
1289
1014
|
for (const key in item) {
|
|
1290
1015
|
const value = item[key];
|
|
1291
1016
|
const valueType = typeof value;
|
|
1292
1017
|
if (key in defaultIconSizeCustomisations) {
|
|
1293
|
-
if (value === null || value && (valueType === "string" || valueType === "number"))
|
|
1294
|
-
|
|
1295
|
-
}
|
|
1296
|
-
} else if (valueType === typeof result[key]) {
|
|
1297
|
-
result[key] = key === "rotate" ? value % 4 : value;
|
|
1298
|
-
}
|
|
1018
|
+
if (value === null || value && (valueType === "string" || valueType === "number")) result[key] = value;
|
|
1019
|
+
} else if (valueType === typeof result[key]) result[key] = key === "rotate" ? value % 4 : value;
|
|
1299
1020
|
}
|
|
1300
1021
|
return result;
|
|
1301
1022
|
}
|
|
@@ -1315,11 +1036,9 @@ function flipFromString(custom, flip) {
|
|
|
1315
1036
|
}
|
|
1316
1037
|
function rotateFromString(value, defaultValue = 0) {
|
|
1317
1038
|
const units = value.replace(/^-?[0-9.]*/, "");
|
|
1318
|
-
function cleanup(
|
|
1319
|
-
while (
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
return value2 % 4;
|
|
1039
|
+
function cleanup(value$1) {
|
|
1040
|
+
while (value$1 < 0) value$1 += 4;
|
|
1041
|
+
return value$1 % 4;
|
|
1323
1042
|
}
|
|
1324
1043
|
if (units === "") {
|
|
1325
1044
|
const num = parseInt(value);
|
|
@@ -1335,9 +1054,7 @@ function rotateFromString(value, defaultValue = 0) {
|
|
|
1335
1054
|
}
|
|
1336
1055
|
if (split) {
|
|
1337
1056
|
let num = parseFloat(value.slice(0, value.length - units.length));
|
|
1338
|
-
if (isNaN(num))
|
|
1339
|
-
return 0;
|
|
1340
|
-
}
|
|
1057
|
+
if (isNaN(num)) return 0;
|
|
1341
1058
|
num = num / split;
|
|
1342
1059
|
return num % 1 === 0 ? cleanup(num) : 0;
|
|
1343
1060
|
}
|
|
@@ -1346,9 +1063,7 @@ function rotateFromString(value, defaultValue = 0) {
|
|
|
1346
1063
|
}
|
|
1347
1064
|
function iconToHTML(body, attributes) {
|
|
1348
1065
|
let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
1349
|
-
for (const attr in attributes)
|
|
1350
|
-
renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
|
|
1351
|
-
}
|
|
1066
|
+
for (const attr in attributes) renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
|
|
1352
1067
|
return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
|
|
1353
1068
|
}
|
|
1354
1069
|
function encodeSVGforURL(svg) {
|
|
@@ -1363,18 +1078,13 @@ function svgToURL(svg) {
|
|
|
1363
1078
|
let policy;
|
|
1364
1079
|
function createPolicy() {
|
|
1365
1080
|
try {
|
|
1366
|
-
policy = window.trustedTypes.createPolicy("iconify", {
|
|
1367
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
1368
|
-
createHTML: (s) => s
|
|
1369
|
-
});
|
|
1081
|
+
policy = window.trustedTypes.createPolicy("iconify", { createHTML: (s) => s });
|
|
1370
1082
|
} catch (err) {
|
|
1371
1083
|
policy = null;
|
|
1372
1084
|
}
|
|
1373
1085
|
}
|
|
1374
1086
|
function cleanUpInnerHTML(html) {
|
|
1375
|
-
if (policy === void 0)
|
|
1376
|
-
createPolicy();
|
|
1377
|
-
}
|
|
1087
|
+
if (policy === void 0) createPolicy();
|
|
1378
1088
|
return policy ? policy.createHTML(html) : html;
|
|
1379
1089
|
}
|
|
1380
1090
|
const defaultExtendedIconCustomisations = {
|
|
@@ -1457,6 +1167,7 @@ const render = (icon, props, name) => {
|
|
|
1457
1167
|
case "onLoad":
|
|
1458
1168
|
case "mode":
|
|
1459
1169
|
case "ssr":
|
|
1170
|
+
case "fallback":
|
|
1460
1171
|
break;
|
|
1461
1172
|
// Forward ref
|
|
1462
1173
|
case "_ref":
|