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.4 to 0.1.5

10

dist/api.d.ts

@@ -25,2 +25,11 @@ export interface ComponentMeta {

}
export interface ProjectMeta {
id: string;
name: string;
version: string;
remoteFonts: FontMeta[];
}
export interface FontMeta {
url: string;
}
export interface LoaderBundleOutput {

@@ -31,2 +40,3 @@ modules: (CodeModule | AssetModule)[];

globalGroups: GlobalGroupMeta[];
projects: ProjectMeta[];
}

@@ -33,0 +43,0 @@ export interface LoaderHtmlOutput {

2

dist/index.d.ts

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

export { Api, AssetModule, CodeModule, ComponentMeta, GlobalGroupMeta, LoaderBundleOutput, LoaderHtmlOutput, PageMeta, } from './api';
export { Api, AssetModule, CodeModule, ComponentMeta, FontMeta, GlobalGroupMeta, LoaderBundleOutput, LoaderHtmlOutput, PageMeta, ProjectMeta, } from './api';
export { getBundleSubset } from './bundles';

@@ -3,0 +3,0 @@ export { LoaderBundleCache, PlasmicModulesFetcher } from './fetcher';

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

components: bundle.components,
globalGroups: bundle.globalGroups
globalGroups: bundle.globalGroups,
projects: bundle.projects
};

@@ -1279,3 +1280,2 @@ }

updated = true;
console.log('UPDATED module', mod.fileName);
}

@@ -1282,0 +1282,0 @@ }

@@ -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=t(require("isomorphic-fetch")),r=t(require("socket.io-client"));function n(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function s(t){n(a,o,i,s,c,"next",t)}function c(t){n(a,o,i,s,c,"throw",t)}s(void 0)}))}}function i(){return(i=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 a(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 s(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 a(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)?a(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 c,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 c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).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 s=b(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 c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h={};function l(){}function f(){}function p(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(E([])));m&&m!==e&&r.call(m,o)&&(d=m);var y=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 c=u(t[o],t,i);if("throw"!==c.type){var h=c.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(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(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,b(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=u(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 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 k(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 E(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:L}}function L(){return{value:void 0,done:!0}}return f.prototype=y.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(y),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(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),s(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=E,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(k),!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"),c=r.call(i,"finallyLoc");if(s&&c){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(!c)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),k(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;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(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={exports:{}}),c.exports),h=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=o(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=o(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 i({},this.makeAuthHeaders())},r.makePostHeaders=function(){return i({"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}(),l=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=s(null!=(a=e[r])?a:[]);!(o=i()).done;){var a;t(o.value)}}},i=s(e[t]);!(r=i()).done;)o(r.value);return Array.from(n)},e.rebuildGraph=function(){this.dependedBy={},this.dependsOn={};for(var t,e=s(this.bundle.modules);!(t=e()).done;){var r=t.value;if("code"===r.type)for(var n,o=s(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}(),f=function(){function t(t){this.opts=t,this.curFetch=void 0,this.api=new h({projects:t.projects,host:t.host})}var e=t.prototype;return e.fetchAllData=function(){var t=o(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=o(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}(),p=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,a=s(n);!(o=a()).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=s(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,console.log("UPDATED module",o.fileName))}r&&this.clear()},t}(),d=function(){function t(t){var e;this.opts=t,this.watchers=[],this.socket=void 0,this.host=null!=(e=t.host)?e:"https://studio.plasmic.app"}var e=t.prototype;return e.subscribe=function(t){var e=this;return this.watchers.push(t),this.ensureWatch(),function(){e.unsubscribe(t)}},e.unsubscribe=function(t){var e=this.watchers.indexOf(t);e>=0&&(this.watchers.splice(e,1),0===this.watchers.length&&this.socket&&(this.socket.disconnect(),this.socket=void 0))},e.connectSocket=function(){var t=o(u.mark((function t(){var e;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r(this.host,{path:"/api/v1/socket",transportOptions:{polling:{extraHeaders:this.makeAuthHeaders()}}}),t.abrupt("return",e);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.makeAuthHeaders=function(){return{"x-plasmic-api-project-tokens":this.opts.projects.map((function(t){return t.id+":"+t.token})).join(",")}},e.ensureWatch=function(){var t=o(u.mark((function t(){var e,r=this;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.socket){t.next=2;break}return t.abrupt("return");case 2:if(0!==this.watchers.length){t.next=4;break}return t.abrupt("return");case 4:return t.next=6,this.connectSocket();case 6:(e=this.socket=t.sent).on("initServerInfo",(function(){e.emit("subscribe",{namespace:"projects",projectIds:r.opts.projects.map((function(t){return t.id}))})})),e.on("error",(function(t){console.error((new Date).toISOString()+": Encountered error "+t),r.watchers.forEach((function(e){return null==e.onError?void 0:e.onError(t)})),e.disconnect(),r.socket=void 0})),e.on("update",function(){var t=o(u.mark((function t(e){return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:console.log((new Date).toISOString()+": Project "+e.projectId+" updated to revision "+e.revisionNum),console.log("Informing watchers",r.watchers),r.watchers.forEach((function(t){return t.onChange(e.projectId)}));case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 10:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();exports.Api=h,exports.PlasmicModulesFetcher=f,exports.PlasmicRemoteChangeWatcher=d,exports.Registry=p,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 l(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}};
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("isomorphic-fetch")),r=t(require("socket.io-client"));function n(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function s(t){n(a,o,i,s,c,"next",t)}function c(t){n(a,o,i,s,c,"throw",t)}s(void 0)}))}}function i(){return(i=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 a(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 s(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 a(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)?a(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 c,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 c(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 s=b(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 c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h={};function f(){}function l(){}function p(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(E([])));m&&m!==e&&r.call(m,o)&&(d=m);var y=p.prototype=f.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 c=u(t[o],t,i);if("throw"!==c.type){var h=c.arg,f=h.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(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,b(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=u(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 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 k(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 E(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:L}}function L(){return{value:void 0,done:!0}}return l.prototype=y.constructor=p,p.constructor=l,l.displayName=s(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"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(y),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(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),s(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=E,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(k),!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"),c=r.call(i,"finallyLoc");if(s&&c){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(!c)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),k(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;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(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={exports:{}}),c.exports),h=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=o(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=o(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 i({},this.makeAuthHeaders())},r.makePostHeaders=function(){return i({"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}(),f=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=s(null!=(a=e[r])?a:[]);!(o=i()).done;){var a;t(o.value)}}},i=s(e[t]);!(r=i()).done;)o(r.value);return Array.from(n)},e.rebuildGraph=function(){this.dependedBy={},this.dependsOn={};for(var t,e=s(this.bundle.modules);!(t=e()).done;){var r=t.value;if("code"===r.type)for(var n,o=s(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 h({projects:t.projects,host:t.host})}var e=t.prototype;return e.fetchAllData=function(){var t=o(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=o(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}(),p=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,a=s(n);!(o=a()).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=s(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}(),d=function(){function t(t){var e;this.opts=t,this.watchers=[],this.socket=void 0,this.host=null!=(e=t.host)?e:"https://studio.plasmic.app"}var e=t.prototype;return e.subscribe=function(t){var e=this;return this.watchers.push(t),this.ensureWatch(),function(){e.unsubscribe(t)}},e.unsubscribe=function(t){var e=this.watchers.indexOf(t);e>=0&&(this.watchers.splice(e,1),0===this.watchers.length&&this.socket&&(this.socket.disconnect(),this.socket=void 0))},e.connectSocket=function(){var t=o(u.mark((function t(){var e;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r(this.host,{path:"/api/v1/socket",transportOptions:{polling:{extraHeaders:this.makeAuthHeaders()}}}),t.abrupt("return",e);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.makeAuthHeaders=function(){return{"x-plasmic-api-project-tokens":this.opts.projects.map((function(t){return t.id+":"+t.token})).join(",")}},e.ensureWatch=function(){var t=o(u.mark((function t(){var e,r=this;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.socket){t.next=2;break}return t.abrupt("return");case 2:if(0!==this.watchers.length){t.next=4;break}return t.abrupt("return");case 4:return t.next=6,this.connectSocket();case 6:(e=this.socket=t.sent).on("initServerInfo",(function(){e.emit("subscribe",{namespace:"projects",projectIds:r.opts.projects.map((function(t){return t.id}))})})),e.on("error",(function(t){console.error((new Date).toISOString()+": Encountered error "+t),r.watchers.forEach((function(e){return null==e.onError?void 0:e.onError(t)})),e.disconnect(),r.socket=void 0})),e.on("update",function(){var t=o(u.mark((function t(e){return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:console.log((new Date).toISOString()+": Project "+e.projectId+" updated to revision "+e.revisionNum),console.log("Informing watchers",r.watchers),r.watchers.forEach((function(t){return t.onChange(e.projectId)}));case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 10:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();exports.Api=h,exports.PlasmicModulesFetcher=l,exports.PlasmicRemoteChangeWatcher=d,exports.Registry=p,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 f(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

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

components: bundle.components,
globalGroups: bundle.globalGroups
globalGroups: bundle.globalGroups,
projects: bundle.projects
};

@@ -1273,3 +1274,2 @@ }

updated = true;
console.log('UPDATED module', mod.fileName);
}

@@ -1276,0 +1276,0 @@ }

{
"version": "0.1.4",
"version": "0.1.5",
"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

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