@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
package/lib/cjs/expression.js
CHANGED
|
@@ -29,27 +29,35 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var expression_exports = {};
|
|
30
30
|
__export(expression_exports, {
|
|
31
31
|
decodeDataSourceVariable: () => decodeDataSourceVariable,
|
|
32
|
+
decodeVariablesMap: () => decodeVariablesMap,
|
|
32
33
|
encodeDataSourceVariable: () => encodeDataSourceVariable,
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
encodeVariablesMap: () => encodeVariablesMap,
|
|
35
|
+
executeComputingExpressions: () => executeComputingExpressions,
|
|
36
|
+
executeEffectfulExpression: () => executeEffectfulExpression,
|
|
37
|
+
generateComputingExpressions: () => generateComputingExpressions,
|
|
38
|
+
generateEffectfulExpression: () => generateEffectfulExpression,
|
|
35
39
|
validateExpression: () => validateExpression
|
|
36
40
|
});
|
|
37
41
|
module.exports = __toCommonJS(expression_exports);
|
|
38
42
|
var import_jsep = __toESM(require("jsep"), 1);
|
|
39
|
-
|
|
43
|
+
var import_assignment = __toESM(require("@jsep-plugin/assignment"), 1);
|
|
44
|
+
import_jsep.default.plugins.register(import_assignment.default);
|
|
45
|
+
const generateCode = (node, failOnForbidden, effectful, transformIdentifier) => {
|
|
40
46
|
if (node.type === "Identifier") {
|
|
41
|
-
return transformIdentifier(node.name);
|
|
47
|
+
return transformIdentifier(node.name, false);
|
|
42
48
|
}
|
|
43
49
|
if (node.type === "MemberExpression") {
|
|
44
50
|
if (failOnForbidden) {
|
|
45
51
|
const object2 = generateCode(
|
|
46
52
|
node.object,
|
|
47
53
|
false,
|
|
54
|
+
effectful,
|
|
48
55
|
transformIdentifier
|
|
49
56
|
);
|
|
50
57
|
const property2 = generateCode(
|
|
51
58
|
node.property,
|
|
52
59
|
false,
|
|
60
|
+
effectful,
|
|
53
61
|
transformIdentifier
|
|
54
62
|
);
|
|
55
63
|
throw Error(`Cannot access "${property2}" of "${object2}"`);
|
|
@@ -57,11 +65,13 @@ const generateCode = (node, failOnForbidden, transformIdentifier) => {
|
|
|
57
65
|
const object = generateCode(
|
|
58
66
|
node.object,
|
|
59
67
|
failOnForbidden,
|
|
68
|
+
effectful,
|
|
60
69
|
transformIdentifier
|
|
61
70
|
);
|
|
62
71
|
const property = generateCode(
|
|
63
72
|
node.property,
|
|
64
73
|
failOnForbidden,
|
|
74
|
+
effectful,
|
|
65
75
|
transformIdentifier
|
|
66
76
|
);
|
|
67
77
|
return `${object}.${property}`;
|
|
@@ -73,6 +83,7 @@ const generateCode = (node, failOnForbidden, transformIdentifier) => {
|
|
|
73
83
|
const arg = generateCode(
|
|
74
84
|
node.argument,
|
|
75
85
|
failOnForbidden,
|
|
86
|
+
effectful,
|
|
76
87
|
transformIdentifier
|
|
77
88
|
);
|
|
78
89
|
return `${node.operator}${arg}`;
|
|
@@ -81,18 +92,25 @@ const generateCode = (node, failOnForbidden, transformIdentifier) => {
|
|
|
81
92
|
const left = generateCode(
|
|
82
93
|
node.left,
|
|
83
94
|
failOnForbidden,
|
|
95
|
+
effectful,
|
|
84
96
|
transformIdentifier
|
|
85
97
|
);
|
|
86
98
|
const right = generateCode(
|
|
87
99
|
node.right,
|
|
88
100
|
failOnForbidden,
|
|
101
|
+
effectful,
|
|
89
102
|
transformIdentifier
|
|
90
103
|
);
|
|
91
104
|
return `${left} ${node.operator} ${right}`;
|
|
92
105
|
}
|
|
93
106
|
if (node.type === "ArrayExpression") {
|
|
94
107
|
const elements = node.elements.map(
|
|
95
|
-
(element) => generateCode(
|
|
108
|
+
(element) => generateCode(
|
|
109
|
+
element,
|
|
110
|
+
failOnForbidden,
|
|
111
|
+
effectful,
|
|
112
|
+
transformIdentifier
|
|
113
|
+
)
|
|
96
114
|
);
|
|
97
115
|
return `[${elements.join(", ")}]`;
|
|
98
116
|
}
|
|
@@ -101,6 +119,7 @@ const generateCode = (node, failOnForbidden, transformIdentifier) => {
|
|
|
101
119
|
const callee2 = generateCode(
|
|
102
120
|
node.callee,
|
|
103
121
|
false,
|
|
122
|
+
effectful,
|
|
104
123
|
transformIdentifier
|
|
105
124
|
);
|
|
106
125
|
throw Error(`Cannot call "${callee2}"`);
|
|
@@ -108,10 +127,11 @@ const generateCode = (node, failOnForbidden, transformIdentifier) => {
|
|
|
108
127
|
const callee = generateCode(
|
|
109
128
|
node.callee,
|
|
110
129
|
failOnForbidden,
|
|
130
|
+
effectful,
|
|
111
131
|
transformIdentifier
|
|
112
132
|
);
|
|
113
133
|
const args = node.arguments.map(
|
|
114
|
-
(arg) => generateCode(arg, failOnForbidden, transformIdentifier)
|
|
134
|
+
(arg) => generateCode(arg, failOnForbidden, effectful, transformIdentifier)
|
|
115
135
|
);
|
|
116
136
|
return `${callee}(${args.join(", ")})`;
|
|
117
137
|
}
|
|
@@ -127,12 +147,38 @@ const generateCode = (node, failOnForbidden, transformIdentifier) => {
|
|
|
127
147
|
if (node.type === "Compound") {
|
|
128
148
|
throw Error("Cannot use multiple expressions");
|
|
129
149
|
}
|
|
150
|
+
if (node.type === "AssignmentExpression") {
|
|
151
|
+
if (node.operator !== "=") {
|
|
152
|
+
throw Error(`Only "=" assignment operator is supported`);
|
|
153
|
+
}
|
|
154
|
+
if (effectful === false) {
|
|
155
|
+
throw Error(`Cannot use assignment in this expression`);
|
|
156
|
+
}
|
|
157
|
+
const left = generateCode(
|
|
158
|
+
node.left,
|
|
159
|
+
failOnForbidden,
|
|
160
|
+
effectful,
|
|
161
|
+
// override and mark all identifiers inside of left expression as assignee
|
|
162
|
+
(id) => transformIdentifier(id, true)
|
|
163
|
+
);
|
|
164
|
+
const right = generateCode(
|
|
165
|
+
node.right,
|
|
166
|
+
failOnForbidden,
|
|
167
|
+
effectful,
|
|
168
|
+
transformIdentifier
|
|
169
|
+
);
|
|
170
|
+
return `${left} ${node.operator} ${right}`;
|
|
171
|
+
}
|
|
172
|
+
if (node.type === "UpdateExpression") {
|
|
173
|
+
throw Error(`"${node.operator}" operator is not supported`);
|
|
174
|
+
}
|
|
130
175
|
node;
|
|
131
176
|
return "";
|
|
132
177
|
};
|
|
133
|
-
const validateExpression = (code,
|
|
178
|
+
const validateExpression = (code, options) => {
|
|
179
|
+
const { effectful = false, transformIdentifier = (id) => id } = options ?? {};
|
|
134
180
|
const expression = (0, import_jsep.default)(code);
|
|
135
|
-
return generateCode(expression, true, transformIdentifier);
|
|
181
|
+
return generateCode(expression, true, effectful, transformIdentifier);
|
|
136
182
|
};
|
|
137
183
|
const sortTopologically = (list, depsById, explored = /* @__PURE__ */ new Set(), sorted = []) => {
|
|
138
184
|
for (const id of list) {
|
|
@@ -148,19 +194,23 @@ const sortTopologically = (list, depsById, explored = /* @__PURE__ */ new Set(),
|
|
|
148
194
|
}
|
|
149
195
|
return sorted;
|
|
150
196
|
};
|
|
151
|
-
const
|
|
197
|
+
const generateComputingExpressions = (expressions, allowedVariables) => {
|
|
152
198
|
const depsById = /* @__PURE__ */ new Map();
|
|
199
|
+
const inputVariables = /* @__PURE__ */ new Set();
|
|
153
200
|
for (const [id, code] of expressions) {
|
|
154
201
|
const deps = /* @__PURE__ */ new Set();
|
|
155
|
-
validateExpression(code,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
202
|
+
validateExpression(code, {
|
|
203
|
+
transformIdentifier: (identifier) => {
|
|
204
|
+
if (allowedVariables.has(identifier)) {
|
|
205
|
+
inputVariables.add(identifier);
|
|
206
|
+
return identifier;
|
|
207
|
+
}
|
|
208
|
+
if (expressions.has(identifier)) {
|
|
209
|
+
deps.add(identifier);
|
|
210
|
+
return identifier;
|
|
211
|
+
}
|
|
212
|
+
throw Error(`Unknown dependency "${identifier}"`);
|
|
162
213
|
}
|
|
163
|
-
throw Error(`Unknown dependency "${identifier}"`);
|
|
164
214
|
});
|
|
165
215
|
depsById.set(id, deps);
|
|
166
216
|
}
|
|
@@ -169,7 +219,7 @@ const generateExpressionsComputation = (variables, expressions) => {
|
|
|
169
219
|
depsById
|
|
170
220
|
);
|
|
171
221
|
let generatedCode = "";
|
|
172
|
-
for (const id of
|
|
222
|
+
for (const id of inputVariables) {
|
|
173
223
|
generatedCode += `const ${id} = _variables.get('${id}');
|
|
174
224
|
`;
|
|
175
225
|
}
|
|
@@ -190,10 +240,58 @@ const generateExpressionsComputation = (variables, expressions) => {
|
|
|
190
240
|
generatedCode += `]);`;
|
|
191
241
|
return generatedCode;
|
|
192
242
|
};
|
|
193
|
-
const
|
|
194
|
-
const generatedCode =
|
|
195
|
-
|
|
196
|
-
|
|
243
|
+
const executeComputingExpressions = (expressions, variables) => {
|
|
244
|
+
const generatedCode = generateComputingExpressions(
|
|
245
|
+
expressions,
|
|
246
|
+
new Set(variables.keys())
|
|
247
|
+
);
|
|
248
|
+
const executeFn = new Function("_variables", generatedCode);
|
|
249
|
+
const values = executeFn(variables);
|
|
250
|
+
return values;
|
|
251
|
+
};
|
|
252
|
+
const generateEffectfulExpression = (code, allowedVariables) => {
|
|
253
|
+
const inputVariables = /* @__PURE__ */ new Set();
|
|
254
|
+
const outputVariables = /* @__PURE__ */ new Set();
|
|
255
|
+
validateExpression(code, {
|
|
256
|
+
effectful: true,
|
|
257
|
+
transformIdentifier: (identifier, assignee) => {
|
|
258
|
+
if (allowedVariables.has(identifier)) {
|
|
259
|
+
if (assignee) {
|
|
260
|
+
outputVariables.add(identifier);
|
|
261
|
+
} else {
|
|
262
|
+
inputVariables.add(identifier);
|
|
263
|
+
}
|
|
264
|
+
return identifier;
|
|
265
|
+
}
|
|
266
|
+
throw Error(`Unknown dependency "${identifier}"`);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
let generatedCode = "";
|
|
270
|
+
for (const id of inputVariables) {
|
|
271
|
+
generatedCode += `let ${id} = _variables.get('${id}');
|
|
272
|
+
`;
|
|
273
|
+
}
|
|
274
|
+
for (const id of outputVariables) {
|
|
275
|
+
if (inputVariables.has(id) === false) {
|
|
276
|
+
generatedCode += `let ${id};
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
generatedCode += `${code};
|
|
281
|
+
`;
|
|
282
|
+
generatedCode += `return new Map([
|
|
283
|
+
`;
|
|
284
|
+
for (const id of outputVariables) {
|
|
285
|
+
generatedCode += ` ['${id}', ${id}],
|
|
286
|
+
`;
|
|
287
|
+
}
|
|
288
|
+
generatedCode += `]);`;
|
|
289
|
+
return generatedCode;
|
|
290
|
+
};
|
|
291
|
+
const executeEffectfulExpression = (code, variables) => {
|
|
292
|
+
const generatedCode = generateEffectfulExpression(
|
|
293
|
+
code,
|
|
294
|
+
new Set(variables.keys())
|
|
197
295
|
);
|
|
198
296
|
const executeFn = new Function("_variables", generatedCode);
|
|
199
297
|
const values = executeFn(variables);
|
|
@@ -204,6 +302,13 @@ const encodeDataSourceVariable = (id) => {
|
|
|
204
302
|
const encoded = id.replaceAll("-", "__DASH__");
|
|
205
303
|
return `${dataSourceVariablePrefix}${encoded}`;
|
|
206
304
|
};
|
|
305
|
+
const encodeVariablesMap = (values) => {
|
|
306
|
+
const encodedValues = /* @__PURE__ */ new Map();
|
|
307
|
+
for (const [id, value] of values) {
|
|
308
|
+
encodedValues.set(encodeDataSourceVariable(id), value);
|
|
309
|
+
}
|
|
310
|
+
return encodedValues;
|
|
311
|
+
};
|
|
207
312
|
const decodeDataSourceVariable = (name) => {
|
|
208
313
|
if (name.startsWith(dataSourceVariablePrefix)) {
|
|
209
314
|
const encoded = name.slice(dataSourceVariablePrefix.length);
|
|
@@ -211,3 +316,13 @@ const decodeDataSourceVariable = (name) => {
|
|
|
211
316
|
}
|
|
212
317
|
return;
|
|
213
318
|
};
|
|
319
|
+
const decodeVariablesMap = (values) => {
|
|
320
|
+
const decodedValues = /* @__PURE__ */ new Map();
|
|
321
|
+
for (const [name, value] of values) {
|
|
322
|
+
const id = decodeDataSourceVariable(name);
|
|
323
|
+
if (id !== void 0) {
|
|
324
|
+
decodedValues.set(id, value);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return decodedValues;
|
|
328
|
+
};
|
package/lib/cjs/index.js
CHANGED
|
@@ -22,10 +22,14 @@ __export(src_exports, {
|
|
|
22
22
|
ReactSdkContext: () => import_context.ReactSdkContext,
|
|
23
23
|
componentCategories: () => import_component_meta.componentCategories,
|
|
24
24
|
decodeDataSourceVariable: () => import_expression.decodeDataSourceVariable,
|
|
25
|
+
decodeVariablesMap: () => import_expression.decodeVariablesMap,
|
|
25
26
|
defaultStates: () => import_component_meta.defaultStates,
|
|
26
27
|
encodeDataSourceVariable: () => import_expression.encodeDataSourceVariable,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
encodeVariablesMap: () => import_expression.encodeVariablesMap,
|
|
29
|
+
executeComputingExpressions: () => import_expression.executeComputingExpressions,
|
|
30
|
+
executeEffectfulExpression: () => import_expression.executeEffectfulExpression,
|
|
31
|
+
generateComputingExpressions: () => import_expression.generateComputingExpressions,
|
|
32
|
+
generateEffectfulExpression: () => import_expression.generateEffectfulExpression,
|
|
29
33
|
getInstanceIdFromComponentProps: () => import_props.getInstanceIdFromComponentProps,
|
|
30
34
|
stateCategories: () => import_component_meta.stateCategories,
|
|
31
35
|
useInstanceProps: () => import_props.useInstanceProps,
|
package/lib/cjs/props.js
CHANGED
|
@@ -44,7 +44,13 @@ const getPropsByInstanceId = (props) => {
|
|
|
44
44
|
return propsByInstanceId;
|
|
45
45
|
};
|
|
46
46
|
const useInstanceProps = (instanceId) => {
|
|
47
|
-
const {
|
|
47
|
+
const {
|
|
48
|
+
propsByInstanceIdStore,
|
|
49
|
+
dataSourceValuesStore,
|
|
50
|
+
executeEffectfulExpression,
|
|
51
|
+
setDataSourceValues,
|
|
52
|
+
renderer
|
|
53
|
+
} = (0, import_react.useContext)(import_context.ReactSdkContext);
|
|
48
54
|
const instancePropsObjectStore = (0, import_react.useMemo)(() => {
|
|
49
55
|
return (0, import_nanostores.computed)(
|
|
50
56
|
[propsByInstanceIdStore, dataSourceValuesStore],
|
|
@@ -66,12 +72,36 @@ const useInstanceProps = (instanceId) => {
|
|
|
66
72
|
}
|
|
67
73
|
continue;
|
|
68
74
|
}
|
|
75
|
+
if (prop.type === "action") {
|
|
76
|
+
instancePropsObject2[prop.name] = () => {
|
|
77
|
+
if (renderer === "canvas") {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
for (const value of prop.value) {
|
|
81
|
+
if (value.type === "execute") {
|
|
82
|
+
const newValues = executeEffectfulExpression(
|
|
83
|
+
value.code,
|
|
84
|
+
dataSourceValues
|
|
85
|
+
);
|
|
86
|
+
setDataSourceValues(newValues);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
69
92
|
instancePropsObject2[prop.name] = prop.value;
|
|
70
93
|
}
|
|
71
94
|
return instancePropsObject2;
|
|
72
95
|
}
|
|
73
96
|
);
|
|
74
|
-
}, [
|
|
97
|
+
}, [
|
|
98
|
+
propsByInstanceIdStore,
|
|
99
|
+
dataSourceValuesStore,
|
|
100
|
+
instanceId,
|
|
101
|
+
renderer,
|
|
102
|
+
executeEffectfulExpression,
|
|
103
|
+
setDataSourceValues
|
|
104
|
+
]);
|
|
75
105
|
const instancePropsObject = (0, import_react2.useStore)(instancePropsObjectStore);
|
|
76
106
|
return instancePropsObject;
|
|
77
107
|
};
|
|
@@ -35,6 +35,7 @@ const createElementsTree = ({
|
|
|
35
35
|
assetsStore,
|
|
36
36
|
pagesStore,
|
|
37
37
|
dataSourceValuesStore,
|
|
38
|
+
executeEffectfulExpression,
|
|
38
39
|
onDataSourceUpdate,
|
|
39
40
|
Component,
|
|
40
41
|
components
|
|
@@ -75,7 +76,9 @@ const createElementsTree = ({
|
|
|
75
76
|
renderer,
|
|
76
77
|
imageBaseUrl,
|
|
77
78
|
assetBaseUrl,
|
|
78
|
-
|
|
79
|
+
executeEffectfulExpression,
|
|
80
|
+
setDataSourceValues: onDataSourceUpdate,
|
|
81
|
+
setBoundDataSourceValue: (instanceId, propName, value) => {
|
|
79
82
|
const propsByInstanceId = propsByInstanceIdStore.get();
|
|
80
83
|
const props = propsByInstanceId.get(instanceId);
|
|
81
84
|
const prop = props?.find((prop2) => prop2.name === propName);
|
|
@@ -83,7 +86,9 @@ const createElementsTree = ({
|
|
|
83
86
|
throw Error(`${propName} is not data source`);
|
|
84
87
|
}
|
|
85
88
|
const dataSourceId = prop.value;
|
|
86
|
-
|
|
89
|
+
const newValues = /* @__PURE__ */ new Map();
|
|
90
|
+
newValues.set(dataSourceId, value);
|
|
91
|
+
onDataSourceUpdate(newValues);
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
children: root
|
package/lib/cjs/tree/root.js
CHANGED
|
@@ -28,7 +28,8 @@ var import_webstudio_component = require("./webstudio-component");
|
|
|
28
28
|
var import_props = require("../props");
|
|
29
29
|
const InstanceRoot = ({
|
|
30
30
|
data,
|
|
31
|
-
|
|
31
|
+
executeComputingExpressions,
|
|
32
|
+
executeEffectfulExpression,
|
|
32
33
|
Component,
|
|
33
34
|
components
|
|
34
35
|
}) => {
|
|
@@ -50,7 +51,7 @@ const InstanceRoot = ({
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
try {
|
|
53
|
-
const result =
|
|
54
|
+
const result = executeComputingExpressions(dataSourceValues);
|
|
54
55
|
for (const [id, value] of result) {
|
|
55
56
|
dataSourceValues.set(id, value);
|
|
56
57
|
}
|
|
@@ -62,6 +63,16 @@ const InstanceRoot = ({
|
|
|
62
63
|
);
|
|
63
64
|
}
|
|
64
65
|
const dataSourceValuesStore = dataSourceValuesStoreRef.current;
|
|
66
|
+
const onDataSourceUpdate = (0, import_react.useCallback)(
|
|
67
|
+
(newValues) => {
|
|
68
|
+
const dataSourceVariables = new Map(dataSourceVariablesStore.get());
|
|
69
|
+
for (const [dataSourceId, value] of newValues) {
|
|
70
|
+
dataSourceVariables.set(dataSourceId, value);
|
|
71
|
+
}
|
|
72
|
+
dataSourceVariablesStore.set(dataSourceVariables);
|
|
73
|
+
},
|
|
74
|
+
[dataSourceVariablesStore]
|
|
75
|
+
);
|
|
65
76
|
return (0, import_create_elements_tree.createElementsTree)({
|
|
66
77
|
imageBaseUrl: data.params?.imageBaseUrl ?? "/",
|
|
67
78
|
assetBaseUrl: data.params?.assetBaseUrl ?? "/",
|
|
@@ -72,12 +83,9 @@ const InstanceRoot = ({
|
|
|
72
83
|
),
|
|
73
84
|
assetsStore: (0, import_nanostores.atom)(new Map(data.assets.map((asset) => [asset.id, asset]))),
|
|
74
85
|
pagesStore: (0, import_nanostores.atom)(new Map(data.pages.map((page) => [page.id, page]))),
|
|
86
|
+
executeEffectfulExpression,
|
|
75
87
|
dataSourceValuesStore,
|
|
76
|
-
onDataSourceUpdate
|
|
77
|
-
const dataSourceVariables = new Map(dataSourceVariablesStore.get());
|
|
78
|
-
dataSourceVariables.set(dataSourceId, value);
|
|
79
|
-
dataSourceVariablesStore.set(dataSourceVariables);
|
|
80
|
-
},
|
|
88
|
+
onDataSourceUpdate,
|
|
81
89
|
Component: Component ?? import_webstudio_component.WebstudioComponent,
|
|
82
90
|
components
|
|
83
91
|
});
|
package/lib/context.js
CHANGED
|
@@ -7,8 +7,14 @@ const ReactSdkContext = createContext({
|
|
|
7
7
|
assetsStore: atom(/* @__PURE__ */ new Map()),
|
|
8
8
|
pagesStore: atom(/* @__PURE__ */ new Map()),
|
|
9
9
|
dataSourceValuesStore: atom(/* @__PURE__ */ new Map()),
|
|
10
|
-
|
|
11
|
-
throw Error("React SDK
|
|
10
|
+
executeEffectfulExpression: () => {
|
|
11
|
+
throw Error("React SDK executeEffectfulExpression is not implemented");
|
|
12
|
+
},
|
|
13
|
+
setDataSourceValues: () => {
|
|
14
|
+
throw Error("React SDK setBoundDataSourceValue is not implemented");
|
|
15
|
+
},
|
|
16
|
+
setBoundDataSourceValue: () => {
|
|
17
|
+
throw Error("React SDK setBoundDataSourceValue is not implemented");
|
|
12
18
|
}
|
|
13
19
|
});
|
|
14
20
|
export {
|
package/lib/css/normalize.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { borders, outline } from "./presets";
|
|
2
2
|
const boxSizing = {
|
|
3
3
|
property: "boxSizing",
|
|
4
4
|
value: { type: "keyword", value: "border-box" }
|
|
5
5
|
};
|
|
6
|
-
const baseStyle = [
|
|
7
|
-
boxSizing,
|
|
8
|
-
...presets.borders,
|
|
9
|
-
...presets.outline
|
|
10
|
-
];
|
|
6
|
+
const baseStyle = [boxSizing, ...borders, ...outline];
|
|
11
7
|
const div = baseStyle;
|
|
12
8
|
const address = baseStyle;
|
|
13
9
|
const article = baseStyle;
|
|
14
10
|
const aside = baseStyle;
|
|
15
|
-
const
|
|
16
|
-
...baseStyle,
|
|
17
|
-
...presets.blockquote
|
|
18
|
-
];
|
|
19
|
-
const figure = [...baseStyle, ...presets.margins];
|
|
11
|
+
const figure = baseStyle;
|
|
20
12
|
const footer = baseStyle;
|
|
21
13
|
const header = baseStyle;
|
|
22
14
|
const main = baseStyle;
|
|
@@ -24,19 +16,19 @@ const nav = baseStyle;
|
|
|
24
16
|
const section = baseStyle;
|
|
25
17
|
const form = baseStyle;
|
|
26
18
|
const label = baseStyle;
|
|
27
|
-
const h1 =
|
|
28
|
-
const h2 =
|
|
29
|
-
const h3 =
|
|
30
|
-
const h4 =
|
|
31
|
-
const h5 =
|
|
32
|
-
const h6 =
|
|
19
|
+
const h1 = baseStyle;
|
|
20
|
+
const h2 = baseStyle;
|
|
21
|
+
const h3 = baseStyle;
|
|
22
|
+
const h4 = baseStyle;
|
|
23
|
+
const h5 = baseStyle;
|
|
24
|
+
const h6 = baseStyle;
|
|
33
25
|
const i = baseStyle;
|
|
34
26
|
const img = baseStyle;
|
|
35
27
|
const a = baseStyle;
|
|
36
28
|
const li = baseStyle;
|
|
37
29
|
const ul = baseStyle;
|
|
38
30
|
const ol = baseStyle;
|
|
39
|
-
const p =
|
|
31
|
+
const p = baseStyle;
|
|
40
32
|
const span = baseStyle;
|
|
41
33
|
const html = [
|
|
42
34
|
/* 1 */
|
|
@@ -55,7 +47,7 @@ const html = [
|
|
|
55
47
|
value: { type: "unit", value: 4, unit: "number" }
|
|
56
48
|
},
|
|
57
49
|
boxSizing,
|
|
58
|
-
...
|
|
50
|
+
...borders
|
|
59
51
|
];
|
|
60
52
|
const body = [
|
|
61
53
|
/* 1 */
|
|
@@ -80,7 +72,7 @@ const body = [
|
|
|
80
72
|
property: "fontFamily",
|
|
81
73
|
value: {
|
|
82
74
|
type: "keyword",
|
|
83
|
-
value: "Arial, sans-serif"
|
|
75
|
+
value: "Arial, Roboto, sans-serif"
|
|
84
76
|
}
|
|
85
77
|
},
|
|
86
78
|
{
|
|
@@ -92,7 +84,7 @@ const body = [
|
|
|
92
84
|
value: { type: "unit", unit: "number", value: 1.2 }
|
|
93
85
|
},
|
|
94
86
|
boxSizing,
|
|
95
|
-
...
|
|
87
|
+
...borders
|
|
96
88
|
];
|
|
97
89
|
const hr = [
|
|
98
90
|
/* 1 */
|
|
@@ -106,8 +98,7 @@ const hr = [
|
|
|
106
98
|
value: { type: "keyword", value: "inherit" }
|
|
107
99
|
},
|
|
108
100
|
boxSizing,
|
|
109
|
-
...
|
|
110
|
-
...presets.margins
|
|
101
|
+
...borders
|
|
111
102
|
];
|
|
112
103
|
const b = [
|
|
113
104
|
{
|
|
@@ -115,7 +106,7 @@ const b = [
|
|
|
115
106
|
value: { type: "keyword", value: "700" }
|
|
116
107
|
},
|
|
117
108
|
boxSizing,
|
|
118
|
-
...
|
|
109
|
+
...borders
|
|
119
110
|
];
|
|
120
111
|
const strong = b;
|
|
121
112
|
const code = [
|
|
@@ -133,7 +124,7 @@ const code = [
|
|
|
133
124
|
value: { type: "unit", value: 1, unit: "em" }
|
|
134
125
|
},
|
|
135
126
|
boxSizing,
|
|
136
|
-
...
|
|
127
|
+
...borders
|
|
137
128
|
];
|
|
138
129
|
const kbd = code;
|
|
139
130
|
const samp = code;
|
|
@@ -144,7 +135,7 @@ const small = [
|
|
|
144
135
|
value: { type: "unit", value: 80, unit: "%" }
|
|
145
136
|
},
|
|
146
137
|
boxSizing,
|
|
147
|
-
...
|
|
138
|
+
...borders
|
|
148
139
|
];
|
|
149
140
|
const subSupBase = [
|
|
150
141
|
{
|
|
@@ -164,7 +155,7 @@ const subSupBase = [
|
|
|
164
155
|
value: { type: "keyword", value: "baseline" }
|
|
165
156
|
},
|
|
166
157
|
boxSizing,
|
|
167
|
-
...
|
|
158
|
+
...borders
|
|
168
159
|
];
|
|
169
160
|
const sub = [
|
|
170
161
|
...subSupBase,
|
|
@@ -186,7 +177,7 @@ const table = [
|
|
|
186
177
|
property: "textIndent",
|
|
187
178
|
value: { type: "unit", value: 0, unit: "number" }
|
|
188
179
|
},
|
|
189
|
-
...
|
|
180
|
+
...borders,
|
|
190
181
|
/* 2 */
|
|
191
182
|
{
|
|
192
183
|
property: "borderTopColor",
|
|
@@ -238,7 +229,7 @@ const buttonBase = [
|
|
|
238
229
|
value: { type: "unit", value: 0, unit: "number" }
|
|
239
230
|
},
|
|
240
231
|
boxSizing,
|
|
241
|
-
...
|
|
232
|
+
...borders
|
|
242
233
|
];
|
|
243
234
|
const input = buttonBase;
|
|
244
235
|
const optgroup = buttonBase;
|
|
@@ -269,7 +260,7 @@ const legend = [
|
|
|
269
260
|
value: { type: "unit", value: 0, unit: "number" }
|
|
270
261
|
},
|
|
271
262
|
boxSizing,
|
|
272
|
-
...
|
|
263
|
+
...borders
|
|
273
264
|
];
|
|
274
265
|
const progress = [
|
|
275
266
|
{
|
|
@@ -277,7 +268,7 @@ const progress = [
|
|
|
277
268
|
value: { type: "keyword", value: "baseline" }
|
|
278
269
|
},
|
|
279
270
|
boxSizing,
|
|
280
|
-
...
|
|
271
|
+
...borders
|
|
281
272
|
];
|
|
282
273
|
const summary = [
|
|
283
274
|
{
|
|
@@ -285,7 +276,7 @@ const summary = [
|
|
|
285
276
|
value: { type: "keyword", value: "list-item" }
|
|
286
277
|
},
|
|
287
278
|
boxSizing,
|
|
288
|
-
...
|
|
279
|
+
...borders
|
|
289
280
|
];
|
|
290
281
|
export {
|
|
291
282
|
a,
|
|
@@ -293,7 +284,6 @@ export {
|
|
|
293
284
|
article,
|
|
294
285
|
aside,
|
|
295
286
|
b,
|
|
296
|
-
blockquote,
|
|
297
287
|
body,
|
|
298
288
|
button,
|
|
299
289
|
code,
|