@vitessce/export-utils 3.5.6 → 3.5.7

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/dist/index.js CHANGED
@@ -1942,6 +1942,10 @@ class Bowser {
1942
1942
  return PLATFORMS_MAP;
1943
1943
  }
1944
1944
  }
1945
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1946
+ function getDefaultExportFromCjs(x) {
1947
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1948
+ }
1945
1949
  var lzString = { exports: {} };
1946
1950
  lzString.exports;
1947
1951
  (function(module) {
@@ -2400,6 +2404,258 @@ lzString.exports;
2400
2404
  }
2401
2405
  })(lzString);
2402
2406
  var lzStringExports = lzString.exports;
2407
+ var loglevel = { exports: {} };
2408
+ (function(module) {
2409
+ (function(root, definition) {
2410
+ if (module.exports) {
2411
+ module.exports = definition();
2412
+ } else {
2413
+ root.log = definition();
2414
+ }
2415
+ })(commonjsGlobal, function() {
2416
+ var noop = function() {
2417
+ };
2418
+ var undefinedType = "undefined";
2419
+ var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
2420
+ var logMethods = [
2421
+ "trace",
2422
+ "debug",
2423
+ "info",
2424
+ "warn",
2425
+ "error"
2426
+ ];
2427
+ var _loggersByName = {};
2428
+ var defaultLogger = null;
2429
+ function bindMethod(obj, methodName) {
2430
+ var method = obj[methodName];
2431
+ if (typeof method.bind === "function") {
2432
+ return method.bind(obj);
2433
+ } else {
2434
+ try {
2435
+ return Function.prototype.bind.call(method, obj);
2436
+ } catch (e) {
2437
+ return function() {
2438
+ return Function.prototype.apply.apply(method, [obj, arguments]);
2439
+ };
2440
+ }
2441
+ }
2442
+ }
2443
+ function traceForIE() {
2444
+ if (console.log) {
2445
+ if (console.log.apply) {
2446
+ console.log.apply(console, arguments);
2447
+ } else {
2448
+ Function.prototype.apply.apply(console.log, [console, arguments]);
2449
+ }
2450
+ }
2451
+ if (console.trace)
2452
+ console.trace();
2453
+ }
2454
+ function realMethod(methodName) {
2455
+ if (methodName === "debug") {
2456
+ methodName = "log";
2457
+ }
2458
+ if (typeof console === undefinedType) {
2459
+ return false;
2460
+ } else if (methodName === "trace" && isIE) {
2461
+ return traceForIE;
2462
+ } else if (console[methodName] !== void 0) {
2463
+ return bindMethod(console, methodName);
2464
+ } else if (console.log !== void 0) {
2465
+ return bindMethod(console, "log");
2466
+ } else {
2467
+ return noop;
2468
+ }
2469
+ }
2470
+ function replaceLoggingMethods() {
2471
+ var level = this.getLevel();
2472
+ for (var i = 0; i < logMethods.length; i++) {
2473
+ var methodName = logMethods[i];
2474
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
2475
+ }
2476
+ this.log = this.debug;
2477
+ if (typeof console === undefinedType && level < this.levels.SILENT) {
2478
+ return "No console available for logging";
2479
+ }
2480
+ }
2481
+ function enableLoggingWhenConsoleArrives(methodName) {
2482
+ return function() {
2483
+ if (typeof console !== undefinedType) {
2484
+ replaceLoggingMethods.call(this);
2485
+ this[methodName].apply(this, arguments);
2486
+ }
2487
+ };
2488
+ }
2489
+ function defaultMethodFactory(methodName, _level, _loggerName) {
2490
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
2491
+ }
2492
+ function Logger(name, factory) {
2493
+ var self2 = this;
2494
+ var inheritedLevel;
2495
+ var defaultLevel;
2496
+ var userLevel;
2497
+ var storageKey = "loglevel";
2498
+ if (typeof name === "string") {
2499
+ storageKey += ":" + name;
2500
+ } else if (typeof name === "symbol") {
2501
+ storageKey = void 0;
2502
+ }
2503
+ function persistLevelIfPossible(levelNum) {
2504
+ var levelName = (logMethods[levelNum] || "silent").toUpperCase();
2505
+ if (typeof window === undefinedType || !storageKey)
2506
+ return;
2507
+ try {
2508
+ window.localStorage[storageKey] = levelName;
2509
+ return;
2510
+ } catch (ignore) {
2511
+ }
2512
+ try {
2513
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
2514
+ } catch (ignore) {
2515
+ }
2516
+ }
2517
+ function getPersistedLevel() {
2518
+ var storedLevel;
2519
+ if (typeof window === undefinedType || !storageKey)
2520
+ return;
2521
+ try {
2522
+ storedLevel = window.localStorage[storageKey];
2523
+ } catch (ignore) {
2524
+ }
2525
+ if (typeof storedLevel === undefinedType) {
2526
+ try {
2527
+ var cookie = window.document.cookie;
2528
+ var cookieName = encodeURIComponent(storageKey);
2529
+ var location = cookie.indexOf(cookieName + "=");
2530
+ if (location !== -1) {
2531
+ storedLevel = /^([^;]+)/.exec(
2532
+ cookie.slice(location + cookieName.length + 1)
2533
+ )[1];
2534
+ }
2535
+ } catch (ignore) {
2536
+ }
2537
+ }
2538
+ if (self2.levels[storedLevel] === void 0) {
2539
+ storedLevel = void 0;
2540
+ }
2541
+ return storedLevel;
2542
+ }
2543
+ function clearPersistedLevel() {
2544
+ if (typeof window === undefinedType || !storageKey)
2545
+ return;
2546
+ try {
2547
+ window.localStorage.removeItem(storageKey);
2548
+ } catch (ignore) {
2549
+ }
2550
+ try {
2551
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
2552
+ } catch (ignore) {
2553
+ }
2554
+ }
2555
+ function normalizeLevel(input) {
2556
+ var level = input;
2557
+ if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
2558
+ level = self2.levels[level.toUpperCase()];
2559
+ }
2560
+ if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
2561
+ return level;
2562
+ } else {
2563
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
2564
+ }
2565
+ }
2566
+ self2.name = name;
2567
+ self2.levels = {
2568
+ "TRACE": 0,
2569
+ "DEBUG": 1,
2570
+ "INFO": 2,
2571
+ "WARN": 3,
2572
+ "ERROR": 4,
2573
+ "SILENT": 5
2574
+ };
2575
+ self2.methodFactory = factory || defaultMethodFactory;
2576
+ self2.getLevel = function() {
2577
+ if (userLevel != null) {
2578
+ return userLevel;
2579
+ } else if (defaultLevel != null) {
2580
+ return defaultLevel;
2581
+ } else {
2582
+ return inheritedLevel;
2583
+ }
2584
+ };
2585
+ self2.setLevel = function(level, persist) {
2586
+ userLevel = normalizeLevel(level);
2587
+ if (persist !== false) {
2588
+ persistLevelIfPossible(userLevel);
2589
+ }
2590
+ return replaceLoggingMethods.call(self2);
2591
+ };
2592
+ self2.setDefaultLevel = function(level) {
2593
+ defaultLevel = normalizeLevel(level);
2594
+ if (!getPersistedLevel()) {
2595
+ self2.setLevel(level, false);
2596
+ }
2597
+ };
2598
+ self2.resetLevel = function() {
2599
+ userLevel = null;
2600
+ clearPersistedLevel();
2601
+ replaceLoggingMethods.call(self2);
2602
+ };
2603
+ self2.enableAll = function(persist) {
2604
+ self2.setLevel(self2.levels.TRACE, persist);
2605
+ };
2606
+ self2.disableAll = function(persist) {
2607
+ self2.setLevel(self2.levels.SILENT, persist);
2608
+ };
2609
+ self2.rebuild = function() {
2610
+ if (defaultLogger !== self2) {
2611
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
2612
+ }
2613
+ replaceLoggingMethods.call(self2);
2614
+ if (defaultLogger === self2) {
2615
+ for (var childName in _loggersByName) {
2616
+ _loggersByName[childName].rebuild();
2617
+ }
2618
+ }
2619
+ };
2620
+ inheritedLevel = normalizeLevel(
2621
+ defaultLogger ? defaultLogger.getLevel() : "WARN"
2622
+ );
2623
+ var initialLevel = getPersistedLevel();
2624
+ if (initialLevel != null) {
2625
+ userLevel = normalizeLevel(initialLevel);
2626
+ }
2627
+ replaceLoggingMethods.call(self2);
2628
+ }
2629
+ defaultLogger = new Logger();
2630
+ defaultLogger.getLogger = function getLogger(name) {
2631
+ if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
2632
+ throw new TypeError("You must supply a name when creating a logger.");
2633
+ }
2634
+ var logger = _loggersByName[name];
2635
+ if (!logger) {
2636
+ logger = _loggersByName[name] = new Logger(
2637
+ name,
2638
+ defaultLogger.methodFactory
2639
+ );
2640
+ }
2641
+ return logger;
2642
+ };
2643
+ var _log = typeof window !== undefinedType ? window.log : void 0;
2644
+ defaultLogger.noConflict = function() {
2645
+ if (typeof window !== undefinedType && window.log === defaultLogger) {
2646
+ window.log = _log;
2647
+ }
2648
+ return defaultLogger;
2649
+ };
2650
+ defaultLogger.getLoggers = function getLoggers() {
2651
+ return _loggersByName;
2652
+ };
2653
+ defaultLogger["default"] = defaultLogger;
2654
+ return defaultLogger;
2655
+ });
2656
+ })(loglevel);
2657
+ var loglevelExports = loglevel.exports;
2658
+ const log = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
2403
2659
  const CURRENT_VERSION = "0.0.1";
2404
2660
  const VITESSCE_CONF_QUERY_STRING = "vitessce_conf";
2405
2661
  const VERSION_QUERY_STRING = "vitessce_conf_version";
@@ -2432,7 +2688,7 @@ function encodeConfInUrl({
2432
2688
  if (newParams.length > maxLength) {
2433
2689
  const willWorkOn = Object.entries(MAX_BROWSER_URL_LENGTHS).filter((entry) => entry[1] > newParams.length).map((entry) => entry[0]);
2434
2690
  const message = `Configuration is ${compressedConf.length} characters; max URL for ${browser} is ${maxLength}: it will work on ${willWorkOn.join(", ") || "no browser"}.`;
2435
- console.error(message);
2691
+ log.error(message);
2436
2692
  onOverMaximumUrlLength({ message, willWorkOn });
2437
2693
  }
2438
2694
  return newParams;
@@ -1 +1 @@
1
- {"version":3,"file":"export-utils.d.ts","sourceRoot":"","sources":["../src/export-utils.js"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH,mEAPG;IAAuB,IAAI,EAAnB,MAAM;IACW,sBAAsB;CAG/C,GAAU,MAAM,CAoBlB;AAED;;;;;;;GAOG;AACH,mDAJW,MAAM,GAEJ,MAAM,CAelB;AAxDD;IACE,0BAEC;IADC,aAAsB;CAEzB"}
1
+ {"version":3,"file":"export-utils.d.ts","sourceRoot":"","sources":["../src/export-utils.js"],"names":[],"mappings":"AA6BA;;;;;;;;;GASG;AACH,mEAPG;IAAuB,IAAI,EAAnB,MAAM;IACW,sBAAsB;CAG/C,GAAU,MAAM,CAoBlB;AAED;;;;;;;GAOG;AACH,mDAJW,MAAM,GAEJ,MAAM,CAelB;AAxDD;IACE,0BAEC;IADC,aAAsB;CAEzB"}
@@ -1,5 +1,6 @@
1
1
  import Bowser from 'bowser';
2
2
  import { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string';
3
+ import { log } from '@vitessce/globals';
3
4
  const CURRENT_VERSION = '0.0.1';
4
5
  const VITESSCE_CONF_QUERY_STRING = 'vitessce_conf';
5
6
  const VERSION_QUERY_STRING = 'vitessce_conf_version';
@@ -41,7 +42,7 @@ export function encodeConfInUrl({ conf, onOverMaximumUrlLength = () => { }, }) {
41
42
  .filter(entry => entry[1] > newParams.length)
42
43
  .map(entry => entry[0]);
43
44
  const message = `Configuration is ${compressedConf.length} characters; max URL for ${browser} is ${maxLength}: it will work on ${willWorkOn.join(', ') || 'no browser'}.`;
44
- console.error(message);
45
+ log.error(message);
45
46
  onOverMaximumUrlLength({ message, willWorkOn });
46
47
  }
47
48
  return newParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/export-utils",
3
- "version": "3.5.6",
3
+ "version": "3.5.7",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -17,7 +17,8 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "bowser": "^2.11.0",
20
- "lz-string": "^1.4.4"
20
+ "lz-string": "^1.4.4",
21
+ "@vitessce/globals": "3.5.7"
21
22
  },
22
23
  "scripts": {
23
24
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
@@ -1,5 +1,6 @@
1
1
  import Bowser from 'bowser';
2
2
  import { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string';
3
+ import { log } from '@vitessce/globals';
3
4
 
4
5
  const CURRENT_VERSION = '0.0.1';
5
6
  const VITESSCE_CONF_QUERY_STRING = 'vitessce_conf';
@@ -49,7 +50,7 @@ export function encodeConfInUrl({
49
50
  .filter(entry => entry[1] > newParams.length)
50
51
  .map(entry => entry[0]);
51
52
  const message = `Configuration is ${compressedConf.length} characters; max URL for ${browser} is ${maxLength}: it will work on ${willWorkOn.join(', ') || 'no browser'}.`;
52
- console.error(message);
53
+ log.error(message);
53
54
  onOverMaximumUrlLength({ message, willWorkOn });
54
55
  }
55
56
  return newParams;