Socket
Socket
Sign inDemoInstall

@plasmicapp/loader-core

Package Overview
Dependencies
Maintainers
1
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plasmicapp/loader-core - npm Package Compare versions

Comparing version 0.1.6 to 0.1.8-alpha.852

20

dist/loader-core.cjs.development.js

@@ -867,3 +867,4 @@ 'use strict';

var _fetchLoaderData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(projectIds, opts) {
var platform, preview, query, url, resp, json;
var platform, preview, query, url, resp, _error$error$message, _error$error, error, json;
return runtime_1.wrap(function _callee$(_context) {

@@ -888,17 +889,22 @@ while (1) {

if (!(resp.status >= 400)) {
_context.next = 8;
_context.next = 11;
break;
}
throw new Error(resp.statusText);
_context.next = 9;
return resp.json();
case 8:
_context.next = 10;
case 9:
error = _context.sent;
throw new Error((_error$error$message = error == null ? void 0 : (_error$error = error.error) == null ? void 0 : _error$error.message) != null ? _error$error$message : resp.statusText);
case 11:
_context.next = 13;
return resp.json();
case 10:
case 13:
json = _context.sent;
return _context.abrupt("return", json);
case 12:
case 15:
case "end":

@@ -905,0 +911,0 @@ return _context.stop();

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("isomorphic-fetch"))&&"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.")}var s,u=(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)}}(s={exports:{}}),s.exports),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;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=8;break}throw new Error(c.statusText);case 8:return t.next=10,c.json();case 10:return t.abrupt("return",t.sent);case 12: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=7;break}return t.next=3,this.opts.cache.get();case 3:if(!(e=t.sent)){t.next=7;break}return console.log("Using cached data"),t.abrupt("return",e);case 7:if(!this.curFetch){t.next=12;break}return console.log("Awaiting in-process fetch"),t.next=11,this.curFetch;case 11:return t.abrupt("return",t.sent);case 12:return console.log("Doing a fresh fetch..."),this.curFetch=this.doFetch(),t.next=16,this.curFetch;case 16:return t.abrupt("return",t.sent);case 17: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 console.log("Finished fresh fetch"),t.abrupt("return",e);case 8: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-fetch"))&&"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.")}var s,u=(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)}}(s={exports:{}}),s.exports),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=7;break}return t.next=3,this.opts.cache.get();case 3:if(!(e=t.sent)){t.next=7;break}return console.log("Using cached data"),t.abrupt("return",e);case 7:if(!this.curFetch){t.next=12;break}return console.log("Awaiting in-process fetch"),t.next=11,this.curFetch;case 11:return t.abrupt("return",t.sent);case 12:return console.log("Doing a fresh fetch..."),this.curFetch=this.doFetch(),t.next=16,this.curFetch;case 16:return t.abrupt("return",t.sent);case 17: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 console.log("Finished fresh fetch"),t.abrupt("return",e);case 8: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}};
//# sourceMappingURL=loader-core.cjs.production.min.js.map

@@ -861,3 +861,4 @@ import fetch from 'isomorphic-fetch';

var _fetchLoaderData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(projectIds, opts) {
var platform, preview, query, url, resp, json;
var platform, preview, query, url, resp, _error$error$message, _error$error, error, json;
return runtime_1.wrap(function _callee$(_context) {

@@ -882,17 +883,22 @@ while (1) {

if (!(resp.status >= 400)) {
_context.next = 8;
_context.next = 11;
break;
}
throw new Error(resp.statusText);
_context.next = 9;
return resp.json();
case 8:
_context.next = 10;
case 9:
error = _context.sent;
throw new Error((_error$error$message = error == null ? void 0 : (_error$error = error.error) == null ? void 0 : _error$error.message) != null ? _error$error$message : resp.statusText);
case 11:
_context.next = 13;
return resp.json();
case 10:
case 13:
json = _context.sent;
return _context.abrupt("return", json);
case 12:
case 15:
case "end":

@@ -899,0 +905,0 @@ return _context.stop();

{
"version": "0.1.6",
"version": "0.1.8-alpha.852+1c48634",
"license": "MIT",

@@ -22,3 +22,2 @@ "main": "dist/index.js",

},
"peerDependencies": {},
"husky": {

@@ -59,3 +58,4 @@ "hooks": {

"isomorphic-fetch": "^3.0.0"
}
},
"gitHead": "1c48634af6b568898daa24475694017a25d3b8de"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc