@splunk/visualization-context 25.13.1 → 26.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BaseRegistry.js +55 -15
- package/BaseRegistry.js.map +1 -1
- package/DataSourceContext.js +3 -1
- package/DataSourceContext.js.map +1 -1
- package/EventsContext.js +3 -1
- 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 +29 -11
- package/GeoJsonProvider.js.map +1 -1
- package/GeoRegistry.js +96 -38
- package/GeoRegistry.js.map +1 -1
- package/IconContext.js +1 -1
- package/IconContext.js.map +1 -1
- package/IconRegistry.js +74 -17
- package/IconRegistry.js.map +1 -1
- package/ImageContext.js +1 -1
- package/ImageContext.js.map +1 -1
- package/ImageRegistry.js +75 -17
- package/ImageRegistry.js.map +1 -1
- package/LocalIconProvider.js +70 -27
- package/LocalIconProvider.js.map +1 -1
- package/LocalImageProvider.js +47 -16
- package/LocalImageProvider.js.map +1 -1
- package/MapContext.js +3 -1
- package/MapContext.js.map +1 -1
- package/MessageContext.js +2 -0
- package/MessageContext.js.map +1 -1
- package/MockedProvider.js +55 -21
- package/MockedProvider.js.map +1 -1
- package/Provider.js +21 -2
- package/Provider.js.map +1 -1
- package/TimezoneContext.js +3 -1
- package/TimezoneContext.js.map +1 -1
- package/package.json +5 -5
- package/testDataURIs.js.map +1 -1
- package/testSVG.js.map +1 -1
package/LocalIconProvider.js
CHANGED
|
@@ -211,45 +211,65 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
211
211
|
|
|
212
212
|
|
|
213
213
|
|
|
214
|
+
|
|
214
215
|
function ownKeys(object, enumerableOnly) {
|
|
215
216
|
var keys = Object.keys(object);
|
|
217
|
+
|
|
216
218
|
if (Object.getOwnPropertySymbols) {
|
|
217
219
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
218
|
-
enumerableOnly
|
|
220
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
219
221
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
220
|
-
})
|
|
222
|
+
});
|
|
223
|
+
keys.push.apply(keys, symbols);
|
|
221
224
|
}
|
|
225
|
+
|
|
222
226
|
return keys;
|
|
223
227
|
}
|
|
228
|
+
|
|
224
229
|
function _objectSpread(target) {
|
|
225
230
|
for (var i = 1; i < arguments.length; i++) {
|
|
226
|
-
var source =
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
232
|
+
|
|
233
|
+
if (i % 2) {
|
|
234
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
235
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
|
|
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
|
+
}
|
|
232
244
|
}
|
|
245
|
+
|
|
233
246
|
return target;
|
|
234
247
|
}
|
|
248
|
+
|
|
235
249
|
function _createSuper(Derived) {
|
|
236
250
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
251
|
+
|
|
237
252
|
return function _createSuperInternal() {
|
|
238
253
|
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(Derived),
|
|
239
|
-
|
|
254
|
+
result;
|
|
255
|
+
|
|
240
256
|
if (hasNativeReflectConstruct) {
|
|
241
257
|
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(this).constructor;
|
|
258
|
+
|
|
242
259
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
243
260
|
} else {
|
|
244
261
|
result = Super.apply(this, arguments);
|
|
245
262
|
}
|
|
263
|
+
|
|
246
264
|
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5___default()(this, result);
|
|
247
265
|
};
|
|
248
266
|
}
|
|
267
|
+
|
|
249
268
|
function _isNativeReflectConstruct() {
|
|
250
269
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
251
270
|
if (Reflect.construct.sham) return false;
|
|
252
271
|
if (typeof Proxy === "function") return true;
|
|
272
|
+
|
|
253
273
|
try {
|
|
254
274
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
255
275
|
return true;
|
|
@@ -261,9 +281,10 @@ function _isNativeReflectConstruct() {
|
|
|
261
281
|
|
|
262
282
|
|
|
263
283
|
|
|
284
|
+
|
|
285
|
+
|
|
264
286
|
var b64EncodeUnicode = function b64EncodeUnicode(str) {
|
|
265
|
-
return (
|
|
266
|
-
// first we use encodeURIComponent to get percent-encoded UTF-8,
|
|
287
|
+
return (// first we use encodeURIComponent to get percent-encoded UTF-8,
|
|
267
288
|
// then we convert the percent encodings into raw bytes which
|
|
268
289
|
// can be fed into btoa.
|
|
269
290
|
btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
|
|
@@ -272,31 +293,35 @@ var b64EncodeUnicode = function b64EncodeUnicode(str) {
|
|
|
272
293
|
);
|
|
273
294
|
};
|
|
274
295
|
var KEY = '__icons__';
|
|
275
|
-
|
|
276
296
|
/**
|
|
277
297
|
* a local icon provider
|
|
278
298
|
*/
|
|
299
|
+
|
|
279
300
|
var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
280
301
|
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(LocalIconProvider, _Provider);
|
|
302
|
+
|
|
281
303
|
var _super = _createSuper(LocalIconProvider);
|
|
304
|
+
|
|
282
305
|
function LocalIconProvider() {
|
|
283
306
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, LocalIconProvider);
|
|
307
|
+
|
|
284
308
|
return _super.call(this);
|
|
285
309
|
}
|
|
286
|
-
|
|
287
310
|
/**
|
|
288
311
|
* return provider type
|
|
289
312
|
* @return {String} 'local'
|
|
290
313
|
*/
|
|
314
|
+
|
|
315
|
+
|
|
291
316
|
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3___default()(LocalIconProvider, [{
|
|
292
317
|
key: "getType",
|
|
293
318
|
value: function getType() {
|
|
294
319
|
return 'local';
|
|
295
320
|
}
|
|
296
|
-
|
|
297
321
|
/**
|
|
298
322
|
* upload one new icon
|
|
299
323
|
*/
|
|
324
|
+
|
|
300
325
|
}, {
|
|
301
326
|
key: "upload",
|
|
302
327
|
value: function () {
|
|
@@ -308,27 +333,33 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
308
333
|
case 0:
|
|
309
334
|
_context.next = 2;
|
|
310
335
|
return fetch(dataURI);
|
|
336
|
+
|
|
311
337
|
case 2:
|
|
312
338
|
response = _context.sent;
|
|
313
339
|
_context.next = 5;
|
|
314
340
|
return response.text();
|
|
341
|
+
|
|
315
342
|
case 5:
|
|
316
343
|
text = _context.sent;
|
|
317
344
|
parser = new DOMParser();
|
|
318
345
|
xmlDoc = parser.parseFromString(text, 'text/xml');
|
|
319
346
|
svg = xmlDoc.getElementsByTagName('svg')[0];
|
|
347
|
+
|
|
320
348
|
if (svg.getAttribute('viewBox')) {
|
|
321
349
|
_context.next = 11;
|
|
322
350
|
break;
|
|
323
351
|
}
|
|
352
|
+
|
|
324
353
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_9__["_"])('Please upload a valid svg with viewBox attribute.'));
|
|
354
|
+
|
|
325
355
|
case 11:
|
|
326
356
|
// reset svg attributes
|
|
327
|
-
svg.setAttribute('preserveAspectRatio', 'none');
|
|
328
|
-
|
|
357
|
+
svg.setAttribute('preserveAspectRatio', 'none'); // convert back to dataURI
|
|
358
|
+
|
|
329
359
|
serializer = new XMLSerializer();
|
|
330
360
|
svgStr = b64EncodeUnicode(serializer.serializeToString(svg));
|
|
331
361
|
iconDataURI = "data:image/svg+xml;base64,".concat(svgStr); // save to localStorage
|
|
362
|
+
|
|
332
363
|
_context.prev = 15;
|
|
333
364
|
icon = {
|
|
334
365
|
dataURI: iconDataURI,
|
|
@@ -339,10 +370,12 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
339
370
|
icons = _objectSpread(_objectSpread({}, icons), {}, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, id, icon));
|
|
340
371
|
localStorage.setItem(KEY, JSON.stringify(icons));
|
|
341
372
|
return _context.abrupt("return", id);
|
|
373
|
+
|
|
342
374
|
case 24:
|
|
343
375
|
_context.prev = 24;
|
|
344
376
|
_context.t0 = _context["catch"](15);
|
|
345
377
|
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
|
+
|
|
346
379
|
case 27:
|
|
347
380
|
case "end":
|
|
348
381
|
return _context.stop();
|
|
@@ -350,41 +383,47 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
350
383
|
}
|
|
351
384
|
}, _callee, null, [[15, 24]]);
|
|
352
385
|
}));
|
|
386
|
+
|
|
353
387
|
function upload(_x, _x2) {
|
|
354
388
|
return _upload.apply(this, arguments);
|
|
355
389
|
}
|
|
390
|
+
|
|
356
391
|
return upload;
|
|
357
392
|
}()
|
|
358
393
|
/**
|
|
359
394
|
* get one icon by icon id
|
|
360
395
|
*/
|
|
396
|
+
|
|
361
397
|
}, {
|
|
362
398
|
key: "getById",
|
|
363
399
|
value: function getById(id) {
|
|
364
400
|
var icons = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
401
|
+
|
|
365
402
|
if (icons[id]) {
|
|
366
403
|
return icons[id];
|
|
367
404
|
}
|
|
405
|
+
|
|
368
406
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_9__["_"])('The icon is not found.'));
|
|
369
407
|
}
|
|
370
|
-
|
|
371
408
|
/**
|
|
372
409
|
* get all icon ids
|
|
373
410
|
* @params options
|
|
374
411
|
* @params options.meta a list of meta data attribute that would be returned with each id
|
|
375
412
|
* @params options.search a search string to filter the returned icons
|
|
376
413
|
*/
|
|
414
|
+
|
|
377
415
|
}, {
|
|
378
416
|
key: "listIds",
|
|
379
417
|
value: function listIds(_ref) {
|
|
380
418
|
var _ref$offset = _ref.offset,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
419
|
+
offset = _ref$offset === void 0 ? 0 : _ref$offset,
|
|
420
|
+
_ref$count = _ref.count,
|
|
421
|
+
count = _ref$count === void 0 ? 100 : _ref$count,
|
|
422
|
+
_ref$meta = _ref.meta,
|
|
423
|
+
meta = _ref$meta === void 0 ? [] : _ref$meta,
|
|
424
|
+
_ref$search = _ref.search,
|
|
425
|
+
search = _ref$search === void 0 ? null : _ref$search;
|
|
426
|
+
|
|
388
427
|
try {
|
|
389
428
|
var icons = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
390
429
|
var results = [];
|
|
@@ -392,12 +431,13 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
392
431
|
var icon = {
|
|
393
432
|
id: id
|
|
394
433
|
};
|
|
395
|
-
var iconMeta = icons[id].metaData || {};
|
|
396
|
-
|
|
434
|
+
var iconMeta = icons[id].metaData || {}; // If search is a valid string, return the icon with matched meta data
|
|
435
|
+
|
|
397
436
|
var isSearchedIcon = search != null && Object.keys(iconMeta).some(function (attr) {
|
|
398
437
|
var iconMetaValue = iconMeta[attr].toLowerCase();
|
|
399
438
|
return iconMetaValue.indexOf(search.toLowerCase()) > -1;
|
|
400
439
|
});
|
|
440
|
+
|
|
401
441
|
if (search == null || isSearchedIcon) {
|
|
402
442
|
if (meta && meta.length) {
|
|
403
443
|
icon.metaData = {};
|
|
@@ -407,6 +447,7 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
407
447
|
}
|
|
408
448
|
});
|
|
409
449
|
}
|
|
450
|
+
|
|
410
451
|
results.push(icon);
|
|
411
452
|
}
|
|
412
453
|
});
|
|
@@ -415,10 +456,10 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
415
456
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_9__["_"])('The icon ids cannot be listed.'));
|
|
416
457
|
}
|
|
417
458
|
}
|
|
418
|
-
|
|
419
459
|
/**
|
|
420
460
|
* delete an icon by icon id
|
|
421
461
|
*/
|
|
462
|
+
|
|
422
463
|
}, {
|
|
423
464
|
key: "deleteById",
|
|
424
465
|
value: function deleteById(id) {
|
|
@@ -433,8 +474,10 @@ var LocalIconProvider = /*#__PURE__*/function (_Provider) {
|
|
|
433
474
|
}
|
|
434
475
|
}
|
|
435
476
|
}]);
|
|
477
|
+
|
|
436
478
|
return LocalIconProvider;
|
|
437
479
|
}(_splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_10___default.a);
|
|
480
|
+
|
|
438
481
|
/* harmony default export */ __webpack_exports__["default"] = (LocalIconProvider);
|
|
439
482
|
|
|
440
483
|
/***/ })
|
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","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;;;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;;Q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AAO,CAAC,UAAAI,IAAI,EAAI;gBACjB,IAAIH,QAAQ,CAACG,IAAI,CAAC,IAAI,IAAI,EAAE;kBACxBvD,IAAI,CAACT,QAAQ,CAACgE,IAAI,CAAC,GAAGH,QAAQ,CAACG,IAAI,CAAC;gBACxC;cACJ,CAAC,CAAC;YACN;YAEAR,OAAO,CAACa,IAAI,CAAC5D,IAAI,CAAC;UACtB;QACJ,CAAC,CAAC;QAEN,OAAO+C,OAAO;MAClB,CAAC,CAAC,OAAOc,KAAK,EAAE;QACZ,MAAM,IAAI/C,KAAK,CAACC,+DAAC,CAAC,gCAAgC,CAAC,CAAC;MACxD;IACJ;;IAEA;AACJ;AACA;EAFI;IAAAjC,GAAA;IAAAC,KAAA,EAGA,SAAA+E,WAAW7D,EAAE,EAAE;MACX,IAAI;QACA,IAAMD,IAAI,GAAG,IAAI,CAACoC,OAAO,CAACnC,EAAE,CAAC;QAC7B,IAAMC,KAAK,GAAGkB,IAAI,CAACC,KAAK,CAACC,YAAY,CAACC,OAAO,CAAClD,GAAG,CAAC,CAAC;QACnD,OAAO6B,KAAK,CAACD,EAAE,CAAC;QAChBqB,YAAY,CAACI,OAAO,CAACrD,GAAG,EAAE+C,IAAI,CAACO,SAAS,CAACzB,KAAK,CAAC,CAAC;QAChD,OAAOF,IAAI;MACf,CAAC,CAAC,OAAO6D,KAAK,EAAE;QACZ,MAAM,IAAI/C,KAAK,CAACC,+DAAC,CAAC,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":""}
|
|
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;;;;;;AC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ocalIconProvider.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,45 +195,65 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
|
|
198
|
+
|
|
198
199
|
function ownKeys(object, enumerableOnly) {
|
|
199
200
|
var keys = Object.keys(object);
|
|
201
|
+
|
|
200
202
|
if (Object.getOwnPropertySymbols) {
|
|
201
203
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
202
|
-
enumerableOnly
|
|
204
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
203
205
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
204
|
-
})
|
|
206
|
+
});
|
|
207
|
+
keys.push.apply(keys, symbols);
|
|
205
208
|
}
|
|
209
|
+
|
|
206
210
|
return keys;
|
|
207
211
|
}
|
|
212
|
+
|
|
208
213
|
function _objectSpread(target) {
|
|
209
214
|
for (var i = 1; i < arguments.length; i++) {
|
|
210
|
-
var source =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
216
|
+
|
|
217
|
+
if (i % 2) {
|
|
218
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
219
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
|
|
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
|
+
}
|
|
216
228
|
}
|
|
229
|
+
|
|
217
230
|
return target;
|
|
218
231
|
}
|
|
232
|
+
|
|
219
233
|
function _createSuper(Derived) {
|
|
220
234
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
235
|
+
|
|
221
236
|
return function _createSuperInternal() {
|
|
222
237
|
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(Derived),
|
|
223
|
-
|
|
238
|
+
result;
|
|
239
|
+
|
|
224
240
|
if (hasNativeReflectConstruct) {
|
|
225
241
|
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(this).constructor;
|
|
242
|
+
|
|
226
243
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
227
244
|
} else {
|
|
228
245
|
result = Super.apply(this, arguments);
|
|
229
246
|
}
|
|
247
|
+
|
|
230
248
|
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, result);
|
|
231
249
|
};
|
|
232
250
|
}
|
|
251
|
+
|
|
233
252
|
function _isNativeReflectConstruct() {
|
|
234
253
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
235
254
|
if (Reflect.construct.sham) return false;
|
|
236
255
|
if (typeof Proxy === "function") return true;
|
|
256
|
+
|
|
237
257
|
try {
|
|
238
258
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
239
259
|
return true;
|
|
@@ -245,31 +265,37 @@ function _isNativeReflectConstruct() {
|
|
|
245
265
|
|
|
246
266
|
|
|
247
267
|
|
|
248
|
-
var KEY = '__images__';
|
|
249
268
|
|
|
269
|
+
|
|
270
|
+
var KEY = '__images__';
|
|
250
271
|
/**
|
|
251
272
|
* a pure frontend local image provider
|
|
252
273
|
*/
|
|
274
|
+
|
|
253
275
|
var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
254
276
|
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default()(LocalImageProvider, _Provider);
|
|
277
|
+
|
|
255
278
|
var _super = _createSuper(LocalImageProvider);
|
|
279
|
+
|
|
256
280
|
function LocalImageProvider() {
|
|
257
281
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, LocalImageProvider);
|
|
282
|
+
|
|
258
283
|
return _super.call(this);
|
|
259
284
|
}
|
|
260
|
-
|
|
261
285
|
/**
|
|
262
286
|
* return provider type
|
|
263
287
|
*/
|
|
288
|
+
|
|
289
|
+
|
|
264
290
|
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(LocalImageProvider, [{
|
|
265
291
|
key: "getType",
|
|
266
292
|
value: function getType() {
|
|
267
293
|
return 'local';
|
|
268
294
|
}
|
|
269
|
-
|
|
270
295
|
/**
|
|
271
296
|
* add a new image
|
|
272
297
|
*/
|
|
298
|
+
|
|
273
299
|
}, {
|
|
274
300
|
key: "upload",
|
|
275
301
|
value: function upload(dataURI, metaData) {
|
|
@@ -287,29 +313,32 @@ var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
|
287
313
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_7__["_"])('The image cannot be uploaded. Please check whether your localStorage is full.'));
|
|
288
314
|
}
|
|
289
315
|
}
|
|
290
|
-
|
|
291
316
|
/**
|
|
292
317
|
* get image by imageID
|
|
293
318
|
*/
|
|
319
|
+
|
|
294
320
|
}, {
|
|
295
321
|
key: "getById",
|
|
296
322
|
value: function getById(imageID) {
|
|
297
323
|
var images = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
298
324
|
var imageObject = images[imageID];
|
|
325
|
+
|
|
299
326
|
if (imageObject) {
|
|
300
327
|
return imageObject;
|
|
301
328
|
}
|
|
329
|
+
|
|
302
330
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_7__["_"])('The image is not found.'));
|
|
303
331
|
}
|
|
304
|
-
|
|
305
332
|
/**
|
|
306
333
|
* get all imageIDs
|
|
307
334
|
*/
|
|
335
|
+
|
|
308
336
|
}, {
|
|
309
337
|
key: "listIds",
|
|
310
338
|
value: function listIds(_ref) {
|
|
311
339
|
var offset = _ref.offset,
|
|
312
|
-
|
|
340
|
+
count = _ref.count;
|
|
341
|
+
|
|
313
342
|
try {
|
|
314
343
|
var images = JSON.parse(localStorage.getItem(KEY) || '{}');
|
|
315
344
|
var imageIDS = Object.keys(images);
|
|
@@ -318,10 +347,10 @@ var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
|
318
347
|
throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_7__["_"])('The image ids cannot be listed.'));
|
|
319
348
|
}
|
|
320
349
|
}
|
|
321
|
-
|
|
322
350
|
/**
|
|
323
351
|
* delete an image by dataID
|
|
324
352
|
*/
|
|
353
|
+
|
|
325
354
|
}, {
|
|
326
355
|
key: "deleteById",
|
|
327
356
|
value: function deleteById(imageID) {
|
|
@@ -336,8 +365,10 @@ var LocalImageProvider = /*#__PURE__*/function (_Provider) {
|
|
|
336
365
|
}
|
|
337
366
|
}
|
|
338
367
|
}]);
|
|
368
|
+
|
|
339
369
|
return LocalImageProvider;
|
|
340
370
|
}(_splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_8___default.a);
|
|
371
|
+
|
|
341
372
|
/* harmony default export */ __webpack_exports__["default"] = (LocalImageProvider);
|
|
342
373
|
|
|
343
374
|
/***/ })
|
|
@@ -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","id","uuid","imageObject","dataURI","metaData","images","JSON","localStorage","_","offset","count","imageIDS","Object","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,kE;;;;;;ACAA,+D;;;;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AeD,CAAf;AACA,YAAMK,QAAQ,GAAGC,MAAM,CAANA,KAAjB,MAAiBA,CAAjB;AACA,eAAOD,QAAQ,CAARA,cAAP,KAAOA,CAAP;AAHJ,QAIE,cAAc;AACZ,cAAM,UAAUH,+DAAC,CAAjB,iCAAiB,CAAX,CAAN;AACH;AACJ;AAED;AACJ;AACA;;;;WACI,6BAAoB;AAChB,UAAI;AACA,YAAMN,WAAW,GAAG,aAApB,OAAoB,CAApB;AACA,YAAMG,MAAM,GAAGC,IAAI,CAAJA,MAAWC,YAAY,CAAZA,QAA1B,GAA0BA,CAAXD,CAAf;AACA,eAAOD,MAAM,CAAb,OAAa,CAAb;AACAE,oBAAY,CAAZA,aAA0BD,IAAI,CAAJA,UAA1BC,MAA0BD,CAA1BC;AACA;AALJ,QAME,cAAc;AACZ,cAAM,UAAUC,+DAAC,CAAjB,8BAAiB,CAAX,CAAN;AACH;AACJ;;;;EApE4BK,6E;;AAuEjC,mF","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,11 +102,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
102
102
|
value: true
|
|
103
103
|
});
|
|
104
104
|
exports.testTileConfig = exports.MapContextConsumer = exports.MapContextProvider = void 0;
|
|
105
|
+
|
|
105
106
|
var React = __webpack_require__(7);
|
|
107
|
+
|
|
106
108
|
var MapContext = React.createContext({
|
|
107
109
|
defaultTileConfig: []
|
|
108
110
|
});
|
|
109
|
-
MapContext.displayName = "data-splunk-visualization-version-MapContext-".concat("
|
|
111
|
+
MapContext.displayName = "data-splunk-visualization-version-MapContext-".concat("26.1.0 - fc8bf8d77");
|
|
110
112
|
exports.MapContextProvider = MapContext.Provider;
|
|
111
113
|
exports.MapContextConsumer = MapContext.Consumer;
|
|
112
114
|
exports.default = MapContext;
|