@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.
- package/.loki/reference/chrome_docker_SizeAwareWrapper_50_parent.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Fix_size_container.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container_with_extra_wrapper.png +0 -0
- package/Downloader.js +164 -403
- package/Downloader.js.map +7 -1
- package/FileDownloader.js +121 -557
- package/FileDownloader.js.map +7 -1
- package/JSONSchemaUtils.js +58 -134
- package/JSONSchemaUtils.js.map +7 -1
- package/Message.js +105 -270
- package/Message.js.map +7 -1
- package/RemoteIcon.js +272 -736
- package/RemoteIcon.js.map +7 -1
- package/RemoteImage.js +190 -458
- package/RemoteImage.js.map +7 -1
- package/SanitizeProps.js +117 -238
- package/SanitizeProps.js.map +7 -1
- package/SizeAwareWrapper.js +108 -306
- package/SizeAwareWrapper.js.map +7 -1
- package/SizeAwareWrapperDeprecated.js +117 -326
- package/SizeAwareWrapperDeprecated.js.map +7 -1
- package/VisualizationDocPage.js +212 -461
- package/VisualizationDocPage.js.map +7 -1
- package/colorConstants.js +81 -132
- package/colorConstants.js.map +7 -1
- package/colorUtils.js +47 -134
- package/colorUtils.js.map +7 -1
- package/configUtils.js +28 -112
- package/configUtils.js.map +7 -1
- package/console.js +45 -183
- package/console.js.map +7 -1
- package/dataSourceUtils.js +45 -140
- package/dataSourceUtils.js.map +7 -1
- package/domUtils.js +58 -122
- package/domUtils.js.map +7 -1
- package/hocUtils.js +45 -122
- package/hocUtils.js.map +7 -1
- package/i18n.js +168 -323
- package/i18n.js.map +7 -1
- package/iconUtils.js +47 -178
- package/iconUtils.js.map +7 -1
- package/mapUtils.js +45 -122
- package/mapUtils.js.map +7 -1
- package/numberUtils.js +101 -275
- package/numberUtils.js.map +7 -1
- package/package.json +18 -22
- package/previewVizMessage.js +28 -108
- package/previewVizMessage.js.map +7 -1
- package/propUtils.js +88 -212
- package/propUtils.js.map +7 -1
- package/schemaUtils.js +58 -185
- package/schemaUtils.js.map +7 -1
- package/simpleXMLOptions.js +142 -225
- package/simpleXMLOptions.js.map +7 -1
- package/style.js +65 -168
- package/style.js.map +7 -1
- package/testHelper.js +247 -303
- package/testHelper.js.map +7 -1
- package/themeUtils.js +63 -142
- package/themeUtils.js.map +7 -1
- package/trellisUtils.js +108 -276
- package/trellisUtils.js.map +7 -1
package/FileDownloader.js
CHANGED
|
@@ -1,576 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 = 41);
|
|
91
|
-
/******/ })
|
|
92
|
-
/************************************************************************/
|
|
93
|
-
/******/ ({
|
|
94
|
-
|
|
95
|
-
/***/ 1:
|
|
96
|
-
/***/ (function(module, exports) {
|
|
97
|
-
|
|
98
|
-
module.exports = require("react");
|
|
99
|
-
|
|
100
|
-
/***/ }),
|
|
101
|
-
|
|
102
|
-
/***/ 10:
|
|
103
|
-
/***/ (function(module, exports) {
|
|
104
|
-
|
|
105
|
-
module.exports = require("@babel/runtime/regenerator");
|
|
106
|
-
|
|
107
|
-
/***/ }),
|
|
108
|
-
|
|
109
|
-
/***/ 12:
|
|
110
|
-
/***/ (function(module, exports) {
|
|
111
|
-
|
|
112
|
-
module.exports = require("@babel/runtime/helpers/slicedToArray");
|
|
113
|
-
|
|
114
|
-
/***/ }),
|
|
115
|
-
|
|
116
|
-
/***/ 24:
|
|
117
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
118
|
-
|
|
119
|
-
"use strict";
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var _regeneratorRuntime = __webpack_require__(10);
|
|
123
|
-
|
|
124
|
-
var _slicedToArray = __webpack_require__(12);
|
|
125
|
-
|
|
126
|
-
var _classCallCheck = __webpack_require__(5);
|
|
127
|
-
|
|
128
|
-
var _createClass = __webpack_require__(6);
|
|
129
|
-
|
|
130
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
131
|
-
function adopt(value) {
|
|
132
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
133
|
-
resolve(value);
|
|
134
|
-
});
|
|
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 });
|
|
135
19
|
}
|
|
136
|
-
|
|
137
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
138
|
-
function fulfilled(value) {
|
|
139
|
-
try {
|
|
140
|
-
step(generator.next(value));
|
|
141
|
-
} catch (e) {
|
|
142
|
-
reject(e);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function rejected(value) {
|
|
147
|
-
try {
|
|
148
|
-
step(generator["throw"](value));
|
|
149
|
-
} catch (e) {
|
|
150
|
-
reject(e);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function step(result) {
|
|
155
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
159
|
-
});
|
|
20
|
+
return to;
|
|
160
21
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
+
|
|
33
|
+
// src/FileDownloader.tsx
|
|
34
|
+
var FileDownloader_exports = {};
|
|
35
|
+
__export(FileDownloader_exports, {
|
|
36
|
+
FileDownloader: () => FileDownloader
|
|
164
37
|
});
|
|
165
|
-
|
|
166
|
-
/* eslint-disable max-classes-per-file */
|
|
167
|
-
|
|
168
|
-
/* eslint-disable class-methods-use-this */
|
|
169
|
-
|
|
170
|
-
var i18n_1 = __webpack_require__(9);
|
|
171
|
-
|
|
172
|
-
var b64DecodeUnicode = function b64DecodeUnicode(base64Data) {
|
|
173
|
-
// from bytestream, to percent-encoding, to original string.
|
|
174
|
-
return decodeURIComponent(atob(base64Data).split('').map(function (c) {
|
|
175
|
-
return "%".concat("00".concat(c.charCodeAt(0).toString(16)).slice(-2));
|
|
176
|
-
}).join(''));
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
exports.b64DecodeUnicode = b64DecodeUnicode;
|
|
180
|
-
|
|
181
|
-
var ImageRegistryFetcher = /*#__PURE__*/function () {
|
|
182
|
-
function ImageRegistryFetcher(context) {
|
|
183
|
-
_classCallCheck(this, ImageRegistryFetcher);
|
|
184
|
-
|
|
185
|
-
this.context = context;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
_createClass(ImageRegistryFetcher, [{
|
|
189
|
-
key: "downloadWithProgress",
|
|
190
|
-
value: function downloadWithProgress(url, complete, progress, error) {
|
|
191
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
192
|
-
var imageRegistry, imageData, _imageData$dataURI$sp, _imageData$dataURI$sp2, mime, svgBase64;
|
|
193
|
-
|
|
194
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
195
|
-
while (1) {
|
|
196
|
-
switch (_context.prev = _context.next) {
|
|
197
|
-
case 0:
|
|
198
|
-
imageRegistry = this.context;
|
|
199
|
-
|
|
200
|
-
if (!imageRegistry) {
|
|
201
|
-
error((0, i18n_1._)('Missing Image Context'));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
_context.prev = 2;
|
|
205
|
-
_context.next = 5;
|
|
206
|
-
return imageRegistry.getByURL(url);
|
|
207
|
-
|
|
208
|
-
case 5:
|
|
209
|
-
imageData = _context.sent;
|
|
210
|
-
_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];
|
|
211
|
-
|
|
212
|
-
if (mime && mime.toLowerCase().indexOf('image/svg+xml') > -1) {
|
|
213
|
-
complete((0, exports.b64DecodeUnicode)(svgBase64));
|
|
214
|
-
} else {
|
|
215
|
-
error((0, i18n_1._)("Unsupported MIME type ".concat(mime, " for url ").concat(url)));
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
_context.next = 13;
|
|
219
|
-
break;
|
|
220
|
-
|
|
221
|
-
case 10:
|
|
222
|
-
_context.prev = 10;
|
|
223
|
-
_context.t0 = _context["catch"](2);
|
|
224
|
-
error((0, i18n_1._)("Error retrieving ".concat(url, " from Image Registry, error was '").concat(_context.t0.message, "'")), _context.t0);
|
|
225
|
-
|
|
226
|
-
case 13:
|
|
227
|
-
case "end":
|
|
228
|
-
return _context.stop();
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}, _callee, this, [[2, 10]]);
|
|
232
|
-
}));
|
|
233
|
-
}
|
|
234
|
-
}]);
|
|
235
|
-
|
|
236
|
-
return ImageRegistryFetcher;
|
|
237
|
-
}();
|
|
238
|
-
|
|
239
|
-
exports.ImageRegistryFetcher = ImageRegistryFetcher;
|
|
240
|
-
|
|
241
|
-
var URLDownloader = /*#__PURE__*/function () {
|
|
242
|
-
function URLDownloader() {
|
|
243
|
-
_classCallCheck(this, URLDownloader);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
_createClass(URLDownloader, [{
|
|
247
|
-
key: "downloadWithProgress",
|
|
248
|
-
value: function downloadWithProgress(url, complete, progress, error) {
|
|
249
|
-
var _this = this;
|
|
250
|
-
|
|
251
|
-
// Step 1: fetch content from URL, get reader
|
|
252
|
-
fetch(url).then(function (response) {
|
|
253
|
-
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
254
|
-
var msg, reader, contentLength, bytesDownloaded, chunks, done, res, value, chunksAll, position, _i, _chunks, chunk, svg;
|
|
255
|
-
|
|
256
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
257
|
-
while (1) {
|
|
258
|
-
switch (_context2.prev = _context2.next) {
|
|
259
|
-
case 0:
|
|
260
|
-
if (response.ok) {
|
|
261
|
-
_context2.next = 5;
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
msg = "Fetch not Ok for ".concat(url, ", status was '").concat(response.statusText, "'");
|
|
266
|
-
console.warn(msg);
|
|
267
|
-
error(msg);
|
|
268
|
-
return _context2.abrupt("return");
|
|
269
|
-
|
|
270
|
-
case 5:
|
|
271
|
-
reader = response.body.getReader(); // Step 2: get total length
|
|
272
|
-
|
|
273
|
-
contentLength = +response.headers.get('Content-Length'); // Step 3: read the data
|
|
274
|
-
|
|
275
|
-
bytesDownloaded = 0; // length at the moment
|
|
276
|
-
|
|
277
|
-
chunks = []; // array of received binary chunks (comprises the body)
|
|
278
|
-
|
|
279
|
-
done = false;
|
|
280
|
-
|
|
281
|
-
case 10:
|
|
282
|
-
if (done) {
|
|
283
|
-
_context2.next = 19;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
_context2.next = 13;
|
|
288
|
-
return reader.read();
|
|
289
|
-
|
|
290
|
-
case 13:
|
|
291
|
-
res = _context2.sent;
|
|
292
|
-
done = res.done;
|
|
293
|
-
value = res.value;
|
|
294
|
-
|
|
295
|
-
if (value) {
|
|
296
|
-
chunks.push(value);
|
|
297
|
-
bytesDownloaded += value.length;
|
|
298
|
-
progress({
|
|
299
|
-
// call the progress callback...can enable the UI to show progress
|
|
300
|
-
bytesDownloaded: bytesDownloaded,
|
|
301
|
-
contentLength: contentLength,
|
|
302
|
-
message: "Received ".concat(bytesDownloaded, " bytes of ").concat(contentLength || 'unknown size')
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
_context2.next = 10;
|
|
307
|
-
break;
|
|
308
|
-
|
|
309
|
-
case 19:
|
|
310
|
-
// Step 4: concatenate chunks into single Uint8Array
|
|
311
|
-
chunksAll = new Uint8Array(bytesDownloaded);
|
|
312
|
-
position = 0; // eslint-disable-next-line no-restricted-syntax
|
|
313
|
-
|
|
314
|
-
for (_i = 0, _chunks = chunks; _i < _chunks.length; _i++) {
|
|
315
|
-
chunk = _chunks[_i];
|
|
316
|
-
chunksAll.set(chunk, position);
|
|
317
|
-
position += chunk.length;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
progress({
|
|
321
|
-
bytesDownloaded: bytesDownloaded,
|
|
322
|
-
contentLength: contentLength,
|
|
323
|
-
message: 'decoding chunks'
|
|
324
|
-
}); // Step 5: decode into a string
|
|
325
|
-
|
|
326
|
-
svg = new TextDecoder('utf-8').decode(chunksAll);
|
|
327
|
-
complete(svg); // show the downloaded svg back to the caller via its completion callback
|
|
328
|
-
|
|
329
|
-
case 25:
|
|
330
|
-
case "end":
|
|
331
|
-
return _context2.stop();
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}, _callee2);
|
|
335
|
-
}));
|
|
336
|
-
}).catch(function (e) {
|
|
337
|
-
// Note: For CORS issue, fetch api call immediately fails without any status code or response and the error message says "Failed to fetch"
|
|
338
|
-
// but for other issues (invalid url, not found, etc), it returns with a certain status code (406, 404, etc)
|
|
339
|
-
// and empty response so further operation on the response data fails.
|
|
340
|
-
var stringifiedError = e.toString();
|
|
341
|
-
console.error(stringifiedError); // call the supplied error handling function
|
|
342
|
-
|
|
343
|
-
if (stringifiedError.includes('Failed to fetch')) {
|
|
344
|
-
error("Cannot fetch the image \"".concat(url, "\" due to a cross-origin resource sharing (CORS) policy"), e);
|
|
345
|
-
} else {
|
|
346
|
-
error("Fetch error for '".concat(url, "', error was '").concat(e.toString(), "'"), e);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
}]);
|
|
351
|
-
|
|
352
|
-
return URLDownloader;
|
|
353
|
-
}();
|
|
354
|
-
|
|
355
|
-
exports.URLDownloader = URLDownloader;
|
|
38
|
+
module.exports = __toCommonJS(FileDownloader_exports);
|
|
356
39
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
40
|
+
// esm-externals:react
|
|
41
|
+
var react_exports = {};
|
|
42
|
+
__export(react_exports, {
|
|
43
|
+
default: () => react_default
|
|
44
|
+
});
|
|
45
|
+
var defaultImport = __toESM(require("react"));
|
|
46
|
+
__reExport(react_exports, require("react"));
|
|
47
|
+
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
48
|
+
|
|
49
|
+
// esm-externals:@splunk/ui-utils/i18n
|
|
50
|
+
var i18n_exports = {};
|
|
51
|
+
__export(i18n_exports, {
|
|
52
|
+
default: () => i18n_default
|
|
53
|
+
});
|
|
54
|
+
var defaultImport2 = __toESM(require("@splunk/ui-utils/i18n"));
|
|
55
|
+
__reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
|
|
56
|
+
var i18n_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
360
57
|
|
|
58
|
+
// src/Downloader.ts
|
|
59
|
+
var Downloader = class {
|
|
60
|
+
constructor(downloaders) {
|
|
361
61
|
this.downloaders = {};
|
|
362
62
|
this.downloaders = downloaders;
|
|
363
63
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
// or otherwise return errors
|
|
374
|
-
var protocol = '';
|
|
375
|
-
var isUrl = true;
|
|
376
|
-
|
|
64
|
+
downloadWithProgress(url, complete, progress, error) {
|
|
65
|
+
let protocol = "";
|
|
66
|
+
let isUrl = true;
|
|
67
|
+
try {
|
|
68
|
+
protocol = new URL(url).protocol;
|
|
69
|
+
} catch (e) {
|
|
70
|
+
isUrl = false;
|
|
71
|
+
}
|
|
72
|
+
if (isUrl) {
|
|
377
73
|
try {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
if (isUrl) {
|
|
384
|
-
try {
|
|
385
|
-
var _protocol$split = protocol.split(':'),
|
|
386
|
-
_protocol$split2 = _slicedToArray(_protocol$split, 1),
|
|
387
|
-
_protocol$split2$ = _protocol$split2[0],
|
|
388
|
-
type = _protocol$split2$ === void 0 ? '' : _protocol$split2$;
|
|
389
|
-
|
|
390
|
-
if (this.downloaders[type]) {
|
|
391
|
-
// data, http(s), local....
|
|
392
|
-
this.downloaders[type].downloadWithProgress(url, complete, progress, error);
|
|
393
|
-
} else {
|
|
394
|
-
// unknown type
|
|
395
|
-
error("Unsupported URL protocol '".concat(type, "' for SVG download: ").concat(url));
|
|
396
|
-
}
|
|
397
|
-
} catch (e) {
|
|
398
|
-
error("Unexpected error downloading SVG: ".concat(e.message));
|
|
74
|
+
const [type = ""] = protocol.split(":");
|
|
75
|
+
if (this.downloaders[type]) {
|
|
76
|
+
this.downloaders[type].downloadWithProgress(url, complete, progress, error);
|
|
77
|
+
} else {
|
|
78
|
+
error(`Unsupported URL protocol '${type}' for SVG download: ${url}`);
|
|
399
79
|
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// that is literal content, it will just return the content. Makes the code flow cleaner in layers above.
|
|
403
|
-
complete(url);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
error(`Unexpected error downloading SVG: ${e.message}`);
|
|
404
82
|
}
|
|
83
|
+
} else {
|
|
84
|
+
complete(url);
|
|
405
85
|
}
|
|
406
|
-
}]);
|
|
407
|
-
|
|
408
|
-
return Downloader;
|
|
409
|
-
}();
|
|
410
|
-
|
|
411
|
-
exports.default = Downloader;
|
|
412
|
-
|
|
413
|
-
/***/ }),
|
|
414
|
-
|
|
415
|
-
/***/ 3:
|
|
416
|
-
/***/ (function(module, exports) {
|
|
417
|
-
|
|
418
|
-
module.exports = require("@babel/runtime/helpers/getPrototypeOf");
|
|
419
|
-
|
|
420
|
-
/***/ }),
|
|
421
|
-
|
|
422
|
-
/***/ 41:
|
|
423
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
424
|
-
|
|
425
|
-
"use strict";
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
var _classCallCheck = __webpack_require__(5);
|
|
429
|
-
|
|
430
|
-
var _createClass = __webpack_require__(6);
|
|
431
|
-
|
|
432
|
-
var _inherits = __webpack_require__(7);
|
|
433
|
-
|
|
434
|
-
var _possibleConstructorReturn = __webpack_require__(8);
|
|
435
|
-
|
|
436
|
-
var _getPrototypeOf = __webpack_require__(3);
|
|
437
|
-
|
|
438
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
439
|
-
|
|
440
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
441
|
-
|
|
442
|
-
Object.defineProperty(exports, "__esModule", {
|
|
443
|
-
value: true
|
|
444
|
-
});
|
|
445
|
-
exports.FileDownloader = void 0;
|
|
446
|
-
|
|
447
|
-
var React = __webpack_require__(1);
|
|
448
|
-
|
|
449
|
-
var Downloader_1 = __webpack_require__(24);
|
|
450
|
-
|
|
451
|
-
var FileDownloader = /*#__PURE__*/function (_React$PureComponent) {
|
|
452
|
-
_inherits(FileDownloader, _React$PureComponent);
|
|
453
|
-
|
|
454
|
-
var _super = _createSuper(FileDownloader);
|
|
455
|
-
|
|
456
|
-
function FileDownloader(props) {
|
|
457
|
-
var _this;
|
|
458
|
-
|
|
459
|
-
_classCallCheck(this, FileDownloader);
|
|
460
|
-
|
|
461
|
-
_this = _super.call(this, props);
|
|
462
|
-
_this.state = {};
|
|
463
|
-
return _this;
|
|
464
86
|
}
|
|
87
|
+
};
|
|
465
88
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
89
|
+
// src/FileDownloader.tsx
|
|
90
|
+
var FileDownloader = class extends react_exports.PureComponent {
|
|
91
|
+
constructor(props) {
|
|
92
|
+
super(props);
|
|
93
|
+
this.state = {};
|
|
94
|
+
}
|
|
95
|
+
componentDidMount() {
|
|
96
|
+
this.initiateDownload();
|
|
97
|
+
}
|
|
98
|
+
componentDidUpdate(prevProps) {
|
|
99
|
+
if (this.props.url !== prevProps.url) {
|
|
469
100
|
this.initiateDownload();
|
|
470
101
|
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
102
|
+
}
|
|
103
|
+
initiateDownload() {
|
|
104
|
+
this.setState({});
|
|
105
|
+
const { url } = this.props;
|
|
106
|
+
const downloader = new Downloader(this.props.protocolHandlers);
|
|
107
|
+
downloader.downloadWithProgress(
|
|
108
|
+
url,
|
|
109
|
+
(content) => this.setState({ content }),
|
|
110
|
+
// done downloading
|
|
111
|
+
(progress) => {
|
|
112
|
+
this.setState({ progress });
|
|
113
|
+
},
|
|
114
|
+
(msg) => {
|
|
115
|
+
this.setState({ error: msg });
|
|
476
116
|
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
const {
|
|
121
|
+
url,
|
|
122
|
+
renderContent,
|
|
123
|
+
renderProgress,
|
|
124
|
+
renderError = (msg) => /* @__PURE__ */ react_exports.createElement("div", null, msg)
|
|
125
|
+
} = this.props;
|
|
126
|
+
const {
|
|
127
|
+
content,
|
|
128
|
+
progress = { message: `Downloading ${url}...`, bytesDownloaded: 0 },
|
|
129
|
+
error
|
|
130
|
+
} = this.state;
|
|
131
|
+
if (content) {
|
|
132
|
+
return renderContent(content);
|
|
477
133
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
value: function initiateDownload() {
|
|
481
|
-
var _this2 = this;
|
|
482
|
-
|
|
483
|
-
this.setState({});
|
|
484
|
-
var url = this.props.url;
|
|
485
|
-
var downloader = new Downloader_1.default(this.props.protocolHandlers);
|
|
486
|
-
downloader.downloadWithProgress(url, function (content) {
|
|
487
|
-
return _this2.setState({
|
|
488
|
-
content: content
|
|
489
|
-
});
|
|
490
|
-
}, // done downloading
|
|
491
|
-
function (progress) {
|
|
492
|
-
_this2.setState({
|
|
493
|
-
progress: progress
|
|
494
|
-
});
|
|
495
|
-
}, function (msg) {
|
|
496
|
-
_this2.setState({
|
|
497
|
-
error: msg
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
}, {
|
|
502
|
-
key: "render",
|
|
503
|
-
value: function render() {
|
|
504
|
-
var _this$props = this.props,
|
|
505
|
-
url = _this$props.url,
|
|
506
|
-
renderContent = _this$props.renderContent,
|
|
507
|
-
renderProgress = _this$props.renderProgress,
|
|
508
|
-
_this$props$renderErr = _this$props.renderError,
|
|
509
|
-
renderError = _this$props$renderErr === void 0 ? function (msg) {
|
|
510
|
-
return React.createElement("div", null, msg);
|
|
511
|
-
} : _this$props$renderErr;
|
|
512
|
-
var _this$state = this.state,
|
|
513
|
-
content = _this$state.content,
|
|
514
|
-
_this$state$progress = _this$state.progress,
|
|
515
|
-
progress = _this$state$progress === void 0 ? {
|
|
516
|
-
message: "Downloading ".concat(url, "..."),
|
|
517
|
-
bytesDownloaded: 0
|
|
518
|
-
} : _this$state$progress,
|
|
519
|
-
error = _this$state.error;
|
|
520
|
-
|
|
521
|
-
if (content) {
|
|
522
|
-
return renderContent(content); // render prop
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (error) {
|
|
526
|
-
return renderError(error);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
return typeof renderProgress === 'function' ? renderProgress(progress) : React.createElement(React.Fragment, null);
|
|
134
|
+
if (error) {
|
|
135
|
+
return renderError(error);
|
|
530
136
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
exports.FileDownloader = FileDownloader;
|
|
537
|
-
|
|
538
|
-
/***/ }),
|
|
539
|
-
|
|
540
|
-
/***/ 5:
|
|
541
|
-
/***/ (function(module, exports) {
|
|
542
|
-
|
|
543
|
-
module.exports = require("@babel/runtime/helpers/classCallCheck");
|
|
544
|
-
|
|
545
|
-
/***/ }),
|
|
546
|
-
|
|
547
|
-
/***/ 6:
|
|
548
|
-
/***/ (function(module, exports) {
|
|
549
|
-
|
|
550
|
-
module.exports = require("@babel/runtime/helpers/createClass");
|
|
551
|
-
|
|
552
|
-
/***/ }),
|
|
553
|
-
|
|
554
|
-
/***/ 7:
|
|
555
|
-
/***/ (function(module, exports) {
|
|
556
|
-
|
|
557
|
-
module.exports = require("@babel/runtime/helpers/inherits");
|
|
558
|
-
|
|
559
|
-
/***/ }),
|
|
560
|
-
|
|
561
|
-
/***/ 8:
|
|
562
|
-
/***/ (function(module, exports) {
|
|
563
|
-
|
|
564
|
-
module.exports = require("@babel/runtime/helpers/possibleConstructorReturn");
|
|
565
|
-
|
|
566
|
-
/***/ }),
|
|
567
|
-
|
|
568
|
-
/***/ 9:
|
|
569
|
-
/***/ (function(module, exports) {
|
|
570
|
-
|
|
571
|
-
module.exports = require("@splunk/ui-utils/i18n");
|
|
572
|
-
|
|
573
|
-
/***/ })
|
|
574
|
-
|
|
575
|
-
/******/ });
|
|
576
|
-
//# sourceMappingURL=FileDownloader.js.map
|
|
137
|
+
return typeof renderProgress === "function" ? renderProgress(progress) : /* @__PURE__ */ react_exports.createElement(react_exports.Fragment, null);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=FileDownloader.js.map
|