@nebula.js/stardust 4.0.0-alpha.8 → 4.0.0-alpha.9

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v4.0.0-alpha.8
2
+ * @nebula.js/stardust v4.0.0-alpha.9
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -1653,6 +1653,246 @@ var Visualization_UnfulfilledCalculationCondition = {
1653
1653
  "zh-TW": "不符計算條件"
1654
1654
  }
1655
1655
  };
1656
+ var Object_Listbox_Selected = {
1657
+ id: "Object.Listbox.Selected",
1658
+ locale: {
1659
+ "de-DE": "Ausgewählt",
1660
+ "en-US": "Selected",
1661
+ "es-ES": "Seleccionado",
1662
+ "fr-FR": "Sélectionné",
1663
+ "it-IT": "Selezionato",
1664
+ "ja-JP": "選択済み",
1665
+ "ko-KR": "선택됨",
1666
+ "nl-NL": "Geselecteerd",
1667
+ "pl-PL": "Wybrane",
1668
+ "pt-BR": "Selecionado",
1669
+ "ru-RU": "Выбранные",
1670
+ "sv-SE": "Urval",
1671
+ "tr-TR": "Seçilen",
1672
+ "zh-CN": "已选择",
1673
+ "zh-TW": "已選取"
1674
+ }
1675
+ };
1676
+ var Object_Listbox_Alternative = {
1677
+ id: "Object.Listbox.Alternative",
1678
+ locale: {
1679
+ "de-DE": "Alternative",
1680
+ "en-US": "Alternative",
1681
+ "es-ES": "Alternativo",
1682
+ "fr-FR": "Alternatif",
1683
+ "it-IT": "Alternativo",
1684
+ "ja-JP": "代替",
1685
+ "ko-KR": "대체 항목",
1686
+ "nl-NL": "Alternatief",
1687
+ "pl-PL": "Alternatywne",
1688
+ "pt-BR": "Alternativo",
1689
+ "ru-RU": "Альтернативные",
1690
+ "sv-SE": "Alternativ",
1691
+ "tr-TR": "Alternatif",
1692
+ "zh-CN": "可选",
1693
+ "zh-TW": "替代選項"
1694
+ }
1695
+ };
1696
+ var Object_Listbox_Optional = {
1697
+ id: "Object.Listbox.Optional",
1698
+ locale: {
1699
+ "de-DE": "Optional",
1700
+ "en-US": "Optional",
1701
+ "es-ES": "Opcional",
1702
+ "fr-FR": "Facultatif",
1703
+ "it-IT": "Opzionale",
1704
+ "ja-JP": "オプション",
1705
+ "ko-KR": "선택 사항",
1706
+ "nl-NL": "Optioneel",
1707
+ "pl-PL": "Opcjonalne",
1708
+ "pt-BR": "Opcional",
1709
+ "ru-RU": "Дополнительные",
1710
+ "sv-SE": "Valfritt",
1711
+ "tr-TR": "İsteğe bağlı",
1712
+ "zh-CN": "可选",
1713
+ "zh-TW": "選用"
1714
+ }
1715
+ };
1716
+ var Object_Listbox_SelectedExcluded = {
1717
+ id: "Object.Listbox.SelectedExcluded",
1718
+ locale: {
1719
+ "de-DE": "Ausgeschlossen ausgewählt",
1720
+ "en-US": "Selected excluded",
1721
+ "es-ES": "Seleccionado excluido",
1722
+ "fr-FR": "Sélectionné exclu",
1723
+ "it-IT": "Selezionato escluso",
1724
+ "ja-JP": "選択された除外値",
1725
+ "ko-KR": "제외 항목 선택됨",
1726
+ "nl-NL": "Geselecteerde uitgesloten",
1727
+ "pl-PL": "Wybrane wykluczone",
1728
+ "pt-BR": "Excluído selecionado",
1729
+ "ru-RU": "Выбранные исключенные элементы",
1730
+ "sv-SE": "Urval uteslutet",
1731
+ "tr-TR": "Seçili hariç tutulan",
1732
+ "zh-CN": "已排除选择",
1733
+ "zh-TW": "已選取排除值"
1734
+ }
1735
+ };
1736
+ var Object_Listbox_Locked = {
1737
+ id: "Object.Listbox.Locked",
1738
+ locale: {
1739
+ "de-DE": "Gesperrt",
1740
+ "en-US": "Locked",
1741
+ "es-ES": "Bloqueado",
1742
+ "fr-FR": "Verrouillé",
1743
+ "it-IT": "Bloccato",
1744
+ "ja-JP": "ロック済み",
1745
+ "ko-KR": "잠김",
1746
+ "nl-NL": "Vergrendeld",
1747
+ "pl-PL": "Zablokowane",
1748
+ "pt-BR": "Bloqueado",
1749
+ "ru-RU": "Заблокированные",
1750
+ "sv-SE": "Låst",
1751
+ "tr-TR": "Kilitli",
1752
+ "zh-CN": "已锁定",
1753
+ "zh-TW": "已鎖定"
1754
+ }
1755
+ };
1756
+ var Object_Listbox_Excluded = {
1757
+ id: "Object.Listbox.Excluded",
1758
+ locale: {
1759
+ "de-DE": "Ausgeschlossen",
1760
+ "en-US": "Excluded",
1761
+ "es-ES": "Excluido",
1762
+ "fr-FR": "Exclu",
1763
+ "it-IT": "Escluso",
1764
+ "ja-JP": "除外済み",
1765
+ "ko-KR": "제외됨",
1766
+ "nl-NL": "Uitgesloten",
1767
+ "pl-PL": "Wykluczone",
1768
+ "pt-BR": "Excluído",
1769
+ "ru-RU": "Исключенные",
1770
+ "sv-SE": "Uteslutet",
1771
+ "tr-TR": "Hariç tutulan",
1772
+ "zh-CN": "已排除",
1773
+ "zh-TW": "已排除"
1774
+ }
1775
+ };
1776
+ var Object_Listbox_ExcludedLock = {
1777
+ id: "Object.Listbox.ExcludedLock",
1778
+ locale: {
1779
+ "de-DE": "Ausgeschlossene Sperre",
1780
+ "en-US": "Excluded lock",
1781
+ "es-ES": "Bloqueo excluido",
1782
+ "fr-FR": "Exclu verrouillé",
1783
+ "it-IT": "Blocco escluso",
1784
+ "ja-JP": "除外されたロック",
1785
+ "ko-KR": "제외된 잠금",
1786
+ "nl-NL": "Uitsluitingsvergrendeling",
1787
+ "pl-PL": "Wykluczone zablokowane",
1788
+ "pt-BR": "Bloqueado excluído",
1789
+ "ru-RU": "Блокировать исключенные элементы",
1790
+ "sv-SE": "Uteslutet låst",
1791
+ "tr-TR": "Hariç tutulan kilit",
1792
+ "zh-CN": "已排除锁定",
1793
+ "zh-TW": "已排除鎖定"
1794
+ }
1795
+ };
1796
+ var Listbox_ScreenReader_SelectionMenu_WithAccSelMenu = {
1797
+ id: "Listbox.ScreenReader.SelectionMenu.WithAccSelMenu",
1798
+ locale: {
1799
+ "de-DE": "Drücken Sie gleichzeitig die Umschalt- und die Tabulatortaste, um den Fokus in das Auswahlmenü zu setzen.",
1800
+ "en-US": "Press Shift plus Tab to set focus on the selections menu.",
1801
+ "es-ES": "Pulse Mayús + Tabulador para establecer el foco en el menú de selecciones.",
1802
+ "fr-FR": "Appuyez sur Maj + Tab pour mettre le focus sur le menu de sélections.",
1803
+ "it-IT": "Premere insieme i tasti MAIUSC+TAB per evidenziare il menu di selezione.",
1804
+ "ja-JP": "Shift キー + Tab キーを押して、選択メニューで焦点を設定します。",
1805
+ "ko-KR": "선택 메뉴에 초점을 설정하려면 Shift+Tab을 누르십시오.",
1806
+ "nl-NL": "Druk op Shift + Tab om de focus in te stellen op het selectiemenu.",
1807
+ "pl-PL": "Naciśnij Shift i Tab, aby ustawić ostrość na menu selekcji.",
1808
+ "pt-BR": "Pressione Shift + Tab para definir o foco sobre o menu de seleções.",
1809
+ "ru-RU": "Нажмите сочетание клавиш \"Shift + Tab\" для установки фокуса на меню выбора.",
1810
+ "sv-SE": "Tryck på Skift plus Tabb när du vill ställa in fokus på urvalsmenyn.",
1811
+ "tr-TR": "Odağı seçim menüsüne ayarlamak için Shift ve Sekme tuşlarına birlikte basın.",
1812
+ "zh-CN": "按下 Shift 加 Tab 以将焦点设置在选择菜单上。",
1813
+ "zh-TW": "按下 Shift 加 Tab 以在選項功能表上設定焦點。"
1814
+ }
1815
+ };
1816
+ var Listbox_ScreenReader_SearchThenSelectionsMenu_WithAccSelMenu = {
1817
+ id: "Listbox.ScreenReader.SearchThenSelectionsMenu.WithAccSelMenu",
1818
+ locale: {
1819
+ "de-DE": "Drücken Sie die Umschalttaste zusammen mit der Tabulatortaste, um den Fokus in die Suchleiste zu setzen, und dann erneut beide Tasten, um den Fokus in das Auswahlmenü zu setzen.",
1820
+ "en-US": "Press Shift plus Tab to set focus on the search bar, then Shift plus Tab again to set focus on the selections menu.",
1821
+ "es-ES": "Pulse Mayús + Tabulador para establecer el foco en la barra de búsqueda, luego Mayús + Tabulador nuevamente para establecer el foco en el menú de selecciones.",
1822
+ "fr-FR": "Appuyez sur Maj + Tab pour définir le focus sur la barre de recherche, puis de nouveau sur Maj + Tab pour définir le focus sur le menu de sélections.",
1823
+ "it-IT": "Premere MAIUSC+TAB per impostare lo stato attivo sulla barra di ricerca, quindi premere nuovamente MAIUSC+TAB per impostare lo stato attivo sul menu selezioni.",
1824
+ "ja-JP": "Shift + Tab を押して検索バーにフォーカスを設定し、Shift + Tab をもう一度押して選択メニューにフォーカスを設定します。",
1825
+ "ko-KR": "Shift+Tab을 눌러 검색 막대에 초점을 맞춘 다음 Shift+Tab을 다시 눌러 선택 메뉴에 초점을 맞추십시오.",
1826
+ "nl-NL": "Druk op Shift + Tab om de focus in te stellen op de zoekbalk, druk vervolgens nogmaals op Shift + Tab om de focus in te stellen op het selectiemenu.",
1827
+ "pl-PL": "Naciśnij Shift i Tab, aby ustawić ostrość na pasek wyszukiwania. Następnie ponownie użyj tej kombinacji klawiszy, aby ustawić ostrość na menu selekcji.",
1828
+ "pt-BR": "Pressione Shift + Tab para definir o foco na barra de pesquisa e Shift + Tab novamente para definir o foco no menu de seleções.",
1829
+ "ru-RU": "Нажмите сочетание клавиш \"Shift + Tab\" для установки фокуса на панель поиска. Затем нажмите сочетание клавиш \"Shift + Tab\" снова, чтобы установить фокус на меню выборки.",
1830
+ "sv-SE": "Tryck på Skift plus Tabb för att ställa in fokus på sökfältet, sedan Skift plus Tabb igen för att ställa in fokus på urvalsmenyn.",
1831
+ "tr-TR": "Odağı arama çubuğuna ayarlamak için Shift ve Sekme tuşlarına birlikte basın, ardından bu tuşlara birlikte tekrar basarak odağı seçim menüsüne ayarlayın.",
1832
+ "zh-CN": "按 Shift+Tab 在搜索栏上设置焦点,然后再次按 Shift+Tab 在“选择”菜单上设置焦点。",
1833
+ "zh-TW": "按下 Shift 加 Tab 鍵以設定搜尋列上的焦點,然後再次按下 Shift 加 Tab 鍵,以設定選項功能表上的焦點。"
1834
+ }
1835
+ };
1836
+ var ScreenReader_ZeroSelected = {
1837
+ id: "ScreenReader.ZeroSelected",
1838
+ locale: {
1839
+ "de-DE": "Es sind keine Werte ausgewählt.",
1840
+ "en-US": "No values are selected.",
1841
+ "es-ES": "No se ha seleccionado ningún valor.",
1842
+ "fr-FR": "Aucune valeur n'a été sélectionnée.",
1843
+ "it-IT": "Nessun valore selezionato.",
1844
+ "ja-JP": "値が選択されていません。",
1845
+ "ko-KR": "선택된 값이 없습니다.",
1846
+ "nl-NL": "Geen waarden geselecteerd.",
1847
+ "pl-PL": "Brak wybranych wartości.",
1848
+ "pt-BR": "Nenhum valor selecionado.",
1849
+ "ru-RU": "Значения не выбраны.",
1850
+ "sv-SE": "Inga värden är valda.",
1851
+ "tr-TR": "Seçilen değer yok.",
1852
+ "zh-CN": "未选择值。",
1853
+ "zh-TW": "沒有選取任何值。"
1854
+ }
1855
+ };
1856
+ var ScreenReader_OneSelected = {
1857
+ id: "ScreenReader.OneSelected",
1858
+ locale: {
1859
+ "de-DE": "Es ist ein Wert ausgewählt.",
1860
+ "en-US": "There is one selected value.",
1861
+ "es-ES": "Hay un valor seleccionado.",
1862
+ "fr-FR": "Une valeur a été sélectionnée.",
1863
+ "it-IT": "È presente un valore selezionato.",
1864
+ "ja-JP": "値が 1 つ選択されています。",
1865
+ "ko-KR": "하나의 값이 선택되었습니다.",
1866
+ "nl-NL": "Er is één waarde geselecteerd.",
1867
+ "pl-PL": "Jest jedna wybrana wartość.",
1868
+ "pt-BR": "Há um valor selecionado.",
1869
+ "ru-RU": "Выбрано одно значение.",
1870
+ "sv-SE": "Ett värde är valt.",
1871
+ "tr-TR": "Seçilen bir değer var.",
1872
+ "zh-CN": "存在一个已选择的值。",
1873
+ "zh-TW": "有一個選取的值。"
1874
+ }
1875
+ };
1876
+ var ScreenReader_ManySelected = {
1877
+ id: "ScreenReader.ManySelected",
1878
+ locale: {
1879
+ "de-DE": "Es sind {0} Werte ausgewählt.",
1880
+ "en-US": "There are {0} selected values.",
1881
+ "es-ES": "Hay {0} valores seleccionados.",
1882
+ "fr-FR": "{0} valeurs ont été sélectionnées.",
1883
+ "it-IT": "Sono presenti {0} valori selezionati.",
1884
+ "ja-JP": "値が {0} つ選択されています。",
1885
+ "ko-KR": "{0}개의 값이 선택되었습니다.",
1886
+ "nl-NL": "Er zijn {0} waarden geselecteerd.",
1887
+ "pl-PL": "Wybranych wartości: {0}",
1888
+ "pt-BR": "Há {0} valores selecionados.",
1889
+ "ru-RU": "Выбраны значения: {0}.",
1890
+ "sv-SE": "{0} värden är valda.",
1891
+ "tr-TR": "Seçilen {0} değer var.",
1892
+ "zh-CN": "存在 {0} 个已选择的值。",
1893
+ "zh-TW": "有 {0} 個選取的值。"
1894
+ }
1895
+ };
1656
1896
  var all = {
1657
1897
  Cancel: Cancel$1,
1658
1898
  CurrentSelections_All: CurrentSelections_All,
@@ -1691,7 +1931,19 @@ var all = {
1691
1931
  Visualization_Invalid_Dimension: Visualization_Invalid_Dimension,
1692
1932
  Visualization_Invalid_Measure: Visualization_Invalid_Measure,
1693
1933
  Visualization_LayoutError: Visualization_LayoutError,
1694
- Visualization_UnfulfilledCalculationCondition: Visualization_UnfulfilledCalculationCondition
1934
+ Visualization_UnfulfilledCalculationCondition: Visualization_UnfulfilledCalculationCondition,
1935
+ Object_Listbox_Selected: Object_Listbox_Selected,
1936
+ Object_Listbox_Alternative: Object_Listbox_Alternative,
1937
+ Object_Listbox_Optional: Object_Listbox_Optional,
1938
+ Object_Listbox_SelectedExcluded: Object_Listbox_SelectedExcluded,
1939
+ Object_Listbox_Locked: Object_Listbox_Locked,
1940
+ Object_Listbox_Excluded: Object_Listbox_Excluded,
1941
+ Object_Listbox_ExcludedLock: Object_Listbox_ExcludedLock,
1942
+ Listbox_ScreenReader_SelectionMenu_WithAccSelMenu: Listbox_ScreenReader_SelectionMenu_WithAccSelMenu,
1943
+ Listbox_ScreenReader_SearchThenSelectionsMenu_WithAccSelMenu: Listbox_ScreenReader_SearchThenSelectionsMenu_WithAccSelMenu,
1944
+ ScreenReader_ZeroSelected: ScreenReader_ZeroSelected,
1945
+ ScreenReader_OneSelected: ScreenReader_OneSelected,
1946
+ ScreenReader_ManySelected: ScreenReader_ManySelected
1695
1947
  };
1696
1948
 
1697
1949
  function appLocaleFn(language) {
@@ -3967,7 +4219,7 @@ function resolveProps(defaultProps, props) {
3967
4219
  return output;
3968
4220
  }
3969
4221
 
3970
- function composeClasses(slots, getUtilityClass, classes) {
4222
+ function composeClasses(slots, getUtilityClass, classes = undefined) {
3971
4223
  const output = {};
3972
4224
  Object.keys(slots).forEach(
3973
4225
  // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`.
@@ -3975,7 +4227,10 @@ function composeClasses(slots, getUtilityClass, classes) {
3975
4227
  slot => {
3976
4228
  output[slot] = slots[slot].reduce((acc, key) => {
3977
4229
  if (key) {
3978
- acc.push(getUtilityClass(key));
4230
+ const utilityClass = getUtilityClass(key);
4231
+ if (utilityClass !== '') {
4232
+ acc.push(utilityClass);
4233
+ }
3979
4234
  if (classes && classes[key]) {
3980
4235
  acc.push(classes[key]);
3981
4236
  }
@@ -6217,6 +6472,11 @@ function unstable_createStyleFunctionSx() {
6217
6472
  if (val == null) {
6218
6473
  return null;
6219
6474
  }
6475
+ if (themeKey === 'typography' && val === 'inherit') {
6476
+ return {
6477
+ [prop]: val
6478
+ };
6479
+ }
6220
6480
  const themeMapping = getPath$1(theme, themeKey) || {};
6221
6481
  if (style) {
6222
6482
  return style(props);
@@ -7537,7 +7797,14 @@ function createTypography(palette, typography) {
7537
7797
  body2: buildVariant(fontWeightRegular, 14, 1.43, 0.15),
7538
7798
  button: buildVariant(fontWeightMedium, 14, 1.75, 0.4, caseAllCaps),
7539
7799
  caption: buildVariant(fontWeightRegular, 12, 1.66, 0.4),
7540
- overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps)
7800
+ overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps),
7801
+ inherit: {
7802
+ fontFamily: 'inherit',
7803
+ fontWeight: 'inherit',
7804
+ fontSize: 'inherit',
7805
+ lineHeight: 'inherit',
7806
+ letterSpacing: 'inherit'
7807
+ }
7541
7808
  };
7542
7809
  return deepmerge(_extends$4({
7543
7810
  htmlFontSize,
@@ -8064,7 +8331,7 @@ function create$3(definition) {
8064
8331
  return cache[key];
8065
8332
  }
8066
8333
 
8067
- const NEBULA_VERSION_HASH = "757e" ;
8334
+ const NEBULA_VERSION_HASH = "64ea" ;
8068
8335
  ClassNameGenerator$1.configure(componentName => {
8069
8336
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
8070
8337
  });
@@ -8272,7 +8539,7 @@ function boot(_ref2) {
8272
8539
  const appRef = React__default.createRef();
8273
8540
  const element = document.createElement('div');
8274
8541
  element.style.display = 'none';
8275
- element.setAttribute('data-nebulajs-version', "4.0.0-alpha.8" );
8542
+ element.setAttribute('data-nebulajs-version', "4.0.0-alpha.9" );
8276
8543
  element.setAttribute('data-app-id', app.id);
8277
8544
  document.body.appendChild(element);
8278
8545
  const root = client.createRoot(element);
@@ -9494,8 +9761,9 @@ function useTempKeyboard(_ref) {
9494
9761
  const c = containerRef.current;
9495
9762
  const searchField = c === null || c === void 0 ? void 0 : c.querySelector('.search input');
9496
9763
  const lastSelectedRow = c === null || c === void 0 ? void 0 : c.querySelector('.value.last-focused');
9497
- const fieldElement = c === null || c === void 0 ? void 0 : c.querySelector('.value.selector, .value, .ActionsToolbar-item button');
9498
- const elementToFocus = searchField || lastSelectedRow || fieldElement;
9764
+ const firstRowElement = c === null || c === void 0 ? void 0 : c.querySelector('.value.selector, .value');
9765
+ const confirmButton = c === null || c === void 0 ? void 0 : c.querySelector('.actions-toolbar-default-actions .actions-toolbar-confirm');
9766
+ const elementToFocus = searchField || lastSelectedRow || firstRowElement || confirmButton;
9499
9767
  elementToFocus === null || elementToFocus === void 0 ? void 0 : elementToFocus.setAttribute('tabIndex', 0);
9500
9768
  elementToFocus === null || elementToFocus === void 0 ? void 0 : elementToFocus.focus();
9501
9769
  },
@@ -9699,7 +9967,7 @@ function getListboxInlineKeyboardNavigation(_ref2) {
9699
9967
  // 3. Blur row and focus the listbox container.
9700
9968
  keyboard.blur();
9701
9969
  const c = currentTarget.closest('.listbox-container');
9702
- c.setAttribute('tabIndex', 0);
9970
+ c.setAttribute('tabIndex', -1);
9703
9971
  c === null || c === void 0 ? void 0 : c.focus();
9704
9972
  }
9705
9973
  };
@@ -9907,7 +10175,7 @@ const ellipsis = {
9907
10175
  const iconWidth = 24; // tick and lock icon width in px
9908
10176
 
9909
10177
  const RowColRoot = styled$1('div', {
9910
- shouldForwardProp: prop => !['flexBasisProp', 'isGridMode', 'isGridCol', 'dense', 'frequencyWidth'].includes(prop)
10178
+ shouldForwardProp: prop => !['flexBasisProp', 'isGridMode', 'isGridCol', 'dense', 'frequencyWidth', 'direction'].includes(prop)
9911
10179
  })(_ref2 => {
9912
10180
  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;
9913
10181
  let {
@@ -9916,7 +10184,8 @@ const RowColRoot = styled$1('div', {
9916
10184
  isGridMode,
9917
10185
  isGridCol,
9918
10186
  dense,
9919
- frequencyWidth
10187
+ frequencyWidth,
10188
+ direction
9920
10189
  } = _ref2;
9921
10190
  return {
9922
10191
  '&:focus': {
@@ -10029,7 +10298,7 @@ const RowColRoot = styled$1('div', {
10029
10298
  justifyContent: 'flex-end'
10030
10299
  }, ellipsis), {}, {
10031
10300
  flex: "0 1 ".concat(frequencyWidth, "px"),
10032
- textAlign: 'right',
10301
+ textAlign: direction === 'rtl' ? 'left' : 'right',
10033
10302
  paddingLeft: '2px'
10034
10303
  }),
10035
10304
  ["&.".concat(rowColClasses.barContainer)]: {
@@ -10062,7 +10331,7 @@ const RowColRoot = styled$1('div', {
10062
10331
  }
10063
10332
  },
10064
10333
  ["& .".concat(rowColClasses.barWithCheckbox)]: {
10065
- left: barWithCheckboxLeftPadPx,
10334
+ left: direction === 'rtl' ? barPadPx : barWithCheckboxLeftPadPx,
10066
10335
  width: "calc(100% - ".concat(barWithCheckboxLeftPadPx + barPadPx, "px)")
10067
10336
  },
10068
10337
  ["& .".concat(rowColClasses.barSelectedWithCheckbox)]: {
@@ -10508,21 +10777,23 @@ function getGridItemSizes(_ref) {
10508
10777
  }
10509
10778
 
10510
10779
  const ItemGrid = styled$1(Grid, {
10511
- shouldForwardProp: prop => !['dataLayout', 'layoutOrder', 'itemPadding', 'cellPaddingRight'].includes(prop)
10780
+ shouldForwardProp: prop => !['dataLayout', 'layoutOrder', 'itemPadding', 'cellPaddingRight', 'direction'].includes(prop)
10512
10781
  })(_ref => {
10513
10782
  let {
10514
10783
  dataLayout,
10515
10784
  layoutOrder,
10516
10785
  itemPadding,
10517
- cellPaddingRight
10786
+ cellPaddingRight,
10787
+ direction
10518
10788
  } = _ref;
10789
+ const att = "padding".concat(direction === 'rtl' ? 'Left' : 'Right');
10519
10790
  return {
10520
10791
  ["&.".concat(rowColClasses.fieldRoot)]: _objectSpread2(_objectSpread2({}, getGridItemSizes({
10521
10792
  dataLayout,
10522
10793
  layoutOrder,
10523
10794
  itemPadding
10524
10795
  })), {}, {
10525
- paddingRight: cellPaddingRight ? '8px' : undefined
10796
+ [att]: cellPaddingRight ? '8px' : undefined
10526
10797
  })
10527
10798
  };
10528
10799
  });
@@ -10791,6 +11062,7 @@ function RowColumn(_ref) {
10791
11062
  isGridMode: dataLayout === 'grid',
10792
11063
  dense: dense,
10793
11064
  frequencyWidth: frequencyWidth,
11065
+ direction: direction,
10794
11066
  "data-testid": "listbox.item"
10795
11067
  }, /*#__PURE__*/React__default.createElement(ItemGrid, {
10796
11068
  role: "row",
@@ -10818,7 +11090,8 @@ function RowColumn(_ref) {
10818
11090
  onTouchEnd: onTouchEnd,
10819
11091
  onContextMenu: preventContextMenu,
10820
11092
  tabIndex: isFirstElement && keyboard.innerTabStops ? 0 : -1,
10821
- "data-n": cell === null || cell === void 0 ? void 0 : cell.qElemNumber
11093
+ "data-n": cell === null || cell === void 0 ? void 0 : cell.qElemNumber,
11094
+ direction: direction
10822
11095
  }, (cell === null || cell === void 0 ? void 0 : cell.qFrequency) && /*#__PURE__*/React__default.createElement(Histogram, {
10823
11096
  qFrequency: cell === null || cell === void 0 ? void 0 : cell.qFrequency,
10824
11097
  histogram: histogram,
@@ -13820,13 +14093,16 @@ const Item = React__default.forwardRef((_ref, ref) => {
13820
14093
  } = useActionState(item);
13821
14094
  if (hidden) return null;
13822
14095
  const spacing = Number.parseInt(theme.spacing(0.5), 10);
13823
- const handleKeyDown = item.keyboardAction ? e => ['Enter', ' ', 'Spacebar'].includes(e.key) && item.keyboardAction() : null;
14096
+ const keyboardAction = item.keyboardAction || item.action;
14097
+ const handleKeyDown = keyboardAction ? e => ['Enter'].includes(e.key) && keyboardAction() : null;
14098
+ const handleKeyUp = keyboardAction ? e => [' ', 'Spacebar'].includes(e.key) && keyboardAction() : null;
13824
14099
  const btnId = "actions-toolbar-".concat(item.key);
13825
14100
  return /*#__PURE__*/React__default.createElement(IconButton, {
13826
14101
  ref: !addAnchor ? ref : null,
13827
14102
  title: item.label,
13828
14103
  onClick: item.action,
13829
14104
  onKeyDown: handleKeyDown,
14105
+ onKeyUp: handleKeyUp,
13830
14106
  disabled: disabled,
13831
14107
  style: style,
13832
14108
  className: [ActionElement.className, btnId].join(' '),
@@ -13892,8 +14168,8 @@ function useDefaultSelectionActions(_ref) {
13892
14168
  onCancel();
13893
14169
  api.cancel();
13894
14170
  },
13895
- keyboardAction: e => {
13896
- onKeyDeactivate(e);
14171
+ keyboardAction: () => {
14172
+ onKeyDeactivate();
13897
14173
  onCancel();
13898
14174
  api.cancel();
13899
14175
  },
@@ -13907,8 +14183,8 @@ function useDefaultSelectionActions(_ref) {
13907
14183
  onConfirm();
13908
14184
  api.confirm();
13909
14185
  },
13910
- keyboardAction: e => {
13911
- onKeyDeactivate(e);
14186
+ keyboardAction: () => {
14187
+ onKeyDeactivate();
13912
14188
  onConfirm();
13913
14189
  api.confirm();
13914
14190
  },
@@ -13938,6 +14214,7 @@ const StyledPopover$1 = styled$1(Popover)(_ref => {
13938
14214
  function MoreItem(_ref2) {
13939
14215
  let {
13940
14216
  item,
14217
+ autoFocus,
13941
14218
  onActionClick = () => {}
13942
14219
  } = _ref2;
13943
14220
  const {
@@ -13950,6 +14227,7 @@ function MoreItem(_ref2) {
13950
14227
  onActionClick();
13951
14228
  };
13952
14229
  return !hidden ? /*#__PURE__*/React__default.createElement(MenuItem, {
14230
+ autoFocus: autoFocus,
13953
14231
  title: item.label,
13954
14232
  onClick: handleClick,
13955
14233
  disabled: disabled,
@@ -13970,6 +14248,7 @@ const More$1 = React__default.forwardRef((_ref3, ref) => {
13970
14248
  onCloseOrActionClick = () => {}
13971
14249
  } = _ref3;
13972
14250
  const showActions = actions.length > 0;
14251
+ const autoFocusIndex = actions.findIndex(action => !action.disabled);
13973
14252
  return showActions && /*#__PURE__*/React__default.createElement(StyledPopover$1
13974
14253
  // eslint-disable-next-line react/jsx-props-no-spreading
13975
14254
  , _extends$6({}, popoverProps, {
@@ -14009,6 +14288,7 @@ const More$1 = React__default.forwardRef((_ref3, ref) => {
14009
14288
  React__default.createElement(MoreItem, {
14010
14289
  key: ix,
14011
14290
  item: item,
14291
+ autoFocus: ix === autoFocusIndex,
14012
14292
  onActionClick: onCloseOrActionClick
14013
14293
  }))));
14014
14294
  });
@@ -14032,7 +14312,8 @@ function getActionsKeyDownHandler(_ref) {
14032
14312
  let {
14033
14313
  keyboardNavigation,
14034
14314
  focusHandler,
14035
- getEnabledButton
14315
+ getEnabledButton,
14316
+ selections
14036
14317
  } = _ref;
14037
14318
  const handleActionsKeyDown = evt => {
14038
14319
  const {
@@ -14072,6 +14353,14 @@ function getActionsKeyDownHandler(_ref) {
14072
14353
  }
14073
14354
  }
14074
14355
  break;
14356
+ case KEYS.ESCAPE:
14357
+ if (selections) {
14358
+ selections.onCancel();
14359
+ selections.api.cancel();
14360
+ evt.preventDefault();
14361
+ evt.stopPropagation();
14362
+ }
14363
+ break;
14075
14364
  }
14076
14365
  };
14077
14366
  return handleActionsKeyDown;
@@ -14213,8 +14502,9 @@ function ActionsToolbar(_ref3) {
14213
14502
  const handleActionsKeyDown = useMemo$1(() => getActionsKeyDownHandler({
14214
14503
  keyboardNavigation,
14215
14504
  focusHandler,
14216
- getEnabledButton
14217
- }), [keyboardNavigation, focusHandler, getEnabledButton]);
14505
+ getEnabledButton,
14506
+ selections
14507
+ }), [keyboardNavigation, focusHandler, getEnabledButton, selections]);
14218
14508
  useEffect$1(() => () => {
14219
14509
  setShowMoreItems(false);
14220
14510
  }, [popover.show, show, selections.show]);
@@ -16396,7 +16686,6 @@ const addListboxTheme = themeApi => {
16396
16686
  };
16397
16687
  };
16398
16688
 
16399
- /* eslint-disable no-nested-ternary */
16400
16689
  function showToolbarDetached(_ref) {
16401
16690
  var _containerRef$current, _containerRef$current2, _titleRef$current$cli, _titleRef$current, _titleRef$current2, _titleRef$current3;
16402
16691
  let {
@@ -16411,11 +16700,7 @@ function showToolbarDetached(_ref) {
16411
16700
  const notSufficientSpace = containerWidth < contentWidth + actionToolbarWidth;
16412
16701
  const isTruncated = (titleRef === null || titleRef === void 0 ? void 0 : (_titleRef$current2 = titleRef.current) === null || _titleRef$current2 === void 0 ? void 0 : _titleRef$current2.scrollWidth) > (titleRef === null || titleRef === void 0 ? void 0 : (_titleRef$current3 = titleRef.current) === null || _titleRef$current3 === void 0 ? void 0 : _titleRef$current3.offsetWidth);
16413
16702
  const isDetached = !!(notSufficientSpace | isTruncated);
16414
- const reasonDetached = isDetached ? notSufficientSpace ? 'noSpace' : 'truncated' : '';
16415
- return {
16416
- isDetached,
16417
- reasonDetached
16418
- };
16703
+ return isDetached;
16419
16704
  }
16420
16705
 
16421
16706
  function getListboxActionProps(_ref) {
@@ -16425,7 +16710,8 @@ function getListboxActionProps(_ref) {
16425
16710
  containerRef,
16426
16711
  isLocked,
16427
16712
  listboxSelectionToolbarItems,
16428
- selections
16713
+ selections,
16714
+ keyboard
16429
16715
  } = _ref;
16430
16716
  return {
16431
16717
  show: showToolbar && !isDetached,
@@ -16447,8 +16733,12 @@ function getListboxActionProps(_ref) {
16447
16733
  selections: {
16448
16734
  show: showToolbar,
16449
16735
  api: selections,
16450
- onConfirm: () => {},
16451
- onCancel: () => {}
16736
+ onConfirm: () => {
16737
+ keyboard === null || keyboard === void 0 ? void 0 : keyboard.focus();
16738
+ },
16739
+ onCancel: () => {
16740
+ keyboard === null || keyboard === void 0 ? void 0 : keyboard.focus();
16741
+ }
16452
16742
  }
16453
16743
  };
16454
16744
  }
@@ -16477,20 +16767,18 @@ const classes$4 = {
16477
16767
  listboxWrapper: "".concat(PREFIX$4, "-listboxWrapper")
16478
16768
  };
16479
16769
  const StyledGrid$3 = styled$1(Grid, {
16480
- shouldForwardProp: p => !['containerPadding', 'hasIcon'].includes(p)
16770
+ shouldForwardProp: p => !['containerPadding'].includes(p)
16481
16771
  })(_ref => {
16482
16772
  var _theme$listBox$backgr, _theme$listBox;
16483
16773
  let {
16484
16774
  theme,
16485
- containerPadding,
16486
- hasIcon
16775
+ containerPadding
16487
16776
  } = _ref;
16488
16777
  return {
16489
16778
  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,
16490
16779
  ["& .".concat(classes$4.listBoxHeader)]: {
16491
16780
  alignSelf: 'center',
16492
- display: 'flex',
16493
- width: "calc(100% - ".concat(hasIcon ? BUTTON_ICON_WIDTH : 0, "px)")
16781
+ display: 'flex'
16494
16782
  },
16495
16783
  ["& .".concat(classes$4.screenReaderOnly)]: {
16496
16784
  position: 'absolute',
@@ -16716,7 +17004,8 @@ function ListBoxInline(_ref4) {
16716
17004
  containerRef,
16717
17005
  isLocked,
16718
17006
  listboxSelectionToolbarItems,
16719
- selections
17007
+ selections,
17008
+ keyboard
16720
17009
  });
16721
17010
  const shouldAutoFocus = searchVisible && search === 'toggle';
16722
17011
  const showSearchIcon = searchEnabled !== false && search === 'toggle';
@@ -16725,10 +17014,7 @@ function ListBoxInline(_ref4) {
16725
17014
  const iconsWidth = (showSearchOrLockIcon ? BUTTON_ICON_WIDTH : 0) + (isDrillDown ? ICON_WIDTH + ICON_PADDING : 0); // Drill-down icon needs padding right so there is space between the icon and the title
16726
17015
  const headerPaddingLeft = CELL_PADDING_LEFT - (showSearchOrLockIcon ? ICON_PADDING : 0);
16727
17016
  const headerPaddingRight = isRtl ? CELL_PADDING_LEFT - (showIcons ? ICON_PADDING : 0) : 0;
16728
- const {
16729
- isDetached,
16730
- reasonDetached
16731
- } = showToolbarDetached({
17017
+ const isDetached = showToolbarDetached({
16732
17018
  containerRef,
16733
17019
  titleRef,
16734
17020
  iconsWidth
@@ -16793,35 +17079,21 @@ function ListBoxInline(_ref4) {
16793
17079
  onKeyDown: handleKeyDown,
16794
17080
  onMouseEnter: handleOnMouseEnter,
16795
17081
  onMouseLeave: handleOnMouseLeave,
16796
- ref: containerRef,
16797
- hasIcon: showIcons
17082
+ ref: containerRef
16798
17083
  }, showToolbarWithTitle && /*#__PURE__*/React__default.createElement(Grid, {
16799
17084
  item: true,
16800
17085
  container: true,
16801
- style: {
16802
- padding: theme.spacing(1),
16803
- paddingLeft: "".concat(headerPaddingLeft, "px"),
16804
- paddingRight: "".concat(headerPaddingRight, "px")
16805
- },
16806
- sx: {
16807
- flexDirection: isRtl ? 'row-reverse' : 'row'
16808
- },
16809
- wrap: "nowrap"
16810
- }, /*#__PURE__*/React__default.createElement(Grid, {
16811
- item: true,
16812
- container: true,
16813
- height: headerHeight,
16814
- sx: {
16815
- flexDirection: isRtl ? 'row-reverse' : 'row'
16816
- },
17086
+ minHeight: headerHeight,
17087
+ flexDirection: isRtl ? 'row-reverse' : 'row',
17088
+ marginY: 1,
17089
+ paddingLeft: "".concat(headerPaddingLeft, "px"),
17090
+ paddingRight: "".concat(headerPaddingRight, "px"),
16817
17091
  wrap: "nowrap"
16818
17092
  }, showIcons && /*#__PURE__*/React__default.createElement(Grid, {
16819
17093
  item: true,
16820
- sx: {
16821
- display: 'flex',
16822
- alignItems: 'center',
16823
- width: iconsWidth
16824
- }
17094
+ container: true,
17095
+ alignItems: "center",
17096
+ width: iconsWidth
16825
17097
  }, isLocked ? lockIconComp : showSearchIcon && searchIconComp, isDrillDown && /*#__PURE__*/React__default.createElement(DrillDownIcon, {
16826
17098
  tabIndex: -1,
16827
17099
  title: translator.get('Listbox.DrillDown'),
@@ -16831,22 +17103,17 @@ function ListBoxInline(_ref4) {
16831
17103
  }
16832
17104
  })), /*#__PURE__*/React__default.createElement(Grid, {
16833
17105
  item: true,
16834
- sx: {
16835
- justifyContent: isRtl ? 'flex-end' : 'flex-start'
16836
- },
17106
+ xs: true,
17107
+ minWidth: 0 // needed to text-overflow see: https://css-tricks.com/flexbox-truncated-text/
17108
+ ,
17109
+ justifyContent: isRtl ? 'flex-end' : 'flex-start',
16837
17110
  className: classes$4.listBoxHeader
16838
17111
  }, /*#__PURE__*/React__default.createElement(Title, {
16839
17112
  variant: "h6",
16840
- sx: {
16841
- width: isPopover && reasonDetached === 'noSpace' ? '60px' : undefined
16842
- },
16843
17113
  noWrap: true,
16844
17114
  ref: titleRef,
16845
17115
  title: layout.title
16846
- }, layout.title))), /*#__PURE__*/React__default.createElement(Grid, {
16847
- item: true,
16848
- xs: true
16849
- }), /*#__PURE__*/React__default.createElement(Grid, {
17116
+ }, layout.title)), /*#__PURE__*/React__default.createElement(Grid, {
16850
17117
  item: true
16851
17118
  }, /*#__PURE__*/React__default.createElement(ActionsToolbar, _extends$6({
16852
17119
  direction: direction
@@ -19946,7 +20213,7 @@ function viz() {
19946
20213
  id: model.id,
19947
20214
  /**
19948
20215
  * This visualizations Enigma model, a representation of the generic object.
19949
- * @type {string}
20216
+ * @type {EngineAPI.IGenericObject}
19950
20217
  */
19951
20218
  model,
19952
20219
  /**
@@ -20095,14 +20362,17 @@ async function init(model, optional, halo, initialError) {
20095
20362
  */
20096
20363
 
20097
20364
  /**
20098
- * @interface CreateConfig
20099
- * @description Rendering configuration for creating and rendering a new object
20100
- * @extends BaseConfig
20101
- * @property {string} type
20102
- * @property {string=} version
20103
- * @property {(Field[])=} fields
20104
- * @property {boolean} [extendProperties=false] Whether to deeply extend properties or not. If false then subtrees will be overwritten.
20105
- * @property {EngineAPI.IGenericObjectProperties=} properties
20365
+ * @interface RenderConfig
20366
+ * @description Configuration for rendering a visualisation, either creating or fetching an existing object.
20367
+ * @property {HTMLElement} element Target html element to render in to
20368
+ * @property {object=} options Options passed into the visualisation
20369
+ * @property {Plugin[]} [plugins] plugins passed into the visualisation
20370
+ * @property {string=} id For existing objects: Engine identifier of object to render
20371
+ * @property {string=} type For creating objects: Type of visualisation to render
20372
+ * @property {string=} version For creating objects: Version of visualization to render
20373
+ * @property {(Field[])=} fields For creating objects: Data fields to use
20374
+ * @property {boolean=} [extendProperties=false] For creating objects: Whether to deeply extend properties or not. If false then subtrees will be overwritten.
20375
+ * @property {EngineAPI.IGenericObjectProperties=} properties For creating objects: Explicit properties to set
20106
20376
  * @example
20107
20377
  * // A config for Creating objects:
20108
20378
  * const createConfig = {
@@ -20117,6 +20387,12 @@ async function init(model, optional, halo, initialError) {
20117
20387
  * }
20118
20388
  * };
20119
20389
  * nebbie.render(createConfig);
20390
+ * // A config for rendering an existing object:
20391
+ * const createConfig = {
20392
+ * id: 'jG5LP',
20393
+ * element: document.querySelector('.line'),
20394
+ * };
20395
+ * nebbie.render(createConfig);
20120
20396
  */
20121
20397
  async function createSessionObject(_ref, halo) {
20122
20398
  let {
@@ -20175,6 +20451,71 @@ async function createSessionObject(_ref, halo) {
20175
20451
  }, halo, error, onDestroy);
20176
20452
  }
20177
20453
 
20454
+ /**
20455
+ * @typedef {string | EngineAPI.INxDimension | EngineAPI.INxMeasure | LibraryField} Field
20456
+ */
20457
+
20458
+ /**
20459
+ * @interface CreateConfig
20460
+ * @description Rendering configuration for creating and rendering a new object
20461
+ * @property {string} type
20462
+ * @property {string=} version
20463
+ * @property {(Field[])=} fields
20464
+ * @property {EngineAPI.IGenericObjectProperties=} properties
20465
+ */
20466
+
20467
+ async function createObject(_ref, halo, generateOnly) {
20468
+ let {
20469
+ type,
20470
+ version,
20471
+ fields,
20472
+ properties,
20473
+ extendProperties /* , options, plugins, element */
20474
+ } = _ref;
20475
+ let mergedProps = {};
20476
+ // let error;
20477
+ try {
20478
+ const t = halo.types.get({
20479
+ name: type,
20480
+ version
20481
+ });
20482
+ mergedProps = await t.initialProperties(properties, extendProperties);
20483
+ const sn = await t.supernova();
20484
+ if (fields) {
20485
+ populateData({
20486
+ sn,
20487
+ properties: mergedProps,
20488
+ fields
20489
+ }, halo);
20490
+ }
20491
+ if (properties && sn && sn.qae.properties.onChange) {
20492
+ sn.qae.properties.onChange.call({}, mergedProps);
20493
+ }
20494
+ } catch (e) {
20495
+ // error = e;
20496
+ // minimal dummy object properties to allow it to be created
20497
+ // and rendered with the error
20498
+ if (!generateOnly) {
20499
+ mergedProps = {
20500
+ qInfo: {
20501
+ qType: type
20502
+ },
20503
+ visualization: type
20504
+ };
20505
+ } else {
20506
+ mergedProps = null;
20507
+ }
20508
+ // console.error(e); // eslint-disable-line
20509
+ }
20510
+
20511
+ if (!generateOnly) {
20512
+ const model = await halo.app.createObject(mergedProps);
20513
+ modelStore.set(model.id, model);
20514
+ return model;
20515
+ }
20516
+ return mergedProps;
20517
+ }
20518
+
20178
20519
  async function getObject$1(_ref, halo) {
20179
20520
  let {
20180
20521
  id,
@@ -20519,21 +20860,6 @@ async function initSheet(model, optional, halo, initialError) {
20519
20860
  return api;
20520
20861
  }
20521
20862
 
20522
- /**
20523
- * @interface BaseConfig
20524
- * @description Basic rendering configuration for rendering an object
20525
- * @property {HTMLElement} element
20526
- * @property {object=} options
20527
- * @property {Plugin[]} [plugins]
20528
- */
20529
-
20530
- /**
20531
- * @interface GetConfig
20532
- * @description Rendering configuration for rendering an existing object
20533
- * @extends BaseConfig
20534
- * @property {string} id
20535
- */
20536
-
20537
20863
  async function getObject(_ref, halo) {
20538
20864
  let {
20539
20865
  id,
@@ -21973,7 +22299,6 @@ function onTakeSnapshot(cb) {
21973
22299
  * @ignore
21974
22300
  * @example
21975
22301
  * import { onContextMenu } from '@nebula.js/stardust';
21976
-
21977
22302
  * onContextMenu((menu, event) => {
21978
22303
  * menu.addItem(item, index);
21979
22304
  * });
@@ -22733,1603 +23058,1350 @@ var semver = {
22733
23058
  };
22734
23059
 
22735
23060
  (function (module, exports) {
22736
- exports = module.exports = SemVer;
22737
-
22738
- var debug;
22739
- /* istanbul ignore next */
22740
- if (typeof process === 'object' &&
22741
- process.env &&
22742
- process.env.NODE_DEBUG &&
22743
- /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
22744
- debug = function () {
22745
- var args = Array.prototype.slice.call(arguments, 0);
22746
- args.unshift('SEMVER');
22747
- console.log.apply(console, args);
22748
- };
22749
- } else {
22750
- debug = function () {};
22751
- }
22752
-
22753
- // Note: this is the semver.org version of the spec that it implements
22754
- // Not necessarily the package version of this code.
22755
- exports.SEMVER_SPEC_VERSION = '2.0.0';
22756
-
22757
- var MAX_LENGTH = 256;
22758
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
22759
- /* istanbul ignore next */ 9007199254740991;
22760
-
22761
- // Max safe segment length for coercion.
22762
- var MAX_SAFE_COMPONENT_LENGTH = 16;
22763
-
22764
- // The actual regexps go on exports.re
22765
- var re = exports.re = [];
22766
- var src = exports.src = [];
22767
- var t = exports.tokens = {};
22768
- var R = 0;
22769
-
22770
- function tok (n) {
22771
- t[n] = R++;
22772
- }
22773
-
22774
- // The following Regular Expressions can be used for tokenizing,
22775
- // validating, and parsing SemVer version strings.
22776
-
22777
- // ## Numeric Identifier
22778
- // A single `0`, or a non-zero digit followed by zero or more digits.
22779
-
22780
- tok('NUMERICIDENTIFIER');
22781
- src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
22782
- tok('NUMERICIDENTIFIERLOOSE');
22783
- src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
22784
-
22785
- // ## Non-numeric Identifier
22786
- // Zero or more digits, followed by a letter or hyphen, and then zero or
22787
- // more letters, digits, or hyphens.
22788
-
22789
- tok('NONNUMERICIDENTIFIER');
22790
- src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
22791
-
22792
- // ## Main Version
22793
- // Three dot-separated numeric identifiers.
22794
-
22795
- tok('MAINVERSION');
22796
- src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
22797
- '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
22798
- '(' + src[t.NUMERICIDENTIFIER] + ')';
22799
-
22800
- tok('MAINVERSIONLOOSE');
22801
- src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
22802
- '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
22803
- '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
22804
-
22805
- // ## Pre-release Version Identifier
22806
- // A numeric identifier, or a non-numeric identifier.
22807
-
22808
- tok('PRERELEASEIDENTIFIER');
22809
- src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
22810
- '|' + src[t.NONNUMERICIDENTIFIER] + ')';
22811
-
22812
- tok('PRERELEASEIDENTIFIERLOOSE');
22813
- src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
22814
- '|' + src[t.NONNUMERICIDENTIFIER] + ')';
22815
-
22816
- // ## Pre-release Version
22817
- // Hyphen, followed by one or more dot-separated pre-release version
22818
- // identifiers.
22819
-
22820
- tok('PRERELEASE');
22821
- src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
22822
- '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
22823
-
22824
- tok('PRERELEASELOOSE');
22825
- src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
22826
- '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
22827
-
22828
- // ## Build Metadata Identifier
22829
- // Any combination of digits, letters, or hyphens.
22830
-
22831
- tok('BUILDIDENTIFIER');
22832
- src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
22833
-
22834
- // ## Build Metadata
22835
- // Plus sign, followed by one or more period-separated build metadata
22836
- // identifiers.
22837
-
22838
- tok('BUILD');
22839
- src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
22840
- '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
22841
-
22842
- // ## Full Version String
22843
- // A main version, followed optionally by a pre-release version and
22844
- // build metadata.
22845
-
22846
- // Note that the only major, minor, patch, and pre-release sections of
22847
- // the version string are capturing groups. The build metadata is not a
22848
- // capturing group, because it should not ever be used in version
22849
- // comparison.
22850
-
22851
- tok('FULL');
22852
- tok('FULLPLAIN');
22853
- src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
22854
- src[t.PRERELEASE] + '?' +
22855
- src[t.BUILD] + '?';
22856
-
22857
- src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
22858
-
22859
- // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
22860
- // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
22861
- // common in the npm registry.
22862
- tok('LOOSEPLAIN');
22863
- src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
22864
- src[t.PRERELEASELOOSE] + '?' +
22865
- src[t.BUILD] + '?';
22866
-
22867
- tok('LOOSE');
22868
- src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
22869
-
22870
- tok('GTLT');
22871
- src[t.GTLT] = '((?:<|>)?=?)';
22872
-
22873
- // Something like "2.*" or "1.2.x".
22874
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
22875
- // Only the first item is strictly required.
22876
- tok('XRANGEIDENTIFIERLOOSE');
22877
- src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
22878
- tok('XRANGEIDENTIFIER');
22879
- src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
22880
-
22881
- tok('XRANGEPLAIN');
22882
- src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
22883
- '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
22884
- '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
22885
- '(?:' + src[t.PRERELEASE] + ')?' +
22886
- src[t.BUILD] + '?' +
22887
- ')?)?';
22888
-
22889
- tok('XRANGEPLAINLOOSE');
22890
- src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
22891
- '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
22892
- '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
22893
- '(?:' + src[t.PRERELEASELOOSE] + ')?' +
22894
- src[t.BUILD] + '?' +
22895
- ')?)?';
22896
-
22897
- tok('XRANGE');
22898
- src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
22899
- tok('XRANGELOOSE');
22900
- src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
22901
-
22902
- // Coercion.
22903
- // Extract anything that could conceivably be a part of a valid semver
22904
- tok('COERCE');
22905
- src[t.COERCE] = '(^|[^\\d])' +
22906
- '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
22907
- '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
22908
- '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
22909
- '(?:$|[^\\d])';
22910
- tok('COERCERTL');
22911
- re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
22912
-
22913
- // Tilde ranges.
22914
- // Meaning is "reasonably at or greater than"
22915
- tok('LONETILDE');
22916
- src[t.LONETILDE] = '(?:~>?)';
22917
-
22918
- tok('TILDETRIM');
22919
- src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
22920
- re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
22921
- var tildeTrimReplace = '$1~';
22922
-
22923
- tok('TILDE');
22924
- src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
22925
- tok('TILDELOOSE');
22926
- src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
22927
-
22928
- // Caret ranges.
22929
- // Meaning is "at least and backwards compatible with"
22930
- tok('LONECARET');
22931
- src[t.LONECARET] = '(?:\\^)';
22932
-
22933
- tok('CARETTRIM');
22934
- src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
22935
- re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
22936
- var caretTrimReplace = '$1^';
22937
-
22938
- tok('CARET');
22939
- src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
22940
- tok('CARETLOOSE');
22941
- src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
22942
-
22943
- // A simple gt/lt/eq thing, or just "" to indicate "any version"
22944
- tok('COMPARATORLOOSE');
22945
- src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
22946
- tok('COMPARATOR');
22947
- src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
22948
-
22949
- // An expression to strip any whitespace between the gtlt and the thing
22950
- // it modifies, so that `> 1.2.3` ==> `>1.2.3`
22951
- tok('COMPARATORTRIM');
22952
- src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
22953
- '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
22954
-
22955
- // this one has to use the /g flag
22956
- re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
22957
- var comparatorTrimReplace = '$1$2$3';
22958
-
22959
- // Something like `1.2.3 - 1.2.4`
22960
- // Note that these all use the loose form, because they'll be
22961
- // checked against either the strict or loose comparator form
22962
- // later.
22963
- tok('HYPHENRANGE');
22964
- src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
22965
- '\\s+-\\s+' +
22966
- '(' + src[t.XRANGEPLAIN] + ')' +
22967
- '\\s*$';
22968
-
22969
- tok('HYPHENRANGELOOSE');
22970
- src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
22971
- '\\s+-\\s+' +
22972
- '(' + src[t.XRANGEPLAINLOOSE] + ')' +
22973
- '\\s*$';
22974
-
22975
- // Star ranges basically just allow anything at all.
22976
- tok('STAR');
22977
- src[t.STAR] = '(<|>)?=?\\s*\\*';
22978
-
22979
- // Compile to actual regexp objects.
22980
- // All are flag-free, unless they were created above with a flag.
22981
- for (var i = 0; i < R; i++) {
22982
- debug(i, src[i]);
22983
- if (!re[i]) {
22984
- re[i] = new RegExp(src[i]);
22985
- }
22986
- }
22987
-
22988
- exports.parse = parse;
22989
- function parse (version, options) {
22990
- if (!options || typeof options !== 'object') {
22991
- options = {
22992
- loose: !!options,
22993
- includePrerelease: false
22994
- };
22995
- }
22996
-
22997
- if (version instanceof SemVer) {
22998
- return version
22999
- }
23000
-
23001
- if (typeof version !== 'string') {
23002
- return null
23003
- }
23004
-
23005
- if (version.length > MAX_LENGTH) {
23006
- return null
23007
- }
23008
-
23009
- var r = options.loose ? re[t.LOOSE] : re[t.FULL];
23010
- if (!r.test(version)) {
23011
- return null
23012
- }
23013
-
23014
- try {
23015
- return new SemVer(version, options)
23016
- } catch (er) {
23017
- return null
23018
- }
23019
- }
23020
-
23021
- exports.valid = valid;
23022
- function valid (version, options) {
23023
- var v = parse(version, options);
23024
- return v ? v.version : null
23025
- }
23026
-
23027
- exports.clean = clean;
23028
- function clean (version, options) {
23029
- var s = parse(version.trim().replace(/^[=v]+/, ''), options);
23030
- return s ? s.version : null
23031
- }
23032
-
23033
- exports.SemVer = SemVer;
23034
-
23035
- function SemVer (version, options) {
23036
- if (!options || typeof options !== 'object') {
23037
- options = {
23038
- loose: !!options,
23039
- includePrerelease: false
23040
- };
23041
- }
23042
- if (version instanceof SemVer) {
23043
- if (version.loose === options.loose) {
23044
- return version
23045
- } else {
23046
- version = version.version;
23047
- }
23048
- } else if (typeof version !== 'string') {
23049
- throw new TypeError('Invalid Version: ' + version)
23050
- }
23051
-
23052
- if (version.length > MAX_LENGTH) {
23053
- throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
23054
- }
23055
-
23056
- if (!(this instanceof SemVer)) {
23057
- return new SemVer(version, options)
23058
- }
23059
-
23060
- debug('SemVer', version, options);
23061
- this.options = options;
23062
- this.loose = !!options.loose;
23063
-
23064
- var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
23065
-
23066
- if (!m) {
23067
- throw new TypeError('Invalid Version: ' + version)
23068
- }
23069
-
23070
- this.raw = version;
23071
-
23072
- // these are actually numbers
23073
- this.major = +m[1];
23074
- this.minor = +m[2];
23075
- this.patch = +m[3];
23076
-
23077
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
23078
- throw new TypeError('Invalid major version')
23079
- }
23080
-
23081
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
23082
- throw new TypeError('Invalid minor version')
23083
- }
23084
-
23085
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
23086
- throw new TypeError('Invalid patch version')
23087
- }
23088
-
23089
- // numberify any prerelease numeric ids
23090
- if (!m[4]) {
23091
- this.prerelease = [];
23092
- } else {
23093
- this.prerelease = m[4].split('.').map(function (id) {
23094
- if (/^[0-9]+$/.test(id)) {
23095
- var num = +id;
23096
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
23097
- return num
23098
- }
23099
- }
23100
- return id
23101
- });
23102
- }
23103
-
23104
- this.build = m[5] ? m[5].split('.') : [];
23105
- this.format();
23106
- }
23107
-
23108
- SemVer.prototype.format = function () {
23109
- this.version = this.major + '.' + this.minor + '.' + this.patch;
23110
- if (this.prerelease.length) {
23111
- this.version += '-' + this.prerelease.join('.');
23112
- }
23113
- return this.version
23114
- };
23115
-
23116
- SemVer.prototype.toString = function () {
23117
- return this.version
23118
- };
23119
-
23120
- SemVer.prototype.compare = function (other) {
23121
- debug('SemVer.compare', this.version, this.options, other);
23122
- if (!(other instanceof SemVer)) {
23123
- other = new SemVer(other, this.options);
23124
- }
23125
-
23126
- return this.compareMain(other) || this.comparePre(other)
23127
- };
23128
-
23129
- SemVer.prototype.compareMain = function (other) {
23130
- if (!(other instanceof SemVer)) {
23131
- other = new SemVer(other, this.options);
23132
- }
23133
-
23134
- return compareIdentifiers(this.major, other.major) ||
23135
- compareIdentifiers(this.minor, other.minor) ||
23136
- compareIdentifiers(this.patch, other.patch)
23137
- };
23138
-
23139
- SemVer.prototype.comparePre = function (other) {
23140
- if (!(other instanceof SemVer)) {
23141
- other = new SemVer(other, this.options);
23142
- }
23143
-
23144
- // NOT having a prerelease is > having one
23145
- if (this.prerelease.length && !other.prerelease.length) {
23146
- return -1
23147
- } else if (!this.prerelease.length && other.prerelease.length) {
23148
- return 1
23149
- } else if (!this.prerelease.length && !other.prerelease.length) {
23150
- return 0
23151
- }
23152
-
23153
- var i = 0;
23154
- do {
23155
- var a = this.prerelease[i];
23156
- var b = other.prerelease[i];
23157
- debug('prerelease compare', i, a, b);
23158
- if (a === undefined && b === undefined) {
23159
- return 0
23160
- } else if (b === undefined) {
23161
- return 1
23162
- } else if (a === undefined) {
23163
- return -1
23164
- } else if (a === b) {
23165
- continue
23166
- } else {
23167
- return compareIdentifiers(a, b)
23168
- }
23169
- } while (++i)
23170
- };
23171
-
23172
- SemVer.prototype.compareBuild = function (other) {
23173
- if (!(other instanceof SemVer)) {
23174
- other = new SemVer(other, this.options);
23175
- }
23176
-
23177
- var i = 0;
23178
- do {
23179
- var a = this.build[i];
23180
- var b = other.build[i];
23181
- debug('prerelease compare', i, a, b);
23182
- if (a === undefined && b === undefined) {
23183
- return 0
23184
- } else if (b === undefined) {
23185
- return 1
23186
- } else if (a === undefined) {
23187
- return -1
23188
- } else if (a === b) {
23189
- continue
23190
- } else {
23191
- return compareIdentifiers(a, b)
23192
- }
23193
- } while (++i)
23194
- };
23195
-
23196
- // preminor will bump the version up to the next minor release, and immediately
23197
- // down to pre-release. premajor and prepatch work the same way.
23198
- SemVer.prototype.inc = function (release, identifier) {
23199
- switch (release) {
23200
- case 'premajor':
23201
- this.prerelease.length = 0;
23202
- this.patch = 0;
23203
- this.minor = 0;
23204
- this.major++;
23205
- this.inc('pre', identifier);
23206
- break
23207
- case 'preminor':
23208
- this.prerelease.length = 0;
23209
- this.patch = 0;
23210
- this.minor++;
23211
- this.inc('pre', identifier);
23212
- break
23213
- case 'prepatch':
23214
- // If this is already a prerelease, it will bump to the next version
23215
- // drop any prereleases that might already exist, since they are not
23216
- // relevant at this point.
23217
- this.prerelease.length = 0;
23218
- this.inc('patch', identifier);
23219
- this.inc('pre', identifier);
23220
- break
23221
- // If the input is a non-prerelease version, this acts the same as
23222
- // prepatch.
23223
- case 'prerelease':
23224
- if (this.prerelease.length === 0) {
23225
- this.inc('patch', identifier);
23226
- }
23227
- this.inc('pre', identifier);
23228
- break
23229
-
23230
- case 'major':
23231
- // If this is a pre-major version, bump up to the same major version.
23232
- // Otherwise increment major.
23233
- // 1.0.0-5 bumps to 1.0.0
23234
- // 1.1.0 bumps to 2.0.0
23235
- if (this.minor !== 0 ||
23236
- this.patch !== 0 ||
23237
- this.prerelease.length === 0) {
23238
- this.major++;
23239
- }
23240
- this.minor = 0;
23241
- this.patch = 0;
23242
- this.prerelease = [];
23243
- break
23244
- case 'minor':
23245
- // If this is a pre-minor version, bump up to the same minor version.
23246
- // Otherwise increment minor.
23247
- // 1.2.0-5 bumps to 1.2.0
23248
- // 1.2.1 bumps to 1.3.0
23249
- if (this.patch !== 0 || this.prerelease.length === 0) {
23250
- this.minor++;
23251
- }
23252
- this.patch = 0;
23253
- this.prerelease = [];
23254
- break
23255
- case 'patch':
23256
- // If this is not a pre-release version, it will increment the patch.
23257
- // If it is a pre-release it will bump up to the same patch version.
23258
- // 1.2.0-5 patches to 1.2.0
23259
- // 1.2.0 patches to 1.2.1
23260
- if (this.prerelease.length === 0) {
23261
- this.patch++;
23262
- }
23263
- this.prerelease = [];
23264
- break
23265
- // This probably shouldn't be used publicly.
23266
- // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
23267
- case 'pre':
23268
- if (this.prerelease.length === 0) {
23269
- this.prerelease = [0];
23270
- } else {
23271
- var i = this.prerelease.length;
23272
- while (--i >= 0) {
23273
- if (typeof this.prerelease[i] === 'number') {
23274
- this.prerelease[i]++;
23275
- i = -2;
23276
- }
23277
- }
23278
- if (i === -1) {
23279
- // didn't increment anything
23280
- this.prerelease.push(0);
23281
- }
23282
- }
23283
- if (identifier) {
23284
- // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
23285
- // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
23286
- if (this.prerelease[0] === identifier) {
23287
- if (isNaN(this.prerelease[1])) {
23288
- this.prerelease = [identifier, 0];
23289
- }
23290
- } else {
23291
- this.prerelease = [identifier, 0];
23292
- }
23293
- }
23294
- break
23295
-
23296
- default:
23297
- throw new Error('invalid increment argument: ' + release)
23298
- }
23299
- this.format();
23300
- this.raw = this.version;
23301
- return this
23302
- };
23303
-
23304
- exports.inc = inc;
23305
- function inc (version, release, loose, identifier) {
23306
- if (typeof (loose) === 'string') {
23307
- identifier = loose;
23308
- loose = undefined;
23309
- }
23310
-
23311
- try {
23312
- return new SemVer(version, loose).inc(release, identifier).version
23313
- } catch (er) {
23314
- return null
23315
- }
23316
- }
23317
-
23318
- exports.diff = diff;
23319
- function diff (version1, version2) {
23320
- if (eq(version1, version2)) {
23321
- return null
23322
- } else {
23323
- var v1 = parse(version1);
23324
- var v2 = parse(version2);
23325
- var prefix = '';
23326
- if (v1.prerelease.length || v2.prerelease.length) {
23327
- prefix = 'pre';
23328
- var defaultResult = 'prerelease';
23329
- }
23330
- for (var key in v1) {
23331
- if (key === 'major' || key === 'minor' || key === 'patch') {
23332
- if (v1[key] !== v2[key]) {
23333
- return prefix + key
23334
- }
23335
- }
23336
- }
23337
- return defaultResult // may be undefined
23338
- }
23339
- }
23340
-
23341
- exports.compareIdentifiers = compareIdentifiers;
23342
-
23343
- var numeric = /^[0-9]+$/;
23344
- function compareIdentifiers (a, b) {
23345
- var anum = numeric.test(a);
23346
- var bnum = numeric.test(b);
23347
-
23348
- if (anum && bnum) {
23349
- a = +a;
23350
- b = +b;
23351
- }
23352
-
23353
- return a === b ? 0
23354
- : (anum && !bnum) ? -1
23355
- : (bnum && !anum) ? 1
23356
- : a < b ? -1
23357
- : 1
23358
- }
23359
-
23360
- exports.rcompareIdentifiers = rcompareIdentifiers;
23361
- function rcompareIdentifiers (a, b) {
23362
- return compareIdentifiers(b, a)
23363
- }
23061
+ exports = module.exports = SemVer;
23062
+ var debug;
23063
+ /* istanbul ignore next */
23064
+ if (typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
23065
+ debug = function () {
23066
+ var args = Array.prototype.slice.call(arguments, 0);
23067
+ args.unshift('SEMVER');
23068
+ console.log.apply(console, args);
23069
+ };
23070
+ } else {
23071
+ debug = function () {};
23072
+ }
23364
23073
 
23365
- exports.major = major;
23366
- function major (a, loose) {
23367
- return new SemVer(a, loose).major
23368
- }
23074
+ // Note: this is the semver.org version of the spec that it implements
23075
+ // Not necessarily the package version of this code.
23076
+ exports.SEMVER_SPEC_VERSION = '2.0.0';
23077
+ var MAX_LENGTH = 256;
23078
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */9007199254740991;
23079
+
23080
+ // Max safe segment length for coercion.
23081
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
23082
+
23083
+ // The actual regexps go on exports.re
23084
+ var re = exports.re = [];
23085
+ var src = exports.src = [];
23086
+ var t = exports.tokens = {};
23087
+ var R = 0;
23088
+ function tok(n) {
23089
+ t[n] = R++;
23090
+ }
23091
+
23092
+ // The following Regular Expressions can be used for tokenizing,
23093
+ // validating, and parsing SemVer version strings.
23094
+
23095
+ // ## Numeric Identifier
23096
+ // A single `0`, or a non-zero digit followed by zero or more digits.
23097
+
23098
+ tok('NUMERICIDENTIFIER');
23099
+ src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
23100
+ tok('NUMERICIDENTIFIERLOOSE');
23101
+ src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
23102
+
23103
+ // ## Non-numeric Identifier
23104
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
23105
+ // more letters, digits, or hyphens.
23106
+
23107
+ tok('NONNUMERICIDENTIFIER');
23108
+ src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
23109
+
23110
+ // ## Main Version
23111
+ // Three dot-separated numeric identifiers.
23112
+
23113
+ tok('MAINVERSION');
23114
+ src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')';
23115
+ tok('MAINVERSIONLOOSE');
23116
+ src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
23117
+
23118
+ // ## Pre-release Version Identifier
23119
+ // A numeric identifier, or a non-numeric identifier.
23120
+
23121
+ tok('PRERELEASEIDENTIFIER');
23122
+ src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + '|' + src[t.NONNUMERICIDENTIFIER] + ')';
23123
+ tok('PRERELEASEIDENTIFIERLOOSE');
23124
+ src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + '|' + src[t.NONNUMERICIDENTIFIER] + ')';
23125
+
23126
+ // ## Pre-release Version
23127
+ // Hyphen, followed by one or more dot-separated pre-release version
23128
+ // identifiers.
23129
+
23130
+ tok('PRERELEASE');
23131
+ src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
23132
+ tok('PRERELEASELOOSE');
23133
+ src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
23134
+
23135
+ // ## Build Metadata Identifier
23136
+ // Any combination of digits, letters, or hyphens.
23137
+
23138
+ tok('BUILDIDENTIFIER');
23139
+ src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
23140
+
23141
+ // ## Build Metadata
23142
+ // Plus sign, followed by one or more period-separated build metadata
23143
+ // identifiers.
23144
+
23145
+ tok('BUILD');
23146
+ src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
23147
+
23148
+ // ## Full Version String
23149
+ // A main version, followed optionally by a pre-release version and
23150
+ // build metadata.
23151
+
23152
+ // Note that the only major, minor, patch, and pre-release sections of
23153
+ // the version string are capturing groups. The build metadata is not a
23154
+ // capturing group, because it should not ever be used in version
23155
+ // comparison.
23156
+
23157
+ tok('FULL');
23158
+ tok('FULLPLAIN');
23159
+ src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + src[t.PRERELEASE] + '?' + src[t.BUILD] + '?';
23160
+ src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
23161
+
23162
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
23163
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
23164
+ // common in the npm registry.
23165
+ tok('LOOSEPLAIN');
23166
+ src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + '?' + src[t.BUILD] + '?';
23167
+ tok('LOOSE');
23168
+ src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
23169
+ tok('GTLT');
23170
+ src[t.GTLT] = '((?:<|>)?=?)';
23171
+
23172
+ // Something like "2.*" or "1.2.x".
23173
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
23174
+ // Only the first item is strictly required.
23175
+ tok('XRANGEIDENTIFIERLOOSE');
23176
+ src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
23177
+ tok('XRANGEIDENTIFIER');
23178
+ src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
23179
+ tok('XRANGEPLAIN');
23180
+ src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:' + src[t.PRERELEASE] + ')?' + src[t.BUILD] + '?' + ')?)?';
23181
+ tok('XRANGEPLAINLOOSE');
23182
+ src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[t.PRERELEASELOOSE] + ')?' + src[t.BUILD] + '?' + ')?)?';
23183
+ tok('XRANGE');
23184
+ src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
23185
+ tok('XRANGELOOSE');
23186
+ src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
23187
+
23188
+ // Coercion.
23189
+ // Extract anything that could conceivably be a part of a valid semver
23190
+ tok('COERCE');
23191
+ src[t.COERCE] = '(^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])';
23192
+ tok('COERCERTL');
23193
+ re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
23194
+
23195
+ // Tilde ranges.
23196
+ // Meaning is "reasonably at or greater than"
23197
+ tok('LONETILDE');
23198
+ src[t.LONETILDE] = '(?:~>?)';
23199
+ tok('TILDETRIM');
23200
+ src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
23201
+ re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
23202
+ var tildeTrimReplace = '$1~';
23203
+ tok('TILDE');
23204
+ src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
23205
+ tok('TILDELOOSE');
23206
+ src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
23207
+
23208
+ // Caret ranges.
23209
+ // Meaning is "at least and backwards compatible with"
23210
+ tok('LONECARET');
23211
+ src[t.LONECARET] = '(?:\\^)';
23212
+ tok('CARETTRIM');
23213
+ src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
23214
+ re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
23215
+ var caretTrimReplace = '$1^';
23216
+ tok('CARET');
23217
+ src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
23218
+ tok('CARETLOOSE');
23219
+ src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
23220
+
23221
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
23222
+ tok('COMPARATORLOOSE');
23223
+ src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
23224
+ tok('COMPARATOR');
23225
+ src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
23226
+
23227
+ // An expression to strip any whitespace between the gtlt and the thing
23228
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
23229
+ tok('COMPARATORTRIM');
23230
+ src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
23231
+
23232
+ // this one has to use the /g flag
23233
+ re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
23234
+ var comparatorTrimReplace = '$1$2$3';
23235
+
23236
+ // Something like `1.2.3 - 1.2.4`
23237
+ // Note that these all use the loose form, because they'll be
23238
+ // checked against either the strict or loose comparator form
23239
+ // later.
23240
+ tok('HYPHENRANGE');
23241
+ src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAIN] + ')' + '\\s*$';
23242
+ tok('HYPHENRANGELOOSE');
23243
+ src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s*$';
23244
+
23245
+ // Star ranges basically just allow anything at all.
23246
+ tok('STAR');
23247
+ src[t.STAR] = '(<|>)?=?\\s*\\*';
23248
+
23249
+ // Compile to actual regexp objects.
23250
+ // All are flag-free, unless they were created above with a flag.
23251
+ for (var i = 0; i < R; i++) {
23252
+ debug(i, src[i]);
23253
+ if (!re[i]) {
23254
+ re[i] = new RegExp(src[i]);
23255
+ }
23256
+ }
23257
+ exports.parse = parse;
23258
+ function parse(version, options) {
23259
+ if (!options || typeof options !== 'object') {
23260
+ options = {
23261
+ loose: !!options,
23262
+ includePrerelease: false
23263
+ };
23264
+ }
23265
+ if (version instanceof SemVer) {
23266
+ return version;
23267
+ }
23268
+ if (typeof version !== 'string') {
23269
+ return null;
23270
+ }
23271
+ if (version.length > MAX_LENGTH) {
23272
+ return null;
23273
+ }
23274
+ var r = options.loose ? re[t.LOOSE] : re[t.FULL];
23275
+ if (!r.test(version)) {
23276
+ return null;
23277
+ }
23278
+ try {
23279
+ return new SemVer(version, options);
23280
+ } catch (er) {
23281
+ return null;
23282
+ }
23283
+ }
23284
+ exports.valid = valid;
23285
+ function valid(version, options) {
23286
+ var v = parse(version, options);
23287
+ return v ? v.version : null;
23288
+ }
23289
+ exports.clean = clean;
23290
+ function clean(version, options) {
23291
+ var s = parse(version.trim().replace(/^[=v]+/, ''), options);
23292
+ return s ? s.version : null;
23293
+ }
23294
+ exports.SemVer = SemVer;
23295
+ function SemVer(version, options) {
23296
+ if (!options || typeof options !== 'object') {
23297
+ options = {
23298
+ loose: !!options,
23299
+ includePrerelease: false
23300
+ };
23301
+ }
23302
+ if (version instanceof SemVer) {
23303
+ if (version.loose === options.loose) {
23304
+ return version;
23305
+ } else {
23306
+ version = version.version;
23307
+ }
23308
+ } else if (typeof version !== 'string') {
23309
+ throw new TypeError('Invalid Version: ' + version);
23310
+ }
23311
+ if (version.length > MAX_LENGTH) {
23312
+ throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
23313
+ }
23314
+ if (!(this instanceof SemVer)) {
23315
+ return new SemVer(version, options);
23316
+ }
23317
+ debug('SemVer', version, options);
23318
+ this.options = options;
23319
+ this.loose = !!options.loose;
23320
+ var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
23321
+ if (!m) {
23322
+ throw new TypeError('Invalid Version: ' + version);
23323
+ }
23324
+ this.raw = version;
23369
23325
 
23370
- exports.minor = minor;
23371
- function minor (a, loose) {
23372
- return new SemVer(a, loose).minor
23373
- }
23326
+ // these are actually numbers
23327
+ this.major = +m[1];
23328
+ this.minor = +m[2];
23329
+ this.patch = +m[3];
23330
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
23331
+ throw new TypeError('Invalid major version');
23332
+ }
23333
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
23334
+ throw new TypeError('Invalid minor version');
23335
+ }
23336
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
23337
+ throw new TypeError('Invalid patch version');
23338
+ }
23374
23339
 
23375
- exports.patch = patch;
23376
- function patch (a, loose) {
23377
- return new SemVer(a, loose).patch
23378
- }
23340
+ // numberify any prerelease numeric ids
23341
+ if (!m[4]) {
23342
+ this.prerelease = [];
23343
+ } else {
23344
+ this.prerelease = m[4].split('.').map(function (id) {
23345
+ if (/^[0-9]+$/.test(id)) {
23346
+ var num = +id;
23347
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
23348
+ return num;
23349
+ }
23350
+ }
23351
+ return id;
23352
+ });
23353
+ }
23354
+ this.build = m[5] ? m[5].split('.') : [];
23355
+ this.format();
23356
+ }
23357
+ SemVer.prototype.format = function () {
23358
+ this.version = this.major + '.' + this.minor + '.' + this.patch;
23359
+ if (this.prerelease.length) {
23360
+ this.version += '-' + this.prerelease.join('.');
23361
+ }
23362
+ return this.version;
23363
+ };
23364
+ SemVer.prototype.toString = function () {
23365
+ return this.version;
23366
+ };
23367
+ SemVer.prototype.compare = function (other) {
23368
+ debug('SemVer.compare', this.version, this.options, other);
23369
+ if (!(other instanceof SemVer)) {
23370
+ other = new SemVer(other, this.options);
23371
+ }
23372
+ return this.compareMain(other) || this.comparePre(other);
23373
+ };
23374
+ SemVer.prototype.compareMain = function (other) {
23375
+ if (!(other instanceof SemVer)) {
23376
+ other = new SemVer(other, this.options);
23377
+ }
23378
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
23379
+ };
23380
+ SemVer.prototype.comparePre = function (other) {
23381
+ if (!(other instanceof SemVer)) {
23382
+ other = new SemVer(other, this.options);
23383
+ }
23379
23384
 
23380
- exports.compare = compare;
23381
- function compare (a, b, loose) {
23382
- return new SemVer(a, loose).compare(new SemVer(b, loose))
23383
- }
23385
+ // NOT having a prerelease is > having one
23386
+ if (this.prerelease.length && !other.prerelease.length) {
23387
+ return -1;
23388
+ } else if (!this.prerelease.length && other.prerelease.length) {
23389
+ return 1;
23390
+ } else if (!this.prerelease.length && !other.prerelease.length) {
23391
+ return 0;
23392
+ }
23393
+ var i = 0;
23394
+ do {
23395
+ var a = this.prerelease[i];
23396
+ var b = other.prerelease[i];
23397
+ debug('prerelease compare', i, a, b);
23398
+ if (a === undefined && b === undefined) {
23399
+ return 0;
23400
+ } else if (b === undefined) {
23401
+ return 1;
23402
+ } else if (a === undefined) {
23403
+ return -1;
23404
+ } else if (a === b) {
23405
+ continue;
23406
+ } else {
23407
+ return compareIdentifiers(a, b);
23408
+ }
23409
+ } while (++i);
23410
+ };
23411
+ SemVer.prototype.compareBuild = function (other) {
23412
+ if (!(other instanceof SemVer)) {
23413
+ other = new SemVer(other, this.options);
23414
+ }
23415
+ var i = 0;
23416
+ do {
23417
+ var a = this.build[i];
23418
+ var b = other.build[i];
23419
+ debug('prerelease compare', i, a, b);
23420
+ if (a === undefined && b === undefined) {
23421
+ return 0;
23422
+ } else if (b === undefined) {
23423
+ return 1;
23424
+ } else if (a === undefined) {
23425
+ return -1;
23426
+ } else if (a === b) {
23427
+ continue;
23428
+ } else {
23429
+ return compareIdentifiers(a, b);
23430
+ }
23431
+ } while (++i);
23432
+ };
23384
23433
 
23385
- exports.compareLoose = compareLoose;
23386
- function compareLoose (a, b) {
23387
- return compare(a, b, true)
23388
- }
23389
-
23390
- exports.compareBuild = compareBuild;
23391
- function compareBuild (a, b, loose) {
23392
- var versionA = new SemVer(a, loose);
23393
- var versionB = new SemVer(b, loose);
23394
- return versionA.compare(versionB) || versionA.compareBuild(versionB)
23395
- }
23396
-
23397
- exports.rcompare = rcompare;
23398
- function rcompare (a, b, loose) {
23399
- return compare(b, a, loose)
23400
- }
23401
-
23402
- exports.sort = sort;
23403
- function sort (list, loose) {
23404
- return list.sort(function (a, b) {
23405
- return exports.compareBuild(a, b, loose)
23406
- })
23407
- }
23408
-
23409
- exports.rsort = rsort;
23410
- function rsort (list, loose) {
23411
- return list.sort(function (a, b) {
23412
- return exports.compareBuild(b, a, loose)
23413
- })
23414
- }
23415
-
23416
- exports.gt = gt;
23417
- function gt (a, b, loose) {
23418
- return compare(a, b, loose) > 0
23419
- }
23420
-
23421
- exports.lt = lt;
23422
- function lt (a, b, loose) {
23423
- return compare(a, b, loose) < 0
23424
- }
23425
-
23426
- exports.eq = eq;
23427
- function eq (a, b, loose) {
23428
- return compare(a, b, loose) === 0
23429
- }
23430
-
23431
- exports.neq = neq;
23432
- function neq (a, b, loose) {
23433
- return compare(a, b, loose) !== 0
23434
- }
23435
-
23436
- exports.gte = gte;
23437
- function gte (a, b, loose) {
23438
- return compare(a, b, loose) >= 0
23439
- }
23440
-
23441
- exports.lte = lte;
23442
- function lte (a, b, loose) {
23443
- return compare(a, b, loose) <= 0
23444
- }
23445
-
23446
- exports.cmp = cmp;
23447
- function cmp (a, op, b, loose) {
23448
- switch (op) {
23449
- case '===':
23450
- if (typeof a === 'object')
23451
- a = a.version;
23452
- if (typeof b === 'object')
23453
- b = b.version;
23454
- return a === b
23455
-
23456
- case '!==':
23457
- if (typeof a === 'object')
23458
- a = a.version;
23459
- if (typeof b === 'object')
23460
- b = b.version;
23461
- return a !== b
23462
-
23463
- case '':
23464
- case '=':
23465
- case '==':
23466
- return eq(a, b, loose)
23467
-
23468
- case '!=':
23469
- return neq(a, b, loose)
23470
-
23471
- case '>':
23472
- return gt(a, b, loose)
23473
-
23474
- case '>=':
23475
- return gte(a, b, loose)
23476
-
23477
- case '<':
23478
- return lt(a, b, loose)
23479
-
23480
- case '<=':
23481
- return lte(a, b, loose)
23482
-
23483
- default:
23484
- throw new TypeError('Invalid operator: ' + op)
23485
- }
23486
- }
23487
-
23488
- exports.Comparator = Comparator;
23489
- function Comparator (comp, options) {
23490
- if (!options || typeof options !== 'object') {
23491
- options = {
23492
- loose: !!options,
23493
- includePrerelease: false
23494
- };
23495
- }
23496
-
23497
- if (comp instanceof Comparator) {
23498
- if (comp.loose === !!options.loose) {
23499
- return comp
23500
- } else {
23501
- comp = comp.value;
23502
- }
23503
- }
23504
-
23505
- if (!(this instanceof Comparator)) {
23506
- return new Comparator(comp, options)
23507
- }
23508
-
23509
- debug('comparator', comp, options);
23510
- this.options = options;
23511
- this.loose = !!options.loose;
23512
- this.parse(comp);
23513
-
23514
- if (this.semver === ANY) {
23515
- this.value = '';
23516
- } else {
23517
- this.value = this.operator + this.semver.version;
23518
- }
23519
-
23520
- debug('comp', this);
23521
- }
23522
-
23523
- var ANY = {};
23524
- Comparator.prototype.parse = function (comp) {
23525
- var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
23526
- var m = comp.match(r);
23527
-
23528
- if (!m) {
23529
- throw new TypeError('Invalid comparator: ' + comp)
23530
- }
23531
-
23532
- this.operator = m[1] !== undefined ? m[1] : '';
23533
- if (this.operator === '=') {
23534
- this.operator = '';
23535
- }
23536
-
23537
- // if it literally is just '>' or '' then allow anything.
23538
- if (!m[2]) {
23539
- this.semver = ANY;
23540
- } else {
23541
- this.semver = new SemVer(m[2], this.options.loose);
23542
- }
23543
- };
23544
-
23545
- Comparator.prototype.toString = function () {
23546
- return this.value
23547
- };
23548
-
23549
- Comparator.prototype.test = function (version) {
23550
- debug('Comparator.test', version, this.options.loose);
23551
-
23552
- if (this.semver === ANY || version === ANY) {
23553
- return true
23554
- }
23555
-
23556
- if (typeof version === 'string') {
23557
- try {
23558
- version = new SemVer(version, this.options);
23559
- } catch (er) {
23560
- return false
23561
- }
23562
- }
23563
-
23564
- return cmp(version, this.operator, this.semver, this.options)
23565
- };
23566
-
23567
- Comparator.prototype.intersects = function (comp, options) {
23568
- if (!(comp instanceof Comparator)) {
23569
- throw new TypeError('a Comparator is required')
23570
- }
23571
-
23572
- if (!options || typeof options !== 'object') {
23573
- options = {
23574
- loose: !!options,
23575
- includePrerelease: false
23576
- };
23577
- }
23578
-
23579
- var rangeTmp;
23580
-
23581
- if (this.operator === '') {
23582
- if (this.value === '') {
23583
- return true
23584
- }
23585
- rangeTmp = new Range(comp.value, options);
23586
- return satisfies(this.value, rangeTmp, options)
23587
- } else if (comp.operator === '') {
23588
- if (comp.value === '') {
23589
- return true
23590
- }
23591
- rangeTmp = new Range(this.value, options);
23592
- return satisfies(comp.semver, rangeTmp, options)
23593
- }
23594
-
23595
- var sameDirectionIncreasing =
23596
- (this.operator === '>=' || this.operator === '>') &&
23597
- (comp.operator === '>=' || comp.operator === '>');
23598
- var sameDirectionDecreasing =
23599
- (this.operator === '<=' || this.operator === '<') &&
23600
- (comp.operator === '<=' || comp.operator === '<');
23601
- var sameSemVer = this.semver.version === comp.semver.version;
23602
- var differentDirectionsInclusive =
23603
- (this.operator === '>=' || this.operator === '<=') &&
23604
- (comp.operator === '>=' || comp.operator === '<=');
23605
- var oppositeDirectionsLessThan =
23606
- cmp(this.semver, '<', comp.semver, options) &&
23607
- ((this.operator === '>=' || this.operator === '>') &&
23608
- (comp.operator === '<=' || comp.operator === '<'));
23609
- var oppositeDirectionsGreaterThan =
23610
- cmp(this.semver, '>', comp.semver, options) &&
23611
- ((this.operator === '<=' || this.operator === '<') &&
23612
- (comp.operator === '>=' || comp.operator === '>'));
23613
-
23614
- return sameDirectionIncreasing || sameDirectionDecreasing ||
23615
- (sameSemVer && differentDirectionsInclusive) ||
23616
- oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
23617
- };
23618
-
23619
- exports.Range = Range;
23620
- function Range (range, options) {
23621
- if (!options || typeof options !== 'object') {
23622
- options = {
23623
- loose: !!options,
23624
- includePrerelease: false
23625
- };
23626
- }
23627
-
23628
- if (range instanceof Range) {
23629
- if (range.loose === !!options.loose &&
23630
- range.includePrerelease === !!options.includePrerelease) {
23631
- return range
23632
- } else {
23633
- return new Range(range.raw, options)
23634
- }
23635
- }
23636
-
23637
- if (range instanceof Comparator) {
23638
- return new Range(range.value, options)
23639
- }
23640
-
23641
- if (!(this instanceof Range)) {
23642
- return new Range(range, options)
23643
- }
23644
-
23645
- this.options = options;
23646
- this.loose = !!options.loose;
23647
- this.includePrerelease = !!options.includePrerelease;
23648
-
23649
- // First, split based on boolean or ||
23650
- this.raw = range;
23651
- this.set = range.split(/\s*\|\|\s*/).map(function (range) {
23652
- return this.parseRange(range.trim())
23653
- }, this).filter(function (c) {
23654
- // throw out any that are not relevant for whatever reason
23655
- return c.length
23656
- });
23657
-
23658
- if (!this.set.length) {
23659
- throw new TypeError('Invalid SemVer Range: ' + range)
23660
- }
23661
-
23662
- this.format();
23663
- }
23664
-
23665
- Range.prototype.format = function () {
23666
- this.range = this.set.map(function (comps) {
23667
- return comps.join(' ').trim()
23668
- }).join('||').trim();
23669
- return this.range
23670
- };
23671
-
23672
- Range.prototype.toString = function () {
23673
- return this.range
23674
- };
23675
-
23676
- Range.prototype.parseRange = function (range) {
23677
- var loose = this.options.loose;
23678
- range = range.trim();
23679
- // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
23680
- var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
23681
- range = range.replace(hr, hyphenReplace);
23682
- debug('hyphen replace', range);
23683
- // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
23684
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
23685
- debug('comparator trim', range, re[t.COMPARATORTRIM]);
23686
-
23687
- // `~ 1.2.3` => `~1.2.3`
23688
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
23689
-
23690
- // `^ 1.2.3` => `^1.2.3`
23691
- range = range.replace(re[t.CARETTRIM], caretTrimReplace);
23692
-
23693
- // normalize spaces
23694
- range = range.split(/\s+/).join(' ');
23695
-
23696
- // At this point, the range is completely trimmed and
23697
- // ready to be split into comparators.
23698
-
23699
- var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
23700
- var set = range.split(' ').map(function (comp) {
23701
- return parseComparator(comp, this.options)
23702
- }, this).join(' ').split(/\s+/);
23703
- if (this.options.loose) {
23704
- // in loose mode, throw out any that are not valid comparators
23705
- set = set.filter(function (comp) {
23706
- return !!comp.match(compRe)
23707
- });
23708
- }
23709
- set = set.map(function (comp) {
23710
- return new Comparator(comp, this.options)
23711
- }, this);
23712
-
23713
- return set
23714
- };
23715
-
23716
- Range.prototype.intersects = function (range, options) {
23717
- if (!(range instanceof Range)) {
23718
- throw new TypeError('a Range is required')
23719
- }
23720
-
23721
- return this.set.some(function (thisComparators) {
23722
- return (
23723
- isSatisfiable(thisComparators, options) &&
23724
- range.set.some(function (rangeComparators) {
23725
- return (
23726
- isSatisfiable(rangeComparators, options) &&
23727
- thisComparators.every(function (thisComparator) {
23728
- return rangeComparators.every(function (rangeComparator) {
23729
- return thisComparator.intersects(rangeComparator, options)
23730
- })
23731
- })
23732
- )
23733
- })
23734
- )
23735
- })
23736
- };
23737
-
23738
- // take a set of comparators and determine whether there
23739
- // exists a version which can satisfy it
23740
- function isSatisfiable (comparators, options) {
23741
- var result = true;
23742
- var remainingComparators = comparators.slice();
23743
- var testComparator = remainingComparators.pop();
23744
-
23745
- while (result && remainingComparators.length) {
23746
- result = remainingComparators.every(function (otherComparator) {
23747
- return testComparator.intersects(otherComparator, options)
23748
- });
23749
-
23750
- testComparator = remainingComparators.pop();
23751
- }
23752
-
23753
- return result
23754
- }
23755
-
23756
- // Mostly just for testing and legacy API reasons
23757
- exports.toComparators = toComparators;
23758
- function toComparators (range, options) {
23759
- return new Range(range, options).set.map(function (comp) {
23760
- return comp.map(function (c) {
23761
- return c.value
23762
- }).join(' ').trim().split(' ')
23763
- })
23764
- }
23765
-
23766
- // comprised of xranges, tildes, stars, and gtlt's at this point.
23767
- // already replaced the hyphen ranges
23768
- // turn into a set of JUST comparators.
23769
- function parseComparator (comp, options) {
23770
- debug('comp', comp, options);
23771
- comp = replaceCarets(comp, options);
23772
- debug('caret', comp);
23773
- comp = replaceTildes(comp, options);
23774
- debug('tildes', comp);
23775
- comp = replaceXRanges(comp, options);
23776
- debug('xrange', comp);
23777
- comp = replaceStars(comp, options);
23778
- debug('stars', comp);
23779
- return comp
23780
- }
23781
-
23782
- function isX (id) {
23783
- return !id || id.toLowerCase() === 'x' || id === '*'
23784
- }
23785
-
23786
- // ~, ~> --> * (any, kinda silly)
23787
- // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
23788
- // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
23789
- // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
23790
- // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
23791
- // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
23792
- function replaceTildes (comp, options) {
23793
- return comp.trim().split(/\s+/).map(function (comp) {
23794
- return replaceTilde(comp, options)
23795
- }).join(' ')
23796
- }
23797
-
23798
- function replaceTilde (comp, options) {
23799
- var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
23800
- return comp.replace(r, function (_, M, m, p, pr) {
23801
- debug('tilde', comp, _, M, m, p, pr);
23802
- var ret;
23803
-
23804
- if (isX(M)) {
23805
- ret = '';
23806
- } else if (isX(m)) {
23807
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
23808
- } else if (isX(p)) {
23809
- // ~1.2 == >=1.2.0 <1.3.0
23810
- ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
23811
- } else if (pr) {
23812
- debug('replaceTilde pr', pr);
23813
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
23814
- ' <' + M + '.' + (+m + 1) + '.0';
23815
- } else {
23816
- // ~1.2.3 == >=1.2.3 <1.3.0
23817
- ret = '>=' + M + '.' + m + '.' + p +
23818
- ' <' + M + '.' + (+m + 1) + '.0';
23819
- }
23820
-
23821
- debug('tilde return', ret);
23822
- return ret
23823
- })
23824
- }
23434
+ // preminor will bump the version up to the next minor release, and immediately
23435
+ // down to pre-release. premajor and prepatch work the same way.
23436
+ SemVer.prototype.inc = function (release, identifier) {
23437
+ switch (release) {
23438
+ case 'premajor':
23439
+ this.prerelease.length = 0;
23440
+ this.patch = 0;
23441
+ this.minor = 0;
23442
+ this.major++;
23443
+ this.inc('pre', identifier);
23444
+ break;
23445
+ case 'preminor':
23446
+ this.prerelease.length = 0;
23447
+ this.patch = 0;
23448
+ this.minor++;
23449
+ this.inc('pre', identifier);
23450
+ break;
23451
+ case 'prepatch':
23452
+ // If this is already a prerelease, it will bump to the next version
23453
+ // drop any prereleases that might already exist, since they are not
23454
+ // relevant at this point.
23455
+ this.prerelease.length = 0;
23456
+ this.inc('patch', identifier);
23457
+ this.inc('pre', identifier);
23458
+ break;
23459
+ // If the input is a non-prerelease version, this acts the same as
23460
+ // prepatch.
23461
+ case 'prerelease':
23462
+ if (this.prerelease.length === 0) {
23463
+ this.inc('patch', identifier);
23464
+ }
23465
+ this.inc('pre', identifier);
23466
+ break;
23467
+ case 'major':
23468
+ // If this is a pre-major version, bump up to the same major version.
23469
+ // Otherwise increment major.
23470
+ // 1.0.0-5 bumps to 1.0.0
23471
+ // 1.1.0 bumps to 2.0.0
23472
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
23473
+ this.major++;
23474
+ }
23475
+ this.minor = 0;
23476
+ this.patch = 0;
23477
+ this.prerelease = [];
23478
+ break;
23479
+ case 'minor':
23480
+ // If this is a pre-minor version, bump up to the same minor version.
23481
+ // Otherwise increment minor.
23482
+ // 1.2.0-5 bumps to 1.2.0
23483
+ // 1.2.1 bumps to 1.3.0
23484
+ if (this.patch !== 0 || this.prerelease.length === 0) {
23485
+ this.minor++;
23486
+ }
23487
+ this.patch = 0;
23488
+ this.prerelease = [];
23489
+ break;
23490
+ case 'patch':
23491
+ // If this is not a pre-release version, it will increment the patch.
23492
+ // If it is a pre-release it will bump up to the same patch version.
23493
+ // 1.2.0-5 patches to 1.2.0
23494
+ // 1.2.0 patches to 1.2.1
23495
+ if (this.prerelease.length === 0) {
23496
+ this.patch++;
23497
+ }
23498
+ this.prerelease = [];
23499
+ break;
23500
+ // This probably shouldn't be used publicly.
23501
+ // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
23502
+ case 'pre':
23503
+ if (this.prerelease.length === 0) {
23504
+ this.prerelease = [0];
23505
+ } else {
23506
+ var i = this.prerelease.length;
23507
+ while (--i >= 0) {
23508
+ if (typeof this.prerelease[i] === 'number') {
23509
+ this.prerelease[i]++;
23510
+ i = -2;
23511
+ }
23512
+ }
23513
+ if (i === -1) {
23514
+ // didn't increment anything
23515
+ this.prerelease.push(0);
23516
+ }
23517
+ }
23518
+ if (identifier) {
23519
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
23520
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
23521
+ if (this.prerelease[0] === identifier) {
23522
+ if (isNaN(this.prerelease[1])) {
23523
+ this.prerelease = [identifier, 0];
23524
+ }
23525
+ } else {
23526
+ this.prerelease = [identifier, 0];
23527
+ }
23528
+ }
23529
+ break;
23530
+ default:
23531
+ throw new Error('invalid increment argument: ' + release);
23532
+ }
23533
+ this.format();
23534
+ this.raw = this.version;
23535
+ return this;
23536
+ };
23537
+ exports.inc = inc;
23538
+ function inc(version, release, loose, identifier) {
23539
+ if (typeof loose === 'string') {
23540
+ identifier = loose;
23541
+ loose = undefined;
23542
+ }
23543
+ try {
23544
+ return new SemVer(version, loose).inc(release, identifier).version;
23545
+ } catch (er) {
23546
+ return null;
23547
+ }
23548
+ }
23549
+ exports.diff = diff;
23550
+ function diff(version1, version2) {
23551
+ if (eq(version1, version2)) {
23552
+ return null;
23553
+ } else {
23554
+ var v1 = parse(version1);
23555
+ var v2 = parse(version2);
23556
+ var prefix = '';
23557
+ if (v1.prerelease.length || v2.prerelease.length) {
23558
+ prefix = 'pre';
23559
+ var defaultResult = 'prerelease';
23560
+ }
23561
+ for (var key in v1) {
23562
+ if (key === 'major' || key === 'minor' || key === 'patch') {
23563
+ if (v1[key] !== v2[key]) {
23564
+ return prefix + key;
23565
+ }
23566
+ }
23567
+ }
23568
+ return defaultResult; // may be undefined
23569
+ }
23570
+ }
23825
23571
 
23826
- // ^ --> * (any, kinda silly)
23827
- // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
23828
- // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
23829
- // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
23830
- // ^1.2.3 --> >=1.2.3 <2.0.0
23831
- // ^1.2.0 --> >=1.2.0 <2.0.0
23832
- function replaceCarets (comp, options) {
23833
- return comp.trim().split(/\s+/).map(function (comp) {
23834
- return replaceCaret(comp, options)
23835
- }).join(' ')
23836
- }
23572
+ exports.compareIdentifiers = compareIdentifiers;
23573
+ var numeric = /^[0-9]+$/;
23574
+ function compareIdentifiers(a, b) {
23575
+ var anum = numeric.test(a);
23576
+ var bnum = numeric.test(b);
23577
+ if (anum && bnum) {
23578
+ a = +a;
23579
+ b = +b;
23580
+ }
23581
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
23582
+ }
23583
+ exports.rcompareIdentifiers = rcompareIdentifiers;
23584
+ function rcompareIdentifiers(a, b) {
23585
+ return compareIdentifiers(b, a);
23586
+ }
23587
+ exports.major = major;
23588
+ function major(a, loose) {
23589
+ return new SemVer(a, loose).major;
23590
+ }
23591
+ exports.minor = minor;
23592
+ function minor(a, loose) {
23593
+ return new SemVer(a, loose).minor;
23594
+ }
23595
+ exports.patch = patch;
23596
+ function patch(a, loose) {
23597
+ return new SemVer(a, loose).patch;
23598
+ }
23599
+ exports.compare = compare;
23600
+ function compare(a, b, loose) {
23601
+ return new SemVer(a, loose).compare(new SemVer(b, loose));
23602
+ }
23603
+ exports.compareLoose = compareLoose;
23604
+ function compareLoose(a, b) {
23605
+ return compare(a, b, true);
23606
+ }
23607
+ exports.compareBuild = compareBuild;
23608
+ function compareBuild(a, b, loose) {
23609
+ var versionA = new SemVer(a, loose);
23610
+ var versionB = new SemVer(b, loose);
23611
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
23612
+ }
23613
+ exports.rcompare = rcompare;
23614
+ function rcompare(a, b, loose) {
23615
+ return compare(b, a, loose);
23616
+ }
23617
+ exports.sort = sort;
23618
+ function sort(list, loose) {
23619
+ return list.sort(function (a, b) {
23620
+ return exports.compareBuild(a, b, loose);
23621
+ });
23622
+ }
23623
+ exports.rsort = rsort;
23624
+ function rsort(list, loose) {
23625
+ return list.sort(function (a, b) {
23626
+ return exports.compareBuild(b, a, loose);
23627
+ });
23628
+ }
23629
+ exports.gt = gt;
23630
+ function gt(a, b, loose) {
23631
+ return compare(a, b, loose) > 0;
23632
+ }
23633
+ exports.lt = lt;
23634
+ function lt(a, b, loose) {
23635
+ return compare(a, b, loose) < 0;
23636
+ }
23637
+ exports.eq = eq;
23638
+ function eq(a, b, loose) {
23639
+ return compare(a, b, loose) === 0;
23640
+ }
23641
+ exports.neq = neq;
23642
+ function neq(a, b, loose) {
23643
+ return compare(a, b, loose) !== 0;
23644
+ }
23645
+ exports.gte = gte;
23646
+ function gte(a, b, loose) {
23647
+ return compare(a, b, loose) >= 0;
23648
+ }
23649
+ exports.lte = lte;
23650
+ function lte(a, b, loose) {
23651
+ return compare(a, b, loose) <= 0;
23652
+ }
23653
+ exports.cmp = cmp;
23654
+ function cmp(a, op, b, loose) {
23655
+ switch (op) {
23656
+ case '===':
23657
+ if (typeof a === 'object') a = a.version;
23658
+ if (typeof b === 'object') b = b.version;
23659
+ return a === b;
23660
+ case '!==':
23661
+ if (typeof a === 'object') a = a.version;
23662
+ if (typeof b === 'object') b = b.version;
23663
+ return a !== b;
23664
+ case '':
23665
+ case '=':
23666
+ case '==':
23667
+ return eq(a, b, loose);
23668
+ case '!=':
23669
+ return neq(a, b, loose);
23670
+ case '>':
23671
+ return gt(a, b, loose);
23672
+ case '>=':
23673
+ return gte(a, b, loose);
23674
+ case '<':
23675
+ return lt(a, b, loose);
23676
+ case '<=':
23677
+ return lte(a, b, loose);
23678
+ default:
23679
+ throw new TypeError('Invalid operator: ' + op);
23680
+ }
23681
+ }
23682
+ exports.Comparator = Comparator;
23683
+ function Comparator(comp, options) {
23684
+ if (!options || typeof options !== 'object') {
23685
+ options = {
23686
+ loose: !!options,
23687
+ includePrerelease: false
23688
+ };
23689
+ }
23690
+ if (comp instanceof Comparator) {
23691
+ if (comp.loose === !!options.loose) {
23692
+ return comp;
23693
+ } else {
23694
+ comp = comp.value;
23695
+ }
23696
+ }
23697
+ if (!(this instanceof Comparator)) {
23698
+ return new Comparator(comp, options);
23699
+ }
23700
+ debug('comparator', comp, options);
23701
+ this.options = options;
23702
+ this.loose = !!options.loose;
23703
+ this.parse(comp);
23704
+ if (this.semver === ANY) {
23705
+ this.value = '';
23706
+ } else {
23707
+ this.value = this.operator + this.semver.version;
23708
+ }
23709
+ debug('comp', this);
23710
+ }
23711
+ var ANY = {};
23712
+ Comparator.prototype.parse = function (comp) {
23713
+ var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
23714
+ var m = comp.match(r);
23715
+ if (!m) {
23716
+ throw new TypeError('Invalid comparator: ' + comp);
23717
+ }
23718
+ this.operator = m[1] !== undefined ? m[1] : '';
23719
+ if (this.operator === '=') {
23720
+ this.operator = '';
23721
+ }
23837
23722
 
23838
- function replaceCaret (comp, options) {
23839
- debug('caret', comp, options);
23840
- var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
23841
- return comp.replace(r, function (_, M, m, p, pr) {
23842
- debug('caret', comp, _, M, m, p, pr);
23843
- var ret;
23844
-
23845
- if (isX(M)) {
23846
- ret = '';
23847
- } else if (isX(m)) {
23848
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
23849
- } else if (isX(p)) {
23850
- if (M === '0') {
23851
- ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
23852
- } else {
23853
- ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
23854
- }
23855
- } else if (pr) {
23856
- debug('replaceCaret pr', pr);
23857
- if (M === '0') {
23858
- if (m === '0') {
23859
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
23860
- ' <' + M + '.' + m + '.' + (+p + 1);
23861
- } else {
23862
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
23863
- ' <' + M + '.' + (+m + 1) + '.0';
23864
- }
23865
- } else {
23866
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
23867
- ' <' + (+M + 1) + '.0.0';
23868
- }
23869
- } else {
23870
- debug('no pr');
23871
- if (M === '0') {
23872
- if (m === '0') {
23873
- ret = '>=' + M + '.' + m + '.' + p +
23874
- ' <' + M + '.' + m + '.' + (+p + 1);
23875
- } else {
23876
- ret = '>=' + M + '.' + m + '.' + p +
23877
- ' <' + M + '.' + (+m + 1) + '.0';
23878
- }
23879
- } else {
23880
- ret = '>=' + M + '.' + m + '.' + p +
23881
- ' <' + (+M + 1) + '.0.0';
23882
- }
23883
- }
23884
-
23885
- debug('caret return', ret);
23886
- return ret
23887
- })
23888
- }
23723
+ // if it literally is just '>' or '' then allow anything.
23724
+ if (!m[2]) {
23725
+ this.semver = ANY;
23726
+ } else {
23727
+ this.semver = new SemVer(m[2], this.options.loose);
23728
+ }
23729
+ };
23730
+ Comparator.prototype.toString = function () {
23731
+ return this.value;
23732
+ };
23733
+ Comparator.prototype.test = function (version) {
23734
+ debug('Comparator.test', version, this.options.loose);
23735
+ if (this.semver === ANY || version === ANY) {
23736
+ return true;
23737
+ }
23738
+ if (typeof version === 'string') {
23739
+ try {
23740
+ version = new SemVer(version, this.options);
23741
+ } catch (er) {
23742
+ return false;
23743
+ }
23744
+ }
23745
+ return cmp(version, this.operator, this.semver, this.options);
23746
+ };
23747
+ Comparator.prototype.intersects = function (comp, options) {
23748
+ if (!(comp instanceof Comparator)) {
23749
+ throw new TypeError('a Comparator is required');
23750
+ }
23751
+ if (!options || typeof options !== 'object') {
23752
+ options = {
23753
+ loose: !!options,
23754
+ includePrerelease: false
23755
+ };
23756
+ }
23757
+ var rangeTmp;
23758
+ if (this.operator === '') {
23759
+ if (this.value === '') {
23760
+ return true;
23761
+ }
23762
+ rangeTmp = new Range(comp.value, options);
23763
+ return satisfies(this.value, rangeTmp, options);
23764
+ } else if (comp.operator === '') {
23765
+ if (comp.value === '') {
23766
+ return true;
23767
+ }
23768
+ rangeTmp = new Range(this.value, options);
23769
+ return satisfies(comp.semver, rangeTmp, options);
23770
+ }
23771
+ var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
23772
+ var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
23773
+ var sameSemVer = this.semver.version === comp.semver.version;
23774
+ var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
23775
+ var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
23776
+ var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
23777
+ return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
23778
+ };
23779
+ exports.Range = Range;
23780
+ function Range(range, options) {
23781
+ if (!options || typeof options !== 'object') {
23782
+ options = {
23783
+ loose: !!options,
23784
+ includePrerelease: false
23785
+ };
23786
+ }
23787
+ if (range instanceof Range) {
23788
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
23789
+ return range;
23790
+ } else {
23791
+ return new Range(range.raw, options);
23792
+ }
23793
+ }
23794
+ if (range instanceof Comparator) {
23795
+ return new Range(range.value, options);
23796
+ }
23797
+ if (!(this instanceof Range)) {
23798
+ return new Range(range, options);
23799
+ }
23800
+ this.options = options;
23801
+ this.loose = !!options.loose;
23802
+ this.includePrerelease = !!options.includePrerelease;
23889
23803
 
23890
- function replaceXRanges (comp, options) {
23891
- debug('replaceXRanges', comp, options);
23892
- return comp.split(/\s+/).map(function (comp) {
23893
- return replaceXRange(comp, options)
23894
- }).join(' ')
23895
- }
23804
+ // First, split based on boolean or ||
23805
+ this.raw = range;
23806
+ this.set = range.split(/\s*\|\|\s*/).map(function (range) {
23807
+ return this.parseRange(range.trim());
23808
+ }, this).filter(function (c) {
23809
+ // throw out any that are not relevant for whatever reason
23810
+ return c.length;
23811
+ });
23812
+ if (!this.set.length) {
23813
+ throw new TypeError('Invalid SemVer Range: ' + range);
23814
+ }
23815
+ this.format();
23816
+ }
23817
+ Range.prototype.format = function () {
23818
+ this.range = this.set.map(function (comps) {
23819
+ return comps.join(' ').trim();
23820
+ }).join('||').trim();
23821
+ return this.range;
23822
+ };
23823
+ Range.prototype.toString = function () {
23824
+ return this.range;
23825
+ };
23826
+ Range.prototype.parseRange = function (range) {
23827
+ var loose = this.options.loose;
23828
+ range = range.trim();
23829
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
23830
+ var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
23831
+ range = range.replace(hr, hyphenReplace);
23832
+ debug('hyphen replace', range);
23833
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
23834
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
23835
+ debug('comparator trim', range, re[t.COMPARATORTRIM]);
23836
+
23837
+ // `~ 1.2.3` => `~1.2.3`
23838
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
23839
+
23840
+ // `^ 1.2.3` => `^1.2.3`
23841
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
23842
+
23843
+ // normalize spaces
23844
+ range = range.split(/\s+/).join(' ');
23845
+
23846
+ // At this point, the range is completely trimmed and
23847
+ // ready to be split into comparators.
23848
+
23849
+ var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
23850
+ var set = range.split(' ').map(function (comp) {
23851
+ return parseComparator(comp, this.options);
23852
+ }, this).join(' ').split(/\s+/);
23853
+ if (this.options.loose) {
23854
+ // in loose mode, throw out any that are not valid comparators
23855
+ set = set.filter(function (comp) {
23856
+ return !!comp.match(compRe);
23857
+ });
23858
+ }
23859
+ set = set.map(function (comp) {
23860
+ return new Comparator(comp, this.options);
23861
+ }, this);
23862
+ return set;
23863
+ };
23864
+ Range.prototype.intersects = function (range, options) {
23865
+ if (!(range instanceof Range)) {
23866
+ throw new TypeError('a Range is required');
23867
+ }
23868
+ return this.set.some(function (thisComparators) {
23869
+ return isSatisfiable(thisComparators, options) && range.set.some(function (rangeComparators) {
23870
+ return isSatisfiable(rangeComparators, options) && thisComparators.every(function (thisComparator) {
23871
+ return rangeComparators.every(function (rangeComparator) {
23872
+ return thisComparator.intersects(rangeComparator, options);
23873
+ });
23874
+ });
23875
+ });
23876
+ });
23877
+ };
23896
23878
 
23897
- function replaceXRange (comp, options) {
23898
- comp = comp.trim();
23899
- var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
23900
- return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
23901
- debug('xRange', comp, ret, gtlt, M, m, p, pr);
23902
- var xM = isX(M);
23903
- var xm = xM || isX(m);
23904
- var xp = xm || isX(p);
23905
- var anyX = xp;
23906
-
23907
- if (gtlt === '=' && anyX) {
23908
- gtlt = '';
23909
- }
23910
-
23911
- // if we're including prereleases in the match, then we need
23912
- // to fix this to -0, the lowest possible prerelease value
23913
- pr = options.includePrerelease ? '-0' : '';
23914
-
23915
- if (xM) {
23916
- if (gtlt === '>' || gtlt === '<') {
23917
- // nothing is allowed
23918
- ret = '<0.0.0-0';
23919
- } else {
23920
- // nothing is forbidden
23921
- ret = '*';
23922
- }
23923
- } else if (gtlt && anyX) {
23924
- // we know patch is an x, because we have any x at all.
23925
- // replace X with 0
23926
- if (xm) {
23927
- m = 0;
23928
- }
23929
- p = 0;
23930
-
23931
- if (gtlt === '>') {
23932
- // >1 => >=2.0.0
23933
- // >1.2 => >=1.3.0
23934
- // >1.2.3 => >= 1.2.4
23935
- gtlt = '>=';
23936
- if (xm) {
23937
- M = +M + 1;
23938
- m = 0;
23939
- p = 0;
23940
- } else {
23941
- m = +m + 1;
23942
- p = 0;
23943
- }
23944
- } else if (gtlt === '<=') {
23945
- // <=0.7.x is actually <0.8.0, since any 0.7.x should
23946
- // pass. Similarly, <=7.x is actually <8.0.0, etc.
23947
- gtlt = '<';
23948
- if (xm) {
23949
- M = +M + 1;
23950
- } else {
23951
- m = +m + 1;
23952
- }
23953
- }
23954
-
23955
- ret = gtlt + M + '.' + m + '.' + p + pr;
23956
- } else if (xm) {
23957
- ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
23958
- } else if (xp) {
23959
- ret = '>=' + M + '.' + m + '.0' + pr +
23960
- ' <' + M + '.' + (+m + 1) + '.0' + pr;
23961
- }
23962
-
23963
- debug('xRange return', ret);
23964
-
23965
- return ret
23966
- })
23967
- }
23879
+ // take a set of comparators and determine whether there
23880
+ // exists a version which can satisfy it
23881
+ function isSatisfiable(comparators, options) {
23882
+ var result = true;
23883
+ var remainingComparators = comparators.slice();
23884
+ var testComparator = remainingComparators.pop();
23885
+ while (result && remainingComparators.length) {
23886
+ result = remainingComparators.every(function (otherComparator) {
23887
+ return testComparator.intersects(otherComparator, options);
23888
+ });
23889
+ testComparator = remainingComparators.pop();
23890
+ }
23891
+ return result;
23892
+ }
23968
23893
 
23969
- // Because * is AND-ed with everything else in the comparator,
23970
- // and '' means "any version", just remove the *s entirely.
23971
- function replaceStars (comp, options) {
23972
- debug('replaceStars', comp, options);
23973
- // Looseness is ignored here. star is always as loose as it gets!
23974
- return comp.trim().replace(re[t.STAR], '')
23975
- }
23894
+ // Mostly just for testing and legacy API reasons
23895
+ exports.toComparators = toComparators;
23896
+ function toComparators(range, options) {
23897
+ return new Range(range, options).set.map(function (comp) {
23898
+ return comp.map(function (c) {
23899
+ return c.value;
23900
+ }).join(' ').trim().split(' ');
23901
+ });
23902
+ }
23976
23903
 
23977
- // This function is passed to string.replace(re[t.HYPHENRANGE])
23978
- // M, m, patch, prerelease, build
23979
- // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
23980
- // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
23981
- // 1.2 - 3.4 => >=1.2.0 <3.5.0
23982
- function hyphenReplace ($0,
23983
- from, fM, fm, fp, fpr, fb,
23984
- to, tM, tm, tp, tpr, tb) {
23985
- if (isX(fM)) {
23986
- from = '';
23987
- } else if (isX(fm)) {
23988
- from = '>=' + fM + '.0.0';
23989
- } else if (isX(fp)) {
23990
- from = '>=' + fM + '.' + fm + '.0';
23991
- } else {
23992
- from = '>=' + from;
23993
- }
23994
-
23995
- if (isX(tM)) {
23996
- to = '';
23997
- } else if (isX(tm)) {
23998
- to = '<' + (+tM + 1) + '.0.0';
23999
- } else if (isX(tp)) {
24000
- to = '<' + tM + '.' + (+tm + 1) + '.0';
24001
- } else if (tpr) {
24002
- to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
24003
- } else {
24004
- to = '<=' + to;
24005
- }
24006
-
24007
- return (from + ' ' + to).trim()
24008
- }
23904
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
23905
+ // already replaced the hyphen ranges
23906
+ // turn into a set of JUST comparators.
23907
+ function parseComparator(comp, options) {
23908
+ debug('comp', comp, options);
23909
+ comp = replaceCarets(comp, options);
23910
+ debug('caret', comp);
23911
+ comp = replaceTildes(comp, options);
23912
+ debug('tildes', comp);
23913
+ comp = replaceXRanges(comp, options);
23914
+ debug('xrange', comp);
23915
+ comp = replaceStars(comp, options);
23916
+ debug('stars', comp);
23917
+ return comp;
23918
+ }
23919
+ function isX(id) {
23920
+ return !id || id.toLowerCase() === 'x' || id === '*';
23921
+ }
23922
+
23923
+ // ~, ~> --> * (any, kinda silly)
23924
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
23925
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
23926
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
23927
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
23928
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
23929
+ function replaceTildes(comp, options) {
23930
+ return comp.trim().split(/\s+/).map(function (comp) {
23931
+ return replaceTilde(comp, options);
23932
+ }).join(' ');
23933
+ }
23934
+ function replaceTilde(comp, options) {
23935
+ var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
23936
+ return comp.replace(r, function (_, M, m, p, pr) {
23937
+ debug('tilde', comp, _, M, m, p, pr);
23938
+ var ret;
23939
+ if (isX(M)) {
23940
+ ret = '';
23941
+ } else if (isX(m)) {
23942
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
23943
+ } else if (isX(p)) {
23944
+ // ~1.2 == >=1.2.0 <1.3.0
23945
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
23946
+ } else if (pr) {
23947
+ debug('replaceTilde pr', pr);
23948
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
23949
+ } else {
23950
+ // ~1.2.3 == >=1.2.3 <1.3.0
23951
+ ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
23952
+ }
23953
+ debug('tilde return', ret);
23954
+ return ret;
23955
+ });
23956
+ }
24009
23957
 
24010
- // if ANY of the sets match ALL of its comparators, then pass
24011
- Range.prototype.test = function (version) {
24012
- if (!version) {
24013
- return false
24014
- }
24015
-
24016
- if (typeof version === 'string') {
24017
- try {
24018
- version = new SemVer(version, this.options);
24019
- } catch (er) {
24020
- return false
24021
- }
24022
- }
24023
-
24024
- for (var i = 0; i < this.set.length; i++) {
24025
- if (testSet(this.set[i], version, this.options)) {
24026
- return true
24027
- }
24028
- }
24029
- return false
24030
- };
24031
-
24032
- function testSet (set, version, options) {
24033
- for (var i = 0; i < set.length; i++) {
24034
- if (!set[i].test(version)) {
24035
- return false
24036
- }
24037
- }
24038
-
24039
- if (version.prerelease.length && !options.includePrerelease) {
24040
- // Find the set of versions that are allowed to have prereleases
24041
- // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
24042
- // That should allow `1.2.3-pr.2` to pass.
24043
- // However, `1.2.4-alpha.notready` should NOT be allowed,
24044
- // even though it's within the range set by the comparators.
24045
- for (i = 0; i < set.length; i++) {
24046
- debug(set[i].semver);
24047
- if (set[i].semver === ANY) {
24048
- continue
24049
- }
24050
-
24051
- if (set[i].semver.prerelease.length > 0) {
24052
- var allowed = set[i].semver;
24053
- if (allowed.major === version.major &&
24054
- allowed.minor === version.minor &&
24055
- allowed.patch === version.patch) {
24056
- return true
24057
- }
24058
- }
24059
- }
24060
-
24061
- // Version has a -pre, but it's not one of the ones we like.
24062
- return false
24063
- }
24064
-
24065
- return true
24066
- }
23958
+ // ^ --> * (any, kinda silly)
23959
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
23960
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
23961
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
23962
+ // ^1.2.3 --> >=1.2.3 <2.0.0
23963
+ // ^1.2.0 --> >=1.2.0 <2.0.0
23964
+ function replaceCarets(comp, options) {
23965
+ return comp.trim().split(/\s+/).map(function (comp) {
23966
+ return replaceCaret(comp, options);
23967
+ }).join(' ');
23968
+ }
23969
+ function replaceCaret(comp, options) {
23970
+ debug('caret', comp, options);
23971
+ var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
23972
+ return comp.replace(r, function (_, M, m, p, pr) {
23973
+ debug('caret', comp, _, M, m, p, pr);
23974
+ var ret;
23975
+ if (isX(M)) {
23976
+ ret = '';
23977
+ } else if (isX(m)) {
23978
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
23979
+ } else if (isX(p)) {
23980
+ if (M === '0') {
23981
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
23982
+ } else {
23983
+ ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
23984
+ }
23985
+ } else if (pr) {
23986
+ debug('replaceCaret pr', pr);
23987
+ if (M === '0') {
23988
+ if (m === '0') {
23989
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
23990
+ } else {
23991
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
23992
+ }
23993
+ } else {
23994
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
23995
+ }
23996
+ } else {
23997
+ debug('no pr');
23998
+ if (M === '0') {
23999
+ if (m === '0') {
24000
+ ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
24001
+ } else {
24002
+ ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
24003
+ }
24004
+ } else {
24005
+ ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
24006
+ }
24007
+ }
24008
+ debug('caret return', ret);
24009
+ return ret;
24010
+ });
24011
+ }
24012
+ function replaceXRanges(comp, options) {
24013
+ debug('replaceXRanges', comp, options);
24014
+ return comp.split(/\s+/).map(function (comp) {
24015
+ return replaceXRange(comp, options);
24016
+ }).join(' ');
24017
+ }
24018
+ function replaceXRange(comp, options) {
24019
+ comp = comp.trim();
24020
+ var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
24021
+ return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
24022
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
24023
+ var xM = isX(M);
24024
+ var xm = xM || isX(m);
24025
+ var xp = xm || isX(p);
24026
+ var anyX = xp;
24027
+ if (gtlt === '=' && anyX) {
24028
+ gtlt = '';
24029
+ }
24067
24030
 
24068
- exports.satisfies = satisfies;
24069
- function satisfies (version, range, options) {
24070
- try {
24071
- range = new Range(range, options);
24072
- } catch (er) {
24073
- return false
24074
- }
24075
- return range.test(version)
24076
- }
24031
+ // if we're including prereleases in the match, then we need
24032
+ // to fix this to -0, the lowest possible prerelease value
24033
+ pr = options.includePrerelease ? '-0' : '';
24034
+ if (xM) {
24035
+ if (gtlt === '>' || gtlt === '<') {
24036
+ // nothing is allowed
24037
+ ret = '<0.0.0-0';
24038
+ } else {
24039
+ // nothing is forbidden
24040
+ ret = '*';
24041
+ }
24042
+ } else if (gtlt && anyX) {
24043
+ // we know patch is an x, because we have any x at all.
24044
+ // replace X with 0
24045
+ if (xm) {
24046
+ m = 0;
24047
+ }
24048
+ p = 0;
24049
+ if (gtlt === '>') {
24050
+ // >1 => >=2.0.0
24051
+ // >1.2 => >=1.3.0
24052
+ // >1.2.3 => >= 1.2.4
24053
+ gtlt = '>=';
24054
+ if (xm) {
24055
+ M = +M + 1;
24056
+ m = 0;
24057
+ p = 0;
24058
+ } else {
24059
+ m = +m + 1;
24060
+ p = 0;
24061
+ }
24062
+ } else if (gtlt === '<=') {
24063
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
24064
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
24065
+ gtlt = '<';
24066
+ if (xm) {
24067
+ M = +M + 1;
24068
+ } else {
24069
+ m = +m + 1;
24070
+ }
24071
+ }
24072
+ ret = gtlt + M + '.' + m + '.' + p + pr;
24073
+ } else if (xm) {
24074
+ ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
24075
+ } else if (xp) {
24076
+ ret = '>=' + M + '.' + m + '.0' + pr + ' <' + M + '.' + (+m + 1) + '.0' + pr;
24077
+ }
24078
+ debug('xRange return', ret);
24079
+ return ret;
24080
+ });
24081
+ }
24077
24082
 
24078
- exports.maxSatisfying = maxSatisfying;
24079
- function maxSatisfying (versions, range, options) {
24080
- var max = null;
24081
- var maxSV = null;
24082
- try {
24083
- var rangeObj = new Range(range, options);
24084
- } catch (er) {
24085
- return null
24086
- }
24087
- versions.forEach(function (v) {
24088
- if (rangeObj.test(v)) {
24089
- // satisfies(v, range, options)
24090
- if (!max || maxSV.compare(v) === -1) {
24091
- // compare(max, v, true)
24092
- max = v;
24093
- maxSV = new SemVer(max, options);
24094
- }
24095
- }
24096
- });
24097
- return max
24098
- }
24083
+ // Because * is AND-ed with everything else in the comparator,
24084
+ // and '' means "any version", just remove the *s entirely.
24085
+ function replaceStars(comp, options) {
24086
+ debug('replaceStars', comp, options);
24087
+ // Looseness is ignored here. star is always as loose as it gets!
24088
+ return comp.trim().replace(re[t.STAR], '');
24089
+ }
24090
+
24091
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
24092
+ // M, m, patch, prerelease, build
24093
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
24094
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
24095
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0
24096
+ function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
24097
+ if (isX(fM)) {
24098
+ from = '';
24099
+ } else if (isX(fm)) {
24100
+ from = '>=' + fM + '.0.0';
24101
+ } else if (isX(fp)) {
24102
+ from = '>=' + fM + '.' + fm + '.0';
24103
+ } else {
24104
+ from = '>=' + from;
24105
+ }
24106
+ if (isX(tM)) {
24107
+ to = '';
24108
+ } else if (isX(tm)) {
24109
+ to = '<' + (+tM + 1) + '.0.0';
24110
+ } else if (isX(tp)) {
24111
+ to = '<' + tM + '.' + (+tm + 1) + '.0';
24112
+ } else if (tpr) {
24113
+ to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
24114
+ } else {
24115
+ to = '<=' + to;
24116
+ }
24117
+ return (from + ' ' + to).trim();
24118
+ }
24099
24119
 
24100
- exports.minSatisfying = minSatisfying;
24101
- function minSatisfying (versions, range, options) {
24102
- var min = null;
24103
- var minSV = null;
24104
- try {
24105
- var rangeObj = new Range(range, options);
24106
- } catch (er) {
24107
- return null
24108
- }
24109
- versions.forEach(function (v) {
24110
- if (rangeObj.test(v)) {
24111
- // satisfies(v, range, options)
24112
- if (!min || minSV.compare(v) === 1) {
24113
- // compare(min, v, true)
24114
- min = v;
24115
- minSV = new SemVer(min, options);
24116
- }
24117
- }
24118
- });
24119
- return min
24120
- }
24120
+ // if ANY of the sets match ALL of its comparators, then pass
24121
+ Range.prototype.test = function (version) {
24122
+ if (!version) {
24123
+ return false;
24124
+ }
24125
+ if (typeof version === 'string') {
24126
+ try {
24127
+ version = new SemVer(version, this.options);
24128
+ } catch (er) {
24129
+ return false;
24130
+ }
24131
+ }
24132
+ for (var i = 0; i < this.set.length; i++) {
24133
+ if (testSet(this.set[i], version, this.options)) {
24134
+ return true;
24135
+ }
24136
+ }
24137
+ return false;
24138
+ };
24139
+ function testSet(set, version, options) {
24140
+ for (var i = 0; i < set.length; i++) {
24141
+ if (!set[i].test(version)) {
24142
+ return false;
24143
+ }
24144
+ }
24145
+ if (version.prerelease.length && !options.includePrerelease) {
24146
+ // Find the set of versions that are allowed to have prereleases
24147
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
24148
+ // That should allow `1.2.3-pr.2` to pass.
24149
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
24150
+ // even though it's within the range set by the comparators.
24151
+ for (i = 0; i < set.length; i++) {
24152
+ debug(set[i].semver);
24153
+ if (set[i].semver === ANY) {
24154
+ continue;
24155
+ }
24156
+ if (set[i].semver.prerelease.length > 0) {
24157
+ var allowed = set[i].semver;
24158
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
24159
+ return true;
24160
+ }
24161
+ }
24162
+ }
24121
24163
 
24122
- exports.minVersion = minVersion;
24123
- function minVersion (range, loose) {
24124
- range = new Range(range, loose);
24125
-
24126
- var minver = new SemVer('0.0.0');
24127
- if (range.test(minver)) {
24128
- return minver
24129
- }
24130
-
24131
- minver = new SemVer('0.0.0-0');
24132
- if (range.test(minver)) {
24133
- return minver
24134
- }
24135
-
24136
- minver = null;
24137
- for (var i = 0; i < range.set.length; ++i) {
24138
- var comparators = range.set[i];
24139
-
24140
- comparators.forEach(function (comparator) {
24141
- // Clone to avoid manipulating the comparator's semver object.
24142
- var compver = new SemVer(comparator.semver.version);
24143
- switch (comparator.operator) {
24144
- case '>':
24145
- if (compver.prerelease.length === 0) {
24146
- compver.patch++;
24147
- } else {
24148
- compver.prerelease.push(0);
24149
- }
24150
- compver.raw = compver.format();
24151
- /* fallthrough */
24152
- case '':
24153
- case '>=':
24154
- if (!minver || gt(minver, compver)) {
24155
- minver = compver;
24156
- }
24157
- break
24158
- case '<':
24159
- case '<=':
24160
- /* Ignore maximum versions */
24161
- break
24162
- /* istanbul ignore next */
24163
- default:
24164
- throw new Error('Unexpected operation: ' + comparator.operator)
24165
- }
24166
- });
24167
- }
24168
-
24169
- if (minver && range.test(minver)) {
24170
- return minver
24171
- }
24172
-
24173
- return null
24174
- }
24164
+ // Version has a -pre, but it's not one of the ones we like.
24165
+ return false;
24166
+ }
24167
+ return true;
24168
+ }
24169
+ exports.satisfies = satisfies;
24170
+ function satisfies(version, range, options) {
24171
+ try {
24172
+ range = new Range(range, options);
24173
+ } catch (er) {
24174
+ return false;
24175
+ }
24176
+ return range.test(version);
24177
+ }
24178
+ exports.maxSatisfying = maxSatisfying;
24179
+ function maxSatisfying(versions, range, options) {
24180
+ var max = null;
24181
+ var maxSV = null;
24182
+ try {
24183
+ var rangeObj = new Range(range, options);
24184
+ } catch (er) {
24185
+ return null;
24186
+ }
24187
+ versions.forEach(function (v) {
24188
+ if (rangeObj.test(v)) {
24189
+ // satisfies(v, range, options)
24190
+ if (!max || maxSV.compare(v) === -1) {
24191
+ // compare(max, v, true)
24192
+ max = v;
24193
+ maxSV = new SemVer(max, options);
24194
+ }
24195
+ }
24196
+ });
24197
+ return max;
24198
+ }
24199
+ exports.minSatisfying = minSatisfying;
24200
+ function minSatisfying(versions, range, options) {
24201
+ var min = null;
24202
+ var minSV = null;
24203
+ try {
24204
+ var rangeObj = new Range(range, options);
24205
+ } catch (er) {
24206
+ return null;
24207
+ }
24208
+ versions.forEach(function (v) {
24209
+ if (rangeObj.test(v)) {
24210
+ // satisfies(v, range, options)
24211
+ if (!min || minSV.compare(v) === 1) {
24212
+ // compare(min, v, true)
24213
+ min = v;
24214
+ minSV = new SemVer(min, options);
24215
+ }
24216
+ }
24217
+ });
24218
+ return min;
24219
+ }
24220
+ exports.minVersion = minVersion;
24221
+ function minVersion(range, loose) {
24222
+ range = new Range(range, loose);
24223
+ var minver = new SemVer('0.0.0');
24224
+ if (range.test(minver)) {
24225
+ return minver;
24226
+ }
24227
+ minver = new SemVer('0.0.0-0');
24228
+ if (range.test(minver)) {
24229
+ return minver;
24230
+ }
24231
+ minver = null;
24232
+ for (var i = 0; i < range.set.length; ++i) {
24233
+ var comparators = range.set[i];
24234
+ comparators.forEach(function (comparator) {
24235
+ // Clone to avoid manipulating the comparator's semver object.
24236
+ var compver = new SemVer(comparator.semver.version);
24237
+ switch (comparator.operator) {
24238
+ case '>':
24239
+ if (compver.prerelease.length === 0) {
24240
+ compver.patch++;
24241
+ } else {
24242
+ compver.prerelease.push(0);
24243
+ }
24244
+ compver.raw = compver.format();
24245
+ /* fallthrough */
24246
+ case '':
24247
+ case '>=':
24248
+ if (!minver || gt(minver, compver)) {
24249
+ minver = compver;
24250
+ }
24251
+ break;
24252
+ case '<':
24253
+ case '<=':
24254
+ /* Ignore maximum versions */
24255
+ break;
24256
+ /* istanbul ignore next */
24257
+ default:
24258
+ throw new Error('Unexpected operation: ' + comparator.operator);
24259
+ }
24260
+ });
24261
+ }
24262
+ if (minver && range.test(minver)) {
24263
+ return minver;
24264
+ }
24265
+ return null;
24266
+ }
24267
+ exports.validRange = validRange;
24268
+ function validRange(range, options) {
24269
+ try {
24270
+ // Return '*' instead of '' so that truthiness works.
24271
+ // This will throw if it's invalid anyway
24272
+ return new Range(range, options).range || '*';
24273
+ } catch (er) {
24274
+ return null;
24275
+ }
24276
+ }
24175
24277
 
24176
- exports.validRange = validRange;
24177
- function validRange (range, options) {
24178
- try {
24179
- // Return '*' instead of '' so that truthiness works.
24180
- // This will throw if it's invalid anyway
24181
- return new Range(range, options).range || '*'
24182
- } catch (er) {
24183
- return null
24184
- }
24185
- }
24278
+ // Determine if version is less than all the versions possible in the range
24279
+ exports.ltr = ltr;
24280
+ function ltr(version, range, options) {
24281
+ return outside(version, range, '<', options);
24282
+ }
24186
24283
 
24187
- // Determine if version is less than all the versions possible in the range
24188
- exports.ltr = ltr;
24189
- function ltr (version, range, options) {
24190
- return outside(version, range, '<', options)
24191
- }
24284
+ // Determine if version is greater than all the versions possible in the range.
24285
+ exports.gtr = gtr;
24286
+ function gtr(version, range, options) {
24287
+ return outside(version, range, '>', options);
24288
+ }
24289
+ exports.outside = outside;
24290
+ function outside(version, range, hilo, options) {
24291
+ version = new SemVer(version, options);
24292
+ range = new Range(range, options);
24293
+ var gtfn, ltefn, ltfn, comp, ecomp;
24294
+ switch (hilo) {
24295
+ case '>':
24296
+ gtfn = gt;
24297
+ ltefn = lte;
24298
+ ltfn = lt;
24299
+ comp = '>';
24300
+ ecomp = '>=';
24301
+ break;
24302
+ case '<':
24303
+ gtfn = lt;
24304
+ ltefn = gte;
24305
+ ltfn = gt;
24306
+ comp = '<';
24307
+ ecomp = '<=';
24308
+ break;
24309
+ default:
24310
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
24311
+ }
24192
24312
 
24193
- // Determine if version is greater than all the versions possible in the range.
24194
- exports.gtr = gtr;
24195
- function gtr (version, range, options) {
24196
- return outside(version, range, '>', options)
24197
- }
24313
+ // If it satisifes the range it is not outside
24314
+ if (satisfies(version, range, options)) {
24315
+ return false;
24316
+ }
24198
24317
 
24199
- exports.outside = outside;
24200
- function outside (version, range, hilo, options) {
24201
- version = new SemVer(version, options);
24202
- range = new Range(range, options);
24203
-
24204
- var gtfn, ltefn, ltfn, comp, ecomp;
24205
- switch (hilo) {
24206
- case '>':
24207
- gtfn = gt;
24208
- ltefn = lte;
24209
- ltfn = lt;
24210
- comp = '>';
24211
- ecomp = '>=';
24212
- break
24213
- case '<':
24214
- gtfn = lt;
24215
- ltefn = gte;
24216
- ltfn = gt;
24217
- comp = '<';
24218
- ecomp = '<=';
24219
- break
24220
- default:
24221
- throw new TypeError('Must provide a hilo val of "<" or ">"')
24222
- }
24223
-
24224
- // If it satisifes the range it is not outside
24225
- if (satisfies(version, range, options)) {
24226
- return false
24227
- }
24228
-
24229
- // From now on, variable terms are as if we're in "gtr" mode.
24230
- // but note that everything is flipped for the "ltr" function.
24231
-
24232
- for (var i = 0; i < range.set.length; ++i) {
24233
- var comparators = range.set[i];
24234
-
24235
- var high = null;
24236
- var low = null;
24237
-
24238
- comparators.forEach(function (comparator) {
24239
- if (comparator.semver === ANY) {
24240
- comparator = new Comparator('>=0.0.0');
24241
- }
24242
- high = high || comparator;
24243
- low = low || comparator;
24244
- if (gtfn(comparator.semver, high.semver, options)) {
24245
- high = comparator;
24246
- } else if (ltfn(comparator.semver, low.semver, options)) {
24247
- low = comparator;
24248
- }
24249
- });
24250
-
24251
- // If the edge version comparator has a operator then our version
24252
- // isn't outside it
24253
- if (high.operator === comp || high.operator === ecomp) {
24254
- return false
24255
- }
24256
-
24257
- // If the lowest version comparator has an operator and our version
24258
- // is less than it then it isn't higher than the range
24259
- if ((!low.operator || low.operator === comp) &&
24260
- ltefn(version, low.semver)) {
24261
- return false
24262
- } else if (low.operator === ecomp && ltfn(version, low.semver)) {
24263
- return false
24264
- }
24265
- }
24266
- return true
24267
- }
24318
+ // From now on, variable terms are as if we're in "gtr" mode.
24319
+ // but note that everything is flipped for the "ltr" function.
24268
24320
 
24269
- exports.prerelease = prerelease;
24270
- function prerelease (version, options) {
24271
- var parsed = parse(version, options);
24272
- return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
24273
- }
24321
+ for (var i = 0; i < range.set.length; ++i) {
24322
+ var comparators = range.set[i];
24323
+ var high = null;
24324
+ var low = null;
24325
+ comparators.forEach(function (comparator) {
24326
+ if (comparator.semver === ANY) {
24327
+ comparator = new Comparator('>=0.0.0');
24328
+ }
24329
+ high = high || comparator;
24330
+ low = low || comparator;
24331
+ if (gtfn(comparator.semver, high.semver, options)) {
24332
+ high = comparator;
24333
+ } else if (ltfn(comparator.semver, low.semver, options)) {
24334
+ low = comparator;
24335
+ }
24336
+ });
24274
24337
 
24275
- exports.intersects = intersects;
24276
- function intersects (r1, r2, options) {
24277
- r1 = new Range(r1, options);
24278
- r2 = new Range(r2, options);
24279
- return r1.intersects(r2)
24280
- }
24338
+ // If the edge version comparator has a operator then our version
24339
+ // isn't outside it
24340
+ if (high.operator === comp || high.operator === ecomp) {
24341
+ return false;
24342
+ }
24281
24343
 
24282
- exports.coerce = coerce;
24283
- function coerce (version, options) {
24284
- if (version instanceof SemVer) {
24285
- return version
24286
- }
24287
-
24288
- if (typeof version === 'number') {
24289
- version = String(version);
24290
- }
24291
-
24292
- if (typeof version !== 'string') {
24293
- return null
24294
- }
24295
-
24296
- options = options || {};
24297
-
24298
- var match = null;
24299
- if (!options.rtl) {
24300
- match = version.match(re[t.COERCE]);
24301
- } else {
24302
- // Find the right-most coercible string that does not share
24303
- // a terminus with a more left-ward coercible string.
24304
- // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
24305
- //
24306
- // Walk through the string checking with a /g regexp
24307
- // Manually set the index so as to pick up overlapping matches.
24308
- // Stop when we get a match that ends at the string end, since no
24309
- // coercible string can be more right-ward without the same terminus.
24310
- var next;
24311
- while ((next = re[t.COERCERTL].exec(version)) &&
24312
- (!match || match.index + match[0].length !== version.length)
24313
- ) {
24314
- if (!match ||
24315
- next.index + next[0].length !== match.index + match[0].length) {
24316
- match = next;
24317
- }
24318
- re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
24319
- }
24320
- // leave it in a clean state
24321
- re[t.COERCERTL].lastIndex = -1;
24322
- }
24323
-
24324
- if (match === null) {
24325
- return null
24326
- }
24327
-
24328
- return parse(match[2] +
24329
- '.' + (match[3] || '0') +
24330
- '.' + (match[4] || '0'), options)
24331
- }
24332
- } (semver, semverExports));
24344
+ // If the lowest version comparator has an operator and our version
24345
+ // is less than it then it isn't higher than the range
24346
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
24347
+ return false;
24348
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
24349
+ return false;
24350
+ }
24351
+ }
24352
+ return true;
24353
+ }
24354
+ exports.prerelease = prerelease;
24355
+ function prerelease(version, options) {
24356
+ var parsed = parse(version, options);
24357
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
24358
+ }
24359
+ exports.intersects = intersects;
24360
+ function intersects(r1, r2, options) {
24361
+ r1 = new Range(r1, options);
24362
+ r2 = new Range(r2, options);
24363
+ return r1.intersects(r2);
24364
+ }
24365
+ exports.coerce = coerce;
24366
+ function coerce(version, options) {
24367
+ if (version instanceof SemVer) {
24368
+ return version;
24369
+ }
24370
+ if (typeof version === 'number') {
24371
+ version = String(version);
24372
+ }
24373
+ if (typeof version !== 'string') {
24374
+ return null;
24375
+ }
24376
+ options = options || {};
24377
+ var match = null;
24378
+ if (!options.rtl) {
24379
+ match = version.match(re[t.COERCE]);
24380
+ } else {
24381
+ // Find the right-most coercible string that does not share
24382
+ // a terminus with a more left-ward coercible string.
24383
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
24384
+ //
24385
+ // Walk through the string checking with a /g regexp
24386
+ // Manually set the index so as to pick up overlapping matches.
24387
+ // Stop when we get a match that ends at the string end, since no
24388
+ // coercible string can be more right-ward without the same terminus.
24389
+ var next;
24390
+ while ((next = re[t.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) {
24391
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
24392
+ match = next;
24393
+ }
24394
+ re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
24395
+ }
24396
+ // leave it in a clean state
24397
+ re[t.COERCERTL].lastIndex = -1;
24398
+ }
24399
+ if (match === null) {
24400
+ return null;
24401
+ }
24402
+ return parse(match[2] + '.' + (match[3] || '0') + '.' + (match[4] || '0'), options);
24403
+ }
24404
+ })(semver, semverExports);
24333
24405
 
24334
24406
  const LOADED = {};
24335
24407
 
@@ -24753,8 +24825,9 @@ function nuked() {
24753
24825
  const api = /** @lends Embed# */{
24754
24826
  /**
24755
24827
  * Renders a visualization or sheet into an HTMLElement.
24828
+ * Visualizations can either be existing objects or created on the fly.
24756
24829
  * Support for sense sheets is experimental.
24757
- * @param {CreateConfig | GetConfig} cfg - The render configuration.
24830
+ * @param {RenderConfig} cfg The render configuration.
24758
24831
  * @returns {Promise<Viz|Sheet>} A controller to the rendered visualization or sheet.
24759
24832
  * @example
24760
24833
  * // render from existing object
@@ -24777,6 +24850,37 @@ function nuked() {
24777
24850
  }
24778
24851
  return createSessionObject(cfg, halo);
24779
24852
  },
24853
+ /**
24854
+ * Creates a visualization model
24855
+ * @param {CreateConfig} cfg The create configuration.
24856
+ * @experimental
24857
+ * @returns {Promise<EngineAPI.IGenericObject>} An engima model
24858
+ * @example
24859
+ * // create a barchart in the app and return the model
24860
+ * const model = await n.create({
24861
+ * type: 'barchart',
24862
+ * fields: ['Product', { qLibraryId: 'u378hn', type: 'measure' }],
24863
+ * properties: { showTitle: true }
24864
+ * }
24865
+ * );
24866
+ */
24867
+ create: async cfg => createObject(cfg, halo, false),
24868
+ /**
24869
+ * Generates properties for a visualization object
24870
+ * @param {CreateConfig} cfg The create configuration.
24871
+ * @experimental
24872
+ * @returns {Promise<object>} The objects properties
24873
+ * @example
24874
+ * // generate properties for a barchart
24875
+ * const properties = await n.create({
24876
+ * type: 'barchart',
24877
+ * fields: ['Product', { qLibraryId: 'u378hn', type: 'measure' }],
24878
+ * properties: { showTitle: true }
24879
+ * },
24880
+ * true
24881
+ * );
24882
+ */
24883
+ generateProperties: async cfg => createObject(cfg, halo, true),
24780
24884
  /**
24781
24885
  * Updates the current context of this embed instance.
24782
24886
  * Use this when you want to change some part of the current context, like theme.