react-runner
Advanced tools
Comparing version 1.0.0-rc.2 to 1.0.0-rc.3
@@ -1,2 +0,2 @@ | ||
import e,{isValidElement as r,createElement as t,Component as o,useRef as n,useState as s,useEffect as c}from"react";import{transform as l}from"sucrase";function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},u.apply(this,arguments)}const p=e=>l(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),i=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,d=["default","import"],a=(r,t)=>{const{import:o}=t,n=function(e,r){if(null==e)return{};var t,o,n={},s=Object.keys(e);for(o=0;o<s.length;o++)r.indexOf(t=s[o])>=0||(n[t]=e[t]);return n}(t,d),s=u({React:e,require:m(o)},n),c=Object.keys(s),l=c.map(e=>s[e]);return new Function(...c,r)(...l)},f=e=>{const{code:o,scope:n}=e;if(!o.trim())return null;const s={};a(p((e=>e.replace(i,"$1export default $2$3"))(o)),u({render:e=>{s.default=e}},n,{exports:s}));const c=s.default;return c?r(c)?c:"function"==typeof c?t(c):"string"==typeof c?c:null:null},m=function(e){return void 0===e&&(e={}),r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]}},v=(e,r)=>{const t={};return a(p(e),u({},r,{exports:t})),t};class h extends o{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null,prevScope:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:f(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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}}const y=e=>{let{code:r,scope:o,disableCache:l}=e;const u=n(!0),p=n(null),[i,d]=s(()=>{const e=t(h,{code:r,scope:o,onRendered:r=>{r?d({element:l?null:p.current,error:r.toString()}):p.current=e}});return{element:e,error:null}});return c(()=>{if(u.current)return void(u.current=!1);const e=t(h,{code:r,scope:o,onRendered:r=>{r?d({element:l?null:p.current,error:r.toString()}):p.current=e}});d({element:e,error:null})},[r,o,l]),i};export{h as Runner,m as createRequire,f as generateElement,v as importCode,y as useRunner}; | ||
import e,{isValidElement as r,createElement as t,Component as o,useRef as n,useState as s,useEffect as c}from"react";import{transform as l}from"sucrase";function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},u.apply(this,arguments)}const p=e=>l(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),i=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,d=["default","import"],a=(r,t)=>{const{import:o}=t,n=function(e,r){if(null==e)return{};var t,o,n={},s=Object.keys(e);for(o=0;o<s.length;o++)r.indexOf(t=s[o])>=0||(n[t]=e[t]);return n}(t,d),s=u({React:e,require:m(o)},n),c=Object.keys(s),l=c.map(e=>s[e]);return new Function(...c,r)(...l)},f=e=>{const{code:o,scope:n}=e;if(!o.trim())return null;const s={};a(p((e=>e.replace(i,"$1export default $2$3"))(o)),u({render:e=>{s.default=e}},n,{exports:s}));const c=s.default;return c?r(c)?c:"function"==typeof c?t(c):"string"==typeof c?c:null:null},m=function(e){return void 0===e&&(e={}),r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]}},v=(e,r)=>{const t={};return a(p(e),u({},r,{exports:t})),t};class h extends o{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null,prevScope:void 0}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:f(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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}}const y=e=>{let{code:r,scope:o,disableCache:l}=e;const u=n(!0),p=n(null),[i,d]=s(()=>{const e=t(h,{code:r,scope:o,onRendered:r=>{r?d({element:l?null:p.current,error:r.toString()}):p.current=e}});return{element:e,error:null}});return c(()=>{if(u.current)return void(u.current=!1);const e=t(h,{code:r,scope:o,onRendered:r=>{r?d({element:l?null:p.current,error:r.toString()}):p.current=e}});d({element:e,error:null})},[r,o,l]),i};export{h as Runner,m as createRequire,f as generateElement,v as importCode,y 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 s=e=>r.transform(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),u=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,c=["default","import"],l=(e,r)=>{const{import:t}=r,s=function(e,r){if(null==e)return{};var t,n,o={},s=Object.keys(e);for(n=0;n<s.length;n++)r.indexOf(t=s[n])>=0||(o[t]=e[t]);return o}(r,c),u=o({React:n.default,require:i(t)},s),l=Object.keys(u),p=l.map(e=>u[e]);return new Function(...l,e)(...p)},p=r=>{const{code:t,scope:n}=r;if(!t.trim())return null;const c={};l(s((e=>e.replace(u,"$1export default $2$3"))(t)),o({render:e=>{c.default=e}},n,{exports:c}));const p=c.default;return p?e.isValidElement(p)?p:"function"==typeof p?e.createElement(p):"string"==typeof p?p:null:null},i=function(e){return void 0===e&&(e={}),r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]}};class a extends e.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null,prevScope:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:p(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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=a,exports.createRequire=i,exports.generateElement=p,exports.importCode=(e,r)=>{const t={};return l(s(e),o({},r,{exports:t})),t},exports.useRunner=r=>{let{code:t,scope:n,disableCache:o}=r;const s=e.useRef(!0),u=e.useRef(null),[c,l]=e.useState(()=>{const r=e.createElement(a,{code:t,scope:n,onRendered:e=>{e?l({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(a,{code:t,scope:n,onRendered:e=>{e?l({element:o?null:u.current,error:e.toString()}):u.current=r}});l({element:r,error:null})},[t,n,o]),c}; | ||
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=e=>r.transform(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),u=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,c=["default","import"],l=(e,r)=>{const{import:t}=r,s=function(e,r){if(null==e)return{};var t,n,o={},s=Object.keys(e);for(n=0;n<s.length;n++)r.indexOf(t=s[n])>=0||(o[t]=e[t]);return o}(r,c),u=o({React:n.default,require:i(t)},s),l=Object.keys(u),p=l.map(e=>u[e]);return new Function(...l,e)(...p)},p=r=>{const{code:t,scope:n}=r;if(!t.trim())return null;const c={};l(s((e=>e.replace(u,"$1export default $2$3"))(t)),o({render:e=>{c.default=e}},n,{exports:c}));const p=c.default;return p?e.isValidElement(p)?p:"function"==typeof p?e.createElement(p):"string"==typeof p?p:null:null},i=function(e){return void 0===e&&(e={}),r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]}};class a extends e.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null,prevScope:void 0}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:p(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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=a,exports.createRequire=i,exports.generateElement=p,exports.importCode=(e,r)=>{const t={};return l(s(e),o({},r,{exports:t})),t},exports.useRunner=r=>{let{code:t,scope:n,disableCache:o}=r;const s=e.useRef(!0),u=e.useRef(null),[c,l]=e.useState(()=>{const r=e.createElement(a,{code:t,scope:n,onRendered:e=>{e?l({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(a,{code:t,scope:n,onRendered:e=>{e?l({element:o?null:u.current,error:e.toString()}):u.current=r}});l({element:r,error:null})},[t,n,o]),c}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{isValidElement as r,createElement as t,Component as o,useRef as n,useState as s,useEffect as c}from"react";import{transform as l}from"sucrase";function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},u.apply(this,arguments)}const p=e=>l(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),i=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,d=["default","import"],a=(r,t)=>{const{import:o}=t,n=function(e,r){if(null==e)return{};var t,o,n={},s=Object.keys(e);for(o=0;o<s.length;o++)r.indexOf(t=s[o])>=0||(n[t]=e[t]);return n}(t,d),s=u({React:e,require:m(o)},n),c=Object.keys(s),l=c.map(e=>s[e]);return new Function(...c,r)(...l)},f=e=>{const{code:o,scope:n}=e;if(!o.trim())return null;const s={};a(p((e=>e.replace(i,"$1export default $2$3"))(o)),u({render:e=>{s.default=e}},n,{exports:s}));const c=s.default;return c?r(c)?c:"function"==typeof c?t(c):"string"==typeof c?c:null:null},m=(e={})=>r=>{if(!e.hasOwnProperty(r))throw new Error(`Module not found: '${r}'`);return e[r]},h=(e,r)=>{const t={};return a(p(e),u({},r,{exports:t})),t};class v extends o{constructor(...e){super(...e),this.state={element:null,error:null,prevCode:null,prevScope:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:f(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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}}const y=({code:e,scope:r,disableCache:o})=>{const l=n(!0),u=n(null),[p,i]=s(()=>{const n=t(v,{code:e,scope:r,onRendered:e=>{e?i({element:o?null:u.current,error:e.toString()}):u.current=n}});return{element:n,error:null}});return c(()=>{if(l.current)return void(l.current=!1);const n=t(v,{code:e,scope:r,onRendered:e=>{e?i({element:o?null:u.current,error:e.toString()}):u.current=n}});i({element:n,error:null})},[e,r,o]),p};export{v as Runner,m as createRequire,f as generateElement,h as importCode,y as useRunner}; | ||
import e,{isValidElement as r,createElement as t,Component as o,useRef as n,useState as s,useEffect as c}from"react";import{transform as l}from"sucrase";function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},u.apply(this,arguments)}const p=e=>l(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),i=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,d=["default","import"],a=(r,t)=>{const{import:o}=t,n=function(e,r){if(null==e)return{};var t,o,n={},s=Object.keys(e);for(o=0;o<s.length;o++)r.indexOf(t=s[o])>=0||(n[t]=e[t]);return n}(t,d),s=u({React:e,require:m(o)},n),c=Object.keys(s),l=c.map(e=>s[e]);return new Function(...c,r)(...l)},f=e=>{const{code:o,scope:n}=e;if(!o.trim())return null;const s={};a(p((e=>e.replace(i,"$1export default $2$3"))(o)),u({render:e=>{s.default=e}},n,{exports:s}));const c=s.default;return c?r(c)?c:"function"==typeof c?t(c):"string"==typeof c?c:null:null},m=(e={})=>r=>{if(!e.hasOwnProperty(r))throw new Error(`Module not found: '${r}'`);return e[r]},v=(e,r)=>{const t={};return a(p(e),u({},r,{exports:t})),t};class h extends o{constructor(...e){super(...e),this.state={element:null,error:null,prevCode:null,prevScope:void 0}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:f(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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}}const y=({code:e,scope:r,disableCache:o})=>{const l=n(!0),u=n(null),[p,i]=s(()=>{const n=t(h,{code:e,scope:r,onRendered:e=>{e?i({element:o?null:u.current,error:e.toString()}):u.current=n}});return{element:n,error:null}});return c(()=>{if(l.current)return void(l.current=!1);const n=t(h,{code:e,scope:r,onRendered:e=>{e?i({element:o?null:u.current,error:e.toString()}):u.current=n}});i({element:n,error:null})},[e,r,o]),p};export{h as Runner,m as createRequire,f as generateElement,v as importCode,y 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 s(){return s=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},s.apply(this,arguments)}const u=e=>t.transform(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),c=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,l=["default","import"],i=(e,r)=>{const{import:t}=r,n=function(e,r){if(null==e)return{};var t,n,o={},s=Object.keys(e);for(n=0;n<s.length;n++)r.indexOf(t=s[n])>=0||(o[t]=e[t]);return o}(r,l),u=s({React:o.default,require:a(t)},n),c=Object.keys(u),i=c.map(e=>u[e]);return new Function(...c,e)(...i)},p=e=>{const{code:t,scope:n}=e;if(!t.trim())return null;const o={};i(u((e=>e.replace(c,"$1export default $2$3"))(t)),s({render:e=>{o.default=e}},n,{exports:o}));const l=o.default;return l?r.isValidElement(l)?l:"function"==typeof l?r.createElement(l):"string"==typeof l?l:null:null},a=function(e){return void 0===e&&(e={}),r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]}};class d extends r.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null,prevScope:null}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:p(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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=d,e.createRequire=a,e.generateElement=p,e.importCode=(e,r)=>{const t={};return i(u(e),s({},r,{exports:t})),t},e.useRunner=e=>{let{code:t,scope:n,disableCache:o}=e;const s=r.useRef(!0),u=r.useRef(null),[c,l]=r.useState(()=>{const e=r.createElement(d,{code:t,scope:n,onRendered:r=>{r?l({element:o?null:u.current,error:r.toString()}):u.current=e}});return{element:e,error:null}});return r.useEffect(()=>{if(s.current)return void(s.current=!1);const e=r.createElement(d,{code:t,scope:n,onRendered:r=>{r?l({element:o?null:u.current,error:r.toString()}):u.current=e}});l({element:e,error:null})},[t,n,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 s(){return s=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},s.apply(this,arguments)}const u=e=>t.transform(e,{transforms:["jsx","typescript","imports"],production:!0}).code.substring(13),c=/^(\s*)(<[^>]*>|function[\(\s]|\(\)[\s=]|class\s)(.*)/,l=["default","import"],i=(e,r)=>{const{import:t}=r,n=function(e,r){if(null==e)return{};var t,n,o={},s=Object.keys(e);for(n=0;n<s.length;n++)r.indexOf(t=s[n])>=0||(o[t]=e[t]);return o}(r,l),u=s({React:o.default,require:a(t)},n),c=Object.keys(u),i=c.map(e=>u[e]);return new Function(...c,e)(...i)},p=e=>{const{code:t,scope:n}=e;if(!t.trim())return null;const o={};i(u((e=>e.replace(c,"$1export default $2$3"))(t)),s({render:e=>{o.default=e}},n,{exports:o}));const l=o.default;return l?r.isValidElement(l)?l:"function"==typeof l?r.createElement(l):"string"==typeof l?l:null:null},a=function(e){return void 0===e&&(e={}),r=>{if(!e.hasOwnProperty(r))throw new Error("Module not found: '"+r+"'");return e[r]}};class d extends r.Component{constructor(){super(...arguments),this.state={element:null,error:null,prevCode:null,prevScope:void 0}}static getDerivedStateFromProps(e,r){if(r.prevCode===e.code&&r.prevScope===e.scope)return null;try{return{element:p(e),error:null,prevCode:e.code,prevScope:e.scope}}catch(r){return{element:null,error:r,prevCode:e.code,prevScope:e.scope}}}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||e.scope!==this.props.scope||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=d,e.createRequire=a,e.generateElement=p,e.importCode=(e,r)=>{const t={};return i(u(e),s({},r,{exports:t})),t},e.useRunner=e=>{let{code:t,scope:n,disableCache:o}=e;const s=r.useRef(!0),u=r.useRef(null),[c,l]=r.useState(()=>{const e=r.createElement(d,{code:t,scope:n,onRendered:r=>{r?l({element:o?null:u.current,error:r.toString()}):u.current=e}});return{element:e,error:null}});return r.useEffect(()=>{if(s.current)return void(s.current=!1);const e=r.createElement(d,{code:t,scope:n,onRendered:r=>{r?l({element:o?null:u.current,error:r.toString()}):u.current=e}});l({element:e,error:null})},[t,n,o]),c}}); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -11,3 +11,3 @@ import { Component, ReactElement } from 'react'; | ||
prevCode: string | null; | ||
prevScope: Scope | null; | ||
prevScope: Scope | undefined; | ||
}; | ||
@@ -14,0 +14,0 @@ export declare class Runner extends Component<RunnerProps, RunnerState> { |
export declare type Scope = Record<string, any> & { | ||
/** scope used by import statement */ | ||
import?: Scope; | ||
import?: Record<string, any>; | ||
}; | ||
@@ -5,0 +5,0 @@ export declare type RunnerOptions = { |
{ | ||
"name": "react-runner", | ||
"version": "1.0.0-rc.2", | ||
"version": "1.0.0-rc.3", | ||
"description": "Run your React code on the go", | ||
@@ -70,3 +70,3 @@ "homepage": "https://react-runner.vercel.app", | ||
}, | ||
"gitHead": "3db936f947d4d7d59816cc31d2aaa7fe1e121b6d" | ||
"gitHead": "08ffe63a8197f0b819d3af17e8b5119cb6238b8c" | ||
} |
@@ -33,3 +33,3 @@ # React Runner | ||
- **code** `string`, _required_ the code to be ran | ||
- **scope** `object` globals that could be used in `code`, **must be memoized** | ||
- **scope** `object` globals that could be used in `code` | ||
@@ -98,4 +98,5 @@ ## Usage | ||
- [Storybook Addon](https://github.com/nihgwu/storybook-addon-react-runner) | ||
- [CodeMirror for React Runner](https://github.com/nihgwu/react-runner/tree/master/packages/react-runner-codemirror) | ||
- [Play React](https://play-react.vercel.app/) | ||
- [CodeMirror for React Runner](https://react-runner-codemirror.vercel.app/) | ||
- [Storybook Addon](https://storybook.js.org/addons/storybook-addon-react-runner/) | ||
@@ -102,0 +103,0 @@ ## react-live-runner |
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
54456
174