@plasmicapp/loader-react
Advanced tools
Comparing version 1.0.22 to 1.0.24
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@plasmicapp/host"),r=require("@plasmicapp/loader-core"),n=require("react"),o=t(n),i=t(require("react-dom")),a=t(require("pascalcase")),u=t(require("react-dom/server"));function s(t,e,r,n,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){s(i,n,o,a,u,"next",t)}function u(t){s(i,n,o,a,u,"throw",t)}a(void 0)}))}}function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function p(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return f(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(t,e){for(var r=[].concat(e),n=new Set(e),o=new Map(t.map((function(t){return[t.id,t]}))),i=[];r.length>0;){var a=r.splice(0,1),u=o.get(a[0]);u&&(i.push(u),u.usedComponents.forEach((function(t){n.has(t)||(n.add(t),r.push(t))})))}return i}function d(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];if(0===n.length)return{entryCompMetas:t.components,bundle:t,remoteFontUrls:[]};var i=h(t.components,n.map((function(t){return t.id}))),a=i.map((function(t){return t.entry})),u=r.getBundleSubset.apply(void 0,[t,"entrypoint.css"].concat(a,["root-provider.js"],t.globalGroups.map((function(t){return t.contextFile})))),s=[];return u.projects.forEach((function(t){return s.push.apply(s,t.remoteFonts.map((function(t){return t.url})))})),{entryCompMetas:n,bundle:u,remoteFontUrls:s}}function m(t,e){var r=new Set(t.components.map((function(t){return t.id}))),n=e.components.filter((function(t){return!r.has(t.id)}));n.length>0&&(t=l({},t,{components:[].concat(t.components,n)}));var o=new Set(t.projects.map((function(t){return t.id}))),i=e.projects.filter((function(t){return!o.has(t.id)}));i.length>0&&(t=l({},t,{projects:[].concat(t.projects,i)}));var a=new Set(t.modules.map((function(t){return t.fileName}))),u=e.modules.filter((function(t){return!a.has(t.fileName)}));u.length>0&&(t=l({},t,{modules:[].concat(t.modules,u)}));var s=new Set(t.globalGroups.map((function(t){return t.id}))),c=e.globalGroups.filter((function(t){return!s.has(t.id)}));c.length>0&&(t=l({},t,{globalGroups:[].concat(t.globalGroups,c)}));var f=new Set(t.external),p=t.external.filter((function(t){return!f.has(t)}));return p.length>0&&(t=l({},t,{external:[].concat(t.external,p)})),t}function v(t,e){return t(e={exports:{}},e.exports),e.exports}var y=v((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new j(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=w(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,i),o}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var l={};function f(){}function p(){}function h(){}var d={};d[o]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(P([])));v&&v!==e&&r.call(v,o)&&(d=v);var y=h.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var s=c(t[o],t,i);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(s.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=y.constructor=h,h.constructor=p,p.displayName=u(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(b.prototype),b.prototype[i]=function(){return this},t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),u(y,a,"Generator"),y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function g(){var t=n.useState(0)[1];return n.useCallback((function(){t((function(t){return t+1}))}),[])}function b(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;var r=C(t),n=C(e);return(w(r)&&w(n)&&r.name===n.name&&r.isCode===n.isCode||x(r)&&x(n)&&r.path===n.path)&&r.projectId===n.projectId}function w(t){return"name"in t}function x(t){return"path"in t}function C(t){var e,r,n="string"==typeof t?t:t.name,o="string"==typeof t?void 0:t.projectId,i="string"==typeof t?void 0:t.isCode;return!0!==i&&n.startsWith("/")?{path:(r=n,r.trim()),projectId:o}:{name:(e=n,a(e).trim()),projectId:o,isCode:i}}function j(t,e){var r=C(e);return t.find((function(t){return function(t,e){return!(t.projectId&&e.projectId!==t.projectId||(w(t)?t.name!==e.name||null!=t.isCode&&t.isCode!==e.isCode:t.path!==e.path))}(r,t)}))}function P(t){return"string"==typeof t?t:t.projectId?t.name+" (project "+t.projectId+")":t.name}var E=function(){function t(t,e){this.bundle=t,this.registry=e}var e=t.prototype;return e.getComponent=function(t,e){void 0===e&&(e={});var r=j(this.bundle.components,t);if(!r)throw new Error("Component not found: "+t);var n=r.entry;if(!this.registry.hasModule(n,e))throw new Error("Component not yet fetched: "+r.name);return this.registry.load(n,{forceOriginal:e.forceOriginal}).default},e.hasComponent=function(t){var e=j(this.bundle.components,t);return!!e&&this.registry.hasModule(e.entry)},e.getGlobalContexts=function(){var t=this;return this.bundle.globalGroups.filter((function(t){return"global-user-defined"===t.type})).map((function(e){return{meta:e,context:t.registry.load(e.contextFile).default}}))},e.getRootProvider=function(){return this.registry.load("root-provider.js").default},e.getCss=function(){return this.bundle.modules.filter((function(t){return"asset"===t.type&&t.fileName.endsWith("css")}))},e.getRemoteFonts=function(){return this.bundle.projects.flatMap((function(t){return t.remoteFonts}))},t}(),_=n.createContext(void 0);function L(t){var e=t.globalVariants,r=t.prefetchedData,o=t.children,i=t.loader.__internal;r&&i.registerPrefetchedBundle(null==r?void 0:r.bundle);var a=n.useMemo((function(){return{globalVariants:e,loader:i}}),[e,i]);return n.createElement(_.Provider,{value:a},n.createElement(k,{loader:i,prefetchedData:r}),o)}var k=n.memo((function(t){var e=t.loader,r=t.prefetchedData,o=n.useState(!!r),i=o[1],a=function(t,e){var r=e&&new Set(["entrypoint.css"].concat(e.map((function(t){return t.cssFile})))),n=t.getLookup().getCss().filter((function(t){return!r||r.has(t.fileName)})),o=function(t){return"entrypoint.css"===t?0:1};return n.sort((function(t,e){return o(t.fileName)!==o(e.fileName)?o(t.fileName)-o(e.fileName):t.fileName.localeCompare(e.fileName)})),"\n "+t.getLookup().getRemoteFonts().map((function(t){return"@import url('"+t.url+"');"})).join("\n")+"\n "+n.map((function(t){return t.source})).join("\n")+"\n "}(e,o[0]&&r?r.bundle.components:void 0),u=g(),s=n.useMemo((function(){return{onDataFetched:function(){i(!1),u()}}}),[e,u]);return n.useEffect((function(){return e.subscribePlasmicRoot(s),function(){return e.unsubscribePlasmicRoot(s)}}),[s,e]),n.createElement("style",{dangerouslySetInnerHTML:{__html:a}})}));function O(){return n.useContext(_)}function S(t,e){return function(){var r,n=O();if(n){var o=[].concat(n.loader.getGlobalVariants(),null!=(r=n.globalVariants)?r:[]).find((function(r){return r.name===t&&(!r.projectId||r.projectId===e)}));return o?o.value:void 0}}}var F=function(){function t(t){this.subs=[],this.roots=[],this.globalVariants=[],this.bundle={modules:[],components:[],globalGroups:[],external:[],projects:[]},this.registry=new r.Registry,this.fetcher=new r.PlasmicModulesFetcher(t)}var n=t.prototype;return n.setGlobalVariants=function(t){this.globalVariants=t},n.getGlobalVariants=function(){return this.globalVariants},n.registerModules=function(t){this.registry.isEmpty()||(console.warn("Calling PlasmicComponentLoader.registerModules() after Plasmic component has rendered; starting over."),this.registry.clear());for(var e=0,r=Object.keys(t);e<r.length;e++){var n=r[e];this.registry.register(n,t[n])}},n.substituteComponent=function(t,e){this.registry.isEmpty()||(console.warn("Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over."),this.registry.clear()),this.subs.push({lookup:e,component:t})},n.registerComponent=function(t,r){var n;this.substituteComponent(t,{name:r.name,isCode:!0}),e.registerComponent(t,l({},r,{importPath:null!=(n=r.importPath)?n:""}))},n.registerPrefetchedBundle=function(t){this.mergeBundle(t)},n.subscribePlasmicRoot=function(t){this.roots.push(t)},n.unsubscribePlasmicRoot=function(t){var e=this.roots.indexOf(t);e>=0&&this.roots.splice(e,1)},n.clearCache=function(){this.bundle={modules:[],components:[],globalGroups:[],external:[],projects:[]},this.registry.clear()},n.maybeGetCompMetas=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return G(this.bundle.components,e)},n.maybeFetchComponentData=function(){var t=c(y.mark((function t(){var e,r,n,o,i,a=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.maybeGetCompMetas.apply(this,a),r=e.found,0!==(n=e.missing).length){t.next=3;break}return t.abrupt("return",d.apply(void 0,[this.bundle].concat(r)));case 3:return t.next=5,this.fetchMissingData({missingSpecs:n});case 5:if(o=this.maybeGetCompMetas.apply(this,a),i=o.found,!(o.missing.length>0)){t.next=8;break}return t.abrupt("return",null);case 8:return t.abrupt("return",d.apply(void 0,[this.bundle].concat(i)));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.fetchComponentData=function(){var t=c(y.mark((function t(){var e,r,n,o=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.maybeFetchComponentData.apply(this,o);case 2:if(e=t.sent){t.next=6;break}throw r=this.maybeGetCompMetas.apply(this,o),n=r.missing,new Error("Unable to find components "+n.map(P).join(", "));case 6:return t.abrupt("return",e);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.fetchPages=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetchAllData();case 2:return t.abrupt("return",t.sent.components.filter((function(t){return t.isPage&&t.path})));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.fetchComponents=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetchAllData();case 2:return t.abrupt("return",t.sent.components);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getLookup=function(){return new E(this.bundle,this.registry)},n.fetchMissingData=function(){var t=c(y.mark((function t(e){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.fetchAllData());case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.fetchAllData=function(){var t=c(y.mark((function t(){var e;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.ensureFetcher().fetchAllData();case 2:return this.mergeBundle(e=t.sent),this.roots.forEach((function(t){return null==t.onDataFetched?void 0:t.onDataFetched()})),t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.mergeBundle=function(t){this.bundle=m(t,this.bundle),this.refreshRegistry()},n.refreshRegistry=function(){for(var t,e=p(this.subs);!(t=e()).done;){var r=t.value,n=j(this.bundle.components,r.lookup);n&&this.registry.register(n.entry,{default:r.component})}for(var o,i=p(this.bundle.globalGroups);!(o=i()).done;){var a,u=o.value;"global-screen"!==u.type&&this.registry.register(u.contextFile,((a={})[u.useName]=S(u.name,u.projectId),a))}this.registry.updateModules(this.bundle)},n.ensureFetcher=function(){if(!this.fetcher)throw new Error("You must first call PlasmicComponentLoader.init()");return this.fetcher},t}();function G(t,e){for(var r,n=[],o=[],i=p(e);!(r=i()).done;){var a=r.value,u=j(t,a);u?n.push(u):o.push(a)}return{found:n,missing:o}}var D=function(){function t(t){this.warnedRegisterComponent=!1,this.__internal=t}var e=t.prototype;return e.setGlobalVariants=function(t){this.__internal.setGlobalVariants(t)},e.registerModules=function(t){this.__internal.registerModules(t)},e.substituteComponent=function(t,e){this.__internal.substituteComponent(t,e)},e.registerComponent=function(t,e){e&&"object"==typeof e&&"props"in e?this.__internal.registerComponent(t,e):this.substituteComponent(t,e)},e.fetchComponentData=function(){var t=c(y.mark((function t(){var e,r=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(e=this.__internal).fetchComponentData.apply(e,r));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.maybeFetchComponentData=function(){var t=c(y.mark((function t(){var e,r=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(e=this.__internal).maybeFetchComponentData.apply(e,r));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.fetchPages=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.__internal.fetchPages());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.fetchComponents=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.__internal.fetchComponents());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.clearCache=function(){return this.__internal.clearCache()},t}();function I(t,e){void 0===e&&(e={});var r=O();if(!r)throw new Error("You can only use usePlasmicComponent if wrapped in <PlasmicRootProvider />");var o=r.loader,i=o.getLookup(),a=i.hasComponent(t)?i.getComponent(t,e):void 0,u=function(t){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var o=n.useState(e),i=o[0],a=o[1];return n.useEffect((function(){(e.length!==i.length||e.some((function(t,e){return!b(t,i[e])})))&&a(e)}),[e,i]),i}(t)[0]}(t),s=function(){var t=n.useRef(!1),e=n.useCallback((function(){return t.current}),[]);return n.useEffect((function(){return t.current=!0,function(){t.current=!1}}),[]),e}(),l=g();return n.useEffect((function(){a||c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.fetchComponentData(u);case 2:s()&&l();case 3:case"end":return t.stop()}}),t)})))()}),[a,u]),a}var M=n.createContext(!1);function N(t){var e=t.component,r=t.projectId,o=t.componentProps,i=t.forceOriginal,a=O(),u=!n.useContext(M);if(!a)throw new Error("You must use <PlasmicRootProvider/> at the root of your app");var s=a.loader.getLookup(),c=I({name:e,projectId:r},{forceOriginal:i});if(!c)return null;var l=n.createElement(c,Object.assign({},o));if(u){var f=s.getRootProvider();l=n.createElement(f,null,n.createElement(M.Provider,{value:!0},l))}return l}function R(){return(R=c(y.mark((function t(e,r,n,o){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===o&&(o={}),t.abrupt("return",new Promise((function(t){var a=V(e,n,o);i.render(a,r,(function(){return t()}))})));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function A(){return(A=c(y.mark((function t(e,r,n,o){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===o&&(o={}),t.abrupt("return",new Promise((function(t){var a=V(e,n,o);i.hydrate(a,r,(function(){return t()}))})));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function V(t,e,r){return void 0===r&&(r={}),o.createElement(L,{loader:t,prefetchedData:r.prefetchedData,globalVariants:r.globalVariants},o.createElement(N,{component:"string"==typeof e?e:e.name,projectId:"string"==typeof e?void 0:e.projectId,componentProps:r.componentProps}))}Object.defineProperty(exports,"PlasmicCanvasContext",{enumerable:!0,get:function(){return e.PlasmicCanvasContext}}),Object.defineProperty(exports,"PlasmicCanvasHost",{enumerable:!0,get:function(){return e.PlasmicCanvasHost}}),Object.defineProperty(exports,"repeatedElement",{enumerable:!0,get:function(){return e.repeatedElement}}),exports.PlasmicComponent=N,exports.PlasmicComponentLoader=D,exports.PlasmicRootProvider=L,exports.convertBundlesToComponentRenderData=function(t,e){if(0===t.length)return null;var r=t.reduce((function(t,e){return m(t,e)}));return d.apply(void 0,[r].concat(e))},exports.hydrateFromElement=function(t,e,r,n){return A.apply(this,arguments)},exports.initPlasmicLoader=function(t){var e=new F(t);return e.registerModules({react:o,"react-dom":i}),new D(e)},exports.renderToElement=function(t,e,r,n){return R.apply(this,arguments)},exports.renderToString=function(t,e,r){void 0===r&&(r={});var n=V(t,e,r);return u.renderToString(n)},exports.usePlasmicComponent=I; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@plasmicapp/host"),r=require("@plasmicapp/loader-core"),n=require("react"),o=t(n),i=t(require("react-dom")),a=t(require("pascalcase")),u=t(require("react-dom/server"));function s(t,e,r,n,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){s(i,n,o,a,u,"next",t)}function u(t){s(i,n,o,a,u,"throw",t)}a(void 0)}))}}function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function p(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return f(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(t,e){for(var r=[].concat(e),n=new Set(e),o=new Map(t.map((function(t){return[t.id,t]}))),i=[];r.length>0;){var a=r.splice(0,1),u=o.get(a[0]);u&&(i.push(u),u.usedComponents.forEach((function(t){n.has(t)||(n.add(t),r.push(t))})))}return i}function d(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];if(0===n.length)return{entryCompMetas:t.components,bundle:t,remoteFontUrls:[]};var i=h(t.components,n.map((function(t){return t.id}))),a=i.map((function(t){return t.entry})),u=r.getBundleSubset.apply(void 0,[t,"entrypoint.css"].concat(a,["root-provider.js"],t.globalGroups.map((function(t){return t.contextFile})))),s=[];return u.projects.forEach((function(t){return s.push.apply(s,t.remoteFonts.map((function(t){return t.url})))})),{entryCompMetas:n,bundle:u,remoteFontUrls:s}}function m(t,e){var r=new Set(t.components.map((function(t){return t.id}))),n=e.components.filter((function(t){return!r.has(t.id)}));n.length>0&&(t=l({},t,{components:[].concat(t.components,n)}));var o=new Set(t.projects.map((function(t){return t.id}))),i=e.projects.filter((function(t){return!o.has(t.id)}));i.length>0&&(t=l({},t,{projects:[].concat(t.projects,i)}));var a=new Set(t.modules.map((function(t){return t.fileName}))),u=e.modules.filter((function(t){return!a.has(t.fileName)}));u.length>0&&(t=l({},t,{modules:[].concat(t.modules,u)}));var s=new Set(t.globalGroups.map((function(t){return t.id}))),c=e.globalGroups.filter((function(t){return!s.has(t.id)}));c.length>0&&(t=l({},t,{globalGroups:[].concat(t.globalGroups,c)}));var f=new Set(t.external),p=t.external.filter((function(t){return!f.has(t)}));return p.length>0&&(t=l({},t,{external:[].concat(t.external,p)})),t}function v(t,e){return t(e={exports:{}},e.exports),e.exports}var y=v((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new j(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=w(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,i),o}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var l={};function f(){}function p(){}function h(){}var d={};d[o]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(P([])));v&&v!==e&&r.call(v,o)&&(d=v);var y=h.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var s=c(t[o],t,i);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(s.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=y.constructor=h,h.constructor=p,p.displayName=u(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(b.prototype),b.prototype[i]=function(){return this},t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),u(y,a,"Generator"),y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function g(){var t=n.useState(0)[1];return n.useCallback((function(){t((function(t){return t+1}))}),[])}function b(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;var r=C(t),n=C(e);return(w(r)&&w(n)&&r.name===n.name&&r.isCode===n.isCode||x(r)&&x(n)&&r.path===n.path)&&r.projectId===n.projectId}function w(t){return"name"in t}function x(t){return"path"in t}function C(t){var e,r,n="string"==typeof t?t:t.name,o="string"==typeof t?void 0:t.projectId,i="string"==typeof t?void 0:t.isCode;return!0!==i&&n.startsWith("/")?{path:(r=n,r.trim()),projectId:o}:{name:(e=n,a(e).trim()),projectId:o,isCode:i}}function j(t,e){var r=C(e);return t.find((function(t){return function(t,e){return!(t.projectId&&e.projectId!==t.projectId||(w(t)?t.name!==e.name||null!=t.isCode&&t.isCode!==e.isCode:t.path!==e.path))}(r,t)}))}function P(t){return"string"==typeof t?t:t.projectId?t.name+" (project "+t.projectId+")":t.name}var E=function(){function t(t,e){this.bundle=t,this.registry=e}var e=t.prototype;return e.getComponent=function(t,e){void 0===e&&(e={});var r=j(this.bundle.components,t);if(!r)throw new Error("Component not found: "+t);var n=r.entry;if(!this.registry.hasModule(n,e))throw new Error("Component not yet fetched: "+r.name);return this.registry.load(n,{forceOriginal:e.forceOriginal}).default},e.hasComponent=function(t){var e=j(this.bundle.components,t);return!!e&&this.registry.hasModule(e.entry)},e.getGlobalContexts=function(){var t=this;return this.bundle.globalGroups.filter((function(t){return"global-user-defined"===t.type})).map((function(e){return{meta:e,context:t.registry.load(e.contextFile).default}}))},e.getRootProvider=function(){return this.registry.load("root-provider.js").default},e.getCss=function(){return this.bundle.modules.filter((function(t){return"asset"===t.type&&t.fileName.endsWith("css")}))},e.getRemoteFonts=function(){return this.bundle.projects.flatMap((function(t){return t.remoteFonts}))},t}(),_=n.createContext(void 0);function k(t){var e=t.globalVariants,r=t.prefetchedData,o=t.children,i=t.skipCss,a=t.skipFonts,u=t.loader.__internal;r&&u.registerPrefetchedBundle(null==r?void 0:r.bundle);var s=n.useMemo((function(){return{globalVariants:e,loader:u}}),[e,u]);return n.createElement(_.Provider,{value:s},!i&&n.createElement(L,{loader:u,prefetchedData:r,skipFonts:a}),o)}var L=n.memo((function(t){var e=t.loader,r=t.prefetchedData,o=t.skipFonts,i=n.useState(!!r),a=i[1],u=function(t,e){var r=e.scopedCompMetas,n=e.skipFonts,o=r&&new Set(["entrypoint.css"].concat(r.map((function(t){return t.cssFile})))),i=t.getLookup().getCss().filter((function(t){return!o||o.has(t.fileName)})),a=function(t){return"entrypoint.css"===t?0:1};i.sort((function(t,e){return a(t.fileName)!==a(e.fileName)?a(t.fileName)-a(e.fileName):t.fileName.localeCompare(e.fileName)}));var u=t.getLookup().getRemoteFonts();return"\n "+(n?"":u.map((function(t){return"@import url('"+t.url+"');"})).join("\n"))+"\n "+i.map((function(t){return t.source})).join("\n")+"\n "}(e,{scopedCompMetas:i[0]&&r?r.bundle.components:void 0,skipFonts:o}),s=g(),c=n.useMemo((function(){return{onDataFetched:function(){a(!1),s()}}}),[e,s]);return n.useEffect((function(){return e.subscribePlasmicRoot(c),function(){return e.unsubscribePlasmicRoot(c)}}),[c,e]),n.createElement("style",{dangerouslySetInnerHTML:{__html:u}})}));function F(){return n.useContext(_)}function O(t,e){return function(){var r,n=F();if(n){var o=[].concat(n.loader.getGlobalVariants(),null!=(r=n.globalVariants)?r:[]).find((function(r){return r.name===t&&(!r.projectId||r.projectId===e)}));return o?o.value:void 0}}}var S=function(){function t(t){this.subs=[],this.roots=[],this.globalVariants=[],this.bundle={modules:[],components:[],globalGroups:[],external:[],projects:[]},this.registry=new r.Registry,this.fetcher=new r.PlasmicModulesFetcher(t)}var n=t.prototype;return n.setGlobalVariants=function(t){this.globalVariants=t},n.getGlobalVariants=function(){return this.globalVariants},n.registerModules=function(t){this.registry.isEmpty()||(console.warn("Calling PlasmicComponentLoader.registerModules() after Plasmic component has rendered; starting over."),this.registry.clear());for(var e=0,r=Object.keys(t);e<r.length;e++){var n=r[e];this.registry.register(n,t[n])}},n.substituteComponent=function(t,e){this.registry.isEmpty()||(console.warn("Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over."),this.registry.clear()),this.subs.push({lookup:e,component:t})},n.registerComponent=function(t,r){var n;this.substituteComponent(t,{name:r.name,isCode:!0}),e.registerComponent(t,l({},r,{importPath:null!=(n=r.importPath)?n:""}))},n.registerPrefetchedBundle=function(t){this.mergeBundle(t)},n.subscribePlasmicRoot=function(t){this.roots.push(t)},n.unsubscribePlasmicRoot=function(t){var e=this.roots.indexOf(t);e>=0&&this.roots.splice(e,1)},n.clearCache=function(){this.bundle={modules:[],components:[],globalGroups:[],external:[],projects:[]},this.registry.clear()},n.maybeGetCompMetas=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return G(this.bundle.components,e)},n.maybeFetchComponentData=function(){var t=c(y.mark((function t(){var e,r,n,o,i,a=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.maybeGetCompMetas.apply(this,a),r=e.found,0!==(n=e.missing).length){t.next=3;break}return t.abrupt("return",d.apply(void 0,[this.bundle].concat(r)));case 3:return t.next=5,this.fetchMissingData({missingSpecs:n});case 5:if(o=this.maybeGetCompMetas.apply(this,a),i=o.found,!(o.missing.length>0)){t.next=8;break}return t.abrupt("return",null);case 8:return t.abrupt("return",d.apply(void 0,[this.bundle].concat(i)));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.fetchComponentData=function(){var t=c(y.mark((function t(){var e,r,n,o=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.maybeFetchComponentData.apply(this,o);case 2:if(e=t.sent){t.next=6;break}throw r=this.maybeGetCompMetas.apply(this,o),n=r.missing,new Error("Unable to find components "+n.map(P).join(", "));case 6:return t.abrupt("return",e);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.fetchPages=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetchAllData();case 2:return t.abrupt("return",t.sent.components.filter((function(t){return t.isPage&&t.path})));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.fetchComponents=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetchAllData();case 2:return t.abrupt("return",t.sent.components);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getLookup=function(){return new E(this.bundle,this.registry)},n.fetchMissingData=function(){var t=c(y.mark((function t(e){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.fetchAllData());case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.fetchAllData=function(){var t=c(y.mark((function t(){var e;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.ensureFetcher().fetchAllData();case 2:return this.mergeBundle(e=t.sent),this.roots.forEach((function(t){return null==t.onDataFetched?void 0:t.onDataFetched()})),t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.mergeBundle=function(t){this.bundle=m(t,this.bundle),this.refreshRegistry()},n.refreshRegistry=function(){for(var t,e=p(this.subs);!(t=e()).done;){var r=t.value,n=j(this.bundle.components,r.lookup);n&&this.registry.register(n.entry,{default:r.component})}for(var o,i=p(this.bundle.globalGroups);!(o=i()).done;){var a,u=o.value;"global-screen"!==u.type&&this.registry.register(u.contextFile,((a={})[u.useName]=O(u.name,u.projectId),a))}this.registry.updateModules(this.bundle)},n.ensureFetcher=function(){if(!this.fetcher)throw new Error("You must first call PlasmicComponentLoader.init()");return this.fetcher},t}();function G(t,e){for(var r,n=[],o=[],i=p(e);!(r=i()).done;){var a=r.value,u=j(t,a);u?n.push(u):o.push(a)}return{found:n,missing:o}}var M=function(){function t(t){this.warnedRegisterComponent=!1,this.__internal=t}var e=t.prototype;return e.setGlobalVariants=function(t){this.__internal.setGlobalVariants(t)},e.registerModules=function(t){this.__internal.registerModules(t)},e.substituteComponent=function(t,e){this.__internal.substituteComponent(t,e)},e.registerComponent=function(t,e){e&&"object"==typeof e&&"props"in e?this.__internal.registerComponent(t,e):this.substituteComponent(t,e)},e.fetchComponentData=function(){var t=c(y.mark((function t(){var e,r=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(e=this.__internal).fetchComponentData.apply(e,r));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.maybeFetchComponentData=function(){var t=c(y.mark((function t(){var e,r=arguments;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(e=this.__internal).maybeFetchComponentData.apply(e,r));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.fetchPages=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.__internal.fetchPages());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.fetchComponents=function(){var t=c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.__internal.fetchComponents());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.clearCache=function(){return this.__internal.clearCache()},t}();function D(t,e){void 0===e&&(e={});var r=F();if(!r)throw new Error("You can only use usePlasmicComponent if wrapped in <PlasmicRootProvider />");var o=r.loader,i=o.getLookup(),a=i.hasComponent(t)?i.getComponent(t,e):void 0,u=function(t){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var o=n.useState(e),i=o[0],a=o[1];return n.useEffect((function(){(e.length!==i.length||e.some((function(t,e){return!b(t,i[e])})))&&a(e)}),[e,i]),i}(t)[0]}(t),s=function(){var t=n.useRef(!1),e=n.useCallback((function(){return t.current}),[]);return n.useEffect((function(){return t.current=!0,function(){t.current=!1}}),[]),e}(),l=g();return n.useEffect((function(){a||c(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.fetchComponentData(u);case 2:s()&&l();case 3:case"end":return t.stop()}}),t)})))()}),[a,u]),a}var I=n.createContext(!1);function N(t){var e=t.component,r=t.projectId,o=t.componentProps,i=t.forceOriginal,a=F(),u=!n.useContext(I);if(!a)throw new Error("You must use <PlasmicRootProvider/> at the root of your app");var s=a.loader.getLookup(),c=D({name:e,projectId:r},{forceOriginal:i});if(!c)return null;var l=n.createElement(c,Object.assign({},o));if(u){var f=s.getRootProvider();l=n.createElement(f,null,n.createElement(I.Provider,{value:!0},l))}return l}function R(){return(R=c(y.mark((function t(e,r,n,o){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===o&&(o={}),t.abrupt("return",new Promise((function(t){var a=V(e,n,o);i.render(a,r,(function(){return t()}))})));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function A(){return(A=c(y.mark((function t(e,r,n,o){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===o&&(o={}),t.abrupt("return",new Promise((function(t){var a=V(e,n,o);i.hydrate(a,r,(function(){return t()}))})));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function V(t,e,r){return void 0===r&&(r={}),o.createElement(k,{loader:t,prefetchedData:r.prefetchedData,globalVariants:r.globalVariants},o.createElement(N,{component:"string"==typeof e?e:e.name,projectId:"string"==typeof e?void 0:e.projectId,componentProps:r.componentProps}))}Object.defineProperty(exports,"PlasmicCanvasContext",{enumerable:!0,get:function(){return e.PlasmicCanvasContext}}),Object.defineProperty(exports,"PlasmicCanvasHost",{enumerable:!0,get:function(){return e.PlasmicCanvasHost}}),Object.defineProperty(exports,"repeatedElement",{enumerable:!0,get:function(){return e.repeatedElement}}),exports.PlasmicComponent=N,exports.PlasmicComponentLoader=M,exports.PlasmicRootProvider=k,exports.convertBundlesToComponentRenderData=function(t,e){if(0===t.length)return null;var r=t.reduce((function(t,e){return m(t,e)}));return d.apply(void 0,[r].concat(e))},exports.hydrateFromElement=function(t,e,r,n){return A.apply(this,arguments)},exports.initPlasmicLoader=function(t){var e=new S(t);return e.registerModules({react:o,"react-dom":i}),new M(e)},exports.renderToElement=function(t,e,r,n){return R.apply(this,arguments)},exports.renderToString=function(t,e,r){void 0===r&&(r={});var n=V(t,e,r);return u.renderToString(n)},exports.usePlasmicComponent=D; | ||
//# sourceMappingURL=loader-react.cjs.production.min.js.map |
@@ -33,4 +33,12 @@ import * as React from 'react'; | ||
children?: React.ReactNode; | ||
/** | ||
* If true, will skip rendering css | ||
*/ | ||
skipCss?: boolean; | ||
/** | ||
* If true, will skip installing fonts | ||
*/ | ||
skipFonts?: boolean; | ||
}): JSX.Element; | ||
export declare function usePlasmicRootContext(): PlasmicRootContextValue | undefined; | ||
export {}; |
{ | ||
"name": "@plasmicapp/loader-react", | ||
"version": "1.0.22", | ||
"version": "1.0.24", | ||
"module": "dist/loader-react.esm.js", | ||
@@ -24,4 +24,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@plasmicapp/host": "0.0.23", | ||
"@plasmicapp/loader-core": "1.0.13", | ||
"@plasmicapp/host": "0.0.25", | ||
"@plasmicapp/loader-core": "1.0.15", | ||
"pascalcase": "^1.0.0" | ||
@@ -28,0 +28,0 @@ }, |
Sorry, the diff of this file is too big to display
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 too big to display
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
467734
3896
+ Added@plasmicapp/host@0.0.25(transitive)
+ Added@plasmicapp/loader-core@1.0.15(transitive)
+ Added@plasmicapp/preamble@0.0.10(transitive)
- Removed@plasmicapp/host@0.0.23(transitive)
- Removed@plasmicapp/loader-core@1.0.13(transitive)
- Removed@plasmicapp/preamble@0.0.8(transitive)
Updated@plasmicapp/host@0.0.25