@plasmicapp/host 1.0.28 → 1.0.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/host",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "plasmic library for app hosting",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "analyze": "size-limit --why"
31
31
  },
32
32
  "dependencies": {
33
- "@plasmicapp/preamble": "0.0.59",
33
+ "@plasmicapp/preamble": "0.0.60",
34
34
  "window-or-global": "^1.0.1"
35
35
  },
36
36
  "devDependencies": {
@@ -0,0 +1,61 @@
1
+ /// <reference types="react" />
2
+ import { BooleanType, ChoiceType, CustomType, JSONLikeType, NumberType, StringType, SupportControlled } from "./registerComponent";
3
+ export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | CustomType<P>>;
4
+ declare type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
5
+ declare type DistributedKeyOf<T> = T extends any ? keyof T : never;
6
+ export interface GlobalContextMeta<P> {
7
+ /**
8
+ * Any unique string name used to identify that context. Each context
9
+ * should be registered with a different `meta.name`, even if they have the
10
+ * same name in the code.
11
+ */
12
+ name: string;
13
+ /**
14
+ * The name to be displayed for the context in Studio. Optional: if not
15
+ * specified, `meta.name` is used.
16
+ */
17
+ displayName?: string;
18
+ /**
19
+ * The javascript name to be used when generating code. Optional: if not
20
+ * provided, `meta.name` is used.
21
+ */
22
+ importName?: string;
23
+ /**
24
+ * An object describing the context properties to be used in Studio.
25
+ * For each `prop`, there should be an entry `meta.props[prop]` describing
26
+ * its type.
27
+ */
28
+ props: {
29
+ [prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P>;
30
+ } & {
31
+ [prop: string]: PropType<P>;
32
+ };
33
+ /**
34
+ * The path to be used when importing the context in the generated code.
35
+ * It can be the name of the package that contains the context, or the path
36
+ * to the file in the project (relative to the root directory).
37
+ */
38
+ importPath: string;
39
+ /**
40
+ * Whether the context is the default export from that path. Optional: if
41
+ * not specified, it's considered `false`.
42
+ */
43
+ isDefaultExport?: boolean;
44
+ /**
45
+ * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`
46
+ * to interact with components, so it's not used in the generated code.
47
+ * Optional: If not provided, the usual `ref` is used.
48
+ */
49
+ refProp?: string;
50
+ }
51
+ export interface GlobalContextRegistration {
52
+ component: React.ComponentType<any>;
53
+ meta: GlobalContextMeta<any>;
54
+ }
55
+ declare global {
56
+ interface Window {
57
+ __PlasmicContextRegistry: GlobalContextRegistration[];
58
+ }
59
+ }
60
+ export default function registerGlobalContext<T extends React.ComponentType<any>>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
61
+ export {};