react-inlinesvg 2.3.0 → 3.0.0
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/README.md +1 -1
- package/esm/helpers.d.ts +1 -1
- package/esm/helpers.js +8 -7
- package/esm/helpers.js.map +1 -1
- package/esm/index.d.ts +5 -6
- package/esm/index.js +67 -81
- package/esm/index.js.map +1 -1
- package/esm/types.d.ts +0 -3
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +10 -9
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +5 -6
- package/lib/index.js +78 -88
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +0 -3
- package/package.json +54 -56
- package/src/helpers.ts +13 -8
- package/src/index.tsx +124 -146
- package/src/types.ts +0 -3
package/lib/index.js
CHANGED
|
@@ -27,7 +27,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
27
27
|
};
|
|
28
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
29
|
if (k2 === undefined) k2 = k;
|
|
30
|
-
Object.
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
31
35
|
}) : (function(o, m, k, k2) {
|
|
32
36
|
if (k2 === undefined) k2 = k;
|
|
33
37
|
o[k2] = m[k];
|
|
@@ -51,10 +55,14 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
51
55
|
}
|
|
52
56
|
return ar;
|
|
53
57
|
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
55
|
-
for (var i = 0,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
59
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
60
|
+
if (ar || !(i in from)) {
|
|
61
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
62
|
+
ar[i] = from[i];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
58
66
|
};
|
|
59
67
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
68
|
exports.cacheStore = void 0;
|
|
@@ -67,14 +75,6 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
67
75
|
function InlineSVG(props) {
|
|
68
76
|
var _this = _super.call(this, props) || this;
|
|
69
77
|
_this.isActive = false;
|
|
70
|
-
_this.handleCacheQueue = function (content) {
|
|
71
|
-
/* istanbul ignore else */
|
|
72
|
-
if (typeof content === 'string') {
|
|
73
|
-
_this.handleLoad(content);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
_this.handleError(content);
|
|
77
|
-
};
|
|
78
78
|
_this.handleLoad = function (content) {
|
|
79
79
|
/* istanbul ignore else */
|
|
80
80
|
if (_this.isActive) {
|
|
@@ -101,7 +101,7 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
101
101
|
var _a = _this.props, cacheRequests = _a.cacheRequests, fetchOptions = _a.fetchOptions, src = _a.src;
|
|
102
102
|
try {
|
|
103
103
|
if (cacheRequests) {
|
|
104
|
-
exports.cacheStore[src] = { content: '', status: helpers_1.STATUS.LOADING
|
|
104
|
+
exports.cacheStore[src] = { content: '', status: helpers_1.STATUS.LOADING };
|
|
105
105
|
}
|
|
106
106
|
return fetch(src, fetchOptions)
|
|
107
107
|
.then(function (response) {
|
|
@@ -110,8 +110,8 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
110
110
|
if (response.status > 299) {
|
|
111
111
|
throw new Error('Not found');
|
|
112
112
|
}
|
|
113
|
-
if (!['image/svg+xml', 'text/plain'].some(function (d) { return fileType.
|
|
114
|
-
throw new Error("Content type isn't valid: "
|
|
113
|
+
if (!['image/svg+xml', 'text/plain'].some(function (d) { return fileType.includes(d); })) {
|
|
114
|
+
throw new Error("Content type isn't valid: ".concat(fileType));
|
|
115
115
|
}
|
|
116
116
|
return response.text();
|
|
117
117
|
})
|
|
@@ -119,6 +119,9 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
119
119
|
var currentSrc = _this.props.src;
|
|
120
120
|
// the current src don't match the previous one, skipping...
|
|
121
121
|
if (src !== currentSrc) {
|
|
122
|
+
if (exports.cacheStore[src].status === helpers_1.STATUS.LOADING) {
|
|
123
|
+
delete exports.cacheStore[src];
|
|
124
|
+
}
|
|
122
125
|
return;
|
|
123
126
|
}
|
|
124
127
|
_this.handleLoad(content);
|
|
@@ -129,10 +132,6 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
129
132
|
if (cache) {
|
|
130
133
|
cache.content = content;
|
|
131
134
|
cache.status = helpers_1.STATUS.LOADED;
|
|
132
|
-
cache.queue = cache.queue.filter(function (cb) {
|
|
133
|
-
cb(content);
|
|
134
|
-
return false;
|
|
135
|
-
});
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
})
|
|
@@ -143,9 +142,6 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
143
142
|
var cache = exports.cacheStore[src];
|
|
144
143
|
/* istanbul ignore else */
|
|
145
144
|
if (cache) {
|
|
146
|
-
cache.queue.forEach(function (cb) {
|
|
147
|
-
cb(error);
|
|
148
|
-
});
|
|
149
145
|
delete exports.cacheStore[src];
|
|
150
146
|
}
|
|
151
147
|
}
|
|
@@ -161,12 +157,12 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
161
157
|
hasCache: !!props.cacheRequests && !!exports.cacheStore[props.src],
|
|
162
158
|
status: helpers_1.STATUS.PENDING,
|
|
163
159
|
};
|
|
164
|
-
_this.hash = props.uniqueHash || helpers_1.randomString(8);
|
|
160
|
+
_this.hash = props.uniqueHash || (0, helpers_1.randomString)(8);
|
|
165
161
|
return _this;
|
|
166
162
|
}
|
|
167
163
|
InlineSVG.prototype.componentDidMount = function () {
|
|
168
164
|
this.isActive = true;
|
|
169
|
-
if (!helpers_1.canUseDOM()) {
|
|
165
|
+
if (!(0, helpers_1.canUseDOM)()) {
|
|
170
166
|
return;
|
|
171
167
|
}
|
|
172
168
|
var status = this.state.status;
|
|
@@ -175,7 +171,7 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
175
171
|
/* istanbul ignore else */
|
|
176
172
|
if (status === helpers_1.STATUS.PENDING) {
|
|
177
173
|
/* istanbul ignore else */
|
|
178
|
-
if (!helpers_1.isSupportedEnvironment()) {
|
|
174
|
+
if (!(0, helpers_1.isSupportedEnvironment)()) {
|
|
179
175
|
throw new Error('Browser does not support SVG');
|
|
180
176
|
}
|
|
181
177
|
/* istanbul ignore else */
|
|
@@ -189,19 +185,19 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
189
185
|
this.handleError(error);
|
|
190
186
|
}
|
|
191
187
|
};
|
|
192
|
-
InlineSVG.prototype.componentDidUpdate = function (
|
|
193
|
-
if (!helpers_1.canUseDOM()) {
|
|
188
|
+
InlineSVG.prototype.componentDidUpdate = function (previousProps, previousState) {
|
|
189
|
+
if (!(0, helpers_1.canUseDOM)()) {
|
|
194
190
|
return;
|
|
195
191
|
}
|
|
196
192
|
var _a = this.state, hasCache = _a.hasCache, status = _a.status;
|
|
197
193
|
var _b = this.props, onLoad = _b.onLoad, src = _b.src;
|
|
198
|
-
if (
|
|
194
|
+
if (previousState.status !== helpers_1.STATUS.READY && status === helpers_1.STATUS.READY) {
|
|
199
195
|
/* istanbul ignore else */
|
|
200
196
|
if (onLoad) {
|
|
201
197
|
onLoad(src, hasCache);
|
|
202
198
|
}
|
|
203
199
|
}
|
|
204
|
-
if (
|
|
200
|
+
if (previousProps.src !== src) {
|
|
205
201
|
if (!src) {
|
|
206
202
|
this.handleError(new Error('Missing src'));
|
|
207
203
|
return;
|
|
@@ -212,54 +208,11 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
212
208
|
InlineSVG.prototype.componentWillUnmount = function () {
|
|
213
209
|
this.isActive = false;
|
|
214
210
|
};
|
|
215
|
-
InlineSVG.prototype.processSVG = function () {
|
|
216
|
-
var content = this.state.content;
|
|
217
|
-
var preProcessor = this.props.preProcessor;
|
|
218
|
-
if (preProcessor) {
|
|
219
|
-
return preProcessor(content);
|
|
220
|
-
}
|
|
221
|
-
return content;
|
|
222
|
-
};
|
|
223
|
-
InlineSVG.prototype.updateSVGAttributes = function (node) {
|
|
224
|
-
var _this = this;
|
|
225
|
-
var _a = this.props, _b = _a.baseURL, baseURL = _b === void 0 ? '' : _b, uniquifyIDs = _a.uniquifyIDs;
|
|
226
|
-
var replaceableAttributes = ['id', 'href', 'xlink:href', 'xlink:role', 'xlink:arcrole'];
|
|
227
|
-
var linkAttributes = ['href', 'xlink:href'];
|
|
228
|
-
var isDataValue = function (name, value) {
|
|
229
|
-
return linkAttributes.indexOf(name) >= 0 && (value ? value.indexOf('#') < 0 : false);
|
|
230
|
-
};
|
|
231
|
-
if (!uniquifyIDs) {
|
|
232
|
-
return node;
|
|
233
|
-
}
|
|
234
|
-
__spreadArray([], __read(node.children)).map(function (d) {
|
|
235
|
-
if (d.attributes && d.attributes.length) {
|
|
236
|
-
var attributes_1 = Object.values(d.attributes).map(function (a) {
|
|
237
|
-
var attr = a;
|
|
238
|
-
var match = a.value.match(/url\((.*?)\)/);
|
|
239
|
-
if (match && match[1]) {
|
|
240
|
-
attr.value = a.value.replace(match[0], "url(" + baseURL + match[1] + "__" + _this.hash + ")");
|
|
241
|
-
}
|
|
242
|
-
return attr;
|
|
243
|
-
});
|
|
244
|
-
replaceableAttributes.forEach(function (r) {
|
|
245
|
-
var attribute = attributes_1.find(function (a) { return a.name === r; });
|
|
246
|
-
if (attribute && !isDataValue(r, attribute.value)) {
|
|
247
|
-
attribute.value = attribute.value + "__" + _this.hash;
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
if (d.children.length) {
|
|
252
|
-
return _this.updateSVGAttributes(d);
|
|
253
|
-
}
|
|
254
|
-
return d;
|
|
255
|
-
});
|
|
256
|
-
return node;
|
|
257
|
-
};
|
|
258
211
|
InlineSVG.prototype.getNode = function () {
|
|
259
212
|
var _a = this.props, description = _a.description, title = _a.title;
|
|
260
213
|
try {
|
|
261
214
|
var svgText = this.processSVG();
|
|
262
|
-
var node = react_from_dom_1.default(svgText, { nodeOnly: true });
|
|
215
|
+
var node = (0, react_from_dom_1.default)(svgText, { nodeOnly: true });
|
|
263
216
|
if (!node || !(node instanceof SVGSVGElement)) {
|
|
264
217
|
throw new Error('Could not convert the src to a DOM Node');
|
|
265
218
|
}
|
|
@@ -291,7 +244,7 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
291
244
|
InlineSVG.prototype.getElement = function () {
|
|
292
245
|
try {
|
|
293
246
|
var node = this.getNode();
|
|
294
|
-
var element = react_from_dom_1.default(node);
|
|
247
|
+
var element = (0, react_from_dom_1.default)(node);
|
|
295
248
|
if (!element || !React.isValidElement(element)) {
|
|
296
249
|
throw new Error('Could not convert the src to a React element');
|
|
297
250
|
}
|
|
@@ -315,22 +268,16 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
315
268
|
}, function () {
|
|
316
269
|
var _a = _this.props, cacheRequests = _a.cacheRequests, src = _a.src;
|
|
317
270
|
var cache = cacheRequests && exports.cacheStore[src];
|
|
318
|
-
if (cache) {
|
|
319
|
-
|
|
320
|
-
if (cache.status === helpers_1.STATUS.LOADING) {
|
|
321
|
-
cache.queue.push(_this.handleCacheQueue);
|
|
322
|
-
}
|
|
323
|
-
else if (cache.status === helpers_1.STATUS.LOADED) {
|
|
324
|
-
_this.handleLoad(cache.content);
|
|
325
|
-
}
|
|
271
|
+
if (cache && cache.status === helpers_1.STATUS.LOADED) {
|
|
272
|
+
_this.handleLoad(cache.content);
|
|
326
273
|
return;
|
|
327
274
|
}
|
|
328
275
|
var dataURI = src.match(/data:image\/svg[^,]*?(;base64)?,(.*)/);
|
|
329
276
|
var inlineSrc;
|
|
330
277
|
if (dataURI) {
|
|
331
|
-
inlineSrc = dataURI[1] ? atob(dataURI[2]) : decodeURIComponent(dataURI[2]);
|
|
278
|
+
inlineSrc = dataURI[1] ? window.atob(dataURI[2]) : decodeURIComponent(dataURI[2]);
|
|
332
279
|
}
|
|
333
|
-
else if (src.
|
|
280
|
+
else if (src.includes('<svg')) {
|
|
334
281
|
inlineSrc = src;
|
|
335
282
|
}
|
|
336
283
|
if (inlineSrc) {
|
|
@@ -341,17 +288,60 @@ var InlineSVG = /** @class */ (function (_super) {
|
|
|
341
288
|
});
|
|
342
289
|
}
|
|
343
290
|
};
|
|
291
|
+
InlineSVG.prototype.updateSVGAttributes = function (node) {
|
|
292
|
+
var _this = this;
|
|
293
|
+
var _a = this.props, _b = _a.baseURL, baseURL = _b === void 0 ? '' : _b, uniquifyIDs = _a.uniquifyIDs;
|
|
294
|
+
var replaceableAttributes = ['id', 'href', 'xlink:href', 'xlink:role', 'xlink:arcrole'];
|
|
295
|
+
var linkAttributes = ['href', 'xlink:href'];
|
|
296
|
+
var isDataValue = function (name, value) {
|
|
297
|
+
return linkAttributes.includes(name) && (value ? !value.includes('#') : false);
|
|
298
|
+
};
|
|
299
|
+
if (!uniquifyIDs) {
|
|
300
|
+
return node;
|
|
301
|
+
}
|
|
302
|
+
__spreadArray([], __read(node.children), false).map(function (d) {
|
|
303
|
+
if (d.attributes && d.attributes.length) {
|
|
304
|
+
var attributes_1 = Object.values(d.attributes).map(function (a) {
|
|
305
|
+
var attribute = a;
|
|
306
|
+
var match = a.value.match(/url\((.*?)\)/);
|
|
307
|
+
if (match && match[1]) {
|
|
308
|
+
attribute.value = a.value.replace(match[0], "url(".concat(baseURL).concat(match[1], "__").concat(_this.hash, ")"));
|
|
309
|
+
}
|
|
310
|
+
return attribute;
|
|
311
|
+
});
|
|
312
|
+
replaceableAttributes.forEach(function (r) {
|
|
313
|
+
var attribute = attributes_1.find(function (a) { return a.name === r; });
|
|
314
|
+
if (attribute && !isDataValue(r, attribute.value)) {
|
|
315
|
+
attribute.value = "".concat(attribute.value, "__").concat(_this.hash);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
if (d.children.length) {
|
|
320
|
+
return _this.updateSVGAttributes(d);
|
|
321
|
+
}
|
|
322
|
+
return d;
|
|
323
|
+
});
|
|
324
|
+
return node;
|
|
325
|
+
};
|
|
326
|
+
InlineSVG.prototype.processSVG = function () {
|
|
327
|
+
var content = this.state.content;
|
|
328
|
+
var preProcessor = this.props.preProcessor;
|
|
329
|
+
if (preProcessor) {
|
|
330
|
+
return preProcessor(content);
|
|
331
|
+
}
|
|
332
|
+
return content;
|
|
333
|
+
};
|
|
344
334
|
InlineSVG.prototype.render = function () {
|
|
345
335
|
var _a = this.state, element = _a.element, status = _a.status;
|
|
346
336
|
var _b = this.props, _c = _b.children, children = _c === void 0 ? null : _c, innerRef = _b.innerRef, _d = _b.loader, loader = _d === void 0 ? null : _d;
|
|
347
|
-
var elementProps = helpers_1.
|
|
348
|
-
if (!helpers_1.canUseDOM()) {
|
|
337
|
+
var elementProps = (0, helpers_1.omit)(this.props, 'baseURL', 'cacheRequests', 'children', 'description', 'fetchOptions', 'innerRef', 'loader', 'onError', 'onLoad', 'preProcessor', 'src', 'title', 'uniqueHash', 'uniquifyIDs');
|
|
338
|
+
if (!(0, helpers_1.canUseDOM)()) {
|
|
349
339
|
return loader;
|
|
350
340
|
}
|
|
351
341
|
if (element) {
|
|
352
342
|
return React.cloneElement(element, __assign({ ref: innerRef }, elementProps));
|
|
353
343
|
}
|
|
354
|
-
if ([helpers_1.STATUS.UNSUPPORTED, helpers_1.STATUS.FAILED].
|
|
344
|
+
if ([helpers_1.STATUS.UNSUPPORTED, helpers_1.STATUS.FAILED].includes(status)) {
|
|
355
345
|
return children;
|
|
356
346
|
}
|
|
357
347
|
return loader;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,iDAAqC;AAErC,qCAA0F;AAG7E,QAAA,UAAU,GAAmC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAE9E;IAAuC,6BAAiC;IAStE,mBAAY,KAAY;QAAxB,YACE,kBAAM,KAAK,CAAC,SAUb;QAnBO,cAAQ,GAAG,KAAK,CAAC;QAgJjB,gBAAU,GAAG,UAAC,OAAe;YACnC,0BAA0B;YAC1B,IAAI,KAAI,CAAC,QAAQ,EAAE;gBACjB,KAAI,CAAC,QAAQ,CACX;oBACE,OAAO,SAAA;oBACP,MAAM,EAAE,gBAAM,CAAC,MAAM;iBACtB,EACD,KAAI,CAAC,UAAU,CAChB,CAAC;aACH;QACH,CAAC,CAAC;QAEM,iBAAW,GAAG,UAAC,KAAyB;YACtC,IAAA,OAAO,GAAK,KAAI,CAAC,KAAK,QAAf,CAAgB;YAC/B,IAAM,MAAM,GACV,KAAK,CAAC,OAAO,KAAK,8BAA8B,CAAC,CAAC,CAAC,gBAAM,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAM,CAAC,MAAM,CAAC;YAExF,0BAA0B;YAC1B,IAAI,KAAI,CAAC,QAAQ,EAAE;gBACjB,KAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAA,EAAE,EAAE;oBACxB,0BAA0B;oBAC1B,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;wBACjC,OAAO,CAAC,KAAK,CAAC,CAAC;qBAChB;gBACH,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC;QAEM,aAAO,GAAG;YACV,IAAA,KAAu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|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare type Callback = (...args: any[]) => void;
|
|
3
2
|
export declare type ErrorCallback = (error: Error | FetchError) => void;
|
|
4
3
|
export declare type LoadCallback = (src: string, isCached: boolean) => void;
|
|
5
4
|
export declare type PlainObject<T = unknown> = Record<string | number | symbol, T>;
|
|
@@ -34,7 +33,5 @@ export interface FetchError extends Error {
|
|
|
34
33
|
}
|
|
35
34
|
export interface StorageItem {
|
|
36
35
|
content: string;
|
|
37
|
-
queue: Callback[];
|
|
38
36
|
status: string;
|
|
39
37
|
}
|
|
40
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-inlinesvg",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "An SVG loader for React",
|
|
5
5
|
"author": "Gil Barbara <gilbarbara@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -32,57 +32,45 @@
|
|
|
32
32
|
"types": "esm",
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"react": "^16.8.0 || ^17.0.0"
|
|
35
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"exenv": "^1.2.2",
|
|
39
|
-
"react-from-dom": "^0.6.
|
|
39
|
+
"react-from-dom": "^0.6.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gilbarbara/
|
|
42
|
+
"@gilbarbara/eslint-config": "^0.2.1",
|
|
43
|
+
"@gilbarbara/helpers": "^0.5.1",
|
|
44
|
+
"@gilbarbara/prettier-config": "^0.1.0",
|
|
43
45
|
"@gilbarbara/tsconfig": "^0.1.0",
|
|
44
|
-
"@size-limit/preset-small-lib": "^
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
46
|
+
"@size-limit/preset-small-lib": "^7.0.8",
|
|
47
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
48
|
+
"@testing-library/react": "^13.0.1",
|
|
47
49
|
"@types/exenv": "^1.2.0",
|
|
48
|
-
"@types/fetch-mock": "^7.3.
|
|
49
|
-
"@types/jest": "^
|
|
50
|
-
"@types/node": "^
|
|
51
|
-
"@types/node-fetch": "^2.
|
|
52
|
-
"@types/react": "^
|
|
53
|
-
"@types/react-dom": "^
|
|
54
|
-
"
|
|
55
|
-
"@typescript-eslint/parser": "^4.22.0",
|
|
50
|
+
"@types/fetch-mock": "^7.3.5",
|
|
51
|
+
"@types/jest": "^27.4.1",
|
|
52
|
+
"@types/node": "^17.0.24",
|
|
53
|
+
"@types/node-fetch": "^2.6.1",
|
|
54
|
+
"@types/react": "^18.0.5",
|
|
55
|
+
"@types/react-dom": "^18.0.1",
|
|
56
|
+
"cross-fetch": "^3.1.5",
|
|
56
57
|
"del-cli": "^3.0.1",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"eslint-config-airbnb": "^18.2.1",
|
|
61
|
-
"eslint-config-prettier": "^8.3.0",
|
|
62
|
-
"eslint-plugin-import": "^2.22.1",
|
|
63
|
-
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
64
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
65
|
-
"eslint-plugin-react": "^7.23.2",
|
|
66
|
-
"eslint-plugin-react-hooks": "^4.2.0",
|
|
67
|
-
"http-server": "^0.12.3",
|
|
68
|
-
"husky": "^4.3.8",
|
|
69
|
-
"jest": "^26.6.3",
|
|
58
|
+
"http-server": "^14.1.0",
|
|
59
|
+
"husky": "^7.0.4",
|
|
60
|
+
"jest": "^27.5.1",
|
|
70
61
|
"jest-chain": "^1.1.5",
|
|
71
|
-
"jest-
|
|
72
|
-
"jest-extended": "^0.11.5",
|
|
62
|
+
"jest-extended": "^2.0.0",
|
|
73
63
|
"jest-fetch-mock": "^3.0.3",
|
|
74
|
-
"jest-serializer-html": "^7.
|
|
75
|
-
"jest-watch-typeahead": "^0.
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"react": "^16.14.0",
|
|
79
|
-
"react-dom": "^16.14.0",
|
|
64
|
+
"jest-serializer-html": "^7.1.0",
|
|
65
|
+
"jest-watch-typeahead": "^1.0.0",
|
|
66
|
+
"react": "^18.0.0",
|
|
67
|
+
"react-dom": "^18.0.0",
|
|
80
68
|
"repo-tools": "^0.2.2",
|
|
81
|
-
"size-limit": "^
|
|
82
|
-
"start-server-and-test": "^1.
|
|
83
|
-
"ts-jest": "^
|
|
84
|
-
"ts-node": "^
|
|
85
|
-
"typescript": "^4.
|
|
69
|
+
"size-limit": "^7.0.8",
|
|
70
|
+
"start-server-and-test": "^1.14.0",
|
|
71
|
+
"ts-jest": "^27.1.4",
|
|
72
|
+
"ts-node": "^10.7.0",
|
|
73
|
+
"typescript": "^4.6.3"
|
|
86
74
|
},
|
|
87
75
|
"scripts": {
|
|
88
76
|
"build": "npm run clean && npm run build:cjs && npm run build:esm",
|
|
@@ -99,28 +87,38 @@
|
|
|
99
87
|
"format": "prettier \"**/*.{js,jsx,json,yml,yaml,css,less,scss,ts,tsx,md,graphql,mdx}\" --write",
|
|
100
88
|
"validate": "npm run lint && npm run test && npm run build && npm run size",
|
|
101
89
|
"size": "size-limit",
|
|
102
|
-
"prepublishOnly": "npm run validate"
|
|
90
|
+
"prepublishOnly": "npm run validate",
|
|
91
|
+
"prepare": "husky install"
|
|
103
92
|
},
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
93
|
+
"eslintConfig": {
|
|
94
|
+
"extends": [
|
|
95
|
+
"@gilbarbara/eslint-config"
|
|
96
|
+
],
|
|
97
|
+
"overrides": [
|
|
98
|
+
{
|
|
99
|
+
"files": [
|
|
100
|
+
"test/**/*.ts?(x)"
|
|
101
|
+
],
|
|
102
|
+
"rules": {
|
|
103
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
104
|
+
"no-console": "off",
|
|
105
|
+
"testing-library/no-container": "off",
|
|
106
|
+
"testing-library/no-node-access": "off"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
109
110
|
},
|
|
111
|
+
"prettier": "@gilbarbara/prettier-config",
|
|
110
112
|
"size-limit": [
|
|
111
113
|
{
|
|
114
|
+
"name": "lib",
|
|
112
115
|
"path": "./lib/index.js",
|
|
113
|
-
"limit": "
|
|
116
|
+
"limit": "9 kB"
|
|
114
117
|
},
|
|
115
118
|
{
|
|
119
|
+
"name": "esm",
|
|
116
120
|
"path": "./esm/index.js",
|
|
117
|
-
"limit": "
|
|
121
|
+
"limit": "9 kB"
|
|
118
122
|
}
|
|
119
|
-
]
|
|
120
|
-
"husky": {
|
|
121
|
-
"hooks": {
|
|
122
|
-
"post-merge": "repo-tools install-packages",
|
|
123
|
-
"pre-commit": "repo-tools check-remote && npm run validate"
|
|
124
|
-
}
|
|
125
|
-
}
|
|
123
|
+
]
|
|
126
124
|
}
|
package/src/helpers.ts
CHANGED
|
@@ -26,8 +26,15 @@ export function supportsInlineSVG(): boolean {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const div = document.createElement('div');
|
|
29
|
+
|
|
29
30
|
div.innerHTML = '<svg />';
|
|
30
|
-
|
|
31
|
+
const svg = div.firstChild as SVGSVGElement;
|
|
32
|
+
|
|
33
|
+
return !!svg && svg.namespaceURI === 'http://www.w3.org/2000/svg';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function randomCharacter(character: string) {
|
|
37
|
+
return character[Math.floor(Math.random() * character.length)];
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
export function randomString(length: number): string {
|
|
@@ -35,11 +42,9 @@ export function randomString(length: number): string {
|
|
|
35
42
|
const numbers = '1234567890';
|
|
36
43
|
const charset = `${letters}${letters.toUpperCase()}${numbers}`;
|
|
37
44
|
|
|
38
|
-
const randomCharacter = (character: string) =>
|
|
39
|
-
character[Math.floor(Math.random() * character.length)];
|
|
40
|
-
|
|
41
45
|
let R = '';
|
|
42
|
-
|
|
46
|
+
|
|
47
|
+
for (let index = 0; index < length; index++) {
|
|
43
48
|
R += randomCharacter(charset);
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -49,7 +54,7 @@ export function randomString(length: number): string {
|
|
|
49
54
|
/**
|
|
50
55
|
* Remove properties from an object
|
|
51
56
|
*/
|
|
52
|
-
export function
|
|
57
|
+
export function omit<T extends PlainObject, K extends keyof T>(
|
|
53
58
|
input: T,
|
|
54
59
|
...filter: K[]
|
|
55
60
|
): Omit<T, K> {
|
|
@@ -58,11 +63,11 @@ export function removeProperties<T extends PlainObject, K extends keyof T>(
|
|
|
58
63
|
for (const key in input) {
|
|
59
64
|
/* istanbul ignore else */
|
|
60
65
|
if ({}.hasOwnProperty.call(input, key)) {
|
|
61
|
-
if (!filter.includes(
|
|
66
|
+
if (!filter.includes(key as unknown as K)) {
|
|
62
67
|
output[key] = input[key];
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
return output
|
|
72
|
+
return output as Omit<T, K>;
|
|
68
73
|
}
|