@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.
- package/core/esm/dev.js +172 -112
- package/core/esm/dev.js.map +1 -1
- package/core/esm/index.js +4 -4
- package/core/esm/index.js.map +1 -1
- package/core/package.json +2 -2
- package/dist/stardust.dev.js +173 -117
- package/dist/stardust.dev.js.map +1 -1
- package/dist/stardust.js +10 -10
- package/dist/stardust.js.map +1 -1
- package/package.json +12 -12
- package/types/index.d.ts +10 -10
package/core/esm/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @nebula.js/stardust v5.0.0-alpha.
|
|
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
|
*/
|
|
@@ -282,8 +282,9 @@ var runtime = {exports: {}};
|
|
|
282
282
|
throw arg;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
// Be forgiving, per
|
|
286
|
-
// https://
|
|
285
|
+
// Be forgiving, per GeneratorResume behavior specified since ES2015:
|
|
286
|
+
// ES2015 spec, step 3: https://262.ecma-international.org/6.0/#sec-generatorresume
|
|
287
|
+
// Latest spec, step 2: https://tc39.es/ecma262/#sec-generatorresume
|
|
287
288
|
return doneResult();
|
|
288
289
|
}
|
|
289
290
|
context.method = method;
|
|
@@ -343,7 +344,7 @@ var runtime = {exports: {}};
|
|
|
343
344
|
var method = delegate.iterator[methodName];
|
|
344
345
|
if (method === undefined$1) {
|
|
345
346
|
// A .throw or .return when the delegate iterator has no .throw
|
|
346
|
-
// method, or a missing .next
|
|
347
|
+
// method, or a missing .next method, always terminate the
|
|
347
348
|
// yield* loop.
|
|
348
349
|
context.delegate = null;
|
|
349
350
|
|
|
@@ -482,7 +483,7 @@ var runtime = {exports: {}};
|
|
|
482
483
|
};
|
|
483
484
|
};
|
|
484
485
|
function values(iterable) {
|
|
485
|
-
if (iterable
|
|
486
|
+
if (iterable != null) {
|
|
486
487
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
487
488
|
if (iteratorMethod) {
|
|
488
489
|
return iteratorMethod.call(iterable);
|
|
@@ -2819,7 +2820,7 @@ var extend$1 = function extend() {
|
|
|
2819
2820
|
|
|
2820
2821
|
var extend$2 = /*@__PURE__*/getDefaultExportFromCjs(extend$1);
|
|
2821
2822
|
|
|
2822
|
-
var fontSize = "
|
|
2823
|
+
var fontSize = "12px";
|
|
2823
2824
|
var fontFamily = "'Source Sans Pro', 'Arial', 'sans-serif'";
|
|
2824
2825
|
var backgroundColor$1 = "transparent";
|
|
2825
2826
|
var dataColors = {
|
|
@@ -4073,7 +4074,6 @@ function useEventCallback(fn) {
|
|
|
4073
4074
|
});
|
|
4074
4075
|
return React.useRef((...args) =>
|
|
4075
4076
|
// @ts-expect-error hide `this`
|
|
4076
|
-
// tslint:disable-next-line:ban-comma-operator
|
|
4077
4077
|
(0, ref.current)(...args)).current;
|
|
4078
4078
|
}
|
|
4079
4079
|
|
|
@@ -4325,6 +4325,7 @@ var ClassNameGenerator$1 = ClassNameGenerator;
|
|
|
4325
4325
|
|
|
4326
4326
|
// If GlobalStateSlot is changed, GLOBAL_STATE_CLASSES in
|
|
4327
4327
|
// \packages\api-docs-builder\utils\parseSlotsAndClasses.ts must be updated accordingly.
|
|
4328
|
+
|
|
4328
4329
|
const globalStateClassesMapping = {
|
|
4329
4330
|
active: 'active',
|
|
4330
4331
|
checked: 'checked',
|
|
@@ -5668,7 +5669,7 @@ function StyledEngineProvider(props) {
|
|
|
5668
5669
|
}
|
|
5669
5670
|
|
|
5670
5671
|
/**
|
|
5671
|
-
* @mui/styled-engine v5.
|
|
5672
|
+
* @mui/styled-engine v5.15.0
|
|
5672
5673
|
*
|
|
5673
5674
|
* @license MIT
|
|
5674
5675
|
* This source code is licensed under the MIT license found in the
|
|
@@ -5747,7 +5748,6 @@ function createBreakpoints(breakpoints) {
|
|
|
5747
5748
|
// desktop
|
|
5748
5749
|
xl: 1536 // large screen
|
|
5749
5750
|
},
|
|
5750
|
-
|
|
5751
5751
|
unit = 'px',
|
|
5752
5752
|
step = 5
|
|
5753
5753
|
} = breakpoints,
|
|
@@ -5822,7 +5822,6 @@ const values = {
|
|
|
5822
5822
|
// desktop
|
|
5823
5823
|
xl: 1536 // large screen
|
|
5824
5824
|
};
|
|
5825
|
-
|
|
5826
5825
|
const defaultBreakpoints = {
|
|
5827
5826
|
// Sorted ASC by size. That's important.
|
|
5828
5827
|
// It can't be configured as it's used statically for propTypes.
|
|
@@ -6069,8 +6068,6 @@ padding.filterProps = paddingKeys;
|
|
|
6069
6068
|
|
|
6070
6069
|
// The different signatures imply different meaning for their arguments that can't be expressed structurally.
|
|
6071
6070
|
// We express the difference with variable names.
|
|
6072
|
-
/* tslint:disable:unified-signatures */
|
|
6073
|
-
/* tslint:enable:unified-signatures */
|
|
6074
6071
|
|
|
6075
6072
|
function createSpacing(spacingInput = 8) {
|
|
6076
6073
|
// Already transformed.
|
|
@@ -6672,7 +6669,6 @@ function unstable_createStyleFunctionSx() {
|
|
|
6672
6669
|
if (!sx) {
|
|
6673
6670
|
return null; // Emotion & styled-components will neglect null
|
|
6674
6671
|
}
|
|
6675
|
-
|
|
6676
6672
|
const config = (_theme$unstable_sxCon = theme.unstable_sxConfig) != null ? _theme$unstable_sxCon : defaultSxConfig$1;
|
|
6677
6673
|
|
|
6678
6674
|
/*
|
|
@@ -7250,7 +7246,6 @@ function getLuminance(color) {
|
|
|
7250
7246
|
if (color.type !== 'color') {
|
|
7251
7247
|
val /= 255; // normalized
|
|
7252
7248
|
}
|
|
7253
|
-
|
|
7254
7249
|
return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
|
|
7255
7250
|
});
|
|
7256
7251
|
|
|
@@ -8530,7 +8525,7 @@ function create$3(definition) {
|
|
|
8530
8525
|
return cache[key];
|
|
8531
8526
|
}
|
|
8532
8527
|
|
|
8533
|
-
const NEBULA_VERSION_HASH = "
|
|
8528
|
+
const NEBULA_VERSION_HASH = "5ec7" ;
|
|
8534
8529
|
ClassNameGenerator$1.configure(componentName => {
|
|
8535
8530
|
return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
|
|
8536
8531
|
});
|
|
@@ -8762,7 +8757,7 @@ function boot(_ref2) {
|
|
|
8762
8757
|
const appRef = React__default.createRef();
|
|
8763
8758
|
const element = document.createElement('div');
|
|
8764
8759
|
element.style.display = 'none';
|
|
8765
|
-
element.setAttribute('data-nebulajs-version', "5.0.0-alpha.
|
|
8760
|
+
element.setAttribute('data-nebulajs-version', "5.0.0-alpha.1" );
|
|
8766
8761
|
element.setAttribute('data-app-id', app.id);
|
|
8767
8762
|
document.body.appendChild(element);
|
|
8768
8763
|
if (context) {
|
|
@@ -14866,6 +14861,7 @@ const StyledOutlinedInput = styled$1(OutlinedInput, {
|
|
|
14866
14861
|
fontSize: 14,
|
|
14867
14862
|
borderRadius: 0,
|
|
14868
14863
|
backgroundColor: styles.search.backgroundColor,
|
|
14864
|
+
backdropFilter: styles.background.backgroundImage ? styles.search.backdropFilter : undefined,
|
|
14869
14865
|
paddingLeft: "".concat(CELL_PADDING_LEFT, "px"),
|
|
14870
14866
|
flexDirection: isRtl ? 'row-reverse' : 'row',
|
|
14871
14867
|
'& fieldset': {
|
|
@@ -14873,6 +14869,9 @@ const StyledOutlinedInput = styled$1(OutlinedInput, {
|
|
|
14873
14869
|
borderWidth: '1px 0 1px 0',
|
|
14874
14870
|
borderRadius: 0
|
|
14875
14871
|
},
|
|
14872
|
+
'&.Mui-focused fieldset': {
|
|
14873
|
+
borderColor: "".concat(styles.search.highlightBorderColor, " !important")
|
|
14874
|
+
},
|
|
14876
14875
|
'& .MuiInputBase-root': _objectSpread2({}, styles.search),
|
|
14877
14876
|
'& *': {
|
|
14878
14877
|
color: styles.search.color
|
|
@@ -14880,9 +14879,6 @@ const StyledOutlinedInput = styled$1(OutlinedInput, {
|
|
|
14880
14879
|
'& input': {
|
|
14881
14880
|
color: styles.search.color,
|
|
14882
14881
|
textAlign: isRtl ? 'right' : 'left'
|
|
14883
|
-
},
|
|
14884
|
-
'&.Mui-focused fieldset.OutlinedInput-notchedOutline': {
|
|
14885
|
-
borderColor: "".concat(styles.search.highlightBorderColor, " !important")
|
|
14886
14882
|
}
|
|
14887
14883
|
}, denseProps);
|
|
14888
14884
|
});
|
|
@@ -17332,7 +17328,7 @@ function resolveBgImage(bgComp, app) {
|
|
|
17332
17328
|
function resolveBgColor(comp, theme, objectType) {
|
|
17333
17329
|
const bgColor = comp === null || comp === void 0 ? void 0 : comp.bgColor;
|
|
17334
17330
|
if (bgColor && theme) {
|
|
17335
|
-
if (bgColor.useExpression) {
|
|
17331
|
+
if (bgColor.useExpression || bgColor.useColorExpression) {
|
|
17336
17332
|
return theme.validateColor(bgColor.colorExpression);
|
|
17337
17333
|
}
|
|
17338
17334
|
}
|
|
@@ -17427,24 +17423,25 @@ function getOverridesAsObject() {
|
|
|
17427
17423
|
return overrides;
|
|
17428
17424
|
}
|
|
17429
17425
|
function getSelectionColors(_ref) {
|
|
17430
|
-
var _overrides$theme, _theme$palette, _overrides$theme$cont, _overrides$theme2, _overrides$selections,
|
|
17426
|
+
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;
|
|
17431
17427
|
let {
|
|
17428
|
+
getColorPickerColor,
|
|
17432
17429
|
theme,
|
|
17433
17430
|
getListboxStyle,
|
|
17434
17431
|
overrides,
|
|
17435
17432
|
checkboxes
|
|
17436
17433
|
} = _ref;
|
|
17437
|
-
const componentContentTextColor = (_overrides$theme = overrides.theme) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.content) === null || _overrides$theme === void 0
|
|
17438
|
-
const desiredTextColor = componentContentTextColor || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
|
|
17434
|
+
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;
|
|
17435
|
+
const desiredTextColor = getColorPickerColor(componentContentTextColor) || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
|
|
17439
17436
|
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);
|
|
17440
17437
|
|
|
17441
17438
|
// Background colors
|
|
17442
17439
|
const selectionColors = ((_overrides$selections = overrides.selections) === null || _overrides$selections === void 0 ? void 0 : _overrides$selections.colors) || {};
|
|
17443
|
-
const selected = (
|
|
17444
|
-
const alternative = (
|
|
17445
|
-
const excluded = (
|
|
17446
|
-
const selectedExcluded = (
|
|
17447
|
-
const possible = (
|
|
17440
|
+
const selected = getColorPickerColor(selectionColors.selected) || ((_theme$palette2 = theme.palette) === null || _theme$palette2 === void 0 ? void 0 : _theme$palette2.selected.main) || '#009845';
|
|
17441
|
+
const alternative = getColorPickerColor(selectionColors.alternative) || ((_theme$palette3 = theme.palette) === null || _theme$palette3 === void 0 ? void 0 : _theme$palette3.selected.alternative) || '#E4E4E4';
|
|
17442
|
+
const excluded = getColorPickerColor(selectionColors.excluded) || ((_theme$palette4 = theme.palette) === null || _theme$palette4 === void 0 ? void 0 : _theme$palette4.selected.excluded) || '#A9A9A9';
|
|
17443
|
+
const selectedExcluded = getColorPickerColor(selectionColors.selectedExcluded) || ((_theme$palette5 = theme.palette) === null || _theme$palette5 === void 0 ? void 0 : _theme$palette5.selected.selectedExcluded) || '#A9A9A9';
|
|
17444
|
+
const possible = getColorPickerColor(selectionColors.possible) || getListboxStyle('', 'backgroundColor') || ((_theme$palette6 = theme.palette) === null || _theme$palette6 === void 0 ? void 0 : _theme$palette6.selected.possible) || '#FFFFFF';
|
|
17448
17445
|
|
|
17449
17446
|
// Font colors
|
|
17450
17447
|
let selectedContrast = desiredTextColor || ((_theme$palette7 = theme.palette) === null || _theme$palette7 === void 0 ? void 0 : _theme$palette7.selected.selectedContrastText);
|
|
@@ -17488,8 +17485,7 @@ function getBackgroundColor(_ref2) {
|
|
|
17488
17485
|
bgColor
|
|
17489
17486
|
}, themeApi, 'listBox');
|
|
17490
17487
|
} else {
|
|
17491
|
-
|
|
17492
|
-
color = (_themeApi$getColorPic = themeApi.getColorPickerColor(bgColor, true)) === null || _themeApi$getColorPic === void 0 ? void 0 : _themeApi$getColorPic.color;
|
|
17488
|
+
color = themeApi.getColorPickerColor(bgColor === null || bgColor === void 0 ? void 0 : bgColor.color, false);
|
|
17493
17489
|
}
|
|
17494
17490
|
return color;
|
|
17495
17491
|
}
|
|
@@ -17509,14 +17505,16 @@ function getStyles(_ref3) {
|
|
|
17509
17505
|
} = _ref3;
|
|
17510
17506
|
const overrides = getOverridesAsObject(components);
|
|
17511
17507
|
const getListboxStyle = (path, prop) => themeApi.getStyle('object.listBox', path, prop);
|
|
17508
|
+
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;
|
|
17512
17509
|
const selections = getSelectionColors({
|
|
17510
|
+
getColorPickerColor,
|
|
17513
17511
|
theme,
|
|
17514
17512
|
getListboxStyle,
|
|
17515
17513
|
overrides,
|
|
17516
17514
|
checkboxes
|
|
17517
17515
|
});
|
|
17518
17516
|
const themeOverrides = overrides.theme || {};
|
|
17519
|
-
const headerColor = ((_themeOverrides$heade = themeOverrides.header) === null || _themeOverrides$heade === void 0
|
|
17517
|
+
const headerColor = getColorPickerColor((_themeOverrides$heade = themeOverrides.header) === null || _themeOverrides$heade === void 0 ? void 0 : _themeOverrides$heade.fontColor) || getListboxStyle('title.main', 'color');
|
|
17520
17518
|
const bgComponentColor = getBackgroundColor({
|
|
17521
17519
|
themeApi,
|
|
17522
17520
|
themeOverrides
|
|
@@ -17559,8 +17557,9 @@ function getStyles(_ref3) {
|
|
|
17559
17557
|
search: {
|
|
17560
17558
|
color: searchColor,
|
|
17561
17559
|
borderColor: theme.palette.divider,
|
|
17562
|
-
highlightBorderColor: theme.palette.
|
|
17563
|
-
backgroundColor: searchBgColor
|
|
17560
|
+
highlightBorderColor: theme.palette.custom.focusBorder,
|
|
17561
|
+
backgroundColor: searchBgColor,
|
|
17562
|
+
backdropFilter: 'blur(8px)'
|
|
17564
17563
|
},
|
|
17565
17564
|
selections
|
|
17566
17565
|
};
|
|
@@ -19240,7 +19239,7 @@ function getContainerPadding(_ref) {
|
|
|
19240
19239
|
}
|
|
19241
19240
|
containerPadding = layoutOrder === 'row' ? "".concat(paddingY, " 4px") : "".concat(paddingY, " 6px ").concat(paddingY, " 4px");
|
|
19242
19241
|
} else {
|
|
19243
|
-
containerPadding = undefined;
|
|
19242
|
+
containerPadding = undefined;
|
|
19244
19243
|
}
|
|
19245
19244
|
return containerPadding;
|
|
19246
19245
|
}
|
|
@@ -26506,6 +26505,7 @@ try {
|
|
|
26506
26505
|
|
|
26507
26506
|
// A linked list to keep track of recently-used-ness
|
|
26508
26507
|
const Yallist = yallist;
|
|
26508
|
+
|
|
26509
26509
|
const MAX = Symbol('max');
|
|
26510
26510
|
const LENGTH = Symbol('length');
|
|
26511
26511
|
const LENGTH_CALCULATOR = Symbol('lengthCalculator');
|
|
@@ -26516,6 +26516,7 @@ const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
|
|
|
26516
26516
|
const LRU_LIST = Symbol('lruList');
|
|
26517
26517
|
const CACHE = Symbol('cache');
|
|
26518
26518
|
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
|
|
26519
|
+
|
|
26519
26520
|
const naiveLength = () => 1;
|
|
26520
26521
|
|
|
26521
26522
|
// lruList is a yallist where the head is the youngest
|
|
@@ -26527,18 +26528,23 @@ const naiveLength = () => 1;
|
|
|
26527
26528
|
// cache is a Map (or PseudoMap) that matches the keys to
|
|
26528
26529
|
// the Yallist.Node object.
|
|
26529
26530
|
class LRUCache {
|
|
26530
|
-
constructor(options) {
|
|
26531
|
-
if (typeof options === 'number')
|
|
26532
|
-
max: options
|
|
26533
|
-
|
|
26534
|
-
if (!options)
|
|
26535
|
-
|
|
26531
|
+
constructor (options) {
|
|
26532
|
+
if (typeof options === 'number')
|
|
26533
|
+
options = { max: options };
|
|
26534
|
+
|
|
26535
|
+
if (!options)
|
|
26536
|
+
options = {};
|
|
26537
|
+
|
|
26538
|
+
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
|
26539
|
+
throw new TypeError('max must be a non-negative number')
|
|
26536
26540
|
// Kind of weird to have a default max of Infinity, but oh well.
|
|
26537
26541
|
this[MAX] = options.max || Infinity;
|
|
26542
|
+
|
|
26538
26543
|
const lc = options.length || naiveLength;
|
|
26539
|
-
this[LENGTH_CALCULATOR] = typeof lc !== 'function' ? naiveLength : lc;
|
|
26544
|
+
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
|
|
26540
26545
|
this[ALLOW_STALE] = options.stale || false;
|
|
26541
|
-
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
26546
|
+
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
26547
|
+
throw new TypeError('maxAge must be a number')
|
|
26542
26548
|
this[MAX_AGE] = options.maxAge || 0;
|
|
26543
26549
|
this[DISPOSE] = options.dispose;
|
|
26544
26550
|
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
|
@@ -26547,32 +26553,40 @@ class LRUCache {
|
|
|
26547
26553
|
}
|
|
26548
26554
|
|
|
26549
26555
|
// resize the cache when the max changes.
|
|
26550
|
-
set max(mL) {
|
|
26551
|
-
if (typeof mL !== 'number' || mL < 0)
|
|
26556
|
+
set max (mL) {
|
|
26557
|
+
if (typeof mL !== 'number' || mL < 0)
|
|
26558
|
+
throw new TypeError('max must be a non-negative number')
|
|
26559
|
+
|
|
26552
26560
|
this[MAX] = mL || Infinity;
|
|
26553
26561
|
trim(this);
|
|
26554
26562
|
}
|
|
26555
|
-
get max() {
|
|
26556
|
-
return this[MAX]
|
|
26563
|
+
get max () {
|
|
26564
|
+
return this[MAX]
|
|
26557
26565
|
}
|
|
26558
|
-
|
|
26566
|
+
|
|
26567
|
+
set allowStale (allowStale) {
|
|
26559
26568
|
this[ALLOW_STALE] = !!allowStale;
|
|
26560
26569
|
}
|
|
26561
|
-
get allowStale() {
|
|
26562
|
-
return this[ALLOW_STALE]
|
|
26570
|
+
get allowStale () {
|
|
26571
|
+
return this[ALLOW_STALE]
|
|
26563
26572
|
}
|
|
26564
|
-
|
|
26565
|
-
|
|
26573
|
+
|
|
26574
|
+
set maxAge (mA) {
|
|
26575
|
+
if (typeof mA !== 'number')
|
|
26576
|
+
throw new TypeError('maxAge must be a non-negative number')
|
|
26577
|
+
|
|
26566
26578
|
this[MAX_AGE] = mA;
|
|
26567
26579
|
trim(this);
|
|
26568
26580
|
}
|
|
26569
|
-
get maxAge() {
|
|
26570
|
-
return this[MAX_AGE]
|
|
26581
|
+
get maxAge () {
|
|
26582
|
+
return this[MAX_AGE]
|
|
26571
26583
|
}
|
|
26572
26584
|
|
|
26573
26585
|
// resize the cache when the lengthCalculator changes.
|
|
26574
|
-
set lengthCalculator(lC) {
|
|
26575
|
-
if (typeof lC !== 'function')
|
|
26586
|
+
set lengthCalculator (lC) {
|
|
26587
|
+
if (typeof lC !== 'function')
|
|
26588
|
+
lC = naiveLength;
|
|
26589
|
+
|
|
26576
26590
|
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
26577
26591
|
this[LENGTH_CALCULATOR] = lC;
|
|
26578
26592
|
this[LENGTH] = 0;
|
|
@@ -26583,16 +26597,12 @@ class LRUCache {
|
|
|
26583
26597
|
}
|
|
26584
26598
|
trim(this);
|
|
26585
26599
|
}
|
|
26586
|
-
get lengthCalculator() {
|
|
26587
|
-
|
|
26588
|
-
}
|
|
26589
|
-
get
|
|
26590
|
-
|
|
26591
|
-
|
|
26592
|
-
get itemCount() {
|
|
26593
|
-
return this[LRU_LIST].length;
|
|
26594
|
-
}
|
|
26595
|
-
rforEach(fn, thisp) {
|
|
26600
|
+
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
|
26601
|
+
|
|
26602
|
+
get length () { return this[LENGTH] }
|
|
26603
|
+
get itemCount () { return this[LRU_LIST].length }
|
|
26604
|
+
|
|
26605
|
+
rforEach (fn, thisp) {
|
|
26596
26606
|
thisp = thisp || this;
|
|
26597
26607
|
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
|
26598
26608
|
const prev = walker.prev;
|
|
@@ -26600,7 +26610,8 @@ class LRUCache {
|
|
|
26600
26610
|
walker = prev;
|
|
26601
26611
|
}
|
|
26602
26612
|
}
|
|
26603
|
-
|
|
26613
|
+
|
|
26614
|
+
forEach (fn, thisp) {
|
|
26604
26615
|
thisp = thisp || this;
|
|
26605
26616
|
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
|
26606
26617
|
const next = walker.next;
|
|
@@ -26608,48 +26619,65 @@ class LRUCache {
|
|
|
26608
26619
|
walker = next;
|
|
26609
26620
|
}
|
|
26610
26621
|
}
|
|
26611
|
-
|
|
26612
|
-
|
|
26622
|
+
|
|
26623
|
+
keys () {
|
|
26624
|
+
return this[LRU_LIST].toArray().map(k => k.key)
|
|
26613
26625
|
}
|
|
26614
|
-
|
|
26615
|
-
|
|
26626
|
+
|
|
26627
|
+
values () {
|
|
26628
|
+
return this[LRU_LIST].toArray().map(k => k.value)
|
|
26616
26629
|
}
|
|
26617
|
-
|
|
26618
|
-
|
|
26630
|
+
|
|
26631
|
+
reset () {
|
|
26632
|
+
if (this[DISPOSE] &&
|
|
26633
|
+
this[LRU_LIST] &&
|
|
26634
|
+
this[LRU_LIST].length) {
|
|
26619
26635
|
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
|
|
26620
26636
|
}
|
|
26637
|
+
|
|
26621
26638
|
this[CACHE] = new Map(); // hash of items by key
|
|
26622
26639
|
this[LRU_LIST] = new Yallist(); // list of items in order of use recency
|
|
26623
26640
|
this[LENGTH] = 0; // length of items in the list
|
|
26624
26641
|
}
|
|
26625
|
-
|
|
26626
|
-
|
|
26627
|
-
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26642
|
+
|
|
26643
|
+
dump () {
|
|
26644
|
+
return this[LRU_LIST].map(hit =>
|
|
26645
|
+
isStale(this, hit) ? false : {
|
|
26646
|
+
k: hit.key,
|
|
26647
|
+
v: hit.value,
|
|
26648
|
+
e: hit.now + (hit.maxAge || 0)
|
|
26649
|
+
}).toArray().filter(h => h)
|
|
26631
26650
|
}
|
|
26632
|
-
|
|
26633
|
-
|
|
26651
|
+
|
|
26652
|
+
dumpLru () {
|
|
26653
|
+
return this[LRU_LIST]
|
|
26634
26654
|
}
|
|
26635
|
-
|
|
26655
|
+
|
|
26656
|
+
set (key, value, maxAge) {
|
|
26636
26657
|
maxAge = maxAge || this[MAX_AGE];
|
|
26637
|
-
|
|
26658
|
+
|
|
26659
|
+
if (maxAge && typeof maxAge !== 'number')
|
|
26660
|
+
throw new TypeError('maxAge must be a number')
|
|
26661
|
+
|
|
26638
26662
|
const now = maxAge ? Date.now() : 0;
|
|
26639
26663
|
const len = this[LENGTH_CALCULATOR](value, key);
|
|
26664
|
+
|
|
26640
26665
|
if (this[CACHE].has(key)) {
|
|
26641
26666
|
if (len > this[MAX]) {
|
|
26642
26667
|
del(this, this[CACHE].get(key));
|
|
26643
|
-
return false
|
|
26668
|
+
return false
|
|
26644
26669
|
}
|
|
26670
|
+
|
|
26645
26671
|
const node = this[CACHE].get(key);
|
|
26646
26672
|
const item = node.value;
|
|
26647
26673
|
|
|
26648
26674
|
// dispose of the old one before overwriting
|
|
26649
26675
|
// split out into 2 ifs for better coverage tracking
|
|
26650
26676
|
if (this[DISPOSE]) {
|
|
26651
|
-
if (!this[NO_DISPOSE_ON_SET])
|
|
26677
|
+
if (!this[NO_DISPOSE_ON_SET])
|
|
26678
|
+
this[DISPOSE](key, item.value);
|
|
26652
26679
|
}
|
|
26680
|
+
|
|
26653
26681
|
item.now = now;
|
|
26654
26682
|
item.maxAge = maxAge;
|
|
26655
26683
|
item.value = value;
|
|
@@ -26657,44 +26685,57 @@ class LRUCache {
|
|
|
26657
26685
|
item.length = len;
|
|
26658
26686
|
this.get(key);
|
|
26659
26687
|
trim(this);
|
|
26660
|
-
return true
|
|
26688
|
+
return true
|
|
26661
26689
|
}
|
|
26690
|
+
|
|
26662
26691
|
const hit = new Entry(key, value, len, now, maxAge);
|
|
26663
26692
|
|
|
26664
26693
|
// oversized objects fall out of cache automatically.
|
|
26665
26694
|
if (hit.length > this[MAX]) {
|
|
26666
|
-
if (this[DISPOSE])
|
|
26667
|
-
|
|
26695
|
+
if (this[DISPOSE])
|
|
26696
|
+
this[DISPOSE](key, value);
|
|
26697
|
+
|
|
26698
|
+
return false
|
|
26668
26699
|
}
|
|
26700
|
+
|
|
26669
26701
|
this[LENGTH] += hit.length;
|
|
26670
26702
|
this[LRU_LIST].unshift(hit);
|
|
26671
26703
|
this[CACHE].set(key, this[LRU_LIST].head);
|
|
26672
26704
|
trim(this);
|
|
26673
|
-
return true
|
|
26705
|
+
return true
|
|
26674
26706
|
}
|
|
26675
|
-
|
|
26676
|
-
|
|
26707
|
+
|
|
26708
|
+
has (key) {
|
|
26709
|
+
if (!this[CACHE].has(key)) return false
|
|
26677
26710
|
const hit = this[CACHE].get(key).value;
|
|
26678
|
-
return !isStale(this, hit)
|
|
26711
|
+
return !isStale(this, hit)
|
|
26679
26712
|
}
|
|
26680
|
-
|
|
26681
|
-
|
|
26713
|
+
|
|
26714
|
+
get (key) {
|
|
26715
|
+
return get(this, key, true)
|
|
26682
26716
|
}
|
|
26683
|
-
|
|
26684
|
-
|
|
26717
|
+
|
|
26718
|
+
peek (key) {
|
|
26719
|
+
return get(this, key, false)
|
|
26685
26720
|
}
|
|
26686
|
-
|
|
26721
|
+
|
|
26722
|
+
pop () {
|
|
26687
26723
|
const node = this[LRU_LIST].tail;
|
|
26688
|
-
if (!node)
|
|
26724
|
+
if (!node)
|
|
26725
|
+
return null
|
|
26726
|
+
|
|
26689
26727
|
del(this, node);
|
|
26690
|
-
return node.value
|
|
26728
|
+
return node.value
|
|
26691
26729
|
}
|
|
26692
|
-
|
|
26730
|
+
|
|
26731
|
+
del (key) {
|
|
26693
26732
|
del(this, this[CACHE].get(key));
|
|
26694
26733
|
}
|
|
26695
|
-
|
|
26734
|
+
|
|
26735
|
+
load (arr) {
|
|
26696
26736
|
// reset the cache
|
|
26697
26737
|
this.reset();
|
|
26738
|
+
|
|
26698
26739
|
const now = Date.now();
|
|
26699
26740
|
// A previous serialized cache has the most recent items first
|
|
26700
26741
|
for (let l = arr.length - 1; l >= 0; l--) {
|
|
@@ -26702,7 +26743,8 @@ class LRUCache {
|
|
|
26702
26743
|
const expiresAt = hit.e || 0;
|
|
26703
26744
|
if (expiresAt === 0)
|
|
26704
26745
|
// the item was created without expiration in a non aged cache
|
|
26705
|
-
this.set(hit.k, hit.v);
|
|
26746
|
+
this.set(hit.k, hit.v);
|
|
26747
|
+
else {
|
|
26706
26748
|
const maxAge = expiresAt - now;
|
|
26707
26749
|
// dont add already expired items
|
|
26708
26750
|
if (maxAge > 0) {
|
|
@@ -26711,34 +26753,44 @@ class LRUCache {
|
|
|
26711
26753
|
}
|
|
26712
26754
|
}
|
|
26713
26755
|
}
|
|
26714
|
-
|
|
26756
|
+
|
|
26757
|
+
prune () {
|
|
26715
26758
|
this[CACHE].forEach((value, key) => get(this, key, false));
|
|
26716
26759
|
}
|
|
26717
26760
|
}
|
|
26761
|
+
|
|
26718
26762
|
const get = (self, key, doUse) => {
|
|
26719
26763
|
const node = self[CACHE].get(key);
|
|
26720
26764
|
if (node) {
|
|
26721
26765
|
const hit = node.value;
|
|
26722
26766
|
if (isStale(self, hit)) {
|
|
26723
26767
|
del(self, node);
|
|
26724
|
-
if (!self[ALLOW_STALE])
|
|
26768
|
+
if (!self[ALLOW_STALE])
|
|
26769
|
+
return undefined
|
|
26725
26770
|
} else {
|
|
26726
26771
|
if (doUse) {
|
|
26727
|
-
if (self[UPDATE_AGE_ON_GET])
|
|
26772
|
+
if (self[UPDATE_AGE_ON_GET])
|
|
26773
|
+
node.value.now = Date.now();
|
|
26728
26774
|
self[LRU_LIST].unshiftNode(node);
|
|
26729
26775
|
}
|
|
26730
26776
|
}
|
|
26731
|
-
return hit.value
|
|
26777
|
+
return hit.value
|
|
26732
26778
|
}
|
|
26733
26779
|
};
|
|
26780
|
+
|
|
26734
26781
|
const isStale = (self, hit) => {
|
|
26735
|
-
if (!hit || !hit.maxAge && !self[MAX_AGE])
|
|
26782
|
+
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
|
26783
|
+
return false
|
|
26784
|
+
|
|
26736
26785
|
const diff = Date.now() - hit.now;
|
|
26737
|
-
return hit.maxAge ? diff > hit.maxAge
|
|
26786
|
+
return hit.maxAge ? diff > hit.maxAge
|
|
26787
|
+
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
|
26738
26788
|
};
|
|
26789
|
+
|
|
26739
26790
|
const trim = self => {
|
|
26740
26791
|
if (self[LENGTH] > self[MAX]) {
|
|
26741
|
-
for (let walker = self[LRU_LIST].tail;
|
|
26792
|
+
for (let walker = self[LRU_LIST].tail;
|
|
26793
|
+
self[LENGTH] > self[MAX] && walker !== null;) {
|
|
26742
26794
|
// We know that we're about to delete this one, and also
|
|
26743
26795
|
// what the next least recently used key will be, so just
|
|
26744
26796
|
// go ahead and set it now.
|
|
@@ -26748,17 +26800,21 @@ const trim = self => {
|
|
|
26748
26800
|
}
|
|
26749
26801
|
}
|
|
26750
26802
|
};
|
|
26803
|
+
|
|
26751
26804
|
const del = (self, node) => {
|
|
26752
26805
|
if (node) {
|
|
26753
26806
|
const hit = node.value;
|
|
26754
|
-
if (self[DISPOSE])
|
|
26807
|
+
if (self[DISPOSE])
|
|
26808
|
+
self[DISPOSE](hit.key, hit.value);
|
|
26809
|
+
|
|
26755
26810
|
self[LENGTH] -= hit.length;
|
|
26756
26811
|
self[CACHE].delete(hit.key);
|
|
26757
26812
|
self[LRU_LIST].removeNode(node);
|
|
26758
26813
|
}
|
|
26759
26814
|
};
|
|
26815
|
+
|
|
26760
26816
|
class Entry {
|
|
26761
|
-
constructor(key, value, length, now, maxAge) {
|
|
26817
|
+
constructor (key, value, length, now, maxAge) {
|
|
26762
26818
|
this.key = key;
|
|
26763
26819
|
this.value = value;
|
|
26764
26820
|
this.length = length;
|
|
@@ -26766,14 +26822,18 @@ class Entry {
|
|
|
26766
26822
|
this.maxAge = maxAge || 0;
|
|
26767
26823
|
}
|
|
26768
26824
|
}
|
|
26825
|
+
|
|
26769
26826
|
const forEachStep = (self, fn, node, thisp) => {
|
|
26770
26827
|
let hit = node.value;
|
|
26771
26828
|
if (isStale(self, hit)) {
|
|
26772
26829
|
del(self, node);
|
|
26773
|
-
if (!self[ALLOW_STALE])
|
|
26830
|
+
if (!self[ALLOW_STALE])
|
|
26831
|
+
hit = undefined;
|
|
26774
26832
|
}
|
|
26775
|
-
if (hit)
|
|
26833
|
+
if (hit)
|
|
26834
|
+
fn.call(thisp, hit.value, hit.key, self);
|
|
26776
26835
|
};
|
|
26836
|
+
|
|
26777
26837
|
var lruCache = LRUCache;
|
|
26778
26838
|
|
|
26779
26839
|
// parse out just the options we care about
|