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