built-in-definitions.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.StaticProperties = exports.InstanceProperties = exports.CommonIterators = exports.BuiltIns = 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/index", ["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. };
  108. // This isn't present in older @babel/compat-data versions
  109. exports.InstanceProperties = InstanceProperties;
  110. if ("es6.array.slice" in _corejs2BuiltIns.default) {
  111. InstanceProperties.slice = globalOnly(["es6.array.slice"]);
  112. }
  113. const StaticProperties = {
  114. Array: {
  115. from: pureAndGlobal("array/from", ["es6.symbol", "es6.array.from", ...CommonIterators]),
  116. isArray: pureAndGlobal("array/is-array", ["es6.array.is-array"]),
  117. of: pureAndGlobal("array/of", ["es6.array.of"])
  118. },
  119. Date: {
  120. now: pureAndGlobal("date/now", ["es6.date.now"])
  121. },
  122. JSON: {
  123. stringify: pureOnly("json/stringify", "es6.symbol")
  124. },
  125. Math: {
  126. // 'Math' was not included in the 7.0.0
  127. // release of '@babel/runtime'. See issue https://github.com/babel/babel/pull/8616.
  128. acosh: pureAndGlobal("math/acosh", ["es6.math.acosh"], "7.0.1"),
  129. asinh: pureAndGlobal("math/asinh", ["es6.math.asinh"], "7.0.1"),
  130. atanh: pureAndGlobal("math/atanh", ["es6.math.atanh"], "7.0.1"),
  131. cbrt: pureAndGlobal("math/cbrt", ["es6.math.cbrt"], "7.0.1"),
  132. clz32: pureAndGlobal("math/clz32", ["es6.math.clz32"], "7.0.1"),
  133. cosh: pureAndGlobal("math/cosh", ["es6.math.cosh"], "7.0.1"),
  134. expm1: pureAndGlobal("math/expm1", ["es6.math.expm1"], "7.0.1"),
  135. fround: pureAndGlobal("math/fround", ["es6.math.fround"], "7.0.1"),
  136. hypot: pureAndGlobal("math/hypot", ["es6.math.hypot"], "7.0.1"),
  137. imul: pureAndGlobal("math/imul", ["es6.math.imul"], "7.0.1"),
  138. log1p: pureAndGlobal("math/log1p", ["es6.math.log1p"], "7.0.1"),
  139. log10: pureAndGlobal("math/log10", ["es6.math.log10"], "7.0.1"),
  140. log2: pureAndGlobal("math/log2", ["es6.math.log2"], "7.0.1"),
  141. sign: pureAndGlobal("math/sign", ["es6.math.sign"], "7.0.1"),
  142. sinh: pureAndGlobal("math/sinh", ["es6.math.sinh"], "7.0.1"),
  143. tanh: pureAndGlobal("math/tanh", ["es6.math.tanh"], "7.0.1"),
  144. trunc: pureAndGlobal("math/trunc", ["es6.math.trunc"], "7.0.1")
  145. },
  146. Number: {
  147. EPSILON: pureAndGlobal("number/epsilon", ["es6.number.epsilon"]),
  148. MIN_SAFE_INTEGER: pureAndGlobal("number/min-safe-integer", ["es6.number.min-safe-integer"]),
  149. MAX_SAFE_INTEGER: pureAndGlobal("number/max-safe-integer", ["es6.number.max-safe-integer"]),
  150. isFinite: pureAndGlobal("number/is-finite", ["es6.number.is-finite"]),
  151. isInteger: pureAndGlobal("number/is-integer", ["es6.number.is-integer"]),
  152. isSafeInteger: pureAndGlobal("number/is-safe-integer", ["es6.number.is-safe-integer"]),
  153. isNaN: pureAndGlobal("number/is-nan", ["es6.number.is-nan"]),
  154. parseFloat: pureAndGlobal("number/parse-float", ["es6.number.parse-float"]),
  155. parseInt: pureAndGlobal("number/parse-int", ["es6.number.parse-int"])
  156. },
  157. Object: {
  158. assign: pureAndGlobal("object/assign", ["es6.object.assign"]),
  159. create: pureAndGlobal("object/create", ["es6.object.create"]),
  160. defineProperties: pureAndGlobal("object/define-properties", ["es6.object.define-properties"]),
  161. defineProperty: pureAndGlobal("object/define-property", ["es6.object.define-property"]),
  162. entries: pureAndGlobal("object/entries", ["es7.object.entries"]),
  163. freeze: pureAndGlobal("object/freeze", ["es6.object.freeze"]),
  164. getOwnPropertyDescriptor: pureAndGlobal("object/get-own-property-descriptor", ["es6.object.get-own-property-descriptor"]),
  165. getOwnPropertyDescriptors: pureAndGlobal("object/get-own-property-descriptors", ["es7.object.get-own-property-descriptors"]),
  166. getOwnPropertyNames: pureAndGlobal("object/get-own-property-names", ["es6.object.get-own-property-names"]),
  167. getOwnPropertySymbols: pureAndGlobal("object/get-own-property-symbols", ["es6.symbol"]),
  168. getPrototypeOf: pureAndGlobal("object/get-prototype-of", ["es6.object.get-prototype-of"]),
  169. is: pureAndGlobal("object/is", ["es6.object.is"]),
  170. isExtensible: pureAndGlobal("object/is-extensible", ["es6.object.is-extensible"]),
  171. isFrozen: pureAndGlobal("object/is-frozen", ["es6.object.is-frozen"]),
  172. isSealed: pureAndGlobal("object/is-sealed", ["es6.object.is-sealed"]),
  173. keys: pureAndGlobal("object/keys", ["es6.object.keys"]),
  174. preventExtensions: pureAndGlobal("object/prevent-extensions", ["es6.object.prevent-extensions"]),
  175. seal: pureAndGlobal("object/seal", ["es6.object.seal"]),
  176. setPrototypeOf: pureAndGlobal("object/set-prototype-of", ["es6.object.set-prototype-of"]),
  177. values: pureAndGlobal("object/values", ["es7.object.values"])
  178. },
  179. Promise: {
  180. all: globalOnly(CommonIterators),
  181. race: globalOnly(CommonIterators)
  182. },
  183. Reflect: {
  184. apply: pureAndGlobal("reflect/apply", ["es6.reflect.apply"]),
  185. construct: pureAndGlobal("reflect/construct", ["es6.reflect.construct"]),
  186. defineProperty: pureAndGlobal("reflect/define-property", ["es6.reflect.define-property"]),
  187. deleteProperty: pureAndGlobal("reflect/delete-property", ["es6.reflect.delete-property"]),
  188. get: pureAndGlobal("reflect/get", ["es6.reflect.get"]),
  189. getOwnPropertyDescriptor: pureAndGlobal("reflect/get-own-property-descriptor", ["es6.reflect.get-own-property-descriptor"]),
  190. getPrototypeOf: pureAndGlobal("reflect/get-prototype-of", ["es6.reflect.get-prototype-of"]),
  191. has: pureAndGlobal("reflect/has", ["es6.reflect.has"]),
  192. isExtensible: pureAndGlobal("reflect/is-extensible", ["es6.reflect.is-extensible"]),
  193. ownKeys: pureAndGlobal("reflect/own-keys", ["es6.reflect.own-keys"]),
  194. preventExtensions: pureAndGlobal("reflect/prevent-extensions", ["es6.reflect.prevent-extensions"]),
  195. set: pureAndGlobal("reflect/set", ["es6.reflect.set"]),
  196. setPrototypeOf: pureAndGlobal("reflect/set-prototype-of", ["es6.reflect.set-prototype-of"])
  197. },
  198. String: {
  199. at: pureOnly("string/at", "es7.string.at"),
  200. fromCodePoint: pureAndGlobal("string/from-code-point", ["es6.string.from-code-point"]),
  201. raw: pureAndGlobal("string/raw", ["es6.string.raw"])
  202. },
  203. Symbol: {
  204. // FIXME: Pure disabled to work around zloirock/core-js#262.
  205. asyncIterator: globalOnly(["es6.symbol", "es7.symbol.async-iterator"]),
  206. for: pureOnly("symbol/for", "es6.symbol"),
  207. hasInstance: pureOnly("symbol/has-instance", "es6.symbol"),
  208. isConcatSpreadable: pureOnly("symbol/is-concat-spreadable", "es6.symbol"),
  209. iterator: define("es6.symbol", "symbol/iterator", CommonIterators),
  210. keyFor: pureOnly("symbol/key-for", "es6.symbol"),
  211. match: pureAndGlobal("symbol/match", ["es6.regexp.match"]),
  212. replace: pureOnly("symbol/replace", "es6.symbol"),
  213. search: pureOnly("symbol/search", "es6.symbol"),
  214. species: pureOnly("symbol/species", "es6.symbol"),
  215. split: pureOnly("symbol/split", "es6.symbol"),
  216. toPrimitive: pureOnly("symbol/to-primitive", "es6.symbol"),
  217. toStringTag: pureOnly("symbol/to-string-tag", "es6.symbol"),
  218. unscopables: pureOnly("symbol/unscopables", "es6.symbol")
  219. }
  220. };
  221. exports.StaticProperties = StaticProperties;