You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.7 KiB

4 years ago
  1. # Electron-to-Chromium [![npm](https://img.shields.io/npm/v/electron-to-chromium.svg)](https://www.npmjs.com/package/electron-to-chromium) [![travis](https://img.shields.io/travis/Kilian/electron-to-chromium/master.svg)](https://travis-ci.org/Kilian/electron-to-chromium) [![npm-downloads](https://img.shields.io/npm/dm/electron-to-chromium.svg)](https://www.npmjs.com/package/electron-to-chromium) [![codecov](https://codecov.io/gh/Kilian/electron-to-chromium/branch/master/graph/badge.svg)](https://codecov.io/gh/Kilian/electron-to-chromium)
  2. [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FKilian%2Felectron-to-chromium.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FKilian%2Felectron-to-chromium?ref=badge_shield)
  3. This repository provides a mapping of Electron versions to the Chromium version that it uses.
  4. This package is used in [Browserslist](https://github.com/ai/browserslist), so you can use e.g. `electron >= 1.4` in [Autoprefixer](https://github.com/postcss/autoprefixer), [Stylelint](https://github.com/stylelint/stylelint), [babel-preset-env](https://github.com/babel/babel-preset-env) and [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat).
  5. ## Install
  6. Install using `npm install electron-to-chromium`.
  7. ## Usage
  8. To include Electron-to-Chromium, require it:
  9. ```js
  10. var e2c = require('electron-to-chromium');
  11. ```
  12. ### Properties
  13. The Electron-to-Chromium object has 4 properties to use:
  14. #### `versions`
  15. An object of key-value pairs with a _major_ Electron version as the key, and the corresponding major Chromium version as the value.
  16. ```js
  17. var versions = e2c.versions;
  18. console.log(versions['1.4']);
  19. // returns "53"
  20. ```
  21. #### `fullVersions`
  22. An object of key-value pairs with a Electron version as the key, and the corresponding full Chromium version as the value.
  23. ```js
  24. var versions = e2c.fullVersions;
  25. console.log(versions['1.4.11']);
  26. // returns "53.0.2785.143"
  27. ```
  28. #### `chromiumVersions`
  29. An object of key-value pairs with a _major_ Chromium version as the key, and the corresponding major Electron version as the value.
  30. ```js
  31. var versions = e2c.chromiumVersions;
  32. console.log(versions['54']);
  33. // returns "1.4"
  34. ```
  35. #### `fullChromiumVersions`
  36. An object of key-value pairs with a Chromium version as the key, and an array of the corresponding major Electron versions as the value.
  37. ```js
  38. var versions = e2c.fullChromiumVersions;
  39. console.log(versions['54.0.2840.101']);
  40. // returns ["1.5.1", "1.5.0"]
  41. ```
  42. ### Functions
  43. #### `electronToChromium(query)`
  44. Arguments:
  45. * Query: string or number, required. A major or full Electron version.
  46. A function that returns the corresponding Chromium version for a given Electron function. Returns a string.
  47. If you provide it with a major Electron version, it will return a major Chromium version:
  48. ```js
  49. var chromeVersion = e2c.electronToChromium('1.4');
  50. // chromeVersion is "53"
  51. ```
  52. If you provide it with a full Electron version, it will return the full Chromium version.
  53. ```js
  54. var chromeVersion = e2c.electronToChromium('1.4.11');
  55. // chromeVersion is "53.0.2785.143"
  56. ```
  57. If a query does not match a Chromium version, it will return `undefined`.
  58. ```js
  59. var chromeVersion = e2c.electronToChromium('9000');
  60. // chromeVersion is undefined
  61. ```
  62. #### `chromiumToElectron(query)`
  63. Arguments:
  64. * Query: string or number, required. A major or full Chromium version.
  65. Returns a string with the corresponding Electron version for a given Chromium query.
  66. If you provide it with a major Chromium version, it will return a major Electron version:
  67. ```js
  68. var electronVersion = e2c.chromiumToElectron('54');
  69. // electronVersion is "1.4"
  70. ```
  71. If you provide it with a full Chrome version, it will return an array of full Electron versions.
  72. ```js
  73. var electronVersions = e2c.chromiumToElectron('56.0.2924.87');
  74. // electronVersions is ["1.6.3", "1.6.2", "1.6.1", "1.6.0"]
  75. ```
  76. If a query does not match an Electron version, it will return `undefined`.
  77. ```js
  78. var electronVersion = e2c.chromiumToElectron('10');
  79. // chromeVersion is undefined
  80. ```
  81. #### `electronToBrowserList(query)` **DEPRECATED**
  82. Arguments:
  83. * Query: string or number, required. A major Electron version.
  84. _**Deprecated**: Browserlist already includes electron-to-chromium._
  85. A function that returns a [Browserslist](https://github.com/ai/browserslist) query that matches the given major Electron version. Returns a string.
  86. If you provide it with a major Electron version, it will return a Browserlist query string that matches the Chromium capabilities:
  87. ```js
  88. var query = e2c.electronToBrowserList('1.4');
  89. // query is "Chrome >= 53"
  90. ```
  91. If a query does not match a Chromium version, it will return `undefined`.
  92. ```js
  93. var query = e2c.electronToBrowserList('9000');
  94. // query is undefined
  95. ```
  96. ### Importing just versions, fullVersions, chromiumVersions and fullChromiumVersions
  97. All lists can be imported on their own, if file size is a concern.
  98. #### `versions`
  99. ```js
  100. var versions = require('electron-to-chromium/versions');
  101. ```
  102. #### `fullVersions`
  103. ```js
  104. var fullVersions = require('electron-to-chromium/full-versions');
  105. ```
  106. #### `chromiumVersions`
  107. ```js
  108. var chromiumVersions = require('electron-to-chromium/chromium-versions');
  109. ```
  110. #### `fullChromiumVersions`
  111. ```js
  112. var fullChromiumVersions = require('electron-to-chromium/full-chromium-versions');
  113. ```
  114. ## Updating
  115. This package will be updated with each new Electron release.
  116. To update the list, run `npm run build.js`. Requires internet access as it downloads from the canonical list of Electron versions.
  117. To verify correct behaviour, run `npm test`.
  118. ## License
  119. [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FKilian%2Felectron-to-chromium.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FKilian%2Felectron-to-chromium?ref=badge_large)