@plasmicapp/host 1.0.166 → 1.0.169

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.
Files changed (55) hide show
  1. package/dist/data.d.ts +2 -1
  2. package/dist/exports.d.ts +4 -3
  3. package/dist/host.esm.js +52 -34
  4. package/dist/host.esm.js.map +1 -1
  5. package/dist/index.cjs.js +52 -33
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/prop-types.d.ts +2 -1
  8. package/dist/registerFunction.d.ts +105 -0
  9. package/dist/version.d.ts +1 -1
  10. package/package.json +6 -4
  11. package/registerComponent/dist/data.d.ts +2 -1
  12. package/registerComponent/dist/exports.d.ts +4 -3
  13. package/registerComponent/dist/prop-types.d.ts +2 -1
  14. package/registerComponent/dist/registerFunction.d.ts +105 -0
  15. package/registerComponent/dist/version.d.ts +1 -1
  16. package/registerFunction/dist/canvas-host.d.ts +41 -0
  17. package/registerFunction/dist/common.d.ts +1 -0
  18. package/registerFunction/dist/data.d.ts +49 -0
  19. package/registerFunction/dist/element-types.d.ts +115 -0
  20. package/registerFunction/dist/exports.d.ts +13 -0
  21. package/registerFunction/dist/fetcher.d.ts +40 -0
  22. package/registerFunction/dist/global-actions.d.ts +9 -0
  23. package/registerFunction/dist/index.cjs.js +23 -0
  24. package/registerFunction/dist/index.cjs.js.map +1 -0
  25. package/registerFunction/dist/index.d.ts +1 -0
  26. package/registerFunction/dist/index.esm.js +19 -0
  27. package/registerFunction/dist/index.esm.js.map +1 -0
  28. package/registerFunction/dist/lang-utils.d.ts +3 -0
  29. package/registerFunction/dist/link.d.ts +7 -0
  30. package/registerFunction/dist/prop-types.d.ts +426 -0
  31. package/registerFunction/dist/registerComponent.d.ts +272 -0
  32. package/registerFunction/dist/registerFunction.d.ts +105 -0
  33. package/registerFunction/dist/registerGlobalContext.d.ts +76 -0
  34. package/registerFunction/dist/registerToken.d.ts +34 -0
  35. package/registerFunction/dist/registerTrait.d.ts +20 -0
  36. package/registerFunction/dist/repeatedElement.d.ts +15 -0
  37. package/registerFunction/dist/type-utils.d.ts +6 -0
  38. package/registerFunction/dist/useForceUpdate.d.ts +1 -0
  39. package/registerFunction/dist/version.d.ts +1 -0
  40. package/registerFunction/package.json +5 -0
  41. package/registerGlobalContext/dist/data.d.ts +2 -1
  42. package/registerGlobalContext/dist/exports.d.ts +4 -3
  43. package/registerGlobalContext/dist/prop-types.d.ts +2 -1
  44. package/registerGlobalContext/dist/registerFunction.d.ts +105 -0
  45. package/registerGlobalContext/dist/version.d.ts +1 -1
  46. package/registerToken/dist/data.d.ts +2 -1
  47. package/registerToken/dist/exports.d.ts +4 -3
  48. package/registerToken/dist/prop-types.d.ts +2 -1
  49. package/registerToken/dist/registerFunction.d.ts +105 -0
  50. package/registerToken/dist/version.d.ts +1 -1
  51. package/registerTrait/dist/data.d.ts +2 -1
  52. package/registerTrait/dist/exports.d.ts +4 -3
  53. package/registerTrait/dist/prop-types.d.ts +2 -1
  54. package/registerTrait/dist/registerFunction.d.ts +105 -0
  55. package/registerTrait/dist/version.d.ts +1 -1
@@ -0,0 +1,105 @@
1
+ export type StringType<T extends string = string> = "string" | `'${T}'`;
2
+ export type NumberType<T extends number = number> = "number" | `${number extends T ? number : T}`;
3
+ export type BooleanType<T extends boolean = boolean> = "boolean" | `${boolean extends T ? boolean : T}`;
4
+ export type NullType = "null";
5
+ export type UndefinedType = "undefined";
6
+ export type ArrayType = "array";
7
+ export type ObjectType = "object";
8
+ export type AnyType = "any";
9
+ export type VoidType = "void";
10
+ export type RestrictedType<T> = T extends string ? StringType<T> : T extends number ? NumberType<T> : T extends boolean ? BooleanType<T> : T extends null ? NullType : T extends undefined ? UndefinedType : T extends Array<any> ? ArrayType : T extends object ? ObjectType : AnyType;
11
+ export type OrType<T> = RestrictedType<T>[];
12
+ export type ParamType<T> = AnyType | RestrictedType<T> | OrType<T>;
13
+ export interface BaseParam<T> {
14
+ name: string;
15
+ type?: ParamType<T>;
16
+ description?: string;
17
+ isOptional?: boolean;
18
+ isRestParam?: boolean;
19
+ }
20
+ export interface RequiredParam<T> extends BaseParam<T> {
21
+ isOptional?: false;
22
+ isRestParameter?: false;
23
+ }
24
+ export interface OptionalParam<T> extends BaseParam<T | undefined> {
25
+ isRestParameter?: false;
26
+ }
27
+ export interface RestParam<T> extends BaseParam<T> {
28
+ isOptional?: false;
29
+ isRestParameter: true;
30
+ }
31
+ type RequiredParams<T extends any[], U extends any[] = []> = Partial<T> extends T ? U : T extends [infer F, ...infer R] ? RequiredParams<R, [...U, F]> : U;
32
+ type OptionalParams<T extends any[]> = T extends [
33
+ ...RequiredParams<T>,
34
+ ...infer R
35
+ ] ? [...R] : [];
36
+ type HandleRequiredParams<P extends any[]> = P extends [infer H, ...infer T] ? [string | RequiredParam<H>, ...HandleRequiredParams<T>] : [];
37
+ type HandleOptionalParams<P extends any[]> = P extends [infer H, ...infer T] ? [] | [string | OptionalParam<H | undefined>, ...HandleOptionalParams<T>] : P extends [] ? [] : P extends Array<infer T> ? [] | [RestParam<T[]>] : [];
38
+ export type HandleParams<P extends any[]> = [
39
+ ...HandleRequiredParams<RequiredParams<P>>,
40
+ ...HandleOptionalParams<Required<OptionalParams<P>>>
41
+ ];
42
+ export type HandleReturnType<T> = VoidType | ParamType<T>;
43
+ export interface CustomFunctionMeta<F extends (...args: any[]) => any> {
44
+ /**
45
+ * The javascript name of the function. Notice it must be unique across all
46
+ * other functions and function namespaces. If two functions have the same
47
+ * name, they should be registered with different `meta.namespace`.
48
+ */
49
+ name: string;
50
+ /**
51
+ * A namespace for organizing groups of functions. It's also used to handle
52
+ * function name collisions. If a function has a namespace, it will be used
53
+ * whenever accessing the function.
54
+ */
55
+ namespace?: string;
56
+ /**
57
+ * Documentation for the registered function.
58
+ */
59
+ description?: string;
60
+ /**
61
+ * An array containing the list of parameters names the function takes.
62
+ * Optionally they can also be registered with the expected param types.
63
+ */
64
+ params?: HandleParams<Parameters<F>>;
65
+ /**
66
+ * Return value information.
67
+ */
68
+ returnValue?: {
69
+ /**
70
+ * The function return type.
71
+ */
72
+ type?: HandleReturnType<ReturnType<F>>;
73
+ /**
74
+ * The function return value description.
75
+ */
76
+ description?: string;
77
+ };
78
+ /**
79
+ * Typescript function declaration. If specified, it ignores the types
80
+ * provided by `params` and `returnValue`.
81
+ */
82
+ typescriptDeclaration?: string;
83
+ /**
84
+ * The path to be used when importing the function in the generated code.
85
+ * It can be the name of the package that contains the function, or the path
86
+ * to the file in the project (relative to the root directory).
87
+ */
88
+ importPath: string;
89
+ /**
90
+ * Whether the function is the default export from that path. Optional: if
91
+ * not specified, it's considered `false`.
92
+ */
93
+ isDefaultExport?: boolean;
94
+ }
95
+ export interface CustomFunctionRegistration {
96
+ function: (...args: any[]) => any;
97
+ meta: CustomFunctionMeta<any>;
98
+ }
99
+ declare global {
100
+ interface Window {
101
+ __PlasmicFunctionsRegistry: CustomFunctionRegistration[];
102
+ }
103
+ }
104
+ export default function unstable_registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
105
+ export {};
@@ -1 +1 @@
1
- export declare const hostVersion = "1.0.166";
1
+ export declare const hostVersion = "1.0.169";