@splunk/visualizations-shared 26.4.1 → 27.1.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.
Files changed (63) hide show
  1. package/.loki/reference/chrome_docker_SizeAwareWrapper_50_parent.png +0 -0
  2. package/.loki/reference/chrome_docker_SizeAwareWrapper_Fix_size_container.png +0 -0
  3. package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container.png +0 -0
  4. package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container_with_extra_wrapper.png +0 -0
  5. package/Downloader.js +164 -403
  6. package/Downloader.js.map +7 -1
  7. package/FileDownloader.js +121 -557
  8. package/FileDownloader.js.map +7 -1
  9. package/JSONSchemaUtils.js +58 -134
  10. package/JSONSchemaUtils.js.map +7 -1
  11. package/Message.js +105 -270
  12. package/Message.js.map +7 -1
  13. package/RemoteIcon.js +272 -736
  14. package/RemoteIcon.js.map +7 -1
  15. package/RemoteImage.js +190 -458
  16. package/RemoteImage.js.map +7 -1
  17. package/SanitizeProps.js +117 -238
  18. package/SanitizeProps.js.map +7 -1
  19. package/SizeAwareWrapper.js +108 -306
  20. package/SizeAwareWrapper.js.map +7 -1
  21. package/SizeAwareWrapperDeprecated.js +117 -326
  22. package/SizeAwareWrapperDeprecated.js.map +7 -1
  23. package/VisualizationDocPage.js +212 -461
  24. package/VisualizationDocPage.js.map +7 -1
  25. package/colorConstants.js +81 -132
  26. package/colorConstants.js.map +7 -1
  27. package/colorUtils.js +47 -134
  28. package/colorUtils.js.map +7 -1
  29. package/configUtils.js +28 -112
  30. package/configUtils.js.map +7 -1
  31. package/console.js +45 -183
  32. package/console.js.map +7 -1
  33. package/dataSourceUtils.js +45 -140
  34. package/dataSourceUtils.js.map +7 -1
  35. package/domUtils.js +58 -122
  36. package/domUtils.js.map +7 -1
  37. package/hocUtils.js +45 -122
  38. package/hocUtils.js.map +7 -1
  39. package/i18n.js +168 -323
  40. package/i18n.js.map +7 -1
  41. package/iconUtils.js +47 -178
  42. package/iconUtils.js.map +7 -1
  43. package/mapUtils.js +45 -122
  44. package/mapUtils.js.map +7 -1
  45. package/numberUtils.js +101 -275
  46. package/numberUtils.js.map +7 -1
  47. package/package.json +18 -22
  48. package/previewVizMessage.js +28 -108
  49. package/previewVizMessage.js.map +7 -1
  50. package/propUtils.js +88 -212
  51. package/propUtils.js.map +7 -1
  52. package/schemaUtils.js +58 -185
  53. package/schemaUtils.js.map +7 -1
  54. package/simpleXMLOptions.js +142 -225
  55. package/simpleXMLOptions.js.map +7 -1
  56. package/style.js +65 -168
  57. package/style.js.map +7 -1
  58. package/testHelper.js +247 -303
  59. package/testHelper.js.map +7 -1
  60. package/themeUtils.js +63 -142
  61. package/themeUtils.js.map +7 -1
  62. package/trellisUtils.js +108 -276
  63. package/trellisUtils.js.map +7 -1
package/Downloader.js CHANGED
@@ -1,430 +1,191 @@
1
- /*!
2
- * Copyright © 2024 Splunk Inc.
3
- * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
4
- * in part without a valid written license from Splunk Inc. is PROHIBITED.
5
- */
6
- module.exports =
7
- /******/ (function(modules) { // webpackBootstrap
8
- /******/ // The module cache
9
- /******/ var installedModules = {};
10
- /******/
11
- /******/ // The require function
12
- /******/ function __webpack_require__(moduleId) {
13
- /******/
14
- /******/ // Check if module is in cache
15
- /******/ if(installedModules[moduleId]) {
16
- /******/ return installedModules[moduleId].exports;
17
- /******/ }
18
- /******/ // Create a new module (and put it into the cache)
19
- /******/ var module = installedModules[moduleId] = {
20
- /******/ i: moduleId,
21
- /******/ l: false,
22
- /******/ exports: {}
23
- /******/ };
24
- /******/
25
- /******/ // Execute the module function
26
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27
- /******/
28
- /******/ // Flag the module as loaded
29
- /******/ module.l = true;
30
- /******/
31
- /******/ // Return the exports of the module
32
- /******/ return module.exports;
33
- /******/ }
34
- /******/
35
- /******/
36
- /******/ // expose the modules object (__webpack_modules__)
37
- /******/ __webpack_require__.m = modules;
38
- /******/
39
- /******/ // expose the module cache
40
- /******/ __webpack_require__.c = installedModules;
41
- /******/
42
- /******/ // define getter function for harmony exports
43
- /******/ __webpack_require__.d = function(exports, name, getter) {
44
- /******/ if(!__webpack_require__.o(exports, name)) {
45
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46
- /******/ }
47
- /******/ };
48
- /******/
49
- /******/ // define __esModule on exports
50
- /******/ __webpack_require__.r = function(exports) {
51
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53
- /******/ }
54
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
55
- /******/ };
56
- /******/
57
- /******/ // create a fake namespace object
58
- /******/ // mode & 1: value is a module id, require it
59
- /******/ // mode & 2: merge all properties of value into the ns
60
- /******/ // mode & 4: return value when already ns object
61
- /******/ // mode & 8|1: behave like require
62
- /******/ __webpack_require__.t = function(value, mode) {
63
- /******/ if(mode & 1) value = __webpack_require__(value);
64
- /******/ if(mode & 8) return value;
65
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66
- /******/ var ns = Object.create(null);
67
- /******/ __webpack_require__.r(ns);
68
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70
- /******/ return ns;
71
- /******/ };
72
- /******/
73
- /******/ // getDefaultExport function for compatibility with non-harmony modules
74
- /******/ __webpack_require__.n = function(module) {
75
- /******/ var getter = module && module.__esModule ?
76
- /******/ function getDefault() { return module['default']; } :
77
- /******/ function getModuleExports() { return module; };
78
- /******/ __webpack_require__.d(getter, 'a', getter);
79
- /******/ return getter;
80
- /******/ };
81
- /******/
82
- /******/ // Object.prototype.hasOwnProperty.call
83
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84
- /******/
85
- /******/ // __webpack_public_path__
86
- /******/ __webpack_require__.p = "";
87
- /******/
88
- /******/
89
- /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 24);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ({
94
-
95
- /***/ 10:
96
- /***/ (function(module, exports) {
97
-
98
- module.exports = require("@babel/runtime/regenerator");
99
-
100
- /***/ }),
101
-
102
- /***/ 12:
103
- /***/ (function(module, exports) {
104
-
105
- module.exports = require("@babel/runtime/helpers/slicedToArray");
106
-
107
- /***/ }),
108
-
109
- /***/ 24:
110
- /***/ (function(module, exports, __webpack_require__) {
111
-
112
- "use strict";
113
-
114
-
115
- var _regeneratorRuntime = __webpack_require__(10);
116
-
117
- var _slicedToArray = __webpack_require__(12);
118
-
119
- var _classCallCheck = __webpack_require__(5);
120
-
121
- var _createClass = __webpack_require__(6);
122
-
123
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
124
- function adopt(value) {
125
- return value instanceof P ? value : new P(function (resolve) {
126
- resolve(value);
127
- });
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
128
19
  }
129
-
130
- return new (P || (P = Promise))(function (resolve, reject) {
131
- function fulfilled(value) {
20
+ return to;
21
+ };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var __async = (__this, __arguments, generator) => {
33
+ return new Promise((resolve, reject) => {
34
+ var fulfilled = (value) => {
132
35
  try {
133
36
  step(generator.next(value));
134
37
  } catch (e) {
135
38
  reject(e);
136
39
  }
137
- }
138
-
139
- function rejected(value) {
40
+ };
41
+ var rejected = (value) => {
140
42
  try {
141
- step(generator["throw"](value));
43
+ step(generator.throw(value));
142
44
  } catch (e) {
143
45
  reject(e);
144
46
  }
145
- }
146
-
147
- function step(result) {
148
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
149
- }
150
-
151
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ };
48
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
+ step((generator = generator.apply(__this, __arguments)).next());
152
50
  });
153
51
  };
154
52
 
155
- Object.defineProperty(exports, "__esModule", {
156
- value: true
53
+ // src/Downloader.ts
54
+ var Downloader_exports = {};
55
+ __export(Downloader_exports, {
56
+ ImageRegistryFetcher: () => ImageRegistryFetcher,
57
+ URLDownloader: () => URLDownloader,
58
+ b64DecodeUnicode: () => b64DecodeUnicode,
59
+ default: () => Downloader
157
60
  });
158
- exports.URLDownloader = exports.ImageRegistryFetcher = exports.b64DecodeUnicode = void 0;
159
- /* eslint-disable max-classes-per-file */
160
-
161
- /* eslint-disable class-methods-use-this */
61
+ module.exports = __toCommonJS(Downloader_exports);
162
62
 
163
- var i18n_1 = __webpack_require__(9);
164
-
165
- var b64DecodeUnicode = function b64DecodeUnicode(base64Data) {
166
- // from bytestream, to percent-encoding, to original string.
167
- return decodeURIComponent(atob(base64Data).split('').map(function (c) {
168
- return "%".concat("00".concat(c.charCodeAt(0).toString(16)).slice(-2));
169
- }).join(''));
63
+ // esm-externals:@splunk/ui-utils/i18n
64
+ var i18n_exports = {};
65
+ __export(i18n_exports, {
66
+ default: () => i18n_default
67
+ });
68
+ var defaultImport = __toESM(require("@splunk/ui-utils/i18n"));
69
+ __reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
70
+ var i18n_default = "default" in defaultImport ? defaultImport.default : defaultImport;
71
+
72
+ // src/Downloader.ts
73
+ var b64DecodeUnicode = (base64Data) => {
74
+ return decodeURIComponent(
75
+ atob(base64Data).split("").map((c) => {
76
+ return `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`;
77
+ }).join("")
78
+ );
170
79
  };
171
-
172
- exports.b64DecodeUnicode = b64DecodeUnicode;
173
-
174
- var ImageRegistryFetcher = /*#__PURE__*/function () {
175
- function ImageRegistryFetcher(context) {
176
- _classCallCheck(this, ImageRegistryFetcher);
177
-
80
+ var ImageRegistryFetcher = class {
81
+ constructor(context) {
178
82
  this.context = context;
179
83
  }
180
-
181
- _createClass(ImageRegistryFetcher, [{
182
- key: "downloadWithProgress",
183
- value: function downloadWithProgress(url, complete, progress, error) {
184
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
185
- var imageRegistry, imageData, _imageData$dataURI$sp, _imageData$dataURI$sp2, mime, svgBase64;
186
-
187
- return _regeneratorRuntime.wrap(function _callee$(_context) {
188
- while (1) {
189
- switch (_context.prev = _context.next) {
190
- case 0:
191
- imageRegistry = this.context;
192
-
193
- if (!imageRegistry) {
194
- error((0, i18n_1._)('Missing Image Context'));
195
- }
196
-
197
- _context.prev = 2;
198
- _context.next = 5;
199
- return imageRegistry.getByURL(url);
200
-
201
- case 5:
202
- imageData = _context.sent;
203
- _imageData$dataURI$sp = imageData.dataURI.split('base64,'), _imageData$dataURI$sp2 = _slicedToArray(_imageData$dataURI$sp, 2), mime = _imageData$dataURI$sp2[0], svgBase64 = _imageData$dataURI$sp2[1];
204
-
205
- if (mime && mime.toLowerCase().indexOf('image/svg+xml') > -1) {
206
- complete((0, exports.b64DecodeUnicode)(svgBase64));
207
- } else {
208
- error((0, i18n_1._)("Unsupported MIME type ".concat(mime, " for url ").concat(url)));
209
- }
210
-
211
- _context.next = 13;
212
- break;
213
-
214
- case 10:
215
- _context.prev = 10;
216
- _context.t0 = _context["catch"](2);
217
- error((0, i18n_1._)("Error retrieving ".concat(url, " from Image Registry, error was '").concat(_context.t0.message, "'")), _context.t0);
218
-
219
- case 13:
220
- case "end":
221
- return _context.stop();
222
- }
223
- }
224
- }, _callee, this, [[2, 10]]);
225
- }));
226
- }
227
- }]);
228
-
229
- return ImageRegistryFetcher;
230
- }();
231
-
232
- exports.ImageRegistryFetcher = ImageRegistryFetcher;
233
-
234
- var URLDownloader = /*#__PURE__*/function () {
235
- function URLDownloader() {
236
- _classCallCheck(this, URLDownloader);
237
- }
238
-
239
- _createClass(URLDownloader, [{
240
- key: "downloadWithProgress",
241
- value: function downloadWithProgress(url, complete, progress, error) {
242
- var _this = this;
243
-
244
- // Step 1: fetch content from URL, get reader
245
- fetch(url).then(function (response) {
246
- return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
247
- var msg, reader, contentLength, bytesDownloaded, chunks, done, res, value, chunksAll, position, _i, _chunks, chunk, svg;
248
-
249
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
250
- while (1) {
251
- switch (_context2.prev = _context2.next) {
252
- case 0:
253
- if (response.ok) {
254
- _context2.next = 5;
255
- break;
256
- }
257
-
258
- msg = "Fetch not Ok for ".concat(url, ", status was '").concat(response.statusText, "'");
259
- console.warn(msg);
260
- error(msg);
261
- return _context2.abrupt("return");
262
-
263
- case 5:
264
- reader = response.body.getReader(); // Step 2: get total length
265
-
266
- contentLength = +response.headers.get('Content-Length'); // Step 3: read the data
267
-
268
- bytesDownloaded = 0; // length at the moment
269
-
270
- chunks = []; // array of received binary chunks (comprises the body)
271
-
272
- done = false;
273
-
274
- case 10:
275
- if (done) {
276
- _context2.next = 19;
277
- break;
278
- }
279
-
280
- _context2.next = 13;
281
- return reader.read();
282
-
283
- case 13:
284
- res = _context2.sent;
285
- done = res.done;
286
- value = res.value;
287
-
288
- if (value) {
289
- chunks.push(value);
290
- bytesDownloaded += value.length;
291
- progress({
292
- // call the progress callback...can enable the UI to show progress
293
- bytesDownloaded: bytesDownloaded,
294
- contentLength: contentLength,
295
- message: "Received ".concat(bytesDownloaded, " bytes of ").concat(contentLength || 'unknown size')
296
- });
297
- }
298
-
299
- _context2.next = 10;
300
- break;
301
-
302
- case 19:
303
- // Step 4: concatenate chunks into single Uint8Array
304
- chunksAll = new Uint8Array(bytesDownloaded);
305
- position = 0; // eslint-disable-next-line no-restricted-syntax
306
-
307
- for (_i = 0, _chunks = chunks; _i < _chunks.length; _i++) {
308
- chunk = _chunks[_i];
309
- chunksAll.set(chunk, position);
310
- position += chunk.length;
311
- }
312
-
313
- progress({
314
- bytesDownloaded: bytesDownloaded,
315
- contentLength: contentLength,
316
- message: 'decoding chunks'
317
- }); // Step 5: decode into a string
318
-
319
- svg = new TextDecoder('utf-8').decode(chunksAll);
320
- complete(svg); // show the downloaded svg back to the caller via its completion callback
321
-
322
- case 25:
323
- case "end":
324
- return _context2.stop();
325
- }
326
- }
327
- }, _callee2);
328
- }));
329
- }).catch(function (e) {
330
- // Note: For CORS issue, fetch api call immediately fails without any status code or response and the error message says "Failed to fetch"
331
- // but for other issues (invalid url, not found, etc), it returns with a certain status code (406, 404, etc)
332
- // and empty response so further operation on the response data fails.
333
- var stringifiedError = e.toString();
334
- console.error(stringifiedError); // call the supplied error handling function
335
-
336
- if (stringifiedError.includes('Failed to fetch')) {
337
- error("Cannot fetch the image \"".concat(url, "\" due to a cross-origin resource sharing (CORS) policy"), e);
84
+ downloadWithProgress(url, complete, progress, error) {
85
+ return __async(this, null, function* () {
86
+ const imageRegistry = this.context;
87
+ if (!imageRegistry) {
88
+ error((0, i18n_exports._)("Missing Image Context"));
89
+ }
90
+ try {
91
+ const imageData = yield imageRegistry.getByURL(url);
92
+ const [mime, svgBase64] = imageData.dataURI.split("base64,");
93
+ if (mime && mime.toLowerCase().indexOf("image/svg+xml") > -1) {
94
+ complete(b64DecodeUnicode(svgBase64));
338
95
  } else {
339
- error("Fetch error for '".concat(url, "', error was '").concat(e.toString(), "'"), e);
96
+ error((0, i18n_exports._)(`Unsupported MIME type ${mime} for url ${url}`));
340
97
  }
341
- });
342
- }
343
- }]);
344
-
345
- return URLDownloader;
346
- }();
347
-
348
- exports.URLDownloader = URLDownloader;
349
-
350
- var Downloader = /*#__PURE__*/function () {
351
- function Downloader(downloaders) {
352
- _classCallCheck(this, Downloader);
353
-
354
- this.downloaders = {};
355
- this.downloaders = downloaders;
356
- }
357
-
358
- _createClass(Downloader, [{
359
- key: "downloadWithProgress",
360
- value: function downloadWithProgress(url, complete, progress, error) {
361
- // url is the following:
362
- // data:image/svg+xml;base64....
363
- // http://
364
- // https://
365
- // local://
366
- // or otherwise return errors
367
- var protocol = '';
368
- var isUrl = true;
369
-
370
- try {
371
- protocol = new URL(url).protocol;
372
98
  } catch (e) {
373
- isUrl = false;
99
+ error((0, i18n_exports._)(`Error retrieving ${url} from Image Registry, error was '${e.message}'`), e);
374
100
  }
375
-
376
- if (isUrl) {
377
- try {
378
- var _protocol$split = protocol.split(':'),
379
- _protocol$split2 = _slicedToArray(_protocol$split, 1),
380
- _protocol$split2$ = _protocol$split2[0],
381
- type = _protocol$split2$ === void 0 ? '' : _protocol$split2$;
382
-
383
- if (this.downloaders[type]) {
384
- // data, http(s), local....
385
- this.downloaders[type].downloadWithProgress(url, complete, progress, error);
386
- } else {
387
- // unknown type
388
- error("Unsupported URL protocol '".concat(type, "' for SVG download: ").concat(url));
101
+ });
102
+ }
103
+ };
104
+ var URLDownloader = class {
105
+ downloadWithProgress(url, complete, progress, error) {
106
+ fetch(url).then(
107
+ (response) => __async(this, null, function* () {
108
+ if (!response.ok) {
109
+ const msg = `Fetch not Ok for ${url}, status was '${response.statusText}'`;
110
+ console.warn(msg);
111
+ error(msg);
112
+ return;
113
+ }
114
+ const reader = response.body.getReader();
115
+ const contentLength = +response.headers.get("Content-Length");
116
+ let bytesDownloaded = 0;
117
+ const chunks = [];
118
+ let done = false;
119
+ while (!done) {
120
+ const res = yield reader.read();
121
+ done = res.done;
122
+ const { value } = res;
123
+ if (value) {
124
+ chunks.push(value);
125
+ bytesDownloaded += value.length;
126
+ progress({
127
+ // call the progress callback...can enable the UI to show progress
128
+ bytesDownloaded,
129
+ contentLength,
130
+ message: `Received ${bytesDownloaded} bytes of ${contentLength || "unknown size"}`
131
+ });
389
132
  }
390
- } catch (e) {
391
- error("Unexpected error downloading SVG: ".concat(e.message));
392
133
  }
134
+ const chunksAll = new Uint8Array(bytesDownloaded);
135
+ let position = 0;
136
+ for (const chunk of chunks) {
137
+ chunksAll.set(chunk, position);
138
+ position += chunk.length;
139
+ }
140
+ progress({
141
+ bytesDownloaded,
142
+ contentLength,
143
+ message: "decoding chunks"
144
+ });
145
+ const svg = new TextDecoder("utf-8").decode(chunksAll);
146
+ complete(svg);
147
+ })
148
+ ).catch((e) => {
149
+ const stringifiedError = e.toString();
150
+ console.error(stringifiedError);
151
+ if (stringifiedError.includes("Failed to fetch")) {
152
+ error(
153
+ `Cannot fetch the image "${url}" due to a cross-origin resource sharing (CORS) policy`,
154
+ e
155
+ );
393
156
  } else {
394
- // the url might be literal content. <svg>...</svg>. This is kindof a hack where if you pass the downloader something
395
- // that is literal content, it will just return the content. Makes the code flow cleaner in layers above.
396
- complete(url);
157
+ error(`Fetch error for '${url}', error was '${e.toString()}'`, e);
397
158
  }
159
+ });
160
+ }
161
+ };
162
+ var Downloader = class {
163
+ constructor(downloaders) {
164
+ this.downloaders = {};
165
+ this.downloaders = downloaders;
166
+ }
167
+ downloadWithProgress(url, complete, progress, error) {
168
+ let protocol = "";
169
+ let isUrl = true;
170
+ try {
171
+ protocol = new URL(url).protocol;
172
+ } catch (e) {
173
+ isUrl = false;
398
174
  }
399
- }]);
400
-
401
- return Downloader;
402
- }();
403
-
404
- exports.default = Downloader;
405
-
406
- /***/ }),
407
-
408
- /***/ 5:
409
- /***/ (function(module, exports) {
410
-
411
- module.exports = require("@babel/runtime/helpers/classCallCheck");
412
-
413
- /***/ }),
414
-
415
- /***/ 6:
416
- /***/ (function(module, exports) {
417
-
418
- module.exports = require("@babel/runtime/helpers/createClass");
419
-
420
- /***/ }),
421
-
422
- /***/ 9:
423
- /***/ (function(module, exports) {
424
-
425
- module.exports = require("@splunk/ui-utils/i18n");
426
-
427
- /***/ })
428
-
429
- /******/ });
430
- //# sourceMappingURL=Downloader.js.map
175
+ if (isUrl) {
176
+ try {
177
+ const [type = ""] = protocol.split(":");
178
+ if (this.downloaders[type]) {
179
+ this.downloaders[type].downloadWithProgress(url, complete, progress, error);
180
+ } else {
181
+ error(`Unsupported URL protocol '${type}' for SVG download: ${url}`);
182
+ }
183
+ } catch (e) {
184
+ error(`Unexpected error downloading SVG: ${e.message}`);
185
+ }
186
+ } else {
187
+ complete(url);
188
+ }
189
+ }
190
+ };
191
+ //# sourceMappingURL=Downloader.js.map