react-inlinesvg 3.0.2 → 3.1.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/lib/index.js DELETED
@@ -1,445 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
- if (k2 === undefined) k2 = k;
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);
35
- }) : (function(o, m, k, k2) {
36
- if (k2 === undefined) k2 = k;
37
- o[k2] = m[k];
38
- }));
39
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
40
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
41
- };
42
- var __read = (this && this.__read) || function (o, n) {
43
- var m = typeof Symbol === "function" && o[Symbol.iterator];
44
- if (!m) return o;
45
- var i = m.call(o), r, ar = [], e;
46
- try {
47
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
48
- }
49
- catch (error) { e = { error: error }; }
50
- finally {
51
- try {
52
- if (r && !r.done && (m = i["return"])) m.call(i);
53
- }
54
- finally { if (e) throw e.error; }
55
- }
56
- return ar;
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));
66
- };
67
- Object.defineProperty(exports, "__esModule", { value: true });
68
- exports.cacheStore = void 0;
69
- var React = require("react");
70
- var react_from_dom_1 = require("react-from-dom");
71
- var helpers_1 = require("./helpers");
72
- exports.cacheStore = Object.create(null);
73
- var InlineSVG = /** @class */ (function (_super) {
74
- __extends(InlineSVG, _super);
75
- function InlineSVG(props) {
76
- var _this = _super.call(this, props) || this;
77
- Object.defineProperty(_this, "isInitialized", {
78
- enumerable: true,
79
- configurable: true,
80
- writable: true,
81
- value: false
82
- });
83
- Object.defineProperty(_this, "isActive", {
84
- enumerable: true,
85
- configurable: true,
86
- writable: true,
87
- value: false
88
- });
89
- Object.defineProperty(_this, "hash", {
90
- enumerable: true,
91
- configurable: true,
92
- writable: true,
93
- value: void 0
94
- });
95
- Object.defineProperty(_this, "handleLoad", {
96
- enumerable: true,
97
- configurable: true,
98
- writable: true,
99
- value: function (content, hasCache) {
100
- if (hasCache === void 0) { hasCache = false; }
101
- /* istanbul ignore else */
102
- if (_this.isActive) {
103
- _this.setState({
104
- content: content,
105
- hasCache: hasCache,
106
- status: helpers_1.STATUS.LOADED,
107
- }, _this.getElement);
108
- }
109
- }
110
- });
111
- Object.defineProperty(_this, "handleError", {
112
- enumerable: true,
113
- configurable: true,
114
- writable: true,
115
- value: function (error) {
116
- var onError = _this.props.onError;
117
- var status = error.message === 'Browser does not support SVG' ? helpers_1.STATUS.UNSUPPORTED : helpers_1.STATUS.FAILED;
118
- /* istanbul ignore else */
119
- if (_this.isActive) {
120
- _this.setState({ status: status }, function () {
121
- /* istanbul ignore else */
122
- if (typeof onError === 'function') {
123
- onError(error);
124
- }
125
- });
126
- }
127
- }
128
- });
129
- Object.defineProperty(_this, "request", {
130
- enumerable: true,
131
- configurable: true,
132
- writable: true,
133
- value: function () {
134
- var _a = _this.props, cacheRequests = _a.cacheRequests, fetchOptions = _a.fetchOptions, src = _a.src;
135
- try {
136
- if (cacheRequests) {
137
- exports.cacheStore[src] = { content: '', status: helpers_1.STATUS.LOADING };
138
- }
139
- return fetch(src, fetchOptions)
140
- .then(function (response) {
141
- var contentType = response.headers.get('content-type');
142
- var _a = __read((contentType || '').split(/ ?; ?/), 1), fileType = _a[0];
143
- if (response.status > 299) {
144
- throw new Error('Not found');
145
- }
146
- if (!['image/svg+xml', 'text/plain'].some(function (d) { return fileType.includes(d); })) {
147
- throw new Error("Content type isn't valid: ".concat(fileType));
148
- }
149
- return response.text();
150
- })
151
- .then(function (content) {
152
- var currentSrc = _this.props.src;
153
- // the current src don't match the previous one, skipping...
154
- if (src !== currentSrc) {
155
- if (exports.cacheStore[src].status === helpers_1.STATUS.LOADING) {
156
- delete exports.cacheStore[src];
157
- }
158
- return;
159
- }
160
- _this.handleLoad(content);
161
- /* istanbul ignore else */
162
- if (cacheRequests) {
163
- var cache = exports.cacheStore[src];
164
- /* istanbul ignore else */
165
- if (cache) {
166
- cache.content = content;
167
- cache.status = helpers_1.STATUS.LOADED;
168
- }
169
- }
170
- })
171
- .catch(function (error) {
172
- _this.handleError(error);
173
- /* istanbul ignore else */
174
- if (cacheRequests) {
175
- var cache = exports.cacheStore[src];
176
- /* istanbul ignore else */
177
- if (cache) {
178
- delete exports.cacheStore[src];
179
- }
180
- }
181
- });
182
- }
183
- catch (error) {
184
- return _this.handleError(new Error(error.message));
185
- }
186
- }
187
- });
188
- _this.state = {
189
- content: '',
190
- element: null,
191
- hasCache: !!props.cacheRequests && !!exports.cacheStore[props.src],
192
- status: helpers_1.STATUS.PENDING,
193
- };
194
- _this.hash = props.uniqueHash || (0, helpers_1.randomString)(8);
195
- return _this;
196
- }
197
- Object.defineProperty(InlineSVG.prototype, "componentDidMount", {
198
- enumerable: false,
199
- configurable: true,
200
- writable: true,
201
- value: function () {
202
- this.isActive = true;
203
- if (!(0, helpers_1.canUseDOM)() || this.isInitialized) {
204
- return;
205
- }
206
- var status = this.state.status;
207
- var src = this.props.src;
208
- try {
209
- /* istanbul ignore else */
210
- if (status === helpers_1.STATUS.PENDING) {
211
- /* istanbul ignore else */
212
- if (!(0, helpers_1.isSupportedEnvironment)()) {
213
- throw new Error('Browser does not support SVG');
214
- }
215
- /* istanbul ignore else */
216
- if (!src) {
217
- throw new Error('Missing src');
218
- }
219
- this.load();
220
- }
221
- }
222
- catch (error) {
223
- this.handleError(error);
224
- }
225
- this.isInitialized = true;
226
- }
227
- });
228
- Object.defineProperty(InlineSVG.prototype, "componentDidUpdate", {
229
- enumerable: false,
230
- configurable: true,
231
- writable: true,
232
- value: function (previousProps, previousState) {
233
- if (!(0, helpers_1.canUseDOM)()) {
234
- return;
235
- }
236
- var _a = this.state, hasCache = _a.hasCache, status = _a.status;
237
- var _b = this.props, onLoad = _b.onLoad, src = _b.src;
238
- if (previousState.status !== helpers_1.STATUS.READY && status === helpers_1.STATUS.READY) {
239
- /* istanbul ignore else */
240
- if (onLoad) {
241
- onLoad(src, hasCache);
242
- }
243
- }
244
- if (previousProps.src !== src) {
245
- if (!src) {
246
- this.handleError(new Error('Missing src'));
247
- return;
248
- }
249
- this.load();
250
- }
251
- }
252
- });
253
- Object.defineProperty(InlineSVG.prototype, "componentWillUnmount", {
254
- enumerable: false,
255
- configurable: true,
256
- writable: true,
257
- value: function () {
258
- this.isActive = false;
259
- }
260
- });
261
- Object.defineProperty(InlineSVG.prototype, "getNode", {
262
- enumerable: false,
263
- configurable: true,
264
- writable: true,
265
- value: function () {
266
- var _a = this.props, description = _a.description, title = _a.title;
267
- try {
268
- var svgText = this.processSVG();
269
- var node = (0, react_from_dom_1.default)(svgText, { nodeOnly: true });
270
- if (!node || !(node instanceof SVGSVGElement)) {
271
- throw new Error('Could not convert the src to a DOM Node');
272
- }
273
- var svg = this.updateSVGAttributes(node);
274
- if (description) {
275
- var originalDesc = svg.querySelector('desc');
276
- if (originalDesc && originalDesc.parentNode) {
277
- originalDesc.parentNode.removeChild(originalDesc);
278
- }
279
- var descElement = document.createElementNS('http://www.w3.org/2000/svg', 'desc');
280
- descElement.innerHTML = description;
281
- svg.prepend(descElement);
282
- }
283
- if (typeof title !== 'undefined') {
284
- var originalTitle = svg.querySelector('title');
285
- if (originalTitle && originalTitle.parentNode) {
286
- originalTitle.parentNode.removeChild(originalTitle);
287
- }
288
- if (title) {
289
- var titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
290
- titleElement.innerHTML = title;
291
- svg.prepend(titleElement);
292
- }
293
- }
294
- return svg;
295
- }
296
- catch (error) {
297
- return this.handleError(error);
298
- }
299
- }
300
- });
301
- Object.defineProperty(InlineSVG.prototype, "getElement", {
302
- enumerable: false,
303
- configurable: true,
304
- writable: true,
305
- value: function () {
306
- try {
307
- var node = this.getNode();
308
- var element = (0, react_from_dom_1.default)(node);
309
- if (!element || !React.isValidElement(element)) {
310
- throw new Error('Could not convert the src to a React element');
311
- }
312
- this.setState({
313
- element: element,
314
- status: helpers_1.STATUS.READY,
315
- });
316
- }
317
- catch (error) {
318
- this.handleError(new Error(error.message));
319
- }
320
- }
321
- });
322
- Object.defineProperty(InlineSVG.prototype, "load", {
323
- enumerable: false,
324
- configurable: true,
325
- writable: true,
326
- value: function () {
327
- var _this = this;
328
- /* istanbul ignore else */
329
- if (this.isActive) {
330
- this.setState({
331
- content: '',
332
- element: null,
333
- hasCache: false,
334
- status: helpers_1.STATUS.LOADING,
335
- }, function () {
336
- var _a = _this.props, cacheRequests = _a.cacheRequests, src = _a.src;
337
- var cache = cacheRequests && exports.cacheStore[src];
338
- if (cache && cache.status === helpers_1.STATUS.LOADED) {
339
- _this.handleLoad(cache.content, true);
340
- return;
341
- }
342
- var dataURI = src.match(/data:image\/svg[^,]*?(;base64)?,(.*)/);
343
- var inlineSrc;
344
- if (dataURI) {
345
- inlineSrc = dataURI[1] ? window.atob(dataURI[2]) : decodeURIComponent(dataURI[2]);
346
- }
347
- else if (src.includes('<svg')) {
348
- inlineSrc = src;
349
- }
350
- if (inlineSrc) {
351
- _this.handleLoad(inlineSrc);
352
- return;
353
- }
354
- _this.request();
355
- });
356
- }
357
- }
358
- });
359
- Object.defineProperty(InlineSVG.prototype, "updateSVGAttributes", {
360
- enumerable: false,
361
- configurable: true,
362
- writable: true,
363
- value: function (node) {
364
- var _this = this;
365
- var _a = this.props, _b = _a.baseURL, baseURL = _b === void 0 ? '' : _b, uniquifyIDs = _a.uniquifyIDs;
366
- var replaceableAttributes = ['id', 'href', 'xlink:href', 'xlink:role', 'xlink:arcrole'];
367
- var linkAttributes = ['href', 'xlink:href'];
368
- var isDataValue = function (name, value) {
369
- return linkAttributes.includes(name) && (value ? !value.includes('#') : false);
370
- };
371
- if (!uniquifyIDs) {
372
- return node;
373
- }
374
- __spreadArray([], __read(node.children), false).map(function (d) {
375
- if (d.attributes && d.attributes.length) {
376
- var attributes_1 = Object.values(d.attributes).map(function (a) {
377
- var attribute = a;
378
- var match = a.value.match(/url\((.*?)\)/);
379
- if (match && match[1]) {
380
- attribute.value = a.value.replace(match[0], "url(".concat(baseURL).concat(match[1], "__").concat(_this.hash, ")"));
381
- }
382
- return attribute;
383
- });
384
- replaceableAttributes.forEach(function (r) {
385
- var attribute = attributes_1.find(function (a) { return a.name === r; });
386
- if (attribute && !isDataValue(r, attribute.value)) {
387
- attribute.value = "".concat(attribute.value, "__").concat(_this.hash);
388
- }
389
- });
390
- }
391
- if (d.children.length) {
392
- return _this.updateSVGAttributes(d);
393
- }
394
- return d;
395
- });
396
- return node;
397
- }
398
- });
399
- Object.defineProperty(InlineSVG.prototype, "processSVG", {
400
- enumerable: false,
401
- configurable: true,
402
- writable: true,
403
- value: function () {
404
- var content = this.state.content;
405
- var preProcessor = this.props.preProcessor;
406
- if (preProcessor) {
407
- return preProcessor(content);
408
- }
409
- return content;
410
- }
411
- });
412
- Object.defineProperty(InlineSVG.prototype, "render", {
413
- enumerable: false,
414
- configurable: true,
415
- writable: true,
416
- value: function () {
417
- var _a = this.state, element = _a.element, status = _a.status;
418
- 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;
419
- var elementProps = (0, helpers_1.omit)(this.props, 'baseURL', 'cacheRequests', 'children', 'description', 'fetchOptions', 'innerRef', 'loader', 'onError', 'onLoad', 'preProcessor', 'src', 'title', 'uniqueHash', 'uniquifyIDs');
420
- if (!(0, helpers_1.canUseDOM)()) {
421
- return loader;
422
- }
423
- if (element) {
424
- return React.cloneElement(element, __assign({ ref: innerRef }, elementProps));
425
- }
426
- if ([helpers_1.STATUS.UNSUPPORTED, helpers_1.STATUS.FAILED].includes(status)) {
427
- return children;
428
- }
429
- return loader;
430
- }
431
- });
432
- Object.defineProperty(InlineSVG, "defaultProps", {
433
- enumerable: true,
434
- configurable: true,
435
- writable: true,
436
- value: {
437
- cacheRequests: true,
438
- uniquifyIDs: false,
439
- }
440
- });
441
- return InlineSVG;
442
- }(React.PureComponent));
443
- exports.default = InlineSVG;
444
- __exportStar(require("./types"), exports);
445
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,iDAAqC;AAErC,qCAA0F;AAG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 'react';
2
- export type ErrorCallback = (error: Error | FetchError) => void;
3
- export type LoadCallback = (src: string, isCached: boolean) => void;
4
- export type PlainObject<T = unknown> = Record<string | number | symbol, T>;
5
- export type PreProcessorCallback = (code: string) => string;
6
- export interface Props extends Omit<React.SVGProps<SVGElement>, 'onLoad' | 'onError' | 'ref'> {
7
- baseURL?: string;
8
- cacheRequests?: boolean;
9
- children?: React.ReactNode;
10
- description?: string;
11
- fetchOptions?: RequestInit;
12
- innerRef?: React.Ref<SVGElement>;
13
- loader?: React.ReactNode;
14
- onError?: ErrorCallback;
15
- onLoad?: LoadCallback;
16
- preProcessor?: PreProcessorCallback;
17
- src: string;
18
- title?: string | null;
19
- uniqueHash?: string;
20
- uniquifyIDs?: boolean;
21
- }
22
- export interface State {
23
- content: string;
24
- element: React.ReactNode;
25
- hasCache: boolean;
26
- status: string;
27
- }
28
- export interface FetchError extends Error {
29
- code: string;
30
- errno: string;
31
- message: string;
32
- type: string;
33
- }
34
- export interface StorageItem {
35
- content: string;
36
- status: string;
37
- }
package/lib/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}