@splunk/visualizations-shared 25.7.1 → 25.8.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 (55) hide show
  1. package/Downloader.js +5 -60
  2. package/Downloader.js.map +1 -1
  3. package/FileDownloader.js +21 -95
  4. package/FileDownloader.js.map +1 -1
  5. package/JSONSchemaUtils.js +0 -5
  6. package/JSONSchemaUtils.js.map +1 -1
  7. package/Message.js +10 -21
  8. package/Message.js.map +1 -1
  9. package/RemoteIcon.js +33 -86
  10. package/RemoteIcon.js.map +1 -1
  11. package/RemoteImage.js +8 -44
  12. package/RemoteImage.js.map +1 -1
  13. package/SanitizeProps.js +14 -39
  14. package/SanitizeProps.js.map +1 -1
  15. package/SizeAwareWrapper.js +6 -34
  16. package/SizeAwareWrapper.js.map +1 -1
  17. package/VisualizationDocPage.js +18 -64
  18. package/VisualizationDocPage.js.map +1 -1
  19. package/colorConstants.js.map +1 -1
  20. package/colorUtils.js +14 -27
  21. package/colorUtils.js.map +1 -1
  22. package/configUtils.js +0 -2
  23. package/configUtils.js.map +1 -1
  24. package/console.js +0 -12
  25. package/console.js.map +1 -1
  26. package/dataSourceUtils.js +1 -10
  27. package/dataSourceUtils.js.map +1 -1
  28. package/domUtils.js.map +1 -1
  29. package/hocUtils.js +0 -14
  30. package/hocUtils.js.map +1 -1
  31. package/i18n.js +0 -2
  32. package/i18n.js.map +1 -1
  33. package/iconUtils.js +12 -11
  34. package/iconUtils.js.map +1 -1
  35. package/mapUtils.js +0 -4
  36. package/mapUtils.js.map +1 -1
  37. package/namedColors.js +2 -2
  38. package/namedColors.js.map +1 -1
  39. package/numberUtils.js +17 -27
  40. package/numberUtils.js.map +1 -1
  41. package/package.json +5 -5
  42. package/previewVizMessage.js.map +1 -1
  43. package/propUtils.js +5 -7
  44. package/propUtils.js.map +1 -1
  45. package/schemaUtils.js +10 -10
  46. package/schemaUtils.js.map +1 -1
  47. package/simpleXMLOptions.js +2 -2
  48. package/simpleXMLOptions.js.map +1 -1
  49. package/style.js +6 -11
  50. package/style.js.map +1 -1
  51. package/testHelper.js.map +1 -1
  52. package/themeUtils.js +7 -8
  53. package/themeUtils.js.map +1 -1
  54. package/trellisUtils.js +18 -62
  55. package/trellisUtils.js.map +1 -1
package/FileDownloader.js CHANGED
@@ -120,20 +120,15 @@ module.exports = require("@babel/runtime/helpers/slicedToArray");
120
120
 
121
121
 
122
122
  var _regeneratorRuntime = __webpack_require__(10);
123
-
124
123
  var _slicedToArray = __webpack_require__(11);
125
-
126
124
  var _classCallCheck = __webpack_require__(5);
127
-
128
125
  var _createClass = __webpack_require__(6);
129
-
130
126
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
131
127
  function adopt(value) {
132
128
  return value instanceof P ? value : new P(function (resolve) {
133
129
  resolve(value);
134
130
  });
135
131
  }
136
-
137
132
  return new (P || (P = Promise))(function (resolve, reject) {
138
133
  function fulfilled(value) {
139
134
  try {
@@ -142,7 +137,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
142
137
  reject(e);
143
138
  }
144
139
  }
145
-
146
140
  function rejected(value) {
147
141
  try {
148
142
  step(generator["throw"](value));
@@ -150,79 +144,61 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
150
144
  reject(e);
151
145
  }
152
146
  }
153
-
154
147
  function step(result) {
155
148
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
156
149
  }
157
-
158
150
  step((generator = generator.apply(thisArg, _arguments || [])).next());
159
151
  });
160
152
  };
161
-
162
153
  Object.defineProperty(exports, "__esModule", {
163
154
  value: true
164
155
  });
165
156
  exports.URLDownloader = exports.ImageRegistryFetcher = exports.b64DecodeUnicode = void 0;
166
157
  /* eslint-disable max-classes-per-file */
167
-
168
158
  /* eslint-disable class-methods-use-this */
169
-
170
159
  var i18n_1 = __webpack_require__(7);
171
-
172
160
  var b64DecodeUnicode = function b64DecodeUnicode(base64Data) {
173
161
  // from bytestream, to percent-encoding, to original string.
174
162
  return decodeURIComponent(atob(base64Data).split('').map(function (c) {
175
163
  return "%".concat("00".concat(c.charCodeAt(0).toString(16)).slice(-2));
176
164
  }).join(''));
177
165
  };
178
-
179
166
  exports.b64DecodeUnicode = b64DecodeUnicode;
180
-
181
167
  var ImageRegistryFetcher = /*#__PURE__*/function () {
182
168
  function ImageRegistryFetcher(context) {
183
169
  _classCallCheck(this, ImageRegistryFetcher);
184
-
185
170
  this.context = context;
186
171
  }
187
-
188
172
  _createClass(ImageRegistryFetcher, [{
189
173
  key: "downloadWithProgress",
190
174
  value: function downloadWithProgress(url, complete, progress, error) {
191
175
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
192
176
  var imageRegistry, imageData, _imageData$dataURI$sp, _imageData$dataURI$sp2, mime, svgBase64;
193
-
194
177
  return _regeneratorRuntime.wrap(function _callee$(_context) {
195
178
  while (1) {
196
179
  switch (_context.prev = _context.next) {
197
180
  case 0:
198
181
  imageRegistry = this.context;
199
-
200
182
  if (!imageRegistry) {
201
183
  error(i18n_1._('Missing Image Context'));
202
184
  }
203
-
204
185
  _context.prev = 2;
205
186
  _context.next = 5;
206
187
  return imageRegistry.getByURL(url);
207
-
208
188
  case 5:
209
189
  imageData = _context.sent;
210
190
  _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
191
  if (mime && mime.toLowerCase().indexOf('image/svg+xml') > -1) {
213
192
  complete(exports.b64DecodeUnicode(svgBase64));
214
193
  } else {
215
194
  error(i18n_1._("Unsupported MIME type ".concat(mime, " for url ").concat(url)));
216
195
  }
217
-
218
196
  _context.next = 13;
219
197
  break;
220
-
221
198
  case 10:
222
199
  _context.prev = 10;
223
200
  _context.t0 = _context["catch"](2);
224
201
  error(i18n_1._("Error retrieving ".concat(url, " from Image Registry, error was '").concat(_context.t0.message, "'")), _context.t0);
225
-
226
202
  case 13:
227
203
  case "end":
228
204
  return _context.stop();
@@ -232,27 +208,21 @@ var ImageRegistryFetcher = /*#__PURE__*/function () {
232
208
  }));
233
209
  }
234
210
  }]);
235
-
236
211
  return ImageRegistryFetcher;
237
212
  }();
238
-
239
213
  exports.ImageRegistryFetcher = ImageRegistryFetcher;
240
-
241
214
  var URLDownloader = /*#__PURE__*/function () {
242
215
  function URLDownloader() {
243
216
  _classCallCheck(this, URLDownloader);
244
217
  }
245
-
246
218
  _createClass(URLDownloader, [{
247
219
  key: "downloadWithProgress",
248
220
  value: function downloadWithProgress(url, complete, progress, error) {
249
221
  var _this = this;
250
-
251
222
  // Step 1: fetch content from URL, get reader
252
223
  fetch(url).then(function (response) {
253
224
  return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
254
225
  var msg, reader, contentLength, bytesDownloaded, chunks, done, res, value, chunksAll, position, _i, _chunks, chunk, svg;
255
-
256
226
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
257
227
  while (1) {
258
228
  switch (_context2.prev = _context2.next) {
@@ -261,37 +231,27 @@ var URLDownloader = /*#__PURE__*/function () {
261
231
  _context2.next = 5;
262
232
  break;
263
233
  }
264
-
265
234
  msg = "Fetch not Ok for ".concat(url, ", status was '").concat(response.statusText, "'");
266
235
  console.warn(msg);
267
236
  error(msg);
268
237
  return _context2.abrupt("return");
269
-
270
238
  case 5:
271
239
  reader = response.body.getReader(); // Step 2: get total length
272
-
273
240
  contentLength = +response.headers.get('Content-Length'); // Step 3: read the data
274
-
275
241
  bytesDownloaded = 0; // length at the moment
276
-
277
242
  chunks = []; // array of received binary chunks (comprises the body)
278
-
279
243
  done = false;
280
-
281
244
  case 10:
282
245
  if (done) {
283
246
  _context2.next = 19;
284
247
  break;
285
248
  }
286
-
287
249
  _context2.next = 13;
288
250
  return reader.read();
289
-
290
251
  case 13:
291
252
  res = _context2.sent;
292
253
  done = res.done;
293
254
  value = res.value;
294
-
295
255
  if (value) {
296
256
  chunks.push(value);
297
257
  bytesDownloaded += value.length;
@@ -302,30 +262,25 @@ var URLDownloader = /*#__PURE__*/function () {
302
262
  message: "Received ".concat(bytesDownloaded, " bytes of ").concat(contentLength || 'unknown size')
303
263
  });
304
264
  }
305
-
306
265
  _context2.next = 10;
307
266
  break;
308
-
309
267
  case 19:
310
268
  // Step 4: concatenate chunks into single Uint8Array
311
269
  chunksAll = new Uint8Array(bytesDownloaded);
312
270
  position = 0; // eslint-disable-next-line no-restricted-syntax
313
-
314
271
  for (_i = 0, _chunks = chunks; _i < _chunks.length; _i++) {
315
272
  chunk = _chunks[_i];
316
273
  chunksAll.set(chunk, position);
317
274
  position += chunk.length;
318
275
  }
319
-
320
276
  progress({
321
277
  bytesDownloaded: bytesDownloaded,
322
278
  contentLength: contentLength,
323
279
  message: 'decoding chunks'
324
- }); // Step 5: decode into a string
325
-
280
+ });
281
+ // Step 5: decode into a string
326
282
  svg = new TextDecoder('utf-8').decode(chunksAll);
327
283
  complete(svg); // show the downloaded svg back to the caller via its completion callback
328
-
329
284
  case 25:
330
285
  case "end":
331
286
  return _context2.stop();
@@ -339,20 +294,15 @@ var URLDownloader = /*#__PURE__*/function () {
339
294
  });
340
295
  }
341
296
  }]);
342
-
343
297
  return URLDownloader;
344
298
  }();
345
-
346
299
  exports.URLDownloader = URLDownloader;
347
-
348
300
  var Downloader = /*#__PURE__*/function () {
349
301
  function Downloader(downloaders) {
350
302
  _classCallCheck(this, Downloader);
351
-
352
303
  this.downloaders = {};
353
304
  this.downloaders = downloaders;
354
305
  }
355
-
356
306
  _createClass(Downloader, [{
357
307
  key: "downloadWithProgress",
358
308
  value: function downloadWithProgress(url, complete, progress, error) {
@@ -364,20 +314,17 @@ var Downloader = /*#__PURE__*/function () {
364
314
  // or otherwise return errors
365
315
  var protocol = '';
366
316
  var isUrl = true;
367
-
368
317
  try {
369
318
  protocol = new URL(url).protocol;
370
319
  } catch (e) {
371
320
  isUrl = false;
372
321
  }
373
-
374
322
  if (isUrl) {
375
323
  try {
376
324
  var _protocol$split = protocol.split(':'),
377
- _protocol$split2 = _slicedToArray(_protocol$split, 1),
378
- _protocol$split2$ = _protocol$split2[0],
379
- type = _protocol$split2$ === void 0 ? '' : _protocol$split2$;
380
-
325
+ _protocol$split2 = _slicedToArray(_protocol$split, 1),
326
+ _protocol$split2$ = _protocol$split2[0],
327
+ type = _protocol$split2$ === void 0 ? '' : _protocol$split2$;
381
328
  if (this.downloaders[type]) {
382
329
  // data, http(s), local....
383
330
  this.downloaders[type].downloadWithProgress(url, complete, progress, error);
@@ -395,10 +342,8 @@ var Downloader = /*#__PURE__*/function () {
395
342
  }
396
343
  }
397
344
  }]);
398
-
399
345
  return Downloader;
400
346
  }();
401
-
402
347
  exports.default = Downloader;
403
348
 
404
349
  /***/ }),
@@ -417,43 +362,28 @@ module.exports = require("@babel/runtime/helpers/getPrototypeOf");
417
362
 
418
363
 
419
364
  var _classCallCheck = __webpack_require__(5);
420
-
421
365
  var _createClass = __webpack_require__(6);
422
-
423
366
  var _inherits = __webpack_require__(8);
424
-
425
367
  var _possibleConstructorReturn = __webpack_require__(9);
426
-
427
368
  var _getPrototypeOf = __webpack_require__(3);
428
-
429
369
  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); }; }
430
-
431
370
  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; } }
432
-
433
371
  Object.defineProperty(exports, "__esModule", {
434
372
  value: true
435
373
  });
436
374
  exports.FileDownloader = void 0;
437
-
438
375
  var React = __webpack_require__(1);
439
-
440
376
  var Downloader_1 = __webpack_require__(26);
441
-
442
377
  var FileDownloader = /*#__PURE__*/function (_React$PureComponent) {
443
378
  _inherits(FileDownloader, _React$PureComponent);
444
-
445
379
  var _super = _createSuper(FileDownloader);
446
-
447
380
  function FileDownloader(props) {
448
381
  var _this;
449
-
450
382
  _classCallCheck(this, FileDownloader);
451
-
452
383
  _this = _super.call(this, props);
453
384
  _this.state = {};
454
385
  return _this;
455
386
  }
456
-
457
387
  _createClass(FileDownloader, [{
458
388
  key: "componentDidMount",
459
389
  value: function componentDidMount() {
@@ -470,7 +400,6 @@ var FileDownloader = /*#__PURE__*/function (_React$PureComponent) {
470
400
  key: "initiateDownload",
471
401
  value: function initiateDownload() {
472
402
  var _this2 = this;
473
-
474
403
  this.setState({});
475
404
  var url = this.props.url;
476
405
  var downloader = new Downloader_1.default(this.props.protocolHandlers);
@@ -478,7 +407,8 @@ var FileDownloader = /*#__PURE__*/function (_React$PureComponent) {
478
407
  return _this2.setState({
479
408
  content: content
480
409
  });
481
- }, // done downloading
410
+ },
411
+ // done downloading
482
412
  function (progress) {
483
413
  _this2.setState({
484
414
  progress: progress
@@ -493,22 +423,21 @@ var FileDownloader = /*#__PURE__*/function (_React$PureComponent) {
493
423
  key: "render",
494
424
  value: function render() {
495
425
  var _this$props = this.props,
496
- url = _this$props.url,
497
- renderContent = _this$props.renderContent,
498
- renderProgress = _this$props.renderProgress,
499
- _this$props$renderErr = _this$props.renderError,
500
- renderError = _this$props$renderErr === void 0 ? function (msg) {
501
- return React.createElement("div", null, msg);
502
- } : _this$props$renderErr;
426
+ url = _this$props.url,
427
+ renderContent = _this$props.renderContent,
428
+ renderProgress = _this$props.renderProgress,
429
+ _this$props$renderErr = _this$props.renderError,
430
+ renderError = _this$props$renderErr === void 0 ? function (msg) {
431
+ return React.createElement("div", null, msg);
432
+ } : _this$props$renderErr;
503
433
  var _this$state = this.state,
504
- content = _this$state.content,
505
- _this$state$progress = _this$state.progress,
506
- progress = _this$state$progress === void 0 ? {
507
- message: "Downloading ".concat(url, "..."),
508
- bytesDownloaded: 0
509
- } : _this$state$progress,
510
- error = _this$state.error;
511
-
434
+ content = _this$state.content,
435
+ _this$state$progress = _this$state.progress,
436
+ progress = _this$state$progress === void 0 ? {
437
+ message: "Downloading ".concat(url, "..."),
438
+ bytesDownloaded: 0
439
+ } : _this$state$progress,
440
+ error = _this$state.error;
512
441
  if (content) {
513
442
  return renderContent(content); // render prop
514
443
  }
@@ -516,14 +445,11 @@ var FileDownloader = /*#__PURE__*/function (_React$PureComponent) {
516
445
  if (error) {
517
446
  return renderError(error);
518
447
  }
519
-
520
448
  return typeof renderProgress === 'function' ? renderProgress(progress) : React.createElement(React.Fragment, null);
521
449
  }
522
450
  }]);
523
-
524
451
  return FileDownloader;
525
452
  }(React.PureComponent);
526
-
527
453
  exports.FileDownloader = FileDownloader;
528
454
 
529
455
  /***/ }),
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"react\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///./src/Downloader.ts","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///./src/FileDownloader.tsx","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\""],"names":[],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA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,CAAnB;AACA,gBAAU,CAAC,oBAAX,CACI,GADJ,EAEI,UAAC,OAAD;AAAA,eAA2B,MAAI,CAAC,QAAL,CAAc;AAAE,iBAAO,EAAP;AAAF,SAAd,CAA3B;AAAA,OAFJ,EAE2D;AACvD,gBAAC,QAAD,EAAqC;AACjC,cAAI,CAAC,QAAL,CAAc;AAAE,kBAAQ,EAAR;AAAF,SAAd;AACH,OALL,EAMI,UAAC,GAAD,EAAsB;AAClB,cAAI,CAAC,QAAL,CAAc;AAAE,eAAK,EAAE;AAAT,SAAd;AACH,OARL;AAUH;;;WAED,kBAAM;AAAA,wBAME,KAAK,KANP;AAAA,UAEE,GAFF,eAEE,GAFF;AAAA,UAGE,aAHF,eAGE,aAHF;AAAA,UAIE,cAJF,eAIE,cAJF;AAAA,8CAKE,WALF;AAAA,UAKE,WALF,sCAKgB,UAAC,GAAD;AAAA,eAA8B,iCAAM,GAAN,CAA9B;AAAA,OALhB;AAAA,wBAWE,KAAK,KAXP;AAAA,UAQE,OARF,eAQE,OARF;AAAA,6CASE,QATF;AAAA,UASE,QATF,qCASa;AAAE,eAAO,wBAAiB,GAAjB,QAAT;AAAoC,uBAAe,EAAE;AAArD,OATb;AAAA,UAUE,KAVF,eAUE,KAVF;;AAYF,UAAI,OAAJ,EAAa;AACT,eAAO,aAAa,CAAC,OAAD,CAApB,CADS,CACsB;AAClC;;AACD,UAAI,KAAJ,EAAW;AACP,eAAO,WAAW,CAAC,KAAD,CAAlB;AACH;;AACD,aAAO,OAAO,cAAP,KAA0B,UAA1B,GAAuC,cAAc,CAAC,QAAD,CAArD,GAAkE,yCAAzE;AACH;;;;EAvD+B,KAAK,CAAC,a;;AAA1C,wC;;;;;;;ACtCA,kE;;;;;;;ACAA,+D;;;;;;;ACAA,kD;;;;;;;ACAA,4D;;;;;;;ACAA,6E","file":"FileDownloader.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 44);\n","module.exports = require(\"react\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","/* eslint-disable max-classes-per-file */\n/* eslint-disable class-methods-use-this */\nimport { _ } from '@splunk/ui-utils/i18n';\nimport ImageRegistry from '@splunk/visualization-context/ImageRegistry';\n\nexport interface DownloadProgress {\n bytesDownloaded: number;\n contentLength?: number;\n message: string;\n}\nexport interface IDownloader {\n downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): void;\n}\n\nexport const b64DecodeUnicode = (base64Data: string): string => {\n // from bytestream, to percent-encoding, to original string.\n return decodeURIComponent(\n atob(base64Data)\n .split('')\n .map((c: string): string => {\n return `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`;\n })\n .join('')\n );\n};\n\nexport class ImageRegistryFetcher implements IDownloader {\n context: ImageRegistry;\n\n constructor(context?: ImageRegistry) {\n this.context = context;\n }\n\n async downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): Promise<void> {\n const imageRegistry = this.context;\n if (!imageRegistry) {\n error(_('Missing Image Context'));\n }\n try {\n const imageData = await imageRegistry.getByURL(url);\n const [mime, svgBase64] = imageData.dataURI.split('base64,');\n if (mime && mime.toLowerCase().indexOf('image/svg+xml') > -1) {\n complete(b64DecodeUnicode(svgBase64));\n } else {\n error(_(`Unsupported MIME type ${mime} for url ${url}`));\n }\n } catch (e) {\n error(_(`Error retrieving ${url} from Image Registry, error was '${e.message}'`), e);\n }\n }\n}\n\nexport class URLDownloader implements IDownloader {\n downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): void {\n // Step 1: fetch content from URL, get reader\n fetch(url)\n .then(\n async (response: Response): Promise<void> => {\n if (!response.ok) {\n const msg = `Fetch not Ok for ${url}, status was '${response.statusText}'`;\n console.warn(msg);\n error(msg);\n return;\n }\n const reader = response.body.getReader();\n\n // Step 2: get total length\n const contentLength = +response.headers.get('Content-Length');\n\n // Step 3: read the data\n let bytesDownloaded = 0; // length at the moment\n const chunks = []; // array of received binary chunks (comprises the body)\n let done = false;\n while (!done) {\n // eslint-disable-next-line no-await-in-loop\n const res = await reader.read();\n done = res.done;\n const { value } = res;\n if (value) {\n chunks.push(value);\n bytesDownloaded += value.length;\n progress({\n // call the progress callback...can enable the UI to show progress\n bytesDownloaded,\n contentLength,\n message: `Received ${bytesDownloaded} bytes of ${\n contentLength || 'unknown size'\n }`,\n });\n }\n }\n\n // Step 4: concatenate chunks into single Uint8Array\n const chunksAll = new Uint8Array(bytesDownloaded);\n let position = 0;\n // eslint-disable-next-line no-restricted-syntax\n for (const chunk of chunks) {\n chunksAll.set(chunk, position);\n position += chunk.length;\n }\n\n progress({\n bytesDownloaded,\n contentLength,\n message: 'decoding chunks',\n });\n\n // Step 5: decode into a string\n const svg = new TextDecoder('utf-8').decode(chunksAll);\n complete(svg); // show the downloaded svg back to the caller via its completion callback\n }\n )\n .catch((e: Error): void => {\n console.error(e.toString());\n error(`Fetch error for '${url}', error was '${e.toString()}'`, e); // call the supplied error handling function\n });\n }\n}\n\nexport default class Downloader {\n private downloaders = {};\n\n constructor(downloaders: { [protocol: string]: IDownloader }) {\n this.downloaders = downloaders;\n }\n\n downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): void {\n // url is the following:\n // data:image/svg+xml;base64....\n // http://\n // https://\n // local://\n // or otherwise return errors\n\n let protocol = '';\n let isUrl = true;\n try {\n protocol = new URL(url).protocol;\n } catch (e) {\n isUrl = false;\n }\n\n if (isUrl) {\n try {\n const [type = ''] = protocol.split(':');\n if (this.downloaders[type]) {\n // data, http(s), local....\n this.downloaders[type].downloadWithProgress(url, complete, progress, error);\n } else {\n // unknown type\n error(`Unsupported URL protocol '${type}' for SVG download: ${url}`);\n }\n } catch (e) {\n error(`Unexpected error downloading SVG: ${e.message}`);\n }\n } else {\n // the url might be literal content. <svg>...</svg>. This is kindof a hack where if you pass the downloader something\n // that is literal content, it will just return the content. Makes the code flow cleaner in layers above.\n complete(url);\n }\n }\n}\n","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","import * as React from 'react';\nimport Downloader, { IDownloader, DownloadProgress } from './Downloader';\n\n/**\n * The FileDownloader is passed a URL string, and render prop which allows a caller to control what is rendered\n * When the file is completely downloaded. This FileDownloader also displays basic text showing download progress.\n * If you want to supply your own custom renderer or progress and error you can do so as well.\n *\n */\nexport interface FileDownloaderProps {\n /**\n * The URL to download\n */\n url: string;\n /**\n * The render function that will render when the content is downloaded\n * @returns {React.Component}\n */\n renderContent: (content: string) => React.ReactElement;\n /**\n * An optional function to render progress (defaults to basic text display of progress)\n * @param {DownloadProgress} progress\n * @returns {React.Component}\n */\n renderProgress?: (progress: DownloadProgress) => React.Component;\n /**\n * An optional function to render errors (defaults to basic text display of errors)\n * @param {string} msg\n * @param {Error} error\n * @returns {React.Component}\n */\n renderError?: (msg: string, error?: Error) => React.Component;\n /**\n * A <key>:<Downloader> map for Downloader Component\n */\n protocolHandlers: { [key: string]: IDownloader };\n}\n\nexport class FileDownloader extends React.PureComponent<\n FileDownloaderProps,\n { content?: string; progress?: DownloadProgress; error?: string }\n> {\n constructor(props: FileDownloaderProps) {\n super(props);\n this.state = {};\n }\n\n componentDidMount(): void {\n this.initiateDownload();\n }\n\n componentDidUpdate(prevProps: FileDownloaderProps): void {\n if (this.props.url !== prevProps.url) {\n this.initiateDownload();\n }\n }\n\n initiateDownload(): void {\n this.setState({});\n const { url } = this.props;\n\n const downloader = new Downloader(this.props.protocolHandlers);\n downloader.downloadWithProgress(\n url,\n (content: string): void => this.setState({ content }), // done downloading\n (progress: DownloadProgress): void => {\n this.setState({ progress });\n },\n (msg: string): void => {\n this.setState({ error: msg });\n }\n );\n }\n\n render(): JSX.Element | React.Component {\n const {\n url,\n renderContent,\n renderProgress,\n renderError = (msg: string): JSX.Element => <div>{msg}</div>,\n } = this.props;\n const {\n content,\n progress = { message: `Downloading ${url}...`, bytesDownloaded: 0 },\n error,\n } = this.state;\n if (content) {\n return renderContent(content); // render prop\n }\n if (error) {\n return renderError(error);\n }\n return typeof renderProgress === 'function' ? renderProgress(progress) : <></>;\n }\n}\n","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"react\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///./src/Downloader.ts","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///./src/FileDownloader.tsx","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\""],"names":["i18n_1","require","b64DecodeUnicode","base64Data","decodeURIComponent","atob","split","map","c","concat","charCodeAt","toString","slice","join","exports","ImageRegistryFetcher","context","_classCallCheck","_createClass","key","value","downloadWithProgress","url","complete","progress","error","imageRegistry","_","_context","prev","next","getByURL","imageData","sent","_imageData$dataURI$sp","dataURI","_imageData$dataURI$sp2","_slicedToArray","mime","svgBase64","toLowerCase","indexOf","t0","message","stop","_callee","URLDownloader","_this","fetch","then","response","__awaiter","_regeneratorRuntime","mark","_callee2","msg","reader","contentLength","bytesDownloaded","chunks","done","res","chunksAll","position","_i","_chunks","chunk","svg","wrap","_callee2$","_context2","ok","statusText","console","warn","abrupt","body","getReader","headers","get","read","push","length","Uint8Array","set","TextDecoder","decode","catch","e","Downloader","downloaders","protocol","isUrl","URL","_protocol$split","_protocol$split2","_protocol$split2$","type","default","React","Downloader_1","FileDownloader","_React$PureComponent","_inherits","_super","_createSuper","props","call","state","componentDidMount","initiateDownload","componentDidUpdate","prevProps","_this2","setState","downloader","protocolHandlers","content","render","_this$props","renderContent","renderProgress","_this$props$renderErr","renderError","createElement","_this$state","_this$state$progress","Fragment","PureComponent"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;AClFA,kC;;;;;;;ACAA,uD;;;;;;;ACAA,iE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;AACA;AACA,IAAAA,MAAA,GAAA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AA,+D;;;;;;;ACAA,kD;;;;;;;ACAA,4D;;;;;;;ACAA,6E","file":"FileDownloader.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 44);\n","module.exports = require(\"react\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","/* eslint-disable max-classes-per-file */\n/* eslint-disable class-methods-use-this */\nimport { _ } from '@splunk/ui-utils/i18n';\nimport ImageRegistry from '@splunk/visualization-context/ImageRegistry';\n\nexport interface DownloadProgress {\n bytesDownloaded: number;\n contentLength?: number;\n message: string;\n}\nexport interface IDownloader {\n downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): void;\n}\n\nexport const b64DecodeUnicode = (base64Data: string): string => {\n // from bytestream, to percent-encoding, to original string.\n return decodeURIComponent(\n atob(base64Data)\n .split('')\n .map((c: string): string => {\n return `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`;\n })\n .join('')\n );\n};\n\nexport class ImageRegistryFetcher implements IDownloader {\n context: ImageRegistry;\n\n constructor(context?: ImageRegistry) {\n this.context = context;\n }\n\n async downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): Promise<void> {\n const imageRegistry = this.context;\n if (!imageRegistry) {\n error(_('Missing Image Context'));\n }\n try {\n const imageData = await imageRegistry.getByURL(url);\n const [mime, svgBase64] = imageData.dataURI.split('base64,');\n if (mime && mime.toLowerCase().indexOf('image/svg+xml') > -1) {\n complete(b64DecodeUnicode(svgBase64));\n } else {\n error(_(`Unsupported MIME type ${mime} for url ${url}`));\n }\n } catch (e) {\n error(_(`Error retrieving ${url} from Image Registry, error was '${e.message}'`), e);\n }\n }\n}\n\nexport class URLDownloader implements IDownloader {\n downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): void {\n // Step 1: fetch content from URL, get reader\n fetch(url)\n .then(\n async (response: Response): Promise<void> => {\n if (!response.ok) {\n const msg = `Fetch not Ok for ${url}, status was '${response.statusText}'`;\n console.warn(msg);\n error(msg);\n return;\n }\n const reader = response.body.getReader();\n\n // Step 2: get total length\n const contentLength = +response.headers.get('Content-Length');\n\n // Step 3: read the data\n let bytesDownloaded = 0; // length at the moment\n const chunks = []; // array of received binary chunks (comprises the body)\n let done = false;\n while (!done) {\n // eslint-disable-next-line no-await-in-loop\n const res = await reader.read();\n done = res.done;\n const { value } = res;\n if (value) {\n chunks.push(value);\n bytesDownloaded += value.length;\n progress({\n // call the progress callback...can enable the UI to show progress\n bytesDownloaded,\n contentLength,\n message: `Received ${bytesDownloaded} bytes of ${\n contentLength || 'unknown size'\n }`,\n });\n }\n }\n\n // Step 4: concatenate chunks into single Uint8Array\n const chunksAll = new Uint8Array(bytesDownloaded);\n let position = 0;\n // eslint-disable-next-line no-restricted-syntax\n for (const chunk of chunks) {\n chunksAll.set(chunk, position);\n position += chunk.length;\n }\n\n progress({\n bytesDownloaded,\n contentLength,\n message: 'decoding chunks',\n });\n\n // Step 5: decode into a string\n const svg = new TextDecoder('utf-8').decode(chunksAll);\n complete(svg); // show the downloaded svg back to the caller via its completion callback\n }\n )\n .catch((e: Error): void => {\n console.error(e.toString());\n error(`Fetch error for '${url}', error was '${e.toString()}'`, e); // call the supplied error handling function\n });\n }\n}\n\nexport default class Downloader {\n private downloaders = {};\n\n constructor(downloaders: { [protocol: string]: IDownloader }) {\n this.downloaders = downloaders;\n }\n\n downloadWithProgress(\n url: string,\n complete: (svg: string) => void,\n progress?: (p: DownloadProgress) => void,\n error?: (msg: string, error?: Error) => void\n ): void {\n // url is the following:\n // data:image/svg+xml;base64....\n // http://\n // https://\n // local://\n // or otherwise return errors\n\n let protocol = '';\n let isUrl = true;\n try {\n protocol = new URL(url).protocol;\n } catch (e) {\n isUrl = false;\n }\n\n if (isUrl) {\n try {\n const [type = ''] = protocol.split(':');\n if (this.downloaders[type]) {\n // data, http(s), local....\n this.downloaders[type].downloadWithProgress(url, complete, progress, error);\n } else {\n // unknown type\n error(`Unsupported URL protocol '${type}' for SVG download: ${url}`);\n }\n } catch (e) {\n error(`Unexpected error downloading SVG: ${e.message}`);\n }\n } else {\n // the url might be literal content. <svg>...</svg>. This is kindof a hack where if you pass the downloader something\n // that is literal content, it will just return the content. Makes the code flow cleaner in layers above.\n complete(url);\n }\n }\n}\n","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","import * as React from 'react';\nimport Downloader, { IDownloader, DownloadProgress } from './Downloader';\n\n/**\n * The FileDownloader is passed a URL string, and render prop which allows a caller to control what is rendered\n * When the file is completely downloaded. This FileDownloader also displays basic text showing download progress.\n * If you want to supply your own custom renderer or progress and error you can do so as well.\n *\n */\nexport interface FileDownloaderProps {\n /**\n * The URL to download\n */\n url: string;\n /**\n * The render function that will render when the content is downloaded\n * @returns {React.Component}\n */\n renderContent: (content: string) => React.ReactElement;\n /**\n * An optional function to render progress (defaults to basic text display of progress)\n * @param {DownloadProgress} progress\n * @returns {React.Component}\n */\n renderProgress?: (progress: DownloadProgress) => React.Component;\n /**\n * An optional function to render errors (defaults to basic text display of errors)\n * @param {string} msg\n * @param {Error} error\n * @returns {React.Component}\n */\n renderError?: (msg: string, error?: Error) => React.Component;\n /**\n * A <key>:<Downloader> map for Downloader Component\n */\n protocolHandlers: { [key: string]: IDownloader };\n}\n\nexport class FileDownloader extends React.PureComponent<\n FileDownloaderProps,\n { content?: string; progress?: DownloadProgress; error?: string }\n> {\n constructor(props: FileDownloaderProps) {\n super(props);\n this.state = {};\n }\n\n componentDidMount(): void {\n this.initiateDownload();\n }\n\n componentDidUpdate(prevProps: FileDownloaderProps): void {\n if (this.props.url !== prevProps.url) {\n this.initiateDownload();\n }\n }\n\n initiateDownload(): void {\n this.setState({});\n const { url } = this.props;\n\n const downloader = new Downloader(this.props.protocolHandlers);\n downloader.downloadWithProgress(\n url,\n (content: string): void => this.setState({ content }), // done downloading\n (progress: DownloadProgress): void => {\n this.setState({ progress });\n },\n (msg: string): void => {\n this.setState({ error: msg });\n }\n );\n }\n\n render(): JSX.Element | React.Component {\n const {\n url,\n renderContent,\n renderProgress,\n renderError = (msg: string): JSX.Element => <div>{msg}</div>,\n } = this.props;\n const {\n content,\n progress = { message: `Downloading ${url}...`, bytesDownloaded: 0 },\n error,\n } = this.state;\n if (content) {\n return renderContent(content); // render prop\n }\n if (error) {\n return renderError(error);\n }\n return typeof renderProgress === 'function' ? renderProgress(progress) : <></>;\n }\n}\n","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");"],"sourceRoot":""}
@@ -109,9 +109,7 @@ Object.defineProperty(exports, "__esModule", {
109
109
  value: true
110
110
  });
111
111
  exports.pickFieldFromJSONSchema = void 0;
112
-
113
112
  var lodash_1 = __webpack_require__(4);
114
-
115
113
  var pickFieldFromJSONSchema = function pickFieldFromJSONSchema(optionsSchema) {
116
114
  var fieldName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
117
115
  return Object.keys(optionsSchema).reduce(function (accum, k) {
@@ -119,16 +117,13 @@ var pickFieldFromJSONSchema = function pickFieldFromJSONSchema(optionsSchema) {
119
117
  accum[k] = optionsSchema[k][fieldName];
120
118
  } else if (lodash_1.get(optionsSchema, [k, 'type']) === 'object' && lodash_1.has(optionsSchema[k], 'properties')) {
121
119
  var nestedSchema = exports.pickFieldFromJSONSchema(optionsSchema[k].properties, fieldName);
122
-
123
120
  if (!lodash_1.isEmpty(nestedSchema)) {
124
121
  accum[k] = nestedSchema;
125
122
  }
126
123
  }
127
-
128
124
  return accum;
129
125
  }, {});
130
126
  };
131
-
132
127
  exports.pickFieldFromJSONSchema = pickFieldFromJSONSchema;
133
128
 
134
129
  /***/ })
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"lodash\"","webpack:///./src/JSONSchemaUtils.ts"],"names":[],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;AClFA,mC;;;;;;;;;;;;;;;ACEA;;AAUO,IAAM,uBAAuB,GAAG,SAA1B,uBAA0B,CACnC,aADmC;AAAA,MAEnC,SAFmC,uEAEvB,SAFuB;AAAA,SAInC,MAAM,CAAC,IAAP,CAAY,aAAZ,EAA2B,MAA3B,CAAkC,UAAC,KAAD,EAAiC,CAAjC,EAA+D;AAC7F,QAAI,aAAI,aAAa,CAAC,CAAD,CAAjB,EAAsB,SAAtB,CAAJ,EAAsC;AAClC,WAAK,CAAC,CAAD,CAAL,GAAW,aAAa,CAAC,CAAD,CAAb,CAAiB,SAAjB,CAAX;AACH,KAFD,MAEO,IAAI,aAAI,aAAJ,EAAmB,CAAC,CAAD,EAAI,MAAJ,CAAnB,MAAoC,QAApC,IAAgD,aAAI,aAAa,CAAC,CAAD,CAAjB,EAAsB,YAAtB,CAApD,EAAyF;AAC5F,UAAM,YAAY,GAAG,gCAAwB,aAAa,CAAC,CAAD,CAAb,CAAiB,UAAzC,EAAqD,SAArD,CAArB;;AACA,UAAI,CAAC,iBAAQ,YAAR,CAAL,EAA4B;AACxB,aAAK,CAAC,CAAD,CAAL,GAAW,YAAX;AACH;AACJ;;AACD,WAAO,KAAP;AACH,GAVD,EAUG,EAVH,CAJmC;AAAA,CAAhC;;AAAM,kCAAuB,uBAAvB,C","file":"JSONSchemaUtils.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 45);\n","module.exports = require(\"lodash\");","/* eslint-disable no-param-reassign */\nimport type { JSONSchema7, JSONSchema7Definition } from 'json-schema';\nimport { has, isEmpty, get } from 'lodash';\n\ninterface OptionsSchema {\n [key: string]: JSONSchema7;\n}\n\ninterface KV {\n [key: string]: any;\n}\n\nexport const pickFieldFromJSONSchema = (\n optionsSchema: OptionsSchema | JSONSchema7Definition,\n fieldName = 'default'\n): KV =>\n Object.keys(optionsSchema).reduce((accum: Record<string, unknown>, k): Record<string, unknown> => {\n if (has(optionsSchema[k], fieldName)) {\n accum[k] = optionsSchema[k][fieldName];\n } else if (get(optionsSchema, [k, 'type']) === 'object' && has(optionsSchema[k], 'properties')) {\n const nestedSchema = pickFieldFromJSONSchema(optionsSchema[k].properties, fieldName);\n if (!isEmpty(nestedSchema)) {\n accum[k] = nestedSchema;\n }\n }\n return accum;\n }, {});\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"lodash\"","webpack:///./src/JSONSchemaUtils.ts"],"names":["lodash_1","require","pickFieldFromJSONSchema","optionsSchema","fieldName","arguments","length","undefined","Object","keys","reduce","accum","k","has","get","nestedSchema","exports","properties","isEmpty"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;AClFA,mC;;;;;;;;;;;;;;ACEA,IAAAA,QAAA,GAAAC,mBAAA;AAUO,IAAMC,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAChCC,aAAoD;EAAA,IACpDC,SAAS,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;EAAA,OAErBG,MAAM,CAACC,IAAI,CAACN,aAAa,CAAC,CAACO,MAAM,CAAC,UAACC,KAA8B,EAAEC,CAAC,EAA6B;IAC7F,IAAIZ,QAAA,CAAAa,GAAG,CAACV,aAAa,CAACS,CAAC,CAAC,EAAER,SAAS,CAAC,EAAE;MAClCO,KAAK,CAACC,CAAC,CAAC,GAAGT,aAAa,CAACS,CAAC,CAAC,CAACR,SAAS,CAAC;KACzC,MAAM,IAAIJ,QAAA,CAAAc,GAAG,CAACX,aAAa,EAAE,CAACS,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,QAAQ,IAAIZ,QAAA,CAAAa,GAAG,CAACV,aAAa,CAACS,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE;MAC5F,IAAMG,YAAY,GAAGC,OAAA,CAAAd,uBAAuB,CAACC,aAAa,CAACS,CAAC,CAAC,CAACK,UAAU,EAAEb,SAAS,CAAC;MACpF,IAAI,CAACJ,QAAA,CAAAkB,OAAO,CAACH,YAAY,CAAC,EAAE;QACxBJ,KAAK,CAACC,CAAC,CAAC,GAAGG,YAAY;;;IAG/B,OAAOJ,KAAK;EAChB,CAAC,EAAE,EAAE,CAAC;AAAA;AAdGK,OAAA,CAAAd,uBAAuB,GAAAA,uBAAA,C","file":"JSONSchemaUtils.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 45);\n","module.exports = require(\"lodash\");","/* eslint-disable no-param-reassign */\nimport type { JSONSchema7, JSONSchema7Definition } from 'json-schema';\nimport { has, isEmpty, get } from 'lodash';\n\ninterface OptionsSchema {\n [key: string]: JSONSchema7;\n}\n\ninterface KV {\n [key: string]: any;\n}\n\nexport const pickFieldFromJSONSchema = (\n optionsSchema: OptionsSchema | JSONSchema7Definition,\n fieldName = 'default'\n): KV =>\n Object.keys(optionsSchema).reduce((accum: Record<string, unknown>, k): Record<string, unknown> => {\n if (has(optionsSchema[k], fieldName)) {\n accum[k] = optionsSchema[k][fieldName];\n } else if (get(optionsSchema, [k, 'type']) === 'object' && has(optionsSchema[k], 'properties')) {\n const nestedSchema = pickFieldFromJSONSchema(optionsSchema[k].properties, fieldName);\n if (!isEmpty(nestedSchema)) {\n accum[k] = nestedSchema;\n }\n }\n return accum;\n }, {});\n"],"sourceRoot":""}