@plasmicapp/host 0.0.46 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,7 @@ function registerComponent(component, meta) {
62
62
  });
63
63
  }
64
64
 
65
+ var _root$__Sub$setRepeat, _root$__Sub;
65
66
  /**
66
67
  * Allows a component from Plasmic Studio to be repeated.
67
68
  * `isPrimary` should be true for at most one instance of the component, and
@@ -95,9 +96,10 @@ var repeatedElementFn = function repeatedElementFn(isPrimary, elt) {
95
96
  return elt;
96
97
  };
97
98
 
98
- function setRepeatedElementFn(fn) {
99
+ var root$2 = globalThis;
100
+ var setRepeatedElementFn = (_root$__Sub$setRepeat = root$2 == null ? void 0 : (_root$__Sub = root$2.__Sub) == null ? void 0 : _root$__Sub.setRepeatedElementFn) != null ? _root$__Sub$setRepeat : function (fn) {
99
101
  repeatedElementFn = fn;
100
- }
102
+ };
101
103
 
102
104
  function useForceUpdate() {
103
105
  var _useState = React.useState(0),
@@ -111,10 +113,10 @@ function useForceUpdate() {
111
113
  return update;
112
114
  }
113
115
 
114
- var root$2 = globalThis;
116
+ var root$3 = globalThis;
115
117
 
116
- if (root$2.__PlasmicHostVersion == null) {
117
- root$2.__PlasmicHostVersion = "2";
118
+ if (root$3.__PlasmicHostVersion == null) {
119
+ root$3.__PlasmicHostVersion = "2";
118
120
  }
119
121
 
120
122
  var rootChangeListeners = [];
@@ -252,11 +254,11 @@ var PlasmicCanvasHost = function PlasmicCanvasHost(props) {
252
254
  return React.createElement(React.Fragment, null, !enableWebpackHmr && React.createElement(DisableWebpackHmr, null), node);
253
255
  };
254
256
 
255
- if (root$2.__Sub == null) {
257
+ if (root$3.__Sub == null) {
256
258
  // Creating a side effect here by logging, so that vite won't
257
259
  // ignore this block for whatever reason
258
260
  console.log("Plasmic: Setting up app host dependencies");
259
- root$2.__Sub = {
261
+ root$3.__Sub = {
260
262
  React: React,
261
263
  ReactDOM: ReactDOM,
262
264
  setPlasmicRootNode: setPlasmicRootNode,
@@ -1 +1 @@
1
- {"version":3,"file":"host.cjs.development.js","sources":["../src/data.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ntype StringType<P> =\n | \"string\"\n | ({\n type: \"string\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\ntype BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\ntype NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\ntype JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options: string[] | ContextDependentConfig<P, string[]>;\n}\n\ntype ChoiceType<P> = (\n | {\n defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\ntype SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T,>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T,>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElement(isPrimary, v)) as any as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any as T;\n }\n return elt;\n}\n\nexport function setRepeatedElementFn(fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n}\n\n\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach((f) => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <p>\n Your app is ready to host Plasmic Studio! <br /> <br />\n On the <a href=\"https://studio.plasmic.app/\">Dashboard</a>, click on the{\" \"}\n <i>Config</i> button, and set{\" \"}\n <code>{location.origin + location.pathname}</code> as the host URL.\n <br />\n <br />\n You can find more information about app-hosting{\" \"}\n <a href=\"https://www.plasmic.app/learn/app-hosting/\">here</a>.\n </p>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach((listener) => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","fn","useForceUpdate","useState","setTick","update","useCallback","tick","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","href","origin","pathname","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","__Sub","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,IAAI,GAAGC,UAAb;AAyCAD,IAAI,CAACE,wBAAL,GAAgC,EAAhC;SAEgBC,gBAAgBC,SAAkBC;AAChDL,EAAAA,IAAI,CAACE,wBAAL,CAA8BI,IAA9B,CAAmC;AAAEF,IAA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AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAO5C,mBAAA,MAAA,MAAA,WAAA,OAAgB,KAAK0C,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKf,KAAL,CAAWgB,QAAlB;AACD;AACF;;;EAvByBhD;;AA0B5B,SAASmC,iBAAT;AACE;AAGA,SACEnC,mBAAA,SAAA;AACEiD,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;;;;;"}
1
+ {"version":3,"file":"host.cjs.development.js","sources":["../src/data.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ntype StringType<P> =\n | \"string\"\n | ({\n type: \"string\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\ntype BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\ntype NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\ntype JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options: string[] | ContextDependentConfig<P, string[]>;\n}\n\ntype ChoiceType<P> = (\n | {\n defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\ntype SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach((f) => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <p>\n Your app is ready to host Plasmic Studio! <br /> <br />\n On the <a href=\"https://studio.plasmic.app/\">Dashboard</a>, click on the{\" \"}\n <i>Config</i> button, and set{\" \"}\n <code>{location.origin + location.pathname}</code> as the host URL.\n <br />\n <br />\n You can find more information about app-hosting{\" \"}\n <a href=\"https://www.plasmic.app/learn/app-hosting/\">here</a>.\n </p>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach((listener) => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","href","origin","pathname","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,IAAI,GAAGC,UAAb;AAyCAD,IAAI,CAACE,wBAAL,GAAgC,EAAhC;SAEgBC,gBAAgBC,SAAkBC;AAChDL,EAAAA,IAAI,CAACE,wBAAL,CAA8BI,IAA9B,CAAmC;AAAEF,IAAAA,OAAO,EAAPA,OAAF;AAAWC,IAAAA,IAAI,EAAJA;AAAX,GAAnC;AACD;;AC9CD,SAASE,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;AAID,SAAgBC,OAAUD,GAAyBE;MAAAA;AAAAA,IAAAA,MAAiB;;;AAClE,MAAIF,CAAC,KAAK,IAAN,IAAcA,CAAC,KAAKG,SAAxB,EAAmC;AACjC;AACAD,IAAAA,GAAG,GAAG,CAACH,QAAQ,CAACG,GAAD,CAAR,GAAgBA,GAAhB,GAAsBA,GAAG,EAA1B,KAAiC,EAAvC;AACA,UAAM,IAAIE,KAAJ,0CACkCF,GAAG,UAAQA,GAAR,GAAgB,EADrD,EAAN;AAGD,GAND,MAMO;AACL,WAAOF,CAAP;AACD;AACF;;ACVD,IAAMR,MAAI,GAAGC,UAAb;;AA0RA,IAAID,MAAI,CAACa,0BAAL,IAAmC,IAAvC,EAA6C;AAC3Cb,EAAAA,MAAI,CAACa,0BAAL,GAAkC,EAAlC;AACD;;AAED,SAAwBC,kBACtBC,WACAV;AAEAL,EAAAA,MAAI,CAACa,0BAAL,CAAgCP,IAAhC,CAAqC;AAAES,IAAAA,SAAS,EAATA,SAAF;AAAaV,IAAAA,IAAI,EAAJA;AAAb,GAArC;AACD;;;ACvSD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,SAAO;AACL,QAAM7B,KAAK,GAAG4B,oBAAoB,CAAC3B,OAArB,CAA6B4B,QAA7B,CAAd;;AACA,QAAI7B,KAAK,IAAI,CAAb,EAAgB;AACd4B,MAAAA,oBAAoB,CAAC1B,MAArB,CAA4BF,KAA5B,EAAmC,CAAnC;AACD;AACF,GALD;AAMD;;IAUKc;;;AAIJ,yBAAYO,KAAZ;;;AACE,yCAAMA,KAAN;AACA,WAAKS,KAAL,GAAa,EAAb;;AACD;;gBAEMC,2BAAP,kCAAgCC,KAAhC;AACE,WAAO;AAAEA,MAAAA,KAAK,EAALA;AAAF,KAAP;AACD;;;;SAEDC,oBAAA,2BAAkBD,KAAlB;AACEJ,IAAAA,oBAAoB,CAAC/D,OAArB,CAA6B,UAACgE,QAAD;AAAA,aAAcA,QAAQ,CAACG,KAAD,CAAtB;AAAA,KAA7B;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAO3C,mBAAA,MAAA,MAAA,WAAA,OAAgB,KAAKyC,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAWe,QAAlB;AACD;AACF;;;EAvByB/C;;AA0B5B,SAASmC,iBAAT;AACE;AAGA,SACEnC,mBAAA,SAAA;AACEgD,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("@plasmicapp/preamble");var e=require("react"),t=require("react-dom");function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var r=globalThis;r.__PlasmicFetcherRegistry=[];var o=globalThis;function a(e,t){return i(e,t)}null==o.__PlasmicComponentRegistry&&(o.__PlasmicComponentRegistry=[]);var i=function(t,n){return t?n:Array.isArray(n)?n.map((function(e){return a(t,e)})):n&&e.isValidElement(n)&&"string"!=typeof n?e.cloneElement(n):n},l=globalThis;null==l.__PlasmicHostVersion&&(l.__PlasmicHostVersion="2");var c=[],s=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 u(){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,m=e.createContext(!1);function d(){var n,r,o,a=!!window.parent,i=!(null==(n=location.hash)||!n.match(/\bcanvas=true\b/)),l=!(null==(r=location.hash)||!r.match(/\blive=true\b/))||!a,d=a&&!document.querySelector("#plasmic-studio-tag")&&!i&&!l,f=(o=e.useState(0)[1],e.useCallback((function(){o((function(e){return e+1}))}),[]));if(e.useLayoutEffect((function(){return c.push(f),function(){var e=c.indexOf(f);e>=0&&c.splice(e,1)}}),[f]),e.useEffect((function(){var e,t;d&&a&&window.parent!==window&&(e=document.createElement("script"),t=u(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[d,a]),e.useEffect((function(){if(!d&&!document.querySelector("#getlibs")&&l){var e=document.createElement("script");e.id="getlibs",e.src=u()+"/static/js/getlibs.js",e.async=!1,e.onload=function(){null==window.__GetlibsReadyResolver||window.__GetlibsReadyResolver()},document.head.append(e)}}),[d]),!a)return null;if(i||l){var b=document.querySelector("#plasmic-app.__wab_user-body");return b||((b=document.createElement("div")).id="plasmic-app",b.classList.add("__wab_user-body"),document.body.appendChild(b)),t.createPortal(e.createElement(h,{key:""+p},e.createElement(m.Provider,{value:i},s.get())),b,"plasmic-app")}return d&&window.parent===window?e.createElement("p",null,"Your app is ready to host Plasmic Studio! ",e.createElement("br",null)," ",e.createElement("br",null),"On the ",e.createElement("a",{href:"https://studio.plasmic.app/"},"Dashboard"),", click on the"," ",e.createElement("i",null,"Config")," button, and set"," ",e.createElement("code",null,location.origin+location.pathname)," as the host URL.",e.createElement("br",null),e.createElement("br",null),"You can find more information about app-hosting"," ",e.createElement("a",{href:"https://www.plasmic.app/learn/app-hosting/"},"here"),"."):null}null==l.__Sub&&(console.log("Plasmic: Setting up app host dependencies"),l.__Sub={React:e,ReactDOM:t,setPlasmicRootNode:function(e){p++,s.set(e)},registerRenderErrorListener:function(e){return f.push(e),function(){var t=f.indexOf(e);t>=0&&f.splice(t,1)}},repeatedElement:a,setRepeatedElementFn:function(e){i=e},PlasmicCanvasContext:m});var f=[],h=function(t){var r,o;function a(e){var n;return(n=t.call(this,e)||this).state={},n}o=t,(r=a).prototype=Object.create(o.prototype),r.prototype.constructor=r,n(r,o),a.getDerivedStateFromError=function(e){return{error:e}};var i=a.prototype;return i.componentDidCatch=function(e){f.forEach((function(t){return t(e)}))},i.render=function(){return this.state.error?e.createElement("div",null,"Error: ",""+this.state.error.message):this.props.children},a}(e.Component);function b(){return null}exports.PlasmicCanvasContext=m,exports.PlasmicCanvasHost=function(t){var n=t.enableWebpackHmr,r=e.useState(null),o=r[0],a=r[1];return e.useEffect((function(){a(e.createElement(d,null))}),[]),e.createElement(e.Fragment,null,!n&&e.createElement(b,null),o)},exports.registerComponent=function(e,t){o.__PlasmicComponentRegistry.push({component:e,meta:t})},exports.repeatedElement=a,exports.unstable_registerFetcher=function(e,t){r.__PlasmicFetcherRegistry.push({fetcher:e,meta:t})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("@plasmicapp/preamble");var e=require("react"),t=require("react-dom");function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var r=globalThis;r.__PlasmicFetcherRegistry=[];var o,a,i=globalThis;function l(e,t){return c(e,t)}null==i.__PlasmicComponentRegistry&&(i.__PlasmicComponentRegistry=[]);var c=function(t,n){return t?n:Array.isArray(n)?n.map((function(e){return l(t,e)})):n&&e.isValidElement(n)&&"string"!=typeof n?e.cloneElement(n):n},u=globalThis,s=null!=(o=null==u||null==(a=u.__Sub)?void 0:a.setRepeatedElementFn)?o:function(e){c=e},p=globalThis;null==p.__PlasmicHostVersion&&(p.__PlasmicHostVersion="2");var m=[],d=new function(e){var t=this;this.value=null,this.set=function(e){t.value=e,m.forEach((function(e){return e()}))},this.get=function(){return t.value}}(null);function f(){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 h=0,b=e.createContext(!1);function _(){var n,r,o,a=!!window.parent,i=!(null==(n=location.hash)||!n.match(/\bcanvas=true\b/)),l=!(null==(r=location.hash)||!r.match(/\blive=true\b/))||!a,c=a&&!document.querySelector("#plasmic-studio-tag")&&!i&&!l,u=(o=e.useState(0)[1],e.useCallback((function(){o((function(e){return e+1}))}),[]));if(e.useLayoutEffect((function(){return m.push(u),function(){var e=m.indexOf(u);e>=0&&m.splice(e,1)}}),[u]),e.useEffect((function(){var e,t;c&&a&&window.parent!==window&&(e=document.createElement("script"),t=f(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[c,a]),e.useEffect((function(){if(!c&&!document.querySelector("#getlibs")&&l){var e=document.createElement("script");e.id="getlibs",e.src=f()+"/static/js/getlibs.js",e.async=!1,e.onload=function(){null==window.__GetlibsReadyResolver||window.__GetlibsReadyResolver()},document.head.append(e)}}),[c]),!a)return null;if(i||l){var s=document.querySelector("#plasmic-app.__wab_user-body");return s||((s=document.createElement("div")).id="plasmic-app",s.classList.add("__wab_user-body"),document.body.appendChild(s)),t.createPortal(e.createElement(E,{key:""+h},e.createElement(b.Provider,{value:i},d.get())),s,"plasmic-app")}return c&&window.parent===window?e.createElement("p",null,"Your app is ready to host Plasmic Studio! ",e.createElement("br",null)," ",e.createElement("br",null),"On the ",e.createElement("a",{href:"https://studio.plasmic.app/"},"Dashboard"),", click on the"," ",e.createElement("i",null,"Config")," button, and set"," ",e.createElement("code",null,location.origin+location.pathname)," as the host URL.",e.createElement("br",null),e.createElement("br",null),"You can find more information about app-hosting"," ",e.createElement("a",{href:"https://www.plasmic.app/learn/app-hosting/"},"here"),"."):null}null==p.__Sub&&(console.log("Plasmic: Setting up app host dependencies"),p.__Sub={React:e,ReactDOM:t,setPlasmicRootNode:function(e){h++,d.set(e)},registerRenderErrorListener:function(e){return v.push(e),function(){var t=v.indexOf(e);t>=0&&v.splice(t,1)}},repeatedElement:l,setRepeatedElementFn:s,PlasmicCanvasContext:b});var v=[],E=function(t){var r,o;function a(e){var n;return(n=t.call(this,e)||this).state={},n}o=t,(r=a).prototype=Object.create(o.prototype),r.prototype.constructor=r,n(r,o),a.getDerivedStateFromError=function(e){return{error:e}};var i=a.prototype;return i.componentDidCatch=function(e){v.forEach((function(t){return t(e)}))},i.render=function(){return this.state.error?e.createElement("div",null,"Error: ",""+this.state.error.message):this.props.children},a}(e.Component);function g(){return null}exports.PlasmicCanvasContext=b,exports.PlasmicCanvasHost=function(t){var n=t.enableWebpackHmr,r=e.useState(null),o=r[0],a=r[1];return e.useEffect((function(){a(e.createElement(_,null))}),[]),e.createElement(e.Fragment,null,!n&&e.createElement(g,null),o)},exports.registerComponent=function(e,t){i.__PlasmicComponentRegistry.push({component:e,meta:t})},exports.repeatedElement=l,exports.unstable_registerFetcher=function(e,t){r.__PlasmicFetcherRegistry.push({fetcher:e,meta:t})};
2
2
  //# sourceMappingURL=host.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.cjs.production.min.js","sources":["../src/data.ts","../src/registerComponent.ts","../src/repeatedElement.ts","../src/index.tsx","../src/lang-utils.ts","../src/useForceUpdate.ts"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ntype StringType<P> =\n | \"string\"\n | ({\n type: \"string\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\ntype BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\ntype NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\ntype JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options: string[] | ContextDependentConfig<P, string[]>;\n}\n\ntype ChoiceType<P> = (\n | {\n defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\ntype SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T,>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T,>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElement(isPrimary, v)) as any as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any as T;\n }\n return elt;\n}\n\nexport function setRepeatedElementFn(fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n}\n\n\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach((f) => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <p>\n Your app is ready to host Plasmic Studio! <br /> <br />\n On the <a href=\"https://studio.plasmic.app/\">Dashboard</a>, click on the{\" \"}\n <i>Config</i> button, and set{\" \"}\n <code>{location.origin + location.pathname}</code> as the host URL.\n <br />\n <br />\n You can find more information about app-hosting{\" \"}\n <a href=\"https://www.plasmic.app/learn/app-hosting/\">here</a>.\n </p>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach((listener) => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","__PlasmicComponentRegistry","Array","isArray","map","v","isValidElement","cloneElement","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","value","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","PlasmicCanvasContext","React","_PlasmicCanvasHost","setTick","isFrameAttached","window","parent","isCanvas","_location$hash","match","isLive","_location$hash2","shouldRenderStudio","document","querySelector","forceUpdate","useState","useCallback","tick","push","index","indexOf","splice","script","plasmicOrigin","createElement","src","body","appendChild","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","href","origin","pathname","__Sub","console","log","setPlasmicRootNode","node","set","registerRenderErrorListener","listener","renderErrorListeners","setRepeatedElementFn","fn","props","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","children","DisableWebpackHmr","enableWebpackHmr","setNode","component","meta","fetcher"],"mappings":"8OACA,IAAMA,EAAOC,WAyCbD,EAAKE,yBAA2B,GCpChC,IAAMF,EAAOC,oBCMWE,EAAoBC,EAAoBC,UACvDC,EAAkBF,EAAWC,GDmRC,MAAnCL,EAAKO,6BACPP,EAAKO,2BAA6B,ICjRpC,IAAID,EAAoB,SAAKF,EAAoBC,UAC3CD,EACKC,EAELG,MAAMC,QAAQJ,GACTA,EAAIK,KAAI,SAACC,UAAMR,EAAgBC,EAAWO,MAE/CN,GAAOO,iBAAeP,IAAuB,iBAARA,EAChCQ,eAAaR,GAEfA,GCRHL,EAAOC,WAoBoB,MAA7BD,EAAKc,uBACPd,EAAKc,qBAAuB,KAG9B,IAAMC,EAAsC,GAUtCC,EAAkB,IARtB,SAAoBC,yBAQ6B,cAP3C,SAACC,GACLC,EAAKF,MAAQC,EACbH,EAAoBK,SAAQ,SAACC,UAAMA,iBAE/B,kBAAMF,EAAKF,OAGK,C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AAoBlE,gBAACiE,QACtBhB,uCFoGLmB,EACAC,GAEAzG,EAAKO,2BAA2B+C,KAAK,CAAEkD,UAAAA,EAAWC,KAAAA,yED5PpBC,EAAkBD,GAChDzG,EAAKE,yBAAyBoD,KAAK,CAAEoD,QAAAA,EAASD,KAAAA"}
1
+ {"version":3,"file":"host.cjs.production.min.js","sources":["../src/data.ts","../src/registerComponent.ts","../src/repeatedElement.ts","../src/index.tsx","../src/lang-utils.ts","../src/useForceUpdate.ts"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ntype StringType<P> =\n | \"string\"\n | ({\n type: \"string\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\ntype BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\ntype NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\ntype JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options: string[] | ContextDependentConfig<P, string[]>;\n}\n\ntype ChoiceType<P> = (\n | {\n defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\ntype SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach((f) => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <p>\n Your app is ready to host Plasmic Studio! <br /> <br />\n On the <a href=\"https://studio.plasmic.app/\">Dashboard</a>, click on the{\" \"}\n <i>Config</i> button, and set{\" \"}\n <code>{location.origin + location.pathname}</code> as the host URL.\n <br />\n <br />\n You can find more information about app-hosting{\" \"}\n <a href=\"https://www.plasmic.app/learn/app-hosting/\">here</a>.\n </p>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach((listener) => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","__PlasmicComponentRegistry","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","value","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","PlasmicCanvasContext","React","_PlasmicCanvasHost","setTick","isFrameAttached","window","parent","isCanvas","_location$hash","match","isLive","_location$hash2","shouldRenderStudio","document","querySelector","forceUpdate","useState","useCallback","tick","push","index","indexOf","splice","script","plasmicOrigin","createElement","src","body","appendChild","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","href","origin","pathname","console","log","setPlasmicRootNode","node","set","registerRenderErrorListener","listener","renderErrorListeners","props","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","children","DisableWebpackHmr","enableWebpackHmr","setNode","component","meta","fetcher"],"mappings":"8OACA,IAAMA,EAAOC,WAyCbD,EAAKE,yBAA2B,GCpChC,Q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KAAKiC,GACnB,eACChC,EAAQiC,EAAqBhC,QAAQ+B,GACvChC,GAAS,GACXiC,EAAqB/B,OAAOF,EAAO,KAbrCxD,gBAAAA,EACAW,qBAAAA,EACAyB,qBAAAA,IAKJ,IAAMqD,EAA8C,GAmB9Cb,iCAIQc,8BACJA,UACDC,MAAQ,uFAGRC,yBAAP,SAAgCC,SACvB,CAAEA,MAAAA,+BAGXC,kBAAA,SAAkBD,GAChBJ,EAAqBpE,SAAQ,SAACmE,UAAaA,EAASK,SAGtDE,OAAA,kBACMC,KAAKL,MAAME,MACNxD,wCAAgB2D,KAAKL,MAAME,MAAMI,SAEjCD,KAAKN,MAAMQ,aArBI7D,aA0B5B,SAAS8D,WAEE,8DAjFuE,SAChFT,OAEQU,EAAqBV,EAArBU,mBACgB/D,WACtB,MADKgD,OAAMgB,cAGbhE,aAAgB,WACdgE,EAAQhE,gBAACC,WACR,IAEDD,iCACI+D,GAAoB/D,gBAAC8D,QACtBd,uCFoGLiB,EACAC,GAEA1G,EAAKO,2BAA2BmD,KAAK,CAAE+C,UAAAA,EAAWC,KAAAA,yED5PpBC,EAAkBD,GAChD1G,EAAKE,yBAAyBwD,KAAK,CAAEiD,QAAAA,EAASD,KAAAA"}
package/dist/host.esm.js CHANGED
@@ -60,6 +60,7 @@ function registerComponent(component, meta) {
60
60
  });
61
61
  }
62
62
 
63
+ var _root$__Sub$setRepeat, _root$__Sub;
63
64
  /**
64
65
  * Allows a component from Plasmic Studio to be repeated.
65
66
  * `isPrimary` should be true for at most one instance of the component, and
@@ -93,9 +94,10 @@ var repeatedElementFn = function repeatedElementFn(isPrimary, elt) {
93
94
  return elt;
94
95
  };
95
96
 
96
- function setRepeatedElementFn(fn) {
97
+ var root$2 = globalThis;
98
+ var setRepeatedElementFn = (_root$__Sub$setRepeat = root$2 == null ? void 0 : (_root$__Sub = root$2.__Sub) == null ? void 0 : _root$__Sub.setRepeatedElementFn) != null ? _root$__Sub$setRepeat : function (fn) {
97
99
  repeatedElementFn = fn;
98
- }
100
+ };
99
101
 
100
102
  function useForceUpdate() {
101
103
  var _useState = useState(0),
@@ -109,10 +111,10 @@ function useForceUpdate() {
109
111
  return update;
110
112
  }
111
113
 
112
- var root$2 = globalThis;
114
+ var root$3 = globalThis;
113
115
 
114
- if (root$2.__PlasmicHostVersion == null) {
115
- root$2.__PlasmicHostVersion = "2";
116
+ if (root$3.__PlasmicHostVersion == null) {
117
+ root$3.__PlasmicHostVersion = "2";
116
118
  }
117
119
 
118
120
  var rootChangeListeners = [];
@@ -250,11 +252,11 @@ var PlasmicCanvasHost = function PlasmicCanvasHost(props) {
250
252
  return createElement(Fragment, null, !enableWebpackHmr && createElement(DisableWebpackHmr, null), node);
251
253
  };
252
254
 
253
- if (root$2.__Sub == null) {
255
+ if (root$3.__Sub == null) {
254
256
  // Creating a side effect here by logging, so that vite won't
255
257
  // ignore this block for whatever reason
256
258
  console.log("Plasmic: Setting up app host dependencies");
257
- root$2.__Sub = {
259
+ root$3.__Sub = {
258
260
  React: React,
259
261
  ReactDOM: ReactDOM,
260
262
  setPlasmicRootNode: setPlasmicRootNode,
@@ -1 +1 @@
1
- {"version":3,"file":"host.esm.js","sources":["../src/data.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ntype StringType<P> =\n | \"string\"\n | ({\n type: \"string\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\ntype BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\ntype NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\ntype JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options: string[] | ContextDependentConfig<P, string[]>;\n}\n\ntype ChoiceType<P> = (\n | {\n defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\ntype SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T,>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T,>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElement(isPrimary, v)) as any as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any as T;\n }\n return elt;\n}\n\nexport function setRepeatedElementFn(fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n}\n\n\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach((f) => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <p>\n Your app is ready to host Plasmic Studio! <br /> <br />\n On the <a href=\"https://studio.plasmic.app/\">Dashboard</a>, click on the{\" \"}\n <i>Config</i> button, and set{\" \"}\n <code>{location.origin + location.pathname}</code> as the host URL.\n <br />\n <br />\n You can find more information about app-hosting{\" \"}\n <a href=\"https://www.plasmic.app/learn/app-hosting/\">here</a>.\n </p>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach((listener) => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","fn","useForceUpdate","useState","setTick","update","useCallback","tick","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","href","origin","pathname","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","__Sub","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","process","env","NODE_ENV","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,IAAI,GAAGC,UAAb;AAyCAD,IAAI,CAACE,wBAAL,GAAgC,EAAhC;SAEgBC,gBAAgBC,SAAkBC;AAChDL,EAAAA,IAAI,CAACE,wBAAL,CAA8BI,IAA9B,CAAmC;AAAEF,IAAAA,OAAO,EAAPA,OAAF;AAAWC,IAAAA,IAAI,EAAJA;AAAX,GAAnC;AACD;;AC9CD,SAASE,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;AAID,SAAgBC,OAAUD,GAAyBE;MAAAA;AAAAA,IAAAA,MAAiB;;;AAClE,MAAIF,CAAC,KAAK,IAAN,IAAcA,CAAC,KAAKG,SAAxB,EAAmC;AACjC;AACAD,IAAAA,GAAG,GAAG,CAACH,QAAQ,CAACG,GAAD,CAAR,GAAgBA,GAAhB,GAAsBA,GAAG,EAA1B,KAAiC,EAAvC;AACA,UAAM,IAAIE,KAAJ,0CACkCF,GAAG,UAAQA,GAAR,GAAgB,EADrD,EAAN;AAGD,GAND,MAMO;AACL,WAAOF,CAAP;AACD;AACF;;ACVD,IAAMR,MAAI,GAAGC,UAAb;;AA0RA,IAAID,MAAI,CAAC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,EAApD;;AACA,SAASD,2BAAT,CAAqCE,QAArC;AACED,EAAAA,oBAAoB,CAACjG,IAArB,CAA0BkG,QAA1B;AACA,SAAO;AACL,QAAM9B,KAAK,GAAG6B,oBAAoB,CAAC5B,OAArB,CAA6B6B,QAA7B,CAAd;;AACA,QAAI9B,KAAK,IAAI,CAAb,EAAgB;AACd6B,MAAAA,oBAAoB,CAAC3B,MAArB,CAA4BF,KAA5B,EAAmC,CAAnC;AACD;AACF,GALD;AAMD;;IAUKc;;;AAIJ,yBAAYO,KAAZ;;;AACE,yCAAMA,KAAN;AACA,WAAKU,KAAL,GAAa,EAAb;;AACD;;gBAEMC,2BAAP,kCAAgCC,KAAhC;AACE,WAAO;AAAEA,MAAAA,KAAK,EAALA;AAAF,KAAP;AACD;;;;SAEDC,oBAAA,2BAAkBD,KAAlB;AACEJ,IAAAA,oBAAoB,CAAChE,OAArB,CAA6B,UAACiE,QAAD;AAAA,aAAcA,QAAQ,CAACG,KAAD,CAAtB;AAAA,KAA7B;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAO5C,aAAA,MAAA,MAAA,WAAA,OAAgB,KAAK0C,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKf,KAAL,CAAWgB,QAAlB;AACD;AACF;;;EAvByBhD;;AA0B5B,SAASmC,iBAAT;AACE,MAAIc,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,WAAO,IAAP;AACD;;AACD,SACEnD,aAAA,SAAA;AACEoD,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;"}
1
+ {"version":3,"file":"host.esm.js","sources":["../src/data.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ntype StringType<P> =\n | \"string\"\n | ({\n type: \"string\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\ntype BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\ntype NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\ntype JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options: string[] | ContextDependentConfig<P, string[]>;\n}\n\ntype ChoiceType<P> = (\n | {\n defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\ntype SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach((f) => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <p>\n Your app is ready to host Plasmic Studio! <br /> <br />\n On the <a href=\"https://studio.plasmic.app/\">Dashboard</a>, click on the{\" \"}\n <i>Config</i> button, and set{\" \"}\n <code>{location.origin + location.pathname}</code> as the host URL.\n <br />\n <br />\n You can find more information about app-hosting{\" \"}\n <a href=\"https://www.plasmic.app/learn/app-hosting/\">here</a>.\n </p>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach((listener) => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","href","origin","pathname","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","process","env","NODE_ENV","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,IAAI,GAAGC,UAAb;AAyCAD,IAAI,CAACE,wBAAL,GAAgC,EAAhC;SAEgBC,gBAAgBC,SAAkBC;AAChDL,EAAAA,IAAI,CAACE,wBAAL,CAA8BI,IAA9B,CAAmC;AAAEF,IAAAA,OAAO,EAAPA,OAAF;AAAWC,IAAAA,IAAI,EAAJA;AAAX,GAAnC;AACD;;AC9CD,SAASE,QAA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,KAA7B;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAO3C,aAAA,MAAA,MAAA,WAAA,OAAgB,KAAKyC,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAWe,QAAlB;AACD;AACF;;;EAvByB/C;;AA0B5B,SAASmC,iBAAT;AACE,MAAIa,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,WAAO,IAAP;AACD;;AACD,SACElD,aAAA,SAAA;AACEmD,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;"}
@@ -9,4 +9,4 @@
9
9
  * value is returned.
10
10
  */
11
11
  export default function repeatedElement<T>(isPrimary: boolean, elt: T): T;
12
- export declare function setRepeatedElementFn(fn: typeof repeatedElement): void;
12
+ export declare const setRepeatedElementFn: (fn: typeof repeatedElement) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/host",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "description": "plasmic library for app hosting",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "analyze": "size-limit --why"
30
30
  },
31
31
  "dependencies": {
32
- "@plasmicapp/preamble": "0.0.30",
32
+ "@plasmicapp/preamble": "0.0.31",
33
33
  "window-or-global": "^1.0.1"
34
34
  },
35
35
  "devDependencies": {
@@ -0,0 +1,103 @@
1
+ import type { Properties } from "csstype";
2
+ export declare type CSSProperties = Properties<string | number>;
3
+ declare type ContainerTags = "a" | "address" | "article" | "aside" | "blockquote" | "button" | "code" | "dd" | "div" | "dl" | "dt" | "form" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "header" | "hgroup" | "label" | "li" | "main" | "nav" | "ol" | "p" | "pre" | "section" | "span" | "ul";
4
+ declare type CommonAttrKeys = "title" | "tabIndex" | "className" | "id" | "aria-label" | "aria-hidden" | "aria-labelledby" | "aria-describedby" | "role";
5
+ declare type PictureAttrKeys = "alt" | "loading" | CommonAttrKeys;
6
+ declare type LinkAttrKeys = "href" | "target" | CommonAttrKeys;
7
+ declare type TextAreaAttrKeys = "disabled" | "value" | "cols" | "rows" | "placeholder" | CommonAttrKeys;
8
+ declare type InputAttrKeys = "disabled" | "value" | "defaultValue" | "name" | "autoComplete" | "checked" | "placeholder" | CommonAttrKeys;
9
+ declare type ButtonAttrKeys = "disabled" | CommonAttrKeys;
10
+ declare type Attrs<Keys extends string> = Partial<Record<Keys, string>>;
11
+ export interface PictureElement {
12
+ type: "img";
13
+ src: string;
14
+ styles?: CSSProperties;
15
+ attrs?: Attrs<PictureAttrKeys>;
16
+ }
17
+ export declare type ImageElement = PictureElement;
18
+ interface LinkTextElement {
19
+ type: "text";
20
+ tag: "a";
21
+ value: string;
22
+ styles?: CSSProperties;
23
+ attrs?: Attrs<LinkAttrKeys>;
24
+ }
25
+ interface ButtonTextElement {
26
+ type: "text";
27
+ tag: "button";
28
+ value: string;
29
+ styles?: CSSProperties;
30
+ attrs?: Attrs<ButtonAttrKeys>;
31
+ }
32
+ interface GenericTextElement {
33
+ type: "text";
34
+ /**
35
+ * Default: "div"
36
+ */
37
+ tag?: Exclude<ContainerTags, "a" | "button">;
38
+ value: string;
39
+ styles?: CSSProperties;
40
+ attrs?: Attrs<CommonAttrKeys>;
41
+ }
42
+ export declare type TextElement = string | LinkTextElement | ButtonTextElement | GenericTextElement;
43
+ interface LinkContainerElement {
44
+ type: "box" | "vbox" | "hbox";
45
+ tag: "a";
46
+ children?: PlasmicElement | PlasmicElement[];
47
+ styles?: CSSProperties;
48
+ attrs?: Attrs<LinkAttrKeys>;
49
+ }
50
+ interface ButtonContainerElement {
51
+ type: "box" | "vbox" | "hbox";
52
+ tag: "button";
53
+ children?: PlasmicElement | PlasmicElement[];
54
+ styles?: CSSProperties;
55
+ attrs?: Attrs<ButtonAttrKeys>;
56
+ }
57
+ interface GenericContainerElement {
58
+ type: "box" | "vbox" | "hbox";
59
+ /**
60
+ * Default: "div"
61
+ */
62
+ tag?: Exclude<ContainerTags, "a" | "button">;
63
+ children?: PlasmicElement | PlasmicElement[];
64
+ styles?: CSSProperties;
65
+ attrs?: Attrs<CommonAttrKeys>;
66
+ }
67
+ export declare type ContainerElement = LinkContainerElement | ButtonContainerElement | GenericContainerElement;
68
+ export interface ButtonElement {
69
+ type: "button";
70
+ value: string;
71
+ styles?: CSSProperties;
72
+ attrs?: Attrs<ButtonAttrKeys>;
73
+ }
74
+ interface InputElement {
75
+ type: "input" | "password";
76
+ styles?: CSSProperties;
77
+ attrs?: Attrs<InputAttrKeys>;
78
+ }
79
+ interface TextAreaElement {
80
+ type: "textarea";
81
+ styles?: CSSProperties;
82
+ attrs?: Attrs<TextAreaAttrKeys>;
83
+ }
84
+ export declare type TextInputElement = InputElement | TextAreaElement;
85
+ interface JsonElement {
86
+ type: "json";
87
+ value: any;
88
+ }
89
+ export interface CodeComponentElement<P> {
90
+ type: "component";
91
+ /**
92
+ * The registered component name
93
+ */
94
+ name: string;
95
+ styles?: CSSProperties;
96
+ props?: {
97
+ [prop in keyof Partial<P>]: number | string | boolean | null | undefined | JsonElement | PlasmicElement | PlasmicElement[];
98
+ } & {
99
+ [prop: string]: number | string | boolean | null | undefined | JsonElement | PlasmicElement | PlasmicElement[];
100
+ };
101
+ }
102
+ export declare type PlasmicElement = ImageElement | TextElement | ContainerElement | ButtonElement | TextInputElement | CodeComponentElement<{}>;
103
+ export {};