@plasmicapp/host 1.0.5 → 1.0.9
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/common.d.ts +1 -0
- package/dist/data.d.ts +13 -39
- package/dist/fetcher.d.ts +40 -0
- package/dist/host.cjs.development.js +135 -1
- package/dist/host.cjs.development.js.map +1 -1
- package/dist/host.cjs.production.min.js +1 -1
- package/dist/host.cjs.production.min.js.map +1 -1
- package/dist/host.esm.js +128 -3
- package/dist/host.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/registerComponent.d.ts +4 -0
- package/package.json +2 -2
- package/registerComponent/dist/index.cjs.js.map +1 -1
- package/registerComponent/dist/index.esm.js.map +1 -1
- package/registerComponent/dist/registerComponent.d.ts +4 -0
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tuple: <T extends any[]>(...args: T) => T;
|
package/dist/data.d.ts
CHANGED
|
@@ -1,40 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* The symbol to import from the importPath.
|
|
14
|
-
*/
|
|
15
|
-
importName?: string;
|
|
16
|
-
args: {
|
|
17
|
-
name: string;
|
|
18
|
-
type: PrimitiveType;
|
|
19
|
-
}[];
|
|
20
|
-
returns: PrimitiveType;
|
|
21
|
-
/**
|
|
22
|
-
* Either the path to the fetcher relative to `rootDir` or the npm
|
|
23
|
-
* package name
|
|
24
|
-
*/
|
|
25
|
-
importPath: string;
|
|
26
|
-
/**
|
|
27
|
-
* Whether it's a default export or named export
|
|
28
|
-
*/
|
|
29
|
-
isDefaultExport?: boolean;
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export declare type DataDict = Record<string, any>;
|
|
3
|
+
export declare const DataContext: React.Context<Record<string, any> | undefined>;
|
|
4
|
+
export declare function applySelector(rawData: DataDict | undefined, selector: string | undefined): any;
|
|
5
|
+
export declare type SelectorDict = Record<string, string | undefined>;
|
|
6
|
+
export declare function useSelector(selector: string | undefined): any;
|
|
7
|
+
export declare function useSelectors(selectors?: SelectorDict): any;
|
|
8
|
+
export declare function useDataEnv(): Record<string, any> | undefined;
|
|
9
|
+
export interface DataProviderProps {
|
|
10
|
+
name?: string;
|
|
11
|
+
data?: any;
|
|
12
|
+
children?: ReactNode;
|
|
30
13
|
}
|
|
31
|
-
export
|
|
32
|
-
fetcher: Fetcher;
|
|
33
|
-
meta: FetcherMeta;
|
|
34
|
-
}
|
|
35
|
-
declare global {
|
|
36
|
-
interface Window {
|
|
37
|
-
__PlasmicFetcherRegistry: FetcherRegistration[];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export declare function registerFetcher(fetcher: Fetcher, meta: FetcherMeta): void;
|
|
14
|
+
export declare function DataProvider({ name, data, children }: DataProviderProps): JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PrimitiveType } from "./index";
|
|
2
|
+
export declare type Fetcher = (...args: any[]) => Promise<any>;
|
|
3
|
+
export interface FetcherMeta {
|
|
4
|
+
/**
|
|
5
|
+
* Any unique identifying string for this fetcher.
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* The Studio-user-friendly display name.
|
|
10
|
+
*/
|
|
11
|
+
displayName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The symbol to import from the importPath.
|
|
14
|
+
*/
|
|
15
|
+
importName?: string;
|
|
16
|
+
args: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: PrimitiveType;
|
|
19
|
+
}[];
|
|
20
|
+
returns: PrimitiveType;
|
|
21
|
+
/**
|
|
22
|
+
* Either the path to the fetcher relative to `rootDir` or the npm
|
|
23
|
+
* package name
|
|
24
|
+
*/
|
|
25
|
+
importPath: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether it's a default export or named export
|
|
28
|
+
*/
|
|
29
|
+
isDefaultExport?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface FetcherRegistration {
|
|
32
|
+
fetcher: Fetcher;
|
|
33
|
+
meta: FetcherMeta;
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface Window {
|
|
37
|
+
__PlasmicFetcherRegistry: FetcherRegistration[];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export declare function registerFetcher(fetcher: Fetcher, meta: FetcherMeta): void;
|
|
@@ -2,10 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
5
7
|
require('@plasmicapp/preamble');
|
|
6
8
|
var React = require('react');
|
|
9
|
+
var React__default = _interopDefault(React);
|
|
7
10
|
var ReactDOM = require('react-dom');
|
|
8
11
|
|
|
12
|
+
function _extends() {
|
|
13
|
+
_extends = Object.assign || function (target) {
|
|
14
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
+
var source = arguments[i];
|
|
16
|
+
|
|
17
|
+
for (var key in source) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
19
|
+
target[key] = source[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return _extends.apply(this, arguments);
|
|
28
|
+
}
|
|
29
|
+
|
|
9
30
|
function _inheritsLoose(subClass, superClass) {
|
|
10
31
|
subClass.prototype = Object.create(superClass.prototype);
|
|
11
32
|
subClass.prototype.constructor = subClass;
|
|
@@ -22,6 +43,44 @@ function _setPrototypeOf(o, p) {
|
|
|
22
43
|
return _setPrototypeOf(o, p);
|
|
23
44
|
}
|
|
24
45
|
|
|
46
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
47
|
+
if (!o) return;
|
|
48
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
49
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
50
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
51
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
52
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _arrayLikeToArray(arr, len) {
|
|
56
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
57
|
+
|
|
58
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
59
|
+
|
|
60
|
+
return arr2;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
64
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
65
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
66
|
+
|
|
67
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
68
|
+
if (it) o = it;
|
|
69
|
+
var i = 0;
|
|
70
|
+
return function () {
|
|
71
|
+
if (i >= o.length) return {
|
|
72
|
+
done: true
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
done: false,
|
|
76
|
+
value: o[i++]
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
82
|
+
}
|
|
83
|
+
|
|
25
84
|
var root = globalThis;
|
|
26
85
|
root.__PlasmicFetcherRegistry = [];
|
|
27
86
|
function registerFetcher(fetcher, meta) {
|
|
@@ -126,6 +185,73 @@ function useForceUpdate() {
|
|
|
126
185
|
return update;
|
|
127
186
|
}
|
|
128
187
|
|
|
188
|
+
var tuple = function tuple() {
|
|
189
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
190
|
+
args[_key] = arguments[_key];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return args;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
var DataContext = /*#__PURE__*/React.createContext(undefined);
|
|
197
|
+
function applySelector(rawData, selector) {
|
|
198
|
+
if (!selector) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var curData = rawData;
|
|
203
|
+
|
|
204
|
+
for (var _iterator = _createForOfIteratorHelperLoose(selector.split(".")), _step; !(_step = _iterator()).done;) {
|
|
205
|
+
var _curData;
|
|
206
|
+
|
|
207
|
+
var key = _step.value;
|
|
208
|
+
curData = (_curData = curData) == null ? void 0 : _curData[key];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return curData;
|
|
212
|
+
}
|
|
213
|
+
function useSelector(selector) {
|
|
214
|
+
var rawData = useDataEnv();
|
|
215
|
+
return applySelector(rawData, selector);
|
|
216
|
+
}
|
|
217
|
+
function useSelectors(selectors) {
|
|
218
|
+
if (selectors === void 0) {
|
|
219
|
+
selectors = {};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
var rawData = useDataEnv();
|
|
223
|
+
return Object.fromEntries(Object.entries(selectors).filter(function (_ref) {
|
|
224
|
+
var key = _ref[0],
|
|
225
|
+
selector = _ref[1];
|
|
226
|
+
return !!key && !!selector;
|
|
227
|
+
}).map(function (_ref2) {
|
|
228
|
+
var key = _ref2[0],
|
|
229
|
+
selector = _ref2[1];
|
|
230
|
+
return tuple(key, applySelector(rawData, selector));
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
function useDataEnv() {
|
|
234
|
+
return React.useContext(DataContext);
|
|
235
|
+
}
|
|
236
|
+
function DataProvider(_ref3) {
|
|
237
|
+
var _useDataEnv;
|
|
238
|
+
|
|
239
|
+
var name = _ref3.name,
|
|
240
|
+
data = _ref3.data,
|
|
241
|
+
children = _ref3.children;
|
|
242
|
+
var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
|
|
243
|
+
|
|
244
|
+
if (!name) {
|
|
245
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
246
|
+
} else {
|
|
247
|
+
var _extends2;
|
|
248
|
+
|
|
249
|
+
return React__default.createElement(DataContext.Provider, {
|
|
250
|
+
value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
|
|
251
|
+
}, children);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
129
255
|
var root$4 = globalThis;
|
|
130
256
|
|
|
131
257
|
if (root$4.__PlasmicHostVersion == null) {
|
|
@@ -285,7 +411,9 @@ if (root$4.__Sub == null) {
|
|
|
285
411
|
registerRenderErrorListener: registerRenderErrorListener,
|
|
286
412
|
repeatedElement: repeatedElement,
|
|
287
413
|
setRepeatedElementFn: setRepeatedElementFn,
|
|
288
|
-
PlasmicCanvasContext: PlasmicCanvasContext
|
|
414
|
+
PlasmicCanvasContext: PlasmicCanvasContext,
|
|
415
|
+
DataProvider: DataProvider,
|
|
416
|
+
useDataEnv: useDataEnv
|
|
289
417
|
};
|
|
290
418
|
}
|
|
291
419
|
|
|
@@ -348,10 +476,16 @@ function DisableWebpackHmr() {
|
|
|
348
476
|
});
|
|
349
477
|
}
|
|
350
478
|
|
|
479
|
+
exports.DataContext = DataContext;
|
|
480
|
+
exports.DataProvider = DataProvider;
|
|
351
481
|
exports.PlasmicCanvasContext = PlasmicCanvasContext;
|
|
352
482
|
exports.PlasmicCanvasHost = PlasmicCanvasHost;
|
|
483
|
+
exports.applySelector = applySelector;
|
|
353
484
|
exports.registerComponent = registerComponent;
|
|
354
485
|
exports.registerGlobalContext = registerGlobalContext;
|
|
355
486
|
exports.repeatedElement = repeatedElement;
|
|
356
487
|
exports.unstable_registerFetcher = registerFetcher;
|
|
488
|
+
exports.useDataEnv = useDataEnv;
|
|
489
|
+
exports.useSelector = useSelector;
|
|
490
|
+
exports.useSelectors = useSelectors;
|
|
357
491
|
//# sourceMappingURL=host.cjs.development.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.cjs.development.js","sources":["../src/data.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n}\n\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 javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach(f => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <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> = props => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach(listener => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,IAAI,GAAGC,UAAb;AAyCAD,IAAI,CAACE,wBAAL,GAAgC,EAAhC;SAEgBC,gBAAgBC,SAAkBC;AAChDL,EAAAA,IAAI,CAACE,wBAAL,CAA8BI,IAA9B,CAAmC;AAAEF,IAAAA,OAAO,EAAPA,OAAF;AAAWC,IAAAA,IAAI,EAAJA;AAAX,GAAnC;AACD;;AC9CD,SAASE,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;AAID,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AAA,oBAAoB,CAACtE,OAArB,CAA6B,UAAAuE,QAAQ;AAAA,aAAIA,QAAQ,CAACG,KAAD,CAAZ;AAAA,KAArC;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAOlD,mBAAA,MAAA,MAAA,WAAA,OAAgB,KAAKgD,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAWe,QAAlB;AACD;AACF;;;EAvByBtD;;AA0B5B,SAAS0C,iBAAT;AACE;AAGA,SACE1C,mBAAA,SAAA;AACEuD,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"host.cjs.development.js","sources":["../src/fetcher.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","export const tuple = <T extends any[]>(...args: T): T => args;\n","import React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./fetcher\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport { DataProvider, useDataEnv } from \"./data\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach(f => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <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> = props => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach(listener => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","tuple","args","DataContext","createContext","applySelector","rawData","selector","curData","split","key","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,IAAI,GAAGC,UAAb;AAyCAD,IAAI,CAACE,wBAAL,GAAgC,EAAhC;SAEgBC,gBAAgBC,SAAkBC;AAChDL,EAAAA,IAAI,CAACE,wBAAL,CAA8BI,IAA9B,CAAmC;AAAEF,IAAAA,OAA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,IAArB,CAA0BkI,QAA1B;AACA,SAAO;AACL,QAAMlC,KAAK,GAAGiC,oBAAoB,CAAChC,OAArB,CAA6BiC,QAA7B,CAAd;;AACA,QAAIlC,KAAK,IAAI,CAAb,EAAgB;AACdiC,MAAAA,oBAAoB,CAAC/B,MAArB,CAA4BF,KAA5B,EAAmC,CAAnC;AACD;AACF,GALD;AAMD;;IAUKc;;;AAIJ,yBAAYY,KAAZ;;;AACE,yCAAMA,KAAN;AACA,WAAKS,KAAL,GAAa,EAAb;;AACD;;gBAEMC,2BAAP,kCAAgCC,KAAhC;AACE,WAAO;AAAEA,MAAAA,KAAK,EAALA;AAAF,KAAP;AACD;;;;SAEDC,oBAAA,2BAAkBD,KAAlB;AACEJ,IAAAA,oBAAoB,CAACnE,OAArB,CAA6B,UAAAoE,QAAQ;AAAA,aAAIA,QAAQ,CAACG,KAAD,CAAZ;AAAA,KAArC;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAO9E,mBAAA,MAAA,MAAA,WAAA,OAAgB,KAAK4E,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAWrE,QAAlB;AACD;AACF;;;EAvByBE;;AA0B5B,SAASsE,iBAAT;AACE;AAGA,SACEtE,mBAAA,SAAA;AACEkF,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("@plasmicapp/preamble");var e=require("react"),t=require("react-dom");function n(e,t){return(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("@plasmicapp/preamble");var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=require("react-dom");function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l=globalThis;l.__PlasmicFetcherRegistry=[];var u=globalThis;null==u.__PlasmicComponentRegistry&&(u.__PlasmicComponentRegistry=[]);var c,s,p=globalThis;function f(e,t){return d(e,t)}null==p.__PlasmicContextRegistry&&(p.__PlasmicContextRegistry=[]);var d=function(e,n){return e?n:Array.isArray(n)?n.map((function(t){return f(e,t)})):n&&t.isValidElement(n)&&"string"!=typeof n?t.cloneElement(n):n},m=globalThis,v=null!=(c=null==m||null==(s=m.__Sub)?void 0:s.setRepeatedElementFn)?c:function(e){d=e},h=t.createContext(void 0);function y(e,t){if(t){for(var n,r=e,o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t.split("."));!(n=o()).done;){var a;r=null==(a=r)?void 0:a[n.value]}return r}}function b(){return t.useContext(h)}function g(e){var t,r,a=e.name,i=e.data,l=e.children,u=null!=(t=b())?t:{};return a?n.createElement(h.Provider,{value:o({},u,(r={},r[a]=i,r))},l):n.createElement(n.Fragment,null,l)}var _=globalThis;null==_.__PlasmicHostVersion&&(_.__PlasmicHostVersion="2");var E=[],w=new function(e){var t=this;this.value=null,this.set=function(e){t.value=e,E.forEach((function(e){return e()}))},this.get=function(){return t.value}}(null);function x(){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,C=t.createContext(!1);function R(){var e,n,o,a=!!window.parent,i=!(null==(e=location.hash)||!e.match(/\bcanvas=true\b/)),l=!(null==(n=location.hash)||!n.match(/\blive=true\b/))||!a,u=a&&!document.querySelector("#plasmic-studio-tag")&&!i&&!l,c=(o=t.useState(0)[1],t.useCallback((function(){o((function(e){return e+1}))}),[]));if(t.useLayoutEffect((function(){return E.push(c),function(){var e=E.indexOf(c);e>=0&&E.splice(e,1)}}),[c]),t.useEffect((function(){var e,t;u&&a&&window.parent!==window&&(e=document.createElement("script"),t=x(),e.src=t+"/static/js/studio.js",document.body.appendChild(e))}),[u,a]),t.useEffect((function(){if(!u&&!document.querySelector("#getlibs")&&l){var e=document.createElement("script");e.id="getlibs",e.src=x()+"/static/js/getlibs.js",e.async=!1,e.onload=function(){null==window.__GetlibsReadyResolver||window.__GetlibsReadyResolver()},document.head.append(e)}}),[u]),!a)return null;if(i||l){var s=document.querySelector("#plasmic-app.__wab_user-body");return s||((s=document.createElement("div")).id="plasmic-app",s.classList.add("__wab_user-body"),document.body.appendChild(s)),r.createPortal(t.createElement(j,{key:""+P},t.createElement(C.Provider,{value:i},w.get())),s,"plasmic-app")}return u&&window.parent===window?t.createElement("iframe",{src:"https://docs.plasmic.app/app-content/app-host-ready#appHostUrl="+encodeURIComponent(location.href),style:{width:"100vw",height:"100vh",border:"none",position:"fixed",top:0,left:0,zIndex:99999999}}):null}null==_.__Sub&&(console.log("Plasmic: Setting up app host dependencies"),_.__Sub={React:t,ReactDOM:r,setPlasmicRootNode:function(e){P++,w.set(e)},registerRenderErrorListener:function(e){return S.push(e),function(){var t=S.indexOf(e);t>=0&&S.splice(t,1)}},repeatedElement:f,setRepeatedElementFn:v,PlasmicCanvasContext:C,DataProvider:g,useDataEnv:b});var S=[],j=function(e){var n,r;function o(t){var n;return(n=e.call(this,t)||this).state={},n}r=e,(n=o).prototype=Object.create(r.prototype),n.prototype.constructor=n,a(n,r),o.getDerivedStateFromError=function(e){return{error:e}};var i=o.prototype;return i.componentDidCatch=function(e){S.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 O(){return null}exports.DataContext=h,exports.DataProvider=g,exports.PlasmicCanvasContext=C,exports.PlasmicCanvasHost=function(e){var n=e.enableWebpackHmr,r=t.useState(null),o=r[0],a=r[1];return t.useEffect((function(){a(t.createElement(R,null))}),[]),t.createElement(t.Fragment,null,!n&&t.createElement(O,null),o)},exports.applySelector=y,exports.registerComponent=function(e,t){u.__PlasmicComponentRegistry.push({component:e,meta:t})},exports.registerGlobalContext=function(e,t){p.__PlasmicContextRegistry.push({component:e,meta:t})},exports.repeatedElement=f,exports.unstable_registerFetcher=function(e,t){l.__PlasmicFetcherRegistry.push({fetcher:e,meta:t})},exports.useDataEnv=b,exports.useSelector=function(e){return y(b(),e)},exports.useSelectors=function(e){void 0===e&&(e={});var t=b();return Object.fromEntries(Object.entries(e).filter((function(e){return!!e[0]&&!!e[1]})).map((function(e){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t}(e[0],y(t,e[1]))})))};
|
|
2
2
|
//# sourceMappingURL=host.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.cjs.production.min.js","sources":["../src/data.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/index.tsx","../src/lang-utils.ts","../src/useForceUpdate.ts"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n}\n\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 javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach(f => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <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> = props => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach(listener => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","__PlasmicComponentRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","__PlasmicContextRegistry","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","value","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","PlasmicCanvasContext","React","_PlasmicCanvasHost","setTick","isFrameAttached","window","parent","isCanvas","_location$hash","match","isLive","_location$hash2","shouldRenderStudio","document","querySelector","forceUpdate","useState","useCallback","tick","push","index","indexOf","splice","script","plasmicOrigin","createElement","src","body","appendChild","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","console","log","setPlasmicRootNode","node","set","registerRenderErrorListener","listener","renderErrorListeners","props","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","children","DisableWebpackHmr","enableWebpackHmr","setNode","component","meta","fetcher"],"mappings":"8OACA,IAAMA,EAAOC,WAyCbD,EAAKE,yBAA2B,GCpChC,IAAMF,EAAOC,WAyU0B,MAAnCD,EAAKG,6BACPH,EAAKG,2BAA6B,ICtUpC,QAAMH,EAAOC,oBCEWG,EAAmBC,EAAoBC,UACtDC,EAAkBF,EAAWC,GD2ED,MAAjCN,EAAKQ,2BACPR,EAAKQ,yBAA2B,ICzElC,IAAID,EAAoB,SAAIF,EAAoBC,UAC1CD,EACKC,EAELG,MAAMC,QAAQJ,GACRA,EAAIK,KAAI,SAACC,UAAMR,EAAgBC,EAAWO,MAEhDN,GAAOO,iBAAeP,IAAuB,iBAARA,EAC/BQ,eAAaR,GAEhBA,GAGHN,EAAOC,WACAc,iBACXf,YAAAA,EAAMgB,cAANC,EAAaF,wBACb,SAAUG,GACRX,EAAoBW,GCVlBlB,EAAOC,WA0BoB,MAA7BD,EAAKmB,uBACPnB,EAAKmB,qBAAuB,KAG9B,IAAMC,EAAsC,GAUtCC,EAAkB,IARtB,SAAoBC,yBAQ6B,cAP3C,SAACC,GACLC,EAAKF,MAAQC,EACbH,EAAoBK,SAAQ,SAAAC,UAAKA,iBAE7B,kBAAMF,EAAKF,OAGK,CAA2B,MAEnD,SAASK,oBC3DiBC,EAAyBC,eAAAA,IAAAA,EAAiB,IAC9DD,MAAAA,Q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AcC,GACdlH,EAAKQ,yBAAyBmD,KAAK,CAAEsD,UAAAA,EAAWC,KAAAA,yEFnDlBC,EAAkBD,GAChDlH,EAAKE,yBAAyByD,KAAK,CAAEwD,QAAAA,EAASD,KAAAA"}
|
|
1
|
+
{"version":3,"file":"host.cjs.production.min.js","sources":["../src/fetcher.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/data.tsx","../src/index.tsx","../src/lang-utils.ts","../src/useForceUpdate.ts","../src/common.ts"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./fetcher\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport { DataProvider, useDataEnv } from \"./data\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach(f => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <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> = props => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach(listener => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","export const tuple = <T extends any[]>(...args: T): T => args;\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","__PlasmicComponentRegistry","repeatedElement","isPrimary","elt","repeatedElementFn","__PlasmicContextRegistry","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","_root$__Sub","fn","DataContext","createContext","undefined","applySelector","rawData","selector","curData","split","_curData","useDataEnv","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","__PlasmicHostVersion","rootChangeListeners","plasmicRootNode","val","_this","forEach","f","getPlasmicOrigin","x","msg","isString","Error","ensure","URL","location","hash","replace","searchParams","get","renderCount","PlasmicCanvasContext","_PlasmicCanvasHost","setTick","isFrameAttached","window","parent","isCanvas","_location$hash","match","isLive","_location$hash2","shouldRenderStudio","document","querySelector","forceUpdate","useState","useCallback","tick","push","index","indexOf","splice","script","plasmicOrigin","createElement","src","body","appendChild","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","console","log","setPlasmicRootNode","node","set","registerRenderErrorListener","listener","renderErrorListeners","props","state","getDerivedStateFromError","error","componentDidCatch","render","this","message","DisableWebpackHmr","enableWebpackHmr","setNode","component","meta","fetcher","selectors","Object","fromEntries","entries","filter","args","tuple"],"mappings":"gmBACA,IAAMA,EAAOC,WAyCbD,EAAKE,yBAA2B,GCpChC,IAAMF,EAAOC,WA6U0B,MAAnCD,EAAKG,6BACPH,EAAKG,2BAA6B,IC1UpC,QAAMH,EAAOC,oBCEWG,EAAmBC,EAAoBC,UACtDC,EAAkBF,EAAWC,GD2ED,MAAjCN,EAAKQ,2BACPR,EAAKQ,yBAA2B,ICzElC,IAAID,EAAoB,SAAIF,EAAoBC,UAC1CD,EACKC,EAELG,MAAMC,QAAQJ,GACRA,EAAIK,KAAI,SAACC,UAAMR,EAAgBC,EAAWO,MAEhDN,GAAOO,iBAAeP,IAAuB,iBAARA,EAC/BQ,eAAaR,GAEhBA,GAGHN,EAAOC,WACAc,iBACXf,YAAAA,EAAMgB,cAANC,EAAaF,wBACb,SAAUG,GACRX,EAAoBW,GC5BXC,EAAcC,qBAAoCC,YAE/CC,EACdC,EACAC,MAEKA,aAGDC,EAAUF,wrBACIC,EAASE,MAAM,qBAAM,OACrCD,WAAUA,UAAAE,kBAELF,GAmBT,SAAgBG,WACPC,aAAWV,YASJW,aAAeC,IAAAA,KAAMC,IAAAA,KAAMC,IAAAA,SACnCC,WAAcN,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GXC,kBAAA,SAAkBD,GAChBJ,EAAqBzE,SAAQ,SAAAwE,UAAYA,EAASK,SAGpDE,OAAA,kBACMC,KAAKL,MAAME,MACNrF,wCAAgBwF,KAAKL,MAAME,MAAMI,SAEjCD,KAAKN,MAAMpF,aArBIE,aA0B5B,SAAS0F,WAEE,2GAjFuE,SAAAR,OACxES,EAAqBT,EAArBS,mBACgB3F,WACtB,MADK6E,OAAMe,cAGb5F,aAAgB,WACd4F,EAAQ5F,gBAACwB,WACR,IAEDxB,iCACI2F,GAAoB3F,gBAAC0F,QACtBb,+DJwILgB,EACAC,GAEAjI,EAAKG,2BAA2ByE,KAAK,CAAEoD,UAAAA,EAAWC,KAAAA,4CC7PlDD,EAAcC,GACdjI,EAAKQ,yBAAyBoE,KAAK,CAAEoD,UAAAA,EAAWC,KAAAA,yEFnDlBC,EAAkBD,GAChDjI,EAAKE,yBAAyB0E,KAAK,CAAEsD,QAAAA,EAASD,KAAAA,uDItBpBzG,UAEnBF,EADSM,IACcJ,kCAGH2G,YAAAA,IAAAA,EAA0B,QAC/C5G,EAAUK,WACTwG,OAAOC,YACZD,OAAOE,QAAQH,GACZI,QAAO,oCACP5H,KAAI,mBIjCU,sCAAqB6H,2BAAAA,yBAAeA,EJiCzBC,MAAWnH,EAAcC"}
|
package/dist/host.esm.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import '@plasmicapp/preamble';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { isValidElement, cloneElement, useState, useCallback, createContext, useEffect, createElement, Fragment, useLayoutEffect, Component } from 'react';
|
|
3
|
+
import React__default, { isValidElement, cloneElement, useState, useCallback, createContext, useContext, useEffect, createElement, Fragment, useLayoutEffect, Component } from 'react';
|
|
4
4
|
import * as ReactDOM from 'react-dom';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
|
|
7
|
+
function _extends() {
|
|
8
|
+
_extends = Object.assign || function (target) {
|
|
9
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
10
|
+
var source = arguments[i];
|
|
11
|
+
|
|
12
|
+
for (var key in source) {
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14
|
+
target[key] = source[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return _extends.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
function _inheritsLoose(subClass, superClass) {
|
|
8
26
|
subClass.prototype = Object.create(superClass.prototype);
|
|
9
27
|
subClass.prototype.constructor = subClass;
|
|
@@ -20,6 +38,44 @@ function _setPrototypeOf(o, p) {
|
|
|
20
38
|
return _setPrototypeOf(o, p);
|
|
21
39
|
}
|
|
22
40
|
|
|
41
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
42
|
+
if (!o) return;
|
|
43
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
44
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
45
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
46
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
47
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _arrayLikeToArray(arr, len) {
|
|
51
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
52
|
+
|
|
53
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
54
|
+
|
|
55
|
+
return arr2;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
59
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
60
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
61
|
+
|
|
62
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
63
|
+
if (it) o = it;
|
|
64
|
+
var i = 0;
|
|
65
|
+
return function () {
|
|
66
|
+
if (i >= o.length) return {
|
|
67
|
+
done: true
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
done: false,
|
|
71
|
+
value: o[i++]
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
77
|
+
}
|
|
78
|
+
|
|
23
79
|
var root = globalThis;
|
|
24
80
|
root.__PlasmicFetcherRegistry = [];
|
|
25
81
|
function registerFetcher(fetcher, meta) {
|
|
@@ -124,6 +180,73 @@ function useForceUpdate() {
|
|
|
124
180
|
return update;
|
|
125
181
|
}
|
|
126
182
|
|
|
183
|
+
var tuple = function tuple() {
|
|
184
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
185
|
+
args[_key] = arguments[_key];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return args;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
var DataContext = /*#__PURE__*/createContext(undefined);
|
|
192
|
+
function applySelector(rawData, selector) {
|
|
193
|
+
if (!selector) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
var curData = rawData;
|
|
198
|
+
|
|
199
|
+
for (var _iterator = _createForOfIteratorHelperLoose(selector.split(".")), _step; !(_step = _iterator()).done;) {
|
|
200
|
+
var _curData;
|
|
201
|
+
|
|
202
|
+
var key = _step.value;
|
|
203
|
+
curData = (_curData = curData) == null ? void 0 : _curData[key];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return curData;
|
|
207
|
+
}
|
|
208
|
+
function useSelector(selector) {
|
|
209
|
+
var rawData = useDataEnv();
|
|
210
|
+
return applySelector(rawData, selector);
|
|
211
|
+
}
|
|
212
|
+
function useSelectors(selectors) {
|
|
213
|
+
if (selectors === void 0) {
|
|
214
|
+
selectors = {};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
var rawData = useDataEnv();
|
|
218
|
+
return Object.fromEntries(Object.entries(selectors).filter(function (_ref) {
|
|
219
|
+
var key = _ref[0],
|
|
220
|
+
selector = _ref[1];
|
|
221
|
+
return !!key && !!selector;
|
|
222
|
+
}).map(function (_ref2) {
|
|
223
|
+
var key = _ref2[0],
|
|
224
|
+
selector = _ref2[1];
|
|
225
|
+
return tuple(key, applySelector(rawData, selector));
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
function useDataEnv() {
|
|
229
|
+
return useContext(DataContext);
|
|
230
|
+
}
|
|
231
|
+
function DataProvider(_ref3) {
|
|
232
|
+
var _useDataEnv;
|
|
233
|
+
|
|
234
|
+
var name = _ref3.name,
|
|
235
|
+
data = _ref3.data,
|
|
236
|
+
children = _ref3.children;
|
|
237
|
+
var existingEnv = (_useDataEnv = useDataEnv()) != null ? _useDataEnv : {};
|
|
238
|
+
|
|
239
|
+
if (!name) {
|
|
240
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
241
|
+
} else {
|
|
242
|
+
var _extends2;
|
|
243
|
+
|
|
244
|
+
return React__default.createElement(DataContext.Provider, {
|
|
245
|
+
value: _extends({}, existingEnv, (_extends2 = {}, _extends2[name] = data, _extends2))
|
|
246
|
+
}, children);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
127
250
|
var root$4 = globalThis;
|
|
128
251
|
|
|
129
252
|
if (root$4.__PlasmicHostVersion == null) {
|
|
@@ -283,7 +406,9 @@ if (root$4.__Sub == null) {
|
|
|
283
406
|
registerRenderErrorListener: registerRenderErrorListener,
|
|
284
407
|
repeatedElement: repeatedElement,
|
|
285
408
|
setRepeatedElementFn: setRepeatedElementFn,
|
|
286
|
-
PlasmicCanvasContext: PlasmicCanvasContext
|
|
409
|
+
PlasmicCanvasContext: PlasmicCanvasContext,
|
|
410
|
+
DataProvider: DataProvider,
|
|
411
|
+
useDataEnv: useDataEnv
|
|
287
412
|
};
|
|
288
413
|
}
|
|
289
414
|
|
|
@@ -349,5 +474,5 @@ function DisableWebpackHmr() {
|
|
|
349
474
|
});
|
|
350
475
|
}
|
|
351
476
|
|
|
352
|
-
export { PlasmicCanvasContext, PlasmicCanvasHost, registerComponent, registerGlobalContext, repeatedElement, registerFetcher as unstable_registerFetcher };
|
|
477
|
+
export { DataContext, DataProvider, PlasmicCanvasContext, PlasmicCanvasHost, applySelector, registerComponent, registerGlobalContext, repeatedElement, registerFetcher as unstable_registerFetcher, useDataEnv, useSelector, useSelectors };
|
|
353
478
|
//# sourceMappingURL=host.esm.js.map
|
package/dist/host.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.esm.js","sources":["../src/data.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n}\n\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 javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./data\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach(f => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <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> = props => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach(listener => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","value","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","React","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","key","Provider","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","children","process","env","NODE_ENV","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,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AA,oBAAoB,CAACjC,MAArB,CAA4BF,KAA5B,EAAmC,CAAnC;AACD;AACF,GALD;AAMD;;IAUKc;;;AAIJ,yBAAYc,KAAZ;;;AACE,yCAAMA,KAAN;AACA,WAAKS,KAAL,GAAa,EAAb;;AACD;;gBAEMC,2BAAP,kCAAgCC,KAAhC;AACE,WAAO;AAAEA,MAAAA,KAAK,EAALA;AAAF,KAAP;AACD;;;;SAEDC,oBAAA,2BAAkBD,KAAlB;AACEJ,IAAAA,oBAAoB,CAACtE,OAArB,CAA6B,UAAAuE,QAAQ;AAAA,aAAIA,QAAQ,CAACG,KAAD,CAAZ;AAAA,KAArC;AACD;;SAEDE,SAAA;AACE,QAAI,KAAKJ,KAAL,CAAWE,KAAf,EAAsB;AACpB,aAAOlD,aAAA,MAAA,MAAA,WAAA,OAAgB,KAAKgD,KAAL,CAAWE,KAAX,CAAiBG,OAAjC,CAAP;AACD,KAFD,MAEO;AACL,aAAO,KAAKd,KAAL,CAAWe,QAAlB;AACD;AACF;;;EAvByBtD;;AA0B5B,SAAS0C,iBAAT;AACE,MAAIa,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,WAAO,IAAP;AACD;;AACD,SACEzD,aAAA,SAAA;AACE0D,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;"}
|
|
1
|
+
{"version":3,"file":"host.esm.js","sources":["../src/fetcher.ts","../src/lang-utils.ts","../src/registerComponent.ts","../src/registerGlobalContext.ts","../src/repeatedElement.ts","../src/useForceUpdate.ts","../src/common.ts","../src/data.tsx","../src/index.tsx"],"sourcesContent":["import { PrimitiveType } from \"./index\";\nconst root = globalThis as any;\n\nexport type Fetcher = (...args: any[]) => Promise<any>;\n\nexport interface FetcherMeta {\n /**\n * Any unique identifying string for this fetcher.\n */\n name: string;\n /**\n * The Studio-user-friendly display name.\n */\n displayName?: string;\n /**\n * The symbol to import from the importPath.\n */\n importName?: string;\n args: { name: string; type: PrimitiveType }[];\n returns: PrimitiveType;\n /**\n * Either the path to the fetcher relative to `rootDir` or the npm\n * package name\n */\n importPath: string;\n /**\n * Whether it's a default export or named export\n */\n isDefaultExport?: boolean;\n}\n\nexport interface FetcherRegistration {\n fetcher: Fetcher;\n meta: FetcherMeta;\n}\n\ndeclare global {\n interface Window {\n __PlasmicFetcherRegistry: FetcherRegistration[];\n }\n}\n\nroot.__PlasmicFetcherRegistry = [];\n\nexport function registerFetcher(fetcher: Fetcher, meta: FetcherMeta) {\n root.__PlasmicFetcherRegistry.push({ fetcher, meta });\n}\n","function isString(x: any): x is string {\n return typeof x === \"string\";\n}\n\ntype StringGen = string | (() => string);\n\nexport function ensure<T>(x: T | null | undefined, msg: StringGen = \"\"): T {\n if (x === null || x === undefined) {\n debugger;\n msg = (isString(msg) ? msg : msg()) || \"\";\n throw new Error(\n `Value must not be undefined or null${msg ? `- ${msg}` : \"\"}`\n );\n } else {\n return x;\n }\n}\n","import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n","import {\n BooleanType,\n ChoiceType,\n CustomType,\n JSONLikeType,\n NumberType,\n StringType,\n SupportControlled,\n} from \"./registerComponent\";\n\nconst root = globalThis as any;\n\nexport type PropType<P> = SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | CustomType<P>\n>;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\nexport interface GlobalContextMeta<P> {\n /**\n * Any unique string name used to identify that context. Each context\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the context in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the context properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the context in the generated code.\n * It can be the name of the package that contains the context, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the context is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n}\n\nexport interface GlobalContextRegistration {\n component: React.ComponentType<any>;\n meta: GlobalContextMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicContextRegistry: GlobalContextRegistration[];\n }\n}\n\nif (root.__PlasmicContextRegistry == null) {\n root.__PlasmicContextRegistry = [];\n}\n\nexport default function registerGlobalContext<\n T extends React.ComponentType<any>\n>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>) {\n root.__PlasmicContextRegistry.push({ component, meta });\n}\n","import { cloneElement, isValidElement } from \"react\";\n\n/**\n * Allows a component from Plasmic Studio to be repeated.\n * `isPrimary` should be true for at most one instance of the component, and\n * indicates which copy of the element will be highlighted when the element is\n * selected in Studio.\n * If `isPrimary` is `false`, and `elt` is a React element (or an array of such),\n * it'll be cloned (using React.cloneElement) and ajusted if it's a component\n * from Plasmic Studio. Otherwise, if `elt` is not a React element, the original\n * value is returned.\n */\nexport default function repeatedElement<T>(isPrimary: boolean, elt: T): T {\n return repeatedElementFn(isPrimary, elt);\n}\n\nlet repeatedElementFn = <T>(isPrimary: boolean, elt: T): T => {\n if (isPrimary) {\n return elt;\n }\n if (Array.isArray(elt)) {\n return (elt.map((v) => repeatedElement(isPrimary, v)) as any) as T;\n }\n if (elt && isValidElement(elt) && typeof elt !== \"string\") {\n return (cloneElement(elt) as any) as T;\n }\n return elt;\n};\n\nconst root = globalThis as any;\nexport const setRepeatedElementFn: (fn: typeof repeatedElement) => void =\n root?.__Sub?.setRepeatedElementFn ??\n function (fn: typeof repeatedElement) {\n repeatedElementFn = fn;\n };\n","import { useCallback, useState } from \"react\";\n\nexport default function useForceUpdate() {\n const [, setTick] = useState(0);\n const update = useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n","export const tuple = <T extends any[]>(...args: T): T => args;\n","import React, { createContext, ReactNode, useContext } from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n","// tslint:disable:ordered-imports\n// organize-imports-ignore\nimport \"@plasmicapp/preamble\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { registerFetcher as unstable_registerFetcher } from \"./fetcher\";\nimport { PlasmicElement } from \"./element-types\";\nimport { ensure } from \"./lang-utils\";\nimport registerComponent, {\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n} from \"./registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n GlobalContextRegistration,\n PropType as GlobalContextPropType,\n} from \"./registerGlobalContext\";\nimport repeatedElement, { setRepeatedElementFn } from \"./repeatedElement\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport { DataProvider, useDataEnv } from \"./data\";\nconst root = globalThis as any;\n\nexport { unstable_registerFetcher };\nexport { repeatedElement };\nexport {\n registerComponent,\n ComponentMeta,\n ComponentRegistration,\n ComponentTemplates,\n PrimitiveType,\n PropType,\n};\nexport {\n registerGlobalContext,\n GlobalContextMeta,\n GlobalContextRegistration,\n GlobalContextPropType,\n};\nexport { PlasmicElement };\nexport * from \"./data\";\n\ndeclare global {\n interface Window {\n __PlasmicHostVersion: string;\n }\n}\n\nif (root.__PlasmicHostVersion == null) {\n root.__PlasmicHostVersion = \"2\";\n}\n\nconst rootChangeListeners: (() => void)[] = [];\nclass PlasmicRootNodeWrapper {\n constructor(private value: null | React.ReactElement) {}\n set = (val: null | React.ReactElement) => {\n this.value = val;\n rootChangeListeners.forEach(f => f());\n };\n get = () => this.value;\n}\n\nconst plasmicRootNode = new PlasmicRootNodeWrapper(null);\n\nfunction getPlasmicOrigin() {\n const params = new URL(`https://fakeurl/${location.hash.replace(/#/, \"?\")}`)\n .searchParams;\n return ensure(\n params.get(\"origin\"),\n \"Missing information from Plasmic window.\"\n );\n}\n\nfunction renderStudioIntoIframe() {\n const script = document.createElement(\"script\");\n const plasmicOrigin = getPlasmicOrigin();\n script.src = plasmicOrigin + \"/static/js/studio.js\";\n document.body.appendChild(script);\n}\n\nlet renderCount = 0;\nfunction setPlasmicRootNode(node: React.ReactElement | null) {\n // Keep track of renderCount, which we use as key to ErrorBoundary, so\n // we can reset the error on each render\n renderCount++;\n plasmicRootNode.set(node);\n}\n\n/**\n * React context to detect whether the component is rendered on Plasmic editor.\n */\nexport const PlasmicCanvasContext = React.createContext<boolean>(false);\n\nfunction _PlasmicCanvasHost() {\n // If window.parent is null, then this is a window whose containing iframe\n // has been detached from the DOM (for the top window, window.parent === window).\n // In that case, we shouldn't do anything. If window.parent is null, by the way,\n // location.hash will also be null.\n const isFrameAttached = !!window.parent;\n const isCanvas = !!location.hash?.match(/\\bcanvas=true\\b/);\n const isLive = !!location.hash?.match(/\\blive=true\\b/) || !isFrameAttached;\n const shouldRenderStudio =\n isFrameAttached &&\n !document.querySelector(\"#plasmic-studio-tag\") &&\n !isCanvas &&\n !isLive;\n const forceUpdate = useForceUpdate();\n React.useLayoutEffect(() => {\n rootChangeListeners.push(forceUpdate);\n return () => {\n const index = rootChangeListeners.indexOf(forceUpdate);\n if (index >= 0) {\n rootChangeListeners.splice(index, 1);\n }\n };\n }, [forceUpdate]);\n React.useEffect(() => {\n if (shouldRenderStudio && isFrameAttached && window.parent !== window) {\n renderStudioIntoIframe();\n }\n }, [shouldRenderStudio, isFrameAttached]);\n React.useEffect(() => {\n if (!shouldRenderStudio && !document.querySelector(\"#getlibs\") && isLive) {\n const scriptElt = document.createElement(\"script\");\n scriptElt.id = \"getlibs\";\n scriptElt.src = getPlasmicOrigin() + \"/static/js/getlibs.js\";\n scriptElt.async = false;\n scriptElt.onload = () => {\n (window as any).__GetlibsReadyResolver?.();\n };\n document.head.append(scriptElt);\n }\n }, [shouldRenderStudio]);\n if (!isFrameAttached) {\n return null;\n }\n if (isCanvas || isLive) {\n let appDiv = document.querySelector(\"#plasmic-app.__wab_user-body\");\n if (!appDiv) {\n appDiv = document.createElement(\"div\");\n appDiv.id = \"plasmic-app\";\n appDiv.classList.add(\"__wab_user-body\");\n document.body.appendChild(appDiv);\n }\n return ReactDOM.createPortal(\n <ErrorBoundary key={`${renderCount}`}>\n <PlasmicCanvasContext.Provider value={isCanvas}>\n {plasmicRootNode.get()}\n </PlasmicCanvasContext.Provider>\n </ErrorBoundary>,\n appDiv,\n \"plasmic-app\"\n );\n }\n if (shouldRenderStudio && window.parent === window) {\n return (\n <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> = props => {\n const { enableWebpackHmr } = props;\n const [node, setNode] = React.useState<React.ReactElement<any, any> | null>(\n null\n );\n React.useEffect(() => {\n setNode(<_PlasmicCanvasHost />);\n }, []);\n return (\n <>\n {!enableWebpackHmr && <DisableWebpackHmr />}\n {node}\n </>\n );\n};\n\nif (root.__Sub == null) {\n // Creating a side effect here by logging, so that vite won't\n // ignore this block for whatever reason\n console.log(\"Plasmic: Setting up app host dependencies\");\n root.__Sub = {\n React,\n ReactDOM,\n setPlasmicRootNode,\n registerRenderErrorListener,\n repeatedElement,\n setRepeatedElementFn,\n PlasmicCanvasContext,\n DataProvider,\n useDataEnv,\n };\n}\n\ntype RenderErrorListener = (err: Error) => void;\nconst renderErrorListeners: RenderErrorListener[] = [];\nfunction registerRenderErrorListener(listener: RenderErrorListener) {\n renderErrorListeners.push(listener);\n return () => {\n const index = renderErrorListeners.indexOf(listener);\n if (index >= 0) {\n renderErrorListeners.splice(index, 1);\n }\n };\n}\n\ninterface ErrorBoundaryProps {\n children?: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error?: Error;\n}\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {};\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n renderErrorListeners.forEach(listener => listener(error));\n }\n\n render() {\n if (this.state.error) {\n return <div>Error: {`${this.state.error.message}`}</div>;\n } else {\n return this.props.children;\n }\n }\n}\n\nfunction DisableWebpackHmr() {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n return (\n <script\n type=\"text/javascript\"\n dangerouslySetInnerHTML={{\n __html: `\n if (typeof window !== \"undefined\") {\n const RealEventSource = window.EventSource;\n window.EventSource = function(url, config) {\n if (/[^a-zA-Z]hmr($|[^a-zA-Z])/.test(url)) {\n console.warn(\"Plasmic: disabled EventSource request for\", url);\n return {\n onerror() {}, onmessage() {}, onopen() {}, close() {}\n };\n } else {\n return new RealEventSource(url, config);\n }\n }\n }\n `,\n }}\n ></script>\n );\n}\n"],"names":["root","globalThis","__PlasmicFetcherRegistry","registerFetcher","fetcher","meta","push","isString","x","ensure","msg","undefined","Error","__PlasmicComponentRegistry","registerComponent","component","__PlasmicContextRegistry","registerGlobalContext","repeatedElement","isPrimary","elt","repeatedElementFn","Array","isArray","map","v","isValidElement","cloneElement","setRepeatedElementFn","__Sub","fn","useForceUpdate","useState","setTick","update","useCallback","tick","tuple","args","DataContext","createContext","applySelector","rawData","selector","curData","split","key","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","__PlasmicHostVersion","rootChangeListeners","PlasmicRootNodeWrapper","val","forEach","f","plasmicRootNode","getPlasmicOrigin","params","URL","location","hash","replace","searchParams","get","renderStudioIntoIframe","script","document","createElement","plasmicOrigin","src","body","appendChild","renderCount","setPlasmicRootNode","node","set","PlasmicCanvasContext","_PlasmicCanvasHost","isFrameAttached","window","parent","isCanvas","match","isLive","shouldRenderStudio","querySelector","forceUpdate","index","indexOf","splice","scriptElt","id","async","onload","__GetlibsReadyResolver","head","append","appDiv","classList","add","ReactDOM","ErrorBoundary","encodeURIComponent","href","style","width","height","border","position","top","left","zIndex","PlasmicCanvasHost","props","enableWebpackHmr","setNode","DisableWebpackHmr","console","log","registerRenderErrorListener","renderErrorListeners","listener","state","getDerivedStateFromError","error","componentDidCatch","render","message","process","env","NODE_ENV","type","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,IAAI,GAAGC,UAAb;AAyCAD,IAAI,CAACE,wBAAL,GAAgC,EAAhC;SAEgBC,gBAAgBC,SAAkBC;AAChDL,EAAAA,IAAI,CAACE,wBAAL,CAA8BI,IAA9B,CAAmC;AAAEF,IAAAA,OAAO,EAAPA,OAAF;AAAWC,IAAAA,IAAI,EAAJA;AAAX,GAAnC;AACD;;AC9CD,SAASE,QAAT,CAAkBC,CAAlB;AACE,SAAO,OAAOA,CAAP,KAAa,QAApB;AACD;;AAID,SAAgBC,OAAUD,GAAyBE;MAAAA;AAAAA,IAAAA,MAAiB;;;AAClE,MAAIF,CAAC,KAAK,IAAN,IAAcA,CAAC,KAAKG,SAAxB,EAAmC;AACjC;AACAD,IAAAA,GAAG,GAAG,CAACH,QAAQ,CAACG,GAAD,CAAR,GAAgBA,GAAhB,GAAsBA,GAAG,EAA1B,KAAiC,EAAvC;AACA,UAAM,IAAIE,KAAJ,0CACkCF,GAAG,UAAQA,GAAR,GAAgB,EADrD,EAAN;AAGD,GAND,MAMO;AACL,WAAOF,CAAP;AACD;AACF;;ACVD,IAAMR,MAAI,GAAGC,UAAb;;AA6UA,IAAID,MAAI,CAACa,0BAAL,IAAmC,IAAvC,EAA6C;AAC3Cb,EAAAA,MAAI,CAACa,0BAAL,GAAkC,EAAlC;AACD;;AAED,SAAwBC,kBACtBC,WACAV;AAEAL,EAAAA,MAAI,CAACa,0BAAL,CAAgCP,IAAhC,CAAqC;AAAES,IAAAA,SAAS,EAATA,SAAF;AAAaV,IAAAA,IAAI,EAAJA;AAAb,GAArC;AACD;;AClVD,IAAML,MAAI,GAAGC,UAAb;;AA8EA,IAAID,MA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yB,YAA7B,EAA2C;AACzC,WAAO,IAAP;AACD;;AACD,SACEpF,aAAA,SAAA;AACEqF,IAAAA,IAAI,EAAC;AACLC,IAAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM;AADiB;GAF3B,CADF;AAsBD;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@plasmicapp/preamble";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { registerFetcher as unstable_registerFetcher } from "./
|
|
3
|
+
import { registerFetcher as unstable_registerFetcher } from "./fetcher";
|
|
4
4
|
import { PlasmicElement } from "./element-types";
|
|
5
5
|
import registerComponent, { ComponentMeta, ComponentRegistration, ComponentTemplates, PrimitiveType, PropType } from "./registerComponent";
|
|
6
6
|
import registerGlobalContext, { GlobalContextMeta, GlobalContextRegistration, PropType as GlobalContextPropType } from "./registerGlobalContext";
|
|
@@ -10,6 +10,7 @@ export { repeatedElement };
|
|
|
10
10
|
export { registerComponent, ComponentMeta, ComponentRegistration, ComponentTemplates, PrimitiveType, PropType, };
|
|
11
11
|
export { registerGlobalContext, GlobalContextMeta, GlobalContextRegistration, GlobalContextPropType, };
|
|
12
12
|
export { PlasmicElement };
|
|
13
|
+
export * from "./data";
|
|
13
14
|
declare global {
|
|
14
15
|
interface Window {
|
|
15
16
|
__PlasmicHostVersion: string;
|
|
@@ -226,6 +226,10 @@ export interface ComponentMeta<P> {
|
|
|
226
226
|
* Registered name of parent component, used for grouping related components.
|
|
227
227
|
*/
|
|
228
228
|
parentComponentName?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Whether the component can be used as an attachment to an element.
|
|
231
|
+
*/
|
|
232
|
+
isAttachment?: boolean;
|
|
229
233
|
}
|
|
230
234
|
export interface ComponentRegistration {
|
|
231
235
|
component: React.ComponentType<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/host",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "plasmic library for app hosting",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"analyze": "size-limit --why"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@plasmicapp/preamble": "0.0.
|
|
32
|
+
"@plasmicapp/preamble": "0.0.43",
|
|
33
33
|
"window-or-global": "^1.0.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n}\n\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;
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n"],"names":[],"mappings":";;;;AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA6U/B,IAAI,IAAI,CAAC,0BAA0B,IAAI,IAAI,EAAE;IAC3C,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;CACtC;SAEuB,iBAAiB,CACvC,SAAY,EACZ,IAA4C;IAE5C,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,SAAS,WAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;AAC5D;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n}\n\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;
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/registerComponent.ts"],"sourcesContent":["import {\n CodeComponentElement,\n CSSProperties,\n PlasmicElement,\n} from \"./element-types\";\n\nconst root = globalThis as any;\n\nexport interface CanvasComponentProps<Data = any> {\n /**\n * This prop is only provided within the canvas of Plasmic Studio.\n * Allows the component to set data to be consumed by the props' controls.\n */\n setControlContextData?: (data: Data) => void;\n}\n\ntype InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;\n\n/**\n * Config option that takes the context (e.g., props) of the component instance\n * to dynamically set its value.\n */\ntype ContextDependentConfig<P, R> = (\n props: P,\n /**\n * `contextData` can be `null` if the prop controls are rendering before\n * the component instance itself (it will re-render once the component\n * calls `setControlContextData`)\n */\n contextData: InferDataType<P> | null\n) => R;\n\ninterface PropTypeBase<P> {\n displayName?: string;\n description?: string;\n hidden?: ContextDependentConfig<P, boolean>;\n}\n\ninterface StringTypeBase<P> extends PropTypeBase<P> {\n defaultValue?: string;\n defaultValueHint?: string;\n}\n\nexport type StringType<P> =\n | \"string\"\n | ((\n | {\n type: \"string\";\n control?: \"default\" | \"large\";\n }\n | {\n type: \"code\";\n lang: \"css\" | \"html\" | \"javascript\" | \"json\";\n }\n ) &\n StringTypeBase<P>);\n\nexport type BooleanType<P> =\n | \"boolean\"\n | ({\n type: \"boolean\";\n defaultValue?: boolean;\n defaultValueHint?: boolean;\n } & PropTypeBase<P>);\n\ninterface NumberTypeBase<P> extends PropTypeBase<P> {\n type: \"number\";\n defaultValue?: number;\n defaultValueHint?: number;\n}\n\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\nexport type JSONLikeType<P> =\n | \"object\"\n | ({\n type: \"object\";\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n defaultValueHint?: any;\n } & PropTypeBase<P>);\n\ninterface ChoiceTypeBase<P> extends PropTypeBase<P> {\n type: \"choice\";\n options:\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 defaultValue?: string;\n defaultValueHint?: string;\n multiSelect?: false;\n }\n | {\n defaultValue?: string[];\n defaultValueHint?: string[];\n multiSelect: true;\n }\n) &\n ChoiceTypeBase<P>;\n\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\nexport type CustomType<P> =\n | CustomControl<P>\n | ({\n type: \"custom\";\n control: CustomControl<P>;\n /**\n * Expects a JSON-compatible value\n */\n defaultValue?: any;\n } & PropTypeBase<P>);\n\ntype SlotType =\n | \"slot\"\n | {\n type: \"slot\";\n /**\n * The unique names of all code components that can be placed in the slot\n */\n allowedComponents?: string[];\n defaultValue?: PlasmicElement | PlasmicElement[];\n /**\n * Whether the \"empty slot\" placeholder should be hidden in the canvas.\n */\n hidePlaceholder?: boolean;\n };\n\ntype ImageUrlType<P> =\n | \"imageUrl\"\n | ({\n type: \"imageUrl\";\n defaultValue?: string;\n defaultValueHint?: string;\n } & PropTypeBase<P>);\n\nexport type PrimitiveType<P = any> = Extract<\n StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>,\n String\n>;\n\ntype ControlTypeBase =\n | {\n editOnly?: false;\n }\n | {\n editOnly: true;\n /**\n * The prop where the values should be mapped to\n */\n uncontrolledProp?: string;\n };\n\nexport type SupportControlled<T> =\n | Extract<T, String | CustomControl<any>>\n | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);\n\nexport type PropType<P> =\n | SupportControlled<\n | StringType<P>\n | BooleanType<P>\n | NumberType<P>\n | JSONLikeType<P>\n | ChoiceType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n | SlotType;\n\ntype RestrictPropType<T, P> = T extends string\n ? SupportControlled<\n | StringType<P>\n | ChoiceType<P>\n | JSONLikeType<P>\n | ImageUrlType<P>\n | CustomType<P>\n >\n : T extends boolean\n ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>>\n : T extends number\n ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>>\n : PropType<P>;\n\ntype DistributedKeyOf<T> = T extends any ? keyof T : never;\n\ninterface ComponentTemplate<P>\n extends Omit<CodeComponentElement<P>, \"type\" | \"name\"> {\n /**\n * A preview picture for the template.\n */\n previewImg?: string;\n}\n\nexport interface ComponentTemplates<P> {\n [name: string]: ComponentTemplate<P>;\n}\n\nexport interface ComponentMeta<P> {\n /**\n * Any unique string name used to identify that component. Each component\n * should be registered with a different `meta.name`, even if they have the\n * same name in the code.\n */\n name: string;\n /**\n * The name to be displayed for the component in Studio. Optional: if not\n * specified, `meta.name` is used.\n */\n displayName?: string;\n /**\n * The description of the component to be shown in Studio.\n */\n description?: string;\n /**\n * The javascript name to be used when generating code. Optional: if not\n * provided, `meta.name` is used.\n */\n importName?: string;\n /**\n * An object describing the component properties to be used in Studio.\n * For each `prop`, there should be an entry `meta.props[prop]` describing\n * its type.\n */\n props: { [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P> } & {\n [prop: string]: PropType<P>;\n };\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n */\n importPath: string;\n /**\n * Whether the component is the default export from that path. Optional: if\n * not specified, it's considered `false`.\n */\n isDefaultExport?: boolean;\n /**\n * The prop that expects the CSS classes with styles to be applied to the\n * component. Optional: if not specified, Plasmic will expect it to be\n * `className`. Notice that if the component does not accept CSS classes, the\n * component will not be able to receive styles from the Studio.\n */\n classNameProp?: string;\n /**\n * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`\n * to interact with components, so it's not used in the generated code.\n * Optional: If not provided, the usual `ref` is used.\n */\n refProp?: string;\n /**\n * Default styles to start with when instantiating the component in Plasmic.\n */\n defaultStyles?: CSSProperties;\n /**\n * Component templates to start with on Plasmic.\n */\n templates?: ComponentTemplates<P>;\n /**\n * Registered name of parent component, used for grouping related components.\n */\n parentComponentName?: string;\n /**\n * Whether the component can be used as an attachment to an element.\n */\n isAttachment?: boolean;\n}\n\nexport interface ComponentRegistration {\n component: React.ComponentType<any>;\n meta: ComponentMeta<any>;\n}\n\ndeclare global {\n interface Window {\n __PlasmicComponentRegistry: ComponentRegistration[];\n }\n}\n\nif (root.__PlasmicComponentRegistry == null) {\n root.__PlasmicComponentRegistry = [];\n}\n\nexport default function registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n root.__PlasmicComponentRegistry.push({ component, meta });\n}\n"],"names":[],"mappings":"AAMA,IAAM,IAAI,GAAG,UAAiB,CAAC;AA6U/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;;;;"}
|
|
@@ -226,6 +226,10 @@ export interface ComponentMeta<P> {
|
|
|
226
226
|
* Registered name of parent component, used for grouping related components.
|
|
227
227
|
*/
|
|
228
228
|
parentComponentName?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Whether the component can be used as an attachment to an element.
|
|
231
|
+
*/
|
|
232
|
+
isAttachment?: boolean;
|
|
229
233
|
}
|
|
230
234
|
export interface ComponentRegistration {
|
|
231
235
|
component: React.ComponentType<any>;
|