@nebula.js/stardust 5.0.0-alpha.0 → 5.0.0-alpha.1

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v5.0.0-alpha.0
2
+ * @nebula.js/stardust v5.0.0-alpha.1
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -296,8 +296,9 @@
296
296
  throw arg;
297
297
  }
298
298
 
299
- // Be forgiving, per 25.3.3.3.3 of the spec:
300
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
299
+ // Be forgiving, per GeneratorResume behavior specified since ES2015:
300
+ // ES2015 spec, step 3: https://262.ecma-international.org/6.0/#sec-generatorresume
301
+ // Latest spec, step 2: https://tc39.es/ecma262/#sec-generatorresume
301
302
  return doneResult();
302
303
  }
303
304
  context.method = method;
@@ -357,7 +358,7 @@
357
358
  var method = delegate.iterator[methodName];
358
359
  if (method === undefined$1) {
359
360
  // A .throw or .return when the delegate iterator has no .throw
360
- // method, or a missing .next mehtod, always terminate the
361
+ // method, or a missing .next method, always terminate the
361
362
  // yield* loop.
362
363
  context.delegate = null;
363
364
 
@@ -496,7 +497,7 @@
496
497
  };
497
498
  };
498
499
  function values(iterable) {
499
- if (iterable || iterable === "") {
500
+ if (iterable != null) {
500
501
  var iteratorMethod = iterable[iteratorSymbol];
501
502
  if (iteratorMethod) {
502
503
  return iteratorMethod.call(iterable);
@@ -2876,7 +2877,7 @@
2876
2877
 
2877
2878
  var extend$2 = /*@__PURE__*/getDefaultExportFromCjs(extend$1);
2878
2879
 
2879
- var fontSize = "13px";
2880
+ var fontSize = "12px";
2880
2881
  var fontFamily = "'Source Sans Pro', 'Arial', 'sans-serif'";
2881
2882
  var backgroundColor$1 = "transparent";
2882
2883
  var dataColors = {
@@ -4540,7 +4541,6 @@
4540
4541
  });
4541
4542
  return reactExports.useRef((...args) =>
4542
4543
  // @ts-expect-error hide `this`
4543
- // tslint:disable-next-line:ban-comma-operator
4544
4544
  (0, ref.current)(...args)).current;
4545
4545
  }
4546
4546
 
@@ -4809,6 +4809,7 @@
4809
4809
 
4810
4810
  // If GlobalStateSlot is changed, GLOBAL_STATE_CLASSES in
4811
4811
  // \packages\api-docs-builder\utils\parseSlotsAndClasses.ts must be updated accordingly.
4812
+
4812
4813
  const globalStateClassesMapping = {
4813
4814
  active: 'active',
4814
4815
  checked: 'checked',
@@ -6950,7 +6951,7 @@
6950
6951
  }
6951
6952
 
6952
6953
  /**
6953
- * @mui/styled-engine v5.14.19
6954
+ * @mui/styled-engine v5.15.0
6954
6955
  *
6955
6956
  * @license MIT
6956
6957
  * This source code is licensed under the MIT license found in the
@@ -7029,7 +7030,6 @@
7029
7030
  // desktop
7030
7031
  xl: 1536 // large screen
7031
7032
  },
7032
-
7033
7033
  unit = 'px',
7034
7034
  step = 5
7035
7035
  } = breakpoints,
@@ -7104,7 +7104,6 @@
7104
7104
  // desktop
7105
7105
  xl: 1536 // large screen
7106
7106
  };
7107
-
7108
7107
  const defaultBreakpoints = {
7109
7108
  // Sorted ASC by size. That's important.
7110
7109
  // It can't be configured as it's used statically for propTypes.
@@ -7406,8 +7405,6 @@
7406
7405
 
7407
7406
  // The different signatures imply different meaning for their arguments that can't be expressed structurally.
7408
7407
  // We express the difference with variable names.
7409
- /* tslint:disable:unified-signatures */
7410
- /* tslint:enable:unified-signatures */
7411
7408
 
7412
7409
  function createSpacing(spacingInput = 8) {
7413
7410
  // Already transformed.
@@ -8009,7 +8006,6 @@
8009
8006
  if (!sx) {
8010
8007
  return null; // Emotion & styled-components will neglect null
8011
8008
  }
8012
-
8013
8009
  const config = (_theme$unstable_sxCon = theme.unstable_sxConfig) != null ? _theme$unstable_sxCon : defaultSxConfig$1;
8014
8010
 
8015
8011
  /*
@@ -8676,7 +8672,6 @@
8676
8672
  if (color.type !== 'color') {
8677
8673
  val /= 255; // normalized
8678
8674
  }
8679
-
8680
8675
  return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
8681
8676
  });
8682
8677
 
@@ -10939,7 +10934,6 @@
10939
10934
  '&::-moz-focus-inner': {
10940
10935
  borderStyle: 'none' // Remove Firefox dotted outline.
10941
10936
  },
10942
-
10943
10937
  [`&.${buttonBaseClasses$1.disabled}`]: {
10944
10938
  pointerEvents: 'none',
10945
10939
  // Disable link interactions
@@ -11106,7 +11100,7 @@
11106
11100
  });
11107
11101
  const handleKeyUp = useEventCallback(event => {
11108
11102
  // calling preventDefault in keyUp on a <button> will not dispatch a click event if Space is pressed
11109
- // https://codesandbox.io/s/button-keyup-preventdefault-dn7f0
11103
+ // https://codesandbox.io/p/sandbox/button-keyup-preventdefault-dn7f0
11110
11104
  if (focusRipple && event.key === ' ' && rippleRef.current && focusVisible && !event.defaultPrevented) {
11111
11105
  keydownRef.current = false;
11112
11106
  rippleRef.current.stop(event, () => {
@@ -11799,7 +11793,7 @@
11799
11793
  return cache[key];
11800
11794
  }
11801
11795
 
11802
- const NEBULA_VERSION_HASH = "117f" ;
11796
+ const NEBULA_VERSION_HASH = "5ec7" ;
11803
11797
  ClassNameGenerator$1.configure(componentName => {
11804
11798
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
11805
11799
  });
@@ -12031,7 +12025,7 @@
12031
12025
  const appRef = React.createRef();
12032
12026
  const element = document.createElement('div');
12033
12027
  element.style.display = 'none';
12034
- element.setAttribute('data-nebulajs-version', "5.0.0-alpha.0" );
12028
+ element.setAttribute('data-nebulajs-version', "5.0.0-alpha.1" );
12035
12029
  element.setAttribute('data-app-id', app.id);
12036
12030
  document.body.appendChild(element);
12037
12031
  if (context) {
@@ -16090,13 +16084,11 @@
16090
16084
  // IE11
16091
16085
  '&:focus::-ms-input-placeholder': placeholderVisible // Edge
16092
16086
  },
16093
-
16094
16087
  [`&.${inputBaseClasses$1.disabled}`]: {
16095
16088
  opacity: 1,
16096
16089
  // Reset iOS opacity
16097
16090
  WebkitTextFillColor: (theme.vars || theme).palette.text.disabled // Fix opacity Safari bug
16098
16091
  },
16099
-
16100
16092
  '&:-webkit-autofill': {
16101
16093
  animationDuration: '5000s',
16102
16094
  animationName: 'mui-auto-fill'
@@ -17197,7 +17189,6 @@
17197
17189
  })({
17198
17190
  display: 'block' // Keeps the progress centered
17199
17191
  });
17200
-
17201
17192
  const CircularProgressCircle = styled$1('circle', {
17202
17193
  name: 'MuiCircularProgress',
17203
17194
  slot: 'Circle',
@@ -26688,6 +26679,7 @@
26688
26679
  fontSize: 14,
26689
26680
  borderRadius: 0,
26690
26681
  backgroundColor: styles.search.backgroundColor,
26682
+ backdropFilter: styles.background.backgroundImage ? styles.search.backdropFilter : undefined,
26691
26683
  paddingLeft: "".concat(CELL_PADDING_LEFT, "px"),
26692
26684
  flexDirection: isRtl ? 'row-reverse' : 'row',
26693
26685
  '& fieldset': {
@@ -26695,6 +26687,9 @@
26695
26687
  borderWidth: '1px 0 1px 0',
26696
26688
  borderRadius: 0
26697
26689
  },
26690
+ '&.Mui-focused fieldset': {
26691
+ borderColor: "".concat(styles.search.highlightBorderColor, " !important")
26692
+ },
26698
26693
  '& .MuiInputBase-root': _objectSpread2({}, styles.search),
26699
26694
  '& *': {
26700
26695
  color: styles.search.color
@@ -26702,9 +26697,6 @@
26702
26697
  '& input': {
26703
26698
  color: styles.search.color,
26704
26699
  textAlign: isRtl ? 'right' : 'left'
26705
- },
26706
- '&.Mui-focused fieldset.OutlinedInput-notchedOutline': {
26707
- borderColor: "".concat(styles.search.highlightBorderColor, " !important")
26708
26700
  }
26709
26701
  }, denseProps);
26710
26702
  });
@@ -29154,7 +29146,7 @@
29154
29146
  function resolveBgColor(comp, theme, objectType) {
29155
29147
  const bgColor = comp === null || comp === void 0 ? void 0 : comp.bgColor;
29156
29148
  if (bgColor && theme) {
29157
- if (bgColor.useExpression) {
29149
+ if (bgColor.useExpression || bgColor.useColorExpression) {
29158
29150
  return theme.validateColor(bgColor.colorExpression);
29159
29151
  }
29160
29152
  }
@@ -29249,24 +29241,25 @@
29249
29241
  return overrides;
29250
29242
  }
29251
29243
  function getSelectionColors(_ref) {
29252
- var _overrides$theme, _theme$palette, _overrides$theme$cont, _overrides$theme2, _overrides$selections, _selectionColors$sele, _theme$palette2, _selectionColors$alte, _theme$palette3, _selectionColors$excl, _theme$palette4, _selectionColors$sele2, _theme$palette5, _selectionColors$poss, _theme$palette6, _theme$palette7, _theme$palette8, _theme$palette9, _theme$palette10, _theme$palette11;
29244
+ var _overrides$theme, _theme$palette, _overrides$theme$cont, _overrides$theme2, _overrides$selections, _theme$palette2, _theme$palette3, _theme$palette4, _theme$palette5, _theme$palette6, _theme$palette7, _theme$palette8, _theme$palette9, _theme$palette10, _theme$palette11;
29253
29245
  let {
29246
+ getColorPickerColor,
29254
29247
  theme,
29255
29248
  getListboxStyle,
29256
29249
  overrides,
29257
29250
  checkboxes
29258
29251
  } = _ref;
29259
- const componentContentTextColor = (_overrides$theme = overrides.theme) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.content) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.fontColor) === null || _overrides$theme === void 0 ? void 0 : _overrides$theme.color;
29260
- const desiredTextColor = componentContentTextColor || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
29252
+ const componentContentTextColor = (_overrides$theme = overrides.theme) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.content) === null || _overrides$theme === void 0 ? void 0 : _overrides$theme.fontColor;
29253
+ const desiredTextColor = getColorPickerColor(componentContentTextColor) || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
29261
29254
  const useContrastTextColor = !checkboxes && ((_overrides$theme$cont = (_overrides$theme2 = overrides.theme) === null || _overrides$theme2 === void 0 || (_overrides$theme2 = _overrides$theme2.content) === null || _overrides$theme2 === void 0 ? void 0 : _overrides$theme2.useContrastColor) !== null && _overrides$theme$cont !== void 0 ? _overrides$theme$cont : true);
29262
29255
 
29263
29256
  // Background colors
29264
29257
  const selectionColors = ((_overrides$selections = overrides.selections) === null || _overrides$selections === void 0 ? void 0 : _overrides$selections.colors) || {};
29265
- const selected = ((_selectionColors$sele = selectionColors.selected) === null || _selectionColors$sele === void 0 ? void 0 : _selectionColors$sele.color) || ((_theme$palette2 = theme.palette) === null || _theme$palette2 === void 0 ? void 0 : _theme$palette2.selected.main) || '#009845';
29266
- const alternative = ((_selectionColors$alte = selectionColors.alternative) === null || _selectionColors$alte === void 0 ? void 0 : _selectionColors$alte.color) || ((_theme$palette3 = theme.palette) === null || _theme$palette3 === void 0 ? void 0 : _theme$palette3.selected.alternative) || '#E4E4E4';
29267
- const excluded = ((_selectionColors$excl = selectionColors.excluded) === null || _selectionColors$excl === void 0 ? void 0 : _selectionColors$excl.color) || ((_theme$palette4 = theme.palette) === null || _theme$palette4 === void 0 ? void 0 : _theme$palette4.selected.excluded) || '#A9A9A9';
29268
- const selectedExcluded = ((_selectionColors$sele2 = selectionColors.selectedExcluded) === null || _selectionColors$sele2 === void 0 ? void 0 : _selectionColors$sele2.color) || ((_theme$palette5 = theme.palette) === null || _theme$palette5 === void 0 ? void 0 : _theme$palette5.selected.selectedExcluded) || '#A9A9A9';
29269
- const possible = ((_selectionColors$poss = selectionColors.possible) === null || _selectionColors$poss === void 0 ? void 0 : _selectionColors$poss.color) || getListboxStyle('', 'backgroundColor') || ((_theme$palette6 = theme.palette) === null || _theme$palette6 === void 0 ? void 0 : _theme$palette6.selected.possible) || '#FFFFFF';
29258
+ const selected = getColorPickerColor(selectionColors.selected) || ((_theme$palette2 = theme.palette) === null || _theme$palette2 === void 0 ? void 0 : _theme$palette2.selected.main) || '#009845';
29259
+ const alternative = getColorPickerColor(selectionColors.alternative) || ((_theme$palette3 = theme.palette) === null || _theme$palette3 === void 0 ? void 0 : _theme$palette3.selected.alternative) || '#E4E4E4';
29260
+ const excluded = getColorPickerColor(selectionColors.excluded) || ((_theme$palette4 = theme.palette) === null || _theme$palette4 === void 0 ? void 0 : _theme$palette4.selected.excluded) || '#A9A9A9';
29261
+ const selectedExcluded = getColorPickerColor(selectionColors.selectedExcluded) || ((_theme$palette5 = theme.palette) === null || _theme$palette5 === void 0 ? void 0 : _theme$palette5.selected.selectedExcluded) || '#A9A9A9';
29262
+ const possible = getColorPickerColor(selectionColors.possible) || getListboxStyle('', 'backgroundColor') || ((_theme$palette6 = theme.palette) === null || _theme$palette6 === void 0 ? void 0 : _theme$palette6.selected.possible) || '#FFFFFF';
29270
29263
 
29271
29264
  // Font colors
29272
29265
  let selectedContrast = desiredTextColor || ((_theme$palette7 = theme.palette) === null || _theme$palette7 === void 0 ? void 0 : _theme$palette7.selected.selectedContrastText);
@@ -29310,8 +29303,7 @@
29310
29303
  bgColor
29311
29304
  }, themeApi, 'listBox');
29312
29305
  } else {
29313
- var _themeApi$getColorPic;
29314
- color = (_themeApi$getColorPic = themeApi.getColorPickerColor(bgColor, true)) === null || _themeApi$getColorPic === void 0 ? void 0 : _themeApi$getColorPic.color;
29306
+ color = themeApi.getColorPickerColor(bgColor === null || bgColor === void 0 ? void 0 : bgColor.color, false);
29315
29307
  }
29316
29308
  return color;
29317
29309
  }
@@ -29331,14 +29323,16 @@
29331
29323
  } = _ref3;
29332
29324
  const overrides = getOverridesAsObject(components);
29333
29325
  const getListboxStyle = (path, prop) => themeApi.getStyle('object.listBox', path, prop);
29326
+ const getColorPickerColor = c => (c === null || c === void 0 ? void 0 : c.index) > 0 || c !== null && c !== void 0 && c.color ? themeApi.getColorPickerColor(c, false) : undefined;
29334
29327
  const selections = getSelectionColors({
29328
+ getColorPickerColor,
29335
29329
  theme,
29336
29330
  getListboxStyle,
29337
29331
  overrides,
29338
29332
  checkboxes
29339
29333
  });
29340
29334
  const themeOverrides = overrides.theme || {};
29341
- const headerColor = ((_themeOverrides$heade = themeOverrides.header) === null || _themeOverrides$heade === void 0 || (_themeOverrides$heade = _themeOverrides$heade.fontColor) === null || _themeOverrides$heade === void 0 ? void 0 : _themeOverrides$heade.color) || getListboxStyle('title.main', 'color');
29335
+ const headerColor = getColorPickerColor((_themeOverrides$heade = themeOverrides.header) === null || _themeOverrides$heade === void 0 ? void 0 : _themeOverrides$heade.fontColor) || getListboxStyle('title.main', 'color');
29342
29336
  const bgComponentColor = getBackgroundColor({
29343
29337
  themeApi,
29344
29338
  themeOverrides
@@ -29381,8 +29375,9 @@
29381
29375
  search: {
29382
29376
  color: searchColor,
29383
29377
  borderColor: theme.palette.divider,
29384
- highlightBorderColor: theme.palette.primary.main,
29385
- backgroundColor: searchBgColor
29378
+ highlightBorderColor: theme.palette.custom.focusBorder,
29379
+ backgroundColor: searchBgColor,
29380
+ backdropFilter: 'blur(8px)'
29386
29381
  },
29387
29382
  selections
29388
29383
  };
@@ -31062,7 +31057,7 @@
31062
31057
  }
31063
31058
  containerPadding = layoutOrder === 'row' ? "".concat(paddingY, " 4px") : "".concat(paddingY, " 6px ").concat(paddingY, " 4px");
31064
31059
  } else {
31065
- containerPadding = undefined; // to prevent overriding any default padding
31060
+ containerPadding = undefined;
31066
31061
  }
31067
31062
  return containerPadding;
31068
31063
  }
@@ -38328,6 +38323,7 @@
38328
38323
 
38329
38324
  // A linked list to keep track of recently-used-ness
38330
38325
  const Yallist = yallist;
38326
+
38331
38327
  const MAX = Symbol('max');
38332
38328
  const LENGTH = Symbol('length');
38333
38329
  const LENGTH_CALCULATOR = Symbol('lengthCalculator');
@@ -38338,6 +38334,7 @@
38338
38334
  const LRU_LIST = Symbol('lruList');
38339
38335
  const CACHE = Symbol('cache');
38340
38336
  const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
38337
+
38341
38338
  const naiveLength = () => 1;
38342
38339
 
38343
38340
  // lruList is a yallist where the head is the youngest
@@ -38349,18 +38346,23 @@
38349
38346
  // cache is a Map (or PseudoMap) that matches the keys to
38350
38347
  // the Yallist.Node object.
38351
38348
  class LRUCache {
38352
- constructor(options) {
38353
- if (typeof options === 'number') options = {
38354
- max: options
38355
- };
38356
- if (!options) options = {};
38357
- if (options.max && (typeof options.max !== 'number' || options.max < 0)) throw new TypeError('max must be a non-negative number');
38349
+ constructor (options) {
38350
+ if (typeof options === 'number')
38351
+ options = { max: options };
38352
+
38353
+ if (!options)
38354
+ options = {};
38355
+
38356
+ if (options.max && (typeof options.max !== 'number' || options.max < 0))
38357
+ throw new TypeError('max must be a non-negative number')
38358
38358
  // Kind of weird to have a default max of Infinity, but oh well.
38359
38359
  this[MAX] = options.max || Infinity;
38360
+
38360
38361
  const lc = options.length || naiveLength;
38361
- this[LENGTH_CALCULATOR] = typeof lc !== 'function' ? naiveLength : lc;
38362
+ this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
38362
38363
  this[ALLOW_STALE] = options.stale || false;
38363
- if (options.maxAge && typeof options.maxAge !== 'number') throw new TypeError('maxAge must be a number');
38364
+ if (options.maxAge && typeof options.maxAge !== 'number')
38365
+ throw new TypeError('maxAge must be a number')
38364
38366
  this[MAX_AGE] = options.maxAge || 0;
38365
38367
  this[DISPOSE] = options.dispose;
38366
38368
  this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
@@ -38369,32 +38371,40 @@
38369
38371
  }
38370
38372
 
38371
38373
  // resize the cache when the max changes.
38372
- set max(mL) {
38373
- if (typeof mL !== 'number' || mL < 0) throw new TypeError('max must be a non-negative number');
38374
+ set max (mL) {
38375
+ if (typeof mL !== 'number' || mL < 0)
38376
+ throw new TypeError('max must be a non-negative number')
38377
+
38374
38378
  this[MAX] = mL || Infinity;
38375
38379
  trim(this);
38376
38380
  }
38377
- get max() {
38378
- return this[MAX];
38381
+ get max () {
38382
+ return this[MAX]
38379
38383
  }
38380
- set allowStale(allowStale) {
38384
+
38385
+ set allowStale (allowStale) {
38381
38386
  this[ALLOW_STALE] = !!allowStale;
38382
38387
  }
38383
- get allowStale() {
38384
- return this[ALLOW_STALE];
38388
+ get allowStale () {
38389
+ return this[ALLOW_STALE]
38385
38390
  }
38386
- set maxAge(mA) {
38387
- if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number');
38391
+
38392
+ set maxAge (mA) {
38393
+ if (typeof mA !== 'number')
38394
+ throw new TypeError('maxAge must be a non-negative number')
38395
+
38388
38396
  this[MAX_AGE] = mA;
38389
38397
  trim(this);
38390
38398
  }
38391
- get maxAge() {
38392
- return this[MAX_AGE];
38399
+ get maxAge () {
38400
+ return this[MAX_AGE]
38393
38401
  }
38394
38402
 
38395
38403
  // resize the cache when the lengthCalculator changes.
38396
- set lengthCalculator(lC) {
38397
- if (typeof lC !== 'function') lC = naiveLength;
38404
+ set lengthCalculator (lC) {
38405
+ if (typeof lC !== 'function')
38406
+ lC = naiveLength;
38407
+
38398
38408
  if (lC !== this[LENGTH_CALCULATOR]) {
38399
38409
  this[LENGTH_CALCULATOR] = lC;
38400
38410
  this[LENGTH] = 0;
@@ -38405,16 +38415,12 @@
38405
38415
  }
38406
38416
  trim(this);
38407
38417
  }
38408
- get lengthCalculator() {
38409
- return this[LENGTH_CALCULATOR];
38410
- }
38411
- get length() {
38412
- return this[LENGTH];
38413
- }
38414
- get itemCount() {
38415
- return this[LRU_LIST].length;
38416
- }
38417
- rforEach(fn, thisp) {
38418
+ get lengthCalculator () { return this[LENGTH_CALCULATOR] }
38419
+
38420
+ get length () { return this[LENGTH] }
38421
+ get itemCount () { return this[LRU_LIST].length }
38422
+
38423
+ rforEach (fn, thisp) {
38418
38424
  thisp = thisp || this;
38419
38425
  for (let walker = this[LRU_LIST].tail; walker !== null;) {
38420
38426
  const prev = walker.prev;
@@ -38422,7 +38428,8 @@
38422
38428
  walker = prev;
38423
38429
  }
38424
38430
  }
38425
- forEach(fn, thisp) {
38431
+
38432
+ forEach (fn, thisp) {
38426
38433
  thisp = thisp || this;
38427
38434
  for (let walker = this[LRU_LIST].head; walker !== null;) {
38428
38435
  const next = walker.next;
@@ -38430,48 +38437,65 @@
38430
38437
  walker = next;
38431
38438
  }
38432
38439
  }
38433
- keys() {
38434
- return this[LRU_LIST].toArray().map(k => k.key);
38440
+
38441
+ keys () {
38442
+ return this[LRU_LIST].toArray().map(k => k.key)
38435
38443
  }
38436
- values() {
38437
- return this[LRU_LIST].toArray().map(k => k.value);
38444
+
38445
+ values () {
38446
+ return this[LRU_LIST].toArray().map(k => k.value)
38438
38447
  }
38439
- reset() {
38440
- if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
38448
+
38449
+ reset () {
38450
+ if (this[DISPOSE] &&
38451
+ this[LRU_LIST] &&
38452
+ this[LRU_LIST].length) {
38441
38453
  this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
38442
38454
  }
38455
+
38443
38456
  this[CACHE] = new Map(); // hash of items by key
38444
38457
  this[LRU_LIST] = new Yallist(); // list of items in order of use recency
38445
38458
  this[LENGTH] = 0; // length of items in the list
38446
38459
  }
38447
- dump() {
38448
- return this[LRU_LIST].map(hit => isStale(this, hit) ? false : {
38449
- k: hit.key,
38450
- v: hit.value,
38451
- e: hit.now + (hit.maxAge || 0)
38452
- }).toArray().filter(h => h);
38460
+
38461
+ dump () {
38462
+ return this[LRU_LIST].map(hit =>
38463
+ isStale(this, hit) ? false : {
38464
+ k: hit.key,
38465
+ v: hit.value,
38466
+ e: hit.now + (hit.maxAge || 0)
38467
+ }).toArray().filter(h => h)
38453
38468
  }
38454
- dumpLru() {
38455
- return this[LRU_LIST];
38469
+
38470
+ dumpLru () {
38471
+ return this[LRU_LIST]
38456
38472
  }
38457
- set(key, value, maxAge) {
38473
+
38474
+ set (key, value, maxAge) {
38458
38475
  maxAge = maxAge || this[MAX_AGE];
38459
- if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number');
38476
+
38477
+ if (maxAge && typeof maxAge !== 'number')
38478
+ throw new TypeError('maxAge must be a number')
38479
+
38460
38480
  const now = maxAge ? Date.now() : 0;
38461
38481
  const len = this[LENGTH_CALCULATOR](value, key);
38482
+
38462
38483
  if (this[CACHE].has(key)) {
38463
38484
  if (len > this[MAX]) {
38464
38485
  del(this, this[CACHE].get(key));
38465
- return false;
38486
+ return false
38466
38487
  }
38488
+
38467
38489
  const node = this[CACHE].get(key);
38468
38490
  const item = node.value;
38469
38491
 
38470
38492
  // dispose of the old one before overwriting
38471
38493
  // split out into 2 ifs for better coverage tracking
38472
38494
  if (this[DISPOSE]) {
38473
- if (!this[NO_DISPOSE_ON_SET]) this[DISPOSE](key, item.value);
38495
+ if (!this[NO_DISPOSE_ON_SET])
38496
+ this[DISPOSE](key, item.value);
38474
38497
  }
38498
+
38475
38499
  item.now = now;
38476
38500
  item.maxAge = maxAge;
38477
38501
  item.value = value;
@@ -38479,44 +38503,57 @@
38479
38503
  item.length = len;
38480
38504
  this.get(key);
38481
38505
  trim(this);
38482
- return true;
38506
+ return true
38483
38507
  }
38508
+
38484
38509
  const hit = new Entry(key, value, len, now, maxAge);
38485
38510
 
38486
38511
  // oversized objects fall out of cache automatically.
38487
38512
  if (hit.length > this[MAX]) {
38488
- if (this[DISPOSE]) this[DISPOSE](key, value);
38489
- return false;
38513
+ if (this[DISPOSE])
38514
+ this[DISPOSE](key, value);
38515
+
38516
+ return false
38490
38517
  }
38518
+
38491
38519
  this[LENGTH] += hit.length;
38492
38520
  this[LRU_LIST].unshift(hit);
38493
38521
  this[CACHE].set(key, this[LRU_LIST].head);
38494
38522
  trim(this);
38495
- return true;
38523
+ return true
38496
38524
  }
38497
- has(key) {
38498
- if (!this[CACHE].has(key)) return false;
38525
+
38526
+ has (key) {
38527
+ if (!this[CACHE].has(key)) return false
38499
38528
  const hit = this[CACHE].get(key).value;
38500
- return !isStale(this, hit);
38529
+ return !isStale(this, hit)
38501
38530
  }
38502
- get(key) {
38503
- return get(this, key, true);
38531
+
38532
+ get (key) {
38533
+ return get(this, key, true)
38504
38534
  }
38505
- peek(key) {
38506
- return get(this, key, false);
38535
+
38536
+ peek (key) {
38537
+ return get(this, key, false)
38507
38538
  }
38508
- pop() {
38539
+
38540
+ pop () {
38509
38541
  const node = this[LRU_LIST].tail;
38510
- if (!node) return null;
38542
+ if (!node)
38543
+ return null
38544
+
38511
38545
  del(this, node);
38512
- return node.value;
38546
+ return node.value
38513
38547
  }
38514
- del(key) {
38548
+
38549
+ del (key) {
38515
38550
  del(this, this[CACHE].get(key));
38516
38551
  }
38517
- load(arr) {
38552
+
38553
+ load (arr) {
38518
38554
  // reset the cache
38519
38555
  this.reset();
38556
+
38520
38557
  const now = Date.now();
38521
38558
  // A previous serialized cache has the most recent items first
38522
38559
  for (let l = arr.length - 1; l >= 0; l--) {
@@ -38524,7 +38561,8 @@
38524
38561
  const expiresAt = hit.e || 0;
38525
38562
  if (expiresAt === 0)
38526
38563
  // the item was created without expiration in a non aged cache
38527
- this.set(hit.k, hit.v);else {
38564
+ this.set(hit.k, hit.v);
38565
+ else {
38528
38566
  const maxAge = expiresAt - now;
38529
38567
  // dont add already expired items
38530
38568
  if (maxAge > 0) {
@@ -38533,34 +38571,44 @@
38533
38571
  }
38534
38572
  }
38535
38573
  }
38536
- prune() {
38574
+
38575
+ prune () {
38537
38576
  this[CACHE].forEach((value, key) => get(this, key, false));
38538
38577
  }
38539
38578
  }
38579
+
38540
38580
  const get = (self, key, doUse) => {
38541
38581
  const node = self[CACHE].get(key);
38542
38582
  if (node) {
38543
38583
  const hit = node.value;
38544
38584
  if (isStale(self, hit)) {
38545
38585
  del(self, node);
38546
- if (!self[ALLOW_STALE]) return undefined;
38586
+ if (!self[ALLOW_STALE])
38587
+ return undefined
38547
38588
  } else {
38548
38589
  if (doUse) {
38549
- if (self[UPDATE_AGE_ON_GET]) node.value.now = Date.now();
38590
+ if (self[UPDATE_AGE_ON_GET])
38591
+ node.value.now = Date.now();
38550
38592
  self[LRU_LIST].unshiftNode(node);
38551
38593
  }
38552
38594
  }
38553
- return hit.value;
38595
+ return hit.value
38554
38596
  }
38555
38597
  };
38598
+
38556
38599
  const isStale = (self, hit) => {
38557
- if (!hit || !hit.maxAge && !self[MAX_AGE]) return false;
38600
+ if (!hit || (!hit.maxAge && !self[MAX_AGE]))
38601
+ return false
38602
+
38558
38603
  const diff = Date.now() - hit.now;
38559
- return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE];
38604
+ return hit.maxAge ? diff > hit.maxAge
38605
+ : self[MAX_AGE] && (diff > self[MAX_AGE])
38560
38606
  };
38607
+
38561
38608
  const trim = self => {
38562
38609
  if (self[LENGTH] > self[MAX]) {
38563
- for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
38610
+ for (let walker = self[LRU_LIST].tail;
38611
+ self[LENGTH] > self[MAX] && walker !== null;) {
38564
38612
  // We know that we're about to delete this one, and also
38565
38613
  // what the next least recently used key will be, so just
38566
38614
  // go ahead and set it now.
@@ -38570,17 +38618,21 @@
38570
38618
  }
38571
38619
  }
38572
38620
  };
38621
+
38573
38622
  const del = (self, node) => {
38574
38623
  if (node) {
38575
38624
  const hit = node.value;
38576
- if (self[DISPOSE]) self[DISPOSE](hit.key, hit.value);
38625
+ if (self[DISPOSE])
38626
+ self[DISPOSE](hit.key, hit.value);
38627
+
38577
38628
  self[LENGTH] -= hit.length;
38578
38629
  self[CACHE].delete(hit.key);
38579
38630
  self[LRU_LIST].removeNode(node);
38580
38631
  }
38581
38632
  };
38633
+
38582
38634
  class Entry {
38583
- constructor(key, value, length, now, maxAge) {
38635
+ constructor (key, value, length, now, maxAge) {
38584
38636
  this.key = key;
38585
38637
  this.value = value;
38586
38638
  this.length = length;
@@ -38588,14 +38640,18 @@
38588
38640
  this.maxAge = maxAge || 0;
38589
38641
  }
38590
38642
  }
38643
+
38591
38644
  const forEachStep = (self, fn, node, thisp) => {
38592
38645
  let hit = node.value;
38593
38646
  if (isStale(self, hit)) {
38594
38647
  del(self, node);
38595
- if (!self[ALLOW_STALE]) hit = undefined;
38648
+ if (!self[ALLOW_STALE])
38649
+ hit = undefined;
38596
38650
  }
38597
- if (hit) fn.call(thisp, hit.value, hit.key, self);
38651
+ if (hit)
38652
+ fn.call(thisp, hit.value, hit.key, self);
38598
38653
  };
38654
+
38599
38655
  var lruCache = LRUCache;
38600
38656
 
38601
38657
  // parse out just the options we care about