@plasmicapp/host 1.0.75 → 1.0.78
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.
- package/dist/host.cjs.development.js +31 -8
- package/dist/host.cjs.development.js.map +1 -1
- package/dist/host.cjs.production.min.js +1 -1
- package/dist/host.cjs.production.min.js.map +1 -1
- package/dist/host.esm.js +31 -8
- package/dist/host.esm.js.map +1 -1
- package/dist/registerComponent.d.ts +10 -0
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/registerComponent/dist/index.cjs.js.map +1 -1
- package/registerComponent/dist/index.esm.js.map +1 -1
- package/registerComponent/dist/registerComponent.d.ts +10 -0
- package/registerGlobalContext/dist/registerComponent.d.ts +10 -0
|
@@ -178,6 +178,16 @@ function _PlasmicCanvasHost() {
|
|
|
178
178
|
var isCanvas = !!((_location$hash = location.hash) != null && _location$hash.match(/\bcanvas=true\b/));
|
|
179
179
|
var isLive = !!((_location$hash2 = location.hash) != null && _location$hash2.match(/\blive=true\b/)) || !isFrameAttached;
|
|
180
180
|
var shouldRenderStudio = isFrameAttached && !document.querySelector("#plasmic-studio-tag") && !isCanvas && !isLive;
|
|
181
|
+
var locationHash = new URLSearchParams(location.hash);
|
|
182
|
+
|
|
183
|
+
var _React$useState = React.useState(function () {
|
|
184
|
+
var _locationHash$get;
|
|
185
|
+
|
|
186
|
+
return JSON.parse((_locationHash$get = locationHash.get("globalVariants")) != null ? _locationHash$get : "{}");
|
|
187
|
+
}),
|
|
188
|
+
activeGlobalVariants = _React$useState[0],
|
|
189
|
+
setActiveGlobalVariants = _React$useState[1];
|
|
190
|
+
|
|
181
191
|
var forceUpdate = useForceUpdate();
|
|
182
192
|
React.useLayoutEffect(function () {
|
|
183
193
|
rootChangeListeners.push(forceUpdate);
|
|
@@ -208,14 +218,28 @@ function _PlasmicCanvasHost() {
|
|
|
208
218
|
document.head.append(scriptElt);
|
|
209
219
|
}
|
|
210
220
|
}, [shouldRenderStudio]);
|
|
221
|
+
React.useEffect(function () {
|
|
222
|
+
var listener = function listener(event) {
|
|
223
|
+
try {
|
|
224
|
+
var data = JSON.parse(event.data);
|
|
225
|
+
|
|
226
|
+
if (data.source === "canvas-frame") {
|
|
227
|
+
setActiveGlobalVariants(data.activeGlobalVariants);
|
|
228
|
+
}
|
|
229
|
+
} catch (_unused) {}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
window.addEventListener("message", listener);
|
|
233
|
+
return function () {
|
|
234
|
+
return window.removeEventListener("message", listener);
|
|
235
|
+
};
|
|
236
|
+
}, []);
|
|
211
237
|
|
|
212
238
|
if (!isFrameAttached) {
|
|
213
239
|
return null;
|
|
214
240
|
}
|
|
215
241
|
|
|
216
242
|
if (isCanvas || isLive) {
|
|
217
|
-
var _locationHash$get;
|
|
218
|
-
|
|
219
243
|
var appDiv = document.querySelector("#plasmic-app.__wab_user-body");
|
|
220
244
|
|
|
221
245
|
if (!appDiv) {
|
|
@@ -225,10 +249,9 @@ function _PlasmicCanvasHost() {
|
|
|
225
249
|
document.body.appendChild(appDiv);
|
|
226
250
|
}
|
|
227
251
|
|
|
228
|
-
var locationHash = new URLSearchParams(location.hash);
|
|
229
252
|
var plasmicContextValue = isCanvas ? {
|
|
230
253
|
componentName: locationHash.get("componentName"),
|
|
231
|
-
globalVariants:
|
|
254
|
+
globalVariants: activeGlobalVariants
|
|
232
255
|
} : false;
|
|
233
256
|
return ReactDOM.createPortal(React.createElement(ErrorBoundary, {
|
|
234
257
|
key: "" + renderCount
|
|
@@ -258,9 +281,9 @@ function _PlasmicCanvasHost() {
|
|
|
258
281
|
var PlasmicCanvasHost = function PlasmicCanvasHost(props) {
|
|
259
282
|
var enableWebpackHmr = props.enableWebpackHmr;
|
|
260
283
|
|
|
261
|
-
var _React$
|
|
262
|
-
node = _React$
|
|
263
|
-
setNode = _React$
|
|
284
|
+
var _React$useState2 = React.useState(null),
|
|
285
|
+
node = _React$useState2[0],
|
|
286
|
+
setNode = _React$useState2[1];
|
|
264
287
|
|
|
265
288
|
React.useEffect(function () {
|
|
266
289
|
setNode(React.createElement(_PlasmicCanvasHost, null));
|
|
@@ -521,7 +544,7 @@ var hostModule = {
|
|
|
521
544
|
DataCtxReader: DataCtxReader
|
|
522
545
|
};
|
|
523
546
|
|
|
524
|
-
var hostVersion = "1.0.
|
|
547
|
+
var hostVersion = "1.0.78";
|
|
525
548
|
|
|
526
549
|
var root$6 = globalThis;
|
|
527
550
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.cjs.development.js","sources":["../src/lang-utils.ts","../src/useForceUpdate.ts","../src/canvas-host.tsx","../src/common.ts","../src/data.tsx","../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/registerTrait.ts","../src/repeatedElement.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["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","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { ensure } from \"./lang-utils\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\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;\nexport function 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 globalVariants: Record<string, string>;\n }\n | false\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 globalVariants: JSON.parse(\n locationHash.get(\"globalVariants\") ?? \"{}\"\n ),\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\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nexport function 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","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 type DataMeta = {\n hidden?: boolean;\n label?: string;\n};\n\nexport function mkMetaName(name: string) {\n return `__plasmic_meta_${name}`;\n}\n\nexport function mkMetaValue(meta: Partial<DataMeta>): DataMeta {\n return meta;\n}\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 /**\n * Key to set in data context.\n */\n name?: string;\n /**\n * Value to set for `name` in data context.\n */\n data?: any;\n /**\n * If true, hide this entry in studio (data binding).\n */\n hidden?: boolean;\n /**\n * Label to be shown in the studio data picker for easier navigation (data binding).\n */\n label?: string;\n children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\n label,\n children,\n}: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider\n value={{\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: mkMetaValue({ hidden, label }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string | string[] | undefined>;\n query?: Record<string, string | string[] | undefined>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n const $ctx = useDataEnv() || {};\n return (\n <DataProvider\n name={\"params\"}\n data={{ ...$ctx.params, ...params }}\n label={\"Page route params\"}\n >\n <DataProvider\n name={\"query\"}\n data={{ ...$ctx.query, ...query }}\n label={\"Page query params\"}\n >\n {children}\n </DataProvider>\n </DataProvider>\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","import { PrimitiveType } from \"./registerComponent\";\n\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 readOnly?: boolean | 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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 * Whether the global context provides data to its children using DataProvider.\n */\n providesData?: boolean;\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","const root = globalThis as any;\n\nexport interface BasicTrait {\n label?: string;\n type: \"text\" | \"number\" | \"boolean\";\n}\n\nexport interface ChoiceTrait {\n label?: string;\n type: \"choice\";\n options: string[];\n}\n\nexport type TraitMeta = BasicTrait | ChoiceTrait;\n\nexport interface TraitRegistration {\n trait: string;\n meta: TraitMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicTraitRegistry: TraitRegistration[];\n }\n}\n\nif (root.__PlasmicTraitRegistry == null) {\n root.__PlasmicTraitRegistry = [];\n}\n\nexport default function registerTrait(trait: string, meta: TraitMeta) {\n root.__PlasmicTraitRegistry.push({\n trait,\n meta,\n });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param index The index of the copy (starting at 0).\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(index: number, elt: T): T;\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param isPrimary should be true for at most one instance of the element, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T;\nexport default function repeatedElement<T>(index: boolean | number, elt: T): T {\n return repeatedElementFn(index as any, elt);\n}\n\nlet repeatedElementFn: typeof repeatedElement = (\n index: boolean | number,\n elt: any\n) => {\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElementFn(index as any, v)) as any;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any;\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","export const hostVersion = \"1.0.75\";\n","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerRenderErrorListener, setPlasmicRootNode } from \"./canvas-host\";\nimport * as hostModule from \"./exports\";\nimport { setRepeatedElementFn } from \"./repeatedElement\";\n// version.ts is automatically generated by `yarn build` and not committed.\nimport { hostVersion } from \"./version\";\n\n// All exports must come from \"./exports\"\nexport * from \"./exports\";\n\nconst root = globalThis as any;\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. Hiding this for now\n // as users are complaining; will have to check if this has\n // been fixed with vite.\n // console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\n hostVersion,\n hostUtils: {\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n },\n\n // For backwards compatibility:\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n ...hostModule,\n };\n}\n"],"names":["isString","x","ensure","msg","undefined","Error","useForceUpdate","useState","setTick","update","useCallback","tick","root","globalThis","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","push","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","locationHash","URLSearchParams","plasmicContextValue","componentName","globalVariants","JSON","parse","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","renderErrorListeners","registerRenderErrorListener","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","type","dangerouslySetInnerHTML","__html","tuple","args","DataContext","createContext","mkMetaName","name","mkMetaValue","meta","applySelector","rawData","selector","curData","split","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","useContext","DataProvider","data","hidden","label","existingEnv","PageParamsProvider","query","$ctx","DataCtxReader","__PlasmicFetcherRegistry","registerFetcher","fetcher","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","hostVersion","hostModule","hostUtils"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;SAIeC,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;AAC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bF;AAcE+D,IAAAA,oBAAoB,EAApBA;AAdF,KAeKI,UAfL;AAiBD;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"host.cjs.development.js","sources":["../src/lang-utils.ts","../src/useForceUpdate.ts","../src/canvas-host.tsx","../src/common.ts","../src/data.tsx","../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/registerTrait.ts","../src/repeatedElement.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["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","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { ensure } from \"./lang-utils\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\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;\nexport function 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 globalVariants: Record<string, string>;\n }\n | false\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 locationHash = new URLSearchParams(location.hash);\n\n const [activeGlobalVariants, setActiveGlobalVariants] = React.useState<\n Record<string, string>\n >(() => JSON.parse(locationHash.get(\"globalVariants\") ?? \"{}\"));\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 React.useEffect(() => {\n const listener = (event: MessageEvent) => {\n try {\n const data = JSON.parse(event.data);\n if (data.source === \"canvas-frame\") {\n setActiveGlobalVariants(data.activeGlobalVariants);\n }\n } catch {}\n };\n window.addEventListener(\"message\", listener);\n return () => window.removeEventListener(\"message\", listener);\n }, []);\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 plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n globalVariants: activeGlobalVariants,\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\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nexport function 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","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 type DataMeta = {\n hidden?: boolean;\n label?: string;\n};\n\nexport function mkMetaName(name: string) {\n return `__plasmic_meta_${name}`;\n}\n\nexport function mkMetaValue(meta: Partial<DataMeta>): DataMeta {\n return meta;\n}\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 /**\n * Key to set in data context.\n */\n name?: string;\n /**\n * Value to set for `name` in data context.\n */\n data?: any;\n /**\n * If true, hide this entry in studio (data binding).\n */\n hidden?: boolean;\n /**\n * Label to be shown in the studio data picker for easier navigation (data binding).\n */\n label?: string;\n children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\n label,\n children,\n}: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider\n value={{\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: mkMetaValue({ hidden, label }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string | string[] | undefined>;\n query?: Record<string, string | string[] | undefined>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n const $ctx = useDataEnv() || {};\n return (\n <DataProvider\n name={\"params\"}\n data={{ ...$ctx.params, ...params }}\n label={\"Page route params\"}\n >\n <DataProvider\n name={\"query\"}\n data={{ ...$ctx.query, ...query }}\n label={\"Page query params\"}\n >\n {children}\n </DataProvider>\n </DataProvider>\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","import { PrimitiveType } from \"./registerComponent\";\n\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 readOnly?: boolean | ContextDependentConfig<P, boolean>;\n advanced?: 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\n /**\n * Whether style sections should be shown in Studio. For styles to work, the\n * component must accept a `className` prop. If unset, defaults to true.\n */\n styleSections?: boolean;\n /**\n * Whether the element can be repeated in Studio. If unset, defaults to true.\n */\n isRepeatable?: boolean;\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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 * Whether the global context provides data to its children using DataProvider.\n */\n providesData?: boolean;\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","const root = globalThis as any;\n\nexport interface BasicTrait {\n label?: string;\n type: \"text\" | \"number\" | \"boolean\";\n}\n\nexport interface ChoiceTrait {\n label?: string;\n type: \"choice\";\n options: string[];\n}\n\nexport type TraitMeta = BasicTrait | ChoiceTrait;\n\nexport interface TraitRegistration {\n trait: string;\n meta: TraitMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicTraitRegistry: TraitRegistration[];\n }\n}\n\nif (root.__PlasmicTraitRegistry == null) {\n root.__PlasmicTraitRegistry = [];\n}\n\nexport default function registerTrait(trait: string, meta: TraitMeta) {\n root.__PlasmicTraitRegistry.push({\n trait,\n meta,\n });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param index The index of the copy (starting at 0).\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(index: number, elt: T): T;\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param isPrimary should be true for at most one instance of the element, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T;\nexport default function repeatedElement<T>(index: boolean | number, elt: T): T {\n return repeatedElementFn(index as any, elt);\n}\n\nlet repeatedElementFn: typeof repeatedElement = (\n index: boolean | number,\n elt: any\n) => {\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElementFn(index as any, v)) as any;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any;\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","export const hostVersion = \"1.0.78\";\n","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerRenderErrorListener, setPlasmicRootNode } from \"./canvas-host\";\nimport * as hostModule from \"./exports\";\nimport { setRepeatedElementFn } from \"./repeatedElement\";\n// version.ts is automatically generated by `yarn build` and not committed.\nimport { hostVersion } from \"./version\";\n\n// All exports must come from \"./exports\"\nexport * from \"./exports\";\n\nconst root = globalThis as any;\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. Hiding this for now\n // as users are complaining; will have to check if this has\n // been fixed with vite.\n // console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\n hostVersion,\n hostUtils: {\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n },\n\n // For backwards compatibility:\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n ...hostModule,\n };\n}\n"],"names":["isString","x","ensure","msg","undefined","Error","useForceUpdate","useState","setTick","update","useCallback","tick","root","globalThis","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","locationHash","URLSearchParams","JSON","parse","activeGlobalVariants","setActiveGlobalVariants","forceUpdate","push","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","listener","event","data","source","addEventListener","removeEventListener","appDiv","classList","add","plasmicContextValue","componentName","globalVariants","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","renderErrorListeners","registerRenderErrorListener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","type","dangerouslySetInnerHTML","__html","tuple","args","DataContext","createContext","mkMetaName","name","mkMetaValue","meta","applySelector","rawData","selector","curData","split","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","useContext","DataProvider","hidden","label","existingEnv","PageParamsProvider","query","$ctx","DataCtxReader","__PlasmicFetcherRegistry","registerFetcher","fetcher","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","hostVersion","hostModule","hostUtils"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;SA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A8B,OAAOA,GAAP,KAAe,QAAjD,EAA2D;AACzD,WAAOM,kBAAY,CAACN,GAAD,CAAnB;AACD;;AACD,SAAOA,GAAP;AACD,CAXD;;AAaA,IAAMlJ,MAAI,GAAGC,UAAb;AACA,AAAO,IAAMwJ,oBAAoB,4BAC/BzJ,MAD+B,mCAC/BA,MAAI,CAAE0J,KADyB,qBAC/B,YAAaD,oBADkB,oCAE/B,UAAUE,EAAV;AACER,EAAAA,kBAAiB,GAAGQ,EAApB;AACD,CAJI;;;;;;;;;;;;;;;;;;;;;;;;;;AClCA,IAAMC,WAAW,GAAG,QAApB;;ACWP,IAAM5J,MAAI,GAAGC,UAAb;;AAEA,IAAID,MAAI,CAAC0J,KAAL,IAAc,IAAlB,EAAwB;AACtB;AACA;AACA;AACA;AACA;AACA1J,EAAAA,MAAI,CAAC0J,KAAL;AACE3H,IAAAA,KAAK,EAALA,KADF;AAEEyC,IAAAA,QAAQ,EAARA,QAFF;AAGEqF,IAAAA,UAAU,EAAVA,UAHF;AAIED,IAAAA,WAAW,EAAXA,WAJF;AAKEE,IAAAA,SAAS,EAAE;AACTnI,MAAAA,kBAAkB,EAAlBA,kBADS;AAETiE,MAAAA,2BAA2B,EAA3BA,2BAFS;AAGT6D,MAAAA,oBAAoB,EAApBA;AAHS,KALb;AAWE;AACA9H,IAAAA,kBAAkB,EAAlBA,kBAZF;AAaEiE,IAAAA,2BAA2B,EAA3BA,2BAbF;AAcE6D,IAAAA,oBAAoB,EAApBA;AAdF,KAeKI,UAfL;AAiBD;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react-dom");function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react-dom");function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var s=globalThis;null==s.__PlasmicHostVersion&&(s.__PlasmicHostVersion="2");var l=[],u=new function(e){var t=this;this.value=null,this.set=function(e){t.value=e,l.forEach((function(e){return e()}))},this.get=function(){return t.value}}(null);function c(){return function(e,t){if(void 0===t&&(t=""),null==e)throw t=(function(e){return"string"==typeof e}(t)?t:t())||"",new Error("Value must not be undefined or null"+(t?"- "+t:""));return e}(new URL("https://fakeurl/"+location.hash.replace(/#/,"?")).searchParams.get("origin"),"Missing information from Plasmic window.")}var m=0;function p(e){m++,u.set(e)}var d=t.createContext(!1),f=function(){return t.useContext(d)};function v(){var e,r,a,o=!!window.parent,i=!(null==(e=location.hash)||!e.match(/\bcanvas=true\b/)),s=!(null==(r=location.hash)||!r.match(/\blive=true\b/))||!o,p=o&&!document.querySelector("#plasmic-studio-tag")&&!i&&!s,f=new URLSearchParams(location.hash),v=t.useState((function(){var e;return JSON.parse(null!=(e=f.get("globalVariants"))?e:"{}")})),h=v[0],g=v[1],y=(a=t.useState(0)[1],t.useCallback((function(){a((function(e){return e+1}))}),[]));if(t.useLayoutEffect((function(){return l.push(y),function(){var e=l.indexOf(y);e>=0&&l.splice(e,1)}}),[y]),t.useEffect((function(){var e,t;p&&o&&window.parent!==window&&(e=document.createElement("script"),t=c(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[p,o]),t.useEffect((function(){if(!p&&!document.querySelector("#getlibs")&&s){var e=document.createElement("script");e.id="getlibs",e.src=c()+"/static/js/getlibs.js",e.async=!1,e.onload=function(){null==window.__GetlibsReadyResolver||window.__GetlibsReadyResolver()},document.head.append(e)}}),[p]),t.useEffect((function(){var e=function(e){try{var t=JSON.parse(e.data);"canvas-frame"===t.source&&g(t.activeGlobalVariants)}catch(e){}};return window.addEventListener("message",e),function(){return window.removeEventListener("message",e)}}),[]),!o)return null;if(i||s){var _=document.querySelector("#plasmic-app.__wab_user-body");_||((_=document.createElement("div")).id="plasmic-app",_.classList.add("__wab_user-body"),document.body.appendChild(_));var x=!!i&&{componentName:f.get("componentName"),globalVariants:h};return n.createPortal(t.createElement(b,{key:""+m},t.createElement(d.Provider,{value:x},u.get())),_,"plasmic-app")}return p&&window.parent===window?t.createElement("iframe",{src:"https://docs.plasmic.app/app-content/app-host-ready#appHostUrl="+encodeURIComponent(location.href),style:{width:"100vw",height:"100vh",border:"none",position:"fixed",top:0,left:0,zIndex:99999999}}):null}var h=function(e){var r=e.enableWebpackHmr,n=t.useState(null),a=n[0],o=n[1];return t.useEffect((function(){o(t.createElement(v,null))}),[]),t.createElement(t.Fragment,null,!r&&t.createElement(_,null),a)},g=[];function y(e){return g.push(e),function(){var t=g.indexOf(e);t>=0&&g.splice(t,1)}}var b=function(e){var r,n;function a(t){var r;return(r=e.call(this,t)||this).state={},r}n=e,(r=a).prototype=Object.create(n.prototype),r.prototype.constructor=r,o(r,n),a.getDerivedStateFromError=function(e){return{error:e}};var i=a.prototype;return i.componentDidCatch=function(e){g.forEach((function(t){return t(e)}))},i.render=function(){return this.state.error?t.createElement("div",null,"Error: ",""+this.state.error.message):t.createElement(t.Fragment,null,this.props.children)},a}(t.Component);function _(){return null}var x=t.createContext(void 0);function E(e){return"__plasmic_meta_"+e}function P(e){return e}function C(e,t){if(t){for(var r,n=e,a=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,void 0):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t.split("."));!(r=a()).done;){var o;n=null==(o=n)?void 0:o[r.value]}return n}}function w(e){return C(S(),e)}function R(e){void 0===e&&(e={});var t=S();return Object.fromEntries(Object.entries(e).filter((function(e){return!!e[0]&&!!e[1]})).map((function(e){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t}(e[0],C(t,e[1]))})))}function S(){return t.useContext(x)}function O(e){var t,n,o=e.name,i=e.data,s=e.hidden,l=e.label,u=e.children,c=null!=(t=S())?t:{};return o?r.createElement(x.Provider,{value:a({},c,(n={},n[o]=i,n[E(o)]={hidden:s,label:l},n))},u):r.createElement(r.Fragment,null,u)}function j(e){var t=e.children,n=e.params,o=void 0===n?{}:n,i=e.query,s=void 0===i?{}:i,l=S()||{};return r.createElement(O,{name:"params",data:a({},l.params,o),label:"Page route params"},r.createElement(O,{name:"query",data:a({},l.query,s),label:"Page query params"},t))}function T(e){return(0,e.children)(S())}var D=globalThis;function F(e,t){D.__PlasmicFetcherRegistry.push({fetcher:e,meta:t})}D.__PlasmicFetcherRegistry=[];var V=globalThis;function q(e,t){V.__PlasmicComponentRegistry.push({component:e,meta:t})}null==V.__PlasmicComponentRegistry&&(V.__PlasmicComponentRegistry=[]);var A=globalThis;function M(e,t){A.__PlasmicContextRegistry.push({component:e,meta:t})}null==A.__PlasmicContextRegistry&&(A.__PlasmicContextRegistry=[]);var k,L,N=globalThis;function H(e,t){N.__PlasmicTraitRegistry.push({trait:e,meta:t})}function U(e,t){return G(e,t)}null==N.__PlasmicTraitRegistry&&(N.__PlasmicTraitRegistry=[]);var G=function(e,r){return Array.isArray(r)?r.map((function(t){return G(e,t)})):r&&t.isValidElement(r)&&"string"!=typeof r?t.cloneElement(r):r},I=globalThis,J=null!=(k=null==I||null==(L=I.__Sub)?void 0:L.setRepeatedElementFn)?k:function(e){G=e},z={__proto__:null,PlasmicCanvasContext:d,PlasmicCanvasHost:h,usePlasmicCanvasContext:f,unstable_registerFetcher:F,registerComponent:q,registerGlobalContext:M,registerTrait:H,repeatedElement:U,DataContext:x,mkMetaName:E,mkMetaValue:P,applySelector:C,useSelector:w,useSelectors:R,useDataEnv:S,DataProvider:O,PageParamsProvider:j,DataCtxReader:T},W=globalThis;null==W.__Sub&&(W.__Sub=a({React:t,ReactDOM:n,hostModule:z,hostVersion:"1.0.78",hostUtils:{setPlasmicRootNode:p,registerRenderErrorListener:y,setRepeatedElementFn:J},setPlasmicRootNode:p,registerRenderErrorListener:y,setRepeatedElementFn:J},z)),exports.DataContext=x,exports.DataCtxReader=T,exports.DataProvider=O,exports.PageParamsProvider=j,exports.PlasmicCanvasContext=d,exports.PlasmicCanvasHost=h,exports.applySelector=C,exports.mkMetaName=E,exports.mkMetaValue=P,exports.registerComponent=q,exports.registerGlobalContext=M,exports.registerTrait=H,exports.repeatedElement=U,exports.unstable_registerFetcher=F,exports.useDataEnv=S,exports.usePlasmicCanvasContext=f,exports.useSelector=w,exports.useSelectors=R;
|
|
2
2
|
//# sourceMappingURL=host.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.cjs.production.min.js","sources":["../src/canvas-host.tsx","../src/lang-utils.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/registerTrait.ts","../src/repeatedElement.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { ensure } from \"./lang-utils\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\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;\nexport function 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 globalVariants: Record<string, string>;\n }\n | false\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 globalVariants: JSON.parse(\n locationHash.get(\"globalVariants\") ?? \"{}\"\n ),\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\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nexport function 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","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 type DataMeta = {\n hidden?: boolean;\n label?: string;\n};\n\nexport function mkMetaName(name: string) {\n return `__plasmic_meta_${name}`;\n}\n\nexport function mkMetaValue(meta: Partial<DataMeta>): DataMeta {\n return meta;\n}\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 /**\n * Key to set in data context.\n */\n name?: string;\n /**\n * Value to set for `name` in data context.\n */\n data?: any;\n /**\n * If true, hide this entry in studio (data binding).\n */\n hidden?: boolean;\n /**\n * Label to be shown in the studio data picker for easier navigation (data binding).\n */\n label?: string;\n children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\n label,\n children,\n}: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider\n value={{\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: mkMetaValue({ hidden, label }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string | string[] | undefined>;\n query?: Record<string, string | string[] | undefined>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n const $ctx = useDataEnv() || {};\n return (\n <DataProvider\n name={\"params\"}\n data={{ ...$ctx.params, ...params }}\n label={\"Page route params\"}\n >\n <DataProvider\n name={\"query\"}\n data={{ ...$ctx.query, ...query }}\n label={\"Page query params\"}\n >\n {children}\n </DataProvider>\n </DataProvider>\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","import { PrimitiveType } from \"./registerComponent\";\n\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 readOnly?: boolean | 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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 * Whether the global context provides data to its children using DataProvider.\n */\n providesData?: boolean;\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","const root = globalThis as any;\n\nexport interface BasicTrait {\n label?: string;\n type: \"text\" | \"number\" | \"boolean\";\n}\n\nexport interface ChoiceTrait {\n label?: string;\n type: \"choice\";\n options: string[];\n}\n\nexport type TraitMeta = BasicTrait | ChoiceTrait;\n\nexport interface TraitRegistration {\n trait: string;\n meta: TraitMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicTraitRegistry: TraitRegistration[];\n }\n}\n\nif (root.__PlasmicTraitRegistry == null) {\n root.__PlasmicTraitRegistry = [];\n}\n\nexport default function registerTrait(trait: string, meta: TraitMeta) {\n root.__PlasmicTraitRegistry.push({\n trait,\n meta,\n });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param index The index of the copy (starting at 0).\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(index: number, elt: T): T;\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param isPrimary should be true for at most one instance of the element, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T;\nexport default function repeatedElement<T>(index: boolean | number, elt: T): T {\n return repeatedElementFn(index as any, elt);\n}\n\nlet repeatedElementFn: typeof repeatedElement = (\n index: boolean | number,\n elt: any\n) => {\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElementFn(index as any, v)) as any;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any;\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 * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerRenderErrorListener, setPlasmicRootNode } from \"./canvas-host\";\nimport * as hostModule from \"./exports\";\nimport { setRepeatedElementFn } from \"./repeatedElement\";\n// version.ts is automatically generated by `yarn build` and not committed.\nimport { hostVersion } from \"./version\";\n\n// All exports must come from \"./exports\"\nexport * from \"./exports\";\n\nconst root = globalThis as any;\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. Hiding this for now\n // as users are complaining; will have to check if this has\n // been fixed with vite.\n // console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\n hostVersion,\n hostUtils: {\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n },\n\n // For backwards compatibility:\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n ...hostModule,\n };\n}\n","export const hostVersion = \"1.0.75\";\n"],"names":["root","globalThis","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","value","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","usePlasmicCanvasContext","_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","globalVariants","JSON","parse","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","renderErrorListeners","registerRenderErrorListener","listener","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","children","DataContext","createContext","undefined","mkMetaName","name","mkMetaValue","meta","applySelector","rawData","selector","curData","split","_curData","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","args","tuple","useContext","DataProvider","data","hidden","label","existingEnv","PageParamsProvider","params","query","$ctx","DataCtxReader","registerFetcher","fetcher","__PlasmicFetcherRegistry","registerComponent","component","__PlasmicComponentRegistry","registerGlobalContext","__PlasmicContextRegistry","registerTrait","trait","__PlasmicTraitRegistry","repeatedElement","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","hostModule","hostVersion","hostUtils"],"mappings":"gkBAIA,IAAMA,EAAOC,WAQoB,MAA7BD,EAAKE,uBACPF,EAAKE,qBAAuB,KAG9B,IAAMC,EAAsC,GAUtCC,EAAkB,IARtB,SAAoBC,yBAQ6B,cAP3C,SAACC,GACLC,EAAKF,MAAQC,EACbH,EAAoBK,SAAQ,SAACC,UAAMA,iBAE/B,kBAAMF,EAAKF,OAGK,CAA2B,MAEnD,SAASK,oBCtBiBC,EAAyBC,eAAAA,IAAAA,EAAiB,IAC9DD,MAAAA,QAEFC,GATJ,SAAkBD,SACI,iBAANA,EAQLE,CAASD,GAAOA,EAAMA,MAAU,GACjC,IAAIE,6CAC8BF,OAAWA,EAAQ,YAGpDD,EDiBFI,CAFQ,IAAIC,uBAAuBC,SAASC,KAAKC,QAAQ,IAAK,MAClEC,aAEMC,IAAI,UACX,4CAWJ,IAAIC,EAAc,WACFC,EAAmBC,GAGjCF,IACAlB,EAAgBqB,IAAID,OAQTE,EAAuBC,iBAMlC,GACWC,EAA0B,kBACrCD,aAAiBD,IAEnB,SAASG,YEhEEC,EFqEHC,IAAoBC,OAAOC,OAC3BC,aAAajB,SAASC,QAATiB,EAAeC,MAAM,oBAClCC,aAAWpB,SAASC,QAAToB,EAAeF,MAAM,oBAAqBL,EACrDQ,EACJR,IACCS,SAASC,cAAc,yBACvBP,IACAG,EACGK,GE7EGZ,EAAWa,WAAS,MACdC,eAAY,WACzBd,GAAQ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,cAANC,EAAaF,wBACb,SAAUG,GACRT,EAAoBS,2VC1BlBhK,EAAOC,WAEK,MAAdD,EAAK8J,QAMP9J,EAAK8J,SACHnI,MAAAA,EACA8C,SAAAA,EACAwF,WAAAA,EACAC,YCvBuB,SDwBvBC,UAAW,CACT5I,mBAAAA,EACAsE,4BAAAA,EACAgE,qBAAAA,GAIFtI,mBAAAA,EACAsE,4BAAAA,EACAgE,qBAAAA,GACGI"}
|
|
1
|
+
{"version":3,"file":"host.cjs.production.min.js","sources":["../src/canvas-host.tsx","../src/lang-utils.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/registerTrait.ts","../src/repeatedElement.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { ensure } from \"./lang-utils\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\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;\nexport function 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 globalVariants: Record<string, string>;\n }\n | false\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 locationHash = new URLSearchParams(location.hash);\n\n const [activeGlobalVariants, setActiveGlobalVariants] = React.useState<\n Record<string, string>\n >(() => JSON.parse(locationHash.get(\"globalVariants\") ?? \"{}\"));\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 React.useEffect(() => {\n const listener = (event: MessageEvent) => {\n try {\n const data = JSON.parse(event.data);\n if (data.source === \"canvas-frame\") {\n setActiveGlobalVariants(data.activeGlobalVariants);\n }\n } catch {}\n };\n window.addEventListener(\"message\", listener);\n return () => window.removeEventListener(\"message\", listener);\n }, []);\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 plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n globalVariants: activeGlobalVariants,\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\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nexport function 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","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 type DataMeta = {\n hidden?: boolean;\n label?: string;\n};\n\nexport function mkMetaName(name: string) {\n return `__plasmic_meta_${name}`;\n}\n\nexport function mkMetaValue(meta: Partial<DataMeta>): DataMeta {\n return meta;\n}\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 /**\n * Key to set in data context.\n */\n name?: string;\n /**\n * Value to set for `name` in data context.\n */\n data?: any;\n /**\n * If true, hide this entry in studio (data binding).\n */\n hidden?: boolean;\n /**\n * Label to be shown in the studio data picker for easier navigation (data binding).\n */\n label?: string;\n children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\n label,\n children,\n}: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider\n value={{\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: mkMetaValue({ hidden, label }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string | string[] | undefined>;\n query?: Record<string, string | string[] | undefined>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n const $ctx = useDataEnv() || {};\n return (\n <DataProvider\n name={\"params\"}\n data={{ ...$ctx.params, ...params }}\n label={\"Page route params\"}\n >\n <DataProvider\n name={\"query\"}\n data={{ ...$ctx.query, ...query }}\n label={\"Page query params\"}\n >\n {children}\n </DataProvider>\n </DataProvider>\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","import { PrimitiveType } from \"./registerComponent\";\n\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 readOnly?: boolean | ContextDependentConfig<P, boolean>;\n advanced?: 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\n /**\n * Whether style sections should be shown in Studio. For styles to work, the\n * component must accept a `className` prop. If unset, defaults to true.\n */\n styleSections?: boolean;\n /**\n * Whether the element can be repeated in Studio. If unset, defaults to true.\n */\n isRepeatable?: boolean;\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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 * Whether the global context provides data to its children using DataProvider.\n */\n providesData?: boolean;\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","const root = globalThis as any;\n\nexport interface BasicTrait {\n label?: string;\n type: \"text\" | \"number\" | \"boolean\";\n}\n\nexport interface ChoiceTrait {\n label?: string;\n type: \"choice\";\n options: string[];\n}\n\nexport type TraitMeta = BasicTrait | ChoiceTrait;\n\nexport interface TraitRegistration {\n trait: string;\n meta: TraitMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicTraitRegistry: TraitRegistration[];\n }\n}\n\nif (root.__PlasmicTraitRegistry == null) {\n root.__PlasmicTraitRegistry = [];\n}\n\nexport default function registerTrait(trait: string, meta: TraitMeta) {\n root.__PlasmicTraitRegistry.push({\n trait,\n meta,\n });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param index The index of the copy (starting at 0).\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(index: number, elt: T): T;\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param isPrimary should be true for at most one instance of the element, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T;\nexport default function repeatedElement<T>(index: boolean | number, elt: T): T {\n return repeatedElementFn(index as any, elt);\n}\n\nlet repeatedElementFn: typeof repeatedElement = (\n index: boolean | number,\n elt: any\n) => {\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElementFn(index as any, v)) as any;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any;\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 * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerRenderErrorListener, setPlasmicRootNode } from \"./canvas-host\";\nimport * as hostModule from \"./exports\";\nimport { setRepeatedElementFn } from \"./repeatedElement\";\n// version.ts is automatically generated by `yarn build` and not committed.\nimport { hostVersion } from \"./version\";\n\n// All exports must come from \"./exports\"\nexport * from \"./exports\";\n\nconst root = globalThis as any;\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. Hiding this for now\n // as users are complaining; will have to check if this has\n // been fixed with vite.\n // console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\n hostVersion,\n hostUtils: {\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n },\n\n // For backwards compatibility:\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n ...hostModule,\n };\n}\n","export const hostVersion = \"1.0.78\";\n"],"names":["root","globalThis","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","value","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","usePlasmicCanvasContext","_PlasmicCanvasHost","setTick","isFrameAttached","window","parent","isCanvas","_location$hash","match","isLive","_location$hash2","shouldRenderStudio","document","querySelector","locationHash","URLSearchParams","JSON","parse","activeGlobalVariants","setActiveGlobalVariants","forceUpdate","useState","useCallback","tick","push","index","indexOf","splice","script","plasmicOrigin","createElement","src","body","appendChild","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","listener","event","data","source","addEventListener","removeEventListener","appDiv","classList","add","plasmicContextValue","componentName","globalVariants","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","renderErrorListeners","registerRenderErrorListener","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","children","DataContext","createContext","undefined","mkMetaName","name","mkMetaValue","meta","applySelector","rawData","selector","curData","split","_curData","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","args","tuple","useContext","DataProvider","hidden","label","existingEnv","PageParamsProvider","params","query","$ctx","DataCtxReader","registerFetcher","fetcher","__PlasmicFetcherRegistry","registerComponent","component","__PlasmicComponentRegistry","registerGlobalContext","__PlasmicContextRegistry","registerTrait","trait","__PlasmicTraitRegistry","repeatedElement","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","hostModule","hostVersion","hostUtils"],"mappings":"gkBAIA,IAAMA,E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SAAAA,EACAsF,WAAAA,EACAC,YCvBuB,SDwBvBC,UAAW,CACTlJ,mBAAAA,EACA8E,4BAAAA,EACA8D,qBAAAA,GAIF5I,mBAAAA,EACA8E,4BAAAA,EACA8D,qBAAAA,GACGI"}
|
package/dist/host.esm.js
CHANGED
|
@@ -173,6 +173,16 @@ function _PlasmicCanvasHost() {
|
|
|
173
173
|
var isCanvas = !!((_location$hash = location.hash) != null && _location$hash.match(/\bcanvas=true\b/));
|
|
174
174
|
var isLive = !!((_location$hash2 = location.hash) != null && _location$hash2.match(/\blive=true\b/)) || !isFrameAttached;
|
|
175
175
|
var shouldRenderStudio = isFrameAttached && !document.querySelector("#plasmic-studio-tag") && !isCanvas && !isLive;
|
|
176
|
+
var locationHash = new URLSearchParams(location.hash);
|
|
177
|
+
|
|
178
|
+
var _React$useState = useState(function () {
|
|
179
|
+
var _locationHash$get;
|
|
180
|
+
|
|
181
|
+
return JSON.parse((_locationHash$get = locationHash.get("globalVariants")) != null ? _locationHash$get : "{}");
|
|
182
|
+
}),
|
|
183
|
+
activeGlobalVariants = _React$useState[0],
|
|
184
|
+
setActiveGlobalVariants = _React$useState[1];
|
|
185
|
+
|
|
176
186
|
var forceUpdate = useForceUpdate();
|
|
177
187
|
useLayoutEffect(function () {
|
|
178
188
|
rootChangeListeners.push(forceUpdate);
|
|
@@ -203,14 +213,28 @@ function _PlasmicCanvasHost() {
|
|
|
203
213
|
document.head.append(scriptElt);
|
|
204
214
|
}
|
|
205
215
|
}, [shouldRenderStudio]);
|
|
216
|
+
useEffect(function () {
|
|
217
|
+
var listener = function listener(event) {
|
|
218
|
+
try {
|
|
219
|
+
var data = JSON.parse(event.data);
|
|
220
|
+
|
|
221
|
+
if (data.source === "canvas-frame") {
|
|
222
|
+
setActiveGlobalVariants(data.activeGlobalVariants);
|
|
223
|
+
}
|
|
224
|
+
} catch (_unused) {}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
window.addEventListener("message", listener);
|
|
228
|
+
return function () {
|
|
229
|
+
return window.removeEventListener("message", listener);
|
|
230
|
+
};
|
|
231
|
+
}, []);
|
|
206
232
|
|
|
207
233
|
if (!isFrameAttached) {
|
|
208
234
|
return null;
|
|
209
235
|
}
|
|
210
236
|
|
|
211
237
|
if (isCanvas || isLive) {
|
|
212
|
-
var _locationHash$get;
|
|
213
|
-
|
|
214
238
|
var appDiv = document.querySelector("#plasmic-app.__wab_user-body");
|
|
215
239
|
|
|
216
240
|
if (!appDiv) {
|
|
@@ -220,10 +244,9 @@ function _PlasmicCanvasHost() {
|
|
|
220
244
|
document.body.appendChild(appDiv);
|
|
221
245
|
}
|
|
222
246
|
|
|
223
|
-
var locationHash = new URLSearchParams(location.hash);
|
|
224
247
|
var plasmicContextValue = isCanvas ? {
|
|
225
248
|
componentName: locationHash.get("componentName"),
|
|
226
|
-
globalVariants:
|
|
249
|
+
globalVariants: activeGlobalVariants
|
|
227
250
|
} : false;
|
|
228
251
|
return createPortal(createElement(ErrorBoundary, {
|
|
229
252
|
key: "" + renderCount
|
|
@@ -253,9 +276,9 @@ function _PlasmicCanvasHost() {
|
|
|
253
276
|
var PlasmicCanvasHost = function PlasmicCanvasHost(props) {
|
|
254
277
|
var enableWebpackHmr = props.enableWebpackHmr;
|
|
255
278
|
|
|
256
|
-
var _React$
|
|
257
|
-
node = _React$
|
|
258
|
-
setNode = _React$
|
|
279
|
+
var _React$useState2 = useState(null),
|
|
280
|
+
node = _React$useState2[0],
|
|
281
|
+
setNode = _React$useState2[1];
|
|
259
282
|
|
|
260
283
|
useEffect(function () {
|
|
261
284
|
setNode(createElement(_PlasmicCanvasHost, null));
|
|
@@ -519,7 +542,7 @@ var hostModule = {
|
|
|
519
542
|
DataCtxReader: DataCtxReader
|
|
520
543
|
};
|
|
521
544
|
|
|
522
|
-
var hostVersion = "1.0.
|
|
545
|
+
var hostVersion = "1.0.78";
|
|
523
546
|
|
|
524
547
|
var root$6 = globalThis;
|
|
525
548
|
|
package/dist/host.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.esm.js","sources":["../src/lang-utils.ts","../src/useForceUpdate.ts","../src/canvas-host.tsx","../src/common.ts","../src/data.tsx","../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/registerTrait.ts","../src/repeatedElement.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["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","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { ensure } from \"./lang-utils\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\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;\nexport function 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 globalVariants: Record<string, string>;\n }\n | false\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 globalVariants: JSON.parse(\n locationHash.get(\"globalVariants\") ?? \"{}\"\n ),\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\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nexport function 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","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 type DataMeta = {\n hidden?: boolean;\n label?: string;\n};\n\nexport function mkMetaName(name: string) {\n return `__plasmic_meta_${name}`;\n}\n\nexport function mkMetaValue(meta: Partial<DataMeta>): DataMeta {\n return meta;\n}\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 /**\n * Key to set in data context.\n */\n name?: string;\n /**\n * Value to set for `name` in data context.\n */\n data?: any;\n /**\n * If true, hide this entry in studio (data binding).\n */\n hidden?: boolean;\n /**\n * Label to be shown in the studio data picker for easier navigation (data binding).\n */\n label?: string;\n children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\n label,\n children,\n}: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider\n value={{\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: mkMetaValue({ hidden, label }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string | string[] | undefined>;\n query?: Record<string, string | string[] | undefined>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n const $ctx = useDataEnv() || {};\n return (\n <DataProvider\n name={\"params\"}\n data={{ ...$ctx.params, ...params }}\n label={\"Page route params\"}\n >\n <DataProvider\n name={\"query\"}\n data={{ ...$ctx.query, ...query }}\n label={\"Page query params\"}\n >\n {children}\n </DataProvider>\n </DataProvider>\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","import { PrimitiveType } from \"./registerComponent\";\n\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 readOnly?: boolean | 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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 * Whether the global context provides data to its children using DataProvider.\n */\n providesData?: boolean;\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","const root = globalThis as any;\n\nexport interface BasicTrait {\n label?: string;\n type: \"text\" | \"number\" | \"boolean\";\n}\n\nexport interface ChoiceTrait {\n label?: string;\n type: \"choice\";\n options: string[];\n}\n\nexport type TraitMeta = BasicTrait | ChoiceTrait;\n\nexport interface TraitRegistration {\n trait: string;\n meta: TraitMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicTraitRegistry: TraitRegistration[];\n }\n}\n\nif (root.__PlasmicTraitRegistry == null) {\n root.__PlasmicTraitRegistry = [];\n}\n\nexport default function registerTrait(trait: string, meta: TraitMeta) {\n root.__PlasmicTraitRegistry.push({\n trait,\n meta,\n });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param index The index of the copy (starting at 0).\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(index: number, elt: T): T;\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param isPrimary should be true for at most one instance of the element, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T;\nexport default function repeatedElement<T>(index: boolean | number, elt: T): T {\n return repeatedElementFn(index as any, elt);\n}\n\nlet repeatedElementFn: typeof repeatedElement = (\n index: boolean | number,\n elt: any\n) => {\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElementFn(index as any, v)) as any;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any;\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","export const hostVersion = \"1.0.75\";\n","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerRenderErrorListener, setPlasmicRootNode } from \"./canvas-host\";\nimport * as hostModule from \"./exports\";\nimport { setRepeatedElementFn } from \"./repeatedElement\";\n// version.ts is automatically generated by `yarn build` and not committed.\nimport { hostVersion } from \"./version\";\n\n// All exports must come from \"./exports\"\nexport * from \"./exports\";\n\nconst root = globalThis as any;\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. Hiding this for now\n // as users are complaining; will have to check if this has\n // been fixed with vite.\n // console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\n hostVersion,\n hostUtils: {\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n },\n\n // For backwards compatibility:\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n ...hostModule,\n };\n}\n"],"names":["isString","x","ensure","msg","undefined","Error","useForceUpdate","useState","setTick","update","useCallback","tick","root","globalThis","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","push","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","locationHash","URLSearchParams","plasmicContextValue","componentName","globalVariants","JSON","parse","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","renderErrorListeners","registerRenderErrorListener","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","process","env","NODE_ENV","type","dangerouslySetInnerHTML","__html","tuple","args","DataContext","createContext","mkMetaName","name","mkMetaValue","meta","applySelector","rawData","selector","curData","split","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","useContext","DataProvider","data","hidden","label","existingEnv","PageParamsProvider","query","$ctx","DataCtxReader","__PlasmicFetcherRegistry","registerFetcher","fetcher","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","hostVersion","hostModule","hostUtils"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;SAIeC,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;;SCduBK;AACtB,kBAAoBC,QAAQ,CAAC,CAAD,CAA5B;AAAA,MAASC,OAAT;;AACA,MAAMC,MAAM,GAAGC,WAAW,CAAC;AACzBF,IAAAA,OAAO,CAAC,UAACG,IAAD;AAAA,aAAUA,IAAI,GA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AAA,aAAOH,kBAAiB,CAACpG,KAAD,EAAeuG,CAAf,CAAxB;AAAA,KAAR,CAAP;AACD;;AACD,MAAIJ,GAAG,IAAIK,cAAc,CAACL,GAAD,CAArB,IAA8B,OAAOA,GAAP,KAAe,QAAjD,EAA2D;AACzD,WAAOM,YAAY,CAACN,GAAD,CAAnB;AACD;;AACD,SAAOA,GAAP;AACD,CAXD;;AAaA,IAAM/I,MAAI,GAAGC,UAAb;AACA,AAAO,IAAMqJ,oBAAoB,4BAC/BtJ,MAD+B,mCAC/BA,MAAI,CAAEuJ,KADyB,qBAC/B,YAAaD,oBADkB,oCAE/B,UAAUE,EAAV;AACER,EAAAA,kBAAiB,GAAGQ,EAApB;AACD,CAJI;;;;;;;;;;;;;;;;;;;;;;;;;;AClCA,IAAMC,WAAW,GAAG,QAApB;;ACWP,IAAMzJ,MAAI,GAAGC,UAAb;;AAEA,IAAID,MAAI,CAACuJ,KAAL,IAAc,IAAlB,EAAwB;AACtB;AACA;AACA;AACA;AACA;AACAvJ,EAAAA,MAAI,CAACuJ,KAAL;AACExH,IAAAA,KAAK,EAALA,KADF;AAEEiC,IAAAA,QAAQ,EAARA,QAFF;AAGE0F,IAAAA,UAAU,EAAVA,UAHF;AAIED,IAAAA,WAAW,EAAXA,WAJF;AAKEE,IAAAA,SAAS,EAAE;AACThI,MAAAA,kBAAkB,EAAlBA,kBADS;AAETyD,MAAAA,2BAA2B,EAA3BA,2BAFS;AAGTkE,MAAAA,oBAAoB,EAApBA;AAHS,KALb;AAWE;AACA3H,IAAAA,kBAAkB,EAAlBA,kBAZF;AAaEyD,IAAAA,2BAA2B,EAA3BA,2BAbF;AAcEkE,IAAAA,oBAAoB,EAApBA;AAdF,KAeKI,UAfL;AAiBD;;;;"}
|
|
1
|
+
{"version":3,"file":"host.esm.js","sources":["../src/lang-utils.ts","../src/useForceUpdate.ts","../src/canvas-host.tsx","../src/common.ts","../src/data.tsx","../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/registerTrait.ts","../src/repeatedElement.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["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","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { ensure } from \"./lang-utils\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\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;\nexport function 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 globalVariants: Record<string, string>;\n }\n | false\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 locationHash = new URLSearchParams(location.hash);\n\n const [activeGlobalVariants, setActiveGlobalVariants] = React.useState<\n Record<string, string>\n >(() => JSON.parse(locationHash.get(\"globalVariants\") ?? \"{}\"));\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 React.useEffect(() => {\n const listener = (event: MessageEvent) => {\n try {\n const data = JSON.parse(event.data);\n if (data.source === \"canvas-frame\") {\n setActiveGlobalVariants(data.activeGlobalVariants);\n }\n } catch {}\n };\n window.addEventListener(\"message\", listener);\n return () => window.removeEventListener(\"message\", listener);\n }, []);\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 plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n globalVariants: activeGlobalVariants,\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\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nexport function 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","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 type DataMeta = {\n hidden?: boolean;\n label?: string;\n};\n\nexport function mkMetaName(name: string) {\n return `__plasmic_meta_${name}`;\n}\n\nexport function mkMetaValue(meta: Partial<DataMeta>): DataMeta {\n return meta;\n}\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 /**\n * Key to set in data context.\n */\n name?: string;\n /**\n * Value to set for `name` in data context.\n */\n data?: any;\n /**\n * If true, hide this entry in studio (data binding).\n */\n hidden?: boolean;\n /**\n * Label to be shown in the studio data picker for easier navigation (data binding).\n */\n label?: string;\n children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\n label,\n children,\n}: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider\n value={{\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: mkMetaValue({ hidden, label }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string | string[] | undefined>;\n query?: Record<string, string | string[] | undefined>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n const $ctx = useDataEnv() || {};\n return (\n <DataProvider\n name={\"params\"}\n data={{ ...$ctx.params, ...params }}\n label={\"Page route params\"}\n >\n <DataProvider\n name={\"query\"}\n data={{ ...$ctx.query, ...query }}\n label={\"Page query params\"}\n >\n {children}\n </DataProvider>\n </DataProvider>\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","import { PrimitiveType } from \"./registerComponent\";\n\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 readOnly?: boolean | ContextDependentConfig<P, boolean>;\n advanced?: 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\n /**\n * Whether style sections should be shown in Studio. For styles to work, the\n * component must accept a `className` prop. If unset, defaults to true.\n */\n styleSections?: boolean;\n /**\n * Whether the element can be repeated in Studio. If unset, defaults to true.\n */\n isRepeatable?: boolean;\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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 * Whether the global context provides data to its children using DataProvider.\n */\n providesData?: boolean;\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","const root = globalThis as any;\n\nexport interface BasicTrait {\n label?: string;\n type: \"text\" | \"number\" | \"boolean\";\n}\n\nexport interface ChoiceTrait {\n label?: string;\n type: \"choice\";\n options: string[];\n}\n\nexport type TraitMeta = BasicTrait | ChoiceTrait;\n\nexport interface TraitRegistration {\n trait: string;\n meta: TraitMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicTraitRegistry: TraitRegistration[];\n }\n}\n\nif (root.__PlasmicTraitRegistry == null) {\n root.__PlasmicTraitRegistry = [];\n}\n\nexport default function registerTrait(trait: string, meta: TraitMeta) {\n root.__PlasmicTraitRegistry.push({\n trait,\n meta,\n });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param index The index of the copy (starting at 0).\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(index: number, elt: T): T;\n/**\n * Allows elements to be repeated in Plasmic Studio.\n * @param isPrimary should be true for at most one instance of the element, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * @param elt the React element to be repeated (or an array of such).\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T;\nexport default function repeatedElement<T>(index: boolean | number, elt: T): T {\n return repeatedElementFn(index as any, elt);\n}\n\nlet repeatedElementFn: typeof repeatedElement = (\n index: boolean | number,\n elt: any\n) => {\n if (Array.isArray(elt)) {\n return elt.map((v) => repeatedElementFn(index as any, v)) as any;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return cloneElement(elt) as any;\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","export const hostVersion = \"1.0.78\";\n","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerRenderErrorListener, setPlasmicRootNode } from \"./canvas-host\";\nimport * as hostModule from \"./exports\";\nimport { setRepeatedElementFn } from \"./repeatedElement\";\n// version.ts is automatically generated by `yarn build` and not committed.\nimport { hostVersion } from \"./version\";\n\n// All exports must come from \"./exports\"\nexport * from \"./exports\";\n\nconst root = globalThis as any;\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. Hiding this for now\n // as users are complaining; will have to check if this has\n // been fixed with vite.\n // console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\n hostVersion,\n hostUtils: {\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n },\n\n // For backwards compatibility:\n setPlasmicRootNode,\n registerRenderErrorListener,\n setRepeatedElementFn,\n ...hostModule,\n };\n}\n"],"names":["isString","x","ensure","msg","undefined","Error","useForceUpdate","useState","setTick","update","useCallback","tick","root","globalThis","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","usePlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","locationHash","URLSearchParams","JSON","parse","activeGlobalVariants","setActiveGlobalVariants","forceUpdate","push","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","listener","event","data","source","addEventListener","removeEventListener","appDiv","classList","add","plasmicContextValue","componentName","globalVariants","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","renderErrorListeners","registerRenderErrorListener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","process","env","NODE_ENV","type","dangerouslySetInnerHTML","__html","tuple","args","DataContext","createContext","mkMetaName","name","mkMetaValue","meta","applySelector","rawData","selector","curData","split","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","useContext","DataProvider","hidden","label","existingEnv","PageParamsProvider","query","$ctx","DataCtxReader","__PlasmicFetcherRegistry","registerFetcher","fetcher","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","hostVersion","hostModule","hostUtils"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;SAIeC,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,EAAv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M2J,oBAAoB,4BAC/B5J,MAD+B,mCAC/BA,MAAI,CAAE6J,KADyB,qBAC/B,YAAaD,oBADkB,oCAE/B,UAAUE,EAAV;AACER,EAAAA,kBAAiB,GAAGQ,EAApB;AACD,CAJI;;;;;;;;;;;;;;;;;;;;;;;;;;AClCA,IAAMC,WAAW,GAAG,QAApB;;ACWP,IAAM/J,MAAI,GAAGC,UAAb;;AAEA,IAAID,MAAI,CAAC6J,KAAL,IAAc,IAAlB,EAAwB;AACtB;AACA;AACA;AACA;AACA;AACA7J,EAAAA,MAAI,CAAC6J,KAAL;AACE9H,IAAAA,KAAK,EAALA,KADF;AAEEyC,IAAAA,QAAQ,EAARA,QAFF;AAGEwF,IAAAA,UAAU,EAAVA,UAHF;AAIED,IAAAA,WAAW,EAAXA,WAJF;AAKEE,IAAAA,SAAS,EAAE;AACTtI,MAAAA,kBAAkB,EAAlBA,kBADS;AAETiE,MAAAA,2BAA2B,EAA3BA,2BAFS;AAGTgE,MAAAA,oBAAoB,EAApBA;AAHS,KALb;AAWE;AACAjI,IAAAA,kBAAkB,EAAlBA,kBAZF;AAaEiE,IAAAA,2BAA2B,EAA3BA,2BAbF;AAcEgE,IAAAA,oBAAoB,EAApBA;AAdF,KAeKI,UAfL;AAiBD;;;;"}
|
|
@@ -24,6 +24,7 @@ interface PropTypeBase<P> {
|
|
|
24
24
|
description?: string;
|
|
25
25
|
hidden?: ContextDependentConfig<P, boolean>;
|
|
26
26
|
readOnly?: boolean | ContextDependentConfig<P, boolean>;
|
|
27
|
+
advanced?: boolean;
|
|
27
28
|
}
|
|
28
29
|
declare type DefaultValueOrExpr<P, T> = {
|
|
29
30
|
defaultExpr?: undefined;
|
|
@@ -273,6 +274,15 @@ export interface ComponentMeta<P> {
|
|
|
273
274
|
* An array describing the component actions to be used in Studio.
|
|
274
275
|
*/
|
|
275
276
|
actions?: Action<P>[];
|
|
277
|
+
/**
|
|
278
|
+
* Whether style sections should be shown in Studio. For styles to work, the
|
|
279
|
+
* component must accept a `className` prop. If unset, defaults to true.
|
|
280
|
+
*/
|
|
281
|
+
styleSections?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Whether the element can be repeated in Studio. If unset, defaults to true.
|
|
284
|
+
*/
|
|
285
|
+
isRepeatable?: boolean;
|
|
276
286
|
/**
|
|
277
287
|
* The path to be used when importing the component in the generated code.
|
|
278
288
|
* It can be the name of the package that contains the component, or the path
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const hostVersion = "1.0.
|
|
1
|
+
export declare const hostVersion = "1.0.78";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/host",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.78",
|
|
4
4
|
"description": "plasmic library for app hosting",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react": ">=16.8.0",
|
|
56
56
|
"react-dom": ">=16.8.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "00908b0c730adea12726998c0a84427ec378374d"
|
|
59
59
|
}
|
|
@@ -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 readOnly?: boolean | 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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;AAsd/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 readOnly?: boolean | ContextDependentConfig<P, boolean>;\n advanced?: 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\n /**\n * Whether style sections should be shown in Studio. For styles to work, the\n * component must accept a `className` prop. If unset, defaults to true.\n */\n styleSections?: boolean;\n /**\n * Whether the element can be repeated in Studio. If unset, defaults to true.\n */\n isRepeatable?: boolean;\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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;AAge/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 readOnly?: boolean | 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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;AAsd/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 readOnly?: boolean | ContextDependentConfig<P, boolean>;\n advanced?: 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 type: \"cardPicker\";\n modalTitle?:\n | React.ReactNode\n | ContextDependentConfig<P, React.ReactNode>;\n options:\n | {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n | ContextDependentConfig<\n P,\n {\n value: string;\n label?: string;\n imgUrl: string;\n footer?: React.ReactNode;\n }[]\n >;\n showInput?: boolean | ContextDependentConfig<P, boolean>;\n onSearch?: ContextDependentConfig<\n P,\n ((value: string) => void) | undefined\n >;\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 GraphQLValue = {\n query: string;\n variables?: Record<string, any>;\n};\n\nexport type GraphQLType<P> = {\n type: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n} & DefaultValueOrExpr<P, GraphQLValue> &\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 | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data:\n | Record<string, any>\n | ContextDependentConfig<P, Record<string, any>>;\n alwaysShowValuePathAsLabel?: boolean;\n } & DefaultValueOrExpr<P, Record<string, 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 allowSearch?: boolean;\n filterOption?: boolean;\n onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string | number | boolean>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, (string | number | boolean)[]>)\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 | GraphQLType<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\nexport interface ActionProps<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 studioOps: {\n showModal: (\n modalProps: Omit<ModalProps, \"onClose\"> & { onClose?: () => void }\n ) => void;\n refreshQueryData: () => void;\n appendToSlot: (element: PlasmicElement, slotName: string) => void;\n removeFromSlotAt: (pos: number, slotName: string) => void;\n updateProps: (newValues: any) => void;\n };\n}\n\nexport type Action<P> =\n | {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\n }\n | {\n type: \"custom-action\";\n control: React.ComponentType<ActionProps<P>>;\n };\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}\ninterface $State {\n [key: string]: any;\n}\n\ninterface $StateSpec<T> {\n // Whether this state is private, readonly, or writable in\n // this component\n type: \"private\" | \"readonly\" | \"writable\";\n // if initial value is defined by a js expression\n initFunc?: ($props: Record<string, any>, $state: $State) => T;\n // if initial value is a hard-coded value\n initVal?: T;\n // Whether this state is private, readonly, or writable in\n // this component\n\n // If writable, there should be a valueProp that maps props[valueProp]\n // to the value of the state\n valueProp?: string;\n\n // If writable or readonly, there should be an onChangeProp where\n // props[onChangeProp] is invoked whenever the value changes\n onChangeProp?: string;\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 * WIP: An object describing the component states to be used in Studio.\n */\n unstable__states?: Record<string, $StateSpec<any>>;\n /**\n * An array describing the component actions to be used in Studio.\n */\n actions?: Action<P>[];\n /**\n * Whether style sections should be shown in Studio. For styles to work, the\n * component must accept a `className` prop. If unset, defaults to true.\n */\n styleSections?: boolean;\n /**\n * Whether the element can be repeated in Studio. If unset, defaults to true.\n */\n isRepeatable?: boolean;\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 * Whether the component provides data to its slots using DataProvider.\n */\n providesData?: 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;AAge/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,6 +24,7 @@ interface PropTypeBase<P> {
|
|
|
24
24
|
description?: string;
|
|
25
25
|
hidden?: ContextDependentConfig<P, boolean>;
|
|
26
26
|
readOnly?: boolean | ContextDependentConfig<P, boolean>;
|
|
27
|
+
advanced?: boolean;
|
|
27
28
|
}
|
|
28
29
|
declare type DefaultValueOrExpr<P, T> = {
|
|
29
30
|
defaultExpr?: undefined;
|
|
@@ -273,6 +274,15 @@ export interface ComponentMeta<P> {
|
|
|
273
274
|
* An array describing the component actions to be used in Studio.
|
|
274
275
|
*/
|
|
275
276
|
actions?: Action<P>[];
|
|
277
|
+
/**
|
|
278
|
+
* Whether style sections should be shown in Studio. For styles to work, the
|
|
279
|
+
* component must accept a `className` prop. If unset, defaults to true.
|
|
280
|
+
*/
|
|
281
|
+
styleSections?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Whether the element can be repeated in Studio. If unset, defaults to true.
|
|
284
|
+
*/
|
|
285
|
+
isRepeatable?: boolean;
|
|
276
286
|
/**
|
|
277
287
|
* The path to be used when importing the component in the generated code.
|
|
278
288
|
* It can be the name of the package that contains the component, or the path
|
|
@@ -24,6 +24,7 @@ interface PropTypeBase<P> {
|
|
|
24
24
|
description?: string;
|
|
25
25
|
hidden?: ContextDependentConfig<P, boolean>;
|
|
26
26
|
readOnly?: boolean | ContextDependentConfig<P, boolean>;
|
|
27
|
+
advanced?: boolean;
|
|
27
28
|
}
|
|
28
29
|
declare type DefaultValueOrExpr<P, T> = {
|
|
29
30
|
defaultExpr?: undefined;
|
|
@@ -273,6 +274,15 @@ export interface ComponentMeta<P> {
|
|
|
273
274
|
* An array describing the component actions to be used in Studio.
|
|
274
275
|
*/
|
|
275
276
|
actions?: Action<P>[];
|
|
277
|
+
/**
|
|
278
|
+
* Whether style sections should be shown in Studio. For styles to work, the
|
|
279
|
+
* component must accept a `className` prop. If unset, defaults to true.
|
|
280
|
+
*/
|
|
281
|
+
styleSections?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Whether the element can be repeated in Studio. If unset, defaults to true.
|
|
284
|
+
*/
|
|
285
|
+
isRepeatable?: boolean;
|
|
276
286
|
/**
|
|
277
287
|
* The path to be used when importing the component in the generated code.
|
|
278
288
|
* It can be the name of the package that contains the component, or the path
|