@plasmicapp/host 1.0.27 → 1.0.28

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.
@@ -1 +1 @@
1
- {"version":3,"file":"host.cjs.development.js","sources":["../src/fetcher.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../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 DefaultValueOrExpr<T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<any>);\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<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\nexport type 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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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 {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | 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\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\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 context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: 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 context 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 context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context 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 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\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.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","export const tuple = <T extends any[]>(...args: T): T => args;\n","import React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport function DataCtxReader({\n children,\n}: {\n children: ($ctx: DataDict | undefined) => ReactNode;\n}) {\n const $ctx = useDataEnv();\n return children($ctx);\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 \"./fetcher\";\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 registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport {\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\n} from \"./data\";\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 {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\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 * If not, return false.\n * If so, return an object with more information about the component\n */\nexport const PlasmicCanvasContext = React.createContext<\n | {\n componentName: string | null;\n }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\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 const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\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\n // Must include all the dependencies used by canvas rendering,\n // and canvas-package (all hostless packages) from host\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\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","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","tuple","args","DataContext","createContext","applySelector","rawData","selector","curData","split","key","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DataCtxReader","$ctx","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","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","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","locationHash","URLSearchParams","plasmicContextValue","componentName","ReactDOM","ErrorBoundary","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","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;;AA2VA,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,IAAA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KAA5B,EAAmC,CAAnC;AACD;AACF,GALD;AAMD;;IAUKkB;;;AAIJ,yBAAYY,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,CAACxE,OAArB,CAA6B,UAACyE,QAAD;AAAA,aAAcA,QAAQ,CAACG,KAAD,CAAtB;AAAA,KAA7B;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAOrF,mBAAA,MAAA,MAAA,WAAA,OAAgB,KAAKmF,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAW5E,QAAlB;AACD;AACF;;;EAvByBE;;AA0B5B,SAAS6E,iBAAT;AACE;AAGA,SACE7E,mBAAA,SAAA;AACEyF,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"host.cjs.development.js","sources":["../src/fetcher.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../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 DefaultValueOrExpr<P, T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, 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\nexport type 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<P>;\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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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 {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | 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\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\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 context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: 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 context 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 context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context 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 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\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.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","export const tuple = <T extends any[]>(...args: T): T => args;\n","import React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport function DataCtxReader({\n children,\n}: {\n children: ($ctx: DataDict | undefined) => ReactNode;\n}) {\n const $ctx = useDataEnv();\n return children($ctx);\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 \"./fetcher\";\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 registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport {\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\n} from \"./data\";\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 {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\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 * If not, return false.\n * If so, return an object with more information about the component\n */\nexport const PlasmicCanvasContext = React.createContext<\n | {\n componentName: string | null;\n }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\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 const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\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\n // Must include all the dependencies used by canvas rendering,\n // and canvas-package (all hostless packages) from host\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\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","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","tuple","args","DataContext","createContext","applySelector","rawData","selector","curData","split","key","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DataCtxReader","$ctx","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","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","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","locationHash","URLSearchParams","plasmicContextValue","componentName","ReactDOM","ErrorBoundary","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","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,GAAn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AAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAW5E,QAAlB;AACD;AACF;;;EAvByBE;;AA0B5B,SAAS6E,iBAAT;AACE;AAGA,SACE7E,mBAAA,SAAA;AACEyF,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"host.cjs.production.min.js","sources":["../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/data.tsx","../src/common.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 DefaultValueOrExpr<T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<any>);\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<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\nexport type 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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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 {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | 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\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\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 context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: 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 context 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 context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context 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 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\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.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 React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport function DataCtxReader({\n children,\n}: {\n children: ($ctx: DataDict | undefined) => ReactNode;\n}) {\n const $ctx = useDataEnv();\n return children($ctx);\n}\n","export const tuple = <T extends any[]>(...args: T): T => args;\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 \"./fetcher\";\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 registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport {\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\n} from \"./data\";\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 {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\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 * If not, return false.\n * If so, return an object with more information about the component\n */\nexport const PlasmicCanvasContext = React.createContext<\n | {\n componentName: string | null;\n }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\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 const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\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\n // Must include all the dependencies used by canvas rendering,\n // and canvas-package (all hostless packages) from host\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\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","__PlasmicComponentRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","__PlasmicContextRegistry","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","DataContext","createContext","undefined","applySelector","rawData","selector","curData","split","_curData","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","args","tuple","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DataCtxReader","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","PlasmicCanvasContext","_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","locationHash","URLSearchParams","plasmicContextValue","componentName","ReactDOM","ErrorBoundary","key","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","console","log","setPlasmicRootNode","node","set","registerRenderErrorListener","listener","renderErrorListeners","props","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","DisableWebpackHmr","enableWebpackHmr","setNode","component","meta","fetcher"],"mappings":"gmBACA,IAAMA,EAAOC,WAyCbD,EAAKE,yBAA2B,GCpChC,IAAMF,EAAOC,WA2V0B,MAAnCD,EAAKG,6BACPH,EAAKG,2BAA6B,ICxVpC,QAAMH,EAAOC,oBCEWG,EAAmBC,EAAoBC,UACtDC,EAAkBF,EAAWC,GD+ED,MAAjCN,EAAKQ,2BACPR,EAAKQ,yBAA2B,IC7ElC,IAAID,EAAoB,SAAIF,EAAoBC,UAC1CD,EACKC,EAELG,MAAMC,QAAQJ,GACRA,EAAIK,KAAI,SAACC,UAAMR,EAAgBC,EAAWO,MAEhDN,GAAOO,iBAAeP,IAAuB,iBAARA,EAC/BQ,eAAaR,GAEhBA,GAGHN,EAAOC,WACAc,iBACXf,YAAAA,EAAMgB,cAANC,EAAaF,wBACb,SAAUG,GACRX,EAAoBW,GC5BXC,EAAcC,qBAAoCC,YAE/CC,EACdC,EACAC,MAEKA,aAGDC,EAAUF,wrBACIC,EAASE,MAAM,qBAAM,OACrCD,WAAUA,UAAAE,kBAELF,YAKOG,EAAYJ,UAEnBF,EADSO,IACcL,YAGhBM,EAAaC,YAAAA,IAAAA,EAA0B,QAC/CR,EAAUM,WACTG,OAAOC,YACZD,OAAOE,QAAQH,GACZI,QAAO,oCACPxB,KAAI,mBCjCU,sCAAqByB,2BAAAA,yBAAeA,EDiCzBC,MAAWf,EAAcC,aAIzD,SAAgBM,WACPS,aAAWnB,YASJoB,aAAeC,IAAAA,KAAMC,IAAAA,KAAMC,IAAAA,SACnCC,WAAcd,OAAgB,UAC/BW,EAIDI,gBAACzB,EAAY0B,UAASC,WAAY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AyB,cAAAA,IAKJ,IAAMmF,EAA8C,GAmB9CnB,iCAIQoB,8BACJA,UACDC,MAAQ,uFAGRC,yBAAP,SAAgCC,SACvB,CAAEA,MAAAA,+BAGXC,kBAAA,SAAkBD,GAChBJ,EAAqB7E,SAAQ,SAAC4E,UAAaA,EAASK,SAGtDE,OAAA,kBACMC,KAAKL,MAAME,MACN1F,wCAAgB6F,KAAKL,MAAME,MAAMI,SAEjCD,KAAKN,MAAMzF,aArBIE,aA0B5B,SAAS+F,WAEE,mIA1FuE,SAChFR,OAEQS,EAAqBT,EAArBS,mBACgBhG,WACtB,MADKkF,OAAMe,cAGbjG,aAAgB,WACdiG,EAAQjG,gBAACyB,WACR,IAEDzB,iCACIgG,GAAoBhG,gBAAC+F,QACtBb,+DL8HLgB,EACAC,GAEA/I,EAAKG,2BAA2BmF,KAAK,CAAEwD,UAAAA,EAAWC,KAAAA,4CCvQlDD,EAAcC,GACd/I,EAAKQ,yBAAyB8E,KAAK,CAAEwD,UAAAA,EAAWC,KAAAA,yEFvDlBC,EAAkBD,GAChD/I,EAAKE,yBAAyBoF,KAAK,CAAE0D,QAAAA,EAASD,KAAAA,0DMgET,kBACrCnG,aAAiBwB"}
1
+ {"version":3,"file":"host.cjs.production.min.js","sources":["../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/data.tsx","../src/common.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 DefaultValueOrExpr<P, T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, 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\nexport type 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<P>;\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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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 {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | 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\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\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 context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: 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 context 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 context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context 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 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\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.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 React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport function DataCtxReader({\n children,\n}: {\n children: ($ctx: DataDict | undefined) => ReactNode;\n}) {\n const $ctx = useDataEnv();\n return children($ctx);\n}\n","export const tuple = <T extends any[]>(...args: T): T => args;\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 \"./fetcher\";\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 registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport {\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\n} from \"./data\";\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 {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\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 * If not, return false.\n * If so, return an object with more information about the component\n */\nexport const PlasmicCanvasContext = React.createContext<\n | {\n componentName: string | null;\n }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\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 const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\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\n // Must include all the dependencies used by canvas rendering,\n // and canvas-package (all hostless packages) from host\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\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","__PlasmicComponentRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","__PlasmicContextRegistry","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","DataContext","createContext","undefined","applySelector","rawData","selector","curData","split","_curData","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","args","tuple","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DataCtxReader","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","PlasmicCanvasContext","_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","locationHash","URLSearchParams","plasmicContextValue","componentName","ReactDOM","ErrorBoundary","key","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","console","log","setPlasmicRootNode","node","set","registerRenderErrorListener","listener","renderErrorListeners","props","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","DisableWebpackHmr","enableWebpackHmr","setNode","component","meta","fetcher"],"mappings":"gmBACA,IAAMA,EAAOC,WAyCbD,EAAKE,yBAA2B,GCpChC,IAAMF,EAAOC,WA2V0B,MAAnCD,EAAKG,6BACPH,EAAKG,2BAA6B,ICxVpC,QAAMH,EAAOC,oBCEWG,EAAmBC,EAAoBC,UACtDC,EAAkBF,EAAWC,GD+ED,MAAjCN,EAAKQ,2BACPR,EAAKQ,yBAA2B,IC7ElC,IAAID,EAAoB,SAAIF,EAAoBC,UAC1CD,EACKC,EAELG,MAAMC,QAAQJ,GACRA,EAAIK,KAAI,SAACC,UAAMR,EAAgBC,EAAWO,MAEhDN,GAAOO,iBAAeP,IAAuB,iBAARA,EAC/BQ,eAAaR,GAEhBA,GAGHN,EAAOC,WACAc,iBACXf,YAAAA,EAAMg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AAAA,0DMgET,kBACrCnG,aAAiBwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"host.esm.js","sources":["../src/fetcher.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../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 DefaultValueOrExpr<T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<any>);\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<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\nexport type 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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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 {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | 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\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\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 context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: 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 context 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 context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context 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 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\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.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","export const tuple = <T extends any[]>(...args: T): T => args;\n","import React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport function DataCtxReader({\n children,\n}: {\n children: ($ctx: DataDict | undefined) => ReactNode;\n}) {\n const $ctx = useDataEnv();\n return children($ctx);\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 \"./fetcher\";\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 registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport {\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\n} from \"./data\";\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 {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\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 * If not, return false.\n * If so, return an object with more information about the component\n */\nexport const PlasmicCanvasContext = React.createContext<\n | {\n componentName: string | null;\n }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\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 const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\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\n // Must include all the dependencies used by canvas rendering,\n // and canvas-package (all hostless packages) from host\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\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","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","tuple","args","DataContext","createContext","applySelector","rawData","selector","curData","split","key","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DataCtxReader","$ctx","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","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","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","locationHash","URLSearchParams","plasmicContextValue","componentName","ReactDOM","ErrorBoundary","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","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;;AA2VA,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;;AChWD,IAAML,MAAI,GAAGC,UAAb;;AAkFA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A,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,CAACxE,OAArB,CAA6B,UAACyE,QAAD;AAAA,aAAcA,QAAQ,CAACG,KAAD,CAAtB;AAAA,KAA7B;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAOrF,aAAA,MAAA,MAAA,WAAA,OAAgB,KAAKmF,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAW5E,QAAlB;AACD;AACF;;;EAvByBE;;AA0B5B,SAAS6E,iBAAT;AACE,MAAIY,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,WAAO,IAAP;AACD;;AACD,SACE3F,aAAA,SAAA;AACE4F,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;"}
1
+ {"version":3,"file":"host.esm.js","sources":["../src/fetcher.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../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 DefaultValueOrExpr<P, T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, 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\nexport type 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<P>;\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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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 {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | 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\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\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 context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: 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 context 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 context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context 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 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\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.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","export const tuple = <T extends any[]>(...args: T): T => args;\n","import React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport function DataCtxReader({\n children,\n}: {\n children: ($ctx: DataDict | undefined) => ReactNode;\n}) {\n const $ctx = useDataEnv();\n return children($ctx);\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 \"./fetcher\";\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 registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport {\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\n} from \"./data\";\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 {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\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 * If not, return false.\n * If so, return an object with more information about the component\n */\nexport const PlasmicCanvasContext = React.createContext<\n | {\n componentName: string | null;\n }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\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 const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\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\n // Must include all the dependencies used by canvas rendering,\n // and canvas-package (all hostless packages) from host\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n useSelector,\n useSelectors,\n applySelector,\n DataCtxReader,\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","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","tuple","args","DataContext","createContext","applySelector","rawData","selector","curData","split","key","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DataCtxReader","$ctx","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","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","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","locationHash","URLSearchParams","plasmicContextValue","componentName","ReactDOM","ErrorBoundary","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","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,SAAS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,KAAKd,KAAL,CAAW5E,QAAlB;AACD;AACF;;;EAvByBE;;AA0B5B,SAAS6E,iBAAT;AACE,MAAIY,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,WAAO,IAAP;AACD;;AACD,SACE3F,aAAA,SAAA;AACE4F,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;"}
@@ -24,18 +24,18 @@ interface PropTypeBase<P> {
24
24
  description?: string;
25
25
  hidden?: ContextDependentConfig<P, boolean>;
26
26
  }
27
- declare type DefaultValueOrExpr<T> = {
27
+ declare type DefaultValueOrExpr<P, T> = {
28
28
  defaultExpr?: undefined;
29
29
  defaultExprHint?: undefined;
30
30
  defaultValue?: T;
31
- defaultValueHint?: T;
31
+ defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
32
32
  } | {
33
33
  defaultValue?: undefined;
34
34
  defaultValueHint?: undefined;
35
35
  defaultExpr?: string;
36
36
  defaultExprHint?: string;
37
37
  };
38
- declare type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;
38
+ declare type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;
39
39
  export declare type StringType<P> = "string" | (({
40
40
  type: "string";
41
41
  control?: "default" | "large";
@@ -45,8 +45,8 @@ export declare type StringType<P> = "string" | (({
45
45
  }) & StringTypeBase<P>);
46
46
  export declare type BooleanType<P> = "boolean" | ({
47
47
  type: "boolean";
48
- } & DefaultValueOrExpr<boolean> & PropTypeBase<P>);
49
- declare type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<number> & {
48
+ } & DefaultValueOrExpr<P, boolean> & PropTypeBase<P>);
49
+ declare type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, number> & {
50
50
  type: "number";
51
51
  };
52
52
  export declare type NumberType<P> = "number" | (({
@@ -64,9 +64,9 @@ export declare type NumberType<P> = "number" | (({
64
64
  */
65
65
  export declare type JSONLikeType<P> = "object" | ({
66
66
  type: "object";
67
- } & DefaultValueOrExpr<any> & PropTypeBase<P>) | ({
67
+ } & DefaultValueOrExpr<P, any> & PropTypeBase<P>) | ({
68
68
  type: "array";
69
- } & DefaultValueOrExpr<any[]> & PropTypeBase<P>);
69
+ } & DefaultValueOrExpr<P, any[]> & PropTypeBase<P>);
70
70
  interface ChoiceTypeBase<P> extends PropTypeBase<P> {
71
71
  type: "choice";
72
72
  options: string[] | {
@@ -79,9 +79,9 @@ interface ChoiceTypeBase<P> extends PropTypeBase<P> {
79
79
  }
80
80
  export declare type ChoiceType<P> = (({
81
81
  multiSelect?: false;
82
- } & DefaultValueOrExpr<string>) | ({
82
+ } & DefaultValueOrExpr<P, string>) | ({
83
83
  multiSelect: true;
84
- } & DefaultValueOrExpr<string[]>)) & ChoiceTypeBase<P>;
84
+ } & DefaultValueOrExpr<P, string[]>)) & ChoiceTypeBase<P>;
85
85
  export interface ModalProps {
86
86
  show?: boolean;
87
87
  children?: React.ReactNode;
@@ -117,8 +117,8 @@ export declare type CustomControl<P> = React.ComponentType<CustomControlProps<P>
117
117
  export declare type CustomType<P> = CustomControl<P> | ({
118
118
  type: "custom";
119
119
  control: CustomControl<P>;
120
- } & PropTypeBase<P> & DefaultValueOrExpr<any>);
121
- declare type SlotType = "slot" | ({
120
+ } & PropTypeBase<P> & DefaultValueOrExpr<P, any>);
121
+ declare type SlotType<P> = "slot" | ({
122
122
  type: "slot";
123
123
  /**
124
124
  * The unique names of all code components that can be placed in the slot
@@ -133,10 +133,10 @@ declare type SlotType = "slot" | ({
133
133
  * repeatedElement().
134
134
  */
135
135
  isRepeated?: boolean;
136
- } & Omit<DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
136
+ } & Omit<DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
137
137
  declare type ImageUrlType<P> = "imageUrl" | ({
138
138
  type: "imageUrl";
139
- } & DefaultValueOrExpr<string> & PropTypeBase<P>);
139
+ } & DefaultValueOrExpr<P, string> & PropTypeBase<P>);
140
140
  export declare type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, String>;
141
141
  declare type ControlTypeBase = {
142
142
  editOnly?: false;
@@ -148,7 +148,7 @@ declare type ControlTypeBase = {
148
148
  uncontrolledProp?: string;
149
149
  };
150
150
  export declare type SupportControlled<T> = Extract<T, String | CustomControl<any>> | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);
151
- export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType;
151
+ export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType<P>;
152
152
  declare type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
153
153
  declare type DistributedKeyOf<T> = T extends any ? keyof T : never;
154
154
  interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/host",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "plasmic library for app hosting",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["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 DefaultValueOrExpr<T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<any>);\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<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\nexport type 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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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"],"names":[],"mappings":";;;;AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA2V/B,IAAI,IAAI,CAAC,0BAA0B,IAAI,IAAI,EAAE;IAC3C,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;CACtC;SAEuB,iBAAiB,CACvC,SAAY,EACZ,IAA4C;IAE5C,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,SAAS,WAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;AAC5D;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["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 DefaultValueOrExpr<P, T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, 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\nexport type 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<P>;\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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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"],"names":[],"mappings":";;;;AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA2V/B,IAAI,IAAI,CAAC,0BAA0B,IAAI,IAAI,EAAE;IAC3C,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;CACtC;SAEuB,iBAAiB,CACvC,SAAY,EACZ,IAA4C;IAE5C,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,SAAS,WAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;AAC5D;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["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 DefaultValueOrExpr<T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<any>);\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<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\nexport type 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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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"],"names":[],"mappings":"AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA2V/B,IAAI,IAAI,CAAC,0BAA0B,IAAI,IAAI,EAAE;IAC3C,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;CACtC;SAEuB,iBAAiB,CACvC,SAAY,EACZ,IAA4C;IAE5C,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,SAAS,WAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;AAC5D;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["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 DefaultValueOrExpr<P, T> =\n | {\n defaultExpr?: undefined;\n defaultExprHint?: undefined;\n defaultValue?: T;\n defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;\n }\n | {\n defaultValue?: undefined;\n defaultValueHint?: undefined;\n defaultExpr?: string;\n defaultExprHint?: string;\n };\n\ntype StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type 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\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\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 /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\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 /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, 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\nexport type 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<P>;\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 description of the component to be shown in Studio.\n */\n description?: 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 * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\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"],"names":[],"mappings":"AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA2V/B,IAAI,IAAI,CAAC,0BAA0B,IAAI,IAAI,EAAE;IAC3C,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;CACtC;SAEuB,iBAAiB,CACvC,SAAY,EACZ,IAA4C;IAE5C,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,SAAS,WAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;AAC5D;;;;"}
@@ -24,18 +24,18 @@ interface PropTypeBase<P> {
24
24
  description?: string;
25
25
  hidden?: ContextDependentConfig<P, boolean>;
26
26
  }
27
- declare type DefaultValueOrExpr<T> = {
27
+ declare type DefaultValueOrExpr<P, T> = {
28
28
  defaultExpr?: undefined;
29
29
  defaultExprHint?: undefined;
30
30
  defaultValue?: T;
31
- defaultValueHint?: T;
31
+ defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
32
32
  } | {
33
33
  defaultValue?: undefined;
34
34
  defaultValueHint?: undefined;
35
35
  defaultExpr?: string;
36
36
  defaultExprHint?: string;
37
37
  };
38
- declare type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;
38
+ declare type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;
39
39
  export declare type StringType<P> = "string" | (({
40
40
  type: "string";
41
41
  control?: "default" | "large";
@@ -45,8 +45,8 @@ export declare type StringType<P> = "string" | (({
45
45
  }) & StringTypeBase<P>);
46
46
  export declare type BooleanType<P> = "boolean" | ({
47
47
  type: "boolean";
48
- } & DefaultValueOrExpr<boolean> & PropTypeBase<P>);
49
- declare type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<number> & {
48
+ } & DefaultValueOrExpr<P, boolean> & PropTypeBase<P>);
49
+ declare type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, number> & {
50
50
  type: "number";
51
51
  };
52
52
  export declare type NumberType<P> = "number" | (({
@@ -64,9 +64,9 @@ export declare type NumberType<P> = "number" | (({
64
64
  */
65
65
  export declare type JSONLikeType<P> = "object" | ({
66
66
  type: "object";
67
- } & DefaultValueOrExpr<any> & PropTypeBase<P>) | ({
67
+ } & DefaultValueOrExpr<P, any> & PropTypeBase<P>) | ({
68
68
  type: "array";
69
- } & DefaultValueOrExpr<any[]> & PropTypeBase<P>);
69
+ } & DefaultValueOrExpr<P, any[]> & PropTypeBase<P>);
70
70
  interface ChoiceTypeBase<P> extends PropTypeBase<P> {
71
71
  type: "choice";
72
72
  options: string[] | {
@@ -79,9 +79,9 @@ interface ChoiceTypeBase<P> extends PropTypeBase<P> {
79
79
  }
80
80
  export declare type ChoiceType<P> = (({
81
81
  multiSelect?: false;
82
- } & DefaultValueOrExpr<string>) | ({
82
+ } & DefaultValueOrExpr<P, string>) | ({
83
83
  multiSelect: true;
84
- } & DefaultValueOrExpr<string[]>)) & ChoiceTypeBase<P>;
84
+ } & DefaultValueOrExpr<P, string[]>)) & ChoiceTypeBase<P>;
85
85
  export interface ModalProps {
86
86
  show?: boolean;
87
87
  children?: React.ReactNode;
@@ -117,8 +117,8 @@ export declare type CustomControl<P> = React.ComponentType<CustomControlProps<P>
117
117
  export declare type CustomType<P> = CustomControl<P> | ({
118
118
  type: "custom";
119
119
  control: CustomControl<P>;
120
- } & PropTypeBase<P> & DefaultValueOrExpr<any>);
121
- declare type SlotType = "slot" | ({
120
+ } & PropTypeBase<P> & DefaultValueOrExpr<P, any>);
121
+ declare type SlotType<P> = "slot" | ({
122
122
  type: "slot";
123
123
  /**
124
124
  * The unique names of all code components that can be placed in the slot
@@ -133,10 +133,10 @@ declare type SlotType = "slot" | ({
133
133
  * repeatedElement().
134
134
  */
135
135
  isRepeated?: boolean;
136
- } & Omit<DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
136
+ } & Omit<DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
137
137
  declare type ImageUrlType<P> = "imageUrl" | ({
138
138
  type: "imageUrl";
139
- } & DefaultValueOrExpr<string> & PropTypeBase<P>);
139
+ } & DefaultValueOrExpr<P, string> & PropTypeBase<P>);
140
140
  export declare type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, String>;
141
141
  declare type ControlTypeBase = {
142
142
  editOnly?: false;
@@ -148,7 +148,7 @@ declare type ControlTypeBase = {
148
148
  uncontrolledProp?: string;
149
149
  };
150
150
  export declare type SupportControlled<T> = Extract<T, String | CustomControl<any>> | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);
151
- export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType;
151
+ export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType<P>;
152
152
  declare type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
153
153
  declare type DistributedKeyOf<T> = T extends any ? keyof T : never;
154
154
  interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
@@ -24,18 +24,18 @@ interface PropTypeBase<P> {
24
24
  description?: string;
25
25
  hidden?: ContextDependentConfig<P, boolean>;
26
26
  }
27
- declare type DefaultValueOrExpr<T> = {
27
+ declare type DefaultValueOrExpr<P, T> = {
28
28
  defaultExpr?: undefined;
29
29
  defaultExprHint?: undefined;
30
30
  defaultValue?: T;
31
- defaultValueHint?: T;
31
+ defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
32
32
  } | {
33
33
  defaultValue?: undefined;
34
34
  defaultValueHint?: undefined;
35
35
  defaultExpr?: string;
36
36
  defaultExprHint?: string;
37
37
  };
38
- declare type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<string>;
38
+ declare type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;
39
39
  export declare type StringType<P> = "string" | (({
40
40
  type: "string";
41
41
  control?: "default" | "large";
@@ -45,8 +45,8 @@ export declare type StringType<P> = "string" | (({
45
45
  }) & StringTypeBase<P>);
46
46
  export declare type BooleanType<P> = "boolean" | ({
47
47
  type: "boolean";
48
- } & DefaultValueOrExpr<boolean> & PropTypeBase<P>);
49
- declare type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<number> & {
48
+ } & DefaultValueOrExpr<P, boolean> & PropTypeBase<P>);
49
+ declare type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, number> & {
50
50
  type: "number";
51
51
  };
52
52
  export declare type NumberType<P> = "number" | (({
@@ -64,9 +64,9 @@ export declare type NumberType<P> = "number" | (({
64
64
  */
65
65
  export declare type JSONLikeType<P> = "object" | ({
66
66
  type: "object";
67
- } & DefaultValueOrExpr<any> & PropTypeBase<P>) | ({
67
+ } & DefaultValueOrExpr<P, any> & PropTypeBase<P>) | ({
68
68
  type: "array";
69
- } & DefaultValueOrExpr<any[]> & PropTypeBase<P>);
69
+ } & DefaultValueOrExpr<P, any[]> & PropTypeBase<P>);
70
70
  interface ChoiceTypeBase<P> extends PropTypeBase<P> {
71
71
  type: "choice";
72
72
  options: string[] | {
@@ -79,9 +79,9 @@ interface ChoiceTypeBase<P> extends PropTypeBase<P> {
79
79
  }
80
80
  export declare type ChoiceType<P> = (({
81
81
  multiSelect?: false;
82
- } & DefaultValueOrExpr<string>) | ({
82
+ } & DefaultValueOrExpr<P, string>) | ({
83
83
  multiSelect: true;
84
- } & DefaultValueOrExpr<string[]>)) & ChoiceTypeBase<P>;
84
+ } & DefaultValueOrExpr<P, string[]>)) & ChoiceTypeBase<P>;
85
85
  export interface ModalProps {
86
86
  show?: boolean;
87
87
  children?: React.ReactNode;
@@ -117,8 +117,8 @@ export declare type CustomControl<P> = React.ComponentType<CustomControlProps<P>
117
117
  export declare type CustomType<P> = CustomControl<P> | ({
118
118
  type: "custom";
119
119
  control: CustomControl<P>;
120
- } & PropTypeBase<P> & DefaultValueOrExpr<any>);
121
- declare type SlotType = "slot" | ({
120
+ } & PropTypeBase<P> & DefaultValueOrExpr<P, any>);
121
+ declare type SlotType<P> = "slot" | ({
122
122
  type: "slot";
123
123
  /**
124
124
  * The unique names of all code components that can be placed in the slot
@@ -133,10 +133,10 @@ declare type SlotType = "slot" | ({
133
133
  * repeatedElement().
134
134
  */
135
135
  isRepeated?: boolean;
136
- } & Omit<DefaultValueOrExpr<PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
136
+ } & Omit<DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
137
137
  declare type ImageUrlType<P> = "imageUrl" | ({
138
138
  type: "imageUrl";
139
- } & DefaultValueOrExpr<string> & PropTypeBase<P>);
139
+ } & DefaultValueOrExpr<P, string> & PropTypeBase<P>);
140
140
  export declare type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, String>;
141
141
  declare type ControlTypeBase = {
142
142
  editOnly?: false;
@@ -148,7 +148,7 @@ declare type ControlTypeBase = {
148
148
  uncontrolledProp?: string;
149
149
  };
150
150
  export declare type SupportControlled<T> = Extract<T, String | CustomControl<any>> | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);
151
- export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType;
151
+ export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType<P>;
152
152
  declare type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
153
153
  declare type DistributedKeyOf<T> = T extends any ? keyof T : never;
154
154
  interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {