@nebula.js/stardust 3.2.2 → 3.3.0-alpha.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/core/esm/dev.js +1943 -1425
- package/core/esm/dev.js.map +1 -1
- package/core/esm/index.js +6 -4
- package/core/esm/index.js.map +1 -1
- package/core/package.json +4 -4
- package/dist/stardust.dev.js +3654 -2200
- package/dist/stardust.dev.js.map +1 -1
- package/dist/stardust.js +16 -14
- package/dist/stardust.js.map +1 -1
- package/package.json +13 -13
- package/types/index.d.ts +11 -11
package/core/esm/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @nebula.js/stardust v3.
|
|
2
|
+
* @nebula.js/stardust v3.3.0-alpha.0
|
|
3
3
|
* Copyright (c) 2023 QlikTech International AB
|
|
4
4
|
* Released under the MIT license.
|
|
5
5
|
*/
|
|
@@ -3928,6 +3928,7 @@ const globalStateClassesMapping = {
|
|
|
3928
3928
|
checked: 'checked',
|
|
3929
3929
|
completed: 'completed',
|
|
3930
3930
|
disabled: 'disabled',
|
|
3931
|
+
readOnly: 'readOnly',
|
|
3931
3932
|
error: 'error',
|
|
3932
3933
|
expanded: 'expanded',
|
|
3933
3934
|
focused: 'focused',
|
|
@@ -5219,8 +5220,6 @@ var createCache = function createCache(options) {
|
|
|
5219
5220
|
return cache;
|
|
5220
5221
|
};
|
|
5221
5222
|
|
|
5222
|
-
var createCache$1 = createCache;
|
|
5223
|
-
|
|
5224
5223
|
var jsxRuntimeExports$1 = {};
|
|
5225
5224
|
var jsxRuntime = {
|
|
5226
5225
|
get exports(){ return jsxRuntimeExports$1; },
|
|
@@ -5265,23 +5264,28 @@ function requireJsxRuntime () {
|
|
|
5265
5264
|
|
|
5266
5265
|
var jsxRuntimeExports = requireJsxRuntime();
|
|
5267
5266
|
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5267
|
+
let cache$1;
|
|
5268
|
+
if (typeof document === 'object') {
|
|
5269
|
+
cache$1 = createCache({
|
|
5270
|
+
key: 'css',
|
|
5271
|
+
prepend: true
|
|
5272
|
+
});
|
|
5273
|
+
}
|
|
5272
5274
|
function StyledEngineProvider(props) {
|
|
5273
5275
|
const {
|
|
5274
5276
|
injectFirst,
|
|
5275
5277
|
children
|
|
5276
5278
|
} = props;
|
|
5277
|
-
return injectFirst ? /*#__PURE__*/jsxRuntimeExports.jsx(CacheProvider, {
|
|
5279
|
+
return injectFirst && cache$1 ? /*#__PURE__*/jsxRuntimeExports.jsx(CacheProvider, {
|
|
5278
5280
|
value: cache$1,
|
|
5279
5281
|
children: children
|
|
5280
5282
|
}) : children;
|
|
5281
5283
|
}
|
|
5282
5284
|
|
|
5283
|
-
/**
|
|
5285
|
+
/**
|
|
5286
|
+
* @mui/styled-engine v5.11.11
|
|
5284
5287
|
*
|
|
5288
|
+
* @license MIT
|
|
5285
5289
|
* This source code is licensed under the MIT license found in the
|
|
5286
5290
|
* LICENSE file in the root directory of this source tree.
|
|
5287
5291
|
*/
|
|
@@ -7968,7 +7972,7 @@ function create$3(definition) {
|
|
|
7968
7972
|
return cache[key];
|
|
7969
7973
|
}
|
|
7970
7974
|
|
|
7971
|
-
const NEBULA_VERSION_HASH = "
|
|
7975
|
+
const NEBULA_VERSION_HASH = "c721" ;
|
|
7972
7976
|
ClassNameGenerator$1.configure(componentName => {
|
|
7973
7977
|
return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
|
|
7974
7978
|
});
|
|
@@ -8487,7 +8491,7 @@ function boot(_ref2) {
|
|
|
8487
8491
|
const appRef = React__default.createRef();
|
|
8488
8492
|
const element = document.createElement('div');
|
|
8489
8493
|
element.style.display = 'none';
|
|
8490
|
-
element.setAttribute('data-nebulajs-version', "3.
|
|
8494
|
+
element.setAttribute('data-nebulajs-version', "3.3.0-alpha.0" );
|
|
8491
8495
|
element.setAttribute('data-app-id', app.id);
|
|
8492
8496
|
document.body.appendChild(element);
|
|
8493
8497
|
ReactDOM.render( /*#__PURE__*/React__default.createElement(NebulaApp, {
|
|
@@ -8650,7 +8654,7 @@ const lock = props => _objectSpread2(_objectSpread2({}, props), {}, {
|
|
|
8650
8654
|
shapes: [{
|
|
8651
8655
|
type: 'path',
|
|
8652
8656
|
attrs: {
|
|
8653
|
-
d: '
|
|
8657
|
+
d: 'M8 10a1 1 0 0 1 .5 1.866v.634a.5.5 0 0 1-1 0v-.634A1 1 0 0 1 8 10ZM3.625 7.035A2 2 0 0 0 2 9v5a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V9a2 2 0 0 0-1.625-1.965V5.383a4.375 4.375 0 0 0-8.75 0v1.652ZM3 9a1 1 0 0 1 .931-.998h8.138A1 1 0 0 1 13 9v5a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9Zm8.375-3.617V7h-6.75V5.383a3.375 3.375 0 0 1 6.75 0Z'
|
|
8654
8658
|
}
|
|
8655
8659
|
}]
|
|
8656
8660
|
});
|
|
@@ -9533,7 +9537,15 @@ function getFieldKeyboardNavigation(_ref) {
|
|
|
9533
9537
|
}
|
|
9534
9538
|
function getListboxInlineKeyboardNavigation(_ref2) {
|
|
9535
9539
|
let {
|
|
9536
|
-
setKeyboardActive
|
|
9540
|
+
setKeyboardActive,
|
|
9541
|
+
hovering,
|
|
9542
|
+
setHovering,
|
|
9543
|
+
updateKeyScroll,
|
|
9544
|
+
containerRef,
|
|
9545
|
+
currentScrollIndex,
|
|
9546
|
+
app,
|
|
9547
|
+
appSelections,
|
|
9548
|
+
constraints
|
|
9537
9549
|
} = _ref2;
|
|
9538
9550
|
const focusInsideListbox = element => {
|
|
9539
9551
|
const fieldElement = element.querySelector('.search input, .value.selector, .value, .ActionsToolbar-* button');
|
|
@@ -9546,9 +9558,16 @@ function getListboxInlineKeyboardNavigation(_ref2) {
|
|
|
9546
9558
|
setKeyboardActive(false);
|
|
9547
9559
|
element.focus();
|
|
9548
9560
|
};
|
|
9561
|
+
const updateKeyScrollOnHover = newState => {
|
|
9562
|
+
if (hovering) {
|
|
9563
|
+
updateKeyScroll(newState);
|
|
9564
|
+
}
|
|
9565
|
+
};
|
|
9549
9566
|
const handleKeyDown = event => {
|
|
9550
9567
|
const {
|
|
9551
|
-
keyCode
|
|
9568
|
+
keyCode,
|
|
9569
|
+
ctrlKey = false,
|
|
9570
|
+
shiftKey = false
|
|
9552
9571
|
} = event.nativeEvent;
|
|
9553
9572
|
switch (keyCode) {
|
|
9554
9573
|
// case KEYS.TAB: TODO: Focus confirm button using keyboard.focusSelection when we can access the useKeyboard hook.
|
|
@@ -9563,6 +9582,36 @@ function getListboxInlineKeyboardNavigation(_ref2) {
|
|
|
9563
9582
|
case KEYS.ESCAPE:
|
|
9564
9583
|
focusContainer(event.currentTarget);
|
|
9565
9584
|
break;
|
|
9585
|
+
case KEYS.ARROW_UP:
|
|
9586
|
+
updateKeyScrollOnHover({
|
|
9587
|
+
up: 1
|
|
9588
|
+
});
|
|
9589
|
+
break;
|
|
9590
|
+
case KEYS.ARROW_DOWN:
|
|
9591
|
+
updateKeyScrollOnHover({
|
|
9592
|
+
down: 1
|
|
9593
|
+
});
|
|
9594
|
+
break;
|
|
9595
|
+
case KEYS.PAGE_UP:
|
|
9596
|
+
updateKeyScrollOnHover({
|
|
9597
|
+
up: currentScrollIndex.stop - currentScrollIndex.start
|
|
9598
|
+
});
|
|
9599
|
+
break;
|
|
9600
|
+
case KEYS.PAGE_DOWN:
|
|
9601
|
+
updateKeyScrollOnHover({
|
|
9602
|
+
down: currentScrollIndex.stop - currentScrollIndex.start
|
|
9603
|
+
});
|
|
9604
|
+
break;
|
|
9605
|
+
case KEYS.HOME:
|
|
9606
|
+
updateKeyScrollOnHover({
|
|
9607
|
+
scrollPosition: ctrlKey && shiftKey ? 'overflowStart' : 'start'
|
|
9608
|
+
});
|
|
9609
|
+
break;
|
|
9610
|
+
case KEYS.END:
|
|
9611
|
+
updateKeyScrollOnHover({
|
|
9612
|
+
scrollPosition: ctrlKey && shiftKey ? 'overflowEnd' : 'end'
|
|
9613
|
+
});
|
|
9614
|
+
break;
|
|
9566
9615
|
default:
|
|
9567
9616
|
return;
|
|
9568
9617
|
}
|
|
@@ -9571,7 +9620,60 @@ function getListboxInlineKeyboardNavigation(_ref2) {
|
|
|
9571
9620
|
// from handling keydown events.
|
|
9572
9621
|
event.preventDefault();
|
|
9573
9622
|
};
|
|
9574
|
-
|
|
9623
|
+
const focusOnHoverDisabled = () => {
|
|
9624
|
+
var _app$isInModalSelecti, _app$isInModalSelecti2;
|
|
9625
|
+
const selectNotAllowed = (constraints === null || constraints === void 0 ? void 0 : constraints.select) || (constraints === null || constraints === void 0 ? void 0 : constraints.active);
|
|
9626
|
+
const appInModal = (_app$isInModalSelecti = (_app$isInModalSelecti2 = app.isInModalSelection) === null || _app$isInModalSelecti2 === void 0 ? void 0 : _app$isInModalSelecti2.call(app)) !== null && _app$isInModalSelecti !== void 0 ? _app$isInModalSelecti : appSelections.isInModal();
|
|
9627
|
+
return selectNotAllowed || appInModal;
|
|
9628
|
+
};
|
|
9629
|
+
const handleOnMouseEnter = () => {
|
|
9630
|
+
if (!focusOnHoverDisabled()) {
|
|
9631
|
+
var _containerRef$current, _containerRef$current2;
|
|
9632
|
+
setHovering(true);
|
|
9633
|
+
containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.focus) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.call(_containerRef$current);
|
|
9634
|
+
}
|
|
9635
|
+
};
|
|
9636
|
+
const handleOnMouseLeave = () => {
|
|
9637
|
+
if (hovering) {
|
|
9638
|
+
var _containerRef$current3, _containerRef$current4;
|
|
9639
|
+
setHovering(false);
|
|
9640
|
+
containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : (_containerRef$current4 = _containerRef$current3.blur) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.call(_containerRef$current3);
|
|
9641
|
+
}
|
|
9642
|
+
};
|
|
9643
|
+
return {
|
|
9644
|
+
handleKeyDown,
|
|
9645
|
+
handleOnMouseEnter,
|
|
9646
|
+
handleOnMouseLeave
|
|
9647
|
+
};
|
|
9648
|
+
}
|
|
9649
|
+
|
|
9650
|
+
function getGridItemSizes(_ref) {
|
|
9651
|
+
let {
|
|
9652
|
+
dataLayout,
|
|
9653
|
+
layoutOrder,
|
|
9654
|
+
itemPadding
|
|
9655
|
+
} = _ref;
|
|
9656
|
+
// Simulate margin/padding by making the item smaller than its container.
|
|
9657
|
+
if (dataLayout === 'singleColumn') {
|
|
9658
|
+
return {
|
|
9659
|
+
height: '100%',
|
|
9660
|
+
width: '100%'
|
|
9661
|
+
};
|
|
9662
|
+
}
|
|
9663
|
+
switch (layoutOrder) {
|
|
9664
|
+
case 'row':
|
|
9665
|
+
return {
|
|
9666
|
+
height: "calc(100% - ".concat(itemPadding, "px)"),
|
|
9667
|
+
width: "calc(100% - ".concat(2 * itemPadding, "px)")
|
|
9668
|
+
};
|
|
9669
|
+
case 'column':
|
|
9670
|
+
return {
|
|
9671
|
+
height: "calc(100% - ".concat(itemPadding, "px)"),
|
|
9672
|
+
width: "calc(100% - ".concat(2 * itemPadding, "px)")
|
|
9673
|
+
};
|
|
9674
|
+
default:
|
|
9675
|
+
return {};
|
|
9676
|
+
}
|
|
9575
9677
|
}
|
|
9576
9678
|
|
|
9577
9679
|
const PREFIX$a = 'RowColumn';
|
|
@@ -9615,7 +9717,7 @@ const getSelectedStyle = _ref => {
|
|
|
9615
9717
|
background: theme.palette.selected.main,
|
|
9616
9718
|
color: theme.palette.selected.mainContrastText,
|
|
9617
9719
|
'&:focus': {
|
|
9618
|
-
boxShadow: "inset 0 0 0 2px
|
|
9720
|
+
boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder),
|
|
9619
9721
|
outline: 'none'
|
|
9620
9722
|
},
|
|
9621
9723
|
'& $cell': {
|
|
@@ -9623,36 +9725,53 @@ const getSelectedStyle = _ref => {
|
|
|
9623
9725
|
}
|
|
9624
9726
|
};
|
|
9625
9727
|
};
|
|
9626
|
-
const
|
|
9627
|
-
shouldForwardProp:
|
|
9728
|
+
const ItemGrid = styled$1(Grid, {
|
|
9729
|
+
shouldForwardProp: prop => !['dataLayout', 'layoutOrder', 'itemPadding'].includes(prop)
|
|
9628
9730
|
})(_ref2 => {
|
|
9731
|
+
let {
|
|
9732
|
+
dataLayout,
|
|
9733
|
+
layoutOrder,
|
|
9734
|
+
itemPadding
|
|
9735
|
+
} = _ref2;
|
|
9736
|
+
return {
|
|
9737
|
+
["&.".concat(classes$a.fieldRoot)]: getGridItemSizes({
|
|
9738
|
+
dataLayout,
|
|
9739
|
+
layoutOrder,
|
|
9740
|
+
itemPadding
|
|
9741
|
+
})
|
|
9742
|
+
};
|
|
9743
|
+
});
|
|
9744
|
+
const Root$1 = styled$1('div', {
|
|
9745
|
+
shouldForwardProp: prop => !['flexBasisProp', 'isGridMode', 'isGridCol', 'dense'].includes(prop)
|
|
9746
|
+
})(_ref3 => {
|
|
9629
9747
|
var _theme$listBox$conten, _theme$listBox, _theme$listBox$conten2, _theme$listBox$conten3, _theme$listBox2, _theme$listBox2$conte, _theme$listBox3, _theme$listBox3$conte, _theme$listBox4, _theme$listBox4$conte;
|
|
9630
9748
|
let {
|
|
9631
9749
|
theme,
|
|
9632
9750
|
flexBasisProp,
|
|
9751
|
+
isGridMode,
|
|
9752
|
+
isGridCol,
|
|
9633
9753
|
dense
|
|
9634
|
-
} =
|
|
9754
|
+
} = _ref3;
|
|
9635
9755
|
return {
|
|
9756
|
+
'&:focus': {
|
|
9757
|
+
boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
|
|
9758
|
+
},
|
|
9759
|
+
'&:focus-visible': {
|
|
9760
|
+
outline: 'none'
|
|
9761
|
+
},
|
|
9636
9762
|
["& .".concat(classes$a.row)]: {
|
|
9637
9763
|
flexWrap: 'nowrap',
|
|
9638
9764
|
color: (_theme$listBox$conten = (_theme$listBox = theme.listBox) === null || _theme$listBox === void 0 ? void 0 : (_theme$listBox$conten2 = _theme$listBox.content) === null || _theme$listBox$conten2 === void 0 ? void 0 : _theme$listBox$conten2.color) !== null && _theme$listBox$conten !== void 0 ? _theme$listBox$conten : theme.palette.text.primary
|
|
9639
9765
|
},
|
|
9640
9766
|
["& .".concat(classes$a.rowBorderBottom)]: {
|
|
9641
|
-
borderBottom: "1px solid ".concat(theme.palette.divider)
|
|
9767
|
+
borderBottom: isGridCol ? 'none' : "1px solid ".concat(theme.palette.divider),
|
|
9768
|
+
borderLeft: isGridCol ? "1px solid ".concat(theme.palette.divider) : 'none'
|
|
9642
9769
|
},
|
|
9643
9770
|
["& .".concat(classes$a.column)]: {
|
|
9644
9771
|
flexWrap: 'nowrap',
|
|
9645
9772
|
borderRight: "1px solid ".concat(theme.palette.divider),
|
|
9646
9773
|
color: (_theme$listBox$conten3 = (_theme$listBox2 = theme.listBox) === null || _theme$listBox2 === void 0 ? void 0 : (_theme$listBox2$conte = _theme$listBox2.content) === null || _theme$listBox2$conte === void 0 ? void 0 : _theme$listBox2$conte.color) !== null && _theme$listBox$conten3 !== void 0 ? _theme$listBox$conten3 : theme.palette.text.primary
|
|
9647
9774
|
},
|
|
9648
|
-
["& .".concat(classes$a.fieldRoot)]: {
|
|
9649
|
-
'&:focus': {
|
|
9650
|
-
boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
|
|
9651
|
-
},
|
|
9652
|
-
'&:focus-visible': {
|
|
9653
|
-
outline: 'none'
|
|
9654
|
-
}
|
|
9655
|
-
},
|
|
9656
9775
|
// The interior wrapper for all field content.
|
|
9657
9776
|
["& .".concat(classes$a.cell)]: {
|
|
9658
9777
|
display: 'flex',
|
|
@@ -9712,22 +9831,27 @@ const Root$1 = styled$1('div', {
|
|
|
9712
9831
|
padding: theme.spacing(1, 1, 1, 0)
|
|
9713
9832
|
},
|
|
9714
9833
|
// Selection styles (S=Selected, XS=ExcludedSelected, A=Available, X=Excluded).
|
|
9715
|
-
["& .".concat(classes$a.S)]: _objectSpread2({}, getSelectedStyle({
|
|
9834
|
+
["& .".concat(classes$a.S)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
|
|
9716
9835
|
theme
|
|
9717
|
-
})),
|
|
9836
|
+
})), {}, {
|
|
9837
|
+
border: isGridMode ? 'none' : undefined
|
|
9838
|
+
}),
|
|
9718
9839
|
["& .".concat(classes$a.XS)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
|
|
9719
9840
|
theme
|
|
9720
9841
|
})), {}, {
|
|
9721
9842
|
background: theme.palette.selected.excluded,
|
|
9722
|
-
color: theme.palette.selected.mainContrastText
|
|
9843
|
+
color: theme.palette.selected.mainContrastText,
|
|
9844
|
+
border: isGridMode ? 'none' : undefined
|
|
9723
9845
|
}),
|
|
9724
9846
|
["& .".concat(classes$a.A)]: {
|
|
9725
9847
|
background: theme.palette.selected.alternative,
|
|
9726
|
-
color: theme.palette.selected.alternativeContrastText
|
|
9848
|
+
color: theme.palette.selected.alternativeContrastText,
|
|
9849
|
+
border: isGridMode ? 'none' : undefined
|
|
9727
9850
|
},
|
|
9728
9851
|
["& .".concat(classes$a.X)]: {
|
|
9729
9852
|
background: theme.palette.selected.excluded,
|
|
9730
|
-
color: theme.palette.selected.excludedContrastText
|
|
9853
|
+
color: theme.palette.selected.excludedContrastText,
|
|
9854
|
+
border: isGridMode ? 'none' : undefined
|
|
9731
9855
|
},
|
|
9732
9856
|
["& .".concat(classes$a.frequencyCount)]: {
|
|
9733
9857
|
width: '66px',
|
|
@@ -9735,7 +9859,8 @@ const Root$1 = styled$1('div', {
|
|
|
9735
9859
|
},
|
|
9736
9860
|
["&.".concat(classes$a.barContainer)]: {
|
|
9737
9861
|
height: '100%',
|
|
9738
|
-
display: '
|
|
9862
|
+
display: 'flex',
|
|
9863
|
+
alignItems: 'center'
|
|
9739
9864
|
},
|
|
9740
9865
|
["& .".concat(classes$a.bar)]: {
|
|
9741
9866
|
border: "".concat(barBorderWidthPx, "px solid"),
|
|
@@ -9766,14 +9891,15 @@ const Root$1 = styled$1('div', {
|
|
|
9766
9891
|
}
|
|
9767
9892
|
};
|
|
9768
9893
|
});
|
|
9769
|
-
function RowColumn(
|
|
9894
|
+
function RowColumn(_ref4) {
|
|
9895
|
+
var _cell$qText;
|
|
9770
9896
|
let {
|
|
9771
9897
|
index,
|
|
9772
9898
|
rowIndex,
|
|
9773
9899
|
columnIndex,
|
|
9774
9900
|
style,
|
|
9775
9901
|
data
|
|
9776
|
-
} =
|
|
9902
|
+
} = _ref4;
|
|
9777
9903
|
const {
|
|
9778
9904
|
onClick,
|
|
9779
9905
|
onMouseDown,
|
|
@@ -9785,7 +9911,7 @@ function RowColumn(_ref3) {
|
|
|
9785
9911
|
checkboxes = false,
|
|
9786
9912
|
textAlign,
|
|
9787
9913
|
direction,
|
|
9788
|
-
|
|
9914
|
+
layoutOptions = {},
|
|
9789
9915
|
freqIsAllowed,
|
|
9790
9916
|
isSingleSelect,
|
|
9791
9917
|
actions,
|
|
@@ -9795,11 +9921,16 @@ function RowColumn(_ref3) {
|
|
|
9795
9921
|
showGray = true,
|
|
9796
9922
|
columnCount = 1,
|
|
9797
9923
|
rowCount = 1,
|
|
9798
|
-
layoutOrder,
|
|
9799
9924
|
dataOffset,
|
|
9800
9925
|
focusListItems,
|
|
9801
|
-
listCount
|
|
9926
|
+
listCount,
|
|
9927
|
+
itemPadding
|
|
9802
9928
|
} = data;
|
|
9929
|
+
const {
|
|
9930
|
+
dense = false,
|
|
9931
|
+
dataLayout = 'singleColumn',
|
|
9932
|
+
layoutOrder
|
|
9933
|
+
} = layoutOptions;
|
|
9803
9934
|
let cellIndex;
|
|
9804
9935
|
let styles;
|
|
9805
9936
|
const count = {
|
|
@@ -9871,7 +10002,7 @@ function RowColumn(_ref3) {
|
|
|
9871
10002
|
const selected = cell.qState === 'S' || cell.qState === 'XS' || cell.qState === 'L';
|
|
9872
10003
|
setSelected(selected);
|
|
9873
10004
|
const clazzArr = [column ? classes$a.column : classes$a.row];
|
|
9874
|
-
if (!(histogram && dense
|
|
10005
|
+
if (!(histogram && (dense || checkboxes))) clazzArr.push(classes$a.rowBorderBottom);
|
|
9875
10006
|
if (!checkboxes) {
|
|
9876
10007
|
if (cell.qState === 'XS') {
|
|
9877
10008
|
clazzArr.push(showGray ? classes$a.XS : classes$a.S);
|
|
@@ -9903,13 +10034,13 @@ function RowColumn(_ref3) {
|
|
|
9903
10034
|
} else {
|
|
9904
10035
|
valueTextAlign = (textAlign === null || textAlign === void 0 ? void 0 : textAlign.align) || 'left';
|
|
9905
10036
|
}
|
|
9906
|
-
const getValueField =
|
|
10037
|
+
const getValueField = _ref5 => {
|
|
9907
10038
|
let {
|
|
9908
10039
|
lbl,
|
|
9909
10040
|
ix,
|
|
9910
10041
|
color,
|
|
9911
10042
|
highlighted = false
|
|
9912
|
-
} =
|
|
10043
|
+
} = _ref5;
|
|
9913
10044
|
return /*#__PURE__*/React__default.createElement(Typography, {
|
|
9914
10045
|
component: "span",
|
|
9915
10046
|
variant: "body2",
|
|
@@ -9930,17 +10061,19 @@ function RowColumn(_ref3) {
|
|
|
9930
10061
|
}
|
|
9931
10062
|
event.preventDefault();
|
|
9932
10063
|
};
|
|
9933
|
-
const
|
|
10064
|
+
const isGridCol = dataLayout === 'grid' && layoutOrder === 'column';
|
|
10065
|
+
const getCheckboxField = _ref6 => {
|
|
9934
10066
|
let {
|
|
9935
10067
|
lbl,
|
|
9936
10068
|
color,
|
|
9937
10069
|
qElemNumber
|
|
9938
|
-
} =
|
|
10070
|
+
} = _ref6;
|
|
9939
10071
|
const cb = /*#__PURE__*/React__default.createElement(ListboxCheckbox, {
|
|
9940
10072
|
label: lbl,
|
|
9941
10073
|
checked: isSelected,
|
|
9942
10074
|
dense: dense,
|
|
9943
10075
|
excluded: isExcluded(cell),
|
|
10076
|
+
isGridCol: isGridCol,
|
|
9944
10077
|
showGray: showGray
|
|
9945
10078
|
});
|
|
9946
10079
|
const rb = /*#__PURE__*/React__default.createElement(ListBoxRadioButton, {
|
|
@@ -9961,7 +10094,7 @@ function RowColumn(_ref3) {
|
|
|
9961
10094
|
key: qElemNumber
|
|
9962
10095
|
});
|
|
9963
10096
|
};
|
|
9964
|
-
const label = cell ? cell.qText : '';
|
|
10097
|
+
const label = (_cell$qText = cell === null || cell === void 0 ? void 0 : cell.qText) !== null && _cell$qText !== void 0 ? _cell$qText : '';
|
|
9965
10098
|
const getFrequencyText = () => {
|
|
9966
10099
|
if (cell) {
|
|
9967
10100
|
return cell.qFrequency ? cell.qFrequency : frequencyTextNone;
|
|
@@ -9973,12 +10106,12 @@ function RowColumn(_ref3) {
|
|
|
9973
10106
|
const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
|
|
9974
10107
|
const labels = getSegmentsFromRanges(label, ranges);
|
|
9975
10108
|
const getField = checkboxes ? getCheckboxField : getValueField;
|
|
9976
|
-
const getFieldWithRanges =
|
|
10109
|
+
const getFieldWithRanges = _ref7 => {
|
|
9977
10110
|
let {
|
|
9978
10111
|
lbls
|
|
9979
|
-
} =
|
|
9980
|
-
const labelsWithRanges = lbls.map((
|
|
9981
|
-
let [lbl, highlighted] =
|
|
10112
|
+
} = _ref7;
|
|
10113
|
+
const labelsWithRanges = lbls.map((_ref8, ix) => {
|
|
10114
|
+
let [lbl, highlighted] = _ref8;
|
|
9982
10115
|
return getValueField({
|
|
9983
10116
|
ix,
|
|
9984
10117
|
highlighted,
|
|
@@ -10018,16 +10151,21 @@ function RowColumn(_ref3) {
|
|
|
10018
10151
|
return /*#__PURE__*/React__default.createElement(Root$1, {
|
|
10019
10152
|
className: classes$a.barContainer,
|
|
10020
10153
|
flexBasisProp: flexBasisVal,
|
|
10154
|
+
style: styles,
|
|
10155
|
+
isGridCol: isGridCol,
|
|
10156
|
+
isGridMode: dataLayout === 'grid',
|
|
10021
10157
|
dense: dense
|
|
10022
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
10158
|
+
}, /*#__PURE__*/React__default.createElement(ItemGrid, {
|
|
10023
10159
|
ref: rowRef,
|
|
10024
10160
|
container: true,
|
|
10161
|
+
dataLayout: dataLayout,
|
|
10162
|
+
layoutOrder: layoutOrder,
|
|
10163
|
+
itemPadding: itemPadding,
|
|
10025
10164
|
gap: 0,
|
|
10026
10165
|
className: joinClassNames(['value', ...classArr]),
|
|
10027
10166
|
classes: {
|
|
10028
10167
|
root: classes$a.fieldRoot
|
|
10029
10168
|
},
|
|
10030
|
-
style: styles,
|
|
10031
10169
|
onClick: onClick,
|
|
10032
10170
|
onMouseDown: onMouseDown,
|
|
10033
10171
|
onMouseUp: onMouseUp,
|
|
@@ -11663,16 +11801,15 @@ function getListBoxComponents(_ref) {
|
|
|
11663
11801
|
listCount,
|
|
11664
11802
|
overflowDisclaimer,
|
|
11665
11803
|
setScrollPosition,
|
|
11666
|
-
focusListItems
|
|
11804
|
+
focusListItems,
|
|
11805
|
+
setCurrentScrollIndex
|
|
11667
11806
|
} = _ref;
|
|
11668
11807
|
const {
|
|
11669
11808
|
layoutOptions = {},
|
|
11670
11809
|
frequencyMax
|
|
11671
11810
|
} = layout || {};
|
|
11672
11811
|
const {
|
|
11673
|
-
|
|
11674
|
-
} = layoutOptions || {};
|
|
11675
|
-
const {
|
|
11812
|
+
itemPadding,
|
|
11676
11813
|
listHeight,
|
|
11677
11814
|
itemSize,
|
|
11678
11815
|
rowCount,
|
|
@@ -11694,7 +11831,7 @@ function getListBoxComponents(_ref) {
|
|
|
11694
11831
|
pages
|
|
11695
11832
|
}, isLocked || selectDisabled() ? {} : interactionEvents), {}, {
|
|
11696
11833
|
checkboxes,
|
|
11697
|
-
|
|
11834
|
+
layoutOptions,
|
|
11698
11835
|
frequencyMode,
|
|
11699
11836
|
freqIsAllowed: getFrequencyAllowed({
|
|
11700
11837
|
width,
|
|
@@ -11703,6 +11840,7 @@ function getListBoxComponents(_ref) {
|
|
|
11703
11840
|
}),
|
|
11704
11841
|
isSingleSelect,
|
|
11705
11842
|
textAlign,
|
|
11843
|
+
itemPadding,
|
|
11706
11844
|
actions: {
|
|
11707
11845
|
select,
|
|
11708
11846
|
confirm: () => selections === null || selections === void 0 ? void 0 : selections.confirm.call(selections),
|
|
@@ -11737,6 +11875,10 @@ function getListBoxComponents(_ref) {
|
|
|
11737
11875
|
itemSize: itemSize,
|
|
11738
11876
|
onItemsRendered: renderProps => {
|
|
11739
11877
|
var _layout$qListObject, _layout$qListObject$q;
|
|
11878
|
+
setCurrentScrollIndex({
|
|
11879
|
+
start: renderProps.visibleStartIndex,
|
|
11880
|
+
stop: renderProps.visibleStopIndex
|
|
11881
|
+
});
|
|
11740
11882
|
if (scrollState) {
|
|
11741
11883
|
scrollState.setScrollPos(renderProps.visibleStopIndex);
|
|
11742
11884
|
}
|
|
@@ -11773,6 +11915,11 @@ function getListBoxComponents(_ref) {
|
|
|
11773
11915
|
local.current.listRef = ref;
|
|
11774
11916
|
const handleGridItemsRendered = renderProps => {
|
|
11775
11917
|
var _layout$qListObject2, _layout$qListObject2$;
|
|
11918
|
+
const isRow = layoutOrder === 'row';
|
|
11919
|
+
setCurrentScrollIndex({
|
|
11920
|
+
start: isRow ? renderProps.visibleRowStartIndex : renderProps.visibleColumnStartIndex,
|
|
11921
|
+
stop: isRow ? renderProps.visibleRowStopIndex : renderProps.visibleColumnStopIndex
|
|
11922
|
+
});
|
|
11776
11923
|
const renderOptions = deriveRenderOptions({
|
|
11777
11924
|
renderProps,
|
|
11778
11925
|
scrollState,
|
|
@@ -11806,8 +11953,7 @@ function getListBoxComponents(_ref) {
|
|
|
11806
11953
|
itemData: _objectSpread2(_objectSpread2({}, commonItemData), {}, {
|
|
11807
11954
|
column: undefined,
|
|
11808
11955
|
columnCount,
|
|
11809
|
-
rowCount
|
|
11810
|
-
layoutOrder
|
|
11956
|
+
rowCount
|
|
11811
11957
|
}),
|
|
11812
11958
|
onItemsRendered: handleGridItemsRendered,
|
|
11813
11959
|
ref: ref
|
|
@@ -11845,8 +11991,17 @@ function getListSizes(_ref) {
|
|
|
11845
11991
|
let columnCount;
|
|
11846
11992
|
let columnWidth;
|
|
11847
11993
|
let rowCount;
|
|
11848
|
-
const
|
|
11849
|
-
const
|
|
11994
|
+
const isGridMode = dataLayout === 'grid';
|
|
11995
|
+
const itemPadding = 4;
|
|
11996
|
+
const denseItemSize = 20;
|
|
11997
|
+
const normalItemSize = isGridMode ? 32 : 29;
|
|
11998
|
+
let itemSize = dense ? denseItemSize : normalItemSize;
|
|
11999
|
+
if (isGridMode) {
|
|
12000
|
+
// Emulate a margin between items using padding, since the list library
|
|
12001
|
+
// needs an explicit row height and cannot handle margins.
|
|
12002
|
+
itemSize += itemPadding;
|
|
12003
|
+
}
|
|
12004
|
+
const listHeight = height !== null && height !== void 0 ? height : 8 * itemSize;
|
|
11850
12005
|
if (layoutOrder) {
|
|
11851
12006
|
if (layoutOrder === 'row') {
|
|
11852
12007
|
overflowStyling = {
|
|
@@ -11896,7 +12051,8 @@ function getListSizes(_ref) {
|
|
|
11896
12051
|
maxCount: {
|
|
11897
12052
|
row: maxRowCount,
|
|
11898
12053
|
column: maxColumnCount
|
|
11899
|
-
}
|
|
12054
|
+
},
|
|
12055
|
+
itemPadding
|
|
11900
12056
|
};
|
|
11901
12057
|
}
|
|
11902
12058
|
|
|
@@ -12412,7 +12568,14 @@ function ListBox(_ref) {
|
|
|
12412
12568
|
keyboard = {},
|
|
12413
12569
|
showGray = true,
|
|
12414
12570
|
scrollState,
|
|
12415
|
-
selectDisabled = () => false
|
|
12571
|
+
selectDisabled = () => false,
|
|
12572
|
+
keyScroll = {
|
|
12573
|
+
state: {},
|
|
12574
|
+
reset: () => {}
|
|
12575
|
+
},
|
|
12576
|
+
currentScrollIndex = {
|
|
12577
|
+
set: () => {}
|
|
12578
|
+
}
|
|
12416
12579
|
} = _ref;
|
|
12417
12580
|
const [initScrollPosIsSet, setInitScrollPosIsSet] = useState$1(false);
|
|
12418
12581
|
const [layout] = useLayout$1(model);
|
|
@@ -12505,8 +12668,12 @@ function ListBox(_ref) {
|
|
|
12505
12668
|
local.current.validPages = false;
|
|
12506
12669
|
if (loaderRef.current) {
|
|
12507
12670
|
loaderRef.current.resetloadMoreItemsCache(true);
|
|
12508
|
-
|
|
12509
|
-
if
|
|
12671
|
+
const isScrollingToEnd = keyScroll.state.scrollPosition === 'overflowEnd';
|
|
12672
|
+
// Skip scrollToItem if we are in selections or if scrolling to the end.
|
|
12673
|
+
if (layout && layout.qSelectionInfo.qInSelections || isScrollingToEnd) {
|
|
12674
|
+
if (isScrollingToEnd) {
|
|
12675
|
+
keyScroll.reset();
|
|
12676
|
+
}
|
|
12510
12677
|
return;
|
|
12511
12678
|
}
|
|
12512
12679
|
local.current.dataOffset = 0;
|
|
@@ -12577,6 +12744,21 @@ function ListBox(_ref) {
|
|
|
12577
12744
|
}
|
|
12578
12745
|
scrollToIndex(scrollIndex);
|
|
12579
12746
|
};
|
|
12747
|
+
useEffect$1(() => {
|
|
12748
|
+
const s = keyScroll.state;
|
|
12749
|
+
if (s.up) {
|
|
12750
|
+
scrollToIndex(currentScrollIndex.state.start - s.up);
|
|
12751
|
+
} else if (s.down) {
|
|
12752
|
+
scrollToIndex(currentScrollIndex.state.stop + s.down);
|
|
12753
|
+
} else if (s.scrollPosition) {
|
|
12754
|
+
setScrollPosition(s.scrollPosition);
|
|
12755
|
+
}
|
|
12756
|
+
if (s.scrollPosition === 'overflowEnd') {
|
|
12757
|
+
return; // Do keyScroll.reset() in fetchData() to avoid scrolling to top.
|
|
12758
|
+
}
|
|
12759
|
+
|
|
12760
|
+
keyScroll.reset();
|
|
12761
|
+
}, [keyScroll.state.up, keyScroll.state.down, keyScroll.state.scrollPosition]);
|
|
12580
12762
|
const {
|
|
12581
12763
|
textAlign
|
|
12582
12764
|
} = (layout === null || layout === void 0 ? void 0 : layout.qListObject.qDimensionInfo) || {};
|
|
@@ -12624,7 +12806,8 @@ function ListBox(_ref) {
|
|
|
12624
12806
|
set: showOverflowDisclaimer
|
|
12625
12807
|
},
|
|
12626
12808
|
setScrollPosition,
|
|
12627
|
-
focusListItems: getFocusState()
|
|
12809
|
+
focusListItems: getFocusState(),
|
|
12810
|
+
setCurrentScrollIndex: currentScrollIndex.set
|
|
12628
12811
|
});
|
|
12629
12812
|
const {
|
|
12630
12813
|
columnWidth,
|
|
@@ -12902,6 +13085,8 @@ const StyledPopover$1 = styled$1(Popover)(_ref => {
|
|
|
12902
13085
|
theme
|
|
12903
13086
|
} = _ref;
|
|
12904
13087
|
return {
|
|
13088
|
+
// Set here to allow clicking through the modals container
|
|
13089
|
+
pointerEvents: 'none',
|
|
12905
13090
|
["& .".concat(classes$8.icon)]: {
|
|
12906
13091
|
color: theme.palette.text.primary
|
|
12907
13092
|
}
|
|
@@ -12949,6 +13134,10 @@ const More$1 = React__default.forwardRef((_ref3, ref) => {
|
|
|
12949
13134
|
ref: ref,
|
|
12950
13135
|
open: show,
|
|
12951
13136
|
anchorEl: alignTo.current,
|
|
13137
|
+
getContentAnchorEl: null,
|
|
13138
|
+
container: alignTo.current,
|
|
13139
|
+
disablePortal: true,
|
|
13140
|
+
hideBackdrop: true,
|
|
12952
13141
|
transitionDuration: 0,
|
|
12953
13142
|
slotProps: {
|
|
12954
13143
|
root: {
|
|
@@ -12957,11 +13146,11 @@ const More$1 = React__default.forwardRef((_ref3, ref) => {
|
|
|
12957
13146
|
},
|
|
12958
13147
|
anchorOrigin: {
|
|
12959
13148
|
vertical: 'bottom',
|
|
12960
|
-
horizontal: '
|
|
13149
|
+
horizontal: 'right'
|
|
12961
13150
|
},
|
|
12962
13151
|
transformOrigin: {
|
|
12963
13152
|
vertical: 'top',
|
|
12964
|
-
horizontal: '
|
|
13153
|
+
horizontal: 'right'
|
|
12965
13154
|
},
|
|
12966
13155
|
PaperProps: {
|
|
12967
13156
|
style: _objectSpread2({
|
|
@@ -13106,7 +13295,9 @@ function ActionsToolbar(_ref3) {
|
|
|
13106
13295
|
const buttons = actionsElement.querySelectorAll('button:not(.Mui-disabled)');
|
|
13107
13296
|
return buttons[last ? buttons.length - 1 : 0];
|
|
13108
13297
|
};
|
|
13109
|
-
useEffect$1(() => () =>
|
|
13298
|
+
useEffect$1(() => () => {
|
|
13299
|
+
setShowMoreItems(false);
|
|
13300
|
+
}, [popover.show, show, selections.show]);
|
|
13110
13301
|
useEffect$1(() => {
|
|
13111
13302
|
if (!focusHandler) return;
|
|
13112
13303
|
const focusFirst = () => {
|
|
@@ -13122,6 +13313,7 @@ function ActionsToolbar(_ref3) {
|
|
|
13122
13313
|
}, []);
|
|
13123
13314
|
let moreEnabled = more$1.enabled;
|
|
13124
13315
|
let moreActions = more$1.actions;
|
|
13316
|
+
const moreAlignTo = more$1.alignTo || moreRef;
|
|
13125
13317
|
const newActions = actions.filter(a => !a.hidden);
|
|
13126
13318
|
if (newActions.length > maxItems) {
|
|
13127
13319
|
const newMoreActions = newActions.splice(-(newActions.length - maxItems) - 1);
|
|
@@ -13186,7 +13378,7 @@ function ActionsToolbar(_ref3) {
|
|
|
13186
13378
|
}), showMoreItems && /*#__PURE__*/React__default.createElement(More$1, {
|
|
13187
13379
|
show: showMoreItems,
|
|
13188
13380
|
actions: moreActions,
|
|
13189
|
-
alignTo:
|
|
13381
|
+
alignTo: moreAlignTo,
|
|
13190
13382
|
popoverProps: more$1.popoverProps,
|
|
13191
13383
|
popoverPaperStyle: more$1.popoverPaperStyle,
|
|
13192
13384
|
onCloseOrActionClick: handleCloseShowMoreItems
|
|
@@ -13215,7 +13407,7 @@ const search = props => _objectSpread2(_objectSpread2({}, props), {}, {
|
|
|
13215
13407
|
shapes: [{
|
|
13216
13408
|
type: 'path',
|
|
13217
13409
|
attrs: {
|
|
13218
|
-
d: '
|
|
13410
|
+
d: 'M8.588 11.415a6 6 0 1 1 2.828-2.829l4.101 4a1.5 1.5 0 0 1 .014 2.134l-.707.707a1.5 1.5 0 0 1-2.108.014l-4.128-4.026ZM11 6A5 5 0 1 0 1 6a5 5 0 0 0 10 0Zm-1.52 4.888 3.934 3.837a.5.5 0 0 0 .703-.005l.707-.707a.5.5 0 0 0-.005-.711l-3.926-3.829a6.034 6.034 0 0 1-1.413 1.415Z'
|
|
13219
13411
|
}
|
|
13220
13412
|
}]
|
|
13221
13413
|
});
|
|
@@ -13248,7 +13440,8 @@ function ListBoxSearch(_ref3) {
|
|
|
13248
13440
|
keyboard,
|
|
13249
13441
|
dense = false,
|
|
13250
13442
|
visible = true,
|
|
13251
|
-
|
|
13443
|
+
autoFocus = true,
|
|
13444
|
+
wildCardSearch = false,
|
|
13252
13445
|
searchEnabled
|
|
13253
13446
|
} = _ref3;
|
|
13254
13447
|
const {
|
|
@@ -13373,6 +13566,7 @@ function ListBoxSearch(_ref3) {
|
|
|
13373
13566
|
onFocus: handleFocus,
|
|
13374
13567
|
onChange: onChange,
|
|
13375
13568
|
onKeyDown: onKeyDown,
|
|
13569
|
+
autoFocus: autoFocus,
|
|
13376
13570
|
inputProps: {
|
|
13377
13571
|
tabIndex: keyboard && (!keyboard.enabled || keyboard.active) ? 0 : -1
|
|
13378
13572
|
}
|
|
@@ -13567,7 +13761,7 @@ const getClickOutFuncs = _ref3 => {
|
|
|
13567
13761
|
let {
|
|
13568
13762
|
elements,
|
|
13569
13763
|
objectSelections,
|
|
13570
|
-
options
|
|
13764
|
+
options = {}
|
|
13571
13765
|
} = _ref3;
|
|
13572
13766
|
const handler = createHandler({
|
|
13573
13767
|
elements,
|
|
@@ -13655,7 +13849,8 @@ function ListBoxPopover(_ref) {
|
|
|
13655
13849
|
close,
|
|
13656
13850
|
app,
|
|
13657
13851
|
fieldName,
|
|
13658
|
-
stateName = '$'
|
|
13852
|
+
stateName = '$',
|
|
13853
|
+
autoFocus
|
|
13659
13854
|
} = _ref;
|
|
13660
13855
|
const isMasterDim = Boolean(fieldName === null || fieldName === void 0 ? void 0 : fieldName.qLibraryId);
|
|
13661
13856
|
const open = show && Boolean(alignTo.current);
|
|
@@ -13787,10 +13982,14 @@ function ListBoxPopover(_ref) {
|
|
|
13787
13982
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
13788
13983
|
ref: moreAlignTo
|
|
13789
13984
|
}), /*#__PURE__*/React__default.createElement(ListBoxSearch, {
|
|
13790
|
-
|
|
13985
|
+
visible: true,
|
|
13791
13986
|
model: model,
|
|
13792
13987
|
listCount: listCount,
|
|
13793
|
-
|
|
13988
|
+
selections: selections,
|
|
13989
|
+
keyboard: {
|
|
13990
|
+
enabled: false
|
|
13991
|
+
},
|
|
13992
|
+
autoFocus: autoFocus !== null && autoFocus !== void 0 ? autoFocus : true
|
|
13794
13993
|
}), /*#__PURE__*/React__default.createElement(ListBox, {
|
|
13795
13994
|
model: model,
|
|
13796
13995
|
selections: selections,
|
|
@@ -14305,7 +14504,7 @@ function getItems(layout) {
|
|
|
14305
14504
|
if (layout.alternateStates) {
|
|
14306
14505
|
layout.alternateStates.forEach(s => collect(s.qSelectionObject, fields, s.stateName));
|
|
14307
14506
|
}
|
|
14308
|
-
return Object.keys(fields).map(key => fields[key]);
|
|
14507
|
+
return Object.keys(fields).map(key => fields[key]).filter(f => !f.selections.some(s => s.qIsHidden));
|
|
14309
14508
|
}
|
|
14310
14509
|
function SelectedFields(_ref) {
|
|
14311
14510
|
let {
|
|
@@ -15027,6 +15226,7 @@ const addListboxTheme = themeApi => {
|
|
|
15027
15226
|
};
|
|
15028
15227
|
|
|
15029
15228
|
const PREFIX$4 = 'ListBoxInline';
|
|
15229
|
+
const searchIconWidth = 28;
|
|
15030
15230
|
const classes$4 = {
|
|
15031
15231
|
listBoxHeader: "".concat(PREFIX$4, "-listBoxHeader"),
|
|
15032
15232
|
screenReaderOnly: "".concat(PREFIX$4, "-screenReaderOnly")
|
|
@@ -15040,7 +15240,8 @@ const StyledGrid$3 = styled$1(Grid)(_ref => {
|
|
|
15040
15240
|
backgroundColor: (_theme$listBox$backgr = (_theme$listBox = theme.listBox) === null || _theme$listBox === void 0 ? void 0 : _theme$listBox.backgroundColor) !== null && _theme$listBox$backgr !== void 0 ? _theme$listBox$backgr : theme.palette.background.default,
|
|
15041
15241
|
["& .".concat(classes$4.listBoxHeader)]: {
|
|
15042
15242
|
alignSelf: 'center',
|
|
15043
|
-
display: 'inline-flex'
|
|
15243
|
+
display: 'inline-flex',
|
|
15244
|
+
width: "calc(100% - ".concat(searchIconWidth, "px)")
|
|
15044
15245
|
},
|
|
15045
15246
|
["& .".concat(classes$4.screenReaderOnly)]: {
|
|
15046
15247
|
position: 'absolute',
|
|
@@ -15067,6 +15268,7 @@ function ListBoxInline(_ref3) {
|
|
|
15067
15268
|
options = {}
|
|
15068
15269
|
} = _ref3;
|
|
15069
15270
|
const {
|
|
15271
|
+
app,
|
|
15070
15272
|
direction,
|
|
15071
15273
|
frequencyMode,
|
|
15072
15274
|
listLayout,
|
|
@@ -15106,17 +15308,43 @@ function ListBoxInline(_ref3) {
|
|
|
15106
15308
|
const {
|
|
15107
15309
|
translator,
|
|
15108
15310
|
keyboardNavigation,
|
|
15109
|
-
themeApi
|
|
15311
|
+
themeApi,
|
|
15312
|
+
constraints
|
|
15110
15313
|
} = useContext(InstanceContext);
|
|
15111
15314
|
theme.listBox = addListboxTheme(themeApi);
|
|
15112
15315
|
const moreAlignTo = useRef();
|
|
15316
|
+
const containerRef = useRef();
|
|
15113
15317
|
const [searchContainer, searchContainerRef] = useRefWithCallback();
|
|
15114
15318
|
const [layout] = useLayout$1(model);
|
|
15115
15319
|
const [showToolbar, setShowToolbar] = useState$1(false);
|
|
15116
15320
|
const [showSearch, setShowSearch] = useState$1(false);
|
|
15117
15321
|
const [keyboardActive, setKeyboardActive] = useState$1(false);
|
|
15118
|
-
const
|
|
15119
|
-
|
|
15322
|
+
const [hovering, setHovering] = useState$1(false);
|
|
15323
|
+
const [keyScroll, setKeyScroll] = useState$1({
|
|
15324
|
+
down: 0,
|
|
15325
|
+
up: 0,
|
|
15326
|
+
scrollPosition: ''
|
|
15327
|
+
});
|
|
15328
|
+
const updateKeyScroll = newState => setKeyScroll(current => _objectSpread2(_objectSpread2({}, current), newState));
|
|
15329
|
+
const [currentScrollIndex, setCurrentScrollIndex] = useState$1({
|
|
15330
|
+
start: 0,
|
|
15331
|
+
stop: 0
|
|
15332
|
+
});
|
|
15333
|
+
const [appSelections] = useAppSelections(app);
|
|
15334
|
+
const {
|
|
15335
|
+
handleKeyDown,
|
|
15336
|
+
handleOnMouseEnter,
|
|
15337
|
+
handleOnMouseLeave
|
|
15338
|
+
} = getListboxInlineKeyboardNavigation({
|
|
15339
|
+
setKeyboardActive,
|
|
15340
|
+
hovering,
|
|
15341
|
+
setHovering,
|
|
15342
|
+
updateKeyScroll,
|
|
15343
|
+
containerRef,
|
|
15344
|
+
currentScrollIndex,
|
|
15345
|
+
app,
|
|
15346
|
+
appSelections,
|
|
15347
|
+
constraints
|
|
15120
15348
|
});
|
|
15121
15349
|
|
|
15122
15350
|
// Expose the keyboard flags in the same way as the keyboard hook does.
|
|
@@ -15128,16 +15356,17 @@ function ListBoxInline(_ref3) {
|
|
|
15128
15356
|
if ((layout === null || layout === void 0 ? void 0 : layout.toolbar) !== undefined) {
|
|
15129
15357
|
toolbar = layout.toolbar;
|
|
15130
15358
|
}
|
|
15359
|
+
toolbar = toolbar && (layout === null || layout === void 0 ? void 0 : layout.title) !== '';
|
|
15131
15360
|
useEffect$1(() => {
|
|
15132
15361
|
const show = () => {
|
|
15133
15362
|
setShowToolbar(true);
|
|
15134
|
-
if (search === '
|
|
15363
|
+
if (search === 'toggle' && toolbar === false) {
|
|
15135
15364
|
setShowSearch(true);
|
|
15136
15365
|
}
|
|
15137
15366
|
};
|
|
15138
15367
|
const hide = () => {
|
|
15139
15368
|
setShowToolbar(false);
|
|
15140
|
-
if (search === 'toggle'
|
|
15369
|
+
if (search === 'toggle') {
|
|
15141
15370
|
setShowSearch(false);
|
|
15142
15371
|
}
|
|
15143
15372
|
};
|
|
@@ -15154,7 +15383,7 @@ function ListBoxInline(_ref3) {
|
|
|
15154
15383
|
selections.removeListener('activated', hide);
|
|
15155
15384
|
}
|
|
15156
15385
|
};
|
|
15157
|
-
}, [selections]);
|
|
15386
|
+
}, [selections, toolbar]);
|
|
15158
15387
|
useEffect$1(() => {
|
|
15159
15388
|
if (!searchContainer || !searchContainer.current) {
|
|
15160
15389
|
return;
|
|
@@ -15174,7 +15403,8 @@ function ListBoxInline(_ref3) {
|
|
|
15174
15403
|
model,
|
|
15175
15404
|
translator
|
|
15176
15405
|
}) : [];
|
|
15177
|
-
const
|
|
15406
|
+
const showSearchToggle = search === 'toggle' && showSearch;
|
|
15407
|
+
const searchVisible = (search === true || showSearchToggle) && !selectDisabled();
|
|
15178
15408
|
const dense = (_layout$layoutOptions = (_layout$layoutOptions2 = layout.layoutOptions) === null || _layout$layoutOptions2 === void 0 ? void 0 : _layout$layoutOptions2.dense) !== null && _layout$layoutOptions !== void 0 ? _layout$layoutOptions : false;
|
|
15179
15409
|
const searchHeight = dense ? 27 : 40;
|
|
15180
15410
|
const extraheight = dense ? 39 : 49;
|
|
@@ -15187,6 +15417,7 @@ function ListBoxInline(_ref3) {
|
|
|
15187
15417
|
const newValue = !showSearch;
|
|
15188
15418
|
setShowSearch(newValue);
|
|
15189
15419
|
};
|
|
15420
|
+
const shouldAutoFocus = searchVisible && search === 'toggle';
|
|
15190
15421
|
return /*#__PURE__*/React__default.createElement(StyledGrid$3, {
|
|
15191
15422
|
className: "listbox-container",
|
|
15192
15423
|
container: true,
|
|
@@ -15198,18 +15429,27 @@ function ListBoxInline(_ref3) {
|
|
|
15198
15429
|
minHeight: "".concat(minHeight, "px"),
|
|
15199
15430
|
flexFlow: 'column nowrap'
|
|
15200
15431
|
},
|
|
15201
|
-
onKeyDown: handleKeyDown
|
|
15202
|
-
|
|
15432
|
+
onKeyDown: handleKeyDown,
|
|
15433
|
+
onMouseEnter: handleOnMouseEnter,
|
|
15434
|
+
onMouseLeave: handleOnMouseLeave,
|
|
15435
|
+
ref: containerRef
|
|
15436
|
+
}, toolbar && /*#__PURE__*/React__default.createElement(Grid, {
|
|
15203
15437
|
item: true,
|
|
15204
15438
|
container: true,
|
|
15205
15439
|
style: {
|
|
15206
15440
|
padding: theme.spacing(1)
|
|
15207
|
-
}
|
|
15441
|
+
},
|
|
15442
|
+
wrap: "nowrap"
|
|
15443
|
+
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
15444
|
+
item: true,
|
|
15445
|
+
container: true,
|
|
15446
|
+
wrap: "nowrap"
|
|
15208
15447
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
15209
15448
|
item: true,
|
|
15210
15449
|
sx: {
|
|
15211
15450
|
display: 'flex',
|
|
15212
|
-
alignItems: 'center'
|
|
15451
|
+
alignItems: 'center',
|
|
15452
|
+
width: searchIconWidth
|
|
15213
15453
|
}
|
|
15214
15454
|
}, isLocked ? /*#__PURE__*/React__default.createElement(IconButton, {
|
|
15215
15455
|
tabIndex: -1,
|
|
@@ -15236,7 +15476,7 @@ function ListBoxInline(_ref3) {
|
|
|
15236
15476
|
}, /*#__PURE__*/React__default.createElement(Title, {
|
|
15237
15477
|
variant: "h6",
|
|
15238
15478
|
noWrap: true
|
|
15239
|
-
}, layout.title)), /*#__PURE__*/React__default.createElement(Grid, {
|
|
15479
|
+
}, layout.title))), /*#__PURE__*/React__default.createElement(Grid, {
|
|
15240
15480
|
item: true,
|
|
15241
15481
|
xs: true
|
|
15242
15482
|
}), /*#__PURE__*/React__default.createElement(Grid, {
|
|
@@ -15270,7 +15510,9 @@ function ListBoxInline(_ref3) {
|
|
|
15270
15510
|
},
|
|
15271
15511
|
role: "region",
|
|
15272
15512
|
"aria-label": translator.get('Listbox.ResultFilterLabel')
|
|
15273
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
15513
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
15514
|
+
ref: moreAlignTo
|
|
15515
|
+
}), /*#__PURE__*/React__default.createElement(Grid, {
|
|
15274
15516
|
item: true,
|
|
15275
15517
|
ref: searchContainerRef
|
|
15276
15518
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -15281,6 +15523,8 @@ function ListBoxInline(_ref3) {
|
|
|
15281
15523
|
dense: dense,
|
|
15282
15524
|
keyboard: keyboard,
|
|
15283
15525
|
visible: searchVisible,
|
|
15526
|
+
search: search,
|
|
15527
|
+
autoFocus: shouldAutoFocus,
|
|
15284
15528
|
searchContainerRef: searchContainerRef,
|
|
15285
15529
|
wildCardSearch: wildCardSearch,
|
|
15286
15530
|
searchEnabled: searchEnabled
|
|
@@ -15288,8 +15532,6 @@ function ListBoxInline(_ref3) {
|
|
|
15288
15532
|
item: true,
|
|
15289
15533
|
xs: true
|
|
15290
15534
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
15291
|
-
ref: moreAlignTo
|
|
15292
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
15293
15535
|
className: classes$4.screenReaderOnly
|
|
15294
15536
|
}, translator.get('Listbox.ScreenReaderInstructions')), /*#__PURE__*/React__default.createElement(AutoSizer, null, _ref4 => {
|
|
15295
15537
|
let {
|
|
@@ -15313,7 +15555,19 @@ function ListBoxInline(_ref3) {
|
|
|
15313
15555
|
selectDisabled: selectDisabled,
|
|
15314
15556
|
keyboard: keyboard,
|
|
15315
15557
|
showGray: showGray,
|
|
15316
|
-
scrollState: scrollState
|
|
15558
|
+
scrollState: scrollState,
|
|
15559
|
+
keyScroll: {
|
|
15560
|
+
state: keyScroll,
|
|
15561
|
+
reset: () => setKeyScroll({
|
|
15562
|
+
up: 0,
|
|
15563
|
+
down: 0,
|
|
15564
|
+
scrollPosition: ''
|
|
15565
|
+
})
|
|
15566
|
+
},
|
|
15567
|
+
currentScrollIndex: {
|
|
15568
|
+
state: currentScrollIndex,
|
|
15569
|
+
set: setCurrentScrollIndex
|
|
15570
|
+
}
|
|
15317
15571
|
});
|
|
15318
15572
|
}))));
|
|
15319
15573
|
}
|
|
@@ -15356,6 +15610,7 @@ function useExistingModel(_ref) {
|
|
|
15356
15610
|
}
|
|
15357
15611
|
|
|
15358
15612
|
function useOnTheFlyModel(_ref) {
|
|
15613
|
+
var _options$title;
|
|
15359
15614
|
let {
|
|
15360
15615
|
app,
|
|
15361
15616
|
fieldIdentifier,
|
|
@@ -15365,11 +15620,14 @@ function useOnTheFlyModel(_ref) {
|
|
|
15365
15620
|
const [fieldDef, setFieldDef] = useState$1('');
|
|
15366
15621
|
const [isFetching, setIsFetching] = useState$1(true);
|
|
15367
15622
|
const [model, setModel] = useState$1();
|
|
15623
|
+
const [fallbackTitle, setFallbackTitle] = useState$1();
|
|
15624
|
+
const title = (_options$title = options.title) !== null && _options$title !== void 0 ? _options$title : fallbackTitle;
|
|
15368
15625
|
useEffect$1(() => {
|
|
15369
15626
|
async function fetchMasterItem() {
|
|
15370
15627
|
try {
|
|
15371
15628
|
const dim = await app.getDimension(fieldIdentifier.qLibraryId);
|
|
15372
15629
|
const dimLayout = await dim.getLayout();
|
|
15630
|
+
setFallbackTitle(dimLayout.qDim.title);
|
|
15373
15631
|
setFieldDef(dimLayout.qDim.qFieldDefs ? dimLayout.qDim.qFieldDefs[0] : '');
|
|
15374
15632
|
setIsFetching(false);
|
|
15375
15633
|
} catch (e) {
|
|
@@ -15386,10 +15644,10 @@ function useOnTheFlyModel(_ref) {
|
|
|
15386
15644
|
fetchMasterItem();
|
|
15387
15645
|
} else {
|
|
15388
15646
|
setIsFetching(false);
|
|
15647
|
+
setFallbackTitle(fieldIdentifier);
|
|
15389
15648
|
}
|
|
15390
15649
|
}, []);
|
|
15391
15650
|
const {
|
|
15392
|
-
title,
|
|
15393
15651
|
dense,
|
|
15394
15652
|
checkboxes,
|
|
15395
15653
|
properties = {}
|
|
@@ -15420,9 +15678,14 @@ function useOnTheFlyModel(_ref) {
|
|
|
15420
15678
|
break;
|
|
15421
15679
|
}
|
|
15422
15680
|
const getListdefFrequencyMode = () => histogram && frequencyMode === 'N' ? 'V' : frequencyMode;
|
|
15681
|
+
const id = useRef();
|
|
15682
|
+
if (!id.current) {
|
|
15683
|
+
id.current = uid();
|
|
15684
|
+
}
|
|
15423
15685
|
const listdef = {
|
|
15424
15686
|
qInfo: {
|
|
15425
|
-
qType: 'njsListbox'
|
|
15687
|
+
qType: 'njsListbox',
|
|
15688
|
+
qId: id.current
|
|
15426
15689
|
},
|
|
15427
15690
|
qListObjectDef: {
|
|
15428
15691
|
qStateName: stateName,
|
|
@@ -15575,7 +15838,8 @@ function ListBoxWrapper(_ref) {
|
|
|
15575
15838
|
}
|
|
15576
15839
|
const opts = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
15577
15840
|
selections,
|
|
15578
|
-
model
|
|
15841
|
+
model,
|
|
15842
|
+
app
|
|
15579
15843
|
});
|
|
15580
15844
|
return /*#__PURE__*/React__default.createElement(ListBoxInline, {
|
|
15581
15845
|
options: opts
|
|
@@ -15642,7 +15906,8 @@ function ListBoxPopoverWrapper(_ref) {
|
|
|
15642
15906
|
transformOrigin: options.transformOrigin,
|
|
15643
15907
|
close: handleCloseShowState,
|
|
15644
15908
|
fieldName: fieldIdentifier,
|
|
15645
|
-
stateName: stateName
|
|
15909
|
+
stateName: stateName,
|
|
15910
|
+
autoFocus: options.autoFocus
|
|
15646
15911
|
});
|
|
15647
15912
|
}
|
|
15648
15913
|
|
|
@@ -17560,7 +17825,7 @@ const validateTarget = (translator, layout, properties, def) => {
|
|
|
17560
17825
|
const minD = def.dimensions.min();
|
|
17561
17826
|
const minM = def.measures.min();
|
|
17562
17827
|
const c = def.resolveLayout(layout);
|
|
17563
|
-
const reqDimErrors = validateInfo(minD, getInfo(c.qDimensionInfo), i => def.dimensions.description(properties, i), translator.get('Visualization.Invalid.Dimension'), translator.get('Visualization.UnfulfilledCalculationCondition'));
|
|
17828
|
+
const reqDimErrors = validateInfo(minD, getInfo(c.qDimensionInfo || c.qItems), i => def.dimensions.description(properties, i), translator.get('Visualization.Invalid.Dimension'), translator.get('Visualization.UnfulfilledCalculationCondition'));
|
|
17564
17829
|
const reqMeasErrors = validateInfo(minM, getInfo(c.qMeasureInfo), i => def.measures.description(properties, i), translator.get('Visualization.Invalid.Measure'), translator.get('Visualization.UnfulfilledCalculationCondition'));
|
|
17565
17830
|
return {
|
|
17566
17831
|
reqDimErrors,
|
|
@@ -17579,7 +17844,7 @@ const validateCubes = (translator, targets, layout) => {
|
|
|
17579
17844
|
const minD = def.dimensions.min();
|
|
17580
17845
|
const minM = def.measures.min();
|
|
17581
17846
|
const c = def.resolveLayout(layout);
|
|
17582
|
-
const d = getInfo(c.qDimensionInfo).filter(filterData); // Filter out optional calc conditions
|
|
17847
|
+
const d = getInfo(c.qDimensionInfo || c.qItems).filter(filterData); // Filter out optional calc conditions
|
|
17583
17848
|
const m = getInfo(c.qMeasureInfo).filter(filterData); // Filter out optional calc conditions
|
|
17584
17849
|
aggMinD += minD;
|
|
17585
17850
|
aggMinM += minM;
|
|
@@ -20786,9 +21051,9 @@ const resolveValue = (data, reference, defaultValue) => {
|
|
|
20786
21051
|
function target(def) {
|
|
20787
21052
|
const propertyPath = def.path || '/qHyperCubeDef';
|
|
20788
21053
|
const layoutPath = propertyPath.slice(0, -3);
|
|
20789
|
-
if (/\/(qHyperCube|qListObject)$/.test(layoutPath) === false) {
|
|
21054
|
+
if (/\/(qHyperCube|qListObject|qChildList)$/.test(layoutPath) === false) {
|
|
20790
21055
|
const d = layoutPath.includes('/qHyperCube') ? 'qHyperCubeDef' : 'qListObjectDef';
|
|
20791
|
-
throw new Error("Incorrect definition for ".concat(d, " at ").concat(propertyPath, ". Valid paths include /qHyperCubeDef or /
|
|
21056
|
+
throw new Error("Incorrect definition for ".concat(d, " at ").concat(propertyPath, ". Valid paths include /qHyperCubeDef, /qListObjectDef, or /qChildListDef, e.g. data/qHyperCubeDef"));
|
|
20792
21057
|
}
|
|
20793
21058
|
return {
|
|
20794
21059
|
propertyPath,
|
|
@@ -20908,1350 +21173,1603 @@ var semver = {
|
|
|
20908
21173
|
};
|
|
20909
21174
|
|
|
20910
21175
|
(function (module, exports) {
|
|
20911
|
-
|
|
20912
|
-
|
|
20913
|
-
|
|
20914
|
-
|
|
20915
|
-
|
|
20916
|
-
|
|
20917
|
-
|
|
20918
|
-
|
|
20919
|
-
|
|
20920
|
-
|
|
20921
|
-
|
|
20922
|
-
|
|
21176
|
+
exports = module.exports = SemVer;
|
|
21177
|
+
|
|
21178
|
+
var debug;
|
|
21179
|
+
/* istanbul ignore next */
|
|
21180
|
+
if (typeof process === 'object' &&
|
|
21181
|
+
process.env &&
|
|
21182
|
+
process.env.NODE_DEBUG &&
|
|
21183
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
21184
|
+
debug = function () {
|
|
21185
|
+
var args = Array.prototype.slice.call(arguments, 0);
|
|
21186
|
+
args.unshift('SEMVER');
|
|
21187
|
+
console.log.apply(console, args);
|
|
21188
|
+
};
|
|
21189
|
+
} else {
|
|
21190
|
+
debug = function () {};
|
|
21191
|
+
}
|
|
20923
21192
|
|
|
20924
|
-
|
|
20925
|
-
|
|
20926
|
-
|
|
20927
|
-
var MAX_LENGTH = 256;
|
|
20928
|
-
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */9007199254740991;
|
|
20929
|
-
|
|
20930
|
-
// Max safe segment length for coercion.
|
|
20931
|
-
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
20932
|
-
|
|
20933
|
-
// The actual regexps go on exports.re
|
|
20934
|
-
var re = exports.re = [];
|
|
20935
|
-
var src = exports.src = [];
|
|
20936
|
-
var t = exports.tokens = {};
|
|
20937
|
-
var R = 0;
|
|
20938
|
-
function tok(n) {
|
|
20939
|
-
t[n] = R++;
|
|
20940
|
-
}
|
|
20941
|
-
|
|
20942
|
-
// The following Regular Expressions can be used for tokenizing,
|
|
20943
|
-
// validating, and parsing SemVer version strings.
|
|
20944
|
-
|
|
20945
|
-
// ## Numeric Identifier
|
|
20946
|
-
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
20947
|
-
|
|
20948
|
-
tok('NUMERICIDENTIFIER');
|
|
20949
|
-
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
|
|
20950
|
-
tok('NUMERICIDENTIFIERLOOSE');
|
|
20951
|
-
src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
|
|
20952
|
-
|
|
20953
|
-
// ## Non-numeric Identifier
|
|
20954
|
-
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
20955
|
-
// more letters, digits, or hyphens.
|
|
20956
|
-
|
|
20957
|
-
tok('NONNUMERICIDENTIFIER');
|
|
20958
|
-
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
|
|
20959
|
-
|
|
20960
|
-
// ## Main Version
|
|
20961
|
-
// Three dot-separated numeric identifiers.
|
|
20962
|
-
|
|
20963
|
-
tok('MAINVERSION');
|
|
20964
|
-
src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')';
|
|
20965
|
-
tok('MAINVERSIONLOOSE');
|
|
20966
|
-
src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
|
|
20967
|
-
|
|
20968
|
-
// ## Pre-release Version Identifier
|
|
20969
|
-
// A numeric identifier, or a non-numeric identifier.
|
|
20970
|
-
|
|
20971
|
-
tok('PRERELEASEIDENTIFIER');
|
|
20972
|
-
src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + '|' + src[t.NONNUMERICIDENTIFIER] + ')';
|
|
20973
|
-
tok('PRERELEASEIDENTIFIERLOOSE');
|
|
20974
|
-
src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + '|' + src[t.NONNUMERICIDENTIFIER] + ')';
|
|
20975
|
-
|
|
20976
|
-
// ## Pre-release Version
|
|
20977
|
-
// Hyphen, followed by one or more dot-separated pre-release version
|
|
20978
|
-
// identifiers.
|
|
20979
|
-
|
|
20980
|
-
tok('PRERELEASE');
|
|
20981
|
-
src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
|
|
20982
|
-
tok('PRERELEASELOOSE');
|
|
20983
|
-
src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
|
|
20984
|
-
|
|
20985
|
-
// ## Build Metadata Identifier
|
|
20986
|
-
// Any combination of digits, letters, or hyphens.
|
|
20987
|
-
|
|
20988
|
-
tok('BUILDIDENTIFIER');
|
|
20989
|
-
src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
|
|
20990
|
-
|
|
20991
|
-
// ## Build Metadata
|
|
20992
|
-
// Plus sign, followed by one or more period-separated build metadata
|
|
20993
|
-
// identifiers.
|
|
20994
|
-
|
|
20995
|
-
tok('BUILD');
|
|
20996
|
-
src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
|
|
20997
|
-
|
|
20998
|
-
// ## Full Version String
|
|
20999
|
-
// A main version, followed optionally by a pre-release version and
|
|
21000
|
-
// build metadata.
|
|
21001
|
-
|
|
21002
|
-
// Note that the only major, minor, patch, and pre-release sections of
|
|
21003
|
-
// the version string are capturing groups. The build metadata is not a
|
|
21004
|
-
// capturing group, because it should not ever be used in version
|
|
21005
|
-
// comparison.
|
|
21006
|
-
|
|
21007
|
-
tok('FULL');
|
|
21008
|
-
tok('FULLPLAIN');
|
|
21009
|
-
src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + src[t.PRERELEASE] + '?' + src[t.BUILD] + '?';
|
|
21010
|
-
src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
|
|
21011
|
-
|
|
21012
|
-
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
21013
|
-
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
21014
|
-
// common in the npm registry.
|
|
21015
|
-
tok('LOOSEPLAIN');
|
|
21016
|
-
src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + '?' + src[t.BUILD] + '?';
|
|
21017
|
-
tok('LOOSE');
|
|
21018
|
-
src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
|
|
21019
|
-
tok('GTLT');
|
|
21020
|
-
src[t.GTLT] = '((?:<|>)?=?)';
|
|
21021
|
-
|
|
21022
|
-
// Something like "2.*" or "1.2.x".
|
|
21023
|
-
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
21024
|
-
// Only the first item is strictly required.
|
|
21025
|
-
tok('XRANGEIDENTIFIERLOOSE');
|
|
21026
|
-
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
|
|
21027
|
-
tok('XRANGEIDENTIFIER');
|
|
21028
|
-
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
|
|
21029
|
-
tok('XRANGEPLAIN');
|
|
21030
|
-
src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:' + src[t.PRERELEASE] + ')?' + src[t.BUILD] + '?' + ')?)?';
|
|
21031
|
-
tok('XRANGEPLAINLOOSE');
|
|
21032
|
-
src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[t.PRERELEASELOOSE] + ')?' + src[t.BUILD] + '?' + ')?)?';
|
|
21033
|
-
tok('XRANGE');
|
|
21034
|
-
src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
|
|
21035
|
-
tok('XRANGELOOSE');
|
|
21036
|
-
src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
|
|
21037
|
-
|
|
21038
|
-
// Coercion.
|
|
21039
|
-
// Extract anything that could conceivably be a part of a valid semver
|
|
21040
|
-
tok('COERCE');
|
|
21041
|
-
src[t.COERCE] = '(^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])';
|
|
21042
|
-
tok('COERCERTL');
|
|
21043
|
-
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
|
|
21044
|
-
|
|
21045
|
-
// Tilde ranges.
|
|
21046
|
-
// Meaning is "reasonably at or greater than"
|
|
21047
|
-
tok('LONETILDE');
|
|
21048
|
-
src[t.LONETILDE] = '(?:~>?)';
|
|
21049
|
-
tok('TILDETRIM');
|
|
21050
|
-
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
|
|
21051
|
-
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
|
|
21052
|
-
var tildeTrimReplace = '$1~';
|
|
21053
|
-
tok('TILDE');
|
|
21054
|
-
src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
|
|
21055
|
-
tok('TILDELOOSE');
|
|
21056
|
-
src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
|
|
21057
|
-
|
|
21058
|
-
// Caret ranges.
|
|
21059
|
-
// Meaning is "at least and backwards compatible with"
|
|
21060
|
-
tok('LONECARET');
|
|
21061
|
-
src[t.LONECARET] = '(?:\\^)';
|
|
21062
|
-
tok('CARETTRIM');
|
|
21063
|
-
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
|
|
21064
|
-
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
|
|
21065
|
-
var caretTrimReplace = '$1^';
|
|
21066
|
-
tok('CARET');
|
|
21067
|
-
src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
|
|
21068
|
-
tok('CARETLOOSE');
|
|
21069
|
-
src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
|
|
21070
|
-
|
|
21071
|
-
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
21072
|
-
tok('COMPARATORLOOSE');
|
|
21073
|
-
src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
|
|
21074
|
-
tok('COMPARATOR');
|
|
21075
|
-
src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
|
|
21076
|
-
|
|
21077
|
-
// An expression to strip any whitespace between the gtlt and the thing
|
|
21078
|
-
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
21079
|
-
tok('COMPARATORTRIM');
|
|
21080
|
-
src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
|
|
21081
|
-
|
|
21082
|
-
// this one has to use the /g flag
|
|
21083
|
-
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
|
|
21084
|
-
var comparatorTrimReplace = '$1$2$3';
|
|
21085
|
-
|
|
21086
|
-
// Something like `1.2.3 - 1.2.4`
|
|
21087
|
-
// Note that these all use the loose form, because they'll be
|
|
21088
|
-
// checked against either the strict or loose comparator form
|
|
21089
|
-
// later.
|
|
21090
|
-
tok('HYPHENRANGE');
|
|
21091
|
-
src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAIN] + ')' + '\\s*$';
|
|
21092
|
-
tok('HYPHENRANGELOOSE');
|
|
21093
|
-
src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s*$';
|
|
21094
|
-
|
|
21095
|
-
// Star ranges basically just allow anything at all.
|
|
21096
|
-
tok('STAR');
|
|
21097
|
-
src[t.STAR] = '(<|>)?=?\\s*\\*';
|
|
21098
|
-
|
|
21099
|
-
// Compile to actual regexp objects.
|
|
21100
|
-
// All are flag-free, unless they were created above with a flag.
|
|
21101
|
-
for (var i = 0; i < R; i++) {
|
|
21102
|
-
debug(i, src[i]);
|
|
21103
|
-
if (!re[i]) {
|
|
21104
|
-
re[i] = new RegExp(src[i]);
|
|
21105
|
-
}
|
|
21106
|
-
}
|
|
21107
|
-
exports.parse = parse;
|
|
21108
|
-
function parse(version, options) {
|
|
21109
|
-
if (!options || typeof options !== 'object') {
|
|
21110
|
-
options = {
|
|
21111
|
-
loose: !!options,
|
|
21112
|
-
includePrerelease: false
|
|
21113
|
-
};
|
|
21114
|
-
}
|
|
21115
|
-
if (version instanceof SemVer) {
|
|
21116
|
-
return version;
|
|
21117
|
-
}
|
|
21118
|
-
if (typeof version !== 'string') {
|
|
21119
|
-
return null;
|
|
21120
|
-
}
|
|
21121
|
-
if (version.length > MAX_LENGTH) {
|
|
21122
|
-
return null;
|
|
21123
|
-
}
|
|
21124
|
-
var r = options.loose ? re[t.LOOSE] : re[t.FULL];
|
|
21125
|
-
if (!r.test(version)) {
|
|
21126
|
-
return null;
|
|
21127
|
-
}
|
|
21128
|
-
try {
|
|
21129
|
-
return new SemVer(version, options);
|
|
21130
|
-
} catch (er) {
|
|
21131
|
-
return null;
|
|
21132
|
-
}
|
|
21133
|
-
}
|
|
21134
|
-
exports.valid = valid;
|
|
21135
|
-
function valid(version, options) {
|
|
21136
|
-
var v = parse(version, options);
|
|
21137
|
-
return v ? v.version : null;
|
|
21138
|
-
}
|
|
21139
|
-
exports.clean = clean;
|
|
21140
|
-
function clean(version, options) {
|
|
21141
|
-
var s = parse(version.trim().replace(/^[=v]+/, ''), options);
|
|
21142
|
-
return s ? s.version : null;
|
|
21143
|
-
}
|
|
21144
|
-
exports.SemVer = SemVer;
|
|
21145
|
-
function SemVer(version, options) {
|
|
21146
|
-
if (!options || typeof options !== 'object') {
|
|
21147
|
-
options = {
|
|
21148
|
-
loose: !!options,
|
|
21149
|
-
includePrerelease: false
|
|
21150
|
-
};
|
|
21151
|
-
}
|
|
21152
|
-
if (version instanceof SemVer) {
|
|
21153
|
-
if (version.loose === options.loose) {
|
|
21154
|
-
return version;
|
|
21155
|
-
} else {
|
|
21156
|
-
version = version.version;
|
|
21157
|
-
}
|
|
21158
|
-
} else if (typeof version !== 'string') {
|
|
21159
|
-
throw new TypeError('Invalid Version: ' + version);
|
|
21160
|
-
}
|
|
21161
|
-
if (version.length > MAX_LENGTH) {
|
|
21162
|
-
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
|
|
21163
|
-
}
|
|
21164
|
-
if (!(this instanceof SemVer)) {
|
|
21165
|
-
return new SemVer(version, options);
|
|
21166
|
-
}
|
|
21167
|
-
debug('SemVer', version, options);
|
|
21168
|
-
this.options = options;
|
|
21169
|
-
this.loose = !!options.loose;
|
|
21170
|
-
var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
21171
|
-
if (!m) {
|
|
21172
|
-
throw new TypeError('Invalid Version: ' + version);
|
|
21173
|
-
}
|
|
21174
|
-
this.raw = version;
|
|
21193
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
21194
|
+
// Not necessarily the package version of this code.
|
|
21195
|
+
exports.SEMVER_SPEC_VERSION = '2.0.0';
|
|
21175
21196
|
|
|
21176
|
-
|
|
21177
|
-
|
|
21178
|
-
|
|
21179
|
-
this.patch = +m[3];
|
|
21180
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
21181
|
-
throw new TypeError('Invalid major version');
|
|
21182
|
-
}
|
|
21183
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
21184
|
-
throw new TypeError('Invalid minor version');
|
|
21185
|
-
}
|
|
21186
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
21187
|
-
throw new TypeError('Invalid patch version');
|
|
21188
|
-
}
|
|
21197
|
+
var MAX_LENGTH = 256;
|
|
21198
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
21199
|
+
/* istanbul ignore next */ 9007199254740991;
|
|
21189
21200
|
|
|
21190
|
-
|
|
21191
|
-
|
|
21192
|
-
this.prerelease = [];
|
|
21193
|
-
} else {
|
|
21194
|
-
this.prerelease = m[4].split('.').map(function (id) {
|
|
21195
|
-
if (/^[0-9]+$/.test(id)) {
|
|
21196
|
-
var num = +id;
|
|
21197
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
21198
|
-
return num;
|
|
21199
|
-
}
|
|
21200
|
-
}
|
|
21201
|
-
return id;
|
|
21202
|
-
});
|
|
21203
|
-
}
|
|
21204
|
-
this.build = m[5] ? m[5].split('.') : [];
|
|
21205
|
-
this.format();
|
|
21206
|
-
}
|
|
21207
|
-
SemVer.prototype.format = function () {
|
|
21208
|
-
this.version = this.major + '.' + this.minor + '.' + this.patch;
|
|
21209
|
-
if (this.prerelease.length) {
|
|
21210
|
-
this.version += '-' + this.prerelease.join('.');
|
|
21211
|
-
}
|
|
21212
|
-
return this.version;
|
|
21213
|
-
};
|
|
21214
|
-
SemVer.prototype.toString = function () {
|
|
21215
|
-
return this.version;
|
|
21216
|
-
};
|
|
21217
|
-
SemVer.prototype.compare = function (other) {
|
|
21218
|
-
debug('SemVer.compare', this.version, this.options, other);
|
|
21219
|
-
if (!(other instanceof SemVer)) {
|
|
21220
|
-
other = new SemVer(other, this.options);
|
|
21221
|
-
}
|
|
21222
|
-
return this.compareMain(other) || this.comparePre(other);
|
|
21223
|
-
};
|
|
21224
|
-
SemVer.prototype.compareMain = function (other) {
|
|
21225
|
-
if (!(other instanceof SemVer)) {
|
|
21226
|
-
other = new SemVer(other, this.options);
|
|
21227
|
-
}
|
|
21228
|
-
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
|
|
21229
|
-
};
|
|
21230
|
-
SemVer.prototype.comparePre = function (other) {
|
|
21231
|
-
if (!(other instanceof SemVer)) {
|
|
21232
|
-
other = new SemVer(other, this.options);
|
|
21233
|
-
}
|
|
21234
|
-
|
|
21235
|
-
// NOT having a prerelease is > having one
|
|
21236
|
-
if (this.prerelease.length && !other.prerelease.length) {
|
|
21237
|
-
return -1;
|
|
21238
|
-
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
21239
|
-
return 1;
|
|
21240
|
-
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
21241
|
-
return 0;
|
|
21242
|
-
}
|
|
21243
|
-
var i = 0;
|
|
21244
|
-
do {
|
|
21245
|
-
var a = this.prerelease[i];
|
|
21246
|
-
var b = other.prerelease[i];
|
|
21247
|
-
debug('prerelease compare', i, a, b);
|
|
21248
|
-
if (a === undefined && b === undefined) {
|
|
21249
|
-
return 0;
|
|
21250
|
-
} else if (b === undefined) {
|
|
21251
|
-
return 1;
|
|
21252
|
-
} else if (a === undefined) {
|
|
21253
|
-
return -1;
|
|
21254
|
-
} else if (a === b) {
|
|
21255
|
-
continue;
|
|
21256
|
-
} else {
|
|
21257
|
-
return compareIdentifiers(a, b);
|
|
21258
|
-
}
|
|
21259
|
-
} while (++i);
|
|
21260
|
-
};
|
|
21261
|
-
SemVer.prototype.compareBuild = function (other) {
|
|
21262
|
-
if (!(other instanceof SemVer)) {
|
|
21263
|
-
other = new SemVer(other, this.options);
|
|
21264
|
-
}
|
|
21265
|
-
var i = 0;
|
|
21266
|
-
do {
|
|
21267
|
-
var a = this.build[i];
|
|
21268
|
-
var b = other.build[i];
|
|
21269
|
-
debug('prerelease compare', i, a, b);
|
|
21270
|
-
if (a === undefined && b === undefined) {
|
|
21271
|
-
return 0;
|
|
21272
|
-
} else if (b === undefined) {
|
|
21273
|
-
return 1;
|
|
21274
|
-
} else if (a === undefined) {
|
|
21275
|
-
return -1;
|
|
21276
|
-
} else if (a === b) {
|
|
21277
|
-
continue;
|
|
21278
|
-
} else {
|
|
21279
|
-
return compareIdentifiers(a, b);
|
|
21280
|
-
}
|
|
21281
|
-
} while (++i);
|
|
21282
|
-
};
|
|
21201
|
+
// Max safe segment length for coercion.
|
|
21202
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
21283
21203
|
|
|
21284
|
-
|
|
21285
|
-
|
|
21286
|
-
|
|
21287
|
-
|
|
21288
|
-
|
|
21289
|
-
this.prerelease.length = 0;
|
|
21290
|
-
this.patch = 0;
|
|
21291
|
-
this.minor = 0;
|
|
21292
|
-
this.major++;
|
|
21293
|
-
this.inc('pre', identifier);
|
|
21294
|
-
break;
|
|
21295
|
-
case 'preminor':
|
|
21296
|
-
this.prerelease.length = 0;
|
|
21297
|
-
this.patch = 0;
|
|
21298
|
-
this.minor++;
|
|
21299
|
-
this.inc('pre', identifier);
|
|
21300
|
-
break;
|
|
21301
|
-
case 'prepatch':
|
|
21302
|
-
// If this is already a prerelease, it will bump to the next version
|
|
21303
|
-
// drop any prereleases that might already exist, since they are not
|
|
21304
|
-
// relevant at this point.
|
|
21305
|
-
this.prerelease.length = 0;
|
|
21306
|
-
this.inc('patch', identifier);
|
|
21307
|
-
this.inc('pre', identifier);
|
|
21308
|
-
break;
|
|
21309
|
-
// If the input is a non-prerelease version, this acts the same as
|
|
21310
|
-
// prepatch.
|
|
21311
|
-
case 'prerelease':
|
|
21312
|
-
if (this.prerelease.length === 0) {
|
|
21313
|
-
this.inc('patch', identifier);
|
|
21314
|
-
}
|
|
21315
|
-
this.inc('pre', identifier);
|
|
21316
|
-
break;
|
|
21317
|
-
case 'major':
|
|
21318
|
-
// If this is a pre-major version, bump up to the same major version.
|
|
21319
|
-
// Otherwise increment major.
|
|
21320
|
-
// 1.0.0-5 bumps to 1.0.0
|
|
21321
|
-
// 1.1.0 bumps to 2.0.0
|
|
21322
|
-
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
21323
|
-
this.major++;
|
|
21324
|
-
}
|
|
21325
|
-
this.minor = 0;
|
|
21326
|
-
this.patch = 0;
|
|
21327
|
-
this.prerelease = [];
|
|
21328
|
-
break;
|
|
21329
|
-
case 'minor':
|
|
21330
|
-
// If this is a pre-minor version, bump up to the same minor version.
|
|
21331
|
-
// Otherwise increment minor.
|
|
21332
|
-
// 1.2.0-5 bumps to 1.2.0
|
|
21333
|
-
// 1.2.1 bumps to 1.3.0
|
|
21334
|
-
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
21335
|
-
this.minor++;
|
|
21336
|
-
}
|
|
21337
|
-
this.patch = 0;
|
|
21338
|
-
this.prerelease = [];
|
|
21339
|
-
break;
|
|
21340
|
-
case 'patch':
|
|
21341
|
-
// If this is not a pre-release version, it will increment the patch.
|
|
21342
|
-
// If it is a pre-release it will bump up to the same patch version.
|
|
21343
|
-
// 1.2.0-5 patches to 1.2.0
|
|
21344
|
-
// 1.2.0 patches to 1.2.1
|
|
21345
|
-
if (this.prerelease.length === 0) {
|
|
21346
|
-
this.patch++;
|
|
21347
|
-
}
|
|
21348
|
-
this.prerelease = [];
|
|
21349
|
-
break;
|
|
21350
|
-
// This probably shouldn't be used publicly.
|
|
21351
|
-
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
|
21352
|
-
case 'pre':
|
|
21353
|
-
if (this.prerelease.length === 0) {
|
|
21354
|
-
this.prerelease = [0];
|
|
21355
|
-
} else {
|
|
21356
|
-
var i = this.prerelease.length;
|
|
21357
|
-
while (--i >= 0) {
|
|
21358
|
-
if (typeof this.prerelease[i] === 'number') {
|
|
21359
|
-
this.prerelease[i]++;
|
|
21360
|
-
i = -2;
|
|
21361
|
-
}
|
|
21362
|
-
}
|
|
21363
|
-
if (i === -1) {
|
|
21364
|
-
// didn't increment anything
|
|
21365
|
-
this.prerelease.push(0);
|
|
21366
|
-
}
|
|
21367
|
-
}
|
|
21368
|
-
if (identifier) {
|
|
21369
|
-
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
21370
|
-
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
21371
|
-
if (this.prerelease[0] === identifier) {
|
|
21372
|
-
if (isNaN(this.prerelease[1])) {
|
|
21373
|
-
this.prerelease = [identifier, 0];
|
|
21374
|
-
}
|
|
21375
|
-
} else {
|
|
21376
|
-
this.prerelease = [identifier, 0];
|
|
21377
|
-
}
|
|
21378
|
-
}
|
|
21379
|
-
break;
|
|
21380
|
-
default:
|
|
21381
|
-
throw new Error('invalid increment argument: ' + release);
|
|
21382
|
-
}
|
|
21383
|
-
this.format();
|
|
21384
|
-
this.raw = this.version;
|
|
21385
|
-
return this;
|
|
21386
|
-
};
|
|
21387
|
-
exports.inc = inc;
|
|
21388
|
-
function inc(version, release, loose, identifier) {
|
|
21389
|
-
if (typeof loose === 'string') {
|
|
21390
|
-
identifier = loose;
|
|
21391
|
-
loose = undefined;
|
|
21392
|
-
}
|
|
21393
|
-
try {
|
|
21394
|
-
return new SemVer(version, loose).inc(release, identifier).version;
|
|
21395
|
-
} catch (er) {
|
|
21396
|
-
return null;
|
|
21397
|
-
}
|
|
21398
|
-
}
|
|
21399
|
-
exports.diff = diff;
|
|
21400
|
-
function diff(version1, version2) {
|
|
21401
|
-
if (eq(version1, version2)) {
|
|
21402
|
-
return null;
|
|
21403
|
-
} else {
|
|
21404
|
-
var v1 = parse(version1);
|
|
21405
|
-
var v2 = parse(version2);
|
|
21406
|
-
var prefix = '';
|
|
21407
|
-
if (v1.prerelease.length || v2.prerelease.length) {
|
|
21408
|
-
prefix = 'pre';
|
|
21409
|
-
var defaultResult = 'prerelease';
|
|
21410
|
-
}
|
|
21411
|
-
for (var key in v1) {
|
|
21412
|
-
if (key === 'major' || key === 'minor' || key === 'patch') {
|
|
21413
|
-
if (v1[key] !== v2[key]) {
|
|
21414
|
-
return prefix + key;
|
|
21415
|
-
}
|
|
21416
|
-
}
|
|
21417
|
-
}
|
|
21418
|
-
return defaultResult; // may be undefined
|
|
21419
|
-
}
|
|
21420
|
-
}
|
|
21204
|
+
// The actual regexps go on exports.re
|
|
21205
|
+
var re = exports.re = [];
|
|
21206
|
+
var src = exports.src = [];
|
|
21207
|
+
var t = exports.tokens = {};
|
|
21208
|
+
var R = 0;
|
|
21421
21209
|
|
|
21422
|
-
|
|
21423
|
-
|
|
21424
|
-
|
|
21425
|
-
var anum = numeric.test(a);
|
|
21426
|
-
var bnum = numeric.test(b);
|
|
21427
|
-
if (anum && bnum) {
|
|
21428
|
-
a = +a;
|
|
21429
|
-
b = +b;
|
|
21430
|
-
}
|
|
21431
|
-
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
21432
|
-
}
|
|
21433
|
-
exports.rcompareIdentifiers = rcompareIdentifiers;
|
|
21434
|
-
function rcompareIdentifiers(a, b) {
|
|
21435
|
-
return compareIdentifiers(b, a);
|
|
21436
|
-
}
|
|
21437
|
-
exports.major = major;
|
|
21438
|
-
function major(a, loose) {
|
|
21439
|
-
return new SemVer(a, loose).major;
|
|
21440
|
-
}
|
|
21441
|
-
exports.minor = minor;
|
|
21442
|
-
function minor(a, loose) {
|
|
21443
|
-
return new SemVer(a, loose).minor;
|
|
21444
|
-
}
|
|
21445
|
-
exports.patch = patch;
|
|
21446
|
-
function patch(a, loose) {
|
|
21447
|
-
return new SemVer(a, loose).patch;
|
|
21448
|
-
}
|
|
21449
|
-
exports.compare = compare;
|
|
21450
|
-
function compare(a, b, loose) {
|
|
21451
|
-
return new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
21452
|
-
}
|
|
21453
|
-
exports.compareLoose = compareLoose;
|
|
21454
|
-
function compareLoose(a, b) {
|
|
21455
|
-
return compare(a, b, true);
|
|
21456
|
-
}
|
|
21457
|
-
exports.compareBuild = compareBuild;
|
|
21458
|
-
function compareBuild(a, b, loose) {
|
|
21459
|
-
var versionA = new SemVer(a, loose);
|
|
21460
|
-
var versionB = new SemVer(b, loose);
|
|
21461
|
-
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
21462
|
-
}
|
|
21463
|
-
exports.rcompare = rcompare;
|
|
21464
|
-
function rcompare(a, b, loose) {
|
|
21465
|
-
return compare(b, a, loose);
|
|
21466
|
-
}
|
|
21467
|
-
exports.sort = sort;
|
|
21468
|
-
function sort(list, loose) {
|
|
21469
|
-
return list.sort(function (a, b) {
|
|
21470
|
-
return exports.compareBuild(a, b, loose);
|
|
21471
|
-
});
|
|
21472
|
-
}
|
|
21473
|
-
exports.rsort = rsort;
|
|
21474
|
-
function rsort(list, loose) {
|
|
21475
|
-
return list.sort(function (a, b) {
|
|
21476
|
-
return exports.compareBuild(b, a, loose);
|
|
21477
|
-
});
|
|
21478
|
-
}
|
|
21479
|
-
exports.gt = gt;
|
|
21480
|
-
function gt(a, b, loose) {
|
|
21481
|
-
return compare(a, b, loose) > 0;
|
|
21482
|
-
}
|
|
21483
|
-
exports.lt = lt;
|
|
21484
|
-
function lt(a, b, loose) {
|
|
21485
|
-
return compare(a, b, loose) < 0;
|
|
21486
|
-
}
|
|
21487
|
-
exports.eq = eq;
|
|
21488
|
-
function eq(a, b, loose) {
|
|
21489
|
-
return compare(a, b, loose) === 0;
|
|
21490
|
-
}
|
|
21491
|
-
exports.neq = neq;
|
|
21492
|
-
function neq(a, b, loose) {
|
|
21493
|
-
return compare(a, b, loose) !== 0;
|
|
21494
|
-
}
|
|
21495
|
-
exports.gte = gte;
|
|
21496
|
-
function gte(a, b, loose) {
|
|
21497
|
-
return compare(a, b, loose) >= 0;
|
|
21498
|
-
}
|
|
21499
|
-
exports.lte = lte;
|
|
21500
|
-
function lte(a, b, loose) {
|
|
21501
|
-
return compare(a, b, loose) <= 0;
|
|
21502
|
-
}
|
|
21503
|
-
exports.cmp = cmp;
|
|
21504
|
-
function cmp(a, op, b, loose) {
|
|
21505
|
-
switch (op) {
|
|
21506
|
-
case '===':
|
|
21507
|
-
if (typeof a === 'object') a = a.version;
|
|
21508
|
-
if (typeof b === 'object') b = b.version;
|
|
21509
|
-
return a === b;
|
|
21510
|
-
case '!==':
|
|
21511
|
-
if (typeof a === 'object') a = a.version;
|
|
21512
|
-
if (typeof b === 'object') b = b.version;
|
|
21513
|
-
return a !== b;
|
|
21514
|
-
case '':
|
|
21515
|
-
case '=':
|
|
21516
|
-
case '==':
|
|
21517
|
-
return eq(a, b, loose);
|
|
21518
|
-
case '!=':
|
|
21519
|
-
return neq(a, b, loose);
|
|
21520
|
-
case '>':
|
|
21521
|
-
return gt(a, b, loose);
|
|
21522
|
-
case '>=':
|
|
21523
|
-
return gte(a, b, loose);
|
|
21524
|
-
case '<':
|
|
21525
|
-
return lt(a, b, loose);
|
|
21526
|
-
case '<=':
|
|
21527
|
-
return lte(a, b, loose);
|
|
21528
|
-
default:
|
|
21529
|
-
throw new TypeError('Invalid operator: ' + op);
|
|
21530
|
-
}
|
|
21531
|
-
}
|
|
21532
|
-
exports.Comparator = Comparator;
|
|
21533
|
-
function Comparator(comp, options) {
|
|
21534
|
-
if (!options || typeof options !== 'object') {
|
|
21535
|
-
options = {
|
|
21536
|
-
loose: !!options,
|
|
21537
|
-
includePrerelease: false
|
|
21538
|
-
};
|
|
21539
|
-
}
|
|
21540
|
-
if (comp instanceof Comparator) {
|
|
21541
|
-
if (comp.loose === !!options.loose) {
|
|
21542
|
-
return comp;
|
|
21543
|
-
} else {
|
|
21544
|
-
comp = comp.value;
|
|
21545
|
-
}
|
|
21546
|
-
}
|
|
21547
|
-
if (!(this instanceof Comparator)) {
|
|
21548
|
-
return new Comparator(comp, options);
|
|
21549
|
-
}
|
|
21550
|
-
debug('comparator', comp, options);
|
|
21551
|
-
this.options = options;
|
|
21552
|
-
this.loose = !!options.loose;
|
|
21553
|
-
this.parse(comp);
|
|
21554
|
-
if (this.semver === ANY) {
|
|
21555
|
-
this.value = '';
|
|
21556
|
-
} else {
|
|
21557
|
-
this.value = this.operator + this.semver.version;
|
|
21558
|
-
}
|
|
21559
|
-
debug('comp', this);
|
|
21560
|
-
}
|
|
21561
|
-
var ANY = {};
|
|
21562
|
-
Comparator.prototype.parse = function (comp) {
|
|
21563
|
-
var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
21564
|
-
var m = comp.match(r);
|
|
21565
|
-
if (!m) {
|
|
21566
|
-
throw new TypeError('Invalid comparator: ' + comp);
|
|
21567
|
-
}
|
|
21568
|
-
this.operator = m[1] !== undefined ? m[1] : '';
|
|
21569
|
-
if (this.operator === '=') {
|
|
21570
|
-
this.operator = '';
|
|
21571
|
-
}
|
|
21210
|
+
function tok (n) {
|
|
21211
|
+
t[n] = R++;
|
|
21212
|
+
}
|
|
21572
21213
|
|
|
21573
|
-
|
|
21574
|
-
|
|
21575
|
-
this.semver = ANY;
|
|
21576
|
-
} else {
|
|
21577
|
-
this.semver = new SemVer(m[2], this.options.loose);
|
|
21578
|
-
}
|
|
21579
|
-
};
|
|
21580
|
-
Comparator.prototype.toString = function () {
|
|
21581
|
-
return this.value;
|
|
21582
|
-
};
|
|
21583
|
-
Comparator.prototype.test = function (version) {
|
|
21584
|
-
debug('Comparator.test', version, this.options.loose);
|
|
21585
|
-
if (this.semver === ANY || version === ANY) {
|
|
21586
|
-
return true;
|
|
21587
|
-
}
|
|
21588
|
-
if (typeof version === 'string') {
|
|
21589
|
-
try {
|
|
21590
|
-
version = new SemVer(version, this.options);
|
|
21591
|
-
} catch (er) {
|
|
21592
|
-
return false;
|
|
21593
|
-
}
|
|
21594
|
-
}
|
|
21595
|
-
return cmp(version, this.operator, this.semver, this.options);
|
|
21596
|
-
};
|
|
21597
|
-
Comparator.prototype.intersects = function (comp, options) {
|
|
21598
|
-
if (!(comp instanceof Comparator)) {
|
|
21599
|
-
throw new TypeError('a Comparator is required');
|
|
21600
|
-
}
|
|
21601
|
-
if (!options || typeof options !== 'object') {
|
|
21602
|
-
options = {
|
|
21603
|
-
loose: !!options,
|
|
21604
|
-
includePrerelease: false
|
|
21605
|
-
};
|
|
21606
|
-
}
|
|
21607
|
-
var rangeTmp;
|
|
21608
|
-
if (this.operator === '') {
|
|
21609
|
-
if (this.value === '') {
|
|
21610
|
-
return true;
|
|
21611
|
-
}
|
|
21612
|
-
rangeTmp = new Range(comp.value, options);
|
|
21613
|
-
return satisfies(this.value, rangeTmp, options);
|
|
21614
|
-
} else if (comp.operator === '') {
|
|
21615
|
-
if (comp.value === '') {
|
|
21616
|
-
return true;
|
|
21617
|
-
}
|
|
21618
|
-
rangeTmp = new Range(this.value, options);
|
|
21619
|
-
return satisfies(comp.semver, rangeTmp, options);
|
|
21620
|
-
}
|
|
21621
|
-
var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
|
|
21622
|
-
var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
|
|
21623
|
-
var sameSemVer = this.semver.version === comp.semver.version;
|
|
21624
|
-
var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
|
|
21625
|
-
var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
|
|
21626
|
-
var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
|
|
21627
|
-
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
|
|
21628
|
-
};
|
|
21629
|
-
exports.Range = Range;
|
|
21630
|
-
function Range(range, options) {
|
|
21631
|
-
if (!options || typeof options !== 'object') {
|
|
21632
|
-
options = {
|
|
21633
|
-
loose: !!options,
|
|
21634
|
-
includePrerelease: false
|
|
21635
|
-
};
|
|
21636
|
-
}
|
|
21637
|
-
if (range instanceof Range) {
|
|
21638
|
-
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
21639
|
-
return range;
|
|
21640
|
-
} else {
|
|
21641
|
-
return new Range(range.raw, options);
|
|
21642
|
-
}
|
|
21643
|
-
}
|
|
21644
|
-
if (range instanceof Comparator) {
|
|
21645
|
-
return new Range(range.value, options);
|
|
21646
|
-
}
|
|
21647
|
-
if (!(this instanceof Range)) {
|
|
21648
|
-
return new Range(range, options);
|
|
21649
|
-
}
|
|
21650
|
-
this.options = options;
|
|
21651
|
-
this.loose = !!options.loose;
|
|
21652
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
21214
|
+
// The following Regular Expressions can be used for tokenizing,
|
|
21215
|
+
// validating, and parsing SemVer version strings.
|
|
21653
21216
|
|
|
21654
|
-
|
|
21655
|
-
|
|
21656
|
-
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
|
21657
|
-
return this.parseRange(range.trim());
|
|
21658
|
-
}, this).filter(function (c) {
|
|
21659
|
-
// throw out any that are not relevant for whatever reason
|
|
21660
|
-
return c.length;
|
|
21661
|
-
});
|
|
21662
|
-
if (!this.set.length) {
|
|
21663
|
-
throw new TypeError('Invalid SemVer Range: ' + range);
|
|
21664
|
-
}
|
|
21665
|
-
this.format();
|
|
21666
|
-
}
|
|
21667
|
-
Range.prototype.format = function () {
|
|
21668
|
-
this.range = this.set.map(function (comps) {
|
|
21669
|
-
return comps.join(' ').trim();
|
|
21670
|
-
}).join('||').trim();
|
|
21671
|
-
return this.range;
|
|
21672
|
-
};
|
|
21673
|
-
Range.prototype.toString = function () {
|
|
21674
|
-
return this.range;
|
|
21675
|
-
};
|
|
21676
|
-
Range.prototype.parseRange = function (range) {
|
|
21677
|
-
var loose = this.options.loose;
|
|
21678
|
-
range = range.trim();
|
|
21679
|
-
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
21680
|
-
var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
21681
|
-
range = range.replace(hr, hyphenReplace);
|
|
21682
|
-
debug('hyphen replace', range);
|
|
21683
|
-
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
21684
|
-
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
21685
|
-
debug('comparator trim', range, re[t.COMPARATORTRIM]);
|
|
21686
|
-
|
|
21687
|
-
// `~ 1.2.3` => `~1.2.3`
|
|
21688
|
-
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
21689
|
-
|
|
21690
|
-
// `^ 1.2.3` => `^1.2.3`
|
|
21691
|
-
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
21692
|
-
|
|
21693
|
-
// normalize spaces
|
|
21694
|
-
range = range.split(/\s+/).join(' ');
|
|
21695
|
-
|
|
21696
|
-
// At this point, the range is completely trimmed and
|
|
21697
|
-
// ready to be split into comparators.
|
|
21698
|
-
|
|
21699
|
-
var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
21700
|
-
var set = range.split(' ').map(function (comp) {
|
|
21701
|
-
return parseComparator(comp, this.options);
|
|
21702
|
-
}, this).join(' ').split(/\s+/);
|
|
21703
|
-
if (this.options.loose) {
|
|
21704
|
-
// in loose mode, throw out any that are not valid comparators
|
|
21705
|
-
set = set.filter(function (comp) {
|
|
21706
|
-
return !!comp.match(compRe);
|
|
21707
|
-
});
|
|
21708
|
-
}
|
|
21709
|
-
set = set.map(function (comp) {
|
|
21710
|
-
return new Comparator(comp, this.options);
|
|
21711
|
-
}, this);
|
|
21712
|
-
return set;
|
|
21713
|
-
};
|
|
21714
|
-
Range.prototype.intersects = function (range, options) {
|
|
21715
|
-
if (!(range instanceof Range)) {
|
|
21716
|
-
throw new TypeError('a Range is required');
|
|
21717
|
-
}
|
|
21718
|
-
return this.set.some(function (thisComparators) {
|
|
21719
|
-
return isSatisfiable(thisComparators, options) && range.set.some(function (rangeComparators) {
|
|
21720
|
-
return isSatisfiable(rangeComparators, options) && thisComparators.every(function (thisComparator) {
|
|
21721
|
-
return rangeComparators.every(function (rangeComparator) {
|
|
21722
|
-
return thisComparator.intersects(rangeComparator, options);
|
|
21723
|
-
});
|
|
21724
|
-
});
|
|
21725
|
-
});
|
|
21726
|
-
});
|
|
21727
|
-
};
|
|
21217
|
+
// ## Numeric Identifier
|
|
21218
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
21728
21219
|
|
|
21729
|
-
|
|
21730
|
-
|
|
21731
|
-
|
|
21732
|
-
|
|
21733
|
-
|
|
21734
|
-
|
|
21735
|
-
|
|
21736
|
-
|
|
21737
|
-
|
|
21738
|
-
|
|
21739
|
-
|
|
21740
|
-
|
|
21741
|
-
|
|
21742
|
-
|
|
21220
|
+
tok('NUMERICIDENTIFIER');
|
|
21221
|
+
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
|
|
21222
|
+
tok('NUMERICIDENTIFIERLOOSE');
|
|
21223
|
+
src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
|
|
21224
|
+
|
|
21225
|
+
// ## Non-numeric Identifier
|
|
21226
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
21227
|
+
// more letters, digits, or hyphens.
|
|
21228
|
+
|
|
21229
|
+
tok('NONNUMERICIDENTIFIER');
|
|
21230
|
+
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
|
|
21231
|
+
|
|
21232
|
+
// ## Main Version
|
|
21233
|
+
// Three dot-separated numeric identifiers.
|
|
21234
|
+
|
|
21235
|
+
tok('MAINVERSION');
|
|
21236
|
+
src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
|
21237
|
+
'(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
|
21238
|
+
'(' + src[t.NUMERICIDENTIFIER] + ')';
|
|
21239
|
+
|
|
21240
|
+
tok('MAINVERSIONLOOSE');
|
|
21241
|
+
src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
21242
|
+
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
21243
|
+
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
|
|
21244
|
+
|
|
21245
|
+
// ## Pre-release Version Identifier
|
|
21246
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
21247
|
+
|
|
21248
|
+
tok('PRERELEASEIDENTIFIER');
|
|
21249
|
+
src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
|
|
21250
|
+
'|' + src[t.NONNUMERICIDENTIFIER] + ')';
|
|
21251
|
+
|
|
21252
|
+
tok('PRERELEASEIDENTIFIERLOOSE');
|
|
21253
|
+
src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
|
|
21254
|
+
'|' + src[t.NONNUMERICIDENTIFIER] + ')';
|
|
21255
|
+
|
|
21256
|
+
// ## Pre-release Version
|
|
21257
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
21258
|
+
// identifiers.
|
|
21259
|
+
|
|
21260
|
+
tok('PRERELEASE');
|
|
21261
|
+
src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
|
|
21262
|
+
'(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
|
|
21263
|
+
|
|
21264
|
+
tok('PRERELEASELOOSE');
|
|
21265
|
+
src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
|
|
21266
|
+
'(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
|
|
21267
|
+
|
|
21268
|
+
// ## Build Metadata Identifier
|
|
21269
|
+
// Any combination of digits, letters, or hyphens.
|
|
21270
|
+
|
|
21271
|
+
tok('BUILDIDENTIFIER');
|
|
21272
|
+
src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
|
|
21273
|
+
|
|
21274
|
+
// ## Build Metadata
|
|
21275
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
21276
|
+
// identifiers.
|
|
21277
|
+
|
|
21278
|
+
tok('BUILD');
|
|
21279
|
+
src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
|
|
21280
|
+
'(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
|
|
21281
|
+
|
|
21282
|
+
// ## Full Version String
|
|
21283
|
+
// A main version, followed optionally by a pre-release version and
|
|
21284
|
+
// build metadata.
|
|
21285
|
+
|
|
21286
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
21287
|
+
// the version string are capturing groups. The build metadata is not a
|
|
21288
|
+
// capturing group, because it should not ever be used in version
|
|
21289
|
+
// comparison.
|
|
21290
|
+
|
|
21291
|
+
tok('FULL');
|
|
21292
|
+
tok('FULLPLAIN');
|
|
21293
|
+
src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
|
|
21294
|
+
src[t.PRERELEASE] + '?' +
|
|
21295
|
+
src[t.BUILD] + '?';
|
|
21296
|
+
|
|
21297
|
+
src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
|
|
21298
|
+
|
|
21299
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
21300
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
21301
|
+
// common in the npm registry.
|
|
21302
|
+
tok('LOOSEPLAIN');
|
|
21303
|
+
src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
|
|
21304
|
+
src[t.PRERELEASELOOSE] + '?' +
|
|
21305
|
+
src[t.BUILD] + '?';
|
|
21306
|
+
|
|
21307
|
+
tok('LOOSE');
|
|
21308
|
+
src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
|
|
21309
|
+
|
|
21310
|
+
tok('GTLT');
|
|
21311
|
+
src[t.GTLT] = '((?:<|>)?=?)';
|
|
21312
|
+
|
|
21313
|
+
// Something like "2.*" or "1.2.x".
|
|
21314
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
21315
|
+
// Only the first item is strictly required.
|
|
21316
|
+
tok('XRANGEIDENTIFIERLOOSE');
|
|
21317
|
+
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
|
|
21318
|
+
tok('XRANGEIDENTIFIER');
|
|
21319
|
+
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
|
|
21320
|
+
|
|
21321
|
+
tok('XRANGEPLAIN');
|
|
21322
|
+
src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
21323
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
21324
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
21325
|
+
'(?:' + src[t.PRERELEASE] + ')?' +
|
|
21326
|
+
src[t.BUILD] + '?' +
|
|
21327
|
+
')?)?';
|
|
21328
|
+
|
|
21329
|
+
tok('XRANGEPLAINLOOSE');
|
|
21330
|
+
src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
21331
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
21332
|
+
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
21333
|
+
'(?:' + src[t.PRERELEASELOOSE] + ')?' +
|
|
21334
|
+
src[t.BUILD] + '?' +
|
|
21335
|
+
')?)?';
|
|
21336
|
+
|
|
21337
|
+
tok('XRANGE');
|
|
21338
|
+
src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
|
|
21339
|
+
tok('XRANGELOOSE');
|
|
21340
|
+
src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
|
|
21341
|
+
|
|
21342
|
+
// Coercion.
|
|
21343
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
21344
|
+
tok('COERCE');
|
|
21345
|
+
src[t.COERCE] = '(^|[^\\d])' +
|
|
21346
|
+
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
|
21347
|
+
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
21348
|
+
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
21349
|
+
'(?:$|[^\\d])';
|
|
21350
|
+
tok('COERCERTL');
|
|
21351
|
+
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
|
|
21352
|
+
|
|
21353
|
+
// Tilde ranges.
|
|
21354
|
+
// Meaning is "reasonably at or greater than"
|
|
21355
|
+
tok('LONETILDE');
|
|
21356
|
+
src[t.LONETILDE] = '(?:~>?)';
|
|
21357
|
+
|
|
21358
|
+
tok('TILDETRIM');
|
|
21359
|
+
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
|
|
21360
|
+
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
|
|
21361
|
+
var tildeTrimReplace = '$1~';
|
|
21362
|
+
|
|
21363
|
+
tok('TILDE');
|
|
21364
|
+
src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
|
|
21365
|
+
tok('TILDELOOSE');
|
|
21366
|
+
src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
|
|
21367
|
+
|
|
21368
|
+
// Caret ranges.
|
|
21369
|
+
// Meaning is "at least and backwards compatible with"
|
|
21370
|
+
tok('LONECARET');
|
|
21371
|
+
src[t.LONECARET] = '(?:\\^)';
|
|
21372
|
+
|
|
21373
|
+
tok('CARETTRIM');
|
|
21374
|
+
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
|
|
21375
|
+
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
|
|
21376
|
+
var caretTrimReplace = '$1^';
|
|
21377
|
+
|
|
21378
|
+
tok('CARET');
|
|
21379
|
+
src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
|
|
21380
|
+
tok('CARETLOOSE');
|
|
21381
|
+
src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
|
|
21382
|
+
|
|
21383
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
21384
|
+
tok('COMPARATORLOOSE');
|
|
21385
|
+
src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
|
|
21386
|
+
tok('COMPARATOR');
|
|
21387
|
+
src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
|
|
21388
|
+
|
|
21389
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
|
21390
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
21391
|
+
tok('COMPARATORTRIM');
|
|
21392
|
+
src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
|
|
21393
|
+
'\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
|
|
21394
|
+
|
|
21395
|
+
// this one has to use the /g flag
|
|
21396
|
+
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
|
|
21397
|
+
var comparatorTrimReplace = '$1$2$3';
|
|
21398
|
+
|
|
21399
|
+
// Something like `1.2.3 - 1.2.4`
|
|
21400
|
+
// Note that these all use the loose form, because they'll be
|
|
21401
|
+
// checked against either the strict or loose comparator form
|
|
21402
|
+
// later.
|
|
21403
|
+
tok('HYPHENRANGE');
|
|
21404
|
+
src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
|
|
21405
|
+
'\\s+-\\s+' +
|
|
21406
|
+
'(' + src[t.XRANGEPLAIN] + ')' +
|
|
21407
|
+
'\\s*$';
|
|
21408
|
+
|
|
21409
|
+
tok('HYPHENRANGELOOSE');
|
|
21410
|
+
src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
|
21411
|
+
'\\s+-\\s+' +
|
|
21412
|
+
'(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
|
21413
|
+
'\\s*$';
|
|
21414
|
+
|
|
21415
|
+
// Star ranges basically just allow anything at all.
|
|
21416
|
+
tok('STAR');
|
|
21417
|
+
src[t.STAR] = '(<|>)?=?\\s*\\*';
|
|
21418
|
+
|
|
21419
|
+
// Compile to actual regexp objects.
|
|
21420
|
+
// All are flag-free, unless they were created above with a flag.
|
|
21421
|
+
for (var i = 0; i < R; i++) {
|
|
21422
|
+
debug(i, src[i]);
|
|
21423
|
+
if (!re[i]) {
|
|
21424
|
+
re[i] = new RegExp(src[i]);
|
|
21425
|
+
}
|
|
21426
|
+
}
|
|
21743
21427
|
|
|
21744
|
-
|
|
21745
|
-
|
|
21746
|
-
|
|
21747
|
-
|
|
21748
|
-
|
|
21749
|
-
|
|
21750
|
-
|
|
21751
|
-
|
|
21752
|
-
|
|
21428
|
+
exports.parse = parse;
|
|
21429
|
+
function parse (version, options) {
|
|
21430
|
+
if (!options || typeof options !== 'object') {
|
|
21431
|
+
options = {
|
|
21432
|
+
loose: !!options,
|
|
21433
|
+
includePrerelease: false
|
|
21434
|
+
};
|
|
21435
|
+
}
|
|
21436
|
+
|
|
21437
|
+
if (version instanceof SemVer) {
|
|
21438
|
+
return version
|
|
21439
|
+
}
|
|
21440
|
+
|
|
21441
|
+
if (typeof version !== 'string') {
|
|
21442
|
+
return null
|
|
21443
|
+
}
|
|
21444
|
+
|
|
21445
|
+
if (version.length > MAX_LENGTH) {
|
|
21446
|
+
return null
|
|
21447
|
+
}
|
|
21448
|
+
|
|
21449
|
+
var r = options.loose ? re[t.LOOSE] : re[t.FULL];
|
|
21450
|
+
if (!r.test(version)) {
|
|
21451
|
+
return null
|
|
21452
|
+
}
|
|
21453
|
+
|
|
21454
|
+
try {
|
|
21455
|
+
return new SemVer(version, options)
|
|
21456
|
+
} catch (er) {
|
|
21457
|
+
return null
|
|
21458
|
+
}
|
|
21459
|
+
}
|
|
21753
21460
|
|
|
21754
|
-
|
|
21755
|
-
|
|
21756
|
-
|
|
21757
|
-
|
|
21758
|
-
|
|
21759
|
-
comp = replaceCarets(comp, options);
|
|
21760
|
-
debug('caret', comp);
|
|
21761
|
-
comp = replaceTildes(comp, options);
|
|
21762
|
-
debug('tildes', comp);
|
|
21763
|
-
comp = replaceXRanges(comp, options);
|
|
21764
|
-
debug('xrange', comp);
|
|
21765
|
-
comp = replaceStars(comp, options);
|
|
21766
|
-
debug('stars', comp);
|
|
21767
|
-
return comp;
|
|
21768
|
-
}
|
|
21769
|
-
function isX(id) {
|
|
21770
|
-
return !id || id.toLowerCase() === 'x' || id === '*';
|
|
21771
|
-
}
|
|
21772
|
-
|
|
21773
|
-
// ~, ~> --> * (any, kinda silly)
|
|
21774
|
-
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
|
21775
|
-
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
|
21776
|
-
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
|
21777
|
-
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
|
21778
|
-
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
|
21779
|
-
function replaceTildes(comp, options) {
|
|
21780
|
-
return comp.trim().split(/\s+/).map(function (comp) {
|
|
21781
|
-
return replaceTilde(comp, options);
|
|
21782
|
-
}).join(' ');
|
|
21783
|
-
}
|
|
21784
|
-
function replaceTilde(comp, options) {
|
|
21785
|
-
var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
21786
|
-
return comp.replace(r, function (_, M, m, p, pr) {
|
|
21787
|
-
debug('tilde', comp, _, M, m, p, pr);
|
|
21788
|
-
var ret;
|
|
21789
|
-
if (isX(M)) {
|
|
21790
|
-
ret = '';
|
|
21791
|
-
} else if (isX(m)) {
|
|
21792
|
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
|
21793
|
-
} else if (isX(p)) {
|
|
21794
|
-
// ~1.2 == >=1.2.0 <1.3.0
|
|
21795
|
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
|
|
21796
|
-
} else if (pr) {
|
|
21797
|
-
debug('replaceTilde pr', pr);
|
|
21798
|
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
|
|
21799
|
-
} else {
|
|
21800
|
-
// ~1.2.3 == >=1.2.3 <1.3.0
|
|
21801
|
-
ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
|
|
21802
|
-
}
|
|
21803
|
-
debug('tilde return', ret);
|
|
21804
|
-
return ret;
|
|
21805
|
-
});
|
|
21806
|
-
}
|
|
21461
|
+
exports.valid = valid;
|
|
21462
|
+
function valid (version, options) {
|
|
21463
|
+
var v = parse(version, options);
|
|
21464
|
+
return v ? v.version : null
|
|
21465
|
+
}
|
|
21807
21466
|
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
21812
|
-
|
|
21813
|
-
// ^1.2.0 --> >=1.2.0 <2.0.0
|
|
21814
|
-
function replaceCarets(comp, options) {
|
|
21815
|
-
return comp.trim().split(/\s+/).map(function (comp) {
|
|
21816
|
-
return replaceCaret(comp, options);
|
|
21817
|
-
}).join(' ');
|
|
21818
|
-
}
|
|
21819
|
-
function replaceCaret(comp, options) {
|
|
21820
|
-
debug('caret', comp, options);
|
|
21821
|
-
var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
21822
|
-
return comp.replace(r, function (_, M, m, p, pr) {
|
|
21823
|
-
debug('caret', comp, _, M, m, p, pr);
|
|
21824
|
-
var ret;
|
|
21825
|
-
if (isX(M)) {
|
|
21826
|
-
ret = '';
|
|
21827
|
-
} else if (isX(m)) {
|
|
21828
|
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
|
21829
|
-
} else if (isX(p)) {
|
|
21830
|
-
if (M === '0') {
|
|
21831
|
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
|
|
21832
|
-
} else {
|
|
21833
|
-
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
|
|
21834
|
-
}
|
|
21835
|
-
} else if (pr) {
|
|
21836
|
-
debug('replaceCaret pr', pr);
|
|
21837
|
-
if (M === '0') {
|
|
21838
|
-
if (m === '0') {
|
|
21839
|
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
|
|
21840
|
-
} else {
|
|
21841
|
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
|
|
21842
|
-
}
|
|
21843
|
-
} else {
|
|
21844
|
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
|
|
21845
|
-
}
|
|
21846
|
-
} else {
|
|
21847
|
-
debug('no pr');
|
|
21848
|
-
if (M === '0') {
|
|
21849
|
-
if (m === '0') {
|
|
21850
|
-
ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
|
|
21851
|
-
} else {
|
|
21852
|
-
ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
|
|
21853
|
-
}
|
|
21854
|
-
} else {
|
|
21855
|
-
ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
|
|
21856
|
-
}
|
|
21857
|
-
}
|
|
21858
|
-
debug('caret return', ret);
|
|
21859
|
-
return ret;
|
|
21860
|
-
});
|
|
21861
|
-
}
|
|
21862
|
-
function replaceXRanges(comp, options) {
|
|
21863
|
-
debug('replaceXRanges', comp, options);
|
|
21864
|
-
return comp.split(/\s+/).map(function (comp) {
|
|
21865
|
-
return replaceXRange(comp, options);
|
|
21866
|
-
}).join(' ');
|
|
21867
|
-
}
|
|
21868
|
-
function replaceXRange(comp, options) {
|
|
21869
|
-
comp = comp.trim();
|
|
21870
|
-
var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
21871
|
-
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
|
21872
|
-
debug('xRange', comp, ret, gtlt, M, m, p, pr);
|
|
21873
|
-
var xM = isX(M);
|
|
21874
|
-
var xm = xM || isX(m);
|
|
21875
|
-
var xp = xm || isX(p);
|
|
21876
|
-
var anyX = xp;
|
|
21877
|
-
if (gtlt === '=' && anyX) {
|
|
21878
|
-
gtlt = '';
|
|
21879
|
-
}
|
|
21467
|
+
exports.clean = clean;
|
|
21468
|
+
function clean (version, options) {
|
|
21469
|
+
var s = parse(version.trim().replace(/^[=v]+/, ''), options);
|
|
21470
|
+
return s ? s.version : null
|
|
21471
|
+
}
|
|
21880
21472
|
|
|
21881
|
-
|
|
21882
|
-
|
|
21883
|
-
|
|
21884
|
-
|
|
21885
|
-
|
|
21886
|
-
|
|
21887
|
-
|
|
21888
|
-
|
|
21889
|
-
|
|
21890
|
-
|
|
21891
|
-
|
|
21892
|
-
|
|
21893
|
-
|
|
21894
|
-
|
|
21895
|
-
|
|
21896
|
-
|
|
21897
|
-
|
|
21898
|
-
|
|
21899
|
-
|
|
21900
|
-
|
|
21901
|
-
|
|
21902
|
-
|
|
21903
|
-
|
|
21904
|
-
|
|
21905
|
-
|
|
21906
|
-
|
|
21907
|
-
|
|
21908
|
-
|
|
21909
|
-
|
|
21910
|
-
|
|
21911
|
-
|
|
21912
|
-
|
|
21913
|
-
|
|
21914
|
-
|
|
21915
|
-
|
|
21916
|
-
|
|
21917
|
-
|
|
21918
|
-
|
|
21919
|
-
|
|
21920
|
-
|
|
21921
|
-
|
|
21922
|
-
|
|
21923
|
-
|
|
21924
|
-
|
|
21925
|
-
|
|
21926
|
-
|
|
21927
|
-
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
|
|
21473
|
+
exports.SemVer = SemVer;
|
|
21474
|
+
|
|
21475
|
+
function SemVer (version, options) {
|
|
21476
|
+
if (!options || typeof options !== 'object') {
|
|
21477
|
+
options = {
|
|
21478
|
+
loose: !!options,
|
|
21479
|
+
includePrerelease: false
|
|
21480
|
+
};
|
|
21481
|
+
}
|
|
21482
|
+
if (version instanceof SemVer) {
|
|
21483
|
+
if (version.loose === options.loose) {
|
|
21484
|
+
return version
|
|
21485
|
+
} else {
|
|
21486
|
+
version = version.version;
|
|
21487
|
+
}
|
|
21488
|
+
} else if (typeof version !== 'string') {
|
|
21489
|
+
throw new TypeError('Invalid Version: ' + version)
|
|
21490
|
+
}
|
|
21491
|
+
|
|
21492
|
+
if (version.length > MAX_LENGTH) {
|
|
21493
|
+
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
|
21494
|
+
}
|
|
21495
|
+
|
|
21496
|
+
if (!(this instanceof SemVer)) {
|
|
21497
|
+
return new SemVer(version, options)
|
|
21498
|
+
}
|
|
21499
|
+
|
|
21500
|
+
debug('SemVer', version, options);
|
|
21501
|
+
this.options = options;
|
|
21502
|
+
this.loose = !!options.loose;
|
|
21503
|
+
|
|
21504
|
+
var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
21505
|
+
|
|
21506
|
+
if (!m) {
|
|
21507
|
+
throw new TypeError('Invalid Version: ' + version)
|
|
21508
|
+
}
|
|
21509
|
+
|
|
21510
|
+
this.raw = version;
|
|
21511
|
+
|
|
21512
|
+
// these are actually numbers
|
|
21513
|
+
this.major = +m[1];
|
|
21514
|
+
this.minor = +m[2];
|
|
21515
|
+
this.patch = +m[3];
|
|
21516
|
+
|
|
21517
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
21518
|
+
throw new TypeError('Invalid major version')
|
|
21519
|
+
}
|
|
21520
|
+
|
|
21521
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
21522
|
+
throw new TypeError('Invalid minor version')
|
|
21523
|
+
}
|
|
21524
|
+
|
|
21525
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
21526
|
+
throw new TypeError('Invalid patch version')
|
|
21527
|
+
}
|
|
21528
|
+
|
|
21529
|
+
// numberify any prerelease numeric ids
|
|
21530
|
+
if (!m[4]) {
|
|
21531
|
+
this.prerelease = [];
|
|
21532
|
+
} else {
|
|
21533
|
+
this.prerelease = m[4].split('.').map(function (id) {
|
|
21534
|
+
if (/^[0-9]+$/.test(id)) {
|
|
21535
|
+
var num = +id;
|
|
21536
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
21537
|
+
return num
|
|
21538
|
+
}
|
|
21539
|
+
}
|
|
21540
|
+
return id
|
|
21541
|
+
});
|
|
21542
|
+
}
|
|
21543
|
+
|
|
21544
|
+
this.build = m[5] ? m[5].split('.') : [];
|
|
21545
|
+
this.format();
|
|
21546
|
+
}
|
|
21932
21547
|
|
|
21933
|
-
|
|
21934
|
-
|
|
21935
|
-
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
|
|
21940
|
-
|
|
21941
|
-
|
|
21942
|
-
|
|
21943
|
-
|
|
21944
|
-
|
|
21945
|
-
|
|
21946
|
-
|
|
21947
|
-
|
|
21948
|
-
|
|
21949
|
-
|
|
21950
|
-
|
|
21951
|
-
|
|
21952
|
-
|
|
21953
|
-
|
|
21954
|
-
|
|
21955
|
-
|
|
21956
|
-
|
|
21957
|
-
|
|
21958
|
-
|
|
21959
|
-
|
|
21960
|
-
|
|
21961
|
-
|
|
21962
|
-
|
|
21963
|
-
|
|
21964
|
-
|
|
21965
|
-
|
|
21966
|
-
|
|
21967
|
-
|
|
21968
|
-
|
|
21548
|
+
SemVer.prototype.format = function () {
|
|
21549
|
+
this.version = this.major + '.' + this.minor + '.' + this.patch;
|
|
21550
|
+
if (this.prerelease.length) {
|
|
21551
|
+
this.version += '-' + this.prerelease.join('.');
|
|
21552
|
+
}
|
|
21553
|
+
return this.version
|
|
21554
|
+
};
|
|
21555
|
+
|
|
21556
|
+
SemVer.prototype.toString = function () {
|
|
21557
|
+
return this.version
|
|
21558
|
+
};
|
|
21559
|
+
|
|
21560
|
+
SemVer.prototype.compare = function (other) {
|
|
21561
|
+
debug('SemVer.compare', this.version, this.options, other);
|
|
21562
|
+
if (!(other instanceof SemVer)) {
|
|
21563
|
+
other = new SemVer(other, this.options);
|
|
21564
|
+
}
|
|
21565
|
+
|
|
21566
|
+
return this.compareMain(other) || this.comparePre(other)
|
|
21567
|
+
};
|
|
21568
|
+
|
|
21569
|
+
SemVer.prototype.compareMain = function (other) {
|
|
21570
|
+
if (!(other instanceof SemVer)) {
|
|
21571
|
+
other = new SemVer(other, this.options);
|
|
21572
|
+
}
|
|
21573
|
+
|
|
21574
|
+
return compareIdentifiers(this.major, other.major) ||
|
|
21575
|
+
compareIdentifiers(this.minor, other.minor) ||
|
|
21576
|
+
compareIdentifiers(this.patch, other.patch)
|
|
21577
|
+
};
|
|
21578
|
+
|
|
21579
|
+
SemVer.prototype.comparePre = function (other) {
|
|
21580
|
+
if (!(other instanceof SemVer)) {
|
|
21581
|
+
other = new SemVer(other, this.options);
|
|
21582
|
+
}
|
|
21583
|
+
|
|
21584
|
+
// NOT having a prerelease is > having one
|
|
21585
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
21586
|
+
return -1
|
|
21587
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
21588
|
+
return 1
|
|
21589
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
21590
|
+
return 0
|
|
21591
|
+
}
|
|
21592
|
+
|
|
21593
|
+
var i = 0;
|
|
21594
|
+
do {
|
|
21595
|
+
var a = this.prerelease[i];
|
|
21596
|
+
var b = other.prerelease[i];
|
|
21597
|
+
debug('prerelease compare', i, a, b);
|
|
21598
|
+
if (a === undefined && b === undefined) {
|
|
21599
|
+
return 0
|
|
21600
|
+
} else if (b === undefined) {
|
|
21601
|
+
return 1
|
|
21602
|
+
} else if (a === undefined) {
|
|
21603
|
+
return -1
|
|
21604
|
+
} else if (a === b) {
|
|
21605
|
+
continue
|
|
21606
|
+
} else {
|
|
21607
|
+
return compareIdentifiers(a, b)
|
|
21608
|
+
}
|
|
21609
|
+
} while (++i)
|
|
21610
|
+
};
|
|
21611
|
+
|
|
21612
|
+
SemVer.prototype.compareBuild = function (other) {
|
|
21613
|
+
if (!(other instanceof SemVer)) {
|
|
21614
|
+
other = new SemVer(other, this.options);
|
|
21615
|
+
}
|
|
21616
|
+
|
|
21617
|
+
var i = 0;
|
|
21618
|
+
do {
|
|
21619
|
+
var a = this.build[i];
|
|
21620
|
+
var b = other.build[i];
|
|
21621
|
+
debug('prerelease compare', i, a, b);
|
|
21622
|
+
if (a === undefined && b === undefined) {
|
|
21623
|
+
return 0
|
|
21624
|
+
} else if (b === undefined) {
|
|
21625
|
+
return 1
|
|
21626
|
+
} else if (a === undefined) {
|
|
21627
|
+
return -1
|
|
21628
|
+
} else if (a === b) {
|
|
21629
|
+
continue
|
|
21630
|
+
} else {
|
|
21631
|
+
return compareIdentifiers(a, b)
|
|
21632
|
+
}
|
|
21633
|
+
} while (++i)
|
|
21634
|
+
};
|
|
21635
|
+
|
|
21636
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
21637
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
21638
|
+
SemVer.prototype.inc = function (release, identifier) {
|
|
21639
|
+
switch (release) {
|
|
21640
|
+
case 'premajor':
|
|
21641
|
+
this.prerelease.length = 0;
|
|
21642
|
+
this.patch = 0;
|
|
21643
|
+
this.minor = 0;
|
|
21644
|
+
this.major++;
|
|
21645
|
+
this.inc('pre', identifier);
|
|
21646
|
+
break
|
|
21647
|
+
case 'preminor':
|
|
21648
|
+
this.prerelease.length = 0;
|
|
21649
|
+
this.patch = 0;
|
|
21650
|
+
this.minor++;
|
|
21651
|
+
this.inc('pre', identifier);
|
|
21652
|
+
break
|
|
21653
|
+
case 'prepatch':
|
|
21654
|
+
// If this is already a prerelease, it will bump to the next version
|
|
21655
|
+
// drop any prereleases that might already exist, since they are not
|
|
21656
|
+
// relevant at this point.
|
|
21657
|
+
this.prerelease.length = 0;
|
|
21658
|
+
this.inc('patch', identifier);
|
|
21659
|
+
this.inc('pre', identifier);
|
|
21660
|
+
break
|
|
21661
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
21662
|
+
// prepatch.
|
|
21663
|
+
case 'prerelease':
|
|
21664
|
+
if (this.prerelease.length === 0) {
|
|
21665
|
+
this.inc('patch', identifier);
|
|
21666
|
+
}
|
|
21667
|
+
this.inc('pre', identifier);
|
|
21668
|
+
break
|
|
21669
|
+
|
|
21670
|
+
case 'major':
|
|
21671
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
21672
|
+
// Otherwise increment major.
|
|
21673
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
21674
|
+
// 1.1.0 bumps to 2.0.0
|
|
21675
|
+
if (this.minor !== 0 ||
|
|
21676
|
+
this.patch !== 0 ||
|
|
21677
|
+
this.prerelease.length === 0) {
|
|
21678
|
+
this.major++;
|
|
21679
|
+
}
|
|
21680
|
+
this.minor = 0;
|
|
21681
|
+
this.patch = 0;
|
|
21682
|
+
this.prerelease = [];
|
|
21683
|
+
break
|
|
21684
|
+
case 'minor':
|
|
21685
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
21686
|
+
// Otherwise increment minor.
|
|
21687
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
21688
|
+
// 1.2.1 bumps to 1.3.0
|
|
21689
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
21690
|
+
this.minor++;
|
|
21691
|
+
}
|
|
21692
|
+
this.patch = 0;
|
|
21693
|
+
this.prerelease = [];
|
|
21694
|
+
break
|
|
21695
|
+
case 'patch':
|
|
21696
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
21697
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
21698
|
+
// 1.2.0-5 patches to 1.2.0
|
|
21699
|
+
// 1.2.0 patches to 1.2.1
|
|
21700
|
+
if (this.prerelease.length === 0) {
|
|
21701
|
+
this.patch++;
|
|
21702
|
+
}
|
|
21703
|
+
this.prerelease = [];
|
|
21704
|
+
break
|
|
21705
|
+
// This probably shouldn't be used publicly.
|
|
21706
|
+
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
|
21707
|
+
case 'pre':
|
|
21708
|
+
if (this.prerelease.length === 0) {
|
|
21709
|
+
this.prerelease = [0];
|
|
21710
|
+
} else {
|
|
21711
|
+
var i = this.prerelease.length;
|
|
21712
|
+
while (--i >= 0) {
|
|
21713
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
21714
|
+
this.prerelease[i]++;
|
|
21715
|
+
i = -2;
|
|
21716
|
+
}
|
|
21717
|
+
}
|
|
21718
|
+
if (i === -1) {
|
|
21719
|
+
// didn't increment anything
|
|
21720
|
+
this.prerelease.push(0);
|
|
21721
|
+
}
|
|
21722
|
+
}
|
|
21723
|
+
if (identifier) {
|
|
21724
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
21725
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
21726
|
+
if (this.prerelease[0] === identifier) {
|
|
21727
|
+
if (isNaN(this.prerelease[1])) {
|
|
21728
|
+
this.prerelease = [identifier, 0];
|
|
21729
|
+
}
|
|
21730
|
+
} else {
|
|
21731
|
+
this.prerelease = [identifier, 0];
|
|
21732
|
+
}
|
|
21733
|
+
}
|
|
21734
|
+
break
|
|
21735
|
+
|
|
21736
|
+
default:
|
|
21737
|
+
throw new Error('invalid increment argument: ' + release)
|
|
21738
|
+
}
|
|
21739
|
+
this.format();
|
|
21740
|
+
this.raw = this.version;
|
|
21741
|
+
return this
|
|
21742
|
+
};
|
|
21743
|
+
|
|
21744
|
+
exports.inc = inc;
|
|
21745
|
+
function inc (version, release, loose, identifier) {
|
|
21746
|
+
if (typeof (loose) === 'string') {
|
|
21747
|
+
identifier = loose;
|
|
21748
|
+
loose = undefined;
|
|
21749
|
+
}
|
|
21750
|
+
|
|
21751
|
+
try {
|
|
21752
|
+
return new SemVer(version, loose).inc(release, identifier).version
|
|
21753
|
+
} catch (er) {
|
|
21754
|
+
return null
|
|
21755
|
+
}
|
|
21756
|
+
}
|
|
21969
21757
|
|
|
21970
|
-
|
|
21971
|
-
|
|
21972
|
-
|
|
21973
|
-
|
|
21974
|
-
|
|
21975
|
-
|
|
21976
|
-
|
|
21977
|
-
|
|
21978
|
-
|
|
21979
|
-
|
|
21980
|
-
|
|
21981
|
-
|
|
21982
|
-
|
|
21983
|
-
|
|
21984
|
-
|
|
21985
|
-
|
|
21986
|
-
|
|
21987
|
-
|
|
21988
|
-
|
|
21989
|
-
|
|
21990
|
-
|
|
21991
|
-
|
|
21992
|
-
return false;
|
|
21993
|
-
}
|
|
21994
|
-
}
|
|
21995
|
-
if (version.prerelease.length && !options.includePrerelease) {
|
|
21996
|
-
// Find the set of versions that are allowed to have prereleases
|
|
21997
|
-
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
21998
|
-
// That should allow `1.2.3-pr.2` to pass.
|
|
21999
|
-
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
22000
|
-
// even though it's within the range set by the comparators.
|
|
22001
|
-
for (i = 0; i < set.length; i++) {
|
|
22002
|
-
debug(set[i].semver);
|
|
22003
|
-
if (set[i].semver === ANY) {
|
|
22004
|
-
continue;
|
|
22005
|
-
}
|
|
22006
|
-
if (set[i].semver.prerelease.length > 0) {
|
|
22007
|
-
var allowed = set[i].semver;
|
|
22008
|
-
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
22009
|
-
return true;
|
|
22010
|
-
}
|
|
22011
|
-
}
|
|
22012
|
-
}
|
|
21758
|
+
exports.diff = diff;
|
|
21759
|
+
function diff (version1, version2) {
|
|
21760
|
+
if (eq(version1, version2)) {
|
|
21761
|
+
return null
|
|
21762
|
+
} else {
|
|
21763
|
+
var v1 = parse(version1);
|
|
21764
|
+
var v2 = parse(version2);
|
|
21765
|
+
var prefix = '';
|
|
21766
|
+
if (v1.prerelease.length || v2.prerelease.length) {
|
|
21767
|
+
prefix = 'pre';
|
|
21768
|
+
var defaultResult = 'prerelease';
|
|
21769
|
+
}
|
|
21770
|
+
for (var key in v1) {
|
|
21771
|
+
if (key === 'major' || key === 'minor' || key === 'patch') {
|
|
21772
|
+
if (v1[key] !== v2[key]) {
|
|
21773
|
+
return prefix + key
|
|
21774
|
+
}
|
|
21775
|
+
}
|
|
21776
|
+
}
|
|
21777
|
+
return defaultResult // may be undefined
|
|
21778
|
+
}
|
|
21779
|
+
}
|
|
22013
21780
|
|
|
22014
|
-
|
|
22015
|
-
return false;
|
|
22016
|
-
}
|
|
22017
|
-
return true;
|
|
22018
|
-
}
|
|
22019
|
-
exports.satisfies = satisfies;
|
|
22020
|
-
function satisfies(version, range, options) {
|
|
22021
|
-
try {
|
|
22022
|
-
range = new Range(range, options);
|
|
22023
|
-
} catch (er) {
|
|
22024
|
-
return false;
|
|
22025
|
-
}
|
|
22026
|
-
return range.test(version);
|
|
22027
|
-
}
|
|
22028
|
-
exports.maxSatisfying = maxSatisfying;
|
|
22029
|
-
function maxSatisfying(versions, range, options) {
|
|
22030
|
-
var max = null;
|
|
22031
|
-
var maxSV = null;
|
|
22032
|
-
try {
|
|
22033
|
-
var rangeObj = new Range(range, options);
|
|
22034
|
-
} catch (er) {
|
|
22035
|
-
return null;
|
|
22036
|
-
}
|
|
22037
|
-
versions.forEach(function (v) {
|
|
22038
|
-
if (rangeObj.test(v)) {
|
|
22039
|
-
// satisfies(v, range, options)
|
|
22040
|
-
if (!max || maxSV.compare(v) === -1) {
|
|
22041
|
-
// compare(max, v, true)
|
|
22042
|
-
max = v;
|
|
22043
|
-
maxSV = new SemVer(max, options);
|
|
22044
|
-
}
|
|
22045
|
-
}
|
|
22046
|
-
});
|
|
22047
|
-
return max;
|
|
22048
|
-
}
|
|
22049
|
-
exports.minSatisfying = minSatisfying;
|
|
22050
|
-
function minSatisfying(versions, range, options) {
|
|
22051
|
-
var min = null;
|
|
22052
|
-
var minSV = null;
|
|
22053
|
-
try {
|
|
22054
|
-
var rangeObj = new Range(range, options);
|
|
22055
|
-
} catch (er) {
|
|
22056
|
-
return null;
|
|
22057
|
-
}
|
|
22058
|
-
versions.forEach(function (v) {
|
|
22059
|
-
if (rangeObj.test(v)) {
|
|
22060
|
-
// satisfies(v, range, options)
|
|
22061
|
-
if (!min || minSV.compare(v) === 1) {
|
|
22062
|
-
// compare(min, v, true)
|
|
22063
|
-
min = v;
|
|
22064
|
-
minSV = new SemVer(min, options);
|
|
22065
|
-
}
|
|
22066
|
-
}
|
|
22067
|
-
});
|
|
22068
|
-
return min;
|
|
22069
|
-
}
|
|
22070
|
-
exports.minVersion = minVersion;
|
|
22071
|
-
function minVersion(range, loose) {
|
|
22072
|
-
range = new Range(range, loose);
|
|
22073
|
-
var minver = new SemVer('0.0.0');
|
|
22074
|
-
if (range.test(minver)) {
|
|
22075
|
-
return minver;
|
|
22076
|
-
}
|
|
22077
|
-
minver = new SemVer('0.0.0-0');
|
|
22078
|
-
if (range.test(minver)) {
|
|
22079
|
-
return minver;
|
|
22080
|
-
}
|
|
22081
|
-
minver = null;
|
|
22082
|
-
for (var i = 0; i < range.set.length; ++i) {
|
|
22083
|
-
var comparators = range.set[i];
|
|
22084
|
-
comparators.forEach(function (comparator) {
|
|
22085
|
-
// Clone to avoid manipulating the comparator's semver object.
|
|
22086
|
-
var compver = new SemVer(comparator.semver.version);
|
|
22087
|
-
switch (comparator.operator) {
|
|
22088
|
-
case '>':
|
|
22089
|
-
if (compver.prerelease.length === 0) {
|
|
22090
|
-
compver.patch++;
|
|
22091
|
-
} else {
|
|
22092
|
-
compver.prerelease.push(0);
|
|
22093
|
-
}
|
|
22094
|
-
compver.raw = compver.format();
|
|
22095
|
-
/* fallthrough */
|
|
22096
|
-
case '':
|
|
22097
|
-
case '>=':
|
|
22098
|
-
if (!minver || gt(minver, compver)) {
|
|
22099
|
-
minver = compver;
|
|
22100
|
-
}
|
|
22101
|
-
break;
|
|
22102
|
-
case '<':
|
|
22103
|
-
case '<=':
|
|
22104
|
-
/* Ignore maximum versions */
|
|
22105
|
-
break;
|
|
22106
|
-
/* istanbul ignore next */
|
|
22107
|
-
default:
|
|
22108
|
-
throw new Error('Unexpected operation: ' + comparator.operator);
|
|
22109
|
-
}
|
|
22110
|
-
});
|
|
22111
|
-
}
|
|
22112
|
-
if (minver && range.test(minver)) {
|
|
22113
|
-
return minver;
|
|
22114
|
-
}
|
|
22115
|
-
return null;
|
|
22116
|
-
}
|
|
22117
|
-
exports.validRange = validRange;
|
|
22118
|
-
function validRange(range, options) {
|
|
22119
|
-
try {
|
|
22120
|
-
// Return '*' instead of '' so that truthiness works.
|
|
22121
|
-
// This will throw if it's invalid anyway
|
|
22122
|
-
return new Range(range, options).range || '*';
|
|
22123
|
-
} catch (er) {
|
|
22124
|
-
return null;
|
|
22125
|
-
}
|
|
22126
|
-
}
|
|
21781
|
+
exports.compareIdentifiers = compareIdentifiers;
|
|
22127
21782
|
|
|
22128
|
-
|
|
22129
|
-
|
|
22130
|
-
|
|
22131
|
-
|
|
22132
|
-
}
|
|
21783
|
+
var numeric = /^[0-9]+$/;
|
|
21784
|
+
function compareIdentifiers (a, b) {
|
|
21785
|
+
var anum = numeric.test(a);
|
|
21786
|
+
var bnum = numeric.test(b);
|
|
22133
21787
|
|
|
22134
|
-
|
|
22135
|
-
|
|
22136
|
-
|
|
22137
|
-
|
|
22138
|
-
}
|
|
22139
|
-
exports.outside = outside;
|
|
22140
|
-
function outside(version, range, hilo, options) {
|
|
22141
|
-
version = new SemVer(version, options);
|
|
22142
|
-
range = new Range(range, options);
|
|
22143
|
-
var gtfn, ltefn, ltfn, comp, ecomp;
|
|
22144
|
-
switch (hilo) {
|
|
22145
|
-
case '>':
|
|
22146
|
-
gtfn = gt;
|
|
22147
|
-
ltefn = lte;
|
|
22148
|
-
ltfn = lt;
|
|
22149
|
-
comp = '>';
|
|
22150
|
-
ecomp = '>=';
|
|
22151
|
-
break;
|
|
22152
|
-
case '<':
|
|
22153
|
-
gtfn = lt;
|
|
22154
|
-
ltefn = gte;
|
|
22155
|
-
ltfn = gt;
|
|
22156
|
-
comp = '<';
|
|
22157
|
-
ecomp = '<=';
|
|
22158
|
-
break;
|
|
22159
|
-
default:
|
|
22160
|
-
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
22161
|
-
}
|
|
21788
|
+
if (anum && bnum) {
|
|
21789
|
+
a = +a;
|
|
21790
|
+
b = +b;
|
|
21791
|
+
}
|
|
22162
21792
|
|
|
22163
|
-
|
|
22164
|
-
|
|
22165
|
-
|
|
22166
|
-
|
|
21793
|
+
return a === b ? 0
|
|
21794
|
+
: (anum && !bnum) ? -1
|
|
21795
|
+
: (bnum && !anum) ? 1
|
|
21796
|
+
: a < b ? -1
|
|
21797
|
+
: 1
|
|
21798
|
+
}
|
|
21799
|
+
|
|
21800
|
+
exports.rcompareIdentifiers = rcompareIdentifiers;
|
|
21801
|
+
function rcompareIdentifiers (a, b) {
|
|
21802
|
+
return compareIdentifiers(b, a)
|
|
21803
|
+
}
|
|
22167
21804
|
|
|
22168
|
-
|
|
22169
|
-
|
|
21805
|
+
exports.major = major;
|
|
21806
|
+
function major (a, loose) {
|
|
21807
|
+
return new SemVer(a, loose).major
|
|
21808
|
+
}
|
|
22170
21809
|
|
|
22171
|
-
|
|
22172
|
-
|
|
22173
|
-
|
|
22174
|
-
|
|
22175
|
-
comparators.forEach(function (comparator) {
|
|
22176
|
-
if (comparator.semver === ANY) {
|
|
22177
|
-
comparator = new Comparator('>=0.0.0');
|
|
22178
|
-
}
|
|
22179
|
-
high = high || comparator;
|
|
22180
|
-
low = low || comparator;
|
|
22181
|
-
if (gtfn(comparator.semver, high.semver, options)) {
|
|
22182
|
-
high = comparator;
|
|
22183
|
-
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
22184
|
-
low = comparator;
|
|
22185
|
-
}
|
|
22186
|
-
});
|
|
21810
|
+
exports.minor = minor;
|
|
21811
|
+
function minor (a, loose) {
|
|
21812
|
+
return new SemVer(a, loose).minor
|
|
21813
|
+
}
|
|
22187
21814
|
|
|
22188
|
-
|
|
22189
|
-
|
|
22190
|
-
|
|
22191
|
-
|
|
22192
|
-
}
|
|
21815
|
+
exports.patch = patch;
|
|
21816
|
+
function patch (a, loose) {
|
|
21817
|
+
return new SemVer(a, loose).patch
|
|
21818
|
+
}
|
|
22193
21819
|
|
|
22194
|
-
|
|
22195
|
-
|
|
22196
|
-
|
|
22197
|
-
|
|
22198
|
-
|
|
22199
|
-
|
|
22200
|
-
|
|
22201
|
-
|
|
22202
|
-
|
|
22203
|
-
|
|
22204
|
-
|
|
22205
|
-
|
|
22206
|
-
|
|
22207
|
-
|
|
22208
|
-
|
|
22209
|
-
|
|
22210
|
-
|
|
22211
|
-
|
|
22212
|
-
|
|
22213
|
-
|
|
22214
|
-
|
|
22215
|
-
|
|
22216
|
-
|
|
22217
|
-
|
|
22218
|
-
|
|
22219
|
-
|
|
22220
|
-
|
|
22221
|
-
|
|
22222
|
-
|
|
22223
|
-
|
|
22224
|
-
|
|
22225
|
-
|
|
22226
|
-
|
|
22227
|
-
|
|
22228
|
-
|
|
22229
|
-
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
|
|
22233
|
-
|
|
22234
|
-
|
|
22235
|
-
|
|
22236
|
-
|
|
22237
|
-
|
|
22238
|
-
|
|
22239
|
-
|
|
22240
|
-
|
|
22241
|
-
|
|
22242
|
-
|
|
22243
|
-
|
|
22244
|
-
|
|
22245
|
-
|
|
22246
|
-
|
|
22247
|
-
|
|
22248
|
-
|
|
22249
|
-
|
|
22250
|
-
|
|
22251
|
-
|
|
22252
|
-
|
|
22253
|
-
|
|
22254
|
-
|
|
21820
|
+
exports.compare = compare;
|
|
21821
|
+
function compare (a, b, loose) {
|
|
21822
|
+
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
|
21823
|
+
}
|
|
21824
|
+
|
|
21825
|
+
exports.compareLoose = compareLoose;
|
|
21826
|
+
function compareLoose (a, b) {
|
|
21827
|
+
return compare(a, b, true)
|
|
21828
|
+
}
|
|
21829
|
+
|
|
21830
|
+
exports.compareBuild = compareBuild;
|
|
21831
|
+
function compareBuild (a, b, loose) {
|
|
21832
|
+
var versionA = new SemVer(a, loose);
|
|
21833
|
+
var versionB = new SemVer(b, loose);
|
|
21834
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
21835
|
+
}
|
|
21836
|
+
|
|
21837
|
+
exports.rcompare = rcompare;
|
|
21838
|
+
function rcompare (a, b, loose) {
|
|
21839
|
+
return compare(b, a, loose)
|
|
21840
|
+
}
|
|
21841
|
+
|
|
21842
|
+
exports.sort = sort;
|
|
21843
|
+
function sort (list, loose) {
|
|
21844
|
+
return list.sort(function (a, b) {
|
|
21845
|
+
return exports.compareBuild(a, b, loose)
|
|
21846
|
+
})
|
|
21847
|
+
}
|
|
21848
|
+
|
|
21849
|
+
exports.rsort = rsort;
|
|
21850
|
+
function rsort (list, loose) {
|
|
21851
|
+
return list.sort(function (a, b) {
|
|
21852
|
+
return exports.compareBuild(b, a, loose)
|
|
21853
|
+
})
|
|
21854
|
+
}
|
|
21855
|
+
|
|
21856
|
+
exports.gt = gt;
|
|
21857
|
+
function gt (a, b, loose) {
|
|
21858
|
+
return compare(a, b, loose) > 0
|
|
21859
|
+
}
|
|
21860
|
+
|
|
21861
|
+
exports.lt = lt;
|
|
21862
|
+
function lt (a, b, loose) {
|
|
21863
|
+
return compare(a, b, loose) < 0
|
|
21864
|
+
}
|
|
21865
|
+
|
|
21866
|
+
exports.eq = eq;
|
|
21867
|
+
function eq (a, b, loose) {
|
|
21868
|
+
return compare(a, b, loose) === 0
|
|
21869
|
+
}
|
|
21870
|
+
|
|
21871
|
+
exports.neq = neq;
|
|
21872
|
+
function neq (a, b, loose) {
|
|
21873
|
+
return compare(a, b, loose) !== 0
|
|
21874
|
+
}
|
|
21875
|
+
|
|
21876
|
+
exports.gte = gte;
|
|
21877
|
+
function gte (a, b, loose) {
|
|
21878
|
+
return compare(a, b, loose) >= 0
|
|
21879
|
+
}
|
|
21880
|
+
|
|
21881
|
+
exports.lte = lte;
|
|
21882
|
+
function lte (a, b, loose) {
|
|
21883
|
+
return compare(a, b, loose) <= 0
|
|
21884
|
+
}
|
|
21885
|
+
|
|
21886
|
+
exports.cmp = cmp;
|
|
21887
|
+
function cmp (a, op, b, loose) {
|
|
21888
|
+
switch (op) {
|
|
21889
|
+
case '===':
|
|
21890
|
+
if (typeof a === 'object')
|
|
21891
|
+
a = a.version;
|
|
21892
|
+
if (typeof b === 'object')
|
|
21893
|
+
b = b.version;
|
|
21894
|
+
return a === b
|
|
21895
|
+
|
|
21896
|
+
case '!==':
|
|
21897
|
+
if (typeof a === 'object')
|
|
21898
|
+
a = a.version;
|
|
21899
|
+
if (typeof b === 'object')
|
|
21900
|
+
b = b.version;
|
|
21901
|
+
return a !== b
|
|
21902
|
+
|
|
21903
|
+
case '':
|
|
21904
|
+
case '=':
|
|
21905
|
+
case '==':
|
|
21906
|
+
return eq(a, b, loose)
|
|
21907
|
+
|
|
21908
|
+
case '!=':
|
|
21909
|
+
return neq(a, b, loose)
|
|
21910
|
+
|
|
21911
|
+
case '>':
|
|
21912
|
+
return gt(a, b, loose)
|
|
21913
|
+
|
|
21914
|
+
case '>=':
|
|
21915
|
+
return gte(a, b, loose)
|
|
21916
|
+
|
|
21917
|
+
case '<':
|
|
21918
|
+
return lt(a, b, loose)
|
|
21919
|
+
|
|
21920
|
+
case '<=':
|
|
21921
|
+
return lte(a, b, loose)
|
|
21922
|
+
|
|
21923
|
+
default:
|
|
21924
|
+
throw new TypeError('Invalid operator: ' + op)
|
|
21925
|
+
}
|
|
21926
|
+
}
|
|
21927
|
+
|
|
21928
|
+
exports.Comparator = Comparator;
|
|
21929
|
+
function Comparator (comp, options) {
|
|
21930
|
+
if (!options || typeof options !== 'object') {
|
|
21931
|
+
options = {
|
|
21932
|
+
loose: !!options,
|
|
21933
|
+
includePrerelease: false
|
|
21934
|
+
};
|
|
21935
|
+
}
|
|
21936
|
+
|
|
21937
|
+
if (comp instanceof Comparator) {
|
|
21938
|
+
if (comp.loose === !!options.loose) {
|
|
21939
|
+
return comp
|
|
21940
|
+
} else {
|
|
21941
|
+
comp = comp.value;
|
|
21942
|
+
}
|
|
21943
|
+
}
|
|
21944
|
+
|
|
21945
|
+
if (!(this instanceof Comparator)) {
|
|
21946
|
+
return new Comparator(comp, options)
|
|
21947
|
+
}
|
|
21948
|
+
|
|
21949
|
+
debug('comparator', comp, options);
|
|
21950
|
+
this.options = options;
|
|
21951
|
+
this.loose = !!options.loose;
|
|
21952
|
+
this.parse(comp);
|
|
21953
|
+
|
|
21954
|
+
if (this.semver === ANY) {
|
|
21955
|
+
this.value = '';
|
|
21956
|
+
} else {
|
|
21957
|
+
this.value = this.operator + this.semver.version;
|
|
21958
|
+
}
|
|
21959
|
+
|
|
21960
|
+
debug('comp', this);
|
|
21961
|
+
}
|
|
21962
|
+
|
|
21963
|
+
var ANY = {};
|
|
21964
|
+
Comparator.prototype.parse = function (comp) {
|
|
21965
|
+
var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
21966
|
+
var m = comp.match(r);
|
|
21967
|
+
|
|
21968
|
+
if (!m) {
|
|
21969
|
+
throw new TypeError('Invalid comparator: ' + comp)
|
|
21970
|
+
}
|
|
21971
|
+
|
|
21972
|
+
this.operator = m[1] !== undefined ? m[1] : '';
|
|
21973
|
+
if (this.operator === '=') {
|
|
21974
|
+
this.operator = '';
|
|
21975
|
+
}
|
|
21976
|
+
|
|
21977
|
+
// if it literally is just '>' or '' then allow anything.
|
|
21978
|
+
if (!m[2]) {
|
|
21979
|
+
this.semver = ANY;
|
|
21980
|
+
} else {
|
|
21981
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
21982
|
+
}
|
|
21983
|
+
};
|
|
21984
|
+
|
|
21985
|
+
Comparator.prototype.toString = function () {
|
|
21986
|
+
return this.value
|
|
21987
|
+
};
|
|
21988
|
+
|
|
21989
|
+
Comparator.prototype.test = function (version) {
|
|
21990
|
+
debug('Comparator.test', version, this.options.loose);
|
|
21991
|
+
|
|
21992
|
+
if (this.semver === ANY || version === ANY) {
|
|
21993
|
+
return true
|
|
21994
|
+
}
|
|
21995
|
+
|
|
21996
|
+
if (typeof version === 'string') {
|
|
21997
|
+
try {
|
|
21998
|
+
version = new SemVer(version, this.options);
|
|
21999
|
+
} catch (er) {
|
|
22000
|
+
return false
|
|
22001
|
+
}
|
|
22002
|
+
}
|
|
22003
|
+
|
|
22004
|
+
return cmp(version, this.operator, this.semver, this.options)
|
|
22005
|
+
};
|
|
22006
|
+
|
|
22007
|
+
Comparator.prototype.intersects = function (comp, options) {
|
|
22008
|
+
if (!(comp instanceof Comparator)) {
|
|
22009
|
+
throw new TypeError('a Comparator is required')
|
|
22010
|
+
}
|
|
22011
|
+
|
|
22012
|
+
if (!options || typeof options !== 'object') {
|
|
22013
|
+
options = {
|
|
22014
|
+
loose: !!options,
|
|
22015
|
+
includePrerelease: false
|
|
22016
|
+
};
|
|
22017
|
+
}
|
|
22018
|
+
|
|
22019
|
+
var rangeTmp;
|
|
22020
|
+
|
|
22021
|
+
if (this.operator === '') {
|
|
22022
|
+
if (this.value === '') {
|
|
22023
|
+
return true
|
|
22024
|
+
}
|
|
22025
|
+
rangeTmp = new Range(comp.value, options);
|
|
22026
|
+
return satisfies(this.value, rangeTmp, options)
|
|
22027
|
+
} else if (comp.operator === '') {
|
|
22028
|
+
if (comp.value === '') {
|
|
22029
|
+
return true
|
|
22030
|
+
}
|
|
22031
|
+
rangeTmp = new Range(this.value, options);
|
|
22032
|
+
return satisfies(comp.semver, rangeTmp, options)
|
|
22033
|
+
}
|
|
22034
|
+
|
|
22035
|
+
var sameDirectionIncreasing =
|
|
22036
|
+
(this.operator === '>=' || this.operator === '>') &&
|
|
22037
|
+
(comp.operator === '>=' || comp.operator === '>');
|
|
22038
|
+
var sameDirectionDecreasing =
|
|
22039
|
+
(this.operator === '<=' || this.operator === '<') &&
|
|
22040
|
+
(comp.operator === '<=' || comp.operator === '<');
|
|
22041
|
+
var sameSemVer = this.semver.version === comp.semver.version;
|
|
22042
|
+
var differentDirectionsInclusive =
|
|
22043
|
+
(this.operator === '>=' || this.operator === '<=') &&
|
|
22044
|
+
(comp.operator === '>=' || comp.operator === '<=');
|
|
22045
|
+
var oppositeDirectionsLessThan =
|
|
22046
|
+
cmp(this.semver, '<', comp.semver, options) &&
|
|
22047
|
+
((this.operator === '>=' || this.operator === '>') &&
|
|
22048
|
+
(comp.operator === '<=' || comp.operator === '<'));
|
|
22049
|
+
var oppositeDirectionsGreaterThan =
|
|
22050
|
+
cmp(this.semver, '>', comp.semver, options) &&
|
|
22051
|
+
((this.operator === '<=' || this.operator === '<') &&
|
|
22052
|
+
(comp.operator === '>=' || comp.operator === '>'));
|
|
22053
|
+
|
|
22054
|
+
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
|
22055
|
+
(sameSemVer && differentDirectionsInclusive) ||
|
|
22056
|
+
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
|
22057
|
+
};
|
|
22058
|
+
|
|
22059
|
+
exports.Range = Range;
|
|
22060
|
+
function Range (range, options) {
|
|
22061
|
+
if (!options || typeof options !== 'object') {
|
|
22062
|
+
options = {
|
|
22063
|
+
loose: !!options,
|
|
22064
|
+
includePrerelease: false
|
|
22065
|
+
};
|
|
22066
|
+
}
|
|
22067
|
+
|
|
22068
|
+
if (range instanceof Range) {
|
|
22069
|
+
if (range.loose === !!options.loose &&
|
|
22070
|
+
range.includePrerelease === !!options.includePrerelease) {
|
|
22071
|
+
return range
|
|
22072
|
+
} else {
|
|
22073
|
+
return new Range(range.raw, options)
|
|
22074
|
+
}
|
|
22075
|
+
}
|
|
22076
|
+
|
|
22077
|
+
if (range instanceof Comparator) {
|
|
22078
|
+
return new Range(range.value, options)
|
|
22079
|
+
}
|
|
22080
|
+
|
|
22081
|
+
if (!(this instanceof Range)) {
|
|
22082
|
+
return new Range(range, options)
|
|
22083
|
+
}
|
|
22084
|
+
|
|
22085
|
+
this.options = options;
|
|
22086
|
+
this.loose = !!options.loose;
|
|
22087
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
22088
|
+
|
|
22089
|
+
// First, split based on boolean or ||
|
|
22090
|
+
this.raw = range;
|
|
22091
|
+
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
|
22092
|
+
return this.parseRange(range.trim())
|
|
22093
|
+
}, this).filter(function (c) {
|
|
22094
|
+
// throw out any that are not relevant for whatever reason
|
|
22095
|
+
return c.length
|
|
22096
|
+
});
|
|
22097
|
+
|
|
22098
|
+
if (!this.set.length) {
|
|
22099
|
+
throw new TypeError('Invalid SemVer Range: ' + range)
|
|
22100
|
+
}
|
|
22101
|
+
|
|
22102
|
+
this.format();
|
|
22103
|
+
}
|
|
22104
|
+
|
|
22105
|
+
Range.prototype.format = function () {
|
|
22106
|
+
this.range = this.set.map(function (comps) {
|
|
22107
|
+
return comps.join(' ').trim()
|
|
22108
|
+
}).join('||').trim();
|
|
22109
|
+
return this.range
|
|
22110
|
+
};
|
|
22111
|
+
|
|
22112
|
+
Range.prototype.toString = function () {
|
|
22113
|
+
return this.range
|
|
22114
|
+
};
|
|
22115
|
+
|
|
22116
|
+
Range.prototype.parseRange = function (range) {
|
|
22117
|
+
var loose = this.options.loose;
|
|
22118
|
+
range = range.trim();
|
|
22119
|
+
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
22120
|
+
var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
22121
|
+
range = range.replace(hr, hyphenReplace);
|
|
22122
|
+
debug('hyphen replace', range);
|
|
22123
|
+
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
22124
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
22125
|
+
debug('comparator trim', range, re[t.COMPARATORTRIM]);
|
|
22126
|
+
|
|
22127
|
+
// `~ 1.2.3` => `~1.2.3`
|
|
22128
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
22129
|
+
|
|
22130
|
+
// `^ 1.2.3` => `^1.2.3`
|
|
22131
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
22132
|
+
|
|
22133
|
+
// normalize spaces
|
|
22134
|
+
range = range.split(/\s+/).join(' ');
|
|
22135
|
+
|
|
22136
|
+
// At this point, the range is completely trimmed and
|
|
22137
|
+
// ready to be split into comparators.
|
|
22138
|
+
|
|
22139
|
+
var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
22140
|
+
var set = range.split(' ').map(function (comp) {
|
|
22141
|
+
return parseComparator(comp, this.options)
|
|
22142
|
+
}, this).join(' ').split(/\s+/);
|
|
22143
|
+
if (this.options.loose) {
|
|
22144
|
+
// in loose mode, throw out any that are not valid comparators
|
|
22145
|
+
set = set.filter(function (comp) {
|
|
22146
|
+
return !!comp.match(compRe)
|
|
22147
|
+
});
|
|
22148
|
+
}
|
|
22149
|
+
set = set.map(function (comp) {
|
|
22150
|
+
return new Comparator(comp, this.options)
|
|
22151
|
+
}, this);
|
|
22152
|
+
|
|
22153
|
+
return set
|
|
22154
|
+
};
|
|
22155
|
+
|
|
22156
|
+
Range.prototype.intersects = function (range, options) {
|
|
22157
|
+
if (!(range instanceof Range)) {
|
|
22158
|
+
throw new TypeError('a Range is required')
|
|
22159
|
+
}
|
|
22160
|
+
|
|
22161
|
+
return this.set.some(function (thisComparators) {
|
|
22162
|
+
return (
|
|
22163
|
+
isSatisfiable(thisComparators, options) &&
|
|
22164
|
+
range.set.some(function (rangeComparators) {
|
|
22165
|
+
return (
|
|
22166
|
+
isSatisfiable(rangeComparators, options) &&
|
|
22167
|
+
thisComparators.every(function (thisComparator) {
|
|
22168
|
+
return rangeComparators.every(function (rangeComparator) {
|
|
22169
|
+
return thisComparator.intersects(rangeComparator, options)
|
|
22170
|
+
})
|
|
22171
|
+
})
|
|
22172
|
+
)
|
|
22173
|
+
})
|
|
22174
|
+
)
|
|
22175
|
+
})
|
|
22176
|
+
};
|
|
22177
|
+
|
|
22178
|
+
// take a set of comparators and determine whether there
|
|
22179
|
+
// exists a version which can satisfy it
|
|
22180
|
+
function isSatisfiable (comparators, options) {
|
|
22181
|
+
var result = true;
|
|
22182
|
+
var remainingComparators = comparators.slice();
|
|
22183
|
+
var testComparator = remainingComparators.pop();
|
|
22184
|
+
|
|
22185
|
+
while (result && remainingComparators.length) {
|
|
22186
|
+
result = remainingComparators.every(function (otherComparator) {
|
|
22187
|
+
return testComparator.intersects(otherComparator, options)
|
|
22188
|
+
});
|
|
22189
|
+
|
|
22190
|
+
testComparator = remainingComparators.pop();
|
|
22191
|
+
}
|
|
22192
|
+
|
|
22193
|
+
return result
|
|
22194
|
+
}
|
|
22195
|
+
|
|
22196
|
+
// Mostly just for testing and legacy API reasons
|
|
22197
|
+
exports.toComparators = toComparators;
|
|
22198
|
+
function toComparators (range, options) {
|
|
22199
|
+
return new Range(range, options).set.map(function (comp) {
|
|
22200
|
+
return comp.map(function (c) {
|
|
22201
|
+
return c.value
|
|
22202
|
+
}).join(' ').trim().split(' ')
|
|
22203
|
+
})
|
|
22204
|
+
}
|
|
22205
|
+
|
|
22206
|
+
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
22207
|
+
// already replaced the hyphen ranges
|
|
22208
|
+
// turn into a set of JUST comparators.
|
|
22209
|
+
function parseComparator (comp, options) {
|
|
22210
|
+
debug('comp', comp, options);
|
|
22211
|
+
comp = replaceCarets(comp, options);
|
|
22212
|
+
debug('caret', comp);
|
|
22213
|
+
comp = replaceTildes(comp, options);
|
|
22214
|
+
debug('tildes', comp);
|
|
22215
|
+
comp = replaceXRanges(comp, options);
|
|
22216
|
+
debug('xrange', comp);
|
|
22217
|
+
comp = replaceStars(comp, options);
|
|
22218
|
+
debug('stars', comp);
|
|
22219
|
+
return comp
|
|
22220
|
+
}
|
|
22221
|
+
|
|
22222
|
+
function isX (id) {
|
|
22223
|
+
return !id || id.toLowerCase() === 'x' || id === '*'
|
|
22224
|
+
}
|
|
22225
|
+
|
|
22226
|
+
// ~, ~> --> * (any, kinda silly)
|
|
22227
|
+
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
|
22228
|
+
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
|
22229
|
+
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
|
22230
|
+
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
|
22231
|
+
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
|
22232
|
+
function replaceTildes (comp, options) {
|
|
22233
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
|
22234
|
+
return replaceTilde(comp, options)
|
|
22235
|
+
}).join(' ')
|
|
22236
|
+
}
|
|
22237
|
+
|
|
22238
|
+
function replaceTilde (comp, options) {
|
|
22239
|
+
var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
22240
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
|
22241
|
+
debug('tilde', comp, _, M, m, p, pr);
|
|
22242
|
+
var ret;
|
|
22243
|
+
|
|
22244
|
+
if (isX(M)) {
|
|
22245
|
+
ret = '';
|
|
22246
|
+
} else if (isX(m)) {
|
|
22247
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
|
22248
|
+
} else if (isX(p)) {
|
|
22249
|
+
// ~1.2 == >=1.2.0 <1.3.0
|
|
22250
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
|
|
22251
|
+
} else if (pr) {
|
|
22252
|
+
debug('replaceTilde pr', pr);
|
|
22253
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
22254
|
+
' <' + M + '.' + (+m + 1) + '.0';
|
|
22255
|
+
} else {
|
|
22256
|
+
// ~1.2.3 == >=1.2.3 <1.3.0
|
|
22257
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
22258
|
+
' <' + M + '.' + (+m + 1) + '.0';
|
|
22259
|
+
}
|
|
22260
|
+
|
|
22261
|
+
debug('tilde return', ret);
|
|
22262
|
+
return ret
|
|
22263
|
+
})
|
|
22264
|
+
}
|
|
22265
|
+
|
|
22266
|
+
// ^ --> * (any, kinda silly)
|
|
22267
|
+
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
|
22268
|
+
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
|
22269
|
+
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
|
22270
|
+
// ^1.2.3 --> >=1.2.3 <2.0.0
|
|
22271
|
+
// ^1.2.0 --> >=1.2.0 <2.0.0
|
|
22272
|
+
function replaceCarets (comp, options) {
|
|
22273
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
|
22274
|
+
return replaceCaret(comp, options)
|
|
22275
|
+
}).join(' ')
|
|
22276
|
+
}
|
|
22277
|
+
|
|
22278
|
+
function replaceCaret (comp, options) {
|
|
22279
|
+
debug('caret', comp, options);
|
|
22280
|
+
var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
22281
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
|
22282
|
+
debug('caret', comp, _, M, m, p, pr);
|
|
22283
|
+
var ret;
|
|
22284
|
+
|
|
22285
|
+
if (isX(M)) {
|
|
22286
|
+
ret = '';
|
|
22287
|
+
} else if (isX(m)) {
|
|
22288
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
|
22289
|
+
} else if (isX(p)) {
|
|
22290
|
+
if (M === '0') {
|
|
22291
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
|
|
22292
|
+
} else {
|
|
22293
|
+
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
|
|
22294
|
+
}
|
|
22295
|
+
} else if (pr) {
|
|
22296
|
+
debug('replaceCaret pr', pr);
|
|
22297
|
+
if (M === '0') {
|
|
22298
|
+
if (m === '0') {
|
|
22299
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
22300
|
+
' <' + M + '.' + m + '.' + (+p + 1);
|
|
22301
|
+
} else {
|
|
22302
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
22303
|
+
' <' + M + '.' + (+m + 1) + '.0';
|
|
22304
|
+
}
|
|
22305
|
+
} else {
|
|
22306
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
22307
|
+
' <' + (+M + 1) + '.0.0';
|
|
22308
|
+
}
|
|
22309
|
+
} else {
|
|
22310
|
+
debug('no pr');
|
|
22311
|
+
if (M === '0') {
|
|
22312
|
+
if (m === '0') {
|
|
22313
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
22314
|
+
' <' + M + '.' + m + '.' + (+p + 1);
|
|
22315
|
+
} else {
|
|
22316
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
22317
|
+
' <' + M + '.' + (+m + 1) + '.0';
|
|
22318
|
+
}
|
|
22319
|
+
} else {
|
|
22320
|
+
ret = '>=' + M + '.' + m + '.' + p +
|
|
22321
|
+
' <' + (+M + 1) + '.0.0';
|
|
22322
|
+
}
|
|
22323
|
+
}
|
|
22324
|
+
|
|
22325
|
+
debug('caret return', ret);
|
|
22326
|
+
return ret
|
|
22327
|
+
})
|
|
22328
|
+
}
|
|
22329
|
+
|
|
22330
|
+
function replaceXRanges (comp, options) {
|
|
22331
|
+
debug('replaceXRanges', comp, options);
|
|
22332
|
+
return comp.split(/\s+/).map(function (comp) {
|
|
22333
|
+
return replaceXRange(comp, options)
|
|
22334
|
+
}).join(' ')
|
|
22335
|
+
}
|
|
22336
|
+
|
|
22337
|
+
function replaceXRange (comp, options) {
|
|
22338
|
+
comp = comp.trim();
|
|
22339
|
+
var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
22340
|
+
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
|
22341
|
+
debug('xRange', comp, ret, gtlt, M, m, p, pr);
|
|
22342
|
+
var xM = isX(M);
|
|
22343
|
+
var xm = xM || isX(m);
|
|
22344
|
+
var xp = xm || isX(p);
|
|
22345
|
+
var anyX = xp;
|
|
22346
|
+
|
|
22347
|
+
if (gtlt === '=' && anyX) {
|
|
22348
|
+
gtlt = '';
|
|
22349
|
+
}
|
|
22350
|
+
|
|
22351
|
+
// if we're including prereleases in the match, then we need
|
|
22352
|
+
// to fix this to -0, the lowest possible prerelease value
|
|
22353
|
+
pr = options.includePrerelease ? '-0' : '';
|
|
22354
|
+
|
|
22355
|
+
if (xM) {
|
|
22356
|
+
if (gtlt === '>' || gtlt === '<') {
|
|
22357
|
+
// nothing is allowed
|
|
22358
|
+
ret = '<0.0.0-0';
|
|
22359
|
+
} else {
|
|
22360
|
+
// nothing is forbidden
|
|
22361
|
+
ret = '*';
|
|
22362
|
+
}
|
|
22363
|
+
} else if (gtlt && anyX) {
|
|
22364
|
+
// we know patch is an x, because we have any x at all.
|
|
22365
|
+
// replace X with 0
|
|
22366
|
+
if (xm) {
|
|
22367
|
+
m = 0;
|
|
22368
|
+
}
|
|
22369
|
+
p = 0;
|
|
22370
|
+
|
|
22371
|
+
if (gtlt === '>') {
|
|
22372
|
+
// >1 => >=2.0.0
|
|
22373
|
+
// >1.2 => >=1.3.0
|
|
22374
|
+
// >1.2.3 => >= 1.2.4
|
|
22375
|
+
gtlt = '>=';
|
|
22376
|
+
if (xm) {
|
|
22377
|
+
M = +M + 1;
|
|
22378
|
+
m = 0;
|
|
22379
|
+
p = 0;
|
|
22380
|
+
} else {
|
|
22381
|
+
m = +m + 1;
|
|
22382
|
+
p = 0;
|
|
22383
|
+
}
|
|
22384
|
+
} else if (gtlt === '<=') {
|
|
22385
|
+
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
22386
|
+
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
22387
|
+
gtlt = '<';
|
|
22388
|
+
if (xm) {
|
|
22389
|
+
M = +M + 1;
|
|
22390
|
+
} else {
|
|
22391
|
+
m = +m + 1;
|
|
22392
|
+
}
|
|
22393
|
+
}
|
|
22394
|
+
|
|
22395
|
+
ret = gtlt + M + '.' + m + '.' + p + pr;
|
|
22396
|
+
} else if (xm) {
|
|
22397
|
+
ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
|
|
22398
|
+
} else if (xp) {
|
|
22399
|
+
ret = '>=' + M + '.' + m + '.0' + pr +
|
|
22400
|
+
' <' + M + '.' + (+m + 1) + '.0' + pr;
|
|
22401
|
+
}
|
|
22402
|
+
|
|
22403
|
+
debug('xRange return', ret);
|
|
22404
|
+
|
|
22405
|
+
return ret
|
|
22406
|
+
})
|
|
22407
|
+
}
|
|
22408
|
+
|
|
22409
|
+
// Because * is AND-ed with everything else in the comparator,
|
|
22410
|
+
// and '' means "any version", just remove the *s entirely.
|
|
22411
|
+
function replaceStars (comp, options) {
|
|
22412
|
+
debug('replaceStars', comp, options);
|
|
22413
|
+
// Looseness is ignored here. star is always as loose as it gets!
|
|
22414
|
+
return comp.trim().replace(re[t.STAR], '')
|
|
22415
|
+
}
|
|
22416
|
+
|
|
22417
|
+
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
|
22418
|
+
// M, m, patch, prerelease, build
|
|
22419
|
+
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
22420
|
+
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
|
22421
|
+
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
|
22422
|
+
function hyphenReplace ($0,
|
|
22423
|
+
from, fM, fm, fp, fpr, fb,
|
|
22424
|
+
to, tM, tm, tp, tpr, tb) {
|
|
22425
|
+
if (isX(fM)) {
|
|
22426
|
+
from = '';
|
|
22427
|
+
} else if (isX(fm)) {
|
|
22428
|
+
from = '>=' + fM + '.0.0';
|
|
22429
|
+
} else if (isX(fp)) {
|
|
22430
|
+
from = '>=' + fM + '.' + fm + '.0';
|
|
22431
|
+
} else {
|
|
22432
|
+
from = '>=' + from;
|
|
22433
|
+
}
|
|
22434
|
+
|
|
22435
|
+
if (isX(tM)) {
|
|
22436
|
+
to = '';
|
|
22437
|
+
} else if (isX(tm)) {
|
|
22438
|
+
to = '<' + (+tM + 1) + '.0.0';
|
|
22439
|
+
} else if (isX(tp)) {
|
|
22440
|
+
to = '<' + tM + '.' + (+tm + 1) + '.0';
|
|
22441
|
+
} else if (tpr) {
|
|
22442
|
+
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
|
|
22443
|
+
} else {
|
|
22444
|
+
to = '<=' + to;
|
|
22445
|
+
}
|
|
22446
|
+
|
|
22447
|
+
return (from + ' ' + to).trim()
|
|
22448
|
+
}
|
|
22449
|
+
|
|
22450
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
22451
|
+
Range.prototype.test = function (version) {
|
|
22452
|
+
if (!version) {
|
|
22453
|
+
return false
|
|
22454
|
+
}
|
|
22455
|
+
|
|
22456
|
+
if (typeof version === 'string') {
|
|
22457
|
+
try {
|
|
22458
|
+
version = new SemVer(version, this.options);
|
|
22459
|
+
} catch (er) {
|
|
22460
|
+
return false
|
|
22461
|
+
}
|
|
22462
|
+
}
|
|
22463
|
+
|
|
22464
|
+
for (var i = 0; i < this.set.length; i++) {
|
|
22465
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
22466
|
+
return true
|
|
22467
|
+
}
|
|
22468
|
+
}
|
|
22469
|
+
return false
|
|
22470
|
+
};
|
|
22471
|
+
|
|
22472
|
+
function testSet (set, version, options) {
|
|
22473
|
+
for (var i = 0; i < set.length; i++) {
|
|
22474
|
+
if (!set[i].test(version)) {
|
|
22475
|
+
return false
|
|
22476
|
+
}
|
|
22477
|
+
}
|
|
22478
|
+
|
|
22479
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
22480
|
+
// Find the set of versions that are allowed to have prereleases
|
|
22481
|
+
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
22482
|
+
// That should allow `1.2.3-pr.2` to pass.
|
|
22483
|
+
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
22484
|
+
// even though it's within the range set by the comparators.
|
|
22485
|
+
for (i = 0; i < set.length; i++) {
|
|
22486
|
+
debug(set[i].semver);
|
|
22487
|
+
if (set[i].semver === ANY) {
|
|
22488
|
+
continue
|
|
22489
|
+
}
|
|
22490
|
+
|
|
22491
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
22492
|
+
var allowed = set[i].semver;
|
|
22493
|
+
if (allowed.major === version.major &&
|
|
22494
|
+
allowed.minor === version.minor &&
|
|
22495
|
+
allowed.patch === version.patch) {
|
|
22496
|
+
return true
|
|
22497
|
+
}
|
|
22498
|
+
}
|
|
22499
|
+
}
|
|
22500
|
+
|
|
22501
|
+
// Version has a -pre, but it's not one of the ones we like.
|
|
22502
|
+
return false
|
|
22503
|
+
}
|
|
22504
|
+
|
|
22505
|
+
return true
|
|
22506
|
+
}
|
|
22507
|
+
|
|
22508
|
+
exports.satisfies = satisfies;
|
|
22509
|
+
function satisfies (version, range, options) {
|
|
22510
|
+
try {
|
|
22511
|
+
range = new Range(range, options);
|
|
22512
|
+
} catch (er) {
|
|
22513
|
+
return false
|
|
22514
|
+
}
|
|
22515
|
+
return range.test(version)
|
|
22516
|
+
}
|
|
22517
|
+
|
|
22518
|
+
exports.maxSatisfying = maxSatisfying;
|
|
22519
|
+
function maxSatisfying (versions, range, options) {
|
|
22520
|
+
var max = null;
|
|
22521
|
+
var maxSV = null;
|
|
22522
|
+
try {
|
|
22523
|
+
var rangeObj = new Range(range, options);
|
|
22524
|
+
} catch (er) {
|
|
22525
|
+
return null
|
|
22526
|
+
}
|
|
22527
|
+
versions.forEach(function (v) {
|
|
22528
|
+
if (rangeObj.test(v)) {
|
|
22529
|
+
// satisfies(v, range, options)
|
|
22530
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
22531
|
+
// compare(max, v, true)
|
|
22532
|
+
max = v;
|
|
22533
|
+
maxSV = new SemVer(max, options);
|
|
22534
|
+
}
|
|
22535
|
+
}
|
|
22536
|
+
});
|
|
22537
|
+
return max
|
|
22538
|
+
}
|
|
22539
|
+
|
|
22540
|
+
exports.minSatisfying = minSatisfying;
|
|
22541
|
+
function minSatisfying (versions, range, options) {
|
|
22542
|
+
var min = null;
|
|
22543
|
+
var minSV = null;
|
|
22544
|
+
try {
|
|
22545
|
+
var rangeObj = new Range(range, options);
|
|
22546
|
+
} catch (er) {
|
|
22547
|
+
return null
|
|
22548
|
+
}
|
|
22549
|
+
versions.forEach(function (v) {
|
|
22550
|
+
if (rangeObj.test(v)) {
|
|
22551
|
+
// satisfies(v, range, options)
|
|
22552
|
+
if (!min || minSV.compare(v) === 1) {
|
|
22553
|
+
// compare(min, v, true)
|
|
22554
|
+
min = v;
|
|
22555
|
+
minSV = new SemVer(min, options);
|
|
22556
|
+
}
|
|
22557
|
+
}
|
|
22558
|
+
});
|
|
22559
|
+
return min
|
|
22560
|
+
}
|
|
22561
|
+
|
|
22562
|
+
exports.minVersion = minVersion;
|
|
22563
|
+
function minVersion (range, loose) {
|
|
22564
|
+
range = new Range(range, loose);
|
|
22565
|
+
|
|
22566
|
+
var minver = new SemVer('0.0.0');
|
|
22567
|
+
if (range.test(minver)) {
|
|
22568
|
+
return minver
|
|
22569
|
+
}
|
|
22570
|
+
|
|
22571
|
+
minver = new SemVer('0.0.0-0');
|
|
22572
|
+
if (range.test(minver)) {
|
|
22573
|
+
return minver
|
|
22574
|
+
}
|
|
22575
|
+
|
|
22576
|
+
minver = null;
|
|
22577
|
+
for (var i = 0; i < range.set.length; ++i) {
|
|
22578
|
+
var comparators = range.set[i];
|
|
22579
|
+
|
|
22580
|
+
comparators.forEach(function (comparator) {
|
|
22581
|
+
// Clone to avoid manipulating the comparator's semver object.
|
|
22582
|
+
var compver = new SemVer(comparator.semver.version);
|
|
22583
|
+
switch (comparator.operator) {
|
|
22584
|
+
case '>':
|
|
22585
|
+
if (compver.prerelease.length === 0) {
|
|
22586
|
+
compver.patch++;
|
|
22587
|
+
} else {
|
|
22588
|
+
compver.prerelease.push(0);
|
|
22589
|
+
}
|
|
22590
|
+
compver.raw = compver.format();
|
|
22591
|
+
/* fallthrough */
|
|
22592
|
+
case '':
|
|
22593
|
+
case '>=':
|
|
22594
|
+
if (!minver || gt(minver, compver)) {
|
|
22595
|
+
minver = compver;
|
|
22596
|
+
}
|
|
22597
|
+
break
|
|
22598
|
+
case '<':
|
|
22599
|
+
case '<=':
|
|
22600
|
+
/* Ignore maximum versions */
|
|
22601
|
+
break
|
|
22602
|
+
/* istanbul ignore next */
|
|
22603
|
+
default:
|
|
22604
|
+
throw new Error('Unexpected operation: ' + comparator.operator)
|
|
22605
|
+
}
|
|
22606
|
+
});
|
|
22607
|
+
}
|
|
22608
|
+
|
|
22609
|
+
if (minver && range.test(minver)) {
|
|
22610
|
+
return minver
|
|
22611
|
+
}
|
|
22612
|
+
|
|
22613
|
+
return null
|
|
22614
|
+
}
|
|
22615
|
+
|
|
22616
|
+
exports.validRange = validRange;
|
|
22617
|
+
function validRange (range, options) {
|
|
22618
|
+
try {
|
|
22619
|
+
// Return '*' instead of '' so that truthiness works.
|
|
22620
|
+
// This will throw if it's invalid anyway
|
|
22621
|
+
return new Range(range, options).range || '*'
|
|
22622
|
+
} catch (er) {
|
|
22623
|
+
return null
|
|
22624
|
+
}
|
|
22625
|
+
}
|
|
22626
|
+
|
|
22627
|
+
// Determine if version is less than all the versions possible in the range
|
|
22628
|
+
exports.ltr = ltr;
|
|
22629
|
+
function ltr (version, range, options) {
|
|
22630
|
+
return outside(version, range, '<', options)
|
|
22631
|
+
}
|
|
22632
|
+
|
|
22633
|
+
// Determine if version is greater than all the versions possible in the range.
|
|
22634
|
+
exports.gtr = gtr;
|
|
22635
|
+
function gtr (version, range, options) {
|
|
22636
|
+
return outside(version, range, '>', options)
|
|
22637
|
+
}
|
|
22638
|
+
|
|
22639
|
+
exports.outside = outside;
|
|
22640
|
+
function outside (version, range, hilo, options) {
|
|
22641
|
+
version = new SemVer(version, options);
|
|
22642
|
+
range = new Range(range, options);
|
|
22643
|
+
|
|
22644
|
+
var gtfn, ltefn, ltfn, comp, ecomp;
|
|
22645
|
+
switch (hilo) {
|
|
22646
|
+
case '>':
|
|
22647
|
+
gtfn = gt;
|
|
22648
|
+
ltefn = lte;
|
|
22649
|
+
ltfn = lt;
|
|
22650
|
+
comp = '>';
|
|
22651
|
+
ecomp = '>=';
|
|
22652
|
+
break
|
|
22653
|
+
case '<':
|
|
22654
|
+
gtfn = lt;
|
|
22655
|
+
ltefn = gte;
|
|
22656
|
+
ltfn = gt;
|
|
22657
|
+
comp = '<';
|
|
22658
|
+
ecomp = '<=';
|
|
22659
|
+
break
|
|
22660
|
+
default:
|
|
22661
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
|
22662
|
+
}
|
|
22663
|
+
|
|
22664
|
+
// If it satisifes the range it is not outside
|
|
22665
|
+
if (satisfies(version, range, options)) {
|
|
22666
|
+
return false
|
|
22667
|
+
}
|
|
22668
|
+
|
|
22669
|
+
// From now on, variable terms are as if we're in "gtr" mode.
|
|
22670
|
+
// but note that everything is flipped for the "ltr" function.
|
|
22671
|
+
|
|
22672
|
+
for (var i = 0; i < range.set.length; ++i) {
|
|
22673
|
+
var comparators = range.set[i];
|
|
22674
|
+
|
|
22675
|
+
var high = null;
|
|
22676
|
+
var low = null;
|
|
22677
|
+
|
|
22678
|
+
comparators.forEach(function (comparator) {
|
|
22679
|
+
if (comparator.semver === ANY) {
|
|
22680
|
+
comparator = new Comparator('>=0.0.0');
|
|
22681
|
+
}
|
|
22682
|
+
high = high || comparator;
|
|
22683
|
+
low = low || comparator;
|
|
22684
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
22685
|
+
high = comparator;
|
|
22686
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
22687
|
+
low = comparator;
|
|
22688
|
+
}
|
|
22689
|
+
});
|
|
22690
|
+
|
|
22691
|
+
// If the edge version comparator has a operator then our version
|
|
22692
|
+
// isn't outside it
|
|
22693
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
22694
|
+
return false
|
|
22695
|
+
}
|
|
22696
|
+
|
|
22697
|
+
// If the lowest version comparator has an operator and our version
|
|
22698
|
+
// is less than it then it isn't higher than the range
|
|
22699
|
+
if ((!low.operator || low.operator === comp) &&
|
|
22700
|
+
ltefn(version, low.semver)) {
|
|
22701
|
+
return false
|
|
22702
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
22703
|
+
return false
|
|
22704
|
+
}
|
|
22705
|
+
}
|
|
22706
|
+
return true
|
|
22707
|
+
}
|
|
22708
|
+
|
|
22709
|
+
exports.prerelease = prerelease;
|
|
22710
|
+
function prerelease (version, options) {
|
|
22711
|
+
var parsed = parse(version, options);
|
|
22712
|
+
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
|
22713
|
+
}
|
|
22714
|
+
|
|
22715
|
+
exports.intersects = intersects;
|
|
22716
|
+
function intersects (r1, r2, options) {
|
|
22717
|
+
r1 = new Range(r1, options);
|
|
22718
|
+
r2 = new Range(r2, options);
|
|
22719
|
+
return r1.intersects(r2)
|
|
22720
|
+
}
|
|
22721
|
+
|
|
22722
|
+
exports.coerce = coerce;
|
|
22723
|
+
function coerce (version, options) {
|
|
22724
|
+
if (version instanceof SemVer) {
|
|
22725
|
+
return version
|
|
22726
|
+
}
|
|
22727
|
+
|
|
22728
|
+
if (typeof version === 'number') {
|
|
22729
|
+
version = String(version);
|
|
22730
|
+
}
|
|
22731
|
+
|
|
22732
|
+
if (typeof version !== 'string') {
|
|
22733
|
+
return null
|
|
22734
|
+
}
|
|
22735
|
+
|
|
22736
|
+
options = options || {};
|
|
22737
|
+
|
|
22738
|
+
var match = null;
|
|
22739
|
+
if (!options.rtl) {
|
|
22740
|
+
match = version.match(re[t.COERCE]);
|
|
22741
|
+
} else {
|
|
22742
|
+
// Find the right-most coercible string that does not share
|
|
22743
|
+
// a terminus with a more left-ward coercible string.
|
|
22744
|
+
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
22745
|
+
//
|
|
22746
|
+
// Walk through the string checking with a /g regexp
|
|
22747
|
+
// Manually set the index so as to pick up overlapping matches.
|
|
22748
|
+
// Stop when we get a match that ends at the string end, since no
|
|
22749
|
+
// coercible string can be more right-ward without the same terminus.
|
|
22750
|
+
var next;
|
|
22751
|
+
while ((next = re[t.COERCERTL].exec(version)) &&
|
|
22752
|
+
(!match || match.index + match[0].length !== version.length)
|
|
22753
|
+
) {
|
|
22754
|
+
if (!match ||
|
|
22755
|
+
next.index + next[0].length !== match.index + match[0].length) {
|
|
22756
|
+
match = next;
|
|
22757
|
+
}
|
|
22758
|
+
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
|
|
22759
|
+
}
|
|
22760
|
+
// leave it in a clean state
|
|
22761
|
+
re[t.COERCERTL].lastIndex = -1;
|
|
22762
|
+
}
|
|
22763
|
+
|
|
22764
|
+
if (match === null) {
|
|
22765
|
+
return null
|
|
22766
|
+
}
|
|
22767
|
+
|
|
22768
|
+
return parse(match[2] +
|
|
22769
|
+
'.' + (match[3] || '0') +
|
|
22770
|
+
'.' + (match[4] || '0'), options)
|
|
22771
|
+
}
|
|
22772
|
+
} (semver, semverExports));
|
|
22255
22773
|
|
|
22256
22774
|
const LOADED = {};
|
|
22257
22775
|
|
|
@@ -22813,7 +23331,7 @@ function nuked() {
|
|
|
22813
23331
|
*/
|
|
22814
23332
|
|
|
22815
23333
|
/**
|
|
22816
|
-
* @typedef { boolean | 'toggle'
|
|
23334
|
+
* @typedef { boolean | 'toggle' } SearchMode
|
|
22817
23335
|
*/
|
|
22818
23336
|
|
|
22819
23337
|
/**
|
|
@@ -22859,7 +23377,7 @@ function nuked() {
|
|
|
22859
23377
|
* @param {ListLayout=} [options.listLayout=vertical] Layout direction vertical|horizontal (not applicable for existing objects)
|
|
22860
23378
|
* @param {FrequencyMode=} [options.frequencyMode=none] Show frequency none|value|percent|relative
|
|
22861
23379
|
* @param {boolean=} [options.histogram=false] Show histogram bar (not applicable for existing objects)
|
|
22862
|
-
* @param {SearchMode=} [options.search=true] Show the search bar permanently, using the toggle button or when in selection: false|true|toggle
|
|
23380
|
+
* @param {SearchMode=} [options.search=true] Show the search bar permanently, using the toggle button or when in selection: false|true|toggle
|
|
22863
23381
|
* @param {boolean=} [options.toolbar=true] Show the toolbar
|
|
22864
23382
|
* @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields (not applicable for existing objects)
|
|
22865
23383
|
* @param {boolean=} [options.dense=false] Reduces padding and text size (not applicable for existing objects)
|