@plasmicapp/loader-core
Advanced tools
Comparing version 1.0.5 to 1.0.7
@@ -7,2 +7,3 @@ export interface ComponentMeta { | ||
skeletonFile: string; | ||
cssFile: string; | ||
path: string | undefined; | ||
@@ -9,0 +10,0 @@ isPage: boolean; |
@@ -829,2 +829,3 @@ 'use strict'; | ||
var VERSION = '1'; | ||
var Api = /*#__PURE__*/function () { | ||
@@ -835,3 +836,3 @@ function Api(opts) { | ||
this.opts = opts; | ||
this.host = (_opts$host = opts.host) != null ? _opts$host : 'https://studio.plasmic.app'; | ||
this.host = (_opts$host = opts.host) != null ? _opts$host : 'https://codegen.plasmic.app'; | ||
} | ||
@@ -938,3 +939,5 @@ | ||
_proto.makeGetHeaders = function makeGetHeaders() { | ||
return _extends({}, this.makeAuthHeaders()); | ||
return _extends({ | ||
'x-plasmic-loader-version': VERSION | ||
}, this.makeAuthHeaders()); | ||
} // @ts-ignore | ||
@@ -945,2 +948,3 @@ ; | ||
return _extends({ | ||
'x-plasmic-loader-version': VERSION, | ||
'Content-Type': 'application/json' | ||
@@ -1045,2 +1049,3 @@ }, this.makeAuthHeaders()); | ||
var namesSet = new Set(names); | ||
var graph = new DepsGraph(bundle); | ||
@@ -1050,5 +1055,10 @@ var deps = new Set(names.flatMap(function (name) { | ||
})); | ||
var isSubModule = function isSubModule(fileName) { | ||
return deps.has(fileName) || namesSet.has(fileName); | ||
}; | ||
return { | ||
modules: bundle.modules.filter(function (mod) { | ||
return deps.has(mod.fileName) || names.includes(mod.fileName); | ||
return isSubModule(mod.fileName); | ||
}), | ||
@@ -1058,3 +1068,5 @@ external: bundle.external.filter(function (dep) { | ||
}), | ||
components: bundle.components, | ||
components: bundle.components.filter(function (c) { | ||
return isSubModule(c.entry); | ||
}), | ||
globalGroups: bundle.globalGroups, | ||
@@ -1061,0 +1073,0 @@ projects: bundle.projects |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("isomorphic-unfetch"))&&"object"==typeof t&&"default"in t?t.default:t;function r(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function s(t){r(a,o,i,s,u,"next",t)}function u(t){r(a,o,i,s,u,"throw",t)}s(void 0)}))}}function o(){return(o=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 i(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 a(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 i(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)?i(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 s(t,e){return t(e={exports:{}},e.exports),e.exports}var u=s((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 s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new L(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 s=x(a,r);if(s){if(s===h)continue;return s}}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 u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.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=u;var h={};function l(){}function f(){}function d(){}var p={};p[o]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(p=y);var m=d.prototype=l.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var u=c(t[o],t,i);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(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,x(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;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,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function b(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function k(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 f.prototype=m.constructor=d,d.constructor=f,f.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),s(m,a,"Generator"),m[o]=function(){return this},m.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=k,L.prototype={constructor:L,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(j),!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 s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)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,h):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),h},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),j(r),h}},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;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}})),c=function(){function t(t){var e;this.opts=t,this.host=null!=(e=t.host)?e:"https://studio.plasmic.app"}var r=t.prototype;return r.fetchLoaderData=function(){var t=n(u.mark((function t(r,n){var o,i,a,s,c,h,l,f;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.platform,i=n.preview,a=new URLSearchParams([["platform",null!=o?o:"react"]].concat(r.map((function(t){return["projectId",t]})))).toString(),s=this.host+"/api/v1/loader/code/"+(i?"preview":"published")+"?"+a,t.next=5,e(s,{method:"GET",headers:this.makeGetHeaders()});case 5:if(!((c=t.sent).status>=400)){t.next=11;break}return t.next=9,c.json();case 9:throw f=t.sent,new Error(null!=(h=null==f||null==(l=f.error)?void 0:l.message)?h:c.statusText);case 11:return t.next=13,c.json();case 13:return t.abrupt("return",t.sent);case 15:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.fetchHtmlData=function(){var t=n(u.mark((function t(r){var n,o;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URLSearchParams([["projectId",r.projectId],["component",r.component],["embedHydrate",r.embedHydrate?"1":"0"],["hydrate",r.hydrate?"1":"0"]]).toString(),t.next=4,e(this.host+"/api/v1/loader/html?"+n,{method:"GET",headers:this.makeGetHeaders()});case 4:return o=t.sent,t.next=7,o.json();case 7:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.makeGetHeaders=function(){return o({},this.makeAuthHeaders())},r.makePostHeaders=function(){return o({"Content-Type":"application/json"},this.makeAuthHeaders())},r.makeAuthHeaders=function(){return{"x-plasmic-api-project-tokens":this.opts.projects.map((function(t){return t.id+":"+t.token})).join(",")}},t}(),h=function(){function t(t){this.bundle=t,this.dependsOn={},this.dependedBy={},this.rebuildGraph()}var e=t.prototype;return e.getTransitiveDependers=function(t){return this.transitiveCrawl(t,this.dependedBy)},e.getTransitiveDeps=function(t){return t in this.dependsOn?this.transitiveCrawl(t,this.dependsOn):[]},e.transitiveCrawl=function(t,e){for(var r,n=new Set,o=function t(r){if(!n.has(r)){n.add(r);for(var o,i=a(null!=(s=e[r])?s:[]);!(o=i()).done;){var s;t(o.value)}}},i=a(e[t]);!(r=i()).done;)o(r.value);return Array.from(n)},e.rebuildGraph=function(){this.dependedBy={},this.dependsOn={};for(var t,e=a(this.bundle.modules);!(t=e()).done;){var r=t.value;if("code"===r.type)for(var n,o=a(r.imports);!(n=o()).done;){var i=n.value;r.fileName in this.dependsOn?this.dependsOn[r.fileName].push(i):this.dependsOn[r.fileName]=[i],i in this.dependedBy?this.dependedBy[i].push(r.fileName):this.dependedBy[i]=[r.fileName]}}},t}(),l=function(){function t(t){this.opts=t,this.curFetch=void 0,this.api=new c({projects:t.projects,host:t.host})}var e=t.prototype;return e.fetchAllData=function(){var t=n(u.mark((function t(){var e;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.opts.cache){t.next=6;break}return t.next=3,this.opts.cache.get();case 3:if(!(e=t.sent)){t.next=6;break}return t.abrupt("return",e);case 6:if(!this.curFetch){t.next=10;break}return t.next=9,this.curFetch;case 9:return t.abrupt("return",t.sent);case 10:return console.debug("PlasmicLoader: doing a fresh fetch..."),this.curFetch=this.doFetch(),t.next=14,this.curFetch;case 14:return t.abrupt("return",t.sent);case 15:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.doFetch=function(){var t=n(u.mark((function t(){var e,r=this;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.api.fetchLoaderData(this.opts.projects.map((function(t){return t.version&&!r.opts.preview?t.id+"@"+t.version:t.id})),{platform:this.opts.platform,preview:this.opts.preview});case 2:if(e=t.sent,!this.opts.cache){t.next=6;break}return t.next=6,this.opts.cache.set(e);case 6:return t.abrupt("return",e);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),f=function(){function t(){this.loadedModules={},this.registeredModules={},this.modules={}}var e=t.prototype;return e.register=function(t,e){this.registeredModules[t]=e},e.isEmpty=function(){return 0===Object.keys(this.loadedModules).length},e.clear=function(){this.loadedModules={}},e.hasModule=function(t,e){return void 0===e&&(e={}),t in this.registeredModules&&!e.forceOriginal||t in this.modules},e.load=function(t,e){var r=this;if(void 0===e&&(e={}),t in this.registeredModules&&!e.forceOriginal)return this.registeredModules[t];if(t in this.loadedModules)return this.loadedModules[t];if(!(t in this.modules))throw new Error("Unknown module "+t);var n=new Function("require","exports",this.modules[t]),o={};return this.loadedModules[t]=o,n((function(e){var n=function(t,e){var r=e.split("/"),n=t.split("/");if(0===n.length)return t;if("."===n[0])return[].concat(r.slice(0,r.length-1),n.slice(1)).join("/");if(".."===n[0]){for(var o,i=0,s=a(n);!(o=s()).done&&".."===o.value;)i+=1;return[].concat(r.slice(0,r.length-i-1),n.slice(i)).join("/")}return t}(e,t);return r.load(n)}),o),o},e.updateModules=function(t){for(var e,r=!1,n=a(t.modules);!(e=n()).done;){var o=e.value;"code"===o.type&&o.code!==this.modules[o.fileName]&&(this.modules[o.fileName]=o.code,r=!0)}r&&this.clear()},t}();exports.Api=c,exports.PlasmicModulesFetcher=l,exports.Registry=f,exports.getBundleSubset=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];var o=new h(t),i=new Set(r.flatMap((function(t){return o.getTransitiveDeps(t)})));return{modules:t.modules.filter((function(t){return i.has(t.fileName)||r.includes(t.fileName)})),external:t.external.filter((function(t){return i.has(t)})),components:t.components,globalGroups:t.globalGroups,projects:t.projects}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("isomorphic-unfetch"))&&"object"==typeof t&&"default"in t?t.default:t;function r(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function s(t){r(a,o,i,s,u,"next",t)}function u(t){r(a,o,i,s,u,"throw",t)}s(void 0)}))}}function o(){return(o=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 i(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 a(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 i(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)?i(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 s(t,e){return t(e={exports:{}},e.exports),e.exports}var u=s((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 s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new L(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 s=x(a,r);if(s){if(s===h)continue;return s}}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 u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.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=u;var h={};function l(){}function f(){}function p(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var m=p.prototype=l.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var u=c(t[o],t,i);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(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,x(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;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,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function b(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function k(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 f.prototype=m.constructor=p,p.constructor=f,f.displayName=s(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),s(m,a,"Generator"),m[o]=function(){return this},m.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=k,L.prototype={constructor:L,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(j),!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 s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)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,h):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),h},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),j(r),h}},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;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}})),c=function(){function t(t){var e;this.opts=t,this.host=null!=(e=t.host)?e:"https://codegen.plasmic.app"}var r=t.prototype;return r.fetchLoaderData=function(){var t=n(u.mark((function t(r,n){var o,i,a,s,c,h,l,f;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.platform,i=n.preview,a=new URLSearchParams([["platform",null!=o?o:"react"]].concat(r.map((function(t){return["projectId",t]})))).toString(),s=this.host+"/api/v1/loader/code/"+(i?"preview":"published")+"?"+a,t.next=5,e(s,{method:"GET",headers:this.makeGetHeaders()});case 5:if(!((c=t.sent).status>=400)){t.next=11;break}return t.next=9,c.json();case 9:throw f=t.sent,new Error(null!=(h=null==f||null==(l=f.error)?void 0:l.message)?h:c.statusText);case 11:return t.next=13,c.json();case 13:return t.abrupt("return",t.sent);case 15:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.fetchHtmlData=function(){var t=n(u.mark((function t(r){var n,o;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URLSearchParams([["projectId",r.projectId],["component",r.component],["embedHydrate",r.embedHydrate?"1":"0"],["hydrate",r.hydrate?"1":"0"]]).toString(),t.next=4,e(this.host+"/api/v1/loader/html?"+n,{method:"GET",headers:this.makeGetHeaders()});case 4:return o=t.sent,t.next=7,o.json();case 7:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.makeGetHeaders=function(){return o({"x-plasmic-loader-version":"1"},this.makeAuthHeaders())},r.makePostHeaders=function(){return o({"x-plasmic-loader-version":"1","Content-Type":"application/json"},this.makeAuthHeaders())},r.makeAuthHeaders=function(){return{"x-plasmic-api-project-tokens":this.opts.projects.map((function(t){return t.id+":"+t.token})).join(",")}},t}(),h=function(){function t(t){this.bundle=t,this.dependsOn={},this.dependedBy={},this.rebuildGraph()}var e=t.prototype;return e.getTransitiveDependers=function(t){return this.transitiveCrawl(t,this.dependedBy)},e.getTransitiveDeps=function(t){return t in this.dependsOn?this.transitiveCrawl(t,this.dependsOn):[]},e.transitiveCrawl=function(t,e){for(var r,n=new Set,o=function t(r){if(!n.has(r)){n.add(r);for(var o,i=a(null!=(s=e[r])?s:[]);!(o=i()).done;){var s;t(o.value)}}},i=a(e[t]);!(r=i()).done;)o(r.value);return Array.from(n)},e.rebuildGraph=function(){this.dependedBy={},this.dependsOn={};for(var t,e=a(this.bundle.modules);!(t=e()).done;){var r=t.value;if("code"===r.type)for(var n,o=a(r.imports);!(n=o()).done;){var i=n.value;r.fileName in this.dependsOn?this.dependsOn[r.fileName].push(i):this.dependsOn[r.fileName]=[i],i in this.dependedBy?this.dependedBy[i].push(r.fileName):this.dependedBy[i]=[r.fileName]}}},t}(),l=function(){function t(t){this.opts=t,this.curFetch=void 0,this.api=new c({projects:t.projects,host:t.host})}var e=t.prototype;return e.fetchAllData=function(){var t=n(u.mark((function t(){var e;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.opts.cache){t.next=6;break}return t.next=3,this.opts.cache.get();case 3:if(!(e=t.sent)){t.next=6;break}return t.abrupt("return",e);case 6:if(!this.curFetch){t.next=10;break}return t.next=9,this.curFetch;case 9:return t.abrupt("return",t.sent);case 10:return console.debug("PlasmicLoader: doing a fresh fetch..."),this.curFetch=this.doFetch(),t.next=14,this.curFetch;case 14:return t.abrupt("return",t.sent);case 15:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.doFetch=function(){var t=n(u.mark((function t(){var e,r=this;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.api.fetchLoaderData(this.opts.projects.map((function(t){return t.version&&!r.opts.preview?t.id+"@"+t.version:t.id})),{platform:this.opts.platform,preview:this.opts.preview});case 2:if(e=t.sent,!this.opts.cache){t.next=6;break}return t.next=6,this.opts.cache.set(e);case 6:return t.abrupt("return",e);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),f=function(){function t(){this.loadedModules={},this.registeredModules={},this.modules={}}var e=t.prototype;return e.register=function(t,e){this.registeredModules[t]=e},e.isEmpty=function(){return 0===Object.keys(this.loadedModules).length},e.clear=function(){this.loadedModules={}},e.hasModule=function(t,e){return void 0===e&&(e={}),t in this.registeredModules&&!e.forceOriginal||t in this.modules},e.load=function(t,e){var r=this;if(void 0===e&&(e={}),t in this.registeredModules&&!e.forceOriginal)return this.registeredModules[t];if(t in this.loadedModules)return this.loadedModules[t];if(!(t in this.modules))throw new Error("Unknown module "+t);var n=new Function("require","exports",this.modules[t]),o={};return this.loadedModules[t]=o,n((function(e){var n=function(t,e){var r=e.split("/"),n=t.split("/");if(0===n.length)return t;if("."===n[0])return[].concat(r.slice(0,r.length-1),n.slice(1)).join("/");if(".."===n[0]){for(var o,i=0,s=a(n);!(o=s()).done&&".."===o.value;)i+=1;return[].concat(r.slice(0,r.length-i-1),n.slice(i)).join("/")}return t}(e,t);return r.load(n)}),o),o},e.updateModules=function(t){for(var e,r=!1,n=a(t.modules);!(e=n()).done;){var o=e.value;"code"===o.type&&o.code!==this.modules[o.fileName]&&(this.modules[o.fileName]=o.code,r=!0)}r&&this.clear()},t}();exports.Api=c,exports.PlasmicModulesFetcher=l,exports.Registry=f,exports.getBundleSubset=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];var o=new Set(r),i=new h(t),a=new Set(r.flatMap((function(t){return i.getTransitiveDeps(t)}))),s=function(t){return a.has(t)||o.has(t)};return{modules:t.modules.filter((function(t){return s(t.fileName)})),external:t.external.filter((function(t){return a.has(t)})),components:t.components.filter((function(t){return s(t.entry)})),globalGroups:t.globalGroups,projects:t.projects}}; | ||
//# sourceMappingURL=loader-core.cjs.production.min.js.map |
@@ -823,2 +823,3 @@ import fetch from 'isomorphic-unfetch'; | ||
var VERSION = '1'; | ||
var Api = /*#__PURE__*/function () { | ||
@@ -829,3 +830,3 @@ function Api(opts) { | ||
this.opts = opts; | ||
this.host = (_opts$host = opts.host) != null ? _opts$host : 'https://studio.plasmic.app'; | ||
this.host = (_opts$host = opts.host) != null ? _opts$host : 'https://codegen.plasmic.app'; | ||
} | ||
@@ -932,3 +933,5 @@ | ||
_proto.makeGetHeaders = function makeGetHeaders() { | ||
return _extends({}, this.makeAuthHeaders()); | ||
return _extends({ | ||
'x-plasmic-loader-version': VERSION | ||
}, this.makeAuthHeaders()); | ||
} // @ts-ignore | ||
@@ -939,2 +942,3 @@ ; | ||
return _extends({ | ||
'x-plasmic-loader-version': VERSION, | ||
'Content-Type': 'application/json' | ||
@@ -1039,2 +1043,3 @@ }, this.makeAuthHeaders()); | ||
var namesSet = new Set(names); | ||
var graph = new DepsGraph(bundle); | ||
@@ -1044,5 +1049,10 @@ var deps = new Set(names.flatMap(function (name) { | ||
})); | ||
var isSubModule = function isSubModule(fileName) { | ||
return deps.has(fileName) || namesSet.has(fileName); | ||
}; | ||
return { | ||
modules: bundle.modules.filter(function (mod) { | ||
return deps.has(mod.fileName) || names.includes(mod.fileName); | ||
return isSubModule(mod.fileName); | ||
}), | ||
@@ -1052,3 +1062,5 @@ external: bundle.external.filter(function (dep) { | ||
}), | ||
components: bundle.components, | ||
components: bundle.components.filter(function (c) { | ||
return isSubModule(c.entry); | ||
}), | ||
globalGroups: bundle.globalGroups, | ||
@@ -1055,0 +1067,0 @@ projects: bundle.projects |
{ | ||
"version": "1.0.5", | ||
"version": "1.0.7", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
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
282681
2323