@webstudio-is/react-sdk 0.99.1-e132cba.0 → 0.100.1-c4ae8b2.0
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/lib/index.js +391 -409
- package/lib/types/component-generator.d.ts +324 -0
- package/lib/types/component-generator.test.d.ts +1 -0
- package/lib/types/components/component-meta.d.ts +5 -5
- package/lib/types/context.d.ts +2 -5
- package/lib/types/embed-template.d.ts +1 -1
- package/lib/types/expression.d.ts +106 -11
- package/lib/types/generator.d.ts +2 -4
- package/lib/types/index.d.ts +6 -6
- package/lib/types/tree/create-elements-tree.d.ts +3 -5
- package/package.json +8 -7
- package/lib/types/component-renderer.d.ts +0 -11
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import type { Instances, Instance, Props, Scope, DataSources } from "@webstudio-is/sdk";
|
|
2
|
+
import type { IndexesWithinAncestors } from "./instance-utils";
|
|
3
|
+
export declare const generateJsxElement: ({ scope, instance, props, dataSources, indexesWithinAncestors, children, }: {
|
|
4
|
+
scope: Scope;
|
|
5
|
+
instance: Instance;
|
|
6
|
+
props: Map<string, {
|
|
7
|
+
value: number;
|
|
8
|
+
type: "number";
|
|
9
|
+
name: string;
|
|
10
|
+
id: string;
|
|
11
|
+
instanceId: string;
|
|
12
|
+
required?: boolean | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
value: string;
|
|
15
|
+
type: "string";
|
|
16
|
+
name: string;
|
|
17
|
+
id: string;
|
|
18
|
+
instanceId: string;
|
|
19
|
+
required?: boolean | undefined;
|
|
20
|
+
} | {
|
|
21
|
+
value: boolean;
|
|
22
|
+
type: "boolean";
|
|
23
|
+
name: string;
|
|
24
|
+
id: string;
|
|
25
|
+
instanceId: string;
|
|
26
|
+
required?: boolean | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
value: string;
|
|
29
|
+
type: "asset";
|
|
30
|
+
name: string;
|
|
31
|
+
id: string;
|
|
32
|
+
instanceId: string;
|
|
33
|
+
required?: boolean | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
value: (string | {
|
|
36
|
+
instanceId: string;
|
|
37
|
+
pageId: string;
|
|
38
|
+
}) & (string | {
|
|
39
|
+
instanceId: string;
|
|
40
|
+
pageId: string;
|
|
41
|
+
} | undefined);
|
|
42
|
+
type: "page";
|
|
43
|
+
name: string;
|
|
44
|
+
id: string;
|
|
45
|
+
instanceId: string;
|
|
46
|
+
required?: boolean | undefined;
|
|
47
|
+
} | {
|
|
48
|
+
value: string[];
|
|
49
|
+
type: "string[]";
|
|
50
|
+
name: string;
|
|
51
|
+
id: string;
|
|
52
|
+
instanceId: string;
|
|
53
|
+
required?: boolean | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
value: string;
|
|
56
|
+
type: "dataSource";
|
|
57
|
+
name: string;
|
|
58
|
+
id: string;
|
|
59
|
+
instanceId: string;
|
|
60
|
+
required?: boolean | undefined;
|
|
61
|
+
} | {
|
|
62
|
+
value: {
|
|
63
|
+
code: string;
|
|
64
|
+
type: "execute";
|
|
65
|
+
args: string[];
|
|
66
|
+
}[];
|
|
67
|
+
type: "action";
|
|
68
|
+
name: string;
|
|
69
|
+
id: string;
|
|
70
|
+
instanceId: string;
|
|
71
|
+
required?: boolean | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
dataSources: Map<string, {
|
|
74
|
+
value: {
|
|
75
|
+
value: number;
|
|
76
|
+
type: "number";
|
|
77
|
+
} | {
|
|
78
|
+
value: string;
|
|
79
|
+
type: "string";
|
|
80
|
+
} | {
|
|
81
|
+
value: boolean;
|
|
82
|
+
type: "boolean";
|
|
83
|
+
} | {
|
|
84
|
+
value: string[];
|
|
85
|
+
type: "string[]";
|
|
86
|
+
};
|
|
87
|
+
type: "variable";
|
|
88
|
+
name: string;
|
|
89
|
+
id: string;
|
|
90
|
+
scopeInstanceId?: string | undefined;
|
|
91
|
+
} | {
|
|
92
|
+
code: string;
|
|
93
|
+
type: "expression";
|
|
94
|
+
name: string;
|
|
95
|
+
id: string;
|
|
96
|
+
scopeInstanceId?: string | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
indexesWithinAncestors: IndexesWithinAncestors;
|
|
99
|
+
children: string;
|
|
100
|
+
}) => string;
|
|
101
|
+
/**
|
|
102
|
+
* Jsx element and children are generated separately to be able
|
|
103
|
+
* to inject some scripts into Body if necessary
|
|
104
|
+
*/
|
|
105
|
+
export declare const generateJsxChildren: ({ scope, children, instances, props, dataSources, indexesWithinAncestors, }: {
|
|
106
|
+
scope: Scope;
|
|
107
|
+
children: Instance["children"];
|
|
108
|
+
instances: Map<string, {
|
|
109
|
+
type: "instance";
|
|
110
|
+
id: string;
|
|
111
|
+
component: string;
|
|
112
|
+
children: ({
|
|
113
|
+
value: string;
|
|
114
|
+
type: "text";
|
|
115
|
+
} | {
|
|
116
|
+
value: string;
|
|
117
|
+
type: "id";
|
|
118
|
+
})[];
|
|
119
|
+
label?: string | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
props: Map<string, {
|
|
122
|
+
value: number;
|
|
123
|
+
type: "number";
|
|
124
|
+
name: string;
|
|
125
|
+
id: string;
|
|
126
|
+
instanceId: string;
|
|
127
|
+
required?: boolean | undefined;
|
|
128
|
+
} | {
|
|
129
|
+
value: string;
|
|
130
|
+
type: "string";
|
|
131
|
+
name: string;
|
|
132
|
+
id: string;
|
|
133
|
+
instanceId: string;
|
|
134
|
+
required?: boolean | undefined;
|
|
135
|
+
} | {
|
|
136
|
+
value: boolean;
|
|
137
|
+
type: "boolean";
|
|
138
|
+
name: string;
|
|
139
|
+
id: string;
|
|
140
|
+
instanceId: string;
|
|
141
|
+
required?: boolean | undefined;
|
|
142
|
+
} | {
|
|
143
|
+
value: string;
|
|
144
|
+
type: "asset";
|
|
145
|
+
name: string;
|
|
146
|
+
id: string;
|
|
147
|
+
instanceId: string;
|
|
148
|
+
required?: boolean | undefined;
|
|
149
|
+
} | {
|
|
150
|
+
value: (string | {
|
|
151
|
+
instanceId: string;
|
|
152
|
+
pageId: string;
|
|
153
|
+
}) & (string | {
|
|
154
|
+
instanceId: string;
|
|
155
|
+
pageId: string;
|
|
156
|
+
} | undefined);
|
|
157
|
+
type: "page";
|
|
158
|
+
name: string;
|
|
159
|
+
id: string;
|
|
160
|
+
instanceId: string;
|
|
161
|
+
required?: boolean | undefined;
|
|
162
|
+
} | {
|
|
163
|
+
value: string[];
|
|
164
|
+
type: "string[]";
|
|
165
|
+
name: string;
|
|
166
|
+
id: string;
|
|
167
|
+
instanceId: string;
|
|
168
|
+
required?: boolean | undefined;
|
|
169
|
+
} | {
|
|
170
|
+
value: string;
|
|
171
|
+
type: "dataSource";
|
|
172
|
+
name: string;
|
|
173
|
+
id: string;
|
|
174
|
+
instanceId: string;
|
|
175
|
+
required?: boolean | undefined;
|
|
176
|
+
} | {
|
|
177
|
+
value: {
|
|
178
|
+
code: string;
|
|
179
|
+
type: "execute";
|
|
180
|
+
args: string[];
|
|
181
|
+
}[];
|
|
182
|
+
type: "action";
|
|
183
|
+
name: string;
|
|
184
|
+
id: string;
|
|
185
|
+
instanceId: string;
|
|
186
|
+
required?: boolean | undefined;
|
|
187
|
+
}>;
|
|
188
|
+
dataSources: Map<string, {
|
|
189
|
+
value: {
|
|
190
|
+
value: number;
|
|
191
|
+
type: "number";
|
|
192
|
+
} | {
|
|
193
|
+
value: string;
|
|
194
|
+
type: "string";
|
|
195
|
+
} | {
|
|
196
|
+
value: boolean;
|
|
197
|
+
type: "boolean";
|
|
198
|
+
} | {
|
|
199
|
+
value: string[];
|
|
200
|
+
type: "string[]";
|
|
201
|
+
};
|
|
202
|
+
type: "variable";
|
|
203
|
+
name: string;
|
|
204
|
+
id: string;
|
|
205
|
+
scopeInstanceId?: string | undefined;
|
|
206
|
+
} | {
|
|
207
|
+
code: string;
|
|
208
|
+
type: "expression";
|
|
209
|
+
name: string;
|
|
210
|
+
id: string;
|
|
211
|
+
scopeInstanceId?: string | undefined;
|
|
212
|
+
}>;
|
|
213
|
+
indexesWithinAncestors: IndexesWithinAncestors;
|
|
214
|
+
}) => string;
|
|
215
|
+
export declare const generatePageComponent: ({ scope, rootInstanceId, instances, props, dataSources, indexesWithinAncestors, }: {
|
|
216
|
+
scope: Scope;
|
|
217
|
+
rootInstanceId: Instance["id"];
|
|
218
|
+
instances: Map<string, {
|
|
219
|
+
type: "instance";
|
|
220
|
+
id: string;
|
|
221
|
+
component: string;
|
|
222
|
+
children: ({
|
|
223
|
+
value: string;
|
|
224
|
+
type: "text";
|
|
225
|
+
} | {
|
|
226
|
+
value: string;
|
|
227
|
+
type: "id";
|
|
228
|
+
})[];
|
|
229
|
+
label?: string | undefined;
|
|
230
|
+
}>;
|
|
231
|
+
props: Map<string, {
|
|
232
|
+
value: number;
|
|
233
|
+
type: "number";
|
|
234
|
+
name: string;
|
|
235
|
+
id: string;
|
|
236
|
+
instanceId: string;
|
|
237
|
+
required?: boolean | undefined;
|
|
238
|
+
} | {
|
|
239
|
+
value: string;
|
|
240
|
+
type: "string";
|
|
241
|
+
name: string;
|
|
242
|
+
id: string;
|
|
243
|
+
instanceId: string;
|
|
244
|
+
required?: boolean | undefined;
|
|
245
|
+
} | {
|
|
246
|
+
value: boolean;
|
|
247
|
+
type: "boolean";
|
|
248
|
+
name: string;
|
|
249
|
+
id: string;
|
|
250
|
+
instanceId: string;
|
|
251
|
+
required?: boolean | undefined;
|
|
252
|
+
} | {
|
|
253
|
+
value: string;
|
|
254
|
+
type: "asset";
|
|
255
|
+
name: string;
|
|
256
|
+
id: string;
|
|
257
|
+
instanceId: string;
|
|
258
|
+
required?: boolean | undefined;
|
|
259
|
+
} | {
|
|
260
|
+
value: (string | {
|
|
261
|
+
instanceId: string;
|
|
262
|
+
pageId: string;
|
|
263
|
+
}) & (string | {
|
|
264
|
+
instanceId: string;
|
|
265
|
+
pageId: string;
|
|
266
|
+
} | undefined);
|
|
267
|
+
type: "page";
|
|
268
|
+
name: string;
|
|
269
|
+
id: string;
|
|
270
|
+
instanceId: string;
|
|
271
|
+
required?: boolean | undefined;
|
|
272
|
+
} | {
|
|
273
|
+
value: string[];
|
|
274
|
+
type: "string[]";
|
|
275
|
+
name: string;
|
|
276
|
+
id: string;
|
|
277
|
+
instanceId: string;
|
|
278
|
+
required?: boolean | undefined;
|
|
279
|
+
} | {
|
|
280
|
+
value: string;
|
|
281
|
+
type: "dataSource";
|
|
282
|
+
name: string;
|
|
283
|
+
id: string;
|
|
284
|
+
instanceId: string;
|
|
285
|
+
required?: boolean | undefined;
|
|
286
|
+
} | {
|
|
287
|
+
value: {
|
|
288
|
+
code: string;
|
|
289
|
+
type: "execute";
|
|
290
|
+
args: string[];
|
|
291
|
+
}[];
|
|
292
|
+
type: "action";
|
|
293
|
+
name: string;
|
|
294
|
+
id: string;
|
|
295
|
+
instanceId: string;
|
|
296
|
+
required?: boolean | undefined;
|
|
297
|
+
}>;
|
|
298
|
+
dataSources: Map<string, {
|
|
299
|
+
value: {
|
|
300
|
+
value: number;
|
|
301
|
+
type: "number";
|
|
302
|
+
} | {
|
|
303
|
+
value: string;
|
|
304
|
+
type: "string";
|
|
305
|
+
} | {
|
|
306
|
+
value: boolean;
|
|
307
|
+
type: "boolean";
|
|
308
|
+
} | {
|
|
309
|
+
value: string[];
|
|
310
|
+
type: "string[]";
|
|
311
|
+
};
|
|
312
|
+
type: "variable";
|
|
313
|
+
name: string;
|
|
314
|
+
id: string;
|
|
315
|
+
scopeInstanceId?: string | undefined;
|
|
316
|
+
} | {
|
|
317
|
+
code: string;
|
|
318
|
+
type: "expression";
|
|
319
|
+
name: string;
|
|
320
|
+
id: string;
|
|
321
|
+
scopeInstanceId?: string | undefined;
|
|
322
|
+
}>;
|
|
323
|
+
indexesWithinAncestors: IndexesWithinAncestors;
|
|
324
|
+
}) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -670,7 +670,7 @@ export declare const ComponentState: z.ZodObject<{
|
|
|
670
670
|
}>;
|
|
671
671
|
export type ComponentState = z.infer<typeof ComponentState>;
|
|
672
672
|
export declare const defaultStates: ComponentState[];
|
|
673
|
-
declare const WsComponentMeta: z.ZodObject<{
|
|
673
|
+
export declare const WsComponentMeta: z.ZodObject<{
|
|
674
674
|
category: z.ZodOptional<z.ZodEnum<["general", "text", "media", "forms", "radix", "hidden"]>>;
|
|
675
675
|
type: z.ZodEnum<["container", "control", "embed", "rich-text-child"]>;
|
|
676
676
|
requiredAncestors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -681,7 +681,7 @@ declare const WsComponentMeta: z.ZodObject<{
|
|
|
681
681
|
label: z.ZodOptional<z.ZodString>;
|
|
682
682
|
description: z.ZodOptional<z.ZodString>;
|
|
683
683
|
icon: z.ZodString;
|
|
684
|
-
presetStyle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<{
|
|
684
|
+
presetStyle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodType<{
|
|
685
685
|
value: {
|
|
686
686
|
value: number;
|
|
687
687
|
type: "unit";
|
|
@@ -1105,7 +1105,7 @@ declare const WsComponentMeta: z.ZodObject<{
|
|
|
1105
1105
|
};
|
|
1106
1106
|
state?: string | undefined;
|
|
1107
1107
|
property: import("@webstudio-is/css-engine").StyleProperty;
|
|
1108
|
-
}>>>;
|
|
1108
|
+
}>, "many">>>;
|
|
1109
1109
|
presetTokens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1110
1110
|
variant: z.ZodOptional<z.ZodString>;
|
|
1111
1111
|
styles: z.ZodArray<z.ZodType<{
|
|
@@ -2211,7 +2211,7 @@ declare const WsComponentMeta: z.ZodObject<{
|
|
|
2211
2211
|
};
|
|
2212
2212
|
state?: string | undefined;
|
|
2213
2213
|
property: import("@webstudio-is/css-engine").StyleProperty;
|
|
2214
|
-
}> | undefined;
|
|
2214
|
+
}[]> | undefined;
|
|
2215
2215
|
presetTokens?: Record<string, {
|
|
2216
2216
|
styles: {
|
|
2217
2217
|
value: {
|
|
@@ -2661,7 +2661,7 @@ declare const WsComponentMeta: z.ZodObject<{
|
|
|
2661
2661
|
};
|
|
2662
2662
|
state?: string | undefined;
|
|
2663
2663
|
property: import("@webstudio-is/css-engine").StyleProperty;
|
|
2664
|
-
}> | undefined;
|
|
2664
|
+
}[]> | undefined;
|
|
2665
2665
|
presetTokens?: Record<string, {
|
|
2666
2666
|
styles: {
|
|
2667
2667
|
value: {
|
package/lib/types/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type ReadableAtom } from "nanostores";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Assets } from "@webstudio-is/sdk";
|
|
4
4
|
import type { Pages, PropsByInstanceId } from "./props";
|
|
5
5
|
import type { IndexesWithinAncestors } from "./instance-utils";
|
|
6
6
|
import type { ImageLoader } from "@webstudio-is/image";
|
|
@@ -30,14 +30,11 @@ export type Params = {
|
|
|
30
30
|
*/
|
|
31
31
|
assetBaseUrl: string;
|
|
32
32
|
};
|
|
33
|
-
export type DataSourceValues = Map<DataSource["id"], unknown>;
|
|
34
33
|
export declare const ReactSdkContext: import("react").Context<Params & {
|
|
35
34
|
imageLoader: ImageLoader;
|
|
36
35
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
|
37
36
|
assetsStore: ReadableAtom<Assets>;
|
|
38
37
|
pagesStore: ReadableAtom<Pages>;
|
|
39
|
-
|
|
40
|
-
executeEffectfulExpression: (expression: string, args: DataSourceValues, values: DataSourceValues) => DataSourceValues;
|
|
41
|
-
setDataSourceValues: (newValues: DataSourceValues) => void;
|
|
38
|
+
dataSourcesLogicStore: ReadableAtom<Map<string, unknown>>;
|
|
42
39
|
indexesWithinAncestors: IndexesWithinAncestors;
|
|
43
40
|
}>;
|
|
@@ -2196,7 +2196,7 @@ export type WsEmbedTemplate = z.infer<typeof WsEmbedTemplate>;
|
|
|
2196
2196
|
export declare const generateDataFromEmbedTemplate: (treeTemplate: ({
|
|
2197
2197
|
value: string;
|
|
2198
2198
|
type: "text";
|
|
2199
|
-
} | EmbedTemplateInstance)[], metas: Map<Instance["component"], WsComponentMeta>, defaultBreakpointId: Breakpoint["id"]) => {
|
|
2199
|
+
} | EmbedTemplateInstance)[], metas: Map<Instance["component"], WsComponentMeta>, defaultBreakpointId: Breakpoint["id"], generateId?: () => string) => {
|
|
2200
2200
|
children: ({
|
|
2201
2201
|
value: string;
|
|
2202
2202
|
type: "text";
|
|
@@ -1,20 +1,115 @@
|
|
|
1
|
+
import type { DataSources, Props, Scope } from "@webstudio-is/sdk";
|
|
1
2
|
type TransformIdentifier = (id: string, assignee: boolean) => string;
|
|
2
3
|
export declare const validateExpression: (code: string, options?: {
|
|
3
4
|
effectful?: boolean;
|
|
4
5
|
transformIdentifier?: TransformIdentifier;
|
|
5
6
|
}) => string;
|
|
6
|
-
/**
|
|
7
|
-
* Generates a function body expecting map as _variables argument
|
|
8
|
-
* and outputing map of results
|
|
9
|
-
*/
|
|
10
|
-
export declare const generateComputingExpressions: (expressions: Map<string, string>, allowedVariables: Set<string>) => string;
|
|
11
|
-
export declare const executeComputingExpressions: (expressions: Map<string, string>, variables: Map<string, unknown>) => Map<string, unknown>;
|
|
12
|
-
export declare const generateEffectfulExpression: (code: string, args: Set<string>, allowedVariables: Set<string>) => string;
|
|
13
|
-
export declare const executeEffectfulExpression: (code: string, args: Map<string, unknown>, variables: Map<string, unknown>) => Map<string, unknown>;
|
|
14
7
|
export declare const computeExpressionsDependencies: (expressions: Map<string, string>) => Map<string, Set<string>>;
|
|
15
|
-
type Values = Map<string, unknown>;
|
|
16
8
|
export declare const encodeDataSourceVariable: (id: string) => string;
|
|
17
|
-
export declare const encodeVariablesMap: (values: Values) => Values;
|
|
18
9
|
export declare const decodeDataSourceVariable: (name: string) => string | undefined;
|
|
19
|
-
|
|
10
|
+
type VariableName = string;
|
|
11
|
+
export declare const generateDataSources: ({ scope, typed, dataSources, props, }: {
|
|
12
|
+
scope: Scope;
|
|
13
|
+
typed?: boolean | undefined;
|
|
14
|
+
dataSources: Map<string, {
|
|
15
|
+
value: {
|
|
16
|
+
value: number;
|
|
17
|
+
type: "number";
|
|
18
|
+
} | {
|
|
19
|
+
value: string;
|
|
20
|
+
type: "string";
|
|
21
|
+
} | {
|
|
22
|
+
value: boolean;
|
|
23
|
+
type: "boolean";
|
|
24
|
+
} | {
|
|
25
|
+
value: string[];
|
|
26
|
+
type: "string[]";
|
|
27
|
+
};
|
|
28
|
+
type: "variable";
|
|
29
|
+
name: string;
|
|
30
|
+
id: string;
|
|
31
|
+
scopeInstanceId?: string | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
code: string;
|
|
34
|
+
type: "expression";
|
|
35
|
+
name: string;
|
|
36
|
+
id: string;
|
|
37
|
+
scopeInstanceId?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
props: Map<string, {
|
|
40
|
+
value: number;
|
|
41
|
+
type: "number";
|
|
42
|
+
name: string;
|
|
43
|
+
id: string;
|
|
44
|
+
instanceId: string;
|
|
45
|
+
required?: boolean | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
value: string;
|
|
48
|
+
type: "string";
|
|
49
|
+
name: string;
|
|
50
|
+
id: string;
|
|
51
|
+
instanceId: string;
|
|
52
|
+
required?: boolean | undefined;
|
|
53
|
+
} | {
|
|
54
|
+
value: boolean;
|
|
55
|
+
type: "boolean";
|
|
56
|
+
name: string;
|
|
57
|
+
id: string;
|
|
58
|
+
instanceId: string;
|
|
59
|
+
required?: boolean | undefined;
|
|
60
|
+
} | {
|
|
61
|
+
value: string;
|
|
62
|
+
type: "asset";
|
|
63
|
+
name: string;
|
|
64
|
+
id: string;
|
|
65
|
+
instanceId: string;
|
|
66
|
+
required?: boolean | undefined;
|
|
67
|
+
} | {
|
|
68
|
+
value: (string | {
|
|
69
|
+
instanceId: string;
|
|
70
|
+
pageId: string;
|
|
71
|
+
}) & (string | {
|
|
72
|
+
instanceId: string;
|
|
73
|
+
pageId: string;
|
|
74
|
+
} | undefined);
|
|
75
|
+
type: "page";
|
|
76
|
+
name: string;
|
|
77
|
+
id: string;
|
|
78
|
+
instanceId: string;
|
|
79
|
+
required?: boolean | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
value: string[];
|
|
82
|
+
type: "string[]";
|
|
83
|
+
name: string;
|
|
84
|
+
id: string;
|
|
85
|
+
instanceId: string;
|
|
86
|
+
required?: boolean | undefined;
|
|
87
|
+
} | {
|
|
88
|
+
value: string;
|
|
89
|
+
type: "dataSource";
|
|
90
|
+
name: string;
|
|
91
|
+
id: string;
|
|
92
|
+
instanceId: string;
|
|
93
|
+
required?: boolean | undefined;
|
|
94
|
+
} | {
|
|
95
|
+
value: {
|
|
96
|
+
code: string;
|
|
97
|
+
type: "execute";
|
|
98
|
+
args: string[];
|
|
99
|
+
}[];
|
|
100
|
+
type: "action";
|
|
101
|
+
name: string;
|
|
102
|
+
id: string;
|
|
103
|
+
instanceId: string;
|
|
104
|
+
required?: boolean | undefined;
|
|
105
|
+
}>;
|
|
106
|
+
}) => {
|
|
107
|
+
variables: Map<string, {
|
|
108
|
+
valueName: VariableName;
|
|
109
|
+
setterName: VariableName;
|
|
110
|
+
initialValue: unknown;
|
|
111
|
+
}>;
|
|
112
|
+
body: string;
|
|
113
|
+
output: Map<string, string>;
|
|
114
|
+
};
|
|
20
115
|
export {};
|
package/lib/types/generator.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DataSources, type Instance, type Instances, type Page, type Props } from "@webstudio-is/sdk";
|
|
2
2
|
import type { WsComponentMeta } from "./components/component-meta";
|
|
3
3
|
import { type IndexesWithinAncestors } from "./instance-utils";
|
|
4
|
-
import type { DataSourceValues } from "./context";
|
|
5
4
|
type PageData = {
|
|
6
5
|
page: Page;
|
|
7
6
|
metas: Map<Instance["component"], WsComponentMeta>;
|
|
@@ -11,8 +10,7 @@ type PageData = {
|
|
|
11
10
|
};
|
|
12
11
|
export type GeneratedUtils = {
|
|
13
12
|
indexesWithinAncestors: IndexesWithinAncestors;
|
|
14
|
-
|
|
15
|
-
executeEffectfulExpression: (expression: string, args: DataSourceValues, values: DataSourceValues) => DataSourceValues;
|
|
13
|
+
getDataSourcesLogic: (getVariable: (id: string) => unknown, setVariable: (id: string, value: unknown) => void) => Map<string, unknown>;
|
|
16
14
|
};
|
|
17
15
|
/**
|
|
18
16
|
* Generates data based utilities at build time
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from "./css";
|
|
2
|
-
export * from "./tree";
|
|
3
|
-
export * from "./app";
|
|
1
|
+
export * from "./css/index";
|
|
2
|
+
export * from "./tree/index";
|
|
3
|
+
export * from "./app/index";
|
|
4
4
|
export * from "./components/components-utils";
|
|
5
5
|
export { PropMeta } from "./prop-meta";
|
|
6
|
-
export { type WsComponentPropsMeta, type
|
|
6
|
+
export { type WsComponentPropsMeta, type ComponentState, type PresetStyle, WsComponentMeta, componentCategories, stateCategories, defaultStates, } from "./components/component-meta";
|
|
7
7
|
export * from "./embed-template";
|
|
8
8
|
export { useInstanceProps, usePropUrl, usePropAsset, getInstanceIdFromComponentProps, getIndexWithinAncestorFromComponentProps, } from "./props";
|
|
9
9
|
export { type Params, ReactSdkContext } from "./context";
|
|
10
|
-
export { validateExpression,
|
|
11
|
-
export { renderComponentTemplate } from "./component-renderer";
|
|
10
|
+
export { validateExpression, computeExpressionsDependencies, encodeDataSourceVariable, decodeDataSourceVariable, generateDataSources, } from "./expression";
|
|
12
11
|
export { getIndexesWithinAncestors } from "./instance-utils";
|
|
13
12
|
export * from "./hook";
|
|
14
13
|
export { generateUtilsExport } from "./generator";
|
|
14
|
+
export { generatePageComponent } from "./component-generator";
|
|
@@ -2,12 +2,12 @@ import { type ForwardRefExoticComponent, type RefAttributes, type ReactNode } fr
|
|
|
2
2
|
import type { ReadableAtom } from "nanostores";
|
|
3
3
|
import type { Instance, Instances, Assets } from "@webstudio-is/sdk";
|
|
4
4
|
import type { Components } from "../components/components-utils";
|
|
5
|
-
import { type Params
|
|
5
|
+
import { type Params } from "../context";
|
|
6
6
|
import type { Pages, PropsByInstanceId } from "../props";
|
|
7
7
|
import type { WebstudioComponentProps } from "./webstudio-component";
|
|
8
8
|
import type { IndexesWithinAncestors } from "../instance-utils";
|
|
9
9
|
import type { ImageLoader } from "@webstudio-is/image";
|
|
10
|
-
export declare const createElementsTree: ({ renderer, assetBaseUrl, imageBaseUrl, imageLoader, instances, rootInstanceId, propsByInstanceIdStore, assetsStore, pagesStore,
|
|
10
|
+
export declare const createElementsTree: ({ renderer, assetBaseUrl, imageBaseUrl, imageLoader, instances, rootInstanceId, propsByInstanceIdStore, assetsStore, pagesStore, dataSourcesLogicStore, indexesWithinAncestors, Component, components, scripts, }: Params & {
|
|
11
11
|
instances: Map<string, {
|
|
12
12
|
type: "instance";
|
|
13
13
|
id: string;
|
|
@@ -26,9 +26,7 @@ export declare const createElementsTree: ({ renderer, assetBaseUrl, imageBaseUrl
|
|
|
26
26
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
|
27
27
|
assetsStore: ReadableAtom<Assets>;
|
|
28
28
|
pagesStore: ReadableAtom<Pages>;
|
|
29
|
-
|
|
30
|
-
dataSourceValuesStore: ReadableAtom<DataSourceValues>;
|
|
31
|
-
onDataSourceUpdate: (newValues: DataSourceValues) => void;
|
|
29
|
+
dataSourcesLogicStore: ReadableAtom<Map<string, unknown>>;
|
|
32
30
|
indexesWithinAncestors: IndexesWithinAncestors;
|
|
33
31
|
Component: ForwardRefExoticComponent<WebstudioComponentProps & RefAttributes<HTMLElement>>;
|
|
34
32
|
components: Components;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.100.1-c4ae8b2.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"jest": "^29.6.4",
|
|
14
14
|
"react": "^18.2.0",
|
|
15
15
|
"react-dom": "^18.2.0",
|
|
16
|
+
"strip-indent": "^4.0.0",
|
|
16
17
|
"type-fest": "^4.3.1",
|
|
17
18
|
"typescript": "5.2.2",
|
|
18
19
|
"zod": "^3.21.4",
|
|
19
|
-
"@webstudio-is/jest-config": "
|
|
20
|
-
"@webstudio-is/tsconfig": "
|
|
20
|
+
"@webstudio-is/jest-config": "1.0.8-c4ae8b2.0",
|
|
21
|
+
"@webstudio-is/tsconfig": "1.0.8-c4ae8b2.0"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"@remix-run/react": "^1.19.1",
|
|
@@ -34,10 +35,10 @@
|
|
|
34
35
|
"nanostores": "^0.9.3",
|
|
35
36
|
"no-case": "^3.0.4",
|
|
36
37
|
"title-case": "^3.0.3",
|
|
37
|
-
"@webstudio-is/css-engine": "
|
|
38
|
-
"@webstudio-is/fonts": "
|
|
39
|
-
"@webstudio-is/image": "
|
|
40
|
-
"@webstudio-is/sdk": "
|
|
38
|
+
"@webstudio-is/css-engine": "0.100.1-c4ae8b2.0",
|
|
39
|
+
"@webstudio-is/fonts": "0.100.1-c4ae8b2.0",
|
|
40
|
+
"@webstudio-is/image": "0.100.1-c4ae8b2.0",
|
|
41
|
+
"@webstudio-is/sdk": "0.100.1-c4ae8b2.0"
|
|
41
42
|
},
|
|
42
43
|
"exports": {
|
|
43
44
|
".": {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ExoticComponent } from "react";
|
|
2
|
-
import type { Instance } from "@webstudio-is/sdk";
|
|
3
|
-
import type { WsComponentMeta } from "./components/component-meta";
|
|
4
|
-
import type { ImageLoader } from "@webstudio-is/image";
|
|
5
|
-
export declare const renderComponentTemplate: ({ name, metas: metasRecord, components, props, imageLoader, }: {
|
|
6
|
-
name: Instance["component"];
|
|
7
|
-
metas: Record<string, WsComponentMeta>;
|
|
8
|
-
props?: Record<string, unknown> | undefined;
|
|
9
|
-
components: Record<string, ExoticComponent<any>>;
|
|
10
|
-
imageLoader?: ImageLoader | undefined;
|
|
11
|
-
}) => import("react/jsx-runtime").JSX.Element;
|