@webstudio-is/react-sdk 0.78.0 → 0.80.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/cjs/context.js +8 -2
- package/lib/cjs/css/normalize.js +23 -43
- package/lib/cjs/css/presets.js +1 -111
- package/lib/cjs/embed-template.js +45 -16
- package/lib/cjs/expression.js +137 -22
- package/lib/cjs/index.js +6 -2
- package/lib/cjs/props.js +32 -2
- package/lib/cjs/tree/create-elements-tree.js +7 -2
- package/lib/cjs/tree/root.js +15 -7
- package/lib/context.js +8 -2
- package/lib/css/normalize.js +23 -33
- package/lib/css/presets.js +1 -111
- package/lib/embed-template.js +45 -16
- package/lib/expression.js +137 -22
- package/lib/index.js +13 -5
- package/lib/props.js +32 -2
- package/lib/tree/create-elements-tree.js +10 -3
- package/lib/tree/root.js +16 -8
- package/lib/types/components/component-meta.d.ts +30 -0
- package/lib/types/context.d.ts +5 -2
- package/lib/types/css/normalize.d.ts +0 -520
- package/lib/types/css/presets.d.ts +0 -282
- package/lib/types/embed-template.d.ts +38 -0
- package/lib/types/expression.d.ts +12 -4
- package/lib/types/index.d.ts +1 -1
- package/lib/types/props.d.ts +10 -0
- package/lib/types/tree/create-elements-tree.d.ts +6 -5
- package/lib/types/tree/root.d.ts +5 -5
- package/package.json +17 -16
- package/src/context.tsx +17 -4
- package/src/css/normalize.ts +23 -32
- package/src/css/presets.ts +0 -110
- package/src/embed-template.test.ts +84 -4
- package/src/embed-template.ts +51 -18
- package/src/expression.test.ts +106 -12
- package/src/expression.ts +157 -26
- package/src/index.ts +6 -2
- package/src/props.ts +33 -3
- package/src/tree/create-elements-tree.tsx +19 -10
- package/src/tree/root.ts +24 -13
|
@@ -1,285 +1,3 @@
|
|
|
1
1
|
import type { Styles } from "./normalize";
|
|
2
2
|
export declare const borders: Styles;
|
|
3
3
|
export declare const outline: Styles;
|
|
4
|
-
export declare const margins: ({
|
|
5
|
-
property: "marginTop";
|
|
6
|
-
value: {
|
|
7
|
-
type: "unit";
|
|
8
|
-
value: number;
|
|
9
|
-
unit: "px";
|
|
10
|
-
};
|
|
11
|
-
} | {
|
|
12
|
-
property: "marginRight";
|
|
13
|
-
value: {
|
|
14
|
-
type: "unit";
|
|
15
|
-
value: number;
|
|
16
|
-
unit: "px";
|
|
17
|
-
};
|
|
18
|
-
} | {
|
|
19
|
-
property: "marginBottom";
|
|
20
|
-
value: {
|
|
21
|
-
type: "unit";
|
|
22
|
-
value: number;
|
|
23
|
-
unit: "px";
|
|
24
|
-
};
|
|
25
|
-
} | {
|
|
26
|
-
property: "marginLeft";
|
|
27
|
-
value: {
|
|
28
|
-
type: "unit";
|
|
29
|
-
value: number;
|
|
30
|
-
unit: "px";
|
|
31
|
-
};
|
|
32
|
-
})[];
|
|
33
|
-
export declare const verticalMargins: ({
|
|
34
|
-
property: "marginTop";
|
|
35
|
-
value: {
|
|
36
|
-
type: "unit";
|
|
37
|
-
value: number;
|
|
38
|
-
unit: "px";
|
|
39
|
-
};
|
|
40
|
-
} | {
|
|
41
|
-
property: "marginBottom";
|
|
42
|
-
value: {
|
|
43
|
-
type: "unit";
|
|
44
|
-
value: number;
|
|
45
|
-
unit: "px";
|
|
46
|
-
};
|
|
47
|
-
})[];
|
|
48
|
-
export declare const blockquote: ({
|
|
49
|
-
property: "marginTop";
|
|
50
|
-
value: {
|
|
51
|
-
type: "unit";
|
|
52
|
-
value: number;
|
|
53
|
-
unit: "px";
|
|
54
|
-
};
|
|
55
|
-
} | {
|
|
56
|
-
property: "marginRight";
|
|
57
|
-
value: {
|
|
58
|
-
type: "unit";
|
|
59
|
-
value: number;
|
|
60
|
-
unit: "px";
|
|
61
|
-
};
|
|
62
|
-
} | {
|
|
63
|
-
property: "marginBottom";
|
|
64
|
-
value: {
|
|
65
|
-
type: "unit";
|
|
66
|
-
value: number;
|
|
67
|
-
unit: "px";
|
|
68
|
-
};
|
|
69
|
-
} | {
|
|
70
|
-
property: "marginLeft";
|
|
71
|
-
value: {
|
|
72
|
-
type: "unit";
|
|
73
|
-
value: number;
|
|
74
|
-
unit: "px";
|
|
75
|
-
};
|
|
76
|
-
} | {
|
|
77
|
-
property: "paddingTop";
|
|
78
|
-
value: {
|
|
79
|
-
type: "unit";
|
|
80
|
-
value: number;
|
|
81
|
-
unit: "px";
|
|
82
|
-
r?: undefined;
|
|
83
|
-
g?: undefined;
|
|
84
|
-
b?: undefined;
|
|
85
|
-
alpha?: undefined;
|
|
86
|
-
};
|
|
87
|
-
} | {
|
|
88
|
-
property: "paddingBottom";
|
|
89
|
-
value: {
|
|
90
|
-
type: "unit";
|
|
91
|
-
value: number;
|
|
92
|
-
unit: "px";
|
|
93
|
-
r?: undefined;
|
|
94
|
-
g?: undefined;
|
|
95
|
-
b?: undefined;
|
|
96
|
-
alpha?: undefined;
|
|
97
|
-
};
|
|
98
|
-
} | {
|
|
99
|
-
property: "paddingLeft";
|
|
100
|
-
value: {
|
|
101
|
-
type: "unit";
|
|
102
|
-
value: number;
|
|
103
|
-
unit: "px";
|
|
104
|
-
r?: undefined;
|
|
105
|
-
g?: undefined;
|
|
106
|
-
b?: undefined;
|
|
107
|
-
alpha?: undefined;
|
|
108
|
-
};
|
|
109
|
-
} | {
|
|
110
|
-
property: "paddingRight";
|
|
111
|
-
value: {
|
|
112
|
-
type: "unit";
|
|
113
|
-
value: number;
|
|
114
|
-
unit: "px";
|
|
115
|
-
r?: undefined;
|
|
116
|
-
g?: undefined;
|
|
117
|
-
b?: undefined;
|
|
118
|
-
alpha?: undefined;
|
|
119
|
-
};
|
|
120
|
-
} | {
|
|
121
|
-
property: "borderLeftWidth";
|
|
122
|
-
value: {
|
|
123
|
-
type: "unit";
|
|
124
|
-
value: number;
|
|
125
|
-
unit: "px";
|
|
126
|
-
r?: undefined;
|
|
127
|
-
g?: undefined;
|
|
128
|
-
b?: undefined;
|
|
129
|
-
alpha?: undefined;
|
|
130
|
-
};
|
|
131
|
-
} | {
|
|
132
|
-
property: "borderLeftStyle";
|
|
133
|
-
value: {
|
|
134
|
-
type: "keyword";
|
|
135
|
-
value: string;
|
|
136
|
-
unit?: undefined;
|
|
137
|
-
r?: undefined;
|
|
138
|
-
g?: undefined;
|
|
139
|
-
b?: undefined;
|
|
140
|
-
alpha?: undefined;
|
|
141
|
-
};
|
|
142
|
-
} | {
|
|
143
|
-
property: "borderLeftColor";
|
|
144
|
-
value: {
|
|
145
|
-
type: "rgb";
|
|
146
|
-
r: number;
|
|
147
|
-
g: number;
|
|
148
|
-
b: number;
|
|
149
|
-
alpha: number;
|
|
150
|
-
value?: undefined;
|
|
151
|
-
unit?: undefined;
|
|
152
|
-
};
|
|
153
|
-
})[];
|
|
154
|
-
export declare const h1: ({
|
|
155
|
-
property: "marginTop";
|
|
156
|
-
value: {
|
|
157
|
-
type: "unit";
|
|
158
|
-
value: number;
|
|
159
|
-
unit: "px";
|
|
160
|
-
};
|
|
161
|
-
} | {
|
|
162
|
-
property: "marginBottom";
|
|
163
|
-
value: {
|
|
164
|
-
type: "unit";
|
|
165
|
-
value: number;
|
|
166
|
-
unit: "px";
|
|
167
|
-
};
|
|
168
|
-
} | {
|
|
169
|
-
property: "fontSize";
|
|
170
|
-
value: {
|
|
171
|
-
type: "unit";
|
|
172
|
-
value: number;
|
|
173
|
-
unit: "px";
|
|
174
|
-
};
|
|
175
|
-
})[];
|
|
176
|
-
export declare const h2: ({
|
|
177
|
-
property: "marginTop";
|
|
178
|
-
value: {
|
|
179
|
-
type: "unit";
|
|
180
|
-
value: number;
|
|
181
|
-
unit: "px";
|
|
182
|
-
};
|
|
183
|
-
} | {
|
|
184
|
-
property: "marginBottom";
|
|
185
|
-
value: {
|
|
186
|
-
type: "unit";
|
|
187
|
-
value: number;
|
|
188
|
-
unit: "px";
|
|
189
|
-
};
|
|
190
|
-
} | {
|
|
191
|
-
property: "fontSize";
|
|
192
|
-
value: {
|
|
193
|
-
type: "unit";
|
|
194
|
-
value: number;
|
|
195
|
-
unit: "px";
|
|
196
|
-
};
|
|
197
|
-
})[];
|
|
198
|
-
export declare const h3: ({
|
|
199
|
-
property: "marginTop";
|
|
200
|
-
value: {
|
|
201
|
-
type: "unit";
|
|
202
|
-
value: number;
|
|
203
|
-
unit: "px";
|
|
204
|
-
};
|
|
205
|
-
} | {
|
|
206
|
-
property: "marginBottom";
|
|
207
|
-
value: {
|
|
208
|
-
type: "unit";
|
|
209
|
-
value: number;
|
|
210
|
-
unit: "px";
|
|
211
|
-
};
|
|
212
|
-
} | {
|
|
213
|
-
property: "fontSize";
|
|
214
|
-
value: {
|
|
215
|
-
type: "unit";
|
|
216
|
-
value: number;
|
|
217
|
-
unit: "px";
|
|
218
|
-
};
|
|
219
|
-
})[];
|
|
220
|
-
export declare const h4: ({
|
|
221
|
-
property: "marginTop";
|
|
222
|
-
value: {
|
|
223
|
-
type: "unit";
|
|
224
|
-
value: number;
|
|
225
|
-
unit: "px";
|
|
226
|
-
};
|
|
227
|
-
} | {
|
|
228
|
-
property: "marginBottom";
|
|
229
|
-
value: {
|
|
230
|
-
type: "unit";
|
|
231
|
-
value: number;
|
|
232
|
-
unit: "px";
|
|
233
|
-
};
|
|
234
|
-
} | {
|
|
235
|
-
property: "fontSize";
|
|
236
|
-
value: {
|
|
237
|
-
type: "unit";
|
|
238
|
-
value: number;
|
|
239
|
-
unit: "px";
|
|
240
|
-
};
|
|
241
|
-
})[];
|
|
242
|
-
export declare const h5: ({
|
|
243
|
-
property: "marginTop";
|
|
244
|
-
value: {
|
|
245
|
-
type: "unit";
|
|
246
|
-
value: number;
|
|
247
|
-
unit: "px";
|
|
248
|
-
};
|
|
249
|
-
} | {
|
|
250
|
-
property: "marginBottom";
|
|
251
|
-
value: {
|
|
252
|
-
type: "unit";
|
|
253
|
-
value: number;
|
|
254
|
-
unit: "px";
|
|
255
|
-
};
|
|
256
|
-
} | {
|
|
257
|
-
property: "fontSize";
|
|
258
|
-
value: {
|
|
259
|
-
type: "unit";
|
|
260
|
-
value: number;
|
|
261
|
-
unit: "px";
|
|
262
|
-
};
|
|
263
|
-
})[];
|
|
264
|
-
export declare const h6: ({
|
|
265
|
-
property: "marginTop";
|
|
266
|
-
value: {
|
|
267
|
-
type: "unit";
|
|
268
|
-
value: number;
|
|
269
|
-
unit: "px";
|
|
270
|
-
};
|
|
271
|
-
} | {
|
|
272
|
-
property: "marginBottom";
|
|
273
|
-
value: {
|
|
274
|
-
type: "unit";
|
|
275
|
-
value: number;
|
|
276
|
-
unit: "px";
|
|
277
|
-
};
|
|
278
|
-
} | {
|
|
279
|
-
property: "fontSize";
|
|
280
|
-
value: {
|
|
281
|
-
type: "unit";
|
|
282
|
-
value: number;
|
|
283
|
-
unit: "px";
|
|
284
|
-
};
|
|
285
|
-
})[];
|
|
@@ -213,6 +213,33 @@ declare const EmbedTemplateProp: z.ZodUnion<[z.ZodObject<{
|
|
|
213
213
|
code: string;
|
|
214
214
|
type: "expression";
|
|
215
215
|
} | undefined;
|
|
216
|
+
}>, z.ZodObject<{
|
|
217
|
+
type: z.ZodLiteral<"action">;
|
|
218
|
+
name: z.ZodString;
|
|
219
|
+
value: z.ZodArray<z.ZodObject<{
|
|
220
|
+
type: z.ZodLiteral<"execute">;
|
|
221
|
+
code: z.ZodString;
|
|
222
|
+
}, "strip", z.ZodTypeAny, {
|
|
223
|
+
code: string;
|
|
224
|
+
type: "execute";
|
|
225
|
+
}, {
|
|
226
|
+
code: string;
|
|
227
|
+
type: "execute";
|
|
228
|
+
}>, "many">;
|
|
229
|
+
}, "strip", z.ZodTypeAny, {
|
|
230
|
+
name: string;
|
|
231
|
+
type: "action";
|
|
232
|
+
value: {
|
|
233
|
+
code: string;
|
|
234
|
+
type: "execute";
|
|
235
|
+
}[];
|
|
236
|
+
}, {
|
|
237
|
+
name: string;
|
|
238
|
+
type: "action";
|
|
239
|
+
value: {
|
|
240
|
+
code: string;
|
|
241
|
+
type: "execute";
|
|
242
|
+
}[];
|
|
216
243
|
}>]>;
|
|
217
244
|
type EmbedTemplateProp = z.infer<typeof EmbedTemplateProp>;
|
|
218
245
|
declare const EmbedTemplateStyleDeclRaw: z.ZodObject<{
|
|
@@ -2357,6 +2384,16 @@ export declare const generateDataFromEmbedTemplate: (treeTemplate: ({
|
|
|
2357
2384
|
id: string;
|
|
2358
2385
|
instanceId: string;
|
|
2359
2386
|
required?: boolean | undefined;
|
|
2387
|
+
} | {
|
|
2388
|
+
name: string;
|
|
2389
|
+
type: "action";
|
|
2390
|
+
value: {
|
|
2391
|
+
code: string;
|
|
2392
|
+
type: "execute";
|
|
2393
|
+
}[];
|
|
2394
|
+
id: string;
|
|
2395
|
+
instanceId: string;
|
|
2396
|
+
required?: boolean | undefined;
|
|
2360
2397
|
})[];
|
|
2361
2398
|
dataSources: ({
|
|
2362
2399
|
name: string;
|
|
@@ -2611,4 +2648,5 @@ export declare const generateDataFromEmbedTemplate: (treeTemplate: ({
|
|
|
2611
2648
|
property: "filter" | "float" | "fontFamily" | "width" | "height" | "clip" | "top" | "right" | `--${string}` | "accentColor" | "alignContent" | "alignItems" | "alignSelf" | "alignTracks" | "animationComposition" | "animationDelay" | "animationDirection" | "animationDuration" | "animationFillMode" | "animationIterationCount" | "animationName" | "animationPlayState" | "animationTimingFunction" | "animationTimeline" | "appearance" | "aspectRatio" | "backdropFilter" | "backfaceVisibility" | "backgroundAttachment" | "backgroundBlendMode" | "backgroundClip" | "backgroundColor" | "backgroundImage" | "backgroundOrigin" | "backgroundPosition" | "backgroundPositionX" | "backgroundPositionY" | "backgroundRepeat" | "backgroundSize" | "blockOverflow" | "blockSize" | "borderBlockColor" | "borderBlockStyle" | "borderBlockWidth" | "borderBlockEndColor" | "borderBlockEndStyle" | "borderBlockEndWidth" | "borderBlockStartColor" | "borderBlockStartStyle" | "borderBlockStartWidth" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderCollapse" | "borderEndEndRadius" | "borderEndStartRadius" | "borderImageOutset" | "borderImageRepeat" | "borderImageSlice" | "borderImageSource" | "borderImageWidth" | "borderInlineColor" | "borderInlineStyle" | "borderInlineWidth" | "borderInlineEndColor" | "borderInlineEndStyle" | "borderInlineEndWidth" | "borderInlineStartColor" | "borderInlineStartStyle" | "borderInlineStartWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderSpacing" | "borderStartEndRadius" | "borderStartStartRadius" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "boxDecorationBreak" | "boxShadow" | "boxSizing" | "breakAfter" | "breakBefore" | "breakInside" | "captionSide" | "caretColor" | "caretShape" | "clear" | "clipPath" | "color" | "printColorAdjust" | "colorScheme" | "columnCount" | "columnFill" | "columnGap" | "columnRuleColor" | "columnRuleStyle" | "columnRuleWidth" | "columnSpan" | "columnWidth" | "contain" | "containIntrinsicBlockSize" | "containIntrinsicHeight" | "containIntrinsicInlineSize" | "containIntrinsicWidth" | "content" | "contentVisibility" | "counterIncrement" | "counterReset" | "counterSet" | "cursor" | "direction" | "display" | "emptyCells" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFeatureSettings" | "fontKerning" | "fontLanguageOverride" | "fontOpticalSizing" | "fontVariationSettings" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontSynthesis" | "fontVariant" | "fontVariantAlternates" | "fontVariantCaps" | "fontVariantEastAsian" | "fontVariantLigatures" | "fontVariantNumeric" | "fontVariantPosition" | "fontWeight" | "forcedColorAdjust" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridColumnEnd" | "gridColumnStart" | "gridRowEnd" | "gridRowStart" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "hangingPunctuation" | "hyphenateCharacter" | "hyphens" | "imageOrientation" | "imageRendering" | "imageResolution" | "initialLetter" | "initialLetterAlign" | "inlineSize" | "inputSecurity" | "insetBlockEnd" | "insetBlockStart" | "insetInlineEnd" | "insetInlineStart" | "isolation" | "justifyContent" | "justifyItems" | "justifySelf" | "justifyTracks" | "left" | "letterSpacing" | "lineBreak" | "lineClamp" | "lineHeight" | "lineHeightStep" | "listStyleImage" | "listStylePosition" | "listStyleType" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "marginTrim" | "maskBorderMode" | "maskBorderOutset" | "maskBorderRepeat" | "maskBorderSlice" | "maskBorderSource" | "maskBorderWidth" | "maskClip" | "maskComposite" | "maskImage" | "maskMode" | "maskOrigin" | "maskPosition" | "maskRepeat" | "maskSize" | "maskType" | "masonryAutoFlow" | "mathDepth" | "mathShift" | "mathStyle" | "maxBlockSize" | "maxHeight" | "maxInlineSize" | "maxLines" | "maxWidth" | "minBlockSize" | "minHeight" | "minInlineSize" | "minWidth" | "mixBlendMode" | "objectFit" | "objectPosition" | "offsetAnchor" | "offsetDistance" | "offsetPath" | "offsetPosition" | "offsetRotate" | "opacity" | "order" | "orphans" | "outlineColor" | "outlineOffset" | "outlineStyle" | "outlineWidth" | "overflow" | "overflowAnchor" | "overflowBlock" | "overflowClipMargin" | "overflowInline" | "overflowWrap" | "overflowX" | "overflowY" | "overscrollBehavior" | "overscrollBehaviorBlock" | "overscrollBehaviorInline" | "overscrollBehaviorX" | "overscrollBehaviorY" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "pageBreakAfter" | "pageBreakBefore" | "pageBreakInside" | "paintOrder" | "perspective" | "perspectiveOrigin" | "pointerEvents" | "position" | "quotes" | "resize" | "rotate" | "rowGap" | "rubyAlign" | "rubyMerge" | "rubyPosition" | "scale" | "scrollbarColor" | "scrollbarGutter" | "scrollbarWidth" | "scrollBehavior" | "scrollMarginBlockStart" | "scrollMarginBlockEnd" | "scrollMarginBottom" | "scrollMarginInlineStart" | "scrollMarginInlineEnd" | "scrollMarginLeft" | "scrollMarginRight" | "scrollMarginTop" | "scrollPaddingBlockStart" | "scrollPaddingBlockEnd" | "scrollPaddingBottom" | "scrollPaddingInlineStart" | "scrollPaddingInlineEnd" | "scrollPaddingLeft" | "scrollPaddingRight" | "scrollPaddingTop" | "scrollSnapAlign" | "scrollSnapStop" | "scrollSnapType" | "scrollTimelineAxis" | "scrollTimelineName" | "shapeImageThreshold" | "shapeMargin" | "shapeOutside" | "tabSize" | "tableLayout" | "textAlign" | "textAlignLast" | "textCombineUpright" | "textDecorationColor" | "textDecorationLine" | "textDecorationSkip" | "textDecorationSkipInk" | "textDecorationStyle" | "textDecorationThickness" | "textEmphasisColor" | "textEmphasisPosition" | "textEmphasisStyle" | "textIndent" | "textJustify" | "textOrientation" | "textOverflow" | "textRendering" | "textShadow" | "textSizeAdjust" | "textTransform" | "textUnderlineOffset" | "textUnderlinePosition" | "touchAction" | "transform" | "transformBox" | "transformOrigin" | "transformStyle" | "transitionDelay" | "transitionDuration" | "transitionProperty" | "transitionTimingFunction" | "translate" | "unicodeBidi" | "userSelect" | "verticalAlign" | "visibility" | "whiteSpace" | "widows" | "willChange" | "wordBreak" | "wordSpacing" | "wordWrap" | "writingMode" | "zIndex";
|
|
2612
2649
|
}[];
|
|
2613
2650
|
};
|
|
2651
|
+
export type EmbedTemplateData = ReturnType<typeof generateDataFromEmbedTemplate>;
|
|
2614
2652
|
export {};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
type TransformIdentifier = (id: string) => string;
|
|
2
|
-
export declare const validateExpression: (code: string,
|
|
1
|
+
type TransformIdentifier = (id: string, assignee: boolean) => string;
|
|
2
|
+
export declare const validateExpression: (code: string, options?: {
|
|
3
|
+
effectful?: boolean;
|
|
4
|
+
transformIdentifier?: TransformIdentifier;
|
|
5
|
+
}) => string;
|
|
3
6
|
/**
|
|
4
7
|
* Generates a function body expecting map as _variables argument
|
|
5
8
|
* and outputing map of results
|
|
6
9
|
*/
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
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, allowedVariables: Set<string>) => string;
|
|
13
|
+
export declare const executeEffectfulExpression: (code: string, variables: Map<string, unknown>) => Map<string, unknown>;
|
|
14
|
+
type Values = Map<string, unknown>;
|
|
9
15
|
export declare const encodeDataSourceVariable: (id: string) => string;
|
|
16
|
+
export declare const encodeVariablesMap: (values: Values) => Values;
|
|
10
17
|
export declare const decodeDataSourceVariable: (name: string) => string | undefined;
|
|
18
|
+
export declare const decodeVariablesMap: (values: Values) => Values;
|
|
11
19
|
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export { type WsComponentPropsMeta, type WsComponentMeta, type ComponentState, t
|
|
|
7
7
|
export * from "./embed-template";
|
|
8
8
|
export { useInstanceProps, usePropUrl, usePropAsset, getInstanceIdFromComponentProps, } from "./props";
|
|
9
9
|
export { type Params, ReactSdkContext } from "./context";
|
|
10
|
-
export { validateExpression,
|
|
10
|
+
export { validateExpression, generateComputingExpressions, executeComputingExpressions, generateEffectfulExpression, executeEffectfulExpression, encodeDataSourceVariable, encodeVariablesMap, decodeDataSourceVariable, decodeVariablesMap, } from "./expression";
|
package/lib/types/props.d.ts
CHANGED
|
@@ -57,6 +57,16 @@ export declare const getPropsByInstanceId: (props: Map<string, {
|
|
|
57
57
|
id: string;
|
|
58
58
|
instanceId: string;
|
|
59
59
|
required?: boolean | undefined;
|
|
60
|
+
} | {
|
|
61
|
+
name: string;
|
|
62
|
+
type: "action";
|
|
63
|
+
value: {
|
|
64
|
+
code: string;
|
|
65
|
+
type: "execute";
|
|
66
|
+
}[];
|
|
67
|
+
id: string;
|
|
68
|
+
instanceId: string;
|
|
69
|
+
required?: boolean | undefined;
|
|
60
70
|
}>) => PropsByInstanceId;
|
|
61
71
|
export declare const useInstanceProps: (instanceId: Instance["id"]) => Record<string, unknown>;
|
|
62
72
|
export declare const usePropAsset: (instanceId: Instance["id"], name: string) => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
2
|
import type { ReadableAtom } from "nanostores";
|
|
3
3
|
import type { Assets } from "@webstudio-is/asset-uploader";
|
|
4
|
-
import type {
|
|
4
|
+
import type { Instance, Instances } from "@webstudio-is/project-build";
|
|
5
5
|
import type { Components } from "../components/components-utils";
|
|
6
|
-
import { type Params } from "../context";
|
|
6
|
+
import { type Params, type DataSourceValues } from "../context";
|
|
7
7
|
import type { Pages, PropsByInstanceId } from "../props";
|
|
8
8
|
import type { WebstudioComponent } from "./webstudio-component";
|
|
9
|
-
export declare const createElementsTree: ({ renderer, imageBaseUrl, assetBaseUrl, instances, rootInstanceId, propsByInstanceIdStore, assetsStore, pagesStore, dataSourceValuesStore, onDataSourceUpdate, Component, components, }: Params & {
|
|
9
|
+
export declare const createElementsTree: ({ renderer, imageBaseUrl, assetBaseUrl, instances, rootInstanceId, propsByInstanceIdStore, assetsStore, pagesStore, dataSourceValuesStore, executeEffectfulExpression, onDataSourceUpdate, Component, components, }: Params & {
|
|
10
10
|
instances: Map<string, {
|
|
11
11
|
type: "instance";
|
|
12
12
|
id: string;
|
|
@@ -24,8 +24,9 @@ export declare const createElementsTree: ({ renderer, imageBaseUrl, assetBaseUrl
|
|
|
24
24
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
|
25
25
|
assetsStore: ReadableAtom<Assets>;
|
|
26
26
|
pagesStore: ReadableAtom<Pages>;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
executeEffectfulExpression: (expression: string, values: DataSourceValues) => DataSourceValues;
|
|
28
|
+
dataSourceValuesStore: ReadableAtom<DataSourceValues>;
|
|
29
|
+
onDataSourceUpdate: (newValues: DataSourceValues) => void;
|
|
29
30
|
Component: (props: ComponentProps<typeof WebstudioComponent>) => JSX.Element;
|
|
30
31
|
components: Components;
|
|
31
32
|
}) => JSX.Element | null;
|
package/lib/types/tree/root.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
|
-
import { type Build, type Page
|
|
2
|
+
import { type Build, type Page } from "@webstudio-is/project-build";
|
|
3
3
|
import type { Asset } from "@webstudio-is/asset-uploader";
|
|
4
4
|
import { WebstudioComponent } from "./webstudio-component";
|
|
5
5
|
import type { Components } from "../components/components-utils";
|
|
6
|
-
import type { Params } from "../context";
|
|
6
|
+
import type { Params, DataSourceValues } from "../context";
|
|
7
7
|
export type Data = {
|
|
8
8
|
page: Page;
|
|
9
9
|
pages: Array<Page>;
|
|
@@ -14,12 +14,12 @@ export type Data = {
|
|
|
14
14
|
export type RootPropsData = Omit<Data, "build"> & {
|
|
15
15
|
build: Pick<Data["build"], "instances" | "props" | "dataSources">;
|
|
16
16
|
};
|
|
17
|
-
type DataSourceValues = Map<DataSource["id"], unknown>;
|
|
18
17
|
type RootProps = {
|
|
19
18
|
data: RootPropsData;
|
|
20
|
-
|
|
19
|
+
executeComputingExpressions: (values: DataSourceValues) => DataSourceValues;
|
|
20
|
+
executeEffectfulExpression: (expression: string, values: DataSourceValues) => DataSourceValues;
|
|
21
21
|
Component?: (props: ComponentProps<typeof WebstudioComponent>) => JSX.Element;
|
|
22
22
|
components: Components;
|
|
23
23
|
};
|
|
24
|
-
export declare const InstanceRoot: ({ data,
|
|
24
|
+
export declare const InstanceRoot: ({ data, executeComputingExpressions, executeEffectfulExpression, Component, components, }: RootProps) => JSX.Element | null;
|
|
25
25
|
export {};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@jest/globals": "^29.
|
|
10
|
-
"@remix-run/react": "^1.
|
|
9
|
+
"@jest/globals": "^29.6.1",
|
|
10
|
+
"@remix-run/react": "^1.18.1",
|
|
11
11
|
"@types/react": "^18.0.35",
|
|
12
12
|
"@types/react-dom": "^18.0.11",
|
|
13
|
-
"jest": "^29.
|
|
13
|
+
"jest": "^29.6.1",
|
|
14
14
|
"react": "^18.2.0",
|
|
15
15
|
"react-dom": "^18.2.0",
|
|
16
16
|
"type-fest": "^3.7.1",
|
|
@@ -21,25 +21,26 @@
|
|
|
21
21
|
"@webstudio-is/tsconfig": "^1.0.6"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@remix-run/react": "^1.
|
|
24
|
+
"@remix-run/react": "^1.18.0",
|
|
25
25
|
"react": "^18.2.0",
|
|
26
26
|
"react-dom": "^18.2.0",
|
|
27
27
|
"zod": "^3.19.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@
|
|
30
|
+
"@jsep-plugin/assignment": "^1.2.1",
|
|
31
|
+
"@nanostores/react": "^0.7.1",
|
|
31
32
|
"detect-font": "^0.1.5",
|
|
32
|
-
"html-tags": "^3.
|
|
33
|
+
"html-tags": "^3.3.1",
|
|
33
34
|
"jsep": "^1.3.8",
|
|
34
|
-
"nanoevents": "^
|
|
35
|
-
"nanoid": "^
|
|
36
|
-
"nanostores": "^0.
|
|
37
|
-
"@webstudio-is/asset-uploader": "^0.
|
|
38
|
-
"@webstudio-is/css-data": "^0.
|
|
39
|
-
"@webstudio-is/css-engine": "^0.
|
|
40
|
-
"@webstudio-is/fonts": "^0.
|
|
41
|
-
"@webstudio-is/generate-arg-types": "^0.
|
|
42
|
-
"@webstudio-is/project-build": "^0.
|
|
35
|
+
"nanoevents": "^8.0.0",
|
|
36
|
+
"nanoid": "^4.0.2",
|
|
37
|
+
"nanostores": "^0.9.3",
|
|
38
|
+
"@webstudio-is/asset-uploader": "^0.80.0",
|
|
39
|
+
"@webstudio-is/css-data": "^0.80.0",
|
|
40
|
+
"@webstudio-is/css-engine": "^0.80.0",
|
|
41
|
+
"@webstudio-is/fonts": "^0.80.0",
|
|
42
|
+
"@webstudio-is/generate-arg-types": "^0.80.0",
|
|
43
|
+
"@webstudio-is/project-build": "^0.80.0"
|
|
43
44
|
},
|
|
44
45
|
"exports": {
|
|
45
46
|
".": {
|
package/src/context.tsx
CHANGED
|
@@ -31,13 +31,20 @@ export type Params = {
|
|
|
31
31
|
assetBaseUrl: string;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
export type DataSourceValues = Map<DataSource["id"], unknown>;
|
|
35
|
+
|
|
34
36
|
export const ReactSdkContext = createContext<
|
|
35
37
|
Params & {
|
|
36
38
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
|
37
39
|
assetsStore: ReadableAtom<Assets>;
|
|
38
40
|
pagesStore: ReadableAtom<Pages>;
|
|
39
|
-
dataSourceValuesStore: ReadableAtom<
|
|
40
|
-
|
|
41
|
+
dataSourceValuesStore: ReadableAtom<DataSourceValues>;
|
|
42
|
+
executeEffectfulExpression: (
|
|
43
|
+
expression: string,
|
|
44
|
+
values: DataSourceValues
|
|
45
|
+
) => DataSourceValues;
|
|
46
|
+
setDataSourceValues: (newValues: DataSourceValues) => void;
|
|
47
|
+
setBoundDataSourceValue: (
|
|
41
48
|
instanceId: Instance["id"],
|
|
42
49
|
prop: Prop["name"],
|
|
43
50
|
value: unknown
|
|
@@ -50,7 +57,13 @@ export const ReactSdkContext = createContext<
|
|
|
50
57
|
assetsStore: atom(new Map()),
|
|
51
58
|
pagesStore: atom(new Map()),
|
|
52
59
|
dataSourceValuesStore: atom(new Map()),
|
|
53
|
-
|
|
54
|
-
throw Error("React SDK
|
|
60
|
+
executeEffectfulExpression: () => {
|
|
61
|
+
throw Error("React SDK executeEffectfulExpression is not implemented");
|
|
62
|
+
},
|
|
63
|
+
setDataSourceValues: () => {
|
|
64
|
+
throw Error("React SDK setBoundDataSourceValue is not implemented");
|
|
65
|
+
},
|
|
66
|
+
setBoundDataSourceValue: () => {
|
|
67
|
+
throw Error("React SDK setBoundDataSourceValue is not implemented");
|
|
55
68
|
},
|
|
56
69
|
});
|