@webstudio-is/sdk 0.0.0-c1d6247 → 0.0.0-ca00e2a
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/__generated__/normalize.css.js +247 -151
- package/lib/core-templates.js +40 -36
- package/lib/index.js +788 -378
- package/lib/runtime.js +17 -1
- package/lib/types/__generated__/normalize.css.d.ts +2 -2
- package/lib/types/core-metas.d.ts +371 -89
- package/lib/types/css.d.ts +31 -0
- package/lib/types/css.test.d.ts +1 -0
- package/lib/types/expression.d.ts +7 -5
- package/lib/types/index.d.ts +3 -1
- package/lib/types/instances-utils.d.ts +3 -0
- package/lib/types/runtime.d.ts +5 -0
- package/lib/types/schema/animation-schema.d.ts +53844 -0
- package/lib/types/schema/assets.d.ts +12 -84
- package/lib/types/schema/breakpoints.d.ts +8 -8
- package/lib/types/schema/component-meta.d.ts +11162 -995
- package/lib/types/schema/data-sources.d.ts +18 -18
- package/lib/types/schema/deployment.d.ts +4 -4
- package/lib/types/schema/instances.d.ts +14 -217
- package/lib/types/schema/pages.d.ts +147 -146
- package/lib/types/schema/prop-meta.d.ts +105 -39
- package/lib/types/schema/props.d.ts +36858 -20
- package/lib/types/schema/resources.d.ts +4 -4
- package/lib/types/schema/styles.d.ts +4903 -1239
- package/lib/types/schema/webstudio.d.ts +23143 -783
- package/package.json +10 -9
- package/lib/types/schema/embed-template.d.ts +0 -2250
package/lib/index.js
CHANGED
|
@@ -57,7 +57,7 @@ var commonPageFields = {
|
|
|
57
57
|
title: PageTitle,
|
|
58
58
|
history: z2.optional(z2.array(z2.string())),
|
|
59
59
|
rootInstanceId: z2.string(),
|
|
60
|
-
systemDataSourceId: z2.string(),
|
|
60
|
+
systemDataSourceId: z2.string().optional(),
|
|
61
61
|
meta: z2.object({
|
|
62
62
|
description: z2.string().optional(),
|
|
63
63
|
title: z2.string().optional(),
|
|
@@ -88,7 +88,7 @@ var HomePage = z2.object({
|
|
|
88
88
|
...commonPageFields,
|
|
89
89
|
path: HomePagePath
|
|
90
90
|
});
|
|
91
|
-
var
|
|
91
|
+
var DefaultPagePage = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
|
|
92
92
|
(path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
|
|
93
93
|
"Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
|
|
94
94
|
).refine(
|
|
@@ -101,6 +101,14 @@ var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refin
|
|
|
101
101
|
(path) => path !== "/build" && path.startsWith("/build/") === false,
|
|
102
102
|
"/build prefix is reserved for the system"
|
|
103
103
|
);
|
|
104
|
+
var PagePath = DefaultPagePage.refine(
|
|
105
|
+
(path) => path === "" || path.startsWith("/"),
|
|
106
|
+
"Must start with a / or a full URL e.g. https://website.org"
|
|
107
|
+
);
|
|
108
|
+
var OldPagePath = DefaultPagePage.refine(
|
|
109
|
+
(path) => path === "" || path.startsWith("/"),
|
|
110
|
+
"Must start with a / and it must be full path e.g. /project/id"
|
|
111
|
+
);
|
|
104
112
|
var Page = z2.object({
|
|
105
113
|
...commonPageFields,
|
|
106
114
|
path: PagePath
|
|
@@ -164,29 +172,11 @@ var Instance = z3.object({
|
|
|
164
172
|
type: z3.literal("instance"),
|
|
165
173
|
id: InstanceId,
|
|
166
174
|
component: z3.string(),
|
|
175
|
+
tag: z3.string().optional(),
|
|
167
176
|
label: z3.string().optional(),
|
|
168
177
|
children: z3.array(InstanceChild)
|
|
169
178
|
});
|
|
170
179
|
var Instances = z3.map(InstanceId, Instance);
|
|
171
|
-
var MatcherRelation = z3.union([
|
|
172
|
-
z3.literal("ancestor"),
|
|
173
|
-
z3.literal("parent"),
|
|
174
|
-
z3.literal("self"),
|
|
175
|
-
z3.literal("child"),
|
|
176
|
-
z3.literal("descendant")
|
|
177
|
-
]);
|
|
178
|
-
var MatcherOperation = z3.object({
|
|
179
|
-
$eq: z3.string().optional(),
|
|
180
|
-
$neq: z3.string().optional(),
|
|
181
|
-
$in: z3.array(z3.string()).optional(),
|
|
182
|
-
$nin: z3.array(z3.string()).optional()
|
|
183
|
-
});
|
|
184
|
-
var Matcher = z3.object({
|
|
185
|
-
relation: MatcherRelation,
|
|
186
|
-
component: MatcherOperation.optional(),
|
|
187
|
-
tag: MatcherOperation.optional()
|
|
188
|
-
});
|
|
189
|
-
var Matchers = z3.union([Matcher, z3.array(Matcher)]);
|
|
190
180
|
|
|
191
181
|
// src/schema/data-sources.ts
|
|
192
182
|
import { z as z4 } from "zod";
|
|
@@ -218,20 +208,25 @@ var DataSource = z4.union([
|
|
|
218
208
|
z4.object({
|
|
219
209
|
type: z4.literal("variable"),
|
|
220
210
|
id: DataSourceId,
|
|
221
|
-
|
|
211
|
+
// The instance should always be specified for variables,
|
|
212
|
+
// however, there was a bug in the embed template
|
|
213
|
+
// which produced variables without an instance
|
|
214
|
+
// and these variables will fail validation
|
|
215
|
+
// if we make it required
|
|
216
|
+
scopeInstanceId: z4.string().optional(),
|
|
222
217
|
name: z4.string(),
|
|
223
218
|
value: DataSourceVariableValue
|
|
224
219
|
}),
|
|
225
220
|
z4.object({
|
|
226
221
|
type: z4.literal("parameter"),
|
|
227
222
|
id: DataSourceId,
|
|
228
|
-
scopeInstanceId: z4.string(),
|
|
223
|
+
scopeInstanceId: z4.string().optional(),
|
|
229
224
|
name: z4.string()
|
|
230
225
|
}),
|
|
231
226
|
z4.object({
|
|
232
227
|
type: z4.literal("resource"),
|
|
233
228
|
id: DataSourceId,
|
|
234
|
-
scopeInstanceId: z4.string(),
|
|
229
|
+
scopeInstanceId: z4.string().optional(),
|
|
235
230
|
name: z4.string(),
|
|
236
231
|
resourceId: z4.string()
|
|
237
232
|
})
|
|
@@ -274,98 +269,280 @@ var ResourceRequest = z5.object({
|
|
|
274
269
|
var Resources = z5.map(ResourceId, Resource);
|
|
275
270
|
|
|
276
271
|
// src/schema/props.ts
|
|
272
|
+
import { z as z7 } from "zod";
|
|
273
|
+
|
|
274
|
+
// src/schema/animation-schema.ts
|
|
275
|
+
import { StyleValue } from "@webstudio-is/css-engine";
|
|
277
276
|
import { z as z6 } from "zod";
|
|
278
|
-
var
|
|
277
|
+
var literalUnion = (arr) => z6.union(
|
|
278
|
+
arr.map((val) => z6.literal(val))
|
|
279
|
+
);
|
|
280
|
+
var RANGE_UNITS = [
|
|
281
|
+
"%",
|
|
282
|
+
"px",
|
|
283
|
+
"cm",
|
|
284
|
+
"mm",
|
|
285
|
+
"q",
|
|
286
|
+
"in",
|
|
287
|
+
"pt",
|
|
288
|
+
"pc",
|
|
289
|
+
"em",
|
|
290
|
+
"rem",
|
|
291
|
+
"ex",
|
|
292
|
+
"rex",
|
|
293
|
+
"cap",
|
|
294
|
+
"rcap",
|
|
295
|
+
"ch",
|
|
296
|
+
"rch",
|
|
297
|
+
"lh",
|
|
298
|
+
"rlh",
|
|
299
|
+
"vw",
|
|
300
|
+
"svw",
|
|
301
|
+
"lvw",
|
|
302
|
+
"dvw",
|
|
303
|
+
"vh",
|
|
304
|
+
"svh",
|
|
305
|
+
"lvh",
|
|
306
|
+
"dvh",
|
|
307
|
+
"vi",
|
|
308
|
+
"svi",
|
|
309
|
+
"lvi",
|
|
310
|
+
"dvi",
|
|
311
|
+
"vb",
|
|
312
|
+
"svb",
|
|
313
|
+
"lvb",
|
|
314
|
+
"dvb",
|
|
315
|
+
"vmin",
|
|
316
|
+
"svmin",
|
|
317
|
+
"lvmin",
|
|
318
|
+
"dvmin",
|
|
319
|
+
"vmax",
|
|
320
|
+
"svmax",
|
|
321
|
+
"lvmax",
|
|
322
|
+
"dvmax"
|
|
323
|
+
];
|
|
324
|
+
var rangeUnitSchema = literalUnion(RANGE_UNITS);
|
|
325
|
+
var rangeUnitValueSchema = z6.union([
|
|
326
|
+
z6.object({
|
|
327
|
+
type: z6.literal("unit"),
|
|
328
|
+
value: z6.number(),
|
|
329
|
+
unit: rangeUnitSchema
|
|
330
|
+
}),
|
|
331
|
+
z6.object({
|
|
332
|
+
type: z6.literal("unparsed"),
|
|
333
|
+
value: z6.string()
|
|
334
|
+
}),
|
|
335
|
+
z6.object({
|
|
336
|
+
type: z6.literal("var"),
|
|
337
|
+
value: z6.string()
|
|
338
|
+
})
|
|
339
|
+
]);
|
|
340
|
+
var TIME_UNITS = ["ms", "s"];
|
|
341
|
+
var timeUnitSchema = literalUnion(TIME_UNITS);
|
|
342
|
+
var durationUnitValueSchema = z6.union([
|
|
343
|
+
z6.object({
|
|
344
|
+
type: z6.literal("unit"),
|
|
345
|
+
value: z6.number(),
|
|
346
|
+
unit: timeUnitSchema
|
|
347
|
+
}),
|
|
348
|
+
z6.object({
|
|
349
|
+
type: z6.literal("var"),
|
|
350
|
+
value: z6.string()
|
|
351
|
+
})
|
|
352
|
+
]);
|
|
353
|
+
var insetUnitValueSchema = z6.union([
|
|
354
|
+
rangeUnitValueSchema,
|
|
355
|
+
z6.object({
|
|
356
|
+
type: z6.literal("keyword"),
|
|
357
|
+
value: z6.literal("auto")
|
|
358
|
+
})
|
|
359
|
+
]);
|
|
360
|
+
var keyframeStylesSchema = z6.record(StyleValue);
|
|
361
|
+
var animationKeyframeSchema = z6.object({
|
|
362
|
+
offset: z6.number().optional(),
|
|
363
|
+
styles: keyframeStylesSchema
|
|
364
|
+
});
|
|
365
|
+
var keyframeEffectOptionsSchema = z6.object({
|
|
366
|
+
easing: z6.string().optional(),
|
|
367
|
+
fill: z6.union([
|
|
368
|
+
z6.literal("none"),
|
|
369
|
+
z6.literal("forwards"),
|
|
370
|
+
z6.literal("backwards"),
|
|
371
|
+
z6.literal("both")
|
|
372
|
+
]).optional(),
|
|
373
|
+
// FillMode
|
|
374
|
+
duration: durationUnitValueSchema.optional()
|
|
375
|
+
});
|
|
376
|
+
var scrollNamedRangeSchema = z6.union([
|
|
377
|
+
z6.literal("start"),
|
|
378
|
+
z6.literal("end")
|
|
379
|
+
]);
|
|
380
|
+
var scrollRangeValueSchema = z6.tuple([
|
|
381
|
+
scrollNamedRangeSchema,
|
|
382
|
+
rangeUnitValueSchema
|
|
383
|
+
]);
|
|
384
|
+
var scrollRangeOptionsSchema = z6.object({
|
|
385
|
+
rangeStart: scrollRangeValueSchema.optional(),
|
|
386
|
+
rangeEnd: scrollRangeValueSchema.optional()
|
|
387
|
+
});
|
|
388
|
+
var animationAxisSchema = z6.union([
|
|
389
|
+
z6.literal("block"),
|
|
390
|
+
z6.literal("inline"),
|
|
391
|
+
z6.literal("x"),
|
|
392
|
+
z6.literal("y")
|
|
393
|
+
]);
|
|
394
|
+
var viewNamedRangeSchema = z6.union([
|
|
395
|
+
z6.literal("contain"),
|
|
396
|
+
z6.literal("cover"),
|
|
397
|
+
z6.literal("entry"),
|
|
398
|
+
z6.literal("exit"),
|
|
399
|
+
z6.literal("entry-crossing"),
|
|
400
|
+
z6.literal("exit-crossing")
|
|
401
|
+
]);
|
|
402
|
+
var viewRangeValueSchema = z6.tuple([
|
|
403
|
+
viewNamedRangeSchema,
|
|
404
|
+
rangeUnitValueSchema
|
|
405
|
+
]);
|
|
406
|
+
var viewRangeOptionsSchema = z6.object({
|
|
407
|
+
rangeStart: viewRangeValueSchema.optional(),
|
|
408
|
+
rangeEnd: viewRangeValueSchema.optional()
|
|
409
|
+
});
|
|
410
|
+
var baseAnimation = z6.object({
|
|
411
|
+
name: z6.string().optional(),
|
|
412
|
+
description: z6.string().optional(),
|
|
413
|
+
enabled: z6.array(z6.tuple([z6.string().describe("breakpointId"), z6.boolean()])).optional(),
|
|
414
|
+
keyframes: z6.array(animationKeyframeSchema)
|
|
415
|
+
});
|
|
416
|
+
var scrollAnimationSchema = baseAnimation.merge(
|
|
417
|
+
z6.object({
|
|
418
|
+
timing: keyframeEffectOptionsSchema.merge(scrollRangeOptionsSchema)
|
|
419
|
+
})
|
|
420
|
+
);
|
|
421
|
+
var scrollActionSchema = z6.object({
|
|
422
|
+
type: z6.literal("scroll"),
|
|
423
|
+
source: z6.union([z6.literal("closest"), z6.literal("nearest"), z6.literal("root")]).optional(),
|
|
424
|
+
axis: animationAxisSchema.optional(),
|
|
425
|
+
animations: z6.array(scrollAnimationSchema),
|
|
426
|
+
isPinned: z6.boolean().optional(),
|
|
427
|
+
debug: z6.boolean().optional()
|
|
428
|
+
});
|
|
429
|
+
var viewAnimationSchema = baseAnimation.merge(
|
|
430
|
+
z6.object({
|
|
431
|
+
timing: keyframeEffectOptionsSchema.merge(viewRangeOptionsSchema)
|
|
432
|
+
})
|
|
433
|
+
);
|
|
434
|
+
var viewActionSchema = z6.object({
|
|
435
|
+
type: z6.literal("view"),
|
|
436
|
+
subject: z6.string().optional(),
|
|
437
|
+
axis: animationAxisSchema.optional(),
|
|
438
|
+
animations: z6.array(viewAnimationSchema),
|
|
439
|
+
insetStart: insetUnitValueSchema.optional(),
|
|
440
|
+
insetEnd: insetUnitValueSchema.optional(),
|
|
441
|
+
isPinned: z6.boolean().optional(),
|
|
442
|
+
debug: z6.boolean().optional()
|
|
443
|
+
});
|
|
444
|
+
var animationActionSchema = z6.discriminatedUnion("type", [
|
|
445
|
+
scrollActionSchema,
|
|
446
|
+
viewActionSchema
|
|
447
|
+
]);
|
|
448
|
+
|
|
449
|
+
// src/schema/props.ts
|
|
450
|
+
var PropId = z7.string();
|
|
279
451
|
var baseProp = {
|
|
280
452
|
id: PropId,
|
|
281
|
-
instanceId:
|
|
282
|
-
name:
|
|
283
|
-
required:
|
|
453
|
+
instanceId: z7.string(),
|
|
454
|
+
name: z7.string(),
|
|
455
|
+
required: z7.optional(z7.boolean())
|
|
284
456
|
};
|
|
285
|
-
var Prop =
|
|
286
|
-
|
|
457
|
+
var Prop = z7.union([
|
|
458
|
+
z7.object({
|
|
287
459
|
...baseProp,
|
|
288
|
-
type:
|
|
289
|
-
value:
|
|
460
|
+
type: z7.literal("number"),
|
|
461
|
+
value: z7.number()
|
|
290
462
|
}),
|
|
291
|
-
|
|
463
|
+
z7.object({
|
|
292
464
|
...baseProp,
|
|
293
|
-
type:
|
|
294
|
-
value:
|
|
465
|
+
type: z7.literal("string"),
|
|
466
|
+
value: z7.string()
|
|
295
467
|
}),
|
|
296
|
-
|
|
468
|
+
z7.object({
|
|
297
469
|
...baseProp,
|
|
298
|
-
type:
|
|
299
|
-
value:
|
|
470
|
+
type: z7.literal("boolean"),
|
|
471
|
+
value: z7.boolean()
|
|
300
472
|
}),
|
|
301
|
-
|
|
473
|
+
z7.object({
|
|
302
474
|
...baseProp,
|
|
303
|
-
type:
|
|
304
|
-
value:
|
|
475
|
+
type: z7.literal("json"),
|
|
476
|
+
value: z7.unknown()
|
|
305
477
|
}),
|
|
306
|
-
|
|
478
|
+
z7.object({
|
|
307
479
|
...baseProp,
|
|
308
|
-
type:
|
|
309
|
-
value:
|
|
480
|
+
type: z7.literal("asset"),
|
|
481
|
+
value: z7.string()
|
|
310
482
|
// asset id
|
|
311
483
|
}),
|
|
312
|
-
|
|
484
|
+
z7.object({
|
|
313
485
|
...baseProp,
|
|
314
|
-
type:
|
|
315
|
-
value:
|
|
316
|
-
|
|
486
|
+
type: z7.literal("page"),
|
|
487
|
+
value: z7.union([
|
|
488
|
+
z7.string(),
|
|
317
489
|
// page id
|
|
318
|
-
|
|
319
|
-
pageId:
|
|
320
|
-
instanceId:
|
|
490
|
+
z7.object({
|
|
491
|
+
pageId: z7.string(),
|
|
492
|
+
instanceId: z7.string()
|
|
321
493
|
})
|
|
322
494
|
])
|
|
323
495
|
}),
|
|
324
|
-
|
|
496
|
+
z7.object({
|
|
325
497
|
...baseProp,
|
|
326
|
-
type:
|
|
327
|
-
value:
|
|
498
|
+
type: z7.literal("string[]"),
|
|
499
|
+
value: z7.array(z7.string())
|
|
328
500
|
}),
|
|
329
|
-
|
|
501
|
+
z7.object({
|
|
330
502
|
...baseProp,
|
|
331
|
-
type:
|
|
503
|
+
type: z7.literal("parameter"),
|
|
332
504
|
// data source id
|
|
333
|
-
value:
|
|
505
|
+
value: z7.string()
|
|
334
506
|
}),
|
|
335
|
-
|
|
507
|
+
z7.object({
|
|
336
508
|
...baseProp,
|
|
337
|
-
type:
|
|
509
|
+
type: z7.literal("resource"),
|
|
338
510
|
// resource id
|
|
339
|
-
value:
|
|
511
|
+
value: z7.string()
|
|
340
512
|
}),
|
|
341
|
-
|
|
513
|
+
z7.object({
|
|
342
514
|
...baseProp,
|
|
343
|
-
type:
|
|
515
|
+
type: z7.literal("expression"),
|
|
344
516
|
// expression code
|
|
345
|
-
value:
|
|
517
|
+
value: z7.string()
|
|
346
518
|
}),
|
|
347
|
-
|
|
519
|
+
z7.object({
|
|
348
520
|
...baseProp,
|
|
349
|
-
type:
|
|
350
|
-
value:
|
|
351
|
-
|
|
352
|
-
type:
|
|
353
|
-
args:
|
|
354
|
-
code:
|
|
521
|
+
type: z7.literal("action"),
|
|
522
|
+
value: z7.array(
|
|
523
|
+
z7.object({
|
|
524
|
+
type: z7.literal("execute"),
|
|
525
|
+
args: z7.array(z7.string()),
|
|
526
|
+
code: z7.string()
|
|
355
527
|
})
|
|
356
528
|
)
|
|
529
|
+
}),
|
|
530
|
+
z7.object({
|
|
531
|
+
...baseProp,
|
|
532
|
+
type: z7.literal("animationAction"),
|
|
533
|
+
value: animationActionSchema
|
|
357
534
|
})
|
|
358
535
|
]);
|
|
359
|
-
var Props =
|
|
536
|
+
var Props = z7.map(PropId, Prop);
|
|
360
537
|
|
|
361
538
|
// src/schema/breakpoints.ts
|
|
362
|
-
import { z as
|
|
363
|
-
var BreakpointId =
|
|
364
|
-
var Breakpoint =
|
|
539
|
+
import { z as z8 } from "zod";
|
|
540
|
+
var BreakpointId = z8.string();
|
|
541
|
+
var Breakpoint = z8.object({
|
|
365
542
|
id: BreakpointId,
|
|
366
|
-
label:
|
|
367
|
-
minWidth:
|
|
368
|
-
maxWidth:
|
|
543
|
+
label: z8.string(),
|
|
544
|
+
minWidth: z8.number().optional(),
|
|
545
|
+
maxWidth: z8.number().optional()
|
|
369
546
|
}).refine(({ minWidth, maxWidth }) => {
|
|
370
547
|
return (
|
|
371
548
|
// Either min or max width have to be defined
|
|
@@ -373,7 +550,7 @@ var Breakpoint = z7.object({
|
|
|
373
550
|
minWidth === void 0 && maxWidth === void 0
|
|
374
551
|
);
|
|
375
552
|
}, "Either minWidth or maxWidth should be defined");
|
|
376
|
-
var Breakpoints =
|
|
553
|
+
var Breakpoints = z8.map(BreakpointId, Breakpoint);
|
|
377
554
|
var initialBreakpoints = [
|
|
378
555
|
{ id: "placeholder", label: "Base" },
|
|
379
556
|
{ id: "placeholder", label: "Tablet", maxWidth: 991 },
|
|
@@ -382,237 +559,255 @@ var initialBreakpoints = [
|
|
|
382
559
|
];
|
|
383
560
|
|
|
384
561
|
// src/schema/style-sources.ts
|
|
385
|
-
import { z as
|
|
386
|
-
var StyleSourceId =
|
|
387
|
-
var StyleSourceToken =
|
|
388
|
-
type:
|
|
562
|
+
import { z as z9 } from "zod";
|
|
563
|
+
var StyleSourceId = z9.string();
|
|
564
|
+
var StyleSourceToken = z9.object({
|
|
565
|
+
type: z9.literal("token"),
|
|
389
566
|
id: StyleSourceId,
|
|
390
|
-
name:
|
|
567
|
+
name: z9.string()
|
|
391
568
|
});
|
|
392
|
-
var StyleSourceLocal =
|
|
393
|
-
type:
|
|
569
|
+
var StyleSourceLocal = z9.object({
|
|
570
|
+
type: z9.literal("local"),
|
|
394
571
|
id: StyleSourceId
|
|
395
572
|
});
|
|
396
|
-
var StyleSource =
|
|
397
|
-
var StyleSources =
|
|
573
|
+
var StyleSource = z9.union([StyleSourceToken, StyleSourceLocal]);
|
|
574
|
+
var StyleSources = z9.map(StyleSourceId, StyleSource);
|
|
398
575
|
|
|
399
576
|
// src/schema/style-source-selections.ts
|
|
400
|
-
import { z as
|
|
401
|
-
var InstanceId2 =
|
|
402
|
-
var StyleSourceId2 =
|
|
403
|
-
var StyleSourceSelection =
|
|
577
|
+
import { z as z10 } from "zod";
|
|
578
|
+
var InstanceId2 = z10.string();
|
|
579
|
+
var StyleSourceId2 = z10.string();
|
|
580
|
+
var StyleSourceSelection = z10.object({
|
|
404
581
|
instanceId: InstanceId2,
|
|
405
|
-
values:
|
|
582
|
+
values: z10.array(StyleSourceId2)
|
|
406
583
|
});
|
|
407
|
-
var StyleSourceSelections =
|
|
584
|
+
var StyleSourceSelections = z10.map(InstanceId2, StyleSourceSelection);
|
|
408
585
|
|
|
409
586
|
// src/schema/styles.ts
|
|
410
|
-
import { z as
|
|
411
|
-
import { StyleValue } from "@webstudio-is/css-engine";
|
|
412
|
-
var StyleDeclRaw =
|
|
413
|
-
styleSourceId:
|
|
414
|
-
breakpointId:
|
|
415
|
-
state:
|
|
587
|
+
import { z as z11 } from "zod";
|
|
588
|
+
import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
|
|
589
|
+
var StyleDeclRaw = z11.object({
|
|
590
|
+
styleSourceId: z11.string(),
|
|
591
|
+
breakpointId: z11.string(),
|
|
592
|
+
state: z11.optional(z11.string()),
|
|
416
593
|
// @todo can't figure out how to make property to be enum
|
|
417
|
-
property:
|
|
418
|
-
value:
|
|
419
|
-
listed:
|
|
594
|
+
property: z11.string(),
|
|
595
|
+
value: StyleValue2,
|
|
596
|
+
listed: z11.boolean().optional().describe("Whether the style is from the Advanced panel")
|
|
420
597
|
});
|
|
421
598
|
var StyleDecl = StyleDeclRaw;
|
|
422
599
|
var getStyleDeclKey = (styleDecl) => {
|
|
423
600
|
return `${styleDecl.styleSourceId}:${styleDecl.breakpointId}:${styleDecl.property}:${styleDecl.state ?? ""}`;
|
|
424
601
|
};
|
|
425
|
-
var Styles =
|
|
602
|
+
var Styles = z11.map(z11.string(), StyleDecl);
|
|
426
603
|
|
|
427
604
|
// src/schema/deployment.ts
|
|
428
|
-
import { z as
|
|
429
|
-
var Templates =
|
|
430
|
-
"vanilla",
|
|
605
|
+
import { z as z12 } from "zod";
|
|
606
|
+
var Templates = z12.enum([
|
|
431
607
|
"docker",
|
|
432
608
|
"vercel",
|
|
433
609
|
"netlify",
|
|
434
|
-
"netlify-functions",
|
|
435
|
-
"netlify-edge-functions",
|
|
436
610
|
"ssg",
|
|
437
611
|
"ssg-netlify",
|
|
438
612
|
"ssg-vercel"
|
|
439
613
|
]);
|
|
440
|
-
var Deployment =
|
|
441
|
-
|
|
442
|
-
destination:
|
|
443
|
-
name:
|
|
444
|
-
assetsDomain:
|
|
614
|
+
var Deployment = z12.union([
|
|
615
|
+
z12.object({
|
|
616
|
+
destination: z12.literal("static"),
|
|
617
|
+
name: z12.string(),
|
|
618
|
+
assetsDomain: z12.string(),
|
|
445
619
|
// Must be validated very strictly
|
|
446
|
-
templates:
|
|
620
|
+
templates: z12.array(Templates)
|
|
447
621
|
}),
|
|
448
|
-
|
|
449
|
-
destination:
|
|
450
|
-
domains:
|
|
451
|
-
assetsDomain:
|
|
622
|
+
z12.object({
|
|
623
|
+
destination: z12.literal("saas").optional(),
|
|
624
|
+
domains: z12.array(z12.string()),
|
|
625
|
+
assetsDomain: z12.string().optional(),
|
|
452
626
|
/**
|
|
453
627
|
* @deprecated This field is deprecated, use `domains` instead.
|
|
454
628
|
*/
|
|
455
|
-
projectDomain:
|
|
456
|
-
excludeWstdDomainFromSearch:
|
|
629
|
+
projectDomain: z12.string().optional(),
|
|
630
|
+
excludeWstdDomainFromSearch: z12.boolean().optional()
|
|
457
631
|
})
|
|
458
632
|
]);
|
|
459
633
|
|
|
460
634
|
// src/schema/webstudio.ts
|
|
461
|
-
import { z as
|
|
462
|
-
var WebstudioFragment =
|
|
463
|
-
children:
|
|
464
|
-
instances:
|
|
465
|
-
assets:
|
|
466
|
-
dataSources:
|
|
467
|
-
resources:
|
|
468
|
-
props:
|
|
469
|
-
breakpoints:
|
|
470
|
-
styleSourceSelections:
|
|
471
|
-
styleSources:
|
|
472
|
-
styles:
|
|
635
|
+
import { z as z13 } from "zod";
|
|
636
|
+
var WebstudioFragment = z13.object({
|
|
637
|
+
children: z13.array(InstanceChild),
|
|
638
|
+
instances: z13.array(Instance),
|
|
639
|
+
assets: z13.array(Asset),
|
|
640
|
+
dataSources: z13.array(DataSource),
|
|
641
|
+
resources: z13.array(Resource),
|
|
642
|
+
props: z13.array(Prop),
|
|
643
|
+
breakpoints: z13.array(Breakpoint),
|
|
644
|
+
styleSourceSelections: z13.array(StyleSourceSelection),
|
|
645
|
+
styleSources: z13.array(StyleSource),
|
|
646
|
+
styles: z13.array(StyleDecl)
|
|
473
647
|
});
|
|
474
648
|
|
|
475
649
|
// src/schema/prop-meta.ts
|
|
476
|
-
import { z as
|
|
650
|
+
import { z as z14 } from "zod";
|
|
477
651
|
var common = {
|
|
478
|
-
label:
|
|
479
|
-
description:
|
|
480
|
-
required:
|
|
652
|
+
label: z14.string().optional(),
|
|
653
|
+
description: z14.string().optional(),
|
|
654
|
+
required: z14.boolean()
|
|
481
655
|
};
|
|
482
|
-
var
|
|
656
|
+
var Tag = z14.object({
|
|
483
657
|
...common,
|
|
484
|
-
control:
|
|
485
|
-
type:
|
|
486
|
-
defaultValue:
|
|
658
|
+
control: z14.literal("tag"),
|
|
659
|
+
type: z14.literal("string"),
|
|
660
|
+
defaultValue: z14.undefined().optional(),
|
|
661
|
+
options: z14.array(z14.string())
|
|
487
662
|
});
|
|
488
|
-
var
|
|
663
|
+
var Number = z14.object({
|
|
489
664
|
...common,
|
|
490
|
-
control:
|
|
491
|
-
type:
|
|
492
|
-
defaultValue:
|
|
665
|
+
control: z14.literal("number"),
|
|
666
|
+
type: z14.literal("number"),
|
|
667
|
+
defaultValue: z14.number().optional()
|
|
493
668
|
});
|
|
494
|
-
var
|
|
669
|
+
var Range = z14.object({
|
|
495
670
|
...common,
|
|
496
|
-
control:
|
|
497
|
-
type:
|
|
498
|
-
defaultValue:
|
|
671
|
+
control: z14.literal("range"),
|
|
672
|
+
type: z14.literal("number"),
|
|
673
|
+
defaultValue: z14.number().optional()
|
|
674
|
+
});
|
|
675
|
+
var Text = z14.object({
|
|
676
|
+
...common,
|
|
677
|
+
control: z14.literal("text"),
|
|
678
|
+
type: z14.literal("string"),
|
|
679
|
+
defaultValue: z14.string().optional(),
|
|
499
680
|
/**
|
|
500
681
|
* The number of rows in <textarea>. If set to 0 an <input> will be used instead.
|
|
501
682
|
* In line with Storybook team's plan: https://github.com/storybookjs/storybook/issues/21100
|
|
502
683
|
*/
|
|
503
|
-
rows:
|
|
684
|
+
rows: z14.number().optional()
|
|
504
685
|
});
|
|
505
|
-
var
|
|
686
|
+
var Resource2 = z14.object({
|
|
506
687
|
...common,
|
|
507
|
-
control:
|
|
508
|
-
type:
|
|
509
|
-
|
|
510
|
-
defaultValue: z13.string().optional()
|
|
688
|
+
control: z14.literal("resource"),
|
|
689
|
+
type: z14.literal("resource"),
|
|
690
|
+
defaultValue: z14.string().optional()
|
|
511
691
|
});
|
|
512
|
-
var
|
|
692
|
+
var Code = z14.object({
|
|
513
693
|
...common,
|
|
514
|
-
control:
|
|
515
|
-
type:
|
|
516
|
-
|
|
694
|
+
control: z14.literal("code"),
|
|
695
|
+
type: z14.literal("string"),
|
|
696
|
+
language: z14.union([z14.literal("html"), z14.literal("markdown")]),
|
|
697
|
+
defaultValue: z14.string().optional()
|
|
517
698
|
});
|
|
518
|
-
var
|
|
699
|
+
var CodeText = z14.object({
|
|
519
700
|
...common,
|
|
520
|
-
control:
|
|
521
|
-
type:
|
|
522
|
-
defaultValue:
|
|
701
|
+
control: z14.literal("codetext"),
|
|
702
|
+
type: z14.literal("string"),
|
|
703
|
+
defaultValue: z14.string().optional()
|
|
523
704
|
});
|
|
524
|
-
var
|
|
705
|
+
var Color = z14.object({
|
|
525
706
|
...common,
|
|
526
|
-
control:
|
|
527
|
-
type:
|
|
528
|
-
defaultValue:
|
|
707
|
+
control: z14.literal("color"),
|
|
708
|
+
type: z14.literal("string"),
|
|
709
|
+
defaultValue: z14.string().optional()
|
|
529
710
|
});
|
|
530
|
-
var
|
|
711
|
+
var Boolean = z14.object({
|
|
531
712
|
...common,
|
|
532
|
-
control:
|
|
533
|
-
type:
|
|
534
|
-
defaultValue:
|
|
535
|
-
options: z13.array(z13.string())
|
|
713
|
+
control: z14.literal("boolean"),
|
|
714
|
+
type: z14.literal("boolean"),
|
|
715
|
+
defaultValue: z14.boolean().optional()
|
|
536
716
|
});
|
|
537
|
-
var
|
|
717
|
+
var Radio = z14.object({
|
|
538
718
|
...common,
|
|
539
|
-
control:
|
|
540
|
-
type:
|
|
541
|
-
defaultValue:
|
|
542
|
-
options:
|
|
719
|
+
control: z14.literal("radio"),
|
|
720
|
+
type: z14.literal("string"),
|
|
721
|
+
defaultValue: z14.string().optional(),
|
|
722
|
+
options: z14.array(z14.string())
|
|
543
723
|
});
|
|
544
|
-
var
|
|
724
|
+
var InlineRadio = z14.object({
|
|
545
725
|
...common,
|
|
546
|
-
control:
|
|
547
|
-
type:
|
|
548
|
-
defaultValue:
|
|
549
|
-
options:
|
|
726
|
+
control: z14.literal("inline-radio"),
|
|
727
|
+
type: z14.literal("string"),
|
|
728
|
+
defaultValue: z14.string().optional(),
|
|
729
|
+
options: z14.array(z14.string())
|
|
550
730
|
});
|
|
551
|
-
var
|
|
731
|
+
var Select = z14.object({
|
|
552
732
|
...common,
|
|
553
|
-
control:
|
|
554
|
-
type:
|
|
555
|
-
defaultValue:
|
|
556
|
-
options:
|
|
733
|
+
control: z14.literal("select"),
|
|
734
|
+
type: z14.literal("string"),
|
|
735
|
+
defaultValue: z14.string().optional(),
|
|
736
|
+
options: z14.array(z14.string())
|
|
557
737
|
});
|
|
558
|
-
var
|
|
738
|
+
var Check = z14.object({
|
|
559
739
|
...common,
|
|
560
|
-
control:
|
|
561
|
-
type:
|
|
562
|
-
defaultValue:
|
|
563
|
-
options:
|
|
740
|
+
control: z14.literal("check"),
|
|
741
|
+
type: z14.literal("string[]"),
|
|
742
|
+
defaultValue: z14.array(z14.string()).optional(),
|
|
743
|
+
options: z14.array(z14.string())
|
|
564
744
|
});
|
|
565
|
-
var
|
|
745
|
+
var InlineCheck = z14.object({
|
|
566
746
|
...common,
|
|
567
|
-
control:
|
|
568
|
-
type:
|
|
569
|
-
defaultValue:
|
|
570
|
-
options:
|
|
747
|
+
control: z14.literal("inline-check"),
|
|
748
|
+
type: z14.literal("string[]"),
|
|
749
|
+
defaultValue: z14.array(z14.string()).optional(),
|
|
750
|
+
options: z14.array(z14.string())
|
|
571
751
|
});
|
|
572
|
-
var
|
|
752
|
+
var MultiSelect = z14.object({
|
|
573
753
|
...common,
|
|
574
|
-
control:
|
|
575
|
-
type:
|
|
576
|
-
defaultValue:
|
|
754
|
+
control: z14.literal("multi-select"),
|
|
755
|
+
type: z14.literal("string[]"),
|
|
756
|
+
defaultValue: z14.array(z14.string()).optional(),
|
|
757
|
+
options: z14.array(z14.string())
|
|
758
|
+
});
|
|
759
|
+
var File = z14.object({
|
|
760
|
+
...common,
|
|
761
|
+
control: z14.literal("file"),
|
|
762
|
+
type: z14.literal("string"),
|
|
763
|
+
defaultValue: z14.string().optional(),
|
|
577
764
|
/** https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept */
|
|
578
|
-
accept:
|
|
765
|
+
accept: z14.string().optional()
|
|
579
766
|
});
|
|
580
|
-
var Url =
|
|
767
|
+
var Url = z14.object({
|
|
581
768
|
...common,
|
|
582
|
-
control:
|
|
583
|
-
type:
|
|
584
|
-
defaultValue:
|
|
769
|
+
control: z14.literal("url"),
|
|
770
|
+
type: z14.literal("string"),
|
|
771
|
+
defaultValue: z14.string().optional()
|
|
585
772
|
});
|
|
586
|
-
var Json =
|
|
773
|
+
var Json = z14.object({
|
|
587
774
|
...common,
|
|
588
|
-
control:
|
|
589
|
-
type:
|
|
590
|
-
defaultValue:
|
|
775
|
+
control: z14.literal("json"),
|
|
776
|
+
type: z14.literal("json"),
|
|
777
|
+
defaultValue: z14.unknown().optional()
|
|
591
778
|
});
|
|
592
|
-
var Date =
|
|
779
|
+
var Date = z14.object({
|
|
593
780
|
...common,
|
|
594
|
-
control:
|
|
781
|
+
control: z14.literal("date"),
|
|
595
782
|
// @todo not sure what type should be here
|
|
596
783
|
// (we don't support Date yet, added for completeness)
|
|
597
|
-
type:
|
|
598
|
-
defaultValue:
|
|
784
|
+
type: z14.literal("string"),
|
|
785
|
+
defaultValue: z14.string().optional()
|
|
786
|
+
});
|
|
787
|
+
var Action = z14.object({
|
|
788
|
+
...common,
|
|
789
|
+
control: z14.literal("action"),
|
|
790
|
+
type: z14.literal("action"),
|
|
791
|
+
defaultValue: z14.undefined().optional()
|
|
599
792
|
});
|
|
600
|
-
var
|
|
793
|
+
var TextContent = z14.object({
|
|
601
794
|
...common,
|
|
602
|
-
control:
|
|
603
|
-
type:
|
|
604
|
-
defaultValue:
|
|
795
|
+
control: z14.literal("textContent"),
|
|
796
|
+
type: z14.literal("string"),
|
|
797
|
+
defaultValue: z14.string().optional()
|
|
605
798
|
});
|
|
606
|
-
var
|
|
799
|
+
var AnimationAction = z14.object({
|
|
607
800
|
...common,
|
|
608
|
-
control:
|
|
609
|
-
type:
|
|
610
|
-
defaultValue:
|
|
801
|
+
control: z14.literal("animationAction"),
|
|
802
|
+
type: z14.literal("animationAction"),
|
|
803
|
+
defaultValue: z14.undefined().optional()
|
|
611
804
|
});
|
|
612
|
-
var PropMeta =
|
|
805
|
+
var PropMeta = z14.union([
|
|
806
|
+
Tag,
|
|
613
807
|
Number,
|
|
614
808
|
Range,
|
|
615
809
|
Text,
|
|
810
|
+
Resource2,
|
|
616
811
|
Code,
|
|
617
812
|
CodeText,
|
|
618
813
|
Color,
|
|
@@ -628,100 +823,19 @@ var PropMeta = z13.union([
|
|
|
628
823
|
Json,
|
|
629
824
|
Date,
|
|
630
825
|
Action,
|
|
631
|
-
TextContent
|
|
826
|
+
TextContent,
|
|
827
|
+
AnimationAction
|
|
632
828
|
]);
|
|
633
829
|
|
|
634
|
-
// src/schema/embed-template.ts
|
|
635
|
-
import { z as z14 } from "zod";
|
|
636
|
-
import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
|
|
637
|
-
var EmbedTemplateText = z14.object({
|
|
638
|
-
type: z14.literal("text"),
|
|
639
|
-
value: z14.string(),
|
|
640
|
-
placeholder: z14.boolean().optional()
|
|
641
|
-
});
|
|
642
|
-
var EmbedTemplateExpression = z14.object({
|
|
643
|
-
type: z14.literal("expression"),
|
|
644
|
-
value: z14.string()
|
|
645
|
-
});
|
|
646
|
-
var EmbedTemplateVariable = z14.object({
|
|
647
|
-
alias: z14.optional(z14.string()),
|
|
648
|
-
initialValue: z14.unknown()
|
|
649
|
-
});
|
|
650
|
-
var EmbedTemplateProp = z14.union([
|
|
651
|
-
z14.object({
|
|
652
|
-
type: z14.literal("number"),
|
|
653
|
-
name: z14.string(),
|
|
654
|
-
value: z14.number()
|
|
655
|
-
}),
|
|
656
|
-
z14.object({
|
|
657
|
-
type: z14.literal("string"),
|
|
658
|
-
name: z14.string(),
|
|
659
|
-
value: z14.string()
|
|
660
|
-
}),
|
|
661
|
-
z14.object({
|
|
662
|
-
type: z14.literal("boolean"),
|
|
663
|
-
name: z14.string(),
|
|
664
|
-
value: z14.boolean()
|
|
665
|
-
}),
|
|
666
|
-
z14.object({
|
|
667
|
-
type: z14.literal("string[]"),
|
|
668
|
-
name: z14.string(),
|
|
669
|
-
value: z14.array(z14.string())
|
|
670
|
-
}),
|
|
671
|
-
z14.object({
|
|
672
|
-
type: z14.literal("json"),
|
|
673
|
-
name: z14.string(),
|
|
674
|
-
value: z14.unknown()
|
|
675
|
-
}),
|
|
676
|
-
z14.object({
|
|
677
|
-
type: z14.literal("expression"),
|
|
678
|
-
name: z14.string(),
|
|
679
|
-
code: z14.string()
|
|
680
|
-
}),
|
|
681
|
-
z14.object({
|
|
682
|
-
type: z14.literal("parameter"),
|
|
683
|
-
name: z14.string(),
|
|
684
|
-
variableName: z14.string(),
|
|
685
|
-
variableAlias: z14.optional(z14.string())
|
|
686
|
-
}),
|
|
687
|
-
z14.object({
|
|
688
|
-
type: z14.literal("action"),
|
|
689
|
-
name: z14.string(),
|
|
690
|
-
value: z14.array(
|
|
691
|
-
z14.object({
|
|
692
|
-
type: z14.literal("execute"),
|
|
693
|
-
args: z14.optional(z14.array(z14.string())),
|
|
694
|
-
code: z14.string()
|
|
695
|
-
})
|
|
696
|
-
)
|
|
697
|
-
})
|
|
698
|
-
]);
|
|
699
|
-
var EmbedTemplateStyleDeclRaw = z14.object({
|
|
700
|
-
// State selector, e.g. :hover
|
|
701
|
-
state: z14.optional(z14.string()),
|
|
702
|
-
property: z14.string(),
|
|
703
|
-
value: StyleValue2
|
|
704
|
-
});
|
|
705
|
-
var EmbedTemplateStyleDecl = EmbedTemplateStyleDeclRaw;
|
|
706
|
-
var EmbedTemplateInstance = z14.lazy(
|
|
707
|
-
() => z14.object({
|
|
708
|
-
type: z14.literal("instance"),
|
|
709
|
-
component: z14.string(),
|
|
710
|
-
label: z14.optional(z14.string()),
|
|
711
|
-
variables: z14.optional(z14.record(z14.string(), EmbedTemplateVariable)),
|
|
712
|
-
props: z14.optional(z14.array(EmbedTemplateProp)),
|
|
713
|
-
styles: z14.optional(z14.array(EmbedTemplateStyleDecl)),
|
|
714
|
-
children: WsEmbedTemplate
|
|
715
|
-
})
|
|
716
|
-
);
|
|
717
|
-
var WsEmbedTemplate = z14.lazy(
|
|
718
|
-
() => z14.array(
|
|
719
|
-
z14.union([EmbedTemplateInstance, EmbedTemplateText, EmbedTemplateExpression])
|
|
720
|
-
)
|
|
721
|
-
);
|
|
722
|
-
|
|
723
830
|
// src/schema/component-meta.ts
|
|
724
831
|
import { z as z15 } from "zod";
|
|
832
|
+
import { StyleValue as StyleValue3 } from "@webstudio-is/css-engine";
|
|
833
|
+
var PresetStyleDecl = z15.object({
|
|
834
|
+
// State selector, e.g. :hover
|
|
835
|
+
state: z15.optional(z15.string()),
|
|
836
|
+
property: z15.string(),
|
|
837
|
+
value: StyleValue3
|
|
838
|
+
});
|
|
725
839
|
var WsComponentPropsMeta = z15.object({
|
|
726
840
|
props: z15.record(PropMeta),
|
|
727
841
|
// Props that will be always visible in properties panel.
|
|
@@ -731,6 +845,7 @@ var componentCategories = [
|
|
|
731
845
|
"general",
|
|
732
846
|
"typography",
|
|
733
847
|
"media",
|
|
848
|
+
"animations",
|
|
734
849
|
"data",
|
|
735
850
|
"forms",
|
|
736
851
|
"localization",
|
|
@@ -752,14 +867,30 @@ var defaultStates = [
|
|
|
752
867
|
{ selector: ":focus-visible", label: "Focus Visible" },
|
|
753
868
|
{ selector: ":focus-within", label: "Focus Within" }
|
|
754
869
|
];
|
|
870
|
+
var ComponentContent = z15.string();
|
|
871
|
+
var ContentModel = z15.object({
|
|
872
|
+
/*
|
|
873
|
+
* instance - accepted by any parent with "instance" in children categories
|
|
874
|
+
* none - accepted by parents with this component name in children categories
|
|
875
|
+
*/
|
|
876
|
+
category: z15.union([z15.literal("instance"), z15.literal("none")]),
|
|
877
|
+
/**
|
|
878
|
+
* enforce direct children of category or components
|
|
879
|
+
*/
|
|
880
|
+
children: z15.array(ComponentContent),
|
|
881
|
+
/**
|
|
882
|
+
* enforce descendants of category or components
|
|
883
|
+
*/
|
|
884
|
+
descendants: z15.array(ComponentContent).optional()
|
|
885
|
+
});
|
|
755
886
|
var WsComponentMeta = z15.object({
|
|
756
887
|
category: z15.enum(componentCategories).optional(),
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
888
|
+
/**
|
|
889
|
+
* a property used as textual placeholder when no content specified while in builder
|
|
890
|
+
* also signals to not insert components inside unless dropped explicitly
|
|
891
|
+
*/
|
|
892
|
+
placeholder: z15.string().optional(),
|
|
893
|
+
contentModel: ContentModel.optional(),
|
|
763
894
|
// when this field is specified component receives
|
|
764
895
|
// prop with index of same components withiin specified ancestor
|
|
765
896
|
// important to automatically enumerate collections without
|
|
@@ -768,11 +899,8 @@ var WsComponentMeta = z15.object({
|
|
|
768
899
|
label: z15.optional(z15.string()),
|
|
769
900
|
description: z15.string().optional(),
|
|
770
901
|
icon: z15.string(),
|
|
771
|
-
presetStyle: z15.optional(
|
|
772
|
-
z15.record(z15.string(), z15.array(EmbedTemplateStyleDecl))
|
|
773
|
-
),
|
|
902
|
+
presetStyle: z15.optional(z15.record(z15.string(), z15.array(PresetStyleDecl))),
|
|
774
903
|
states: z15.optional(z15.array(ComponentState)),
|
|
775
|
-
template: z15.optional(WsEmbedTemplate),
|
|
776
904
|
order: z15.number().optional()
|
|
777
905
|
});
|
|
778
906
|
|
|
@@ -782,24 +910,25 @@ import {
|
|
|
782
910
|
ListViewIcon,
|
|
783
911
|
PaintBrushIcon,
|
|
784
912
|
SettingsIcon,
|
|
785
|
-
AddTemplateInstanceIcon
|
|
913
|
+
AddTemplateInstanceIcon,
|
|
914
|
+
HtmlElementIcon
|
|
786
915
|
} from "@webstudio-is/icons/svg";
|
|
787
916
|
|
|
788
917
|
// src/__generated__/normalize.css.ts
|
|
789
918
|
var html = [
|
|
790
919
|
{ property: "display", value: { type: "keyword", value: "grid" } },
|
|
791
|
-
{ property: "
|
|
920
|
+
{ property: "min-height", value: { type: "unit", unit: "%", value: 100 } },
|
|
792
921
|
{
|
|
793
|
-
property: "
|
|
922
|
+
property: "font-family",
|
|
794
923
|
value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
|
|
795
924
|
},
|
|
796
|
-
{ property: "
|
|
925
|
+
{ property: "font-size", value: { type: "unit", unit: "px", value: 16 } },
|
|
797
926
|
{
|
|
798
|
-
property: "
|
|
927
|
+
property: "line-height",
|
|
799
928
|
value: { type: "unit", unit: "number", value: 1.2 }
|
|
800
929
|
},
|
|
801
930
|
{
|
|
802
|
-
property: "
|
|
931
|
+
property: "white-space-collapse",
|
|
803
932
|
value: { type: "keyword", value: "preserve" }
|
|
804
933
|
}
|
|
805
934
|
];
|
|
@@ -807,7 +936,6 @@ var html = [
|
|
|
807
936
|
// src/core-metas.ts
|
|
808
937
|
var rootComponent = "ws:root";
|
|
809
938
|
var rootMeta = {
|
|
810
|
-
type: "container",
|
|
811
939
|
label: "Global Root",
|
|
812
940
|
icon: SettingsIcon,
|
|
813
941
|
presetStyle: {
|
|
@@ -817,12 +945,23 @@ var rootMeta = {
|
|
|
817
945
|
var rootPropsMeta = {
|
|
818
946
|
props: {}
|
|
819
947
|
};
|
|
948
|
+
var elementComponent = "ws:element";
|
|
949
|
+
var elementMeta = {
|
|
950
|
+
label: "Element",
|
|
951
|
+
icon: HtmlElementIcon
|
|
952
|
+
};
|
|
953
|
+
var elementPropsMeta = {
|
|
954
|
+
props: {}
|
|
955
|
+
};
|
|
820
956
|
var portalComponent = "Slot";
|
|
821
957
|
var collectionComponent = "ws:collection";
|
|
822
958
|
var collectionMeta = {
|
|
823
|
-
type: "container",
|
|
824
959
|
label: "Collection",
|
|
825
|
-
icon: ListViewIcon
|
|
960
|
+
icon: ListViewIcon,
|
|
961
|
+
contentModel: {
|
|
962
|
+
category: "instance",
|
|
963
|
+
children: ["instance"]
|
|
964
|
+
}
|
|
826
965
|
};
|
|
827
966
|
var collectionPropsMeta = {
|
|
828
967
|
props: {
|
|
@@ -836,15 +975,14 @@ var collectionPropsMeta = {
|
|
|
836
975
|
};
|
|
837
976
|
var descendantComponent = "ws:descendant";
|
|
838
977
|
var descendantMeta = {
|
|
839
|
-
type: "control",
|
|
840
978
|
label: "Descendant",
|
|
841
979
|
icon: PaintBrushIcon,
|
|
980
|
+
contentModel: {
|
|
981
|
+
category: "none",
|
|
982
|
+
children: []
|
|
983
|
+
},
|
|
842
984
|
// @todo infer possible presets
|
|
843
|
-
presetStyle: {}
|
|
844
|
-
constraints: {
|
|
845
|
-
relation: "parent",
|
|
846
|
-
component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
|
|
847
|
-
}
|
|
985
|
+
presetStyle: {}
|
|
848
986
|
};
|
|
849
987
|
var descendantPropsMeta = {
|
|
850
988
|
props: {
|
|
@@ -877,36 +1015,29 @@ var descendantPropsMeta = {
|
|
|
877
1015
|
var blockComponent = "ws:block";
|
|
878
1016
|
var blockTemplateComponent = "ws:block-template";
|
|
879
1017
|
var blockTemplateMeta = {
|
|
880
|
-
type: "container",
|
|
881
1018
|
icon: AddTemplateInstanceIcon,
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1019
|
+
contentModel: {
|
|
1020
|
+
category: "none",
|
|
1021
|
+
children: ["instance"]
|
|
885
1022
|
}
|
|
886
1023
|
};
|
|
887
1024
|
var blockTemplatePropsMeta = {
|
|
888
1025
|
props: {}
|
|
889
1026
|
};
|
|
890
1027
|
var blockMeta = {
|
|
891
|
-
type: "container",
|
|
892
1028
|
label: "Content Block",
|
|
893
1029
|
icon: ContentBlockIcon,
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
},
|
|
899
|
-
{
|
|
900
|
-
relation: "child",
|
|
901
|
-
component: { $eq: blockTemplateComponent }
|
|
902
|
-
}
|
|
903
|
-
]
|
|
1030
|
+
contentModel: {
|
|
1031
|
+
category: "instance",
|
|
1032
|
+
children: [blockTemplateComponent, "instance"]
|
|
1033
|
+
}
|
|
904
1034
|
};
|
|
905
1035
|
var blockPropsMeta = {
|
|
906
1036
|
props: {}
|
|
907
1037
|
};
|
|
908
1038
|
var coreMetas = {
|
|
909
1039
|
[rootComponent]: rootMeta,
|
|
1040
|
+
[elementComponent]: elementMeta,
|
|
910
1041
|
[collectionComponent]: collectionMeta,
|
|
911
1042
|
[descendantComponent]: descendantMeta,
|
|
912
1043
|
[blockComponent]: blockMeta,
|
|
@@ -914,12 +1045,14 @@ var coreMetas = {
|
|
|
914
1045
|
};
|
|
915
1046
|
var corePropsMetas = {
|
|
916
1047
|
[rootComponent]: rootPropsMeta,
|
|
1048
|
+
[elementComponent]: elementPropsMeta,
|
|
917
1049
|
[collectionComponent]: collectionPropsMeta,
|
|
918
1050
|
[descendantComponent]: descendantPropsMeta,
|
|
919
1051
|
[blockComponent]: blockPropsMeta,
|
|
920
1052
|
[blockTemplateComponent]: blockTemplatePropsMeta
|
|
921
1053
|
};
|
|
922
|
-
var isCoreComponent = (component) => component === rootComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
|
|
1054
|
+
var isCoreComponent = (component) => component === rootComponent || component === elementComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
|
|
1055
|
+
var isComponentDetachable = (component) => component !== rootComponent && component !== blockTemplateComponent && component !== descendantComponent;
|
|
923
1056
|
|
|
924
1057
|
// src/instances-utils.ts
|
|
925
1058
|
var ROOT_INSTANCE_ID = ":root";
|
|
@@ -966,6 +1099,51 @@ var parseComponentName = (componentName) => {
|
|
|
966
1099
|
}
|
|
967
1100
|
return [namespace, name];
|
|
968
1101
|
};
|
|
1102
|
+
var getIndexesWithinAncestors = (metas, instances, rootIds) => {
|
|
1103
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
1104
|
+
for (const meta of metas.values()) {
|
|
1105
|
+
if (meta.indexWithinAncestor !== void 0) {
|
|
1106
|
+
ancestors.add(meta.indexWithinAncestor);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
1110
|
+
const traverseInstances2 = (instances2, instanceId, latestIndexes2 = /* @__PURE__ */ new Map()) => {
|
|
1111
|
+
const instance = instances2.get(instanceId);
|
|
1112
|
+
if (instance === void 0) {
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
const meta = metas.get(instance.component);
|
|
1116
|
+
if (ancestors.has(instance.component)) {
|
|
1117
|
+
latestIndexes2 = new Map(latestIndexes2);
|
|
1118
|
+
latestIndexes2.set(instance.component, /* @__PURE__ */ new Map());
|
|
1119
|
+
}
|
|
1120
|
+
if (instance.component === blockTemplateComponent) {
|
|
1121
|
+
latestIndexes2 = new Map(latestIndexes2);
|
|
1122
|
+
for (const key of latestIndexes2.keys()) {
|
|
1123
|
+
latestIndexes2.set(key, /* @__PURE__ */ new Map());
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
if (meta?.indexWithinAncestor !== void 0) {
|
|
1127
|
+
const ancestorIndexes = latestIndexes2.get(meta.indexWithinAncestor);
|
|
1128
|
+
if (ancestorIndexes) {
|
|
1129
|
+
let index = ancestorIndexes.get(instance.component) ?? -1;
|
|
1130
|
+
index += 1;
|
|
1131
|
+
ancestorIndexes.set(instance.component, index);
|
|
1132
|
+
indexes.set(instance.id, index);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
for (const child of instance.children) {
|
|
1136
|
+
if (child.type === "id") {
|
|
1137
|
+
traverseInstances2(instances2, child.value, latestIndexes2);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
const latestIndexes = /* @__PURE__ */ new Map();
|
|
1142
|
+
for (const instanceId of rootIds) {
|
|
1143
|
+
traverseInstances2(instances, instanceId, latestIndexes);
|
|
1144
|
+
}
|
|
1145
|
+
return indexes;
|
|
1146
|
+
};
|
|
969
1147
|
|
|
970
1148
|
// src/expression.ts
|
|
971
1149
|
import {
|
|
@@ -973,6 +1151,13 @@ import {
|
|
|
973
1151
|
parseExpressionAt
|
|
974
1152
|
} from "acorn";
|
|
975
1153
|
import { simple } from "acorn-walk";
|
|
1154
|
+
var SYSTEM_VARIABLE_ID = ":system";
|
|
1155
|
+
var systemParameter = {
|
|
1156
|
+
id: SYSTEM_VARIABLE_ID,
|
|
1157
|
+
scopeInstanceId: ROOT_INSTANCE_ID,
|
|
1158
|
+
type: "parameter",
|
|
1159
|
+
name: "system"
|
|
1160
|
+
};
|
|
976
1161
|
var lintExpression = ({
|
|
977
1162
|
expression,
|
|
978
1163
|
availableVariables = /* @__PURE__ */ new Set(),
|
|
@@ -1083,6 +1268,9 @@ var lintExpression = ({
|
|
|
1083
1268
|
return diagnostics;
|
|
1084
1269
|
};
|
|
1085
1270
|
var isLiteralNode = (node) => {
|
|
1271
|
+
if (node.type === "Identifier" && node.name === "undefined") {
|
|
1272
|
+
return true;
|
|
1273
|
+
}
|
|
1086
1274
|
if (node.type === "Literal") {
|
|
1087
1275
|
return true;
|
|
1088
1276
|
}
|
|
@@ -1224,11 +1412,17 @@ var generateObjectExpression = (map) => {
|
|
|
1224
1412
|
return generated;
|
|
1225
1413
|
};
|
|
1226
1414
|
var dataSourceVariablePrefix = "$ws$dataSource$";
|
|
1227
|
-
var
|
|
1415
|
+
var encodeDataVariableId = (id) => {
|
|
1416
|
+
if (id === SYSTEM_VARIABLE_ID) {
|
|
1417
|
+
return "$ws$system";
|
|
1418
|
+
}
|
|
1228
1419
|
const encoded = id.replaceAll("-", "__DASH__");
|
|
1229
1420
|
return `${dataSourceVariablePrefix}${encoded}`;
|
|
1230
1421
|
};
|
|
1231
|
-
var
|
|
1422
|
+
var decodeDataVariableId = (name) => {
|
|
1423
|
+
if (name === "$ws$system") {
|
|
1424
|
+
return SYSTEM_VARIABLE_ID;
|
|
1425
|
+
}
|
|
1232
1426
|
if (name.startsWith(dataSourceVariablePrefix)) {
|
|
1233
1427
|
const encoded = name.slice(dataSourceVariablePrefix.length);
|
|
1234
1428
|
return encoded.replaceAll("__DASH__", "-");
|
|
@@ -1245,8 +1439,11 @@ var generateExpression = ({
|
|
|
1245
1439
|
expression,
|
|
1246
1440
|
executable: true,
|
|
1247
1441
|
replaceVariable: (identifier) => {
|
|
1248
|
-
const depId =
|
|
1249
|
-
|
|
1442
|
+
const depId = decodeDataVariableId(identifier);
|
|
1443
|
+
let dep = depId ? dataSources.get(depId) : void 0;
|
|
1444
|
+
if (depId === SYSTEM_VARIABLE_ID) {
|
|
1445
|
+
dep = systemParameter;
|
|
1446
|
+
}
|
|
1250
1447
|
if (dep) {
|
|
1251
1448
|
usedDataSources?.set(dep.id, dep);
|
|
1252
1449
|
return scope.getName(dep.id, dep.name);
|
|
@@ -1438,12 +1635,11 @@ var generateResources = ({
|
|
|
1438
1635
|
`;
|
|
1439
1636
|
}
|
|
1440
1637
|
if (dataSource.type === "parameter") {
|
|
1441
|
-
if (dataSource.id
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
const name = scope.getName(dataSource.id, dataSource.name);
|
|
1445
|
-
generatedVariables += ` const ${name} = _props.system
|
|
1638
|
+
if (dataSource.id === page.systemDataSourceId || dataSource.id === SYSTEM_VARIABLE_ID) {
|
|
1639
|
+
const name = scope.getName(dataSource.id, dataSource.name);
|
|
1640
|
+
generatedVariables += ` const ${name} = _props.system
|
|
1446
1641
|
`;
|
|
1642
|
+
}
|
|
1447
1643
|
}
|
|
1448
1644
|
}
|
|
1449
1645
|
let generated = "";
|
|
@@ -1532,7 +1728,9 @@ var replaceFormActionsWithResources = ({
|
|
|
1532
1728
|
name: "action",
|
|
1533
1729
|
method: getMethod(method),
|
|
1534
1730
|
url: JSON.stringify(action),
|
|
1535
|
-
headers: [
|
|
1731
|
+
headers: [
|
|
1732
|
+
{ name: "Content-Type", value: JSON.stringify("application/json") }
|
|
1733
|
+
]
|
|
1536
1734
|
});
|
|
1537
1735
|
}
|
|
1538
1736
|
}
|
|
@@ -1640,7 +1838,7 @@ var generatePageMeta = ({
|
|
|
1640
1838
|
continue;
|
|
1641
1839
|
}
|
|
1642
1840
|
if (dataSource.type === "parameter") {
|
|
1643
|
-
if (dataSource.id === page.systemDataSourceId) {
|
|
1841
|
+
if (dataSource.id === page.systemDataSourceId || dataSource.id === SYSTEM_VARIABLE_ID) {
|
|
1644
1842
|
const valueName = localScope.getName(dataSource.id, dataSource.name);
|
|
1645
1843
|
generated += ` let ${valueName} = system
|
|
1646
1844
|
`;
|
|
@@ -1684,6 +1882,208 @@ var generatePageMeta = ({
|
|
|
1684
1882
|
`;
|
|
1685
1883
|
return generated;
|
|
1686
1884
|
};
|
|
1885
|
+
|
|
1886
|
+
// src/css.ts
|
|
1887
|
+
import { kebabCase } from "change-case";
|
|
1888
|
+
import {
|
|
1889
|
+
createRegularStyleSheet,
|
|
1890
|
+
generateAtomic
|
|
1891
|
+
} from "@webstudio-is/css-engine";
|
|
1892
|
+
import { getFontFaces } from "@webstudio-is/fonts";
|
|
1893
|
+
var addFontRules = ({
|
|
1894
|
+
sheet,
|
|
1895
|
+
assets,
|
|
1896
|
+
assetBaseUrl
|
|
1897
|
+
}) => {
|
|
1898
|
+
const fontAssets = [];
|
|
1899
|
+
for (const asset of assets.values()) {
|
|
1900
|
+
if (asset.type === "font") {
|
|
1901
|
+
fontAssets.push(asset);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
const fontFaces = getFontFaces(fontAssets, { assetBaseUrl });
|
|
1905
|
+
for (const fontFace of fontFaces) {
|
|
1906
|
+
sheet.addFontFaceRule(fontFace);
|
|
1907
|
+
}
|
|
1908
|
+
};
|
|
1909
|
+
var createImageValueTransformer = (assets, { assetBaseUrl }) => (styleValue) => {
|
|
1910
|
+
if (styleValue.type === "image" && styleValue.value.type === "asset") {
|
|
1911
|
+
const asset = assets.get(styleValue.value.value);
|
|
1912
|
+
if (asset === void 0) {
|
|
1913
|
+
return { type: "keyword", value: "none" };
|
|
1914
|
+
}
|
|
1915
|
+
const url = `${assetBaseUrl}${asset.name}`;
|
|
1916
|
+
return {
|
|
1917
|
+
type: "image",
|
|
1918
|
+
value: {
|
|
1919
|
+
type: "url",
|
|
1920
|
+
url
|
|
1921
|
+
},
|
|
1922
|
+
hidden: styleValue.hidden
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
var normalizeClassName = (name) => kebabCase(name);
|
|
1927
|
+
var generateCss = ({
|
|
1928
|
+
assets,
|
|
1929
|
+
instances,
|
|
1930
|
+
props,
|
|
1931
|
+
breakpoints,
|
|
1932
|
+
styles,
|
|
1933
|
+
styleSourceSelections,
|
|
1934
|
+
componentMetas,
|
|
1935
|
+
assetBaseUrl,
|
|
1936
|
+
atomic
|
|
1937
|
+
}) => {
|
|
1938
|
+
const fontSheet = createRegularStyleSheet({ name: "ssr" });
|
|
1939
|
+
const presetSheet = createRegularStyleSheet({ name: "ssr" });
|
|
1940
|
+
const userSheet = createRegularStyleSheet({ name: "ssr" });
|
|
1941
|
+
addFontRules({ sheet: fontSheet, assets, assetBaseUrl });
|
|
1942
|
+
presetSheet.addMediaRule("presets");
|
|
1943
|
+
const presetClasses = /* @__PURE__ */ new Map();
|
|
1944
|
+
const scope = createScope([], normalizeClassName, "-");
|
|
1945
|
+
const tagsByComponent = /* @__PURE__ */ new Map();
|
|
1946
|
+
tagsByComponent.set(rootComponent, /* @__PURE__ */ new Set(["html"]));
|
|
1947
|
+
const tagByInstanceId = /* @__PURE__ */ new Map();
|
|
1948
|
+
for (const prop of props.values()) {
|
|
1949
|
+
if (prop.type === "string" && prop.name === "tag") {
|
|
1950
|
+
tagByInstanceId.set(prop.instanceId, prop.value);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
for (const instance of instances.values()) {
|
|
1954
|
+
const propTag = tagByInstanceId.get(instance.id);
|
|
1955
|
+
const meta = componentMetas.get(instance.component);
|
|
1956
|
+
const metaTag = Object.keys(meta?.presetStyle ?? {}).at(0);
|
|
1957
|
+
let componentTags = tagsByComponent.get(instance.component);
|
|
1958
|
+
if (componentTags === void 0) {
|
|
1959
|
+
componentTags = /* @__PURE__ */ new Set();
|
|
1960
|
+
tagsByComponent.set(instance.component, componentTags);
|
|
1961
|
+
}
|
|
1962
|
+
const tag = instance.tag ?? propTag ?? metaTag;
|
|
1963
|
+
if (tag) {
|
|
1964
|
+
componentTags.add(tag);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
for (const [component, meta] of componentMetas) {
|
|
1968
|
+
const componentTags = tagsByComponent.get(component);
|
|
1969
|
+
const [_namespace, componentName] = parseComponentName(component);
|
|
1970
|
+
const className = `w-${scope.getName(component, meta.label ?? componentName)}`;
|
|
1971
|
+
const presetStyle = Object.entries(meta.presetStyle ?? {});
|
|
1972
|
+
if (presetStyle.length > 0) {
|
|
1973
|
+
presetClasses.set(component, className);
|
|
1974
|
+
}
|
|
1975
|
+
for (const [tag, styles2] of presetStyle) {
|
|
1976
|
+
if (!componentTags?.has(tag)) {
|
|
1977
|
+
continue;
|
|
1978
|
+
}
|
|
1979
|
+
const selector = component === rootComponent ? ":root" : `${tag}.${className}`;
|
|
1980
|
+
const rule = presetSheet.addNestingRule(selector);
|
|
1981
|
+
for (const declaration of styles2) {
|
|
1982
|
+
rule.setDeclaration({
|
|
1983
|
+
breakpoint: "presets",
|
|
1984
|
+
selector: declaration.state ?? "",
|
|
1985
|
+
property: declaration.property,
|
|
1986
|
+
value: declaration.value
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
for (const breakpoint of breakpoints.values()) {
|
|
1992
|
+
userSheet.addMediaRule(breakpoint.id, breakpoint);
|
|
1993
|
+
}
|
|
1994
|
+
const imageValueTransformer = createImageValueTransformer(assets, {
|
|
1995
|
+
assetBaseUrl
|
|
1996
|
+
});
|
|
1997
|
+
userSheet.setTransformer(imageValueTransformer);
|
|
1998
|
+
for (const styleDecl of styles.values()) {
|
|
1999
|
+
const rule = userSheet.addMixinRule(styleDecl.styleSourceId);
|
|
2000
|
+
rule.setDeclaration({
|
|
2001
|
+
breakpoint: styleDecl.breakpointId,
|
|
2002
|
+
selector: styleDecl.state ?? "",
|
|
2003
|
+
property: styleDecl.property,
|
|
2004
|
+
value: styleDecl.value
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
const classes = /* @__PURE__ */ new Map();
|
|
2008
|
+
const parentIdByInstanceId = /* @__PURE__ */ new Map();
|
|
2009
|
+
for (const instance of instances.values()) {
|
|
2010
|
+
const presetClass = presetClasses.get(instance.component);
|
|
2011
|
+
if (presetClass) {
|
|
2012
|
+
classes.set(instance.id, [presetClass]);
|
|
2013
|
+
}
|
|
2014
|
+
for (const child of instance.children) {
|
|
2015
|
+
if (child.type === "id") {
|
|
2016
|
+
parentIdByInstanceId.set(child.value, instance.id);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
const descendantSelectorByInstanceId = /* @__PURE__ */ new Map();
|
|
2021
|
+
for (const prop of props.values()) {
|
|
2022
|
+
if (prop.name === "selector" && prop.type === "string") {
|
|
2023
|
+
descendantSelectorByInstanceId.set(prop.instanceId, prop.value);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
const instanceByRule = /* @__PURE__ */ new Map();
|
|
2027
|
+
for (const selection of styleSourceSelections.values()) {
|
|
2028
|
+
let { instanceId } = selection;
|
|
2029
|
+
const { values } = selection;
|
|
2030
|
+
if (instanceId === ROOT_INSTANCE_ID) {
|
|
2031
|
+
const rule2 = userSheet.addNestingRule(`:root`);
|
|
2032
|
+
rule2.applyMixins(values);
|
|
2033
|
+
continue;
|
|
2034
|
+
}
|
|
2035
|
+
let descendantSuffix = "";
|
|
2036
|
+
const instance = instances.get(instanceId);
|
|
2037
|
+
if (instance === void 0) {
|
|
2038
|
+
continue;
|
|
2039
|
+
}
|
|
2040
|
+
if (instance.component === descendantComponent) {
|
|
2041
|
+
const parentId = parentIdByInstanceId.get(instanceId);
|
|
2042
|
+
const descendantSelector = descendantSelectorByInstanceId.get(instanceId);
|
|
2043
|
+
if (parentId && descendantSelector) {
|
|
2044
|
+
descendantSuffix = descendantSelector;
|
|
2045
|
+
instanceId = parentId;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
const meta = componentMetas.get(instance.component);
|
|
2049
|
+
const [_namespace, shortName] = parseComponentName(instance.component);
|
|
2050
|
+
const baseName = instance.label ?? meta?.label ?? shortName;
|
|
2051
|
+
const className = `w-${scope.getName(instanceId, baseName)}`;
|
|
2052
|
+
if (atomic === false) {
|
|
2053
|
+
let classList = classes.get(instanceId);
|
|
2054
|
+
if (classList === void 0) {
|
|
2055
|
+
classList = [];
|
|
2056
|
+
classes.set(instanceId, classList);
|
|
2057
|
+
}
|
|
2058
|
+
classList.push(className);
|
|
2059
|
+
}
|
|
2060
|
+
const rule = userSheet.addNestingRule(`.${className}`, descendantSuffix);
|
|
2061
|
+
rule.applyMixins(values);
|
|
2062
|
+
instanceByRule.set(rule, instanceId);
|
|
2063
|
+
}
|
|
2064
|
+
const fontCss = fontSheet.cssText;
|
|
2065
|
+
const presetCss = presetSheet.cssText.replaceAll(
|
|
2066
|
+
"@media all ",
|
|
2067
|
+
"@layer presets "
|
|
2068
|
+
);
|
|
2069
|
+
if (atomic) {
|
|
2070
|
+
const { cssText } = generateAtomic(userSheet, {
|
|
2071
|
+
getKey: (rule) => instanceByRule.get(rule),
|
|
2072
|
+
transformValue: imageValueTransformer,
|
|
2073
|
+
classes
|
|
2074
|
+
});
|
|
2075
|
+
return {
|
|
2076
|
+
cssText: `${fontCss}${presetCss}
|
|
2077
|
+
${cssText}`,
|
|
2078
|
+
classes
|
|
2079
|
+
};
|
|
2080
|
+
}
|
|
2081
|
+
return {
|
|
2082
|
+
cssText: `${fontCss}${presetCss}
|
|
2083
|
+
${userSheet.cssText}`,
|
|
2084
|
+
classes
|
|
2085
|
+
};
|
|
2086
|
+
};
|
|
1687
2087
|
export {
|
|
1688
2088
|
Asset,
|
|
1689
2089
|
Assets,
|
|
@@ -1691,14 +2091,11 @@ export {
|
|
|
1691
2091
|
Breakpoints,
|
|
1692
2092
|
CompilerSettings,
|
|
1693
2093
|
ComponentState,
|
|
2094
|
+
ContentModel,
|
|
1694
2095
|
DataSource,
|
|
1695
2096
|
DataSourceVariableValue,
|
|
1696
2097
|
DataSources,
|
|
1697
2098
|
Deployment,
|
|
1698
|
-
EmbedTemplateInstance,
|
|
1699
|
-
EmbedTemplateProp,
|
|
1700
|
-
EmbedTemplateStyleDecl,
|
|
1701
|
-
EmbedTemplateVariable,
|
|
1702
2099
|
ExpressionChild,
|
|
1703
2100
|
Folder,
|
|
1704
2101
|
FolderName,
|
|
@@ -1710,24 +2107,24 @@ export {
|
|
|
1710
2107
|
Instance,
|
|
1711
2108
|
InstanceChild,
|
|
1712
2109
|
Instances,
|
|
1713
|
-
|
|
1714
|
-
MatcherOperation,
|
|
1715
|
-
MatcherRelation,
|
|
1716
|
-
Matchers,
|
|
2110
|
+
OldPagePath,
|
|
1717
2111
|
PageName,
|
|
1718
2112
|
PagePath,
|
|
1719
2113
|
PageRedirect,
|
|
1720
2114
|
PageTitle,
|
|
1721
2115
|
Pages,
|
|
2116
|
+
PresetStyleDecl,
|
|
1722
2117
|
ProjectNewRedirectPath,
|
|
1723
2118
|
Prop,
|
|
1724
2119
|
PropMeta,
|
|
1725
2120
|
Props,
|
|
2121
|
+
RANGE_UNITS,
|
|
1726
2122
|
ROOT_FOLDER_ID,
|
|
1727
2123
|
ROOT_INSTANCE_ID,
|
|
1728
2124
|
Resource,
|
|
1729
2125
|
ResourceRequest,
|
|
1730
2126
|
Resources,
|
|
2127
|
+
SYSTEM_VARIABLE_ID,
|
|
1731
2128
|
StyleDecl,
|
|
1732
2129
|
StyleSource,
|
|
1733
2130
|
StyleSourceSelection,
|
|
@@ -1738,7 +2135,9 @@ export {
|
|
|
1738
2135
|
TextChild,
|
|
1739
2136
|
WebstudioFragment,
|
|
1740
2137
|
WsComponentMeta,
|
|
1741
|
-
|
|
2138
|
+
addFontRules,
|
|
2139
|
+
animationActionSchema,
|
|
2140
|
+
animationKeyframeSchema,
|
|
1742
2141
|
blockComponent,
|
|
1743
2142
|
blockTemplateComponent,
|
|
1744
2143
|
blockTemplateMeta,
|
|
@@ -1746,28 +2145,35 @@ export {
|
|
|
1746
2145
|
componentCategories,
|
|
1747
2146
|
coreMetas,
|
|
1748
2147
|
corePropsMetas,
|
|
2148
|
+
createImageValueTransformer,
|
|
1749
2149
|
createScope,
|
|
1750
|
-
decodeDataSourceVariable,
|
|
1751
|
-
|
|
2150
|
+
decodeDataVariableId as decodeDataSourceVariable,
|
|
2151
|
+
decodeDataVariableId,
|
|
1752
2152
|
defaultStates,
|
|
1753
2153
|
descendantComponent,
|
|
1754
2154
|
documentTypes,
|
|
1755
|
-
|
|
1756
|
-
|
|
2155
|
+
durationUnitValueSchema,
|
|
2156
|
+
elementComponent,
|
|
2157
|
+
encodeDataVariableId as encodeDataSourceVariable,
|
|
2158
|
+
encodeDataVariableId,
|
|
1757
2159
|
executeExpression,
|
|
1758
2160
|
findPageByIdOrPath,
|
|
1759
2161
|
findParentFolderByChildId,
|
|
1760
2162
|
findTreeInstanceIds,
|
|
1761
2163
|
findTreeInstanceIdsExcludingSlotDescendants,
|
|
2164
|
+
generateCss,
|
|
1762
2165
|
generateExpression,
|
|
1763
2166
|
generateObjectExpression,
|
|
1764
2167
|
generatePageMeta,
|
|
1765
2168
|
generateResources,
|
|
1766
2169
|
getExpressionIdentifiers,
|
|
2170
|
+
getIndexesWithinAncestors,
|
|
1767
2171
|
getPagePath,
|
|
1768
2172
|
getStaticSiteMapXml,
|
|
1769
2173
|
getStyleDeclKey,
|
|
1770
2174
|
initialBreakpoints,
|
|
2175
|
+
insetUnitValueSchema,
|
|
2176
|
+
isComponentDetachable,
|
|
1771
2177
|
isCoreComponent,
|
|
1772
2178
|
isLiteralExpression,
|
|
1773
2179
|
isPathnamePattern,
|
|
@@ -1777,8 +2183,12 @@ export {
|
|
|
1777
2183
|
parseComponentName,
|
|
1778
2184
|
parseObjectExpression,
|
|
1779
2185
|
portalComponent,
|
|
2186
|
+
rangeUnitValueSchema,
|
|
1780
2187
|
replaceFormActionsWithResources,
|
|
1781
2188
|
rootComponent,
|
|
2189
|
+
scrollAnimationSchema,
|
|
1782
2190
|
stateCategories,
|
|
1783
|
-
|
|
2191
|
+
systemParameter,
|
|
2192
|
+
transpileExpression,
|
|
2193
|
+
viewAnimationSchema
|
|
1784
2194
|
};
|