@splunk/visualization-context 25.7.2 → 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.
- package/BaseRegistry.js +15 -55
- package/BaseRegistry.js.map +1 -1
- package/DataSourceContext.js +1 -3
- package/DataSourceContext.js.map +1 -1
- package/EventsContext.js +1 -3
- package/EventsContext.js.map +1 -1
- package/FeatureFlagContext.js +1 -1
- package/FeatureFlagContext.js.map +1 -1
- package/FeatureFlags.js.map +1 -1
- package/GeoContext.js +1 -1
- package/GeoContext.js.map +1 -1
- package/GeoJsonProvider.js +11 -29
- package/GeoJsonProvider.js.map +1 -1
- package/GeoRegistry.js +38 -96
- package/GeoRegistry.js.map +1 -1
- package/IconContext.js +1 -1
- package/IconContext.js.map +1 -1
- package/IconRegistry.js +17 -74
- package/IconRegistry.js.map +1 -1
- package/ImageContext.js +1 -1
- package/ImageContext.js.map +1 -1
- package/ImageRegistry.js +17 -75
- package/ImageRegistry.js.map +1 -1
- package/LocalIconProvider.js +27 -70
- package/LocalIconProvider.js.map +1 -1
- package/LocalImageProvider.js +16 -47
- package/LocalImageProvider.js.map +1 -1
- package/MapContext.js +1 -3
- package/MapContext.js.map +1 -1
- package/MessageContext.js +0 -2
- package/MessageContext.js.map +1 -1
- package/MockedProvider.js +21 -55
- package/MockedProvider.js.map +1 -1
- package/Provider.js +2 -21
- package/Provider.js.map +1 -1
- package/TimezoneContext.js +1 -3
- package/TimezoneContext.js.map +1 -1
- package/package.json +2 -2
- package/testDataURIs.js.map +1 -1
- package/testSVG.js.map +1 -1
package/LocalIconProvider.js
CHANGED
|
@@ -211,65 +211,45 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
211
211
|
|
|
212
212
|
|
|
213
213
|
|
|
214
|
-
|
|
215
214
|
function ownKeys(object, enumerableOnly) {
|
|
216
215
|
var keys = Object.keys(object);
|
|
217
|
-
|
|
218
216
|
if (Object.getOwnPropertySymbols) {
|
|
219
217
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
220
|
-
|
|
218
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
221
219
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
222
|
-
});
|
|
223
|
-
keys.push.apply(keys, symbols);
|
|
220
|
+
})), keys.push.apply(keys, symbols);
|
|
224
221
|
}
|
|
225
|
-
|
|
226
222
|
return keys;
|
|
227
223
|
}
|
|
228
|
-
|
|
229
224
|
function _objectSpread(target) {
|
|
230
225
|
for (var i = 1; i < arguments.length; i++) {
|
|
231
|
-
var source = arguments[i]
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
238
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
239
|
-
} else {
|
|
240
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
241
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
242
|
-
});
|
|
243
|
-
}
|
|
226
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
227
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
228
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
|
|
229
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
230
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
231
|
+
});
|
|
244
232
|
}
|
|
245
|
-
|
|
246
233
|
return target;
|
|
247
234
|
}
|
|
248
|
-
|
|
249
235
|
function _createSuper(Derived) {
|
|
250
236
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
251
|
-
|
|
252
237
|
return function _createSuperInternal() {
|
|
253
238
|
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(Derived),
|
|
254
|
-
|
|
255
|
-
|
|
239
|
+
result;
|
|
256
240
|
if (hasNativeReflectConstruct) {
|
|
257
241
|
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(this).constructor;
|
|
258
|
-
|
|
259
242
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
260
243
|
} else {
|
|
261
244
|
result = Super.apply(this, arguments);
|
|
262
245
|
}
|
|
263
|
-
|
|
264
246
|
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5___default()(this, result);
|
|
265
247
|
};
|
|
266
248
|
}
|
|
267
|
-
|
|
268
249
|
function _isNativeReflectConstruct() {
|
|
269
250
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
270
251
|
if (Reflect.construct.sham) return false;
|
|
271
252
|
if (typeof Proxy === "function") return true;
|
|
272
|
-
|
|
273
253
|
try {
|
|
274
254
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
275
255
|
return true;
|
|
@@ -281,10 +261,9 @@ function _isNativeReflectConstruct() {
|
|
|
281
261
|
|
|
282
262
|
|
|
283
263
|
|
|
284
|
-
|
|
285
|
-
|
|
286
264
|
var b64EncodeUnicode = function b64EncodeUnicode(str) {
|
|
287
|
-
return (
|
|
265
|
+
return (
|
|
266
|
+
// first we use encodeURIComponent to get percent-encoded UTF-8,
|
|
288
267
|
// then we convert the percent encodings into raw bytes which
|
|
289
268
|
// can be fed into btoa.
|
|
290
269
|
btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
|
|
@@ -293,35 +272,31 @@ var b64EncodeUnicode = function b64EncodeUnicode(str) {
|
|
|
293
272
|
);
|
|
294
273
|
};
|
|
295
274
|
var KEY = '__icons__';
|
|
275
|
+
|
|
296
276
|
/**
|
|
297
277
|
* a local icon provider
|
|
298
278
|
*/
|
|
299
|
-
|
|
300
279
|
var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
301
280
|
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(LocalIconProvider, _Provider);
|
|
302
|
-
|
|
303
281
|
var _super = _createSuper(LocalIconProvider);
|
|
304
|
-
|
|
305
282
|
function LocalIconProvider() {
|
|
306
283
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, LocalIconProvider);
|
|
307
|
-
|
|
308
284
|
return _super.call(this);
|
|
309
285
|
}
|
|
286
|
+
|
|
310
287
|
/**
|
|
311
288
|
* return provider type
|
|
312
289
|
* @return {String} 'local'
|
|
313
290
|
*/
|
|
314
|
-
|
|
315
|
-
|
|
316
291
|
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3___default()(LocalIconProvider, [{
|
|
317
292
|
key: "getType",
|
|
318
293
|
value: function getType() {
|
|
319
294
|
return 'local';
|
|
320
295
|
}
|
|
296
|
+
|
|
321
297
|
/**
|
|
322
298
|
* upload one new icon
|
|
323
299
|
*/
|
|
324
|
-
|
|
325
300
|
}, {
|
|
326
301
|
key: "upload",
|
|
327
302
|
value: function () {
|
|
@@ -333,33 +308,27 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
333
308
|
case 0:
|
|
334
309
|
_context.next = 2;
|
|
335
310
|
return fetch(dataURI);
|
|
336
|
-
|
|
337
311
|
case 2:
|
|
338
312
|
response = _context.sent;
|
|
339
313
|
_context.next = 5;
|
|
340
314
|
return response.text();
|
|
341
|
-
|
|
342
315
|
case 5:
|
|
343
316
|
text = _context.sent;
|
|
344
317
|
parser = new DOMParser();
|
|
345
318
|
xmlDoc = parser.parseFromString(text, 'text/xml');
|
|
346
319
|
svg = xmlDoc.getElementsByTagName('svg')[0];
|
|
347
|
-
|
|
348
320
|
if (svg.getAttribute('viewBox')) {
|
|
349
321
|
_context.next = 11;
|
|
350
322
|
break;
|
|
351
323
|
}
|
|
352
|
-
|
|
353
324
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_9__["_"])('Please upload a valid svg with viewBox attribute.'));
|
|
354
|
-
|
|
355
325
|
case 11:
|
|
356
326
|
// reset svg attributes
|
|
357
|
-
svg.setAttribute('preserveAspectRatio', 'none');
|
|
358
|
-
|
|
327
|
+
svg.setAttribute('preserveAspectRatio', 'none');
|
|
328
|
+
// convert back to dataURI
|
|
359
329
|
serializer = new XMLSerializer();
|
|
360
330
|
svgStr = b64EncodeUnicode(serializer.serializeToString(svg));
|
|
361
331
|
iconDataURI = "data:image/svg+xml;base64,".concat(svgStr); // save to localStorage
|
|
362
|
-
|
|
363
332
|
_context.prev = 15;
|
|
364
333
|
icon = {
|
|
365
334
|
dataURI: iconDataURI,
|
|
@@ -370,12 +339,10 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
370
339
|
icons = _objectSpread(_objectSpread({}, icons), {}, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, id, icon));
|
|
371
340
|
localStorage.setItem(KEY, JSON.stringify(icons));
|
|
372
341
|
return _context.abrupt("return", id);
|
|
373
|
-
|
|
374
342
|
case 24:
|
|
375
343
|
_context.prev = 24;
|
|
376
344
|
_context.t0 = _context["catch"](15);
|
|
377
345
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_9__["_"])('The icon cannot be uploaded. Please check whether your localStorage is full.'));
|
|
378
|
-
|
|
379
346
|
case 27:
|
|
380
347
|
case "end":
|
|
381
348
|
return _context.stop();
|
|
@@ -383,47 +350,41 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
383
350
|
}
|
|
384
351
|
}, _callee, null, [[15, 24]]);
|
|
385
352
|
}));
|
|
386
|
-
|
|
387
353
|
function upload(_x, _x2) {
|
|
388
354
|
return _upload.apply(this, arguments);
|
|
389
355
|
}
|
|
390
|
-
|
|
391
356
|
return upload;
|
|
392
357
|
}()
|
|
393
358
|
/**
|
|
394
359
|
* get one icon by icon id
|
|
395
360
|
*/
|
|
396
|
-
|
|
397
361
|
}, {
|
|
398
362
|
key: "getById",
|
|
399
363
|
value: function getById(id) {
|
|
400
364
|
var icons = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
401
|
-
|
|
402
365
|
if (icons[id]) {
|
|
403
366
|
return icons[id];
|
|
404
367
|
}
|
|
405
|
-
|
|
406
368
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_9__["_"])('The icon is not found.'));
|
|
407
369
|
}
|
|
370
|
+
|
|
408
371
|
/**
|
|
409
372
|
* get all icon ids
|
|
410
373
|
* @params options
|
|
411
374
|
* @params options.meta a list of meta data attribute that would be returned with each id
|
|
412
375
|
* @params options.search a search string to filter the returned icons
|
|
413
376
|
*/
|
|
414
|
-
|
|
415
377
|
}, {
|
|
416
378
|
key: "listIds",
|
|
417
379
|
value: function listIds(_ref) {
|
|
418
380
|
var _ref$offset = _ref.offset,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
381
|
+
offset = _ref$offset === void 0 ? 0 : _ref$offset,
|
|
382
|
+
_ref$count = _ref.count,
|
|
383
|
+
count = _ref$count === void 0 ? 100 : _ref$count,
|
|
384
|
+
_ref$meta = _ref.meta,
|
|
385
|
+
meta = _ref$meta === void 0 ? [] : _ref$meta,
|
|
386
|
+
_ref$search = _ref.search,
|
|
387
|
+
search = _ref$search === void 0 ? null : _ref$search;
|
|
427
388
|
try {
|
|
428
389
|
var icons = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
429
390
|
var results = [];
|
|
@@ -431,13 +392,12 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
431
392
|
var icon = {
|
|
432
393
|
id: id
|
|
433
394
|
};
|
|
434
|
-
var iconMeta = icons[id].metaData || {};
|
|
435
|
-
|
|
395
|
+
var iconMeta = icons[id].metaData || {};
|
|
396
|
+
// If search is a valid string, return the icon with matched meta data
|
|
436
397
|
var isSearchedIcon = search != null && Object.keys(iconMeta).some(function (attr) {
|
|
437
398
|
var iconMetaValue = iconMeta[attr].toLowerCase();
|
|
438
399
|
return iconMetaValue.indexOf(search.toLowerCase()) > -1;
|
|
439
400
|
});
|
|
440
|
-
|
|
441
401
|
if (search == null || isSearchedIcon) {
|
|
442
402
|
if (meta && meta.length) {
|
|
443
403
|
icon.metaData = {};
|
|
@@ -447,7 +407,6 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
447
407
|
}
|
|
448
408
|
});
|
|
449
409
|
}
|
|
450
|
-
|
|
451
410
|
results.push(icon);
|
|
452
411
|
}
|
|
453
412
|
});
|
|
@@ -456,10 +415,10 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
456
415
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_9__["_"])('The icon ids cannot be listed.'));
|
|
457
416
|
}
|
|
458
417
|
}
|
|
418
|
+
|
|
459
419
|
/**
|
|
460
420
|
* delete an icon by icon id
|
|
461
421
|
*/
|
|
462
|
-
|
|
463
422
|
}, {
|
|
464
423
|
key: "deleteById",
|
|
465
424
|
value: function deleteById(id) {
|
|
@@ -474,10 +433,8 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
474
433
|
}
|
|
475
434
|
}
|
|
476
435
|
}]);
|
|
477
|
-
|
|
478
436
|
return LocalIconProvider;
|
|
479
437
|
}(_splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_10___default.a);
|
|
480
|
-
|
|
481
438
|
/* harmony default export */ __webpack_exports__["default"] = (LocalIconProvider);
|
|
482
439
|
|
|
483
440
|
/***/ })
|
package/LocalIconProvider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@splunk/visualization-context/Provider\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"uuid-v4\"","webpack:///./src/LocalIconProvider.js"],"names":["b64EncodeUnicode","btoa","String","parseInt","KEY","LocalIconProvider","fetch","response","text","parser","xmlDoc","svg","_","serializer","svgStr","iconDataURI","icon","dataURI","metaData","id","uuid","icons","JSON","localStorage","offset","count","meta","search","results","Object","iconMeta","isSearchedIcon","iconMetaValue","Provider"],"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,kD;;;;;;ACAA,uD;;;;;;ACAA,kE;;;;;;ACAA,+D;;;;;;ACAA,oE;;;;;;ACAA,kE;;;;;;ACAA,mE;;;;;;;ACAA,4D;;;;;;ACAA,6E;;;;;;ACAA,kE;;;;;;;;;ACAA,oC;;;;;;;;;;;;;;;;;;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A,aAFN,EAEX,CAFW,CAGX;;AACA,cAAMU,cAAc,GAChBJ,MAAM,IAANA,QACA,MAAM,CAAN,oBAA2B,gBAAQ;AAC/B,gBAAMK,aAAa,GAAGF,QAAQ,CAARA,IAAQ,CAARA,CAAtB,WAAsBA,EAAtB;AACA,mBAAOE,aAAa,CAAbA,QAAsBL,MAAM,CAA5BK,WAAsBL,EAAtBK,IAA8C,CAArD;AAJR,WAEI,CAFJ;;AAOA,cAAIL,MAAM,IAANA,QAAJ,gBAAsC;AAClC,gBAAID,IAAI,IAAIA,IAAI,CAAhB,QAAyB;AACrBV,kBAAI,CAAJA;AACAU,kBAAI,CAAJA,QAAa,gBAAQ;AACjB,oBAAII,QAAQ,CAARA,IAAQ,CAARA,IAAJ,MAA4B;AACxBd,sBAAI,CAAJA,iBAAsBc,QAAQ,CAA9Bd,IAA8B,CAA9BA;AACH;AAHLU;AAKH;;AAEDE,mBAAO,CAAPA;AACH;AAxBTC;AA2BA;AA/BJ,QAgCE,cAAc;AACZ,cAAM,UAAUjB,+DAAC,CAAjB,gCAAiB,CAAX,CAAN;AACH;AACJ;AAED;AACJ;AACA;;;;WACI,wBAAe;AACX,UAAI;AACA,YAAMI,IAAI,GAAG,aAAb,EAAa,CAAb;AACA,YAAMK,KAAK,GAAGC,IAAI,CAAJA,MAAWC,YAAY,CAAZA,QAAzB,GAAyBA,CAAXD,CAAd;AACA,eAAOD,KAAK,CAAZ,EAAY,CAAZ;AACAE,oBAAY,CAAZA,aAA0BD,IAAI,CAAJA,UAA1BC,KAA0BD,CAA1BC;AACA;AALJ,QAME,cAAc;AACZ,cAAM,UAAUX,+DAAC,CAAjB,6BAAiB,CAAX,CAAN;AACH;AACJ;;;;EAtH2BqB,8E;;AAyHhC,kF","file":"LocalIconProvider.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 = 28);\n","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@splunk/visualization-context/Provider\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"uuid-v4\");","/* eslint-disable class-methods-use-this,no-useless-constructor */\nimport uuid from 'uuid-v4';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport Provider from '@splunk/visualization-context/Provider';\n\nexport const b64EncodeUnicode = str =>\n // first we use encodeURIComponent to get percent-encoded UTF-8,\n // then we convert the percent encodings into raw bytes which\n // can be fed into btoa.\n btoa(\n encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) =>\n String.fromCharCode(parseInt(`0x${p1}`, 16))\n )\n );\n\nexport const KEY = '__icons__';\n\n/**\n * a local icon provider\n */\nclass LocalIconProvider extends Provider {\n constructor() {\n super();\n }\n\n /**\n * return provider type\n * @return {String} 'local'\n */\n getType() {\n return 'local';\n }\n\n /**\n * upload one new icon\n */\n async upload(dataURI, metaData) {\n // get svg from dataURI\n const response = await fetch(dataURI);\n const text = await response.text();\n const parser = new DOMParser();\n const xmlDoc = parser.parseFromString(text, 'text/xml');\n const svg = xmlDoc.getElementsByTagName('svg')[0];\n\n if (!svg.getAttribute('viewBox')) {\n throw new Error(_('Please upload a valid svg with viewBox attribute.'));\n }\n\n // reset svg attributes\n svg.setAttribute('preserveAspectRatio', 'none');\n // convert back to dataURI\n const serializer = new XMLSerializer();\n const svgStr = b64EncodeUnicode(serializer.serializeToString(svg));\n const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;\n\n // save to localStorage\n try {\n const icon = { dataURI: iconDataURI, metaData };\n const id = uuid();\n let icons = JSON.parse(localStorage.getItem(KEY) || '{}');\n icons = { ...icons, [id]: icon };\n localStorage.setItem(KEY, JSON.stringify(icons));\n return id;\n } catch (error) {\n throw new Error(\n _('The icon cannot be uploaded. Please check whether your localStorage is full.')\n );\n }\n }\n\n /**\n * get one icon by icon id\n */\n getById(id) {\n const icons = JSON.parse(localStorage.getItem(KEY) || '{}');\n if (icons[id]) {\n return icons[id];\n }\n throw new Error(_('The icon is not found.'));\n }\n\n /**\n * get all icon ids\n * @params options\n * @params options.meta a list of meta data attribute that would be returned with each id\n * @params options.search a search string to filter the returned icons\n */\n listIds({ offset = 0, count = 100, meta = [], search = null }) {\n try {\n const icons = JSON.parse(localStorage.getItem(KEY) || '{}');\n const results = [];\n\n Object.keys(icons)\n .slice(offset, count)\n .forEach(id => {\n const icon = { id };\n const iconMeta = icons[id].metaData || {};\n // If search is a valid string, return the icon with matched meta data\n const isSearchedIcon =\n search != null &&\n Object.keys(iconMeta).some(attr => {\n const iconMetaValue = iconMeta[attr].toLowerCase();\n return iconMetaValue.indexOf(search.toLowerCase()) > -1;\n });\n\n if (search == null || isSearchedIcon) {\n if (meta && meta.length) {\n icon.metaData = {};\n meta.forEach(attr => {\n if (iconMeta[attr] != null) {\n icon.metaData[attr] = iconMeta[attr];\n }\n });\n }\n\n results.push(icon);\n }\n });\n\n return results;\n } catch (error) {\n throw new Error(_('The icon ids cannot be listed.'));\n }\n }\n\n /**\n * delete an icon by icon id\n */\n deleteById(id) {\n try {\n const icon = this.getById(id);\n const icons = JSON.parse(localStorage.getItem(KEY));\n delete icons[id];\n localStorage.setItem(KEY, JSON.stringify(icons));\n return icon;\n } catch (error) {\n throw new Error(_('The icon cannot be deleted.'));\n }\n }\n}\n\nexport default LocalIconProvider;\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@splunk/visualization-context/Provider\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"uuid-v4\"","webpack:///./src/LocalIconProvider.js"],"names":["b64EncodeUnicode","str","btoa","encodeURIComponent","replace","match","p1","String","fromCharCode","parseInt","concat","KEY","LocalIconProvider","_Provider","_inherits","_super","_createSuper","_classCallCheck","call","_createClass","key","value","getType","_upload","_asyncToGenerator","_regeneratorRuntime","mark","_callee","dataURI","metaData","response","text","parser","xmlDoc","svg","serializer","svgStr","iconDataURI","icon","id","icons","wrap","_callee$","_context","prev","next","fetch","sent","DOMParser","parseFromString","getElementsByTagName","getAttribute","Error","_","setAttribute","XMLSerializer","serializeToString","uuid","JSON","parse","localStorage","getItem","_objectSpread","_defineProperty","setItem","stringify","abrupt","t0","stop","upload","_x","_x2","apply","arguments","getById","listIds","_ref","_ref$offset","offset","_ref$count","count","_ref$meta","meta","_ref$search","search","results","Object","keys","slice","forEach","iconMeta","isSearchedIcon","some","attr","iconMetaValue","toLowerCase","indexOf","length","push","error","deleteById","Provider"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAG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AC,6BAA6B,CAAC,CAAC;MACrD;IACJ;EAAC;EAAA,OAAAzC,iBAAA;AAAA,EAtH2ByF,8EAAQ;AAyHzBzF,gFAAiB,E","file":"LocalIconProvider.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 = 28);\n","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@splunk/visualization-context/Provider\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"uuid-v4\");","/* eslint-disable class-methods-use-this,no-useless-constructor */\nimport uuid from 'uuid-v4';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport Provider from '@splunk/visualization-context/Provider';\n\nexport const b64EncodeUnicode = str =>\n // first we use encodeURIComponent to get percent-encoded UTF-8,\n // then we convert the percent encodings into raw bytes which\n // can be fed into btoa.\n btoa(\n encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) =>\n String.fromCharCode(parseInt(`0x${p1}`, 16))\n )\n );\n\nexport const KEY = '__icons__';\n\n/**\n * a local icon provider\n */\nclass LocalIconProvider extends Provider {\n constructor() {\n super();\n }\n\n /**\n * return provider type\n * @return {String} 'local'\n */\n getType() {\n return 'local';\n }\n\n /**\n * upload one new icon\n */\n async upload(dataURI, metaData) {\n // get svg from dataURI\n const response = await fetch(dataURI);\n const text = await response.text();\n const parser = new DOMParser();\n const xmlDoc = parser.parseFromString(text, 'text/xml');\n const svg = xmlDoc.getElementsByTagName('svg')[0];\n\n if (!svg.getAttribute('viewBox')) {\n throw new Error(_('Please upload a valid svg with viewBox attribute.'));\n }\n\n // reset svg attributes\n svg.setAttribute('preserveAspectRatio', 'none');\n // convert back to dataURI\n const serializer = new XMLSerializer();\n const svgStr = b64EncodeUnicode(serializer.serializeToString(svg));\n const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;\n\n // save to localStorage\n try {\n const icon = { dataURI: iconDataURI, metaData };\n const id = uuid();\n let icons = JSON.parse(localStorage.getItem(KEY) || '{}');\n icons = { ...icons, [id]: icon };\n localStorage.setItem(KEY, JSON.stringify(icons));\n return id;\n } catch (error) {\n throw new Error(\n _('The icon cannot be uploaded. Please check whether your localStorage is full.')\n );\n }\n }\n\n /**\n * get one icon by icon id\n */\n getById(id) {\n const icons = JSON.parse(localStorage.getItem(KEY) || '{}');\n if (icons[id]) {\n return icons[id];\n }\n throw new Error(_('The icon is not found.'));\n }\n\n /**\n * get all icon ids\n * @params options\n * @params options.meta a list of meta data attribute that would be returned with each id\n * @params options.search a search string to filter the returned icons\n */\n listIds({ offset = 0, count = 100, meta = [], search = null }) {\n try {\n const icons = JSON.parse(localStorage.getItem(KEY) || '{}');\n const results = [];\n\n Object.keys(icons)\n .slice(offset, count)\n .forEach(id => {\n const icon = { id };\n const iconMeta = icons[id].metaData || {};\n // If search is a valid string, return the icon with matched meta data\n const isSearchedIcon =\n search != null &&\n Object.keys(iconMeta).some(attr => {\n const iconMetaValue = iconMeta[attr].toLowerCase();\n return iconMetaValue.indexOf(search.toLowerCase()) > -1;\n });\n\n if (search == null || isSearchedIcon) {\n if (meta && meta.length) {\n icon.metaData = {};\n meta.forEach(attr => {\n if (iconMeta[attr] != null) {\n icon.metaData[attr] = iconMeta[attr];\n }\n });\n }\n\n results.push(icon);\n }\n });\n\n return results;\n } catch (error) {\n throw new Error(_('The icon ids cannot be listed.'));\n }\n }\n\n /**\n * delete an icon by icon id\n */\n deleteById(id) {\n try {\n const icon = this.getById(id);\n const icons = JSON.parse(localStorage.getItem(KEY));\n delete icons[id];\n localStorage.setItem(KEY, JSON.stringify(icons));\n return icon;\n } catch (error) {\n throw new Error(_('The icon cannot be deleted.'));\n }\n }\n}\n\nexport default LocalIconProvider;\n"],"sourceRoot":""}
|
package/LocalImageProvider.js
CHANGED
|
@@ -195,65 +195,45 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
|
|
199
198
|
function ownKeys(object, enumerableOnly) {
|
|
200
199
|
var keys = Object.keys(object);
|
|
201
|
-
|
|
202
200
|
if (Object.getOwnPropertySymbols) {
|
|
203
201
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
204
|
-
|
|
202
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
205
203
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
206
|
-
});
|
|
207
|
-
keys.push.apply(keys, symbols);
|
|
204
|
+
})), keys.push.apply(keys, symbols);
|
|
208
205
|
}
|
|
209
|
-
|
|
210
206
|
return keys;
|
|
211
207
|
}
|
|
212
|
-
|
|
213
208
|
function _objectSpread(target) {
|
|
214
209
|
for (var i = 1; i < arguments.length; i++) {
|
|
215
|
-
var source = arguments[i]
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
222
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
223
|
-
} else {
|
|
224
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
225
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
226
|
-
});
|
|
227
|
-
}
|
|
210
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
211
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
212
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
|
|
213
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
214
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
215
|
+
});
|
|
228
216
|
}
|
|
229
|
-
|
|
230
217
|
return target;
|
|
231
218
|
}
|
|
232
|
-
|
|
233
219
|
function _createSuper(Derived) {
|
|
234
220
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
235
|
-
|
|
236
221
|
return function _createSuperInternal() {
|
|
237
222
|
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(Derived),
|
|
238
|
-
|
|
239
|
-
|
|
223
|
+
result;
|
|
240
224
|
if (hasNativeReflectConstruct) {
|
|
241
225
|
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(this).constructor;
|
|
242
|
-
|
|
243
226
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
244
227
|
} else {
|
|
245
228
|
result = Super.apply(this, arguments);
|
|
246
229
|
}
|
|
247
|
-
|
|
248
230
|
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, result);
|
|
249
231
|
};
|
|
250
232
|
}
|
|
251
|
-
|
|
252
233
|
function _isNativeReflectConstruct() {
|
|
253
234
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
254
235
|
if (Reflect.construct.sham) return false;
|
|
255
236
|
if (typeof Proxy === "function") return true;
|
|
256
|
-
|
|
257
237
|
try {
|
|
258
238
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
259
239
|
return true;
|
|
@@ -265,37 +245,31 @@ function _isNativeReflectConstruct() {
|
|
|
265
245
|
|
|
266
246
|
|
|
267
247
|
|
|
268
|
-
|
|
269
|
-
|
|
270
248
|
var KEY = '__images__';
|
|
249
|
+
|
|
271
250
|
/**
|
|
272
251
|
* a pure frontend local image provider
|
|
273
252
|
*/
|
|
274
|
-
|
|
275
253
|
var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
276
254
|
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default()(LocalImageProvider, _Provider);
|
|
277
|
-
|
|
278
255
|
var _super = _createSuper(LocalImageProvider);
|
|
279
|
-
|
|
280
256
|
function LocalImageProvider() {
|
|
281
257
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, LocalImageProvider);
|
|
282
|
-
|
|
283
258
|
return _super.call(this);
|
|
284
259
|
}
|
|
260
|
+
|
|
285
261
|
/**
|
|
286
262
|
* return provider type
|
|
287
263
|
*/
|
|
288
|
-
|
|
289
|
-
|
|
290
264
|
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(LocalImageProvider, [{
|
|
291
265
|
key: "getType",
|
|
292
266
|
value: function getType() {
|
|
293
267
|
return 'local';
|
|
294
268
|
}
|
|
269
|
+
|
|
295
270
|
/**
|
|
296
271
|
* add a new image
|
|
297
272
|
*/
|
|
298
|
-
|
|
299
273
|
}, {
|
|
300
274
|
key: "upload",
|
|
301
275
|
value: function upload(dataURI, metaData) {
|
|
@@ -313,32 +287,29 @@ var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
|
313
287
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_7__["_"])('The image cannot be uploaded. Please check whether your localStorage is full.'));
|
|
314
288
|
}
|
|
315
289
|
}
|
|
290
|
+
|
|
316
291
|
/**
|
|
317
292
|
* get image by imageID
|
|
318
293
|
*/
|
|
319
|
-
|
|
320
294
|
}, {
|
|
321
295
|
key: "getById",
|
|
322
296
|
value: function getById(imageID) {
|
|
323
297
|
var images = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
324
298
|
var imageObject = images[imageID];
|
|
325
|
-
|
|
326
299
|
if (imageObject) {
|
|
327
300
|
return imageObject;
|
|
328
301
|
}
|
|
329
|
-
|
|
330
302
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_7__["_"])('The image is not found.'));
|
|
331
303
|
}
|
|
304
|
+
|
|
332
305
|
/**
|
|
333
306
|
* get all imageIDs
|
|
334
307
|
*/
|
|
335
|
-
|
|
336
308
|
}, {
|
|
337
309
|
key: "listIds",
|
|
338
310
|
value: function listIds(_ref) {
|
|
339
311
|
var offset = _ref.offset,
|
|
340
|
-
|
|
341
|
-
|
|
312
|
+
count = _ref.count;
|
|
342
313
|
try {
|
|
343
314
|
var images = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
344
315
|
var imageIDS = Object.keys(images);
|
|
@@ -347,10 +318,10 @@ var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
|
347
318
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_7__["_"])('The image ids cannot be listed.'));
|
|
348
319
|
}
|
|
349
320
|
}
|
|
321
|
+
|
|
350
322
|
/**
|
|
351
323
|
* delete an image by dataID
|
|
352
324
|
*/
|
|
353
|
-
|
|
354
325
|
}, {
|
|
355
326
|
key: "deleteById",
|
|
356
327
|
value: function deleteById(imageID) {
|
|
@@ -365,10 +336,8 @@ var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
|
365
336
|
}
|
|
366
337
|
}
|
|
367
338
|
}]);
|
|
368
|
-
|
|
369
339
|
return LocalImageProvider;
|
|
370
340
|
}(_splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_8___default.a);
|
|
371
|
-
|
|
372
341
|
/* harmony default export */ __webpack_exports__["default"] = (LocalImageProvider);
|
|
373
342
|
|
|
374
343
|
/***/ })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@splunk/visualization-context/Provider\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"uuid-v4\"","webpack:///./src/LocalImageProvider.js"],"names":["KEY","LocalImageProvider","
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@splunk/visualization-context/Provider\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"uuid-v4\"","webpack:///./src/LocalImageProvider.js"],"names":["KEY","LocalImageProvider","_Provider","_inherits","_super","_createSuper","_classCallCheck","call","_createClass","key","value","getType","upload","dataURI","metaData","id","uuid","imageObject","images","JSON","parse","localStorage","getItem","_objectSpread","_defineProperty","setItem","stringify","error","Error","_","getById","imageID","listIds","_ref","offset","count","imageIDS","Object","keys","slice","deleteById","Provider"],"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;;QA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KAAK,EAAE;QACZ,MAAM,IAAIC,KAAK,CAACC,+DAAC,CAAC,iCAAiC,CAAC,CAAC;MACzD;IACJ;;IAEA;AACJ;AACA;EAFI;IAAApB,GAAA;IAAAC,KAAA,EAGA,SAAA8B,WAAWT,OAAO,EAAE;MAChB,IAAI;QACA,IAAMd,WAAW,GAAG,IAAI,CAACa,OAAO,CAACC,OAAO,CAAC;QACzC,IAAMb,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACC,YAAY,CAACC,OAAO,CAACtB,GAAG,CAAC,CAAC;QACpD,OAAOkB,MAAM,CAACa,OAAO,CAAC;QACtBV,YAAY,CAACI,OAAO,CAACzB,GAAG,EAAEmB,IAAI,CAACO,SAAS,CAACR,MAAM,CAAC,CAAC;QACjD,OAAOD,WAAW;MACtB,CAAC,CAAC,OAAOU,KAAK,EAAE;QACZ,MAAM,IAAIC,KAAK,CAACC,+DAAC,CAAC,8BAA8B,CAAC,CAAC;MACtD;IACJ;EAAC;EAAA,OAAA5B,kBAAA;AAAA,EApE4BwC,6EAAQ;AAuE1BxC,iFAAkB,E","file":"LocalImageProvider.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 = 29);\n","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@splunk/visualization-context/Provider\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"uuid-v4\");","/* eslint-disable class-methods-use-this,no-useless-constructor */\nimport uuid from 'uuid-v4';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport Provider from '@splunk/visualization-context/Provider';\n\nexport const KEY = '__images__';\n\n/**\n * a pure frontend local image provider\n */\nclass LocalImageProvider extends Provider {\n constructor() {\n super();\n }\n\n /**\n * return provider type\n */\n getType() {\n return 'local';\n }\n\n /**\n * add a new image\n */\n upload(dataURI, metaData) {\n try {\n const id = uuid();\n const imageObject = { dataURI, metaData };\n let images = JSON.parse(localStorage.getItem(KEY) || '{}');\n images = { ...images, [id]: imageObject };\n localStorage.setItem(KEY, JSON.stringify(images));\n return id;\n } catch (error) {\n throw new Error(\n _('The image cannot be uploaded. Please check whether your localStorage is full.')\n );\n }\n }\n\n /**\n * get image by imageID\n */\n getById(imageID) {\n const images = JSON.parse(localStorage.getItem(KEY) || '{}');\n const imageObject = images[imageID];\n if (imageObject) {\n return imageObject;\n }\n throw new Error(_('The image is not found.'));\n }\n\n /**\n * get all imageIDs\n */\n listIds({ offset, count }) {\n try {\n const images = JSON.parse(localStorage.getItem(KEY) || '{}');\n const imageIDS = Object.keys(images);\n return imageIDS.slice(offset, count);\n } catch (error) {\n throw new Error(_('The image ids cannot be listed.'));\n }\n }\n\n /**\n * delete an image by dataID\n */\n deleteById(imageID) {\n try {\n const imageObject = this.getById(imageID);\n const images = JSON.parse(localStorage.getItem(KEY));\n delete images[imageID];\n localStorage.setItem(KEY, JSON.stringify(images));\n return imageObject;\n } catch (error) {\n throw new Error(_('The image cannot be deleted.'));\n }\n }\n}\n\nexport default LocalImageProvider;\n"],"sourceRoot":""}
|
package/MapContext.js
CHANGED
|
@@ -102,13 +102,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
102
102
|
value: true
|
|
103
103
|
});
|
|
104
104
|
exports.testTileConfig = exports.MapContextConsumer = exports.MapContextProvider = void 0;
|
|
105
|
-
|
|
106
105
|
var React = __webpack_require__(7);
|
|
107
|
-
|
|
108
106
|
var MapContext = React.createContext({
|
|
109
107
|
defaultTileConfig: []
|
|
110
108
|
});
|
|
111
|
-
MapContext.displayName = "data-splunk-visualization-version-MapContext-".concat("25.
|
|
109
|
+
MapContext.displayName = "data-splunk-visualization-version-MapContext-".concat("25.8.0 - 65f56b99e");
|
|
112
110
|
exports.MapContextProvider = MapContext.Provider;
|
|
113
111
|
exports.MapContextConsumer = MapContext.Consumer;
|
|
114
112
|
exports.default = MapContext;
|