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 1.0.26 to 1.0.27

7

dist/api.d.ts

@@ -44,3 +44,6 @@ export interface ComponentMeta {

export interface LoaderBundleOutput {
modules: (CodeModule | AssetModule)[];
modules: {
browser: (CodeModule | AssetModule)[];
server: (CodeModule | AssetModule)[];
};
external: string[];

@@ -65,2 +68,3 @@ components: ComponentMeta[];

}
export declare const isBrowser: boolean;
export declare class Api {

@@ -79,2 +83,3 @@ private opts;

preview?: boolean;
browserOnly?: boolean;
}): Promise<LoaderBundleOutput>;

@@ -81,0 +86,0 @@ fetchHtmlData(opts: {

3

dist/deps-graph.d.ts
import { LoaderBundleOutput } from './api';
export declare class DepsGraph {
private bundle;
private browserBuild;
private dependsOn;
private dependedBy;
constructor(bundle: LoaderBundleOutput);
constructor(bundle: LoaderBundleOutput, browserBuild?: boolean);
getTransitiveDependers(name: string): string[];

@@ -8,0 +9,0 @@ getTransitiveDeps(name: string): string[];

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

var VERSION = '2';
var VERSION = '3';
var isBrowser = typeof window !== 'undefined' && window != null && typeof window.document !== 'undefined';
var Api = /*#__PURE__*/function () {

@@ -852,3 +853,3 @@ function Api(opts) {

return ['projectId', projectId];
}))).toString();
}), opts.browserOnly ? [['browserOnly', 'true']] : [])).toString();
url = this.host + "/api/v1/loader/code/" + (preview ? 'preview' : 'published') + "?" + query;

@@ -965,4 +966,9 @@ _context.next = 5;

var DepsGraph = /*#__PURE__*/function () {
function DepsGraph(bundle) {
function DepsGraph(bundle, browserBuild) {
if (browserBuild === void 0) {
browserBuild = true;
}
this.bundle = bundle;
this.browserBuild = browserBuild;
this.dependsOn = {};

@@ -1017,3 +1023,3 @@ this.dependedBy = {};

for (var _iterator3 = _createForOfIteratorHelperLoose(this.bundle.modules), _step3; !(_step3 = _iterator3()).done;) {
for (var _iterator3 = _createForOfIteratorHelperLoose(this.browserBuild ? this.bundle.modules.browser : this.bundle.modules.server), _step3; !(_step3 = _iterator3()).done;) {
var mod = _step3.value;

@@ -1044,2 +1050,4 @@

// from `names`.
function getBundleSubset(bundle) {

@@ -1061,5 +1069,8 @@ for (var _len = arguments.length, names = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

return {
modules: bundle.modules.filter(function (mod) {
return isSubModule(mod.fileName);
}),
modules: {
browser: bundle.modules.browser.filter(function (mod) {
return isSubModule(mod.fileName);
}),
server: []
},
external: bundle.external.filter(function (dep) {

@@ -1165,3 +1176,4 @@ return deps.has(dep);

platform: this.opts.platform,
preview: this.opts.preview
preview: this.opts.preview,
browserOnly: isBrowser
});

@@ -1211,2 +1223,10 @@

Registry.getInstance = function getInstance() {
if (!Registry.instance) {
Registry.instance = new Registry();
}
return Registry.instance;
};
var _proto = Registry.prototype;

@@ -1226,2 +1246,6 @@

_proto.getRegisteredModule = function getRegisteredModule(name) {
return this.registeredModules[name];
};
_proto.hasModule = function hasModule(name, opts) {

@@ -1259,12 +1283,22 @@ if (opts === void 0) {

var code = this.modules[name];
var require = function require(dep) {
var requireFn = isBrowser ? function (dep) {
var normalizedDep = resolvePath(dep, name);
return _this.load(normalizedDep);
} : function (dep) {
try {
var normalizedDep = resolvePath(dep, name);
return _this.load(normalizedDep);
} catch (err) {
try {
// Might be a nodeJs module such as tty
return eval('require')(dep);
} catch (_unused) {
throw err;
}
}
};
var func = new Function('require', 'exports', code);
var exports = {};
this.loadedModules[name] = exports;
func(require, exports);
func(requireFn, exports);
return exports;

@@ -1276,3 +1310,3 @@ };

for (var _iterator = _createForOfIteratorHelperLoose(bundle.modules), _step; !(_step = _iterator()).done;) {
for (var _iterator = _createForOfIteratorHelperLoose(isBrowser ? bundle.modules.browser : bundle.modules.server), _step; !(_step = _iterator()).done;) {
var mod = _step.value;

@@ -1293,4 +1327,6 @@

return Registry;
}();
}(); // Singleton
Registry.instance = undefined;
function resolvePath(path, from) {

@@ -1297,0 +1333,0 @@ var fromParts = from.split('/');

@@ -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://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":"2"},this.makeAuthHeaders())},r.makePostHeaders=function(){return o({"x-plasmic-loader-version":"2","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,r;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("Plasmic: doing a fresh fetch..."),this.curFetch=this.doFetch(),t.next=14,this.curFetch;case 14:return r=t.sent,this.curFetch=void 0,t.abrupt("return",r);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.debug("Plasmic: fetched designs for "+e.projects.map((function(t){return'"'+t.name+'" ('+t.id+"@"+t.version+")"})).join(", ")),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 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}};
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var fetch=_interopDefault(require("isomorphic-unfetch"));function asyncGeneratorStep(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){asyncGeneratorStep(i,n,o,a,s,"next",e)}function s(e){asyncGeneratorStep(i,n,o,a,s,"throw",e)}a(void 0)}))}}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[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 createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var runtime_1=createCommonjsModule((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var o=Object.create((t&&t.prototype instanceof h?t:h).prototype),i=new L(n||[]);return o._invoke=function(e,t,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===l)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(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,i),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function h(){}function p(){}function f(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==t&&r.call(y,o)&&(d=y);var m=f.prototype=h.prototype=Object.create(d);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var n;this._invoke=function(o,i){function a(){return new t((function(n,a){!function n(o,i,a,s){var u=c(e[o],e,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return p.prototype=m.constructor=f,f.constructor=p,p.displayName=s(f,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,s(e,a,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(w.prototype),w.prototype[i]=function(){return this},e.AsyncIterator=w,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),s(m,a,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,L.prototype={constructor:L,reset:function(e){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(_),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.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(e,t){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"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:O(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}})),VERSION="3",isBrowser="undefined"!=typeof window&&null!=window&&void 0!==window.document,Api=function(){function e(e){var t;this.opts=e,this.host=null!=(t=e.host)?t:"https://codegen.plasmic.app"}var t=e.prototype;return t.fetchLoaderData=function(){var e=_asyncToGenerator(runtime_1.mark((function e(t,r){var n,o,i,a,s,u,c,l;return runtime_1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.platform,o=r.preview,i=new URLSearchParams([["platform",null!=n?n:"react"]].concat(t.map((function(e){return["projectId",e]})),r.browserOnly?[["browserOnly","true"]]:[])).toString(),a=this.host+"/api/v1/loader/code/"+(o?"preview":"published")+"?"+i,e.next=5,fetch(a,{method:"GET",headers:this.makeGetHeaders()});case 5:if(!((s=e.sent).status>=400)){e.next=11;break}return e.next=9,s.json();case 9:throw l=e.sent,new Error(null!=(u=null==l||null==(c=l.error)?void 0:c.message)?u:s.statusText);case 11:return e.next=13,s.json();case 13:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.fetchHtmlData=function(){var e=_asyncToGenerator(runtime_1.mark((function e(t){var r,n;return runtime_1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URLSearchParams([["projectId",t.projectId],["component",t.component],["embedHydrate",t.embedHydrate?"1":"0"],["hydrate",t.hydrate?"1":"0"]]).toString(),e.next=4,fetch(this.host+"/api/v1/loader/html?"+r,{method:"GET",headers:this.makeGetHeaders()});case 4:return n=e.sent,e.next=7,n.json();case 7:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.makeGetHeaders=function(){return _extends({"x-plasmic-loader-version":VERSION},this.makeAuthHeaders())},t.makePostHeaders=function(){return _extends({"x-plasmic-loader-version":VERSION,"Content-Type":"application/json"},this.makeAuthHeaders())},t.makeAuthHeaders=function(){return{"x-plasmic-api-project-tokens":this.opts.projects.map((function(e){return e.id+":"+e.token})).join(",")}},e}(),DepsGraph=function(){function e(e,t){void 0===t&&(t=!0),this.bundle=e,this.browserBuild=t,this.dependsOn={},this.dependedBy={},this.rebuildGraph()}var t=e.prototype;return t.getTransitiveDependers=function(e){return this.transitiveCrawl(e,this.dependedBy)},t.getTransitiveDeps=function(e){return e in this.dependsOn?this.transitiveCrawl(e,this.dependsOn):[]},t.transitiveCrawl=function(e,t){for(var r,n=new Set,o=function e(r){if(!n.has(r)){n.add(r);for(var o,i=_createForOfIteratorHelperLoose(null!=(a=t[r])?a:[]);!(o=i()).done;){var a;e(o.value)}}},i=_createForOfIteratorHelperLoose(t[e]);!(r=i()).done;)o(r.value);return Array.from(n)},t.rebuildGraph=function(){this.dependedBy={},this.dependsOn={};for(var e,t=_createForOfIteratorHelperLoose(this.browserBuild?this.bundle.modules.browser:this.bundle.modules.server);!(e=t()).done;){var r=e.value;if("code"===r.type)for(var n,o=_createForOfIteratorHelperLoose(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]}}},e}();function getBundleSubset(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var o=new Set(r),i=new DepsGraph(e),a=new Set(r.flatMap((function(e){return i.getTransitiveDeps(e)}))),s=function(e){return a.has(e)||o.has(e)};return{modules:{browser:e.modules.browser.filter((function(e){return s(e.fileName)})),server:[]},external:e.external.filter((function(e){return a.has(e)})),components:e.components.filter((function(e){return s(e.entry)})),globalGroups:e.globalGroups,projects:e.projects}}var PlasmicModulesFetcher=function(){function e(e){this.opts=e,this.curFetch=void 0,this.api=new Api({projects:e.projects,host:e.host})}var t=e.prototype;return t.fetchAllData=function(){var e=_asyncToGenerator(runtime_1.mark((function e(){var t,r;return runtime_1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.opts.cache){e.next=6;break}return e.next=3,this.opts.cache.get();case 3:if(!(t=e.sent)){e.next=6;break}return e.abrupt("return",t);case 6:if(!this.curFetch){e.next=10;break}return e.next=9,this.curFetch;case 9:return e.abrupt("return",e.sent);case 10:return console.debug("Plasmic: doing a fresh fetch..."),this.curFetch=this.doFetch(),e.next=14,this.curFetch;case 14:return r=e.sent,this.curFetch=void 0,e.abrupt("return",r);case 17:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.doFetch=function(){var e=_asyncToGenerator(runtime_1.mark((function e(){var t,r=this;return runtime_1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.api.fetchLoaderData(this.opts.projects.map((function(e){return e.version&&!r.opts.preview?e.id+"@"+e.version:e.id})),{platform:this.opts.platform,preview:this.opts.preview,browserOnly:isBrowser});case 2:if(t=e.sent,!this.opts.cache){e.next=6;break}return e.next=6,this.opts.cache.set(t);case 6:return console.debug("Plasmic: fetched designs for "+t.projects.map((function(e){return'"'+e.name+'" ('+e.id+"@"+e.version+")"})).join(", ")),e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),Registry=function(){function Registry(){this.loadedModules={},this.registeredModules={},this.modules={}}Registry.getInstance=function(){return Registry.instance||(Registry.instance=new Registry),Registry.instance};var _proto=Registry.prototype;return _proto.register=function(e,t){this.registeredModules[e]=t},_proto.isEmpty=function(){return 0===Object.keys(this.loadedModules).length},_proto.clear=function(){this.loadedModules={}},_proto.getRegisteredModule=function(e){return this.registeredModules[e]},_proto.hasModule=function(e,t){return void 0===t&&(t={}),e in this.registeredModules&&!t.forceOriginal||e in this.modules},_proto.load=function load(name,opts){var _this=this;if(void 0===opts&&(opts={}),name in this.registeredModules&&!opts.forceOriginal)return this.registeredModules[name];if(name in this.loadedModules)return this.loadedModules[name];if(!(name in this.modules))throw new Error("Unknown module "+name);var code=this.modules[name],requireFn=isBrowser?function(e){var t=resolvePath(e,name);return _this.load(t)}:function(dep){try{var normalizedDep=resolvePath(dep,name);return _this.load(normalizedDep)}catch(err){try{return eval("require")(dep)}catch(e){throw err}}},func=new Function("require","exports",code),exports={};return this.loadedModules[name]=exports,func(requireFn,exports),exports},_proto.updateModules=function(e){for(var t,r=!1,n=_createForOfIteratorHelperLoose(isBrowser?e.modules.browser:e.modules.server);!(t=n()).done;){var o=t.value;"code"===o.type&&o.code!==this.modules[o.fileName]&&(this.modules[o.fileName]=o.code,r=!0)}r&&this.clear()},Registry}();function resolvePath(e,t){var r=t.split("/"),n=e.split("/");if(0===n.length)return e;if("."===n[0])return[].concat(r.slice(0,r.length-1),n.slice(1)).join("/");if(".."===n[0]){for(var o,i=0,a=_createForOfIteratorHelperLoose(n);!(o=a()).done&&".."===o.value;)i+=1;return[].concat(r.slice(0,r.length-i-1),n.slice(i)).join("/")}return e}Registry.instance=void 0,exports.Api=Api,exports.PlasmicModulesFetcher=PlasmicModulesFetcher,exports.Registry=Registry,exports.getBundleSubset=getBundleSubset;
//# sourceMappingURL=loader-core.cjs.production.min.js.map

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

var VERSION = '2';
var VERSION = '3';
var isBrowser = typeof window !== 'undefined' && window != null && typeof window.document !== 'undefined';
var Api = /*#__PURE__*/function () {

@@ -846,3 +847,3 @@ function Api(opts) {

return ['projectId', projectId];
}))).toString();
}), opts.browserOnly ? [['browserOnly', 'true']] : [])).toString();
url = this.host + "/api/v1/loader/code/" + (preview ? 'preview' : 'published') + "?" + query;

@@ -959,4 +960,9 @@ _context.next = 5;

var DepsGraph = /*#__PURE__*/function () {
function DepsGraph(bundle) {
function DepsGraph(bundle, browserBuild) {
if (browserBuild === void 0) {
browserBuild = true;
}
this.bundle = bundle;
this.browserBuild = browserBuild;
this.dependsOn = {};

@@ -1011,3 +1017,3 @@ this.dependedBy = {};

for (var _iterator3 = _createForOfIteratorHelperLoose(this.bundle.modules), _step3; !(_step3 = _iterator3()).done;) {
for (var _iterator3 = _createForOfIteratorHelperLoose(this.browserBuild ? this.bundle.modules.browser : this.bundle.modules.server), _step3; !(_step3 = _iterator3()).done;) {
var mod = _step3.value;

@@ -1038,2 +1044,4 @@

// from `names`.
function getBundleSubset(bundle) {

@@ -1055,5 +1063,8 @@ for (var _len = arguments.length, names = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

return {
modules: bundle.modules.filter(function (mod) {
return isSubModule(mod.fileName);
}),
modules: {
browser: bundle.modules.browser.filter(function (mod) {
return isSubModule(mod.fileName);
}),
server: []
},
external: bundle.external.filter(function (dep) {

@@ -1159,3 +1170,4 @@ return deps.has(dep);

platform: this.opts.platform,
preview: this.opts.preview
preview: this.opts.preview,
browserOnly: isBrowser
});

@@ -1205,2 +1217,10 @@

Registry.getInstance = function getInstance() {
if (!Registry.instance) {
Registry.instance = new Registry();
}
return Registry.instance;
};
var _proto = Registry.prototype;

@@ -1220,2 +1240,6 @@

_proto.getRegisteredModule = function getRegisteredModule(name) {
return this.registeredModules[name];
};
_proto.hasModule = function hasModule(name, opts) {

@@ -1253,12 +1277,22 @@ if (opts === void 0) {

var code = this.modules[name];
var require = function require(dep) {
var requireFn = isBrowser ? function (dep) {
var normalizedDep = resolvePath(dep, name);
return _this.load(normalizedDep);
} : function (dep) {
try {
var normalizedDep = resolvePath(dep, name);
return _this.load(normalizedDep);
} catch (err) {
try {
// Might be a nodeJs module such as tty
return eval('require')(dep);
} catch (_unused) {
throw err;
}
}
};
var func = new Function('require', 'exports', code);
var exports = {};
this.loadedModules[name] = exports;
func(require, exports);
func(requireFn, exports);
return exports;

@@ -1270,3 +1304,3 @@ };

for (var _iterator = _createForOfIteratorHelperLoose(bundle.modules), _step; !(_step = _iterator()).done;) {
for (var _iterator = _createForOfIteratorHelperLoose(isBrowser ? bundle.modules.browser : bundle.modules.server), _step; !(_step = _iterator()).done;) {
var mod = _step.value;

@@ -1287,4 +1321,6 @@

return Registry;
}();
}(); // Singleton
Registry.instance = undefined;
function resolvePath(path, from) {

@@ -1291,0 +1327,0 @@ var fromParts = from.split('/');

import { LoaderBundleOutput } from './api';
export declare class Registry {
private static instance;
private loadedModules;
private registeredModules;
private modules;
constructor();
private constructor();
static getInstance(): Registry;
register(name: string, module: any): void;
isEmpty(): boolean;
clear(): void;
getRegisteredModule(name: string): any;
hasModule(name: string, opts?: {

@@ -11,0 +14,0 @@ forceOriginal?: boolean;

{
"version": "1.0.26",
"version": "1.0.27",
"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