Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@plasmicapp/host

Package Overview
Dependencies
Maintainers
1
Versions
248
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plasmicapp/host - npm Package Compare versions

Comparing version 1.0.36 to 1.0.37

dist/canvas-host.d.ts

2

dist/fetcher.d.ts

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

import { PrimitiveType } from "./index";
import { PrimitiveType } from "./registerComponent";
export declare type Fetcher = (...args: any[]) => Promise<any>;

@@ -3,0 +3,0 @@ export interface FetcherMeta {

@@ -7,6 +7,6 @@ 'use strict';

require('@plasmicapp/preamble');
var React = require('react');
var React__default = _interopDefault(React);
var ReactDOM = require('react-dom');
require('@plasmicapp/preamble');

@@ -85,11 +85,2 @@ function _extends() {

var root = globalThis;
root.__PlasmicFetcherRegistry = [];
function registerFetcher(fetcher, meta) {
root.__PlasmicFetcherRegistry.push({
fetcher: fetcher,
meta: meta
});
}
function isString(x) {

@@ -113,67 +104,2 @@ return typeof x === "string";

var root$1 = globalThis;
if (root$1.__PlasmicComponentRegistry == null) {
root$1.__PlasmicComponentRegistry = [];
}
function registerComponent(component, meta) {
root$1.__PlasmicComponentRegistry.push({
component: component,
meta: meta
});
}
var root$2 = globalThis;
if (root$2.__PlasmicContextRegistry == null) {
root$2.__PlasmicContextRegistry = [];
}
function registerGlobalContext(component, meta) {
root$2.__PlasmicContextRegistry.push({
component: component,
meta: meta
});
}
var _root$__Sub$setRepeat, _root$__Sub;
/**
* Allows a component from Plasmic Studio to be repeated.
* `isPrimary` should be true for at most one instance of the component, and
* indicates which copy of the element will be highlighted when the element is
* selected in Studio.
* If `isPrimary` is `false`, and `elt` is a React element (or an array of such),
* it'll be cloned (using React.cloneElement) and ajusted if it's a component
* from Plasmic Studio. Otherwise, if `elt` is not a React element, the original
* value is returned.
*/
function repeatedElement(isPrimary, elt) {
return repeatedElementFn(isPrimary, elt);
}
var repeatedElementFn = function repeatedElementFn(isPrimary, elt) {
if (isPrimary) {
return elt;
}
if (Array.isArray(elt)) {
return elt.map(function (v) {
return repeatedElement(isPrimary, v);
});
}
if (elt && React.isValidElement(elt) && typeof elt !== "string") {
return React.cloneElement(elt);
}
return elt;
};
var root$3 = globalThis;
var setRepeatedElementFn = (_root$__Sub$setRepeat = root$3 == null ? void 0 : (_root$__Sub = root$3.__Sub) == null ? void 0 : _root$__Sub.setRepeatedElementFn) != null ? _root$__Sub$setRepeat : function (fn) {
repeatedElementFn = fn;
};
function useForceUpdate() {

@@ -191,80 +117,8 @@ var _useState = React.useState(0),

var tuple = function tuple() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var root = globalThis;
return args;
};
var DataContext = /*#__PURE__*/React.createContext(undefined);
function applySelector(rawData, selector) {
if (!selector) {
return undefined;
}
var curData = rawData;
for (var _iterator = _createForOfIteratorHelperLoose(selector.split(".")), _step; !(_step = _iterator()).done;) {
var _curData;
var key = _step.value;
curData = (_curData = curData) == null ? void 0 : _curData[key];
}
return curData;
if (root.__PlasmicHostVersion == null) {
root.__PlasmicHostVersion = "2";
}
function useSelector(selector) {
var rawData = useDataEnv();
return applySelector(rawData, selector);
}
function useSelectors(selectors) {
if (selectors === void 0) {
selectors = {};
}
var rawData = useDataEnv();
return Object.fromEntries(Object.entries(selectors).filter(function (_ref) {
var key = _ref[0],
selector = _ref[1];
return !!key && !!selector;
}).map(function (_ref2) {
var key = _ref2[0],
selector = _ref2[1];
return tuple(key, applySelector(rawData, selector));
}));
}
function useDataEnv() {
return React.useContext(DataContext);
}
function DataProvider(_ref3) {
var _useDataEnv;
var name = _ref3.name,
data = _ref3.data,
children = _ref3.children;
var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
if (!name) {
return React__default.createElement(React__default.Fragment, null, children);
} else {
var _extends2;
return React__default.createElement(DataContext.Provider, {
value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
}, children);
}
}
function DataCtxReader(_ref4) {
var children = _ref4.children;
var $ctx = useDataEnv();
return children($ctx);
}
var root$4 = globalThis;
if (root$4.__PlasmicHostVersion == null) {
root$4.__PlasmicHostVersion = "2";
}
var rootChangeListeners = [];

@@ -304,3 +158,2 @@

var renderCount = 0;
function setPlasmicRootNode(node) {

@@ -318,3 +171,2 @@ // Keep track of renderCount, which we use as key to ErrorBoundary, so

var PlasmicCanvasContext = /*#__PURE__*/React.createContext(false);

@@ -422,28 +274,3 @@ var usePlasmicCanvasContext = function usePlasmicCanvasContext() {

};
if (root$4.__Sub == null) {
// Creating a side effect here by logging, so that vite won't
// ignore this block for whatever reason
console.log("Plasmic: Setting up app host dependencies");
root$4.__Sub = {
React: React,
ReactDOM: ReactDOM,
// Must include all the dependencies used by canvas rendering,
// and canvas-package (all hostless packages) from host
setPlasmicRootNode: setPlasmicRootNode,
registerRenderErrorListener: registerRenderErrorListener,
repeatedElement: repeatedElement,
setRepeatedElementFn: setRepeatedElementFn,
PlasmicCanvasContext: PlasmicCanvasContext,
DataProvider: DataProvider,
useDataEnv: useDataEnv,
useSelector: useSelector,
useSelectors: useSelectors,
applySelector: applySelector,
DataCtxReader: DataCtxReader
};
}
var renderErrorListeners = [];
function registerRenderErrorListener(listener) {

@@ -506,2 +333,190 @@ renderErrorListeners.push(listener);

var tuple = function tuple() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args;
};
var DataContext = /*#__PURE__*/React.createContext(undefined);
function applySelector(rawData, selector) {
if (!selector) {
return undefined;
}
var curData = rawData;
for (var _iterator = _createForOfIteratorHelperLoose(selector.split(".")), _step; !(_step = _iterator()).done;) {
var _curData;
var key = _step.value;
curData = (_curData = curData) == null ? void 0 : _curData[key];
}
return curData;
}
function useSelector(selector) {
var rawData = useDataEnv();
return applySelector(rawData, selector);
}
function useSelectors(selectors) {
if (selectors === void 0) {
selectors = {};
}
var rawData = useDataEnv();
return Object.fromEntries(Object.entries(selectors).filter(function (_ref) {
var key = _ref[0],
selector = _ref[1];
return !!key && !!selector;
}).map(function (_ref2) {
var key = _ref2[0],
selector = _ref2[1];
return tuple(key, applySelector(rawData, selector));
}));
}
function useDataEnv() {
return React.useContext(DataContext);
}
function DataProvider(_ref3) {
var _useDataEnv;
var name = _ref3.name,
data = _ref3.data,
children = _ref3.children;
var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
if (!name) {
return React__default.createElement(React__default.Fragment, null, children);
} else {
var _extends2;
return React__default.createElement(DataContext.Provider, {
value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
}, children);
}
}
function DataCtxReader(_ref4) {
var children = _ref4.children;
var $ctx = useDataEnv();
return children($ctx);
}
var root$1 = globalThis;
root$1.__PlasmicFetcherRegistry = [];
function registerFetcher(fetcher, meta) {
root$1.__PlasmicFetcherRegistry.push({
fetcher: fetcher,
meta: meta
});
}
var root$2 = globalThis;
if (root$2.__PlasmicComponentRegistry == null) {
root$2.__PlasmicComponentRegistry = [];
}
function registerComponent(component, meta) {
root$2.__PlasmicComponentRegistry.push({
component: component,
meta: meta
});
}
var root$3 = globalThis;
if (root$3.__PlasmicContextRegistry == null) {
root$3.__PlasmicContextRegistry = [];
}
function registerGlobalContext(component, meta) {
root$3.__PlasmicContextRegistry.push({
component: component,
meta: meta
});
}
var _root$__Sub$setRepeat, _root$__Sub;
/**
* Allows a component from Plasmic Studio to be repeated.
* `isPrimary` should be true for at most one instance of the component, and
* indicates which copy of the element will be highlighted when the element is
* selected in Studio.
* If `isPrimary` is `false`, and `elt` is a React element (or an array of such),
* it'll be cloned (using React.cloneElement) and ajusted if it's a component
* from Plasmic Studio. Otherwise, if `elt` is not a React element, the original
* value is returned.
*/
function repeatedElement(isPrimary, elt) {
return repeatedElementFn(isPrimary, elt);
}
var repeatedElementFn = function repeatedElementFn(isPrimary, elt) {
if (isPrimary) {
return elt;
}
if (Array.isArray(elt)) {
return elt.map(function (v) {
return repeatedElement(isPrimary, v);
});
}
if (elt && React.isValidElement(elt) && typeof elt !== "string") {
return React.cloneElement(elt);
}
return elt;
};
var root$4 = globalThis;
var setRepeatedElementFn = (_root$__Sub$setRepeat = root$4 == null ? void 0 : (_root$__Sub = root$4.__Sub) == null ? void 0 : _root$__Sub.setRepeatedElementFn) != null ? _root$__Sub$setRepeat : function (fn) {
repeatedElementFn = fn;
};
var hostModule = {
__proto__: null,
PlasmicCanvasContext: PlasmicCanvasContext,
PlasmicCanvasHost: PlasmicCanvasHost,
usePlasmicCanvasContext: usePlasmicCanvasContext,
unstable_registerFetcher: registerFetcher,
registerComponent: registerComponent,
registerGlobalContext: registerGlobalContext,
repeatedElement: repeatedElement,
DataContext: DataContext,
applySelector: applySelector,
useSelector: useSelector,
useSelectors: useSelectors,
useDataEnv: useDataEnv,
DataProvider: DataProvider,
DataCtxReader: DataCtxReader
};
var root$5 = globalThis;
if (root$5.__Sub == null) {
// Creating a side effect here by logging, so that vite won't
// ignore this block for whatever reason
console.log("Plasmic: Setting up app host dependencies");
root$5.__Sub = /*#__PURE__*/_extends({
React: React,
ReactDOM: ReactDOM,
hostModule: hostModule,
hostUtils: {
setPlasmicRootNode: setPlasmicRootNode,
registerRenderErrorListener: registerRenderErrorListener,
setRepeatedElementFn: setRepeatedElementFn
},
// For backwards compatibility:
setPlasmicRootNode: setPlasmicRootNode,
registerRenderErrorListener: registerRenderErrorListener,
setRepeatedElementFn: setRepeatedElementFn
}, hostModule);
}
exports.DataContext = DataContext;

@@ -508,0 +523,0 @@ exports.DataCtxReader = DataCtxReader;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("@plasmicapp/preamble");var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=require("react-dom");function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l=globalThis;l.__PlasmicFetcherRegistry=[];var u=globalThis;null==u.__PlasmicComponentRegistry&&(u.__PlasmicComponentRegistry=[]);var c,s,p=globalThis;function f(e,t){return m(e,t)}null==p.__PlasmicContextRegistry&&(p.__PlasmicContextRegistry=[]);var m=function(e,n){return e?n:Array.isArray(n)?n.map((function(t){return f(e,t)})):n&&t.isValidElement(n)&&"string"!=typeof n?t.cloneElement(n):n},d=globalThis,v=null!=(c=null==d||null==(s=d.__Sub)?void 0:s.setRepeatedElementFn)?c:function(e){m=e},h=t.createContext(void 0);function y(e,t){if(t){for(var n,r=e,o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t.split("."));!(n=o()).done;){var a;r=null==(a=r)?void 0:a[n.value]}return r}}function b(e){return y(_(),e)}function g(e){void 0===e&&(e={});var t=_();return Object.fromEntries(Object.entries(e).filter((function(e){return!!e[0]&&!!e[1]})).map((function(e){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t}(e[0],y(t,e[1]))})))}function _(){return t.useContext(h)}function x(e){var t,r,a=e.name,i=e.data,l=e.children,u=null!=(t=_())?t:{};return a?n.createElement(h.Provider,{value:o({},u,(r={},r[a]=i,r))},l):n.createElement(n.Fragment,null,l)}function E(e){return(0,e.children)(_())}var w=globalThis;null==w.__PlasmicHostVersion&&(w.__PlasmicHostVersion="2");var C=[],P=new function(e){var t=this;this.value=null,this.set=function(e){t.value=e,C.forEach((function(e){return e()}))},this.get=function(){return t.value}}(null);function R(){return function(e,t){if(void 0===t&&(t=""),null==e)throw t=(function(e){return"string"==typeof e}(t)?t:t())||"",new Error("Value must not be undefined or null"+(t?"- "+t:""));return e}(new URL("https://fakeurl/"+location.hash.replace(/#/,"?")).searchParams.get("origin"),"Missing information from Plasmic window.")}var S=0,j=t.createContext(!1);function O(){var e,n,o,a=!!window.parent,i=!(null==(e=location.hash)||!e.match(/\bcanvas=true\b/)),l=!(null==(n=location.hash)||!n.match(/\blive=true\b/))||!a,u=a&&!document.querySelector("#plasmic-studio-tag")&&!i&&!l,c=(o=t.useState(0)[1],t.useCallback((function(){o((function(e){return e+1}))}),[]));if(t.useLayoutEffect((function(){return C.push(c),function(){var e=C.indexOf(c);e>=0&&C.splice(e,1)}}),[c]),t.useEffect((function(){var e,t;u&&a&&window.parent!==window&&(e=document.createElement("script"),t=R(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[u,a]),t.useEffect((function(){if(!u&&!document.querySelector("#getlibs")&&l){var e=document.createElement("script");e.id="getlibs",e.src=R()+"/static/js/getlibs.js",e.async=!1,e.onload=function(){null==window.__GetlibsReadyResolver||window.__GetlibsReadyResolver()},document.head.append(e)}}),[u]),!a)return null;if(i||l){var s=document.querySelector("#plasmic-app.__wab_user-body");s||((s=document.createElement("div")).id="plasmic-app",s.classList.add("__wab_user-body"),document.body.appendChild(s));var p=new URLSearchParams(location.hash),f=!!i&&{componentName:p.get("componentName")};return r.createPortal(t.createElement(A,{key:""+S},t.createElement(j.Provider,{value:f},P.get())),s,"plasmic-app")}return u&&window.parent===window?t.createElement("iframe",{src:"https://docs.plasmic.app/app-content/app-host-ready#appHostUrl="+encodeURIComponent(location.href),style:{width:"100vw",height:"100vh",border:"none",position:"fixed",top:0,left:0,zIndex:99999999}}):null}null==w.__Sub&&(console.log("Plasmic: Setting up app host dependencies"),w.__Sub={React:t,ReactDOM:r,setPlasmicRootNode:function(e){S++,P.set(e)},registerRenderErrorListener:function(e){return D.push(e),function(){var t=D.indexOf(e);t>=0&&D.splice(t,1)}},repeatedElement:f,setRepeatedElementFn:v,PlasmicCanvasContext:j,DataProvider:x,useDataEnv:_,useSelector:b,useSelectors:g,applySelector:y,DataCtxReader:E});var D=[],A=function(e){var n,r;function o(t){var n;return(n=e.call(this,t)||this).state={},n}r=e,(n=o).prototype=Object.create(r.prototype),n.prototype.constructor=n,a(n,r),o.getDerivedStateFromError=function(e){return{error:e}};var i=o.prototype;return i.componentDidCatch=function(e){D.forEach((function(t){return t(e)}))},i.render=function(){return this.state.error?t.createElement("div",null,"Error: ",""+this.state.error.message):this.props.children},o}(t.Component);function F(){return null}exports.DataContext=h,exports.DataCtxReader=E,exports.DataProvider=x,exports.PlasmicCanvasContext=j,exports.PlasmicCanvasHost=function(e){var n=e.enableWebpackHmr,r=t.useState(null),o=r[0],a=r[1];return t.useEffect((function(){a(t.createElement(O,null))}),[]),t.createElement(t.Fragment,null,!n&&t.createElement(F,null),o)},exports.applySelector=y,exports.registerComponent=function(e,t){u.__PlasmicComponentRegistry.push({component:e,meta:t})},exports.registerGlobalContext=function(e,t){p.__PlasmicContextRegistry.push({component:e,meta:t})},exports.repeatedElement=f,exports.unstable_registerFetcher=function(e,t){l.__PlasmicFetcherRegistry.push({fetcher:e,meta:t})},exports.useDataEnv=_,exports.usePlasmicCanvasContext=function(){return t.useContext(j)},exports.useSelector=b,exports.useSelectors=g;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=require("react-dom");function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}require("@plasmicapp/preamble");var s=globalThis;null==s.__PlasmicHostVersion&&(s.__PlasmicHostVersion="2");var l=[],u=new function(e){var t=this;this.value=null,this.set=function(e){t.value=e,l.forEach((function(e){return e()}))},this.get=function(){return t.value}}(null);function c(){return function(e,t){if(void 0===t&&(t=""),null==e)throw t=(function(e){return"string"==typeof e}(t)?t:t())||"",new Error("Value must not be undefined or null"+(t?"- "+t:""));return e}(new URL("https://fakeurl/"+location.hash.replace(/#/,"?")).searchParams.get("origin"),"Missing information from Plasmic window.")}var p=0;function f(e){p++,u.set(e)}var m=t.createContext(!1),d=function(){return t.useContext(m)};function v(){var e,n,o,a=!!window.parent,i=!(null==(e=location.hash)||!e.match(/\bcanvas=true\b/)),s=!(null==(n=location.hash)||!n.match(/\blive=true\b/))||!a,f=a&&!document.querySelector("#plasmic-studio-tag")&&!i&&!s,d=(o=t.useState(0)[1],t.useCallback((function(){o((function(e){return e+1}))}),[]));if(t.useLayoutEffect((function(){return l.push(d),function(){var e=l.indexOf(d);e>=0&&l.splice(e,1)}}),[d]),t.useEffect((function(){var e,t;f&&a&&window.parent!==window&&(e=document.createElement("script"),t=c(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[f,a]),t.useEffect((function(){if(!f&&!document.querySelector("#getlibs")&&s){var e=document.createElement("script");e.id="getlibs",e.src=c()+"/static/js/getlibs.js",e.async=!1,e.onload=function(){null==window.__GetlibsReadyResolver||window.__GetlibsReadyResolver()},document.head.append(e)}}),[f]),!a)return null;if(i||s){var v=document.querySelector("#plasmic-app.__wab_user-body");v||((v=document.createElement("div")).id="plasmic-app",v.classList.add("__wab_user-body"),document.body.appendChild(v));var h=new URLSearchParams(location.hash),b=!!i&&{componentName:h.get("componentName")};return r.createPortal(t.createElement(g,{key:""+p},t.createElement(m.Provider,{value:b},u.get())),v,"plasmic-app")}return f&&window.parent===window?t.createElement("iframe",{src:"https://docs.plasmic.app/app-content/app-host-ready#appHostUrl="+encodeURIComponent(location.href),style:{width:"100vw",height:"100vh",border:"none",position:"fixed",top:0,left:0,zIndex:99999999}}):null}var h=function(e){var n=e.enableWebpackHmr,r=t.useState(null),o=r[0],a=r[1];return t.useEffect((function(){a(t.createElement(v,null))}),[]),t.createElement(t.Fragment,null,!n&&t.createElement(_,null),o)},b=[];function y(e){return b.push(e),function(){var t=b.indexOf(e);t>=0&&b.splice(t,1)}}var g=function(e){var n,r;function o(t){var n;return(n=e.call(this,t)||this).state={},n}r=e,(n=o).prototype=Object.create(r.prototype),n.prototype.constructor=n,a(n,r),o.getDerivedStateFromError=function(e){return{error:e}};var i=o.prototype;return i.componentDidCatch=function(e){b.forEach((function(t){return t(e)}))},i.render=function(){return this.state.error?t.createElement("div",null,"Error: ",""+this.state.error.message):this.props.children},o}(t.Component);function _(){return null}var x=t.createContext(void 0);function C(e,t){if(t){for(var n,r=e,o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t.split("."));!(n=o()).done;){var a;r=null==(a=r)?void 0:a[n.value]}return r}}function E(e){return C(P(),e)}function w(e){void 0===e&&(e={});var t=P();return Object.fromEntries(Object.entries(e).filter((function(e){return!!e[0]&&!!e[1]})).map((function(e){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t}(e[0],C(t,e[1]))})))}function P(){return t.useContext(x)}function R(e){var t,r,a=e.name,i=e.data,s=e.children,l=null!=(t=P())?t:{};return a?n.createElement(x.Provider,{value:o({},l,(r={},r[a]=i,r))},s):n.createElement(n.Fragment,null,s)}function S(e){return(0,e.children)(P())}var j=globalThis;function O(e,t){j.__PlasmicFetcherRegistry.push({fetcher:e,meta:t})}j.__PlasmicFetcherRegistry=[];var D=globalThis;function F(e,t){D.__PlasmicComponentRegistry.push({component:e,meta:t})}null==D.__PlasmicComponentRegistry&&(D.__PlasmicComponentRegistry=[]);var A,T,q=globalThis;function H(e,t){q.__PlasmicContextRegistry.push({component:e,meta:t})}function L(e,t){return U(e,t)}null==q.__PlasmicContextRegistry&&(q.__PlasmicContextRegistry=[]);var U=function(e,n){return e?n:Array.isArray(n)?n.map((function(t){return L(e,t)})):n&&t.isValidElement(n)&&"string"!=typeof n?t.cloneElement(n):n},I=globalThis,M=null!=(A=null==I||null==(T=I.__Sub)?void 0:T.setRepeatedElementFn)?A:function(e){U=e},k={__proto__:null,PlasmicCanvasContext:m,PlasmicCanvasHost:h,usePlasmicCanvasContext:d,unstable_registerFetcher:O,registerComponent:F,registerGlobalContext:H,repeatedElement:L,DataContext:x,applySelector:C,useSelector:E,useSelectors:w,useDataEnv:P,DataProvider:R,DataCtxReader:S},G=globalThis;null==G.__Sub&&(console.log("Plasmic: Setting up app host dependencies"),G.__Sub=o({React:t,ReactDOM:r,hostModule:k,hostUtils:{setPlasmicRootNode:f,registerRenderErrorListener:y,setRepeatedElementFn:M},setPlasmicRootNode:f,registerRenderErrorListener:y,setRepeatedElementFn:M},k)),exports.DataContext=x,exports.DataCtxReader=S,exports.DataProvider=R,exports.PlasmicCanvasContext=m,exports.PlasmicCanvasHost=h,exports.applySelector=C,exports.registerComponent=F,exports.registerGlobalContext=H,exports.repeatedElement=L,exports.unstable_registerFetcher=O,exports.useDataEnv=P,exports.usePlasmicCanvasContext=d,exports.useSelector=E,exports.useSelectors=w;
//# sourceMappingURL=host.cjs.production.min.js.map

@@ -1,6 +0,6 @@

import '@plasmicapp/preamble';
import * as React from 'react';
import React__default, { isValidElement, cloneElement, useState, useCallback, createContext, useContext, useEffect, createElement, Fragment, useLayoutEffect, Component } from 'react';
import React__default, { useState, useCallback, createContext, useContext, useEffect, createElement, Fragment, useLayoutEffect, Component, isValidElement, cloneElement } from 'react';
import * as ReactDOM from 'react-dom';
import { createPortal } from 'react-dom';
import '@plasmicapp/preamble';

@@ -79,11 +79,2 @@ function _extends() {

var root = globalThis;
root.__PlasmicFetcherRegistry = [];
function registerFetcher(fetcher, meta) {
root.__PlasmicFetcherRegistry.push({
fetcher: fetcher,
meta: meta
});
}
function isString(x) {

@@ -107,67 +98,2 @@ return typeof x === "string";

var root$1 = globalThis;
if (root$1.__PlasmicComponentRegistry == null) {
root$1.__PlasmicComponentRegistry = [];
}
function registerComponent(component, meta) {
root$1.__PlasmicComponentRegistry.push({
component: component,
meta: meta
});
}
var root$2 = globalThis;
if (root$2.__PlasmicContextRegistry == null) {
root$2.__PlasmicContextRegistry = [];
}
function registerGlobalContext(component, meta) {
root$2.__PlasmicContextRegistry.push({
component: component,
meta: meta
});
}
var _root$__Sub$setRepeat, _root$__Sub;
/**
* Allows a component from Plasmic Studio to be repeated.
* `isPrimary` should be true for at most one instance of the component, and
* indicates which copy of the element will be highlighted when the element is
* selected in Studio.
* If `isPrimary` is `false`, and `elt` is a React element (or an array of such),
* it'll be cloned (using React.cloneElement) and ajusted if it's a component
* from Plasmic Studio. Otherwise, if `elt` is not a React element, the original
* value is returned.
*/
function repeatedElement(isPrimary, elt) {
return repeatedElementFn(isPrimary, elt);
}
var repeatedElementFn = function repeatedElementFn(isPrimary, elt) {
if (isPrimary) {
return elt;
}
if (Array.isArray(elt)) {
return elt.map(function (v) {
return repeatedElement(isPrimary, v);
});
}
if (elt && isValidElement(elt) && typeof elt !== "string") {
return cloneElement(elt);
}
return elt;
};
var root$3 = globalThis;
var setRepeatedElementFn = (_root$__Sub$setRepeat = root$3 == null ? void 0 : (_root$__Sub = root$3.__Sub) == null ? void 0 : _root$__Sub.setRepeatedElementFn) != null ? _root$__Sub$setRepeat : function (fn) {
repeatedElementFn = fn;
};
function useForceUpdate() {

@@ -185,80 +111,8 @@ var _useState = useState(0),

var tuple = function tuple() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var root = globalThis;
return args;
};
var DataContext = /*#__PURE__*/createContext(undefined);
function applySelector(rawData, selector) {
if (!selector) {
return undefined;
}
var curData = rawData;
for (var _iterator = _createForOfIteratorHelperLoose(selector.split(".")), _step; !(_step = _iterator()).done;) {
var _curData;
var key = _step.value;
curData = (_curData = curData) == null ? void 0 : _curData[key];
}
return curData;
if (root.__PlasmicHostVersion == null) {
root.__PlasmicHostVersion = "2";
}
function useSelector(selector) {
var rawData = useDataEnv();
return applySelector(rawData, selector);
}
function useSelectors(selectors) {
if (selectors === void 0) {
selectors = {};
}
var rawData = useDataEnv();
return Object.fromEntries(Object.entries(selectors).filter(function (_ref) {
var key = _ref[0],
selector = _ref[1];
return !!key && !!selector;
}).map(function (_ref2) {
var key = _ref2[0],
selector = _ref2[1];
return tuple(key, applySelector(rawData, selector));
}));
}
function useDataEnv() {
return useContext(DataContext);
}
function DataProvider(_ref3) {
var _useDataEnv;
var name = _ref3.name,
data = _ref3.data,
children = _ref3.children;
var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
if (!name) {
return React__default.createElement(React__default.Fragment, null, children);
} else {
var _extends2;
return React__default.createElement(DataContext.Provider, {
value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
}, children);
}
}
function DataCtxReader(_ref4) {
var children = _ref4.children;
var $ctx = useDataEnv();
return children($ctx);
}
var root$4 = globalThis;
if (root$4.__PlasmicHostVersion == null) {
root$4.__PlasmicHostVersion = "2";
}
var rootChangeListeners = [];

@@ -298,3 +152,2 @@

var renderCount = 0;
function setPlasmicRootNode(node) {

@@ -312,3 +165,2 @@ // Keep track of renderCount, which we use as key to ErrorBoundary, so

var PlasmicCanvasContext = /*#__PURE__*/createContext(false);

@@ -416,28 +268,3 @@ var usePlasmicCanvasContext = function usePlasmicCanvasContext() {

};
if (root$4.__Sub == null) {
// Creating a side effect here by logging, so that vite won't
// ignore this block for whatever reason
console.log("Plasmic: Setting up app host dependencies");
root$4.__Sub = {
React: React,
ReactDOM: ReactDOM,
// Must include all the dependencies used by canvas rendering,
// and canvas-package (all hostless packages) from host
setPlasmicRootNode: setPlasmicRootNode,
registerRenderErrorListener: registerRenderErrorListener,
repeatedElement: repeatedElement,
setRepeatedElementFn: setRepeatedElementFn,
PlasmicCanvasContext: PlasmicCanvasContext,
DataProvider: DataProvider,
useDataEnv: useDataEnv,
useSelector: useSelector,
useSelectors: useSelectors,
applySelector: applySelector,
DataCtxReader: DataCtxReader
};
}
var renderErrorListeners = [];
function registerRenderErrorListener(listener) {

@@ -503,3 +330,191 @@ renderErrorListeners.push(listener);

var tuple = function tuple() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args;
};
var DataContext = /*#__PURE__*/createContext(undefined);
function applySelector(rawData, selector) {
if (!selector) {
return undefined;
}
var curData = rawData;
for (var _iterator = _createForOfIteratorHelperLoose(selector.split(".")), _step; !(_step = _iterator()).done;) {
var _curData;
var key = _step.value;
curData = (_curData = curData) == null ? void 0 : _curData[key];
}
return curData;
}
function useSelector(selector) {
var rawData = useDataEnv();
return applySelector(rawData, selector);
}
function useSelectors(selectors) {
if (selectors === void 0) {
selectors = {};
}
var rawData = useDataEnv();
return Object.fromEntries(Object.entries(selectors).filter(function (_ref) {
var key = _ref[0],
selector = _ref[1];
return !!key && !!selector;
}).map(function (_ref2) {
var key = _ref2[0],
selector = _ref2[1];
return tuple(key, applySelector(rawData, selector));
}));
}
function useDataEnv() {
return useContext(DataContext);
}
function DataProvider(_ref3) {
var _useDataEnv;
var name = _ref3.name,
data = _ref3.data,
children = _ref3.children;
var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
if (!name) {
return React__default.createElement(React__default.Fragment, null, children);
} else {
var _extends2;
return React__default.createElement(DataContext.Provider, {
value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
}, children);
}
}
function DataCtxReader(_ref4) {
var children = _ref4.children;
var $ctx = useDataEnv();
return children($ctx);
}
var root$1 = globalThis;
root$1.__PlasmicFetcherRegistry = [];
function registerFetcher(fetcher, meta) {
root$1.__PlasmicFetcherRegistry.push({
fetcher: fetcher,
meta: meta
});
}
var root$2 = globalThis;
if (root$2.__PlasmicComponentRegistry == null) {
root$2.__PlasmicComponentRegistry = [];
}
function registerComponent(component, meta) {
root$2.__PlasmicComponentRegistry.push({
component: component,
meta: meta
});
}
var root$3 = globalThis;
if (root$3.__PlasmicContextRegistry == null) {
root$3.__PlasmicContextRegistry = [];
}
function registerGlobalContext(component, meta) {
root$3.__PlasmicContextRegistry.push({
component: component,
meta: meta
});
}
var _root$__Sub$setRepeat, _root$__Sub;
/**
* Allows a component from Plasmic Studio to be repeated.
* `isPrimary` should be true for at most one instance of the component, and
* indicates which copy of the element will be highlighted when the element is
* selected in Studio.
* If `isPrimary` is `false`, and `elt` is a React element (or an array of such),
* it'll be cloned (using React.cloneElement) and ajusted if it's a component
* from Plasmic Studio. Otherwise, if `elt` is not a React element, the original
* value is returned.
*/
function repeatedElement(isPrimary, elt) {
return repeatedElementFn(isPrimary, elt);
}
var repeatedElementFn = function repeatedElementFn(isPrimary, elt) {
if (isPrimary) {
return elt;
}
if (Array.isArray(elt)) {
return elt.map(function (v) {
return repeatedElement(isPrimary, v);
});
}
if (elt && isValidElement(elt) && typeof elt !== "string") {
return cloneElement(elt);
}
return elt;
};
var root$4 = globalThis;
var setRepeatedElementFn = (_root$__Sub$setRepeat = root$4 == null ? void 0 : (_root$__Sub = root$4.__Sub) == null ? void 0 : _root$__Sub.setRepeatedElementFn) != null ? _root$__Sub$setRepeat : function (fn) {
repeatedElementFn = fn;
};
var hostModule = {
__proto__: null,
PlasmicCanvasContext: PlasmicCanvasContext,
PlasmicCanvasHost: PlasmicCanvasHost,
usePlasmicCanvasContext: usePlasmicCanvasContext,
unstable_registerFetcher: registerFetcher,
registerComponent: registerComponent,
registerGlobalContext: registerGlobalContext,
repeatedElement: repeatedElement,
DataContext: DataContext,
applySelector: applySelector,
useSelector: useSelector,
useSelectors: useSelectors,
useDataEnv: useDataEnv,
DataProvider: DataProvider,
DataCtxReader: DataCtxReader
};
var root$5 = globalThis;
if (root$5.__Sub == null) {
// Creating a side effect here by logging, so that vite won't
// ignore this block for whatever reason
console.log("Plasmic: Setting up app host dependencies");
root$5.__Sub = /*#__PURE__*/_extends({
React: React,
ReactDOM: ReactDOM,
hostModule: hostModule,
hostUtils: {
setPlasmicRootNode: setPlasmicRootNode,
registerRenderErrorListener: registerRenderErrorListener,
setRepeatedElementFn: setRepeatedElementFn
},
// For backwards compatibility:
setPlasmicRootNode: setPlasmicRootNode,
registerRenderErrorListener: registerRenderErrorListener,
setRepeatedElementFn: setRepeatedElementFn
}, hostModule);
}
export { DataContext, DataCtxReader, DataProvider, PlasmicCanvasContext, PlasmicCanvasHost, applySelector, registerComponent, registerGlobalContext, repeatedElement, registerFetcher as unstable_registerFetcher, useDataEnv, usePlasmicCanvasContext, useSelector, useSelectors };
//# sourceMappingURL=host.esm.js.map

@@ -1,48 +0,1 @@

import "@plasmicapp/preamble";
import * as React from "react";
import { registerFetcher as unstable_registerFetcher } from "./fetcher";
import { PlasmicElement } from "./element-types";
import registerComponent, { ComponentMeta, ComponentRegistration, ComponentTemplates, PrimitiveType, PropType } from "./registerComponent";
import registerGlobalContext, { GlobalContextMeta, GlobalContextRegistration, PropType as GlobalContextPropType } from "./registerGlobalContext";
import repeatedElement from "./repeatedElement";
export { unstable_registerFetcher };
export { repeatedElement };
export { registerComponent, ComponentMeta, ComponentRegistration, ComponentTemplates, PrimitiveType, PropType, };
export { registerGlobalContext, GlobalContextMeta, GlobalContextRegistration, GlobalContextPropType, };
export { PlasmicElement };
export * from "./data";
declare global {
interface Window {
__PlasmicHostVersion: string;
}
}
/**
* React context to detect whether the component is rendered on Plasmic editor.
* If not, return false.
* If so, return an object with more information about the component
*/
export declare const PlasmicCanvasContext: React.Context<boolean | {
componentName: string | null;
}>;
export declare const usePlasmicCanvasContext: () => boolean | {
componentName: string | null;
};
interface PlasmicCanvasHostProps {
/**
* Webpack hmr uses EventSource to listen to hot reloads, but that
* resultsin a persistent connection from each window. In Plasmic
* Studio, if a project is configured to use app-hosting with a
* nextjs or gatsby server running in dev mode, each artboard will
* be holding a persistent connection to the dev server.
* Because browsers have a limit to how many connections can
* be held at a time by domain, this means after X artboards, new
* artboards will freeze and not load.
*
* By default, <PlasmicCanvasHost /> will globally mutate
* window.EventSource to avoid using EventSource for HMR, which you
* typically don't need for your custom host page. If you do still
* want to retain HRM, then youc an pass enableWebpackHmr={true}.
*/
enableWebpackHmr?: boolean;
}
export declare const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps>;
export * from "./exports";
{
"name": "@plasmicapp/host",
"version": "1.0.36",
"version": "1.0.37",
"description": "plasmic library for app hosting",

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

},
"gitHead": "9c7331280936955121f7948a75024e3137a844f0"
"gitHead": "f73c954b181396cce9310f47a9c8def5ba317b86"
}

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