react-runner
Advanced tools
Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6
@@ -1,2 +0,2 @@ | ||
import r,{isValidElement as e,createElement as t,Fragment as n,Component as o,useRef as s,useState as l,useEffect as c}from"react";import{transform as u}from"sucrase";function a(){return a=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},a.apply(this,arguments)}const i=/^export default(?=\s+)/m,p=/^render(?=\s*\([^)])/m,d=/^</,m={React:r,jsxPragma:r.createElement,jsxFragmentPragma:r.Fragment},f=r=>e=>{if(!r.hasOwnProperty(e))throw new Error("Module not found: '"+e+"'");return r[e]},g=r=>{const{code:o,scope:s}=r,l=o.trim();if(!l)return null;const c=(null==s?void 0:s.require)&&"function"==typeof s.require,f=((r,e)=>u(r,{transforms:e?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((r=>i.test(r)?r.replace(i,"return"):p.test(r)?r.replace(p,"return"):(r=r.replace(/;$/,""),d.test(r)&&(r="<>"+r+"</>"),"return ("+r+")"))(l),c),g=((r,e)=>{const t=Object.keys(e),n=t.map(r=>e[r]);return new Function(...t,r)(...n)})(f,a({},m,s));return g?e(g)?g:"function"==typeof g?t(g):"string"==typeof g?t(n,void 0,g):null:null};class h extends o{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(r,e){if(e.prevCode===r.code)return null;try{return{element:g(r),error:e.error&&r.code!==e.prevCode?null:e.error,prevCode:r.code}}catch(e){return{element:null,error:e.toString(),prevCode:r.code}}}static getDerivedStateFromError(r){return{error:r.toString()}}componentDidMount(){var r,e,t;null==(r=(e=this.props).onRendered)||r.call(e,null==(t=this.state.error)?void 0:t.toString())}shouldComponentUpdate(r,e){return r.code!==this.props.code||e.error!==this.state.error}componentDidUpdate(){var r,e,t;null==(r=(e=this.props).onRendered)||r.call(e,null==(t=this.state.error)?void 0:t.toString())}render(){return this.state.error?null:this.state.element}}const v=r=>{let{code:e,scope:n,disableCache:o}=r;const u=s(!0),a=s(null),i=s(n);i.current=n;const[p,d]=l(()=>{const r=t(h,{code:e,scope:i.current,onRendered:e=>{e?d({element:o?null:a.current,error:e}):a.current=r}});return{element:r,error:null}});return c(()=>{if(u.current)return void(u.current=!1);const r=t(h,{code:e,scope:i.current,onRendered:e=>{e?d({element:o?null:a.current,error:e}):a.current=r}});d({element:r,error:null})},[e,o]),p};export{h as Runner,f as createRequire,g as generateElement,v as useRunner}; | ||
import r,{isValidElement as e,createElement as t,Fragment as n,Component as o,useRef as s,useState as c,useEffect as l}from"react";import{transform as u}from"sucrase";function a(){return a=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},a.apply(this,arguments)}const i=/^export default(?=\s+)/m,p=/^render(?=\s*\([^)])/m,d=/^<[^>]*>/,m=/^(function|\(\)|class)[^\w]+/,f={React:r,jsxPragma:r.createElement,jsxFragmentPragma:r.Fragment},g=r=>e=>{if(!r.hasOwnProperty(e))throw new Error("Module not found: '"+e+"'");return r[e]},h=r=>{const{code:o,scope:s}=r,c=o.trim();if(!c)return null;const l=(null==s?void 0:s.require)&&"function"==typeof s.require,g=((r,e)=>u(r,{transforms:e?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((r=>d.test(r)?"return (<>"+r+"</>)":i.test(r)?r.replace(i,"return"):p.test(r)?r.replace(p,"return"):m.test(r)?"return ("+r.replace(/;$/,"")+")":r)(c),l),h=((r,e)=>{const t=Object.keys(e),n=t.map(r=>e[r]);return new Function(...t,r)(...n)})(g,a({},f,s));return h?e(h)?h:"function"==typeof h?t(h):"string"==typeof h?t(n,void 0,h):null:null};class v extends o{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(r,e){if(e.prevCode===r.code)return null;try{return{element:h(r),error:e.error&&r.code!==e.prevCode?null:e.error,prevCode:r.code}}catch(e){return{element:null,error:e,prevCode:r.code}}}static getDerivedStateFromError(r){return{error:r}}componentDidMount(){var r,e;null==(r=(e=this.props).onRendered)||r.call(e,this.state.error||void 0)}shouldComponentUpdate(r,e){return r.code!==this.props.code||e.error!==this.state.error}componentDidUpdate(){var r,e;null==(r=(e=this.props).onRendered)||r.call(e,this.state.error||void 0)}render(){return this.state.error?null:this.state.element}}const j=r=>{let{code:e,scope:n,disableCache:o}=r;const u=s(!0),a=s(null),i=s(n);i.current=n;const[p,d]=c(()=>{const r=t(v,{code:e,scope:i.current,onRendered:e=>{e?d({element:o?null:a.current,error:e.toString()}):a.current=r}});return{element:r,error:null}});return l(()=>{if(u.current)return void(u.current=!1);const r=t(v,{code:e,scope:i.current,onRendered:e=>{e?d({element:o?null:a.current,error:e.toString()}):a.current=r}});d({element:r,error:null})},[e,o]),p};export{v as Runner,g as createRequire,h as generateElement,j as useRunner}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
var e=require("react"),r=require("sucrase");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(e);function o(){return o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o.apply(this,arguments)}const u=/^export default(?=\s+)/m,s=/^render(?=\s*\([^)])/m,l=/^</,a={React:n.default,jsxPragma:n.default.createElement,jsxFragmentPragma:n.default.Fragment},c=t=>{const{code:n,scope:c}=t,i=n.trim();if(!i)return null;const d=(null==c?void 0:c.require)&&"function"==typeof c.require,p=((e,t)=>r.transform(e,{transforms:t?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((e=>u.test(e)?e.replace(u,"return"):s.test(e)?e.replace(s,"return"):(e=e.replace(/;$/,""),l.test(e)&&(e="<>"+e+"</>"),"return ("+e+")"))(i),d),m=((e,r)=>{const t=Object.keys(r),n=t.map(e=>r[e]);return new Function(...t,e)(...n)})(p,o({},a,c));return m?e.isValidElement(m)?m:"function"==typeof m?e.createElement(m):"string"==typeof m?e.createElement(e.Fragment,void 0,m):null:null};class i extends e.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code)return null;try{return{element:c(e),error:r.error&&e.code!==r.prevCode?null:r.error,prevCode:e.code}}catch(r){return{element:null,error:r.toString(),prevCode:e.code}}}static getDerivedStateFromError(e){return{error:e.toString()}}componentDidMount(){var e,r,t;null==(e=(r=this.props).onRendered)||e.call(r,null==(t=this.state.error)?void 0:t.toString())}shouldComponentUpdate(e,r){return e.code!==this.props.code||r.error!==this.state.error}componentDidUpdate(){var e,r,t;null==(e=(r=this.props).onRendered)||e.call(r,null==(t=this.state.error)?void 0:t.toString())}render(){return this.state.error?null:this.state.element}}exports.Runner=i,exports.createRequire=e=>r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]},exports.generateElement=c,exports.useRunner=r=>{let{code:t,scope:n,disableCache:o}=r;const u=e.useRef(!0),s=e.useRef(null),l=e.useRef(n);l.current=n;const[a,c]=e.useState(()=>{const r=e.createElement(i,{code:t,scope:l.current,onRendered:e=>{e?c({element:o?null:s.current,error:e}):s.current=r}});return{element:r,error:null}});return e.useEffect(()=>{if(u.current)return void(u.current=!1);const r=e.createElement(i,{code:t,scope:l.current,onRendered:e=>{e?c({element:o?null:s.current,error:e}):s.current=r}});c({element:r,error:null})},[t,o]),a}; | ||
var e=require("react"),r=require("sucrase");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(e);function o(){return o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o.apply(this,arguments)}const s=/^export default(?=\s+)/m,u=/^render(?=\s*\([^)])/m,l=/^<[^>]*>/,c=/^(function|\(\)|class)[^\w]+/,a={React:n.default,jsxPragma:n.default.createElement,jsxFragmentPragma:n.default.Fragment},i=t=>{const{code:n,scope:i}=t,d=n.trim();if(!d)return null;const p=(null==i?void 0:i.require)&&"function"==typeof i.require,m=((e,t)=>r.transform(e,{transforms:t?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((e=>l.test(e)?"return (<>"+e+"</>)":s.test(e)?e.replace(s,"return"):u.test(e)?e.replace(u,"return"):c.test(e)?"return ("+e.replace(/;$/,"")+")":e)(d),p),f=((e,r)=>{const t=Object.keys(r),n=t.map(e=>r[e]);return new Function(...t,e)(...n)})(m,o({},a,i));return f?e.isValidElement(f)?f:"function"==typeof f?e.createElement(f):"string"==typeof f?e.createElement(e.Fragment,void 0,f):null:null};class d extends e.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code)return null;try{return{element:i(e),error:r.error&&e.code!==r.prevCode?null:r.error,prevCode:e.code}}catch(r){return{element:null,error:r,prevCode:e.code}}}static getDerivedStateFromError(e){return{error:e}}componentDidMount(){var e,r;null==(e=(r=this.props).onRendered)||e.call(r,this.state.error||void 0)}shouldComponentUpdate(e,r){return e.code!==this.props.code||r.error!==this.state.error}componentDidUpdate(){var e,r;null==(e=(r=this.props).onRendered)||e.call(r,this.state.error||void 0)}render(){return this.state.error?null:this.state.element}}exports.Runner=d,exports.createRequire=e=>r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]},exports.generateElement=i,exports.useRunner=r=>{let{code:t,scope:n,disableCache:o}=r;const s=e.useRef(!0),u=e.useRef(null),l=e.useRef(n);l.current=n;const[c,a]=e.useState(()=>{const r=e.createElement(d,{code:t,scope:l.current,onRendered:e=>{e?a({element:o?null:u.current,error:e.toString()}):u.current=r}});return{element:r,error:null}});return e.useEffect(()=>{if(s.current)return void(s.current=!1);const r=e.createElement(d,{code:t,scope:l.current,onRendered:e=>{e?a({element:o?null:u.current,error:e.toString()}):u.current=r}});a({element:r,error:null})},[t,o]),c}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import r,{isValidElement as e,createElement as t,Fragment as n,Component as o,useRef as s,useState as l,useEffect as c}from"react";import{transform as u}from"sucrase";function a(){return a=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},a.apply(this,arguments)}const i=/^export default(?=\s+)/m,p=/^render(?=\s*\([^)])/m,d=/^</,m={React:r,jsxPragma:r.createElement,jsxFragmentPragma:r.Fragment},f=r=>e=>{if(!r.hasOwnProperty(e))throw new Error(`Module not found: '${e}'`);return r[e]},g=r=>{const{code:o,scope:s}=r,l=o.trim();if(!l)return null;const c=(null==s?void 0:s.require)&&"function"==typeof s.require,f=((r,e)=>u(r,{transforms:e?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((r=>i.test(r)?r.replace(i,"return"):p.test(r)?r.replace(p,"return"):(r=r.replace(/;$/,""),d.test(r)&&(r=`<>${r}</>`),`return (${r})`))(l),c),g=((r,e)=>{const t=Object.keys(e),n=t.map(r=>e[r]);return new Function(...t,r)(...n)})(f,a({},m,s));return g?e(g)?g:"function"==typeof g?t(g):"string"==typeof g?t(n,void 0,g):null:null};class h extends o{constructor(...r){super(...r),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(r,e){if(e.prevCode===r.code)return null;try{return{element:g(r),error:e.error&&r.code!==e.prevCode?null:e.error,prevCode:r.code}}catch(e){return{element:null,error:e.toString(),prevCode:r.code}}}static getDerivedStateFromError(r){return{error:r.toString()}}componentDidMount(){var r,e,t;null==(r=(e=this.props).onRendered)||r.call(e,null==(t=this.state.error)?void 0:t.toString())}shouldComponentUpdate(r,e){return r.code!==this.props.code||e.error!==this.state.error}componentDidUpdate(){var r,e,t;null==(r=(e=this.props).onRendered)||r.call(e,null==(t=this.state.error)?void 0:t.toString())}render(){return this.state.error?null:this.state.element}}const v=({code:r,scope:e,disableCache:n})=>{const o=s(!0),u=s(null),a=s(e);a.current=e;const[i,p]=l(()=>{const e=t(h,{code:r,scope:a.current,onRendered:r=>{r?p({element:n?null:u.current,error:r}):u.current=e}});return{element:e,error:null}});return c(()=>{if(o.current)return void(o.current=!1);const e=t(h,{code:r,scope:a.current,onRendered:r=>{r?p({element:n?null:u.current,error:r}):u.current=e}});p({element:e,error:null})},[r,n]),i};export{h as Runner,f as createRequire,g as generateElement,v as useRunner}; | ||
import r,{isValidElement as e,createElement as t,Fragment as n,Component as o,useRef as s,useState as c,useEffect as u}from"react";import{transform as l}from"sucrase";function a(){return a=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},a.apply(this,arguments)}const i=/^export default(?=\s+)/m,p=/^render(?=\s*\([^)])/m,d=/^<[^>]*>/,m=/^(function|\(\)|class)[^\w]+/,f={React:r,jsxPragma:r.createElement,jsxFragmentPragma:r.Fragment},g=r=>e=>{if(!r.hasOwnProperty(e))throw new Error(`Module not found: '${e}'`);return r[e]},h=r=>{const{code:o,scope:s}=r,c=o.trim();if(!c)return null;const u=(null==s?void 0:s.require)&&"function"==typeof s.require,g=((r,e)=>l(r,{transforms:e?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((r=>d.test(r)?`return (<>${r}</>)`:i.test(r)?r.replace(i,"return"):p.test(r)?r.replace(p,"return"):m.test(r)?`return (${r.replace(/;$/,"")})`:r)(c),u),h=((r,e)=>{const t=Object.keys(e),n=t.map(r=>e[r]);return new Function(...t,r)(...n)})(g,a({},f,s));return h?e(h)?h:"function"==typeof h?t(h):"string"==typeof h?t(n,void 0,h):null:null};class v extends o{constructor(...r){super(...r),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(r,e){if(e.prevCode===r.code)return null;try{return{element:h(r),error:e.error&&r.code!==e.prevCode?null:e.error,prevCode:r.code}}catch(e){return{element:null,error:e,prevCode:r.code}}}static getDerivedStateFromError(r){return{error:r}}componentDidMount(){var r,e;null==(r=(e=this.props).onRendered)||r.call(e,this.state.error||void 0)}shouldComponentUpdate(r,e){return r.code!==this.props.code||e.error!==this.state.error}componentDidUpdate(){var r,e;null==(r=(e=this.props).onRendered)||r.call(e,this.state.error||void 0)}render(){return this.state.error?null:this.state.element}}const j=({code:r,scope:e,disableCache:n})=>{const o=s(!0),l=s(null),a=s(e);a.current=e;const[i,p]=c(()=>{const e=t(v,{code:r,scope:a.current,onRendered:r=>{r?p({element:n?null:l.current,error:r.toString()}):l.current=e}});return{element:e,error:null}});return u(()=>{if(o.current)return void(o.current=!1);const e=t(v,{code:r,scope:a.current,onRendered:r=>{r?p({element:n?null:l.current,error:r.toString()}):l.current=e}});p({element:e,error:null})},[r,n]),i};export{v as Runner,g as createRequire,h as generateElement,j as useRunner}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("sucrase")):"function"==typeof define&&define.amd?define(["exports","react","sucrase"],r):r((e||self).reactRunner={},e.react,e.sucrase)}(this,function(e,r,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/n(r);function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},u.apply(this,arguments)}const s=/^export default(?=\s+)/m,l=/^render(?=\s*\([^)])/m,c=/^</,a={React:o.default,jsxPragma:o.default.createElement,jsxFragmentPragma:o.default.Fragment},i=e=>{const{code:n,scope:o}=e,i=n.trim();if(!i)return null;const d=(null==o?void 0:o.require)&&"function"==typeof o.require,p=((e,r)=>t.transform(e,{transforms:r?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((e=>s.test(e)?e.replace(s,"return"):l.test(e)?e.replace(l,"return"):(e=e.replace(/;$/,""),c.test(e)&&(e="<>"+e+"</>"),"return ("+e+")"))(i),d),f=((e,r)=>{const t=Object.keys(r),n=t.map(e=>r[e]);return new Function(...t,e)(...n)})(p,u({},a,o));return f?r.isValidElement(f)?f:"function"==typeof f?r.createElement(f):"string"==typeof f?r.createElement(r.Fragment,void 0,f):null:null};class d extends r.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code)return null;try{return{element:i(e),error:r.error&&e.code!==r.prevCode?null:r.error,prevCode:e.code}}catch(r){return{element:null,error:r.toString(),prevCode:e.code}}}static getDerivedStateFromError(e){return{error:e.toString()}}componentDidMount(){var e,r,t;null==(e=(r=this.props).onRendered)||e.call(r,null==(t=this.state.error)?void 0:t.toString())}shouldComponentUpdate(e,r){return e.code!==this.props.code||r.error!==this.state.error}componentDidUpdate(){var e,r,t;null==(e=(r=this.props).onRendered)||e.call(r,null==(t=this.state.error)?void 0:t.toString())}render(){return this.state.error?null:this.state.element}}e.Runner=d,e.createRequire=e=>r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]},e.generateElement=i,e.useRunner=e=>{let{code:t,scope:n,disableCache:o}=e;const u=r.useRef(!0),s=r.useRef(null),l=r.useRef(n);l.current=n;const[c,a]=r.useState(()=>{const e=r.createElement(d,{code:t,scope:l.current,onRendered:r=>{r?a({element:o?null:s.current,error:r}):s.current=e}});return{element:e,error:null}});return r.useEffect(()=>{if(u.current)return void(u.current=!1);const e=r.createElement(d,{code:t,scope:l.current,onRendered:r=>{r?a({element:o?null:s.current,error:r}):s.current=e}});a({element:e,error:null})},[t,o]),c}}); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("sucrase")):"function"==typeof define&&define.amd?define(["exports","react","sucrase"],r):r((e||self).reactRunner={},e.react,e.sucrase)}(this,function(e,r,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/n(r);function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},u.apply(this,arguments)}const s=/^export default(?=\s+)/m,c=/^render(?=\s*\([^)])/m,l=/^<[^>]*>/,a=/^(function|\(\)|class)[^\w]+/,i={React:o.default,jsxPragma:o.default.createElement,jsxFragmentPragma:o.default.Fragment},d=e=>{const{code:n,scope:o}=e,d=n.trim();if(!d)return null;const p=(null==o?void 0:o.require)&&"function"==typeof o.require,f=((e,r)=>t.transform(e,{transforms:r?["jsx","typescript","imports"]:["jsx","typescript"],production:!0,jsxPragma:"jsxPragma",jsxFragmentPragma:"jsxFragmentPragma"}).code)((e=>l.test(e)?"return (<>"+e+"</>)":s.test(e)?e.replace(s,"return"):c.test(e)?e.replace(c,"return"):a.test(e)?"return ("+e.replace(/;$/,"")+")":e)(d),p),m=((e,r)=>{const t=Object.keys(r),n=t.map(e=>r[e]);return new Function(...t,e)(...n)})(f,u({},i,o));return m?r.isValidElement(m)?m:"function"==typeof m?r.createElement(m):"string"==typeof m?r.createElement(r.Fragment,void 0,m):null:null};class p extends r.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code)return null;try{return{element:d(e),error:r.error&&e.code!==r.prevCode?null:r.error,prevCode:e.code}}catch(r){return{element:null,error:r,prevCode:e.code}}}static getDerivedStateFromError(e){return{error:e}}componentDidMount(){var e,r;null==(e=(r=this.props).onRendered)||e.call(r,this.state.error||void 0)}shouldComponentUpdate(e,r){return e.code!==this.props.code||r.error!==this.state.error}componentDidUpdate(){var e,r;null==(e=(r=this.props).onRendered)||e.call(r,this.state.error||void 0)}render(){return this.state.error?null:this.state.element}}e.Runner=p,e.createRequire=e=>r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]},e.generateElement=d,e.useRunner=e=>{let{code:t,scope:n,disableCache:o}=e;const u=r.useRef(!0),s=r.useRef(null),c=r.useRef(n);c.current=n;const[l,a]=r.useState(()=>{const e=r.createElement(p,{code:t,scope:c.current,onRendered:r=>{r?a({element:o?null:s.current,error:r.toString()}):s.current=e}});return{element:e,error:null}});return r.useEffect(()=>{if(u.current)return void(u.current=!1);const e=r.createElement(p,{code:t,scope:c.current,onRendered:r=>{r?a({element:o?null:s.current,error:r.toString()}):s.current=e}});a({element:e,error:null})},[t,o]),l}}); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -5,7 +5,7 @@ import { Component, ReactElement } from 'react'; | ||
/** callback on code be rendered, returns error message when code is invalid */ | ||
onRendered?: (error?: string) => void; | ||
onRendered?: (error?: Error) => void; | ||
}; | ||
declare type RunnerState = { | ||
element: ReactElement | null; | ||
error: string | null; | ||
error: Error | null; | ||
prevCode: string | null; | ||
@@ -12,0 +12,0 @@ }; |
{ | ||
"name": "react-runner", | ||
"version": "1.0.0-alpha.5", | ||
"version": "1.0.0-alpha.6", | ||
"description": "Run your React code on the go", | ||
@@ -66,3 +66,3 @@ "homepage": "https://react-runner.vercel.app", | ||
}, | ||
"gitHead": "1a9d7a1c223016d5cb19de2e4dac36039afb5a29" | ||
"gitHead": "a789960bd317e986054550ba0afa96fa45daf689" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55512