Skip to content

Commit

Permalink
chore: gulp generate-runtime-helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmare committed Nov 5, 2021
1 parent 09aae36 commit 7410ea6
Showing 1 changed file with 29 additions and 40 deletions.
69 changes: 29 additions & 40 deletions packages/babel-helpers/src/helpers-generated.ts
@@ -1,47 +1,36 @@
/*
* This file is auto-generated! Do not modify it directly.
* To re-generate run 'make build'
* To re-generate run 'yarn gulp generate-runtime-helpers'
*/

import template from "@babel/template";

export const asyncIterator = {
minVersion: "7.15.9",
ast: () =>
template.program.ast(
'\nexport default function _asyncIterator(iterable) {\n var method,\n async,\n sync,\n retry = 2;\n if (typeof Symbol !== "undefined") {\n async = Symbol.asyncIterator;\n sync = Symbol.iterator;\n }\n while (retry--) {\n if (async && (method = iterable[async]) != null) {\n return method.call(iterable);\n }\n if (sync && (method = iterable[sync]) != null) {\n return new AsyncFromSyncIterator(method.call(iterable));\n }\n async = "@@asyncIterator";\n sync = "@@iterator";\n }\n throw new TypeError("Object is not async iterable");\n}\nfunction AsyncFromSyncIterator(s) {\n AsyncFromSyncIterator = function (s) {\n this.s = s;\n this.n = s.next;\n };\n AsyncFromSyncIterator.prototype = {\n s: null,\n n: null,\n next: function () {\n return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));\n },\n return: function (value) {\n var ret = this.s.return;\n if (ret === undefined) {\n return Promise.resolve({ value: value, done: true });\n }\n return AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));\n },\n throw: function (value) {\n var thr = this.s.return;\n if (thr === undefined) return Promise.reject(value);\n return AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));\n },\n };\n function AsyncFromSyncIteratorContinuation(r) {\n \n if (Object(r) !== r) {\n return Promise.reject(new TypeError(r + " is not an object."));\n }\n var done = r.done;\n return Promise.resolve(r.value).then(function (value) {\n return { value: value, done: done };\n });\n }\n return new AsyncFromSyncIterator(s);\n}\n',
),
};
function helper(minVersion, source) {
return Object.freeze({
minVersion,
ast: () => template.program.ast(source),
});
}

export const jsx = {
minVersion: "7.0.0-beta.0",
ast: () =>
template.program.ast(
'\nvar REACT_ELEMENT_TYPE;\nexport default function _createRawReactElement(type, props, key, children) {\n if (!REACT_ELEMENT_TYPE) {\n REACT_ELEMENT_TYPE =\n (typeof Symbol === "function" &&\n \n Symbol["for"] &&\n Symbol["for"]("react.element")) ||\n 0xeac7;\n }\n var defaultProps = type && type.defaultProps;\n var childrenLength = arguments.length - 3;\n if (!props && childrenLength !== 0) {\n \n \n props = { children: void 0 };\n }\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = new Array(childrenLength);\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 3];\n }\n props.children = childArray;\n }\n if (props && defaultProps) {\n for (var propName in defaultProps) {\n if (props[propName] === void 0) {\n props[propName] = defaultProps[propName];\n }\n }\n } else if (!props) {\n props = defaultProps || {};\n }\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key === undefined ? null : "" + key,\n ref: null,\n props: props,\n _owner: null,\n };\n}\n',
),
};

export const objectSpread2 = {
minVersion: "7.5.0",
ast: () =>
template.program.ast(
'\nimport defineProperty from "defineProperty";\nfunction ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n if (enumerableOnly) {\n symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n });\n }\n keys.push.apply(keys, symbols);\n }\n return keys;\n}\nexport default function _objectSpread2(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n if (i % 2) {\n ownKeys(Object(source), true).forEach(function (key) {\n defineProperty(target, key, source[key]);\n });\n } else if (Object.getOwnPropertyDescriptors) {\n Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));\n } else {\n ownKeys(Object(source)).forEach(function (key) {\n Object.defineProperty(\n target,\n key,\n Object.getOwnPropertyDescriptor(source, key)\n );\n });\n }\n }\n return target;\n}\n',
),
};

export { _typeof as typeof };
const _typeof = {
minVersion: "7.0.0-beta.0",
ast: () =>
template.program.ast(
'\nexport default function _typeof(obj) {\n "@babel/helpers - typeof";\n if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj &&\n typeof Symbol === "function" &&\n obj.constructor === Symbol &&\n obj !== Symbol.prototype\n ? "symbol"\n : typeof obj;\n };\n }\n return _typeof(obj);\n}\n',
),
};

export const wrapRegExp = {
minVersion: "7.2.6",
ast: () =>
template.program.ast(
'\nimport setPrototypeOf from "setPrototypeOf";\nimport inherits from "inherits";\nexport default function _wrapRegExp() {\n _wrapRegExp = function (re, groups) {\n return new BabelRegExp(re, undefined, groups);\n };\n var _super = RegExp.prototype;\n var _groups = new WeakMap();\n function BabelRegExp(re, flags, groups) {\n var _this = new RegExp(re, flags);\n \n _groups.set(_this, groups || _groups.get(re));\n return setPrototypeOf(_this, BabelRegExp.prototype);\n }\n inherits(BabelRegExp, RegExp);\n BabelRegExp.prototype.exec = function (str) {\n var result = _super.exec.call(this, str);\n if (result) result.groups = buildGroups(result, this);\n return result;\n };\n BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {\n if (typeof substitution === "string") {\n var groups = _groups.get(this);\n return _super[Symbol.replace].call(\n this,\n str,\n substitution.replace(/\\$<([^>]+)>/g, function (_, name) {\n return "$" + groups[name];\n })\n );\n } else if (typeof substitution === "function") {\n var _this = this;\n return _super[Symbol.replace].call(this, str, function () {\n var args = arguments;\n \n if (typeof args[args.length - 1] !== "object") {\n args = [].slice.call(args);\n args.push(buildGroups(args, _this));\n }\n return substitution.apply(this, args);\n });\n } else {\n return _super[Symbol.replace].call(this, str, substitution);\n }\n };\n function buildGroups(result, re) {\n \n \n var g = _groups.get(re);\n return Object.keys(g).reduce(function (groups, name) {\n groups[name] = result[g[name]];\n return groups;\n }, Object.create(null));\n }\n return _wrapRegExp.apply(this, arguments);\n}\n',
),
};
export default Object.freeze({
asyncIterator: helper(
"7.15.9",
'export default function _asyncIterator(iterable){var method,async,sync,retry=2;if(typeof Symbol!=="undefined"){async=Symbol.asyncIterator;sync=Symbol.iterator}while(retry--){if(async&&(method=iterable[async])!=null){return method.call(iterable)}if(sync&&(method=iterable[sync])!=null){return new AsyncFromSyncIterator(method.call(iterable))}async="@@asyncIterator";sync="@@iterator"}throw new TypeError("Object is not async iterable")}function AsyncFromSyncIterator(s){AsyncFromSyncIterator=function(s){this.s=s;this.n=s.next};AsyncFromSyncIterator.prototype={s:null,n:null,next:function(){return AsyncFromSyncIteratorContinuation(this.n.apply(this.s,arguments))},return:function(value){var ret=this.s.return;if(ret===undefined){return Promise.resolve({value:value,done:true})}return AsyncFromSyncIteratorContinuation(ret.apply(this.s,arguments))},throw:function(value){var thr=this.s.return;if(thr===undefined)return Promise.reject(value);return AsyncFromSyncIteratorContinuation(thr.apply(this.s,arguments))}};function AsyncFromSyncIteratorContinuation(r){if(Object(r)!==r){return Promise.reject(new TypeError(r+" is not an object."))}var done=r.done;return Promise.resolve(r.value).then((function(value){return{value:value,done:done}}))}return new AsyncFromSyncIterator(s)}',
),
jsx: helper(
"7.0.0-beta.0",
'var REACT_ELEMENT_TYPE;export default function _createRawReactElement(type,props,key,children){if(!REACT_ELEMENT_TYPE){REACT_ELEMENT_TYPE=typeof Symbol==="function"&&Symbol["for"]&&Symbol["for"]("react.element")||60103}var defaultProps=type&&type.defaultProps;var childrenLength=arguments.length-3;if(!props&&childrenLength!==0){props={children:void 0}}if(childrenLength===1){props.children=children}else if(childrenLength>1){var childArray=new Array(childrenLength);for(var i=0;i<childrenLength;i++){childArray[i]=arguments[i+3]}props.children=childArray}if(props&&defaultProps){for(var propName in defaultProps){if(props[propName]===void 0){props[propName]=defaultProps[propName]}}}else if(!props){props=defaultProps||{}}return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key===undefined?null:""+key,ref:null,props:props,_owner:null}}',
),
objectSpread2: helper(
"7.5.0",
'import defineProperty from"defineProperty";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))}keys.push.apply(keys,symbols)}return keys}export default function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach((function(key){defineProperty(target,key,source[key])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach((function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))}))}}return target}',
),
typeof: helper(
"7.0.0-beta.0",
'export default function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function(obj){return typeof obj}}else{_typeof=function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}',
),
wrapRegExp: helper(
"7.2.6",
'import setPrototypeOf from"setPrototypeOf";import inherits from"inherits";export default function _wrapRegExp(){_wrapRegExp=function(re,groups){return new BabelRegExp(re,undefined,groups)};var _super=RegExp.prototype;var _groups=new WeakMap;function BabelRegExp(re,flags,groups){var _this=new RegExp(re,flags);_groups.set(_this,groups||_groups.get(re));return setPrototypeOf(_this,BabelRegExp.prototype)}inherits(BabelRegExp,RegExp);BabelRegExp.prototype.exec=function(str){var result=_super.exec.call(this,str);if(result)result.groups=buildGroups(result,this);return result};BabelRegExp.prototype[Symbol.replace]=function(str,substitution){if(typeof substitution==="string"){var groups=_groups.get(this);return _super[Symbol.replace].call(this,str,substitution.replace(/\\$<([^>]+)>/g,(function(_,name){return"$"+groups[name]})))}else if(typeof substitution==="function"){var _this=this;return _super[Symbol.replace].call(this,str,(function(){var args=arguments;if(typeof args[args.length-1]!=="object"){args=[].slice.call(args);args.push(buildGroups(args,_this))}return substitution.apply(this,args)}))}else{return _super[Symbol.replace].call(this,str,substitution)}};function buildGroups(result,re){var g=_groups.get(re);return Object.keys(g).reduce((function(groups,name){groups[name]=result[g[name]];return groups}),Object.create(null))}return _wrapRegExp.apply(this,arguments)}',
),
});

0 comments on commit 7410ea6

Please sign in to comment.