@plasmicapp/host 1.0.47 → 1.0.50

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/data.d.ts CHANGED
@@ -1,17 +1,32 @@
1
1
  import React, { ReactNode } from "react";
2
2
  export declare type DataDict = Record<string, any>;
3
3
  export declare const DataContext: React.Context<Record<string, any> | undefined>;
4
+ export declare type DataMeta = {
5
+ hidden?: boolean;
6
+ };
7
+ export declare function mkMetaName(name: string): string;
8
+ export declare function mkMetaValue(meta: Partial<DataMeta>): DataMeta;
4
9
  export declare function applySelector(rawData: DataDict | undefined, selector: string | undefined): any;
5
10
  export declare type SelectorDict = Record<string, string | undefined>;
6
11
  export declare function useSelector(selector: string | undefined): any;
7
12
  export declare function useSelectors(selectors?: SelectorDict): any;
8
13
  export declare function useDataEnv(): Record<string, any> | undefined;
9
14
  export interface DataProviderProps {
15
+ /**
16
+ * Key to set in data context.
17
+ */
10
18
  name?: string;
19
+ /**
20
+ * Value to set for `name` in data context.
21
+ */
11
22
  data?: any;
23
+ /**
24
+ * If true, hide this entry in studio (data binding).
25
+ */
26
+ hidden?: boolean;
12
27
  children?: ReactNode;
13
28
  }
14
- export declare function DataProvider({ name, data, children }: DataProviderProps): JSX.Element;
29
+ export declare function DataProvider({ name, data, hidden, children, }: DataProviderProps): JSX.Element;
15
30
  export interface PageParamsProviderProps {
16
31
  params?: Record<string, string>;
17
32
  query?: Record<string, string>;
@@ -331,6 +331,12 @@ var tuple = function tuple() {
331
331
  };
332
332
 
333
333
  var DataContext = /*#__PURE__*/React.createContext(undefined);
334
+ function mkMetaName(name) {
335
+ return "__plasmic_meta_" + name;
336
+ }
337
+ function mkMetaValue(meta) {
338
+ return meta;
339
+ }
334
340
  function applySelector(rawData, selector) {
335
341
  if (!selector) {
336
342
  return undefined;
@@ -375,6 +381,7 @@ function DataProvider(_ref3) {
375
381
 
376
382
  var name = _ref3.name,
377
383
  data = _ref3.data,
384
+ hidden = _ref3.hidden,
378
385
  children = _ref3.children;
379
386
  var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
380
387
 
@@ -384,7 +391,9 @@ function DataProvider(_ref3) {
384
391
  var _extends2;
385
392
 
386
393
  return React__default.createElement(DataContext.Provider, {
387
- value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
394
+ value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2[mkMetaName(name)] = mkMetaValue({
395
+ hidden: hidden
396
+ }), _extends2))
388
397
  }, children);
389
398
  }
390
399
  }
@@ -508,6 +517,8 @@ var hostModule = {
508
517
  registerTrait: registerTrait,
509
518
  repeatedElement: repeatedElement,
510
519
  DataContext: DataContext,
520
+ mkMetaName: mkMetaName,
521
+ mkMetaValue: mkMetaValue,
511
522
  applySelector: applySelector,
512
523
  useSelector: useSelector,
513
524
  useSelectors: useSelectors,
@@ -517,6 +528,8 @@ var hostModule = {
517
528
  DataCtxReader: DataCtxReader
518
529
  };
519
530
 
531
+ var hostVersion = "1.0.50";
532
+
520
533
  var root$6 = globalThis;
521
534
 
522
535
  if (root$6.__Sub == null) {
@@ -527,6 +540,7 @@ if (root$6.__Sub == null) {
527
540
  React: React,
528
541
  ReactDOM: ReactDOM,
529
542
  hostModule: hostModule,
543
+ hostVersion: hostVersion,
530
544
  hostUtils: {
531
545
  setPlasmicRootNode: setPlasmicRootNode,
532
546
  registerRenderErrorListener: registerRenderErrorListener,
@@ -546,6 +560,8 @@ exports.PageParamsProvider = PageParamsProvider;
546
560
  exports.PlasmicCanvasContext = PlasmicCanvasContext;
547
561
  exports.PlasmicCanvasHost = PlasmicCanvasHost;
548
562
  exports.applySelector = applySelector;
563
+ exports.mkMetaName = mkMetaName;
564
+ exports.mkMetaValue = mkMetaValue;
549
565
  exports.registerComponent = registerComponent;
550
566
  exports.registerGlobalContext = registerGlobalContext;
551
567
  exports.registerTrait = registerTrait;
@@ -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/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 }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\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 function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string>;\n query?: Record<string, string>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n return (\n <DataProvider name={\"params\"} data={params}>\n <DataProvider name={\"query\"} data={query}>\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","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 a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import * 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\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\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\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","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","applySelector","rawData","selector","curData","split","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","useContext","DataProvider","name","data","existingEnv","PageParamsProvider","query","DataCtxReader","$ctx","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","console","log","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,cAAQ,CAAC,CAAD,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;;;;;;;;;;;;;;;;;ACrBP,IAAM/I,MAAI,GAAGC,UAAb;;AAEA,IAAID,MAAI,CAAC8I,KAAL,IAAc,IAAlB,EAAwB;AACtB;AACA;AACAE,EAAAA,OAAO,CAACC,GAAR,CAAY,2CAAZ;AACAjJ,EAAAA,MAAI,CAAC8I,KAAL;AACE/G,IAAAA,KAAK,EAALA,KADF;AAEE8B,IAAAA,QAAQ,EAARA,QAFF;AAGEqF,IAAAA,UAAU,EAAVA,UAHF;AAIEC,IAAAA,SAAS,EAAE;AACTxH,MAAAA,kBAAkB,EAAlBA,kBADS;AAETsD,MAAAA,2BAA2B,EAA3BA,2BAFS;AAGT4D,MAAAA,oBAAoB,EAApBA;AAHS,KAJb;AAUE;AACAlH,IAAAA,kBAAkB,EAAlBA,kBAXF;AAYEsD,IAAAA,2BAA2B,EAA3BA,2BAZF;AAaE4D,IAAAA,oBAAoB,EAApBA;AAbF,KAcKK,UAdL;AAgBD;;;;;;;;;;;;;;;;;;;"}
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 }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\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};\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 children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\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 }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string>;\n query?: Record<string, string>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n return (\n <DataProvider name={\"params\"} data={params}>\n <DataProvider name={\"query\"} data={query}>\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ninterface 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: (modalProps: ModalProps) => void;\n refreshQueryData: () => void;\n };\n}\n\ninterface Action<P> {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\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}\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 * 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\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","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 a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","export const hostVersion = \"1.0.50\";\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\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","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","existingEnv","PageParamsProvider","query","DataCtxReader","$ctx","__PlasmicFetcherRegistry","registerFetcher","fetcher","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","hostVersion","console","log","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,GAA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AD,CAArB,IAA8B,OAAOA,GAAP,KAAe,QAAjD,EAA2D;AACzD,WAAQM,kBAAY,CAACN,GAAD,CAApB;AACD;;AACD,SAAOA,GAAP;AACD,CAXD;;AAaA,IAAMzI,MAAI,GAAGC,UAAb;AACA,AAAO,IAAM+I,oBAAoB,4BAC/BhJ,MAD+B,mCAC/BA,MAAI,CAAEiJ,KADyB,qBAC/B,YAAaD,oBADkB,oCAE/B,UAAUE,EAAV;AACER,EAAAA,iBAAiB,GAAGQ,EAApB;AACD,CAJI;;;;;;;;;;;;;;;;;;;;;;;;;;AC9BA,IAAMC,WAAW,GAAG,QAApB;;ACWP,IAAMnJ,MAAI,GAAGC,UAAb;;AAEA,IAAID,MAAI,CAACiJ,KAAL,IAAc,IAAlB,EAAwB;AACtB;AACA;AACAG,EAAAA,OAAO,CAACC,GAAR,CAAY,2CAAZ;AACArJ,EAAAA,MAAI,CAACiJ,KAAL;AACElH,IAAAA,KAAK,EAALA,KADF;AAEE8B,IAAAA,QAAQ,EAARA,QAFF;AAGEyF,IAAAA,UAAU,EAAVA,UAHF;AAIEH,IAAAA,WAAW,EAAXA,WAJF;AAKEI,IAAAA,SAAS,EAAE;AACT5H,MAAAA,kBAAkB,EAAlBA,kBADS;AAETsD,MAAAA,2BAA2B,EAA3BA,2BAFS;AAGT+D,MAAAA,oBAAoB,EAApBA;AAHS,KALb;AAWE;AACArH,IAAAA,kBAAkB,EAAlBA,kBAZF;AAaEsD,IAAAA,2BAA2B,EAA3BA,2BAbF;AAcE+D,IAAAA,oBAAoB,EAApBA;AAdF,KAeKM,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 o(){return(o=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 a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var 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 p=0;function m(e){p++,u.set(e)}var d=t.createContext(!1),f=function(){return t.useContext(d)};function v(){var e,r,o,a=!!window.parent,i=!(null==(e=location.hash)||!e.match(/\bcanvas=true\b/)),s=!(null==(r=location.hash)||!r.match(/\blive=true\b/))||!a,m=a&&!document.querySelector("#plasmic-studio-tag")&&!i&&!s,f=(o=t.useState(0)[1],t.useCallback((function(){o((function(e){return e+1}))}),[]));if(t.useLayoutEffect((function(){return l.push(f),function(){var e=l.indexOf(f);e>=0&&l.splice(e,1)}}),[f]),t.useEffect((function(){var e,t;m&&a&&window.parent!==window&&(e=document.createElement("script"),t=c(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[m,a]),t.useEffect((function(){if(!m&&!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)}}),[m]),!a)return null;if(i||s){var v=document.querySelector("#plasmic-app.__wab_user-body");v||((v=document.createElement("div")).id="plasmic-app",v.classList.add("__wab_user-body"),document.body.appendChild(v));var h=new URLSearchParams(location.hash),g=!!i&&{componentName:h.get("componentName")};return n.createPortal(t.createElement(_,{key:""+p},t.createElement(d.Provider,{value:g},u.get())),v,"plasmic-app")}return m&&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),o=n[0],a=n[1];return t.useEffect((function(){a(t.createElement(v,null))}),[]),t.createElement(t.Fragment,null,!r&&t.createElement(b,null),o)},g=[];function y(e){return g.push(e),function(){var t=g.indexOf(e);t>=0&&g.splice(t,1)}}var _=function(e){var r,n;function o(t){var r;return(r=e.call(this,t)||this).state={},r}n=e,(r=o).prototype=Object.create(n.prototype),r.prototype.constructor=r,a(r,n),o.getDerivedStateFromError=function(e){return{error:e}};var i=o.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):this.props.children},o}(t.Component);function b(){return null}var x=t.createContext(void 0);function P(e,t){if(t){for(var r,n=e,o=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=o()).done;){var a;n=null==(a=n)?void 0:a[r.value]}return n}}function E(e){return P(w(),e)}function C(e){void 0===e&&(e={});var t=w();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],P(t,e[1]))})))}function w(){return t.useContext(x)}function R(e){var t,n,a=e.name,i=e.data,s=e.children,l=null!=(t=w())?t:{};return a?r.createElement(x.Provider,{value:o({},l,(n={},n[a]=i,n))},s):r.createElement(r.Fragment,null,s)}function S(e){var t=e.params,n=e.query;return r.createElement(R,{name:"params",data:void 0===t?{}:t},r.createElement(R,{name:"query",data:void 0===n?{}:n},e.children))}function j(e){return(0,e.children)(w())}var O=globalThis;function T(e,t){O.__PlasmicFetcherRegistry.push({fetcher:e,meta:t})}O.__PlasmicFetcherRegistry=[];var D=globalThis;function F(e,t){D.__PlasmicComponentRegistry.push({component:e,meta:t})}null==D.__PlasmicComponentRegistry&&(D.__PlasmicComponentRegistry=[]);var A=globalThis;function q(e,t){A.__PlasmicContextRegistry.push({component:e,meta:t})}null==A.__PlasmicContextRegistry&&(A.__PlasmicContextRegistry=[]);var H,L,U=globalThis;function I(e,t){U.__PlasmicTraitRegistry.push({trait:e,meta:t})}function M(e,t){return k(e,t)}null==U.__PlasmicTraitRegistry&&(U.__PlasmicTraitRegistry=[]);var k=function(e,r){return e?r:Array.isArray(r)?r.map((function(t){return M(e,t)})):r&&t.isValidElement(r)&&"string"!=typeof r?t.cloneElement(r):r},G=globalThis,N=null!=(H=null==G||null==(L=G.__Sub)?void 0:L.setRepeatedElementFn)?H:function(e){k=e},V={__proto__:null,PlasmicCanvasContext:d,PlasmicCanvasHost:h,usePlasmicCanvasContext:f,unstable_registerFetcher:T,registerComponent:F,registerGlobalContext:q,registerTrait:I,repeatedElement:M,DataContext:x,applySelector:P,useSelector:E,useSelectors:C,useDataEnv:w,DataProvider:R,PageParamsProvider:S,DataCtxReader:j},z=globalThis;null==z.__Sub&&(console.log("Plasmic: Setting up app host dependencies"),z.__Sub=o({React:t,ReactDOM:n,hostModule:V,hostUtils:{setPlasmicRootNode:m,registerRenderErrorListener:y,setRepeatedElementFn:N},setPlasmicRootNode:m,registerRenderErrorListener:y,setRepeatedElementFn:N},V)),exports.DataContext=x,exports.DataCtxReader=j,exports.DataProvider=R,exports.PageParamsProvider=S,exports.PlasmicCanvasContext=d,exports.PlasmicCanvasHost=h,exports.applySelector=P,exports.registerComponent=F,exports.registerGlobalContext=q,exports.registerTrait=I,exports.repeatedElement=M,exports.unstable_registerFetcher=T,exports.useDataEnv=w,exports.usePlasmicCanvasContext=f,exports.useSelector=E,exports.useSelectors=C;
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 o(){return(o=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 a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var 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 p=0;function m(e){p++,u.set(e)}var d=t.createContext(!1),f=function(){return t.useContext(d)};function v(){var e,r,o,a=!!window.parent,i=!(null==(e=location.hash)||!e.match(/\bcanvas=true\b/)),s=!(null==(r=location.hash)||!r.match(/\blive=true\b/))||!a,m=a&&!document.querySelector("#plasmic-studio-tag")&&!i&&!s,f=(o=t.useState(0)[1],t.useCallback((function(){o((function(e){return e+1}))}),[]));if(t.useLayoutEffect((function(){return l.push(f),function(){var e=l.indexOf(f);e>=0&&l.splice(e,1)}}),[f]),t.useEffect((function(){var e,t;m&&a&&window.parent!==window&&(e=document.createElement("script"),t=c(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[m,a]),t.useEffect((function(){if(!m&&!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)}}),[m]),!a)return null;if(i||s){var v=document.querySelector("#plasmic-app.__wab_user-body");v||((v=document.createElement("div")).id="plasmic-app",v.classList.add("__wab_user-body"),document.body.appendChild(v));var h=new URLSearchParams(location.hash),g=!!i&&{componentName:h.get("componentName")};return n.createPortal(t.createElement(y,{key:""+p},t.createElement(d.Provider,{value:g},u.get())),v,"plasmic-app")}return m&&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),o=n[0],a=n[1];return t.useEffect((function(){a(t.createElement(v,null))}),[]),t.createElement(t.Fragment,null,!r&&t.createElement(b,null),o)},g=[];function _(e){return g.push(e),function(){var t=g.indexOf(e);t>=0&&g.splice(t,1)}}var y=function(e){var r,n;function o(t){var r;return(r=e.call(this,t)||this).state={},r}n=e,(r=o).prototype=Object.create(n.prototype),r.prototype.constructor=r,a(r,n),o.getDerivedStateFromError=function(e){return{error:e}};var i=o.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):this.props.children},o}(t.Component);function b(){return null}var x=t.createContext(void 0);function P(e){return"__plasmic_meta_"+e}function E(e){return e}function C(e,t){if(t){for(var r,n=e,o=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=o()).done;){var a;n=null==(a=n)?void 0:a[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 j(e){var t,n,a=e.name,i=e.data,s=e.hidden,l=e.children,u=null!=(t=S())?t:{};return a?r.createElement(x.Provider,{value:o({},u,(n={},n[a]=i,n[P(a)]={hidden:s},n))},l):r.createElement(r.Fragment,null,l)}function O(e){var t=e.params,n=e.query;return r.createElement(j,{name:"params",data:void 0===t?{}:t},r.createElement(j,{name:"query",data:void 0===n?{}:n},e.children))}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 A=globalThis;function M(e,t){A.__PlasmicComponentRegistry.push({component:e,meta:t})}null==A.__PlasmicComponentRegistry&&(A.__PlasmicComponentRegistry=[]);var k=globalThis;function q(e,t){k.__PlasmicContextRegistry.push({component:e,meta:t})}null==k.__PlasmicContextRegistry&&(k.__PlasmicContextRegistry=[]);var V,H,L=globalThis;function N(e,t){L.__PlasmicTraitRegistry.push({trait:e,meta:t})}function U(e,t){return I(e,t)}null==L.__PlasmicTraitRegistry&&(L.__PlasmicTraitRegistry=[]);var I=function(e,r){return e?r:Array.isArray(r)?r.map((function(t){return U(e,t)})):r&&t.isValidElement(r)&&"string"!=typeof r?t.cloneElement(r):r},G=globalThis,z=null!=(V=null==G||null==(H=G.__Sub)?void 0:H.setRepeatedElementFn)?V:function(e){I=e},W={__proto__:null,PlasmicCanvasContext:d,PlasmicCanvasHost:h,usePlasmicCanvasContext:f,unstable_registerFetcher:F,registerComponent:M,registerGlobalContext:q,registerTrait:N,repeatedElement:U,DataContext:x,mkMetaName:P,mkMetaValue:E,applySelector:C,useSelector:w,useSelectors:R,useDataEnv:S,DataProvider:j,PageParamsProvider:O,DataCtxReader:T},$=globalThis;null==$.__Sub&&(console.log("Plasmic: Setting up app host dependencies"),$.__Sub=o({React:t,ReactDOM:n,hostModule:W,hostVersion:"1.0.50",hostUtils:{setPlasmicRootNode:m,registerRenderErrorListener:_,setRepeatedElementFn:z},setPlasmicRootNode:m,registerRenderErrorListener:_,setRepeatedElementFn:z},W)),exports.DataContext=x,exports.DataCtxReader=T,exports.DataProvider=j,exports.PageParamsProvider=O,exports.PlasmicCanvasContext=d,exports.PlasmicCanvasHost=h,exports.applySelector=C,exports.mkMetaName=P,exports.mkMetaValue=E,exports.registerComponent=M,exports.registerGlobalContext=q,exports.registerTrait=N,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"],"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 }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\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 function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string>;\n query?: Record<string, string>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n return (\n <DataProvider name={\"params\"} data={params}>\n <DataProvider name={\"query\"} data={query}>\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","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 a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import * 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\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\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\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":["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","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","applySelector","rawData","selector","curData","split","_curData","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","args","tuple","useContext","DataProvider","name","data","existingEnv","PageParamsProvider","params","query","DataCtxReader","registerFetcher","fetcher","meta","__PlasmicFetcherRegistry","registerComponent","component","__PlasmicComponentRegistry","registerGlobalContext","__PlasmicContextRegistry","registerTrait","trait","__PlasmicTraitRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","console","log","hostModule","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,iBAKlC,GACWC,EAA0B,kBACrCD,aAAiBD,IAEnB,SAASG,YE/DEC,EFoEHC,IAAoBC,OAAOC,OAC3BC,aAAajB,SAASC,QAATiB,EAAeC,MAAM,oBAClCC,aAAWpB,SAASC,QAAToB,EAAeF,MAAM,oBAAqBL,EACrDQ,EACJR,IACCS,SAASC,cAAc,yBAC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4D,qBAAAA,GACGM"}
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 }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\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};\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 children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\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 }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string>;\n query?: Record<string, string>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n return (\n <DataProvider name={\"params\"} data={params}>\n <DataProvider name={\"query\"} data={query}>\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ninterface 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: (modalProps: ModalProps) => void;\n refreshQueryData: () => void;\n };\n}\n\ninterface Action<P> {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\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}\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 * 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\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","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 a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import * 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\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.50\";\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","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","existingEnv","PageParamsProvider","params","query","DataCtxReader","registerFetcher","fetcher","__PlasmicFetcherRegistry","registerComponent","component","__PlasmicComponentRegistry","registerGlobalContext","__PlasmicContextRegistry","registerTrait","trait","__PlasmicTraitRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","console","log","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,iBAKlC,GACWC,EAA0B,kBACrCD,aAAiBD,IAEnB,SAASG,YE/DEC,EFoEHC,IAAoBC,OAAOC,OAC3BC,aAAajB,SAASC,QAATiB,EAAeC,MAAM,oBAClCC,aAAWpB,SAASC,QAAToB,EAAeF,MAAM,oBAAqBL,EACrDQ,EACJR,IACCS,SAASC,cAAc,yBACvBP,IACAG,EACGK,GE5EGZ,EAAWa,WAAS,MACdC,eAAY,WACzBd,GAAQ,SAACe,UAASA,EAAO,OACxB,QF0EHlB,mBAAsB,kBACpBxB,EAAoB2C,KAAKJ,GAClB,eACCK,EAAQ5C,EAAoB6C,QAAQN,GACtCK,GAAS,GACX5C,EAAoB8C,OAAOF,EAAO,MAGrC,CAACL,IACJf,aAAgB,WApDlB,IACQuB,EACAC,EAmDAZ,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hD1G,EAAKuI,yBAA2B,GCrChC,IAAMvI,EAAOC,oBAyYWuI,EACtBC,EACA/B,GAEA1G,EAAK0I,2BAA2B5F,KAAK,CAAE2F,UAAAA,EAAW/B,KAAAA,IARb,MAAnC1G,EAAK0I,6BACP1I,EAAK0I,2BAA6B,IClYpC,IAAM1I,EAAOC,oBAsFW0I,EAEtBF,EAAc/B,GACd1G,EAAK4I,yBAAyB9F,KAAK,CAAE2F,UAAAA,EAAW/B,KAAAA,IAPb,MAAjC1G,EAAK4I,2BACP5I,EAAK4I,yBAA2B,IC7FlC,QAAM5I,EAAOC,oBA8BW4I,EAAcC,EAAepC,GACnD1G,EAAK+I,uBAAuBjG,KAAK,CAC/BgG,MAAAA,EACApC,KAAAA,aCrBoBsC,EAAmBC,EAAoBC,UACtDC,EAAkBF,EAAWC,GDaH,MAA/BlJ,EAAK+I,yBACP/I,EAAK+I,uBAAyB,ICXhC,IAAII,EAAoB,SAAIF,EAAoBC,UAC1CD,EACKC,EAELE,MAAMC,QAAQH,GACRA,EAAIzB,KAAI,SAAC6B,UAAMN,EAAgBC,EAAWK,MAEhDJ,GAAOK,iBAAeL,IAAuB,iBAARA,EAC/BM,eAAaN,GAEhBA,GAGHlJ,EAAOC,WACAwJ,iBACXzJ,YAAAA,EAAM0J,cAANC,EAAaF,wBACb,SAAUG,GACRT,EAAoBS,2VCtBlB5J,EAAOC,WAEK,MAAdD,EAAK0J,QAGPG,QAAQC,IAAI,6CACZ9J,EAAK0J,SACH/H,MAAAA,EACA2C,SAAAA,EACAyF,WAAAA,EACAC,YCrBuB,SDsBvBC,UAAW,CACT1I,mBAAAA,EACAmE,4BAAAA,EACA+D,qBAAAA,GAIFlI,mBAAAA,EACAmE,4BAAAA,EACA+D,qBAAAA,GACGM"}
package/dist/host.esm.js CHANGED
@@ -329,6 +329,12 @@ var tuple = function tuple() {
329
329
  };
330
330
 
331
331
  var DataContext = /*#__PURE__*/createContext(undefined);
332
+ function mkMetaName(name) {
333
+ return "__plasmic_meta_" + name;
334
+ }
335
+ function mkMetaValue(meta) {
336
+ return meta;
337
+ }
332
338
  function applySelector(rawData, selector) {
333
339
  if (!selector) {
334
340
  return undefined;
@@ -373,6 +379,7 @@ function DataProvider(_ref3) {
373
379
 
374
380
  var name = _ref3.name,
375
381
  data = _ref3.data,
382
+ hidden = _ref3.hidden,
376
383
  children = _ref3.children;
377
384
  var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
378
385
 
@@ -382,7 +389,9 @@ function DataProvider(_ref3) {
382
389
  var _extends2;
383
390
 
384
391
  return React__default.createElement(DataContext.Provider, {
385
- value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
392
+ value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2[mkMetaName(name)] = mkMetaValue({
393
+ hidden: hidden
394
+ }), _extends2))
386
395
  }, children);
387
396
  }
388
397
  }
@@ -506,6 +515,8 @@ var hostModule = {
506
515
  registerTrait: registerTrait,
507
516
  repeatedElement: repeatedElement,
508
517
  DataContext: DataContext,
518
+ mkMetaName: mkMetaName,
519
+ mkMetaValue: mkMetaValue,
509
520
  applySelector: applySelector,
510
521
  useSelector: useSelector,
511
522
  useSelectors: useSelectors,
@@ -515,6 +526,8 @@ var hostModule = {
515
526
  DataCtxReader: DataCtxReader
516
527
  };
517
528
 
529
+ var hostVersion = "1.0.50";
530
+
518
531
  var root$6 = globalThis;
519
532
 
520
533
  if (root$6.__Sub == null) {
@@ -525,6 +538,7 @@ if (root$6.__Sub == null) {
525
538
  React: React,
526
539
  ReactDOM: ReactDOM,
527
540
  hostModule: hostModule,
541
+ hostVersion: hostVersion,
528
542
  hostUtils: {
529
543
  setPlasmicRootNode: setPlasmicRootNode,
530
544
  registerRenderErrorListener: registerRenderErrorListener,
@@ -537,5 +551,5 @@ if (root$6.__Sub == null) {
537
551
  }, hostModule);
538
552
  }
539
553
 
540
- export { DataContext, DataCtxReader, DataProvider, PageParamsProvider, PlasmicCanvasContext, PlasmicCanvasHost, applySelector, registerComponent, registerGlobalContext, registerTrait, repeatedElement, registerFetcher as unstable_registerFetcher, useDataEnv, usePlasmicCanvasContext, useSelector, useSelectors };
554
+ export { DataContext, DataCtxReader, DataProvider, PageParamsProvider, PlasmicCanvasContext, PlasmicCanvasHost, applySelector, mkMetaName, mkMetaValue, registerComponent, registerGlobalContext, registerTrait, repeatedElement, registerFetcher as unstable_registerFetcher, useDataEnv, usePlasmicCanvasContext, useSelector, useSelectors };
541
555
  //# sourceMappingURL=host.esm.js.map
@@ -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/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 }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\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 function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string>;\n query?: Record<string, string>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n return (\n <DataProvider name={\"params\"} data={params}>\n <DataProvider name={\"query\"} data={query}>\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","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 a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import * 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\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\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n hostModule,\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","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","applySelector","rawData","selector","curData","split","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","useContext","DataProvider","name","data","existingEnv","PageParamsProvider","query","DataCtxReader","$ctx","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","console","log","hostModule","hostUtils"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;SAIeC,OAAUD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AAON,eAAe,CAACC,SAAD,EAAYK,CAAZ,CAAtB;AAAA,KAAR,CAAR;AACD;;AACD,MAAIJ,GAAG,IAAIK,cAAc,CAACL,GAAD,CAArB,IAA8B,OAAOA,GAAP,KAAe,QAAjD,EAA2D;AACzD,WAAQM,YAAY,CAACN,GAAD,CAApB;AACD;;AACD,SAAOA,GAAP;AACD,CAXD;;AAaA,IAAMzI,MAAI,GAAGC,UAAb;AACA,AAAO,IAAM+I,oBAAoB,4BAC/BhJ,MAD+B,mCAC/BA,MAAI,CAAEiJ,KADyB,qBAC/B,YAAaD,oBADkB,oCAE/B,UAAUE,EAAV;AACER,EAAAA,iBAAiB,GAAGQ,EAApB;AACD,CAJI;;;;;;;;;;;;;;;;;;;;;;;;ACrBP,IAAMlJ,MAAI,GAAGC,UAAb;;AAEA,IAAID,MAAI,CAACiJ,KAAL,IAAc,IAAlB,EAAwB;AACtB;AACA;AACAE,EAAAA,OAAO,CAACC,GAAR,CAAY,2CAAZ;AACApJ,EAAAA,MAAI,CAACiJ,KAAL;AACElH,IAAAA,KAAK,EAALA,KADF;AAEE8B,IAAAA,QAAQ,EAARA,QAFF;AAGEwF,IAAAA,UAAU,EAAVA,UAHF;AAIEC,IAAAA,SAAS,EAAE;AACT3H,MAAAA,kBAAkB,EAAlBA,kBADS;AAETsD,MAAAA,2BAA2B,EAA3BA,2BAFS;AAGT+D,MAAAA,oBAAoB,EAApBA;AAHS,KAJb;AAUE;AACArH,IAAAA,kBAAkB,EAAlBA,kBAXF;AAYEsD,IAAAA,2BAA2B,EAA3BA,2BAZF;AAaE+D,IAAAA,oBAAoB,EAApBA;AAbF,KAcKK,UAdL;AAgBD;;;;"}
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 }\n | boolean\n>(false);\nexport const usePlasmicCanvasContext = () =>\n React.useContext(PlasmicCanvasContext);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n const locationHash = new URLSearchParams(location.hash);\n const plasmicContextValue = isCanvas\n ? {\n componentName: locationHash.get(\"componentName\"),\n }\n : false;\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={plasmicContextValue}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <iframe\n src={`https://docs.plasmic.app/app-content/app-host-ready#appHostUrl=${encodeURIComponent(\n location.href\n )}`}\n style={{\n width: \"100vw\",\n height: \"100vh\",\n border: \"none\",\n position: \"fixed\",\n top: 0,\n left: 0,\n zIndex: 99999999,\n }}\n ></iframe>\n );\n }\n return null;\n}\n\ninterface PlasmicCanvasHostProps {\n /**\n * Webpack hmr uses EventSource to\tlisten to hot reloads, but that\n * resultsin a persistent\tconnection from\teach window. In Plasmic\n * Studio, if a project is configured to use app-hosting with a\n * nextjs or gatsby server running in dev mode, each artboard will\n * be holding a persistent connection to the dev server.\n * Because browsers\thave a limit to\thow many connections can\n * be held\tat a time by domain, this means\tafter X\tartboards, new\n * artboards will freeze and not load.\n *\n * By default, <PlasmicCanvasHost /> will globally mutate\n * window.EventSource to avoid using EventSource for HMR, which you\n * typically don't need for your custom host page. If you do still\n * want to retain HRM, then youc an pass enableWebpackHmr={true}.\n */\n enableWebpackHmr?: boolean;\n}\n\nexport const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps> = (\n props\n) => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\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};\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 children?: ReactNode;\n}\n\nexport function DataProvider({\n name,\n data,\n hidden,\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 }),\n }}\n >\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface PageParamsProviderProps {\n params?: Record<string, string>;\n query?: Record<string, string>;\n children?: ReactNode;\n}\n\nexport function PageParamsProvider({\n children,\n params = {},\n query = {},\n}: PageParamsProviderProps) {\n return (\n <DataProvider name={\"params\"} data={params}>\n <DataProvider name={\"query\"} data={query}>\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ninterface 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: (modalProps: ModalProps) => void;\n refreshQueryData: () => void;\n };\n}\n\ninterface Action<P> {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\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}\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 * 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\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the context to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","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 a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","export const hostVersion = \"1.0.50\";\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\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","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","existingEnv","PageParamsProvider","query","DataCtxReader","$ctx","__PlasmicFetcherRegistry","registerFetcher","fetcher","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","__PlasmicTraitRegistry","registerTrait","trait","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","hostVersion","console","log","hostModule","hostUtils"],"mappings":";;;;;;;;;;;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AAAA,kBAAkB,EAAlBA,kBADS;AAETsD,MAAAA,2BAA2B,EAA3BA,2BAFS;AAGTkE,MAAAA,oBAAoB,EAApBA;AAHS,KALb;AAWE;AACAxH,IAAAA,kBAAkB,EAAlBA,kBAZF;AAaEsD,IAAAA,2BAA2B,EAA3BA,2BAbF;AAcEkE,IAAAA,oBAAoB,EAApBA;AAdF,KAeKM,UAfL;AAiBD;;;;"}
@@ -164,6 +164,24 @@ declare type ControlTypeBase = {
164
164
  export declare type SupportControlled<T> = Extract<T, String | CustomControl<any>> | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);
165
165
  export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType<P>;
166
166
  declare type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
167
+ interface ActionProps<P> {
168
+ componentProps: P;
169
+ /**
170
+ * `contextData` can be `null` if the prop controls are rendering before
171
+ * the component instance itself (it will re-render once the component
172
+ * calls `setControlContextData`)
173
+ */
174
+ contextData: InferDataType<P> | null;
175
+ studioOps: {
176
+ showModal: (modalProps: ModalProps) => void;
177
+ refreshQueryData: () => void;
178
+ };
179
+ }
180
+ interface Action<P> {
181
+ type: "button-action";
182
+ label: string;
183
+ onClick: (props: ActionProps<P>) => void;
184
+ }
167
185
  declare type DistributedKeyOf<T> = T extends any ? keyof T : never;
168
186
  interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
169
187
  /**
@@ -205,6 +223,10 @@ export interface ComponentMeta<P> {
205
223
  } & {
206
224
  [prop: string]: PropType<P>;
207
225
  };
226
+ /**
227
+ * An array describing the component actions to be used in Studio.
228
+ */
229
+ actions?: Action<P>[];
208
230
  /**
209
231
  * The path to be used when importing the component in the generated code.
210
232
  * It can be the name of the package that contains the component, or the path
@@ -0,0 +1 @@
1
+ export declare const hostVersion = "1.0.50";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/host",
3
- "version": "1.0.47",
3
+ "version": "1.0.50",
4
4
  "description": "plasmic library for app hosting",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  ],
24
24
  "scripts": {
25
- "build": "tsdx build && rollup -c",
25
+ "build": "./update_version.sh && tsdx build && rollup -c",
26
26
  "start": "tsdx watch",
27
27
  "test": "tsdx test --passWithNoTests",
28
28
  "lint": "tsdx lint",
@@ -55,5 +55,5 @@
55
55
  "react": ">=16.8.0",
56
56
  "react-dom": ">=16.8.0"
57
57
  },
58
- "gitHead": "bd649b245105111e590fe3ff09814c7df2a54ad1"
58
+ "gitHead": "abeca34e3880ca524d37315ed0d3aad56e00fd8e"
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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n"],"names":[],"mappings":";;;;AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA6W/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}\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ninterface 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: (modalProps: ModalProps) => void;\n refreshQueryData: () => void;\n };\n}\n\ninterface Action<P> {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\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}\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 * 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\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;AAqY/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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n"],"names":[],"mappings":"AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA6W/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}\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: \"code\";\n lang: \"graphql\";\n endpoint: string | ContextDependentConfig<P, string>;\n method?: string | ContextDependentConfig<P, string>;\n headers?: object | ContextDependentConfig<P, object>;\n variables?: object | ContextDependentConfig<P, object>;\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n } & DefaultValueOrExpr<P, boolean> &\n PropTypeBase<P>);\n\ntype NumberTypeBase<P> = PropTypeBase<P> &\n DefaultValueOrExpr<P, number> & {\n type: \"number\";\n };\n\nexport type NumberType<P> =\n | \"number\"\n | ((\n | {\n control?: \"default\";\n min?: number | ContextDependentConfig<P, number>;\n max?: number | ContextDependentConfig<P, number>;\n }\n | {\n control: \"slider\";\n min: number | ContextDependentConfig<P, number>;\n max: number | ContextDependentConfig<P, number>;\n step?: number | ContextDependentConfig<P, number>;\n }\n ) &\n NumberTypeBase<P>);\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>)\n | ({\n type: \"array\";\n } & DefaultValueOrExpr<P, any[]> &\n PropTypeBase<P>)\n | ({\n type: \"dataSource\";\n dataSource: \"airtable\" | \"cms\";\n } & PropTypeBase<P>)\n | ({\n type: \"dataSelector\";\n data: any | ContextDependentConfig<P, any>;\n } & DefaultValueOrExpr<P, any> &\n PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n | ContextDependentConfig<\n P,\n | string[]\n | {\n label: string;\n value: string | number | boolean;\n }[]\n >;\n}\n\nexport type ChoiceType<P> = (\n | ({\n multiSelect?: false;\n } & DefaultValueOrExpr<P, string>)\n | ({\n multiSelect: true;\n } & DefaultValueOrExpr<P, string[]>)\n) &\n ChoiceTypeBase<P>;\n\nexport interface ModalProps {\n show?: boolean;\n children?: React.ReactNode;\n onClose: () => void;\n style?: CSSProperties;\n}\n\ninterface CustomControlProps<P> {\n componentProps: P;\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null;\n value: any;\n /**\n * Sets the value to be passed to the prop. Expects a JSON-compatible value.\n */\n updateValue: (newVal: any) => void;\n /**\n * Full screen modal component\n */\n FullscreenModal: React.ComponentType<ModalProps>;\n /**\n * Modal component for the side pane\n */\n SideModal: React.ComponentType<ModalProps>;\n}\nexport type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;\n\n/**\n * Expects defaultValue to be a JSON-compatible value\n */\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n } & PropTypeBase<P> &\n DefaultValueOrExpr<P, any>);\n\ntype SlotType<P> =\n | \"slot\"\n | ({\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n /**\n * Whether the slot is repeated, i.e., is rendered multiple times using\n * repeatedElement().\n */\n isRepeated?: boolean;\n } & Omit<\n DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>,\n \"defaultValueHint\" | \"defaultExpr\" | \"defaultExprHint\"\n >);\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n } & DefaultValueOrExpr<P, string> &\n PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType<P>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ninterface 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: (modalProps: ModalProps) => void;\n refreshQueryData: () => void;\n };\n}\n\ninterface Action<P> {\n type: \"button-action\";\n label: string;\n onClick: (props: ActionProps<P>) => void;\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}\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 * 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\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;AAqY/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;;;;"}
@@ -164,6 +164,24 @@ declare type ControlTypeBase = {
164
164
  export declare type SupportControlled<T> = Extract<T, String | CustomControl<any>> | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);
165
165
  export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType<P>;
166
166
  declare type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
167
+ interface ActionProps<P> {
168
+ componentProps: P;
169
+ /**
170
+ * `contextData` can be `null` if the prop controls are rendering before
171
+ * the component instance itself (it will re-render once the component
172
+ * calls `setControlContextData`)
173
+ */
174
+ contextData: InferDataType<P> | null;
175
+ studioOps: {
176
+ showModal: (modalProps: ModalProps) => void;
177
+ refreshQueryData: () => void;
178
+ };
179
+ }
180
+ interface Action<P> {
181
+ type: "button-action";
182
+ label: string;
183
+ onClick: (props: ActionProps<P>) => void;
184
+ }
167
185
  declare type DistributedKeyOf<T> = T extends any ? keyof T : never;
168
186
  interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
169
187
  /**
@@ -205,6 +223,10 @@ export interface ComponentMeta<P> {
205
223
  } & {
206
224
  [prop: string]: PropType<P>;
207
225
  };
226
+ /**
227
+ * An array describing the component actions to be used in Studio.
228
+ */
229
+ actions?: Action<P>[];
208
230
  /**
209
231
  * The path to be used when importing the component in the generated code.
210
232
  * It can be the name of the package that contains the component, or the path
@@ -164,6 +164,24 @@ declare type ControlTypeBase = {
164
164
  export declare type SupportControlled<T> = Extract<T, String | CustomControl<any>> | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);
165
165
  export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P>> | SlotType<P>;
166
166
  declare type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
167
+ interface ActionProps<P> {
168
+ componentProps: P;
169
+ /**
170
+ * `contextData` can be `null` if the prop controls are rendering before
171
+ * the component instance itself (it will re-render once the component
172
+ * calls `setControlContextData`)
173
+ */
174
+ contextData: InferDataType<P> | null;
175
+ studioOps: {
176
+ showModal: (modalProps: ModalProps) => void;
177
+ refreshQueryData: () => void;
178
+ };
179
+ }
180
+ interface Action<P> {
181
+ type: "button-action";
182
+ label: string;
183
+ onClick: (props: ActionProps<P>) => void;
184
+ }
167
185
  declare type DistributedKeyOf<T> = T extends any ? keyof T : never;
168
186
  interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
169
187
  /**
@@ -205,6 +223,10 @@ export interface ComponentMeta<P> {
205
223
  } & {
206
224
  [prop: string]: PropType<P>;
207
225
  };
226
+ /**
227
+ * An array describing the component actions to be used in Studio.
228
+ */
229
+ actions?: Action<P>[];
208
230
  /**
209
231
  * The path to be used when importing the component in the generated code.
210
232
  * It can be the name of the package that contains the component, or the path