built-in-definitions.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.StaticProperties = exports.InstanceProperties = exports.BuiltIns = exports.CommonIterators = void 0;
  4. var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
  5. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6. const define = (name, pure, global = [], meta) => {
  7. return {
  8. name,
  9. pure,
  10. global,
  11. meta
  12. };
  13. };
  14. const pureAndGlobal = (pure, global, minRuntimeVersion = null) => define(global[0], pure, global, {
  15. minRuntimeVersion
  16. });
  17. const globalOnly = global => define(global[0], null, global);
  18. const pureOnly = (pure, name) => define(name, pure, []);
  19. const ArrayNatureIterators = ["es6.object.to-string", "es6.array.iterator", "web.dom.iterable"];
  20. const CommonIterators = ["es6.string.iterator", ...ArrayNatureIterators];
  21. exports.CommonIterators = CommonIterators;
  22. const PromiseDependencies = ["es6.object.to-string", "es6.promise"];
  23. const BuiltIns = {
  24. DataView: globalOnly(["es6.typed.data-view"]),
  25. Float32Array: globalOnly(["es6.typed.float32-array"]),
  26. Float64Array: globalOnly(["es6.typed.float64-array"]),
  27. Int8Array: globalOnly(["es6.typed.int8-array"]),
  28. Int16Array: globalOnly(["es6.typed.int16-array"]),
  29. Int32Array: globalOnly(["es6.typed.int32-array"]),
  30. Map: pureAndGlobal("map", ["es6.map", ...CommonIterators]),
  31. Number: globalOnly(["es6.number.constructor"]),
  32. Promise: pureAndGlobal("promise", PromiseDependencies),
  33. RegExp: globalOnly(["es6.regexp.constructor"]),
  34. Set: pureAndGlobal("set", ["es6.set", ...CommonIterators]),
  35. Symbol: pureAndGlobal("symbol", ["es6.symbol"]),
  36. Uint8Array: globalOnly(["es6.typed.uint8-array"]),
  37. Uint8ClampedArray: globalOnly(["es6.typed.uint8-clamped-array"]),
  38. Uint16Array: globalOnly(["es6.typed.uint16-array"]),
  39. Uint32Array: globalOnly(["es6.typed.uint32-array"]),
  40. WeakMap: pureAndGlobal("weak-map", ["es6.weak-map", ...CommonIterators]),
  41. WeakSet: pureAndGlobal("weak-set", ["es6.weak-set", ...CommonIterators]),
  42. setImmediate: pureOnly("set-immediate", "web.immediate"),
  43. clearImmediate: pureOnly("clear-immediate", "web.immediate"),
  44. parseFloat: pureOnly("parse-float", "es6.parse-float"),
  45. parseInt: pureOnly("parse-int", "es6.parse-int")
  46. };
  47. exports.BuiltIns = BuiltIns;
  48. const InstanceProperties = {
  49. __defineGetter__: globalOnly(["es7.object.define-getter"]),
  50. __defineSetter__: globalOnly(["es7.object.define-setter"]),
  51. __lookupGetter__: globalOnly(["es7.object.lookup-getter"]),
  52. __lookupSetter__: globalOnly(["es7.object.lookup-setter"]),
  53. anchor: globalOnly(["es6.string.anchor"]),
  54. big: globalOnly(["es6.string.big"]),
  55. bind: globalOnly(["es6.function.bind"]),
  56. blink: globalOnly(["es6.string.blink"]),
  57. bold: globalOnly(["es6.string.bold"]),
  58. codePointAt: globalOnly(["es6.string.code-point-at"]),
  59. copyWithin: globalOnly(["es6.array.copy-within"]),
  60. endsWith: globalOnly(["es6.string.ends-with"]),
  61. entries: globalOnly(ArrayNatureIterators),
  62. every: globalOnly(["es6.array.every"]),
  63. fill: globalOnly(["es6.array.fill"]),
  64. filter: globalOnly(["es6.array.filter"]),
  65. finally: globalOnly(["es7.promise.finally", ...PromiseDependencies]),
  66. find: globalOnly(["es6.array.find"]),
  67. findIndex: globalOnly(["es6.array.find-index"]),
  68. fixed: globalOnly(["es6.string.fixed"]),
  69. flags: globalOnly(["es6.regexp.flags"]),
  70. flatMap: globalOnly(["es7.array.flat-map"]),
  71. fontcolor: globalOnly(["es6.string.fontcolor"]),
  72. fontsize: globalOnly(["es6.string.fontsize"]),
  73. forEach: globalOnly(["es6.array.for-each"]),
  74. includes: globalOnly(["es6.string.includes", "es7.array.includes"]),
  75. indexOf: globalOnly(["es6.array.index-of"]),
  76. italics: globalOnly(["es6.string.italics"]),
  77. keys: globalOnly(ArrayNatureIterators),
  78. lastIndexOf: globalOnly(["es6.array.last-index-of"]),
  79. link: globalOnly(["es6.string.link"]),
  80. map: globalOnly(["es6.array.map"]),
  81. match: globalOnly(["es6.regexp.match"]),
  82. name: globalOnly(["es6.function.name"]),
  83. padStart: globalOnly(["es7.string.pad-start"]),
  84. padEnd: globalOnly(["es7.string.pad-end"]),
  85. reduce: globalOnly(["es6.array.reduce"]),
  86. reduceRight: globalOnly(["es6.array.reduce-right"]),
  87. repeat: globalOnly(["es6.string.repeat"]),
  88. replace: globalOnly(["es6.regexp.replace"]),
  89. search: globalOnly(["es6.regexp.search"]),
  90. small: globalOnly(["es6.string.small"]),
  91. some: globalOnly(["es6.array.some"]),
  92. sort: globalOnly(["es6.array.sort"]),
  93. split: globalOnly(["es6.regexp.split"]),
  94. startsWith: globalOnly(["es6.string.starts-with"]),
  95. strike: globalOnly(["es6.string.strike"]),
  96. sub: globalOnly(["es6.string.sub"]),
  97. sup: globalOnly(["es6.string.sup"]),
  98. toISOString: globalOnly(["es6.date.to-iso-string"]),
  99. toJSON: globalOnly(["es6.date.to-json"]),
  100. toString: globalOnly(["es6.object.to-string", "es6.date.to-string", "es6.regexp.to-string"]),
  101. trim: globalOnly(["es6.string.trim"]),
  102. trimEnd: globalOnly(["es7.string.trim-right"]),
  103. trimLeft: globalOnly(["es7.string.trim-left"]),
  104. trimRight: globalOnly(["es7.string.trim-right"]),
  105. trimStart: globalOnly(["es7.string.trim-left"]),
  106. values: globalOnly(ArrayNatureIterators)
  107. }; // This isn't present in older @babel/compat-data versions
  108. exports.InstanceProperties = InstanceProperties;
  109. if ("es6.array.slice" in _corejs2BuiltIns.default) {
  110. InstanceProperties.slice = globalOnly(["es6.array.slice"]);
  111. }
  112. const StaticProperties = {
  113. Array: {
  114. from: pureAndGlobal("array/from", ["es6.symbol", "es6.array.from", ...CommonIterators]),
  115. isArray: pureAndGlobal("array/is-array", ["es6.array.is-array"]),
  116. of: pureAndGlobal("array/of", ["es6.array.of"])
  117. },
  118. Date: {
  119. now: pureAndGlobal("date/now", ["es6.date.now"])
  120. },
  121. JSON: {
  122. stringify: pureOnly("json/stringify", "es6.symbol")
  123. },
  124. Math: {
  125. // 'Math' was not included in the 7.0.0
  126. // release of '@babel/runtime'. See issue https://github.com/babel/babel/pull/8616.
  127. acosh: pureAndGlobal("math/acosh", ["es6.math.acosh"], "7.0.1"),
  128. asinh: pureAndGlobal("math/asinh", ["es6.math.asinh"], "7.0.1"),
  129. atanh: pureAndGlobal("math/atanh", ["es6.math.atanh"], "7.0.1"),
  130. cbrt: pureAndGlobal("math/cbrt", ["es6.math.cbrt"], "7.0.1"),
  131. clz32: pureAndGlobal("math/clz32", ["es6.math.clz32"], "7.0.1"),
  132. cosh: pureAndGlobal("math/cosh", ["es6.math.cosh"], "7.0.1"),
  133. expm1: pureAndGlobal("math/expm1", ["es6.math.expm1"], "7.0.1"),
  134. fround: pureAndGlobal("math/fround", ["es6.math.fround"], "7.0.1"),
  135. hypot: pureAndGlobal("math/hypot", ["es6.math.hypot"], "7.0.1"),
  136. imul: pureAndGlobal("math/imul", ["es6.math.imul"], "7.0.1"),
  137. log1p: pureAndGlobal("math/log1p", ["es6.math.log1p"], "7.0.1"),
  138. log10: pureAndGlobal("math/log10", ["es6.math.log10"], "7.0.1"),
  139. log2: pureAndGlobal("math/log2", ["es6.math.log2"], "7.0.1"),
  140. sign: pureAndGlobal("math/sign", ["es6.math.sign"], "7.0.1"),
  141. sinh: pureAndGlobal("math/sinh", ["es6.math.sinh"], "7.0.1"),
  142. tanh: pureAndGlobal("math/tanh", ["es6.math.tanh"], "7.0.1"),
  143. trunc: pureAndGlobal("math/trunc", ["es6.math.trunc"], "7.0.1")
  144. },
  145. Number: {
  146. EPSILON: pureAndGlobal("number/epsilon", ["es6.number.epsilon"]),
  147. MIN_SAFE_INTEGER: pureAndGlobal("number/min-safe-integer", ["es6.number.min-safe-integer"]),
  148. MAX_SAFE_INTEGER: pureAndGlobal("number/max-safe-integer", ["es6.number.max-safe-integer"]),
  149. isFinite: pureAndGlobal("number/is-finite", ["es6.number.is-finite"]),
  150. isInteger: pureAndGlobal("number/is-integer", ["es6.number.is-integer"]),
  151. isSafeInteger: pureAndGlobal("number/is-safe-integer", ["es6.number.is-safe-integer"]),
  152. isNaN: pureAndGlobal("number/is-nan", ["es6.number.is-nan"]),
  153. parseFloat: pureAndGlobal("number/parse-float", ["es6.number.parse-float"]),
  154. parseInt: pureAndGlobal("number/parse-int", ["es6.number.parse-int"])
  155. },
  156. Object: {
  157. assign: pureAndGlobal("object/assign", ["es6.object.assign"]),
  158. create: pureAndGlobal("object/create", ["es6.object.create"]),
  159. defineProperties: pureAndGlobal("object/define-properties", ["es6.object.define-properties"]),
  160. defineProperty: pureAndGlobal("object/define-property", ["es6.object.define-property"]),
  161. entries: pureAndGlobal("object/entries", ["es7.object.entries"]),
  162. freeze: pureAndGlobal("object/freeze", ["es6.object.freeze"]),
  163. getOwnPropertyDescriptor: pureAndGlobal("object/get-own-property-descriptor", ["es6.object.get-own-property-descriptor"]),
  164. getOwnPropertyDescriptors: pureAndGlobal("object/get-own-property-descriptors", ["es7.object.get-own-property-descriptors"]),
  165. getOwnPropertyNames: pureAndGlobal("object/get-own-property-names", ["es6.object.get-own-property-names"]),
  166. getOwnPropertySymbols: pureAndGlobal("object/get-own-property-symbols", ["es6.symbol"]),
  167. getPrototypeOf: pureAndGlobal("object/get-prototype-of", ["es6.object.get-prototype-of"]),
  168. is: pureAndGlobal("object/is", ["es6.object.is"]),
  169. isExtensible: pureAndGlobal("object/is-extensible", ["es6.object.is-extensible"]),
  170. isFrozen: pureAndGlobal("object/is-frozen", ["es6.object.is-frozen"]),
  171. isSealed: pureAndGlobal("object/is-sealed", ["es6.object.is-sealed"]),
  172. keys: pureAndGlobal("object/keys", ["es6.object.keys"]),
  173. preventExtensions: pureAndGlobal("object/prevent-extensions", ["es6.object.prevent-extensions"]),
  174. seal: pureAndGlobal("object/seal", ["es6.object.seal"]),
  175. setPrototypeOf: pureAndGlobal("object/set-prototype-of", ["es6.object.set-prototype-of"]),
  176. values: pureAndGlobal("object/values", ["es7.object.values"])
  177. },
  178. Promise: {
  179. all: globalOnly(CommonIterators),
  180. race: globalOnly(CommonIterators)
  181. },
  182. Reflect: {
  183. apply: pureAndGlobal("reflect/apply", ["es6.reflect.apply"]),
  184. construct: pureAndGlobal("reflect/construct", ["es6.reflect.construct"]),
  185. defineProperty: pureAndGlobal("reflect/define-property", ["es6.reflect.define-property"]),
  186. deleteProperty: pureAndGlobal("reflect/delete-property", ["es6.reflect.delete-property"]),
  187. get: pureAndGlobal("reflect/get", ["es6.reflect.get"]),
  188. getOwnPropertyDescriptor: pureAndGlobal("reflect/get-own-property-descriptor", ["es6.reflect.get-own-property-descriptor"]),
  189. getPrototypeOf: pureAndGlobal("reflect/get-prototype-of", ["es6.reflect.get-prototype-of"]),
  190. has: pureAndGlobal("reflect/has", ["es6.reflect.has"]),
  191. isExtensible: pureAndGlobal("reflect/is-extensible", ["es6.reflect.is-extensible"]),
  192. ownKeys: pureAndGlobal("reflect/own-keys", ["es6.reflect.own-keys"]),
  193. preventExtensions: pureAndGlobal("reflect/prevent-extensions", ["es6.reflect.prevent-extensions"]),
  194. set: pureAndGlobal("reflect/set", ["es6.reflect.set"]),
  195. setPrototypeOf: pureAndGlobal("reflect/set-prototype-of", ["es6.reflect.set-prototype-of"])
  196. },
  197. String: {
  198. at: pureOnly("string/at", "es7.string.at"),
  199. fromCodePoint: pureAndGlobal("string/from-code-point", ["es6.string.from-code-point"]),
  200. raw: pureAndGlobal("string/raw", ["es6.string.raw"])
  201. },
  202. Symbol: {
  203. // FIXME: Pure disabled to work around zloirock/core-js#262.
  204. asyncIterator: globalOnly(["es6.symbol", "es7.symbol.async-iterator"]),
  205. for: pureOnly("symbol/for", "es6.symbol"),
  206. hasInstance: pureOnly("symbol/has-instance", "es6.symbol"),
  207. isConcatSpreadable: pureOnly("symbol/is-concat-spreadable", "es6.symbol"),
  208. iterator: define("es6.symbol", "symbol/iterator", CommonIterators),
  209. keyFor: pureOnly("symbol/key-for", "es6.symbol"),
  210. match: pureAndGlobal("symbol/match", ["es6.regexp.match"]),
  211. replace: pureOnly("symbol/replace", "es6.symbol"),
  212. search: pureOnly("symbol/search", "es6.symbol"),
  213. species: pureOnly("symbol/species", "es6.symbol"),
  214. split: pureOnly("symbol/split", "es6.symbol"),
  215. toPrimitive: pureOnly("symbol/to-primitive", "es6.symbol"),
  216. toStringTag: pureOnly("symbol/to-string-tag", "es6.symbol"),
  217. unscopables: pureOnly("symbol/unscopables", "es6.symbol")
  218. }
  219. };
  220. exports.StaticProperties = StaticProperties;