@webstudio-is/sdk 0.0.0-5844e28 → 0.0.0-7cb4145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/schema/assets.ts
2
8
  import { z } from "zod";
3
9
  import { FontFormat, FontMeta } from "@webstudio-is/fonts";
@@ -57,7 +63,7 @@ var commonPageFields = {
57
63
  title: PageTitle,
58
64
  history: z2.optional(z2.array(z2.string())),
59
65
  rootInstanceId: z2.string(),
60
- systemDataSourceId: z2.string(),
66
+ systemDataSourceId: z2.string().optional(),
61
67
  meta: z2.object({
62
68
  description: z2.string().optional(),
63
69
  title: z2.string().optional(),
@@ -88,10 +94,7 @@ var HomePage = z2.object({
88
94
  ...commonPageFields,
89
95
  path: HomePagePath
90
96
  });
91
- var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine(
92
- (path) => path === "" || path.startsWith("/"),
93
- "Must start with a / or a full URL e.g. https://website.org"
94
- ).refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
97
+ 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(
95
98
  (path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
96
99
  "Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
97
100
  ).refine(
@@ -104,6 +107,14 @@ var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refin
104
107
  (path) => path !== "/build" && path.startsWith("/build/") === false,
105
108
  "/build prefix is reserved for the system"
106
109
  );
110
+ var PagePath = DefaultPagePage.refine(
111
+ (path) => path === "" || path.startsWith("/"),
112
+ "Must start with a / or a full URL e.g. https://website.org"
113
+ );
114
+ var OldPagePath = DefaultPagePage.refine(
115
+ (path) => path === "" || path.startsWith("/"),
116
+ "Must start with a / and it must be full path e.g. /project/id"
117
+ );
107
118
  var Page = z2.object({
108
119
  ...commonPageFields,
109
120
  path: PagePath
@@ -167,29 +178,11 @@ var Instance = z3.object({
167
178
  type: z3.literal("instance"),
168
179
  id: InstanceId,
169
180
  component: z3.string(),
181
+ tag: z3.string().optional(),
170
182
  label: z3.string().optional(),
171
183
  children: z3.array(InstanceChild)
172
184
  });
173
185
  var Instances = z3.map(InstanceId, Instance);
174
- var MatcherRelation = z3.union([
175
- z3.literal("ancestor"),
176
- z3.literal("parent"),
177
- z3.literal("self"),
178
- z3.literal("child"),
179
- z3.literal("descendant")
180
- ]);
181
- var MatcherOperation = z3.object({
182
- $eq: z3.string().optional(),
183
- $neq: z3.string().optional(),
184
- $in: z3.array(z3.string()).optional(),
185
- $nin: z3.array(z3.string()).optional()
186
- });
187
- var Matcher = z3.object({
188
- relation: MatcherRelation,
189
- component: MatcherOperation.optional(),
190
- tag: MatcherOperation.optional()
191
- });
192
- var Matchers = z3.union([Matcher, z3.array(Matcher)]);
193
186
 
194
187
  // src/schema/data-sources.ts
195
188
  import { z as z4 } from "zod";
@@ -221,20 +214,25 @@ var DataSource = z4.union([
221
214
  z4.object({
222
215
  type: z4.literal("variable"),
223
216
  id: DataSourceId,
224
- scopeInstanceId: z4.string(),
217
+ // The instance should always be specified for variables,
218
+ // however, there was a bug in the embed template
219
+ // which produced variables without an instance
220
+ // and these variables will fail validation
221
+ // if we make it required
222
+ scopeInstanceId: z4.string().optional(),
225
223
  name: z4.string(),
226
224
  value: DataSourceVariableValue
227
225
  }),
228
226
  z4.object({
229
227
  type: z4.literal("parameter"),
230
228
  id: DataSourceId,
231
- scopeInstanceId: z4.string(),
229
+ scopeInstanceId: z4.string().optional(),
232
230
  name: z4.string()
233
231
  }),
234
232
  z4.object({
235
233
  type: z4.literal("resource"),
236
234
  id: DataSourceId,
237
- scopeInstanceId: z4.string(),
235
+ scopeInstanceId: z4.string().optional(),
238
236
  name: z4.string(),
239
237
  resourceId: z4.string()
240
238
  })
@@ -277,98 +275,280 @@ var ResourceRequest = z5.object({
277
275
  var Resources = z5.map(ResourceId, Resource);
278
276
 
279
277
  // src/schema/props.ts
278
+ import { z as z7 } from "zod";
279
+
280
+ // src/schema/animation-schema.ts
281
+ import { StyleValue } from "@webstudio-is/css-engine";
280
282
  import { z as z6 } from "zod";
281
- var PropId = z6.string();
283
+ var literalUnion = (arr) => z6.union(
284
+ arr.map((val) => z6.literal(val))
285
+ );
286
+ var RANGE_UNITS = [
287
+ "%",
288
+ "px",
289
+ "cm",
290
+ "mm",
291
+ "q",
292
+ "in",
293
+ "pt",
294
+ "pc",
295
+ "em",
296
+ "rem",
297
+ "ex",
298
+ "rex",
299
+ "cap",
300
+ "rcap",
301
+ "ch",
302
+ "rch",
303
+ "lh",
304
+ "rlh",
305
+ "vw",
306
+ "svw",
307
+ "lvw",
308
+ "dvw",
309
+ "vh",
310
+ "svh",
311
+ "lvh",
312
+ "dvh",
313
+ "vi",
314
+ "svi",
315
+ "lvi",
316
+ "dvi",
317
+ "vb",
318
+ "svb",
319
+ "lvb",
320
+ "dvb",
321
+ "vmin",
322
+ "svmin",
323
+ "lvmin",
324
+ "dvmin",
325
+ "vmax",
326
+ "svmax",
327
+ "lvmax",
328
+ "dvmax"
329
+ ];
330
+ var rangeUnitSchema = literalUnion(RANGE_UNITS);
331
+ var rangeUnitValueSchema = z6.union([
332
+ z6.object({
333
+ type: z6.literal("unit"),
334
+ value: z6.number(),
335
+ unit: rangeUnitSchema
336
+ }),
337
+ z6.object({
338
+ type: z6.literal("unparsed"),
339
+ value: z6.string()
340
+ }),
341
+ z6.object({
342
+ type: z6.literal("var"),
343
+ value: z6.string()
344
+ })
345
+ ]);
346
+ var TIME_UNITS = ["ms", "s"];
347
+ var timeUnitSchema = literalUnion(TIME_UNITS);
348
+ var durationUnitValueSchema = z6.union([
349
+ z6.object({
350
+ type: z6.literal("unit"),
351
+ value: z6.number(),
352
+ unit: timeUnitSchema
353
+ }),
354
+ z6.object({
355
+ type: z6.literal("var"),
356
+ value: z6.string()
357
+ })
358
+ ]);
359
+ var insetUnitValueSchema = z6.union([
360
+ rangeUnitValueSchema,
361
+ z6.object({
362
+ type: z6.literal("keyword"),
363
+ value: z6.literal("auto")
364
+ })
365
+ ]);
366
+ var keyframeStylesSchema = z6.record(StyleValue);
367
+ var animationKeyframeSchema = z6.object({
368
+ offset: z6.number().optional(),
369
+ styles: keyframeStylesSchema
370
+ });
371
+ var keyframeEffectOptionsSchema = z6.object({
372
+ easing: z6.string().optional(),
373
+ fill: z6.union([
374
+ z6.literal("none"),
375
+ z6.literal("forwards"),
376
+ z6.literal("backwards"),
377
+ z6.literal("both")
378
+ ]).optional(),
379
+ // FillMode
380
+ duration: durationUnitValueSchema.optional()
381
+ });
382
+ var scrollNamedRangeSchema = z6.union([
383
+ z6.literal("start"),
384
+ z6.literal("end")
385
+ ]);
386
+ var scrollRangeValueSchema = z6.tuple([
387
+ scrollNamedRangeSchema,
388
+ rangeUnitValueSchema
389
+ ]);
390
+ var scrollRangeOptionsSchema = z6.object({
391
+ rangeStart: scrollRangeValueSchema.optional(),
392
+ rangeEnd: scrollRangeValueSchema.optional()
393
+ });
394
+ var animationAxisSchema = z6.union([
395
+ z6.literal("block"),
396
+ z6.literal("inline"),
397
+ z6.literal("x"),
398
+ z6.literal("y")
399
+ ]);
400
+ var viewNamedRangeSchema = z6.union([
401
+ z6.literal("contain"),
402
+ z6.literal("cover"),
403
+ z6.literal("entry"),
404
+ z6.literal("exit"),
405
+ z6.literal("entry-crossing"),
406
+ z6.literal("exit-crossing")
407
+ ]);
408
+ var viewRangeValueSchema = z6.tuple([
409
+ viewNamedRangeSchema,
410
+ rangeUnitValueSchema
411
+ ]);
412
+ var viewRangeOptionsSchema = z6.object({
413
+ rangeStart: viewRangeValueSchema.optional(),
414
+ rangeEnd: viewRangeValueSchema.optional()
415
+ });
416
+ var baseAnimation = z6.object({
417
+ name: z6.string().optional(),
418
+ description: z6.string().optional(),
419
+ enabled: z6.array(z6.tuple([z6.string().describe("breakpointId"), z6.boolean()])).optional(),
420
+ keyframes: z6.array(animationKeyframeSchema)
421
+ });
422
+ var scrollAnimationSchema = baseAnimation.merge(
423
+ z6.object({
424
+ timing: keyframeEffectOptionsSchema.merge(scrollRangeOptionsSchema)
425
+ })
426
+ );
427
+ var scrollActionSchema = z6.object({
428
+ type: z6.literal("scroll"),
429
+ source: z6.union([z6.literal("closest"), z6.literal("nearest"), z6.literal("root")]).optional(),
430
+ axis: animationAxisSchema.optional(),
431
+ animations: z6.array(scrollAnimationSchema),
432
+ isPinned: z6.boolean().optional(),
433
+ debug: z6.boolean().optional()
434
+ });
435
+ var viewAnimationSchema = baseAnimation.merge(
436
+ z6.object({
437
+ timing: keyframeEffectOptionsSchema.merge(viewRangeOptionsSchema)
438
+ })
439
+ );
440
+ var viewActionSchema = z6.object({
441
+ type: z6.literal("view"),
442
+ subject: z6.string().optional(),
443
+ axis: animationAxisSchema.optional(),
444
+ animations: z6.array(viewAnimationSchema),
445
+ insetStart: insetUnitValueSchema.optional(),
446
+ insetEnd: insetUnitValueSchema.optional(),
447
+ isPinned: z6.boolean().optional(),
448
+ debug: z6.boolean().optional()
449
+ });
450
+ var animationActionSchema = z6.discriminatedUnion("type", [
451
+ scrollActionSchema,
452
+ viewActionSchema
453
+ ]);
454
+
455
+ // src/schema/props.ts
456
+ var PropId = z7.string();
282
457
  var baseProp = {
283
458
  id: PropId,
284
- instanceId: z6.string(),
285
- name: z6.string(),
286
- required: z6.optional(z6.boolean())
459
+ instanceId: z7.string(),
460
+ name: z7.string(),
461
+ required: z7.optional(z7.boolean())
287
462
  };
288
- var Prop = z6.union([
289
- z6.object({
463
+ var Prop = z7.union([
464
+ z7.object({
290
465
  ...baseProp,
291
- type: z6.literal("number"),
292
- value: z6.number()
466
+ type: z7.literal("number"),
467
+ value: z7.number()
293
468
  }),
294
- z6.object({
469
+ z7.object({
295
470
  ...baseProp,
296
- type: z6.literal("string"),
297
- value: z6.string()
471
+ type: z7.literal("string"),
472
+ value: z7.string()
298
473
  }),
299
- z6.object({
474
+ z7.object({
300
475
  ...baseProp,
301
- type: z6.literal("boolean"),
302
- value: z6.boolean()
476
+ type: z7.literal("boolean"),
477
+ value: z7.boolean()
303
478
  }),
304
- z6.object({
479
+ z7.object({
305
480
  ...baseProp,
306
- type: z6.literal("json"),
307
- value: z6.unknown()
481
+ type: z7.literal("json"),
482
+ value: z7.unknown()
308
483
  }),
309
- z6.object({
484
+ z7.object({
310
485
  ...baseProp,
311
- type: z6.literal("asset"),
312
- value: z6.string()
486
+ type: z7.literal("asset"),
487
+ value: z7.string()
313
488
  // asset id
314
489
  }),
315
- z6.object({
490
+ z7.object({
316
491
  ...baseProp,
317
- type: z6.literal("page"),
318
- value: z6.union([
319
- z6.string(),
492
+ type: z7.literal("page"),
493
+ value: z7.union([
494
+ z7.string(),
320
495
  // page id
321
- z6.object({
322
- pageId: z6.string(),
323
- instanceId: z6.string()
496
+ z7.object({
497
+ pageId: z7.string(),
498
+ instanceId: z7.string()
324
499
  })
325
500
  ])
326
501
  }),
327
- z6.object({
502
+ z7.object({
328
503
  ...baseProp,
329
- type: z6.literal("string[]"),
330
- value: z6.array(z6.string())
504
+ type: z7.literal("string[]"),
505
+ value: z7.array(z7.string())
331
506
  }),
332
- z6.object({
507
+ z7.object({
333
508
  ...baseProp,
334
- type: z6.literal("parameter"),
509
+ type: z7.literal("parameter"),
335
510
  // data source id
336
- value: z6.string()
511
+ value: z7.string()
337
512
  }),
338
- z6.object({
513
+ z7.object({
339
514
  ...baseProp,
340
- type: z6.literal("resource"),
515
+ type: z7.literal("resource"),
341
516
  // resource id
342
- value: z6.string()
517
+ value: z7.string()
343
518
  }),
344
- z6.object({
519
+ z7.object({
345
520
  ...baseProp,
346
- type: z6.literal("expression"),
521
+ type: z7.literal("expression"),
347
522
  // expression code
348
- value: z6.string()
523
+ value: z7.string()
349
524
  }),
350
- z6.object({
525
+ z7.object({
351
526
  ...baseProp,
352
- type: z6.literal("action"),
353
- value: z6.array(
354
- z6.object({
355
- type: z6.literal("execute"),
356
- args: z6.array(z6.string()),
357
- code: z6.string()
527
+ type: z7.literal("action"),
528
+ value: z7.array(
529
+ z7.object({
530
+ type: z7.literal("execute"),
531
+ args: z7.array(z7.string()),
532
+ code: z7.string()
358
533
  })
359
534
  )
535
+ }),
536
+ z7.object({
537
+ ...baseProp,
538
+ type: z7.literal("animationAction"),
539
+ value: animationActionSchema
360
540
  })
361
541
  ]);
362
- var Props = z6.map(PropId, Prop);
542
+ var Props = z7.map(PropId, Prop);
363
543
 
364
544
  // src/schema/breakpoints.ts
365
- import { z as z7 } from "zod";
366
- var BreakpointId = z7.string();
367
- var Breakpoint = z7.object({
545
+ import { z as z8 } from "zod";
546
+ var BreakpointId = z8.string();
547
+ var Breakpoint = z8.object({
368
548
  id: BreakpointId,
369
- label: z7.string(),
370
- minWidth: z7.number().optional(),
371
- maxWidth: z7.number().optional()
549
+ label: z8.string(),
550
+ minWidth: z8.number().optional(),
551
+ maxWidth: z8.number().optional()
372
552
  }).refine(({ minWidth, maxWidth }) => {
373
553
  return (
374
554
  // Either min or max width have to be defined
@@ -376,7 +556,7 @@ var Breakpoint = z7.object({
376
556
  minWidth === void 0 && maxWidth === void 0
377
557
  );
378
558
  }, "Either minWidth or maxWidth should be defined");
379
- var Breakpoints = z7.map(BreakpointId, Breakpoint);
559
+ var Breakpoints = z8.map(BreakpointId, Breakpoint);
380
560
  var initialBreakpoints = [
381
561
  { id: "placeholder", label: "Base" },
382
562
  { id: "placeholder", label: "Tablet", maxWidth: 991 },
@@ -385,236 +565,255 @@ var initialBreakpoints = [
385
565
  ];
386
566
 
387
567
  // src/schema/style-sources.ts
388
- import { z as z8 } from "zod";
389
- var StyleSourceId = z8.string();
390
- var StyleSourceToken = z8.object({
391
- type: z8.literal("token"),
568
+ import { z as z9 } from "zod";
569
+ var StyleSourceId = z9.string();
570
+ var StyleSourceToken = z9.object({
571
+ type: z9.literal("token"),
392
572
  id: StyleSourceId,
393
- name: z8.string()
573
+ name: z9.string()
394
574
  });
395
- var StyleSourceLocal = z8.object({
396
- type: z8.literal("local"),
575
+ var StyleSourceLocal = z9.object({
576
+ type: z9.literal("local"),
397
577
  id: StyleSourceId
398
578
  });
399
- var StyleSource = z8.union([StyleSourceToken, StyleSourceLocal]);
400
- var StyleSources = z8.map(StyleSourceId, StyleSource);
579
+ var StyleSource = z9.union([StyleSourceToken, StyleSourceLocal]);
580
+ var StyleSources = z9.map(StyleSourceId, StyleSource);
401
581
 
402
582
  // src/schema/style-source-selections.ts
403
- import { z as z9 } from "zod";
404
- var InstanceId2 = z9.string();
405
- var StyleSourceId2 = z9.string();
406
- var StyleSourceSelection = z9.object({
583
+ import { z as z10 } from "zod";
584
+ var InstanceId2 = z10.string();
585
+ var StyleSourceId2 = z10.string();
586
+ var StyleSourceSelection = z10.object({
407
587
  instanceId: InstanceId2,
408
- values: z9.array(StyleSourceId2)
588
+ values: z10.array(StyleSourceId2)
409
589
  });
410
- var StyleSourceSelections = z9.map(InstanceId2, StyleSourceSelection);
590
+ var StyleSourceSelections = z10.map(InstanceId2, StyleSourceSelection);
411
591
 
412
592
  // src/schema/styles.ts
413
- import { z as z10 } from "zod";
414
- import { StyleValue } from "@webstudio-is/css-engine";
415
- var StyleDeclRaw = z10.object({
416
- styleSourceId: z10.string(),
417
- breakpointId: z10.string(),
418
- state: z10.optional(z10.string()),
593
+ import { z as z11 } from "zod";
594
+ import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
595
+ var StyleDeclRaw = z11.object({
596
+ styleSourceId: z11.string(),
597
+ breakpointId: z11.string(),
598
+ state: z11.optional(z11.string()),
419
599
  // @todo can't figure out how to make property to be enum
420
- property: z10.string(),
421
- value: StyleValue,
422
- listed: z10.boolean().optional()
600
+ property: z11.string(),
601
+ value: StyleValue2,
602
+ listed: z11.boolean().optional().describe("Whether the style is from the Advanced panel")
423
603
  });
424
604
  var StyleDecl = StyleDeclRaw;
425
605
  var getStyleDeclKey = (styleDecl) => {
426
606
  return `${styleDecl.styleSourceId}:${styleDecl.breakpointId}:${styleDecl.property}:${styleDecl.state ?? ""}`;
427
607
  };
428
- var Styles = z10.map(z10.string(), StyleDecl);
608
+ var Styles = z11.map(z11.string(), StyleDecl);
429
609
 
430
610
  // src/schema/deployment.ts
431
- import { z as z11 } from "zod";
432
- var Templates = z11.enum([
433
- "vanilla",
611
+ import { z as z12 } from "zod";
612
+ var Templates = z12.enum([
434
613
  "docker",
435
614
  "vercel",
436
- "vercel-legacy",
437
615
  "netlify",
438
616
  "ssg",
439
617
  "ssg-netlify",
440
618
  "ssg-vercel"
441
619
  ]);
442
- var Deployment = z11.union([
443
- z11.object({
444
- destination: z11.literal("static"),
445
- name: z11.string(),
446
- assetsDomain: z11.string(),
620
+ var Deployment = z12.union([
621
+ z12.object({
622
+ destination: z12.literal("static"),
623
+ name: z12.string(),
624
+ assetsDomain: z12.string(),
447
625
  // Must be validated very strictly
448
- templates: z11.array(Templates)
626
+ templates: z12.array(Templates)
449
627
  }),
450
- z11.object({
451
- destination: z11.literal("saas").optional(),
452
- domains: z11.array(z11.string()),
453
- assetsDomain: z11.string().optional(),
628
+ z12.object({
629
+ destination: z12.literal("saas").optional(),
630
+ domains: z12.array(z12.string()),
631
+ assetsDomain: z12.string().optional(),
454
632
  /**
455
633
  * @deprecated This field is deprecated, use `domains` instead.
456
634
  */
457
- projectDomain: z11.string().optional(),
458
- excludeWstdDomainFromSearch: z11.boolean().optional()
635
+ projectDomain: z12.string().optional(),
636
+ excludeWstdDomainFromSearch: z12.boolean().optional()
459
637
  })
460
638
  ]);
461
639
 
462
640
  // src/schema/webstudio.ts
463
- import { z as z12 } from "zod";
464
- var WebstudioFragment = z12.object({
465
- children: z12.array(InstanceChild),
466
- instances: z12.array(Instance),
467
- assets: z12.array(Asset),
468
- dataSources: z12.array(DataSource),
469
- resources: z12.array(Resource),
470
- props: z12.array(Prop),
471
- breakpoints: z12.array(Breakpoint),
472
- styleSourceSelections: z12.array(StyleSourceSelection),
473
- styleSources: z12.array(StyleSource),
474
- styles: z12.array(StyleDecl)
641
+ import { z as z13 } from "zod";
642
+ var WebstudioFragment = z13.object({
643
+ children: z13.array(InstanceChild),
644
+ instances: z13.array(Instance),
645
+ assets: z13.array(Asset),
646
+ dataSources: z13.array(DataSource),
647
+ resources: z13.array(Resource),
648
+ props: z13.array(Prop),
649
+ breakpoints: z13.array(Breakpoint),
650
+ styleSourceSelections: z13.array(StyleSourceSelection),
651
+ styleSources: z13.array(StyleSource),
652
+ styles: z13.array(StyleDecl)
475
653
  });
476
654
 
477
655
  // src/schema/prop-meta.ts
478
- import { z as z13 } from "zod";
656
+ import { z as z14 } from "zod";
479
657
  var common = {
480
- label: z13.string().optional(),
481
- description: z13.string().optional(),
482
- required: z13.boolean()
658
+ label: z14.string().optional(),
659
+ description: z14.string().optional(),
660
+ required: z14.boolean()
483
661
  };
484
- var Number = z13.object({
662
+ var Tag = z14.object({
663
+ ...common,
664
+ control: z14.literal("tag"),
665
+ type: z14.literal("string"),
666
+ defaultValue: z14.undefined().optional(),
667
+ options: z14.array(z14.string())
668
+ });
669
+ var Number = z14.object({
485
670
  ...common,
486
- control: z13.literal("number"),
487
- type: z13.literal("number"),
488
- defaultValue: z13.number().optional()
671
+ control: z14.literal("number"),
672
+ type: z14.literal("number"),
673
+ defaultValue: z14.number().optional()
489
674
  });
490
- var Range = z13.object({
675
+ var Range = z14.object({
491
676
  ...common,
492
- control: z13.literal("range"),
493
- type: z13.literal("number"),
494
- defaultValue: z13.number().optional()
677
+ control: z14.literal("range"),
678
+ type: z14.literal("number"),
679
+ defaultValue: z14.number().optional()
495
680
  });
496
- var Text = z13.object({
681
+ var Text = z14.object({
497
682
  ...common,
498
- control: z13.literal("text"),
499
- type: z13.literal("string"),
500
- defaultValue: z13.string().optional(),
683
+ control: z14.literal("text"),
684
+ type: z14.literal("string"),
685
+ defaultValue: z14.string().optional(),
501
686
  /**
502
687
  * The number of rows in <textarea>. If set to 0 an <input> will be used instead.
503
688
  * In line with Storybook team's plan: https://github.com/storybookjs/storybook/issues/21100
504
689
  */
505
- rows: z13.number().optional()
690
+ rows: z14.number().optional()
691
+ });
692
+ var Resource2 = z14.object({
693
+ ...common,
694
+ control: z14.literal("resource"),
695
+ type: z14.literal("resource"),
696
+ defaultValue: z14.string().optional()
506
697
  });
507
- var Code = z13.object({
698
+ var Code = z14.object({
508
699
  ...common,
509
- control: z13.literal("code"),
510
- type: z13.literal("string"),
511
- language: z13.union([z13.literal("html"), z13.literal("markdown")]),
512
- defaultValue: z13.string().optional()
700
+ control: z14.literal("code"),
701
+ type: z14.literal("string"),
702
+ language: z14.union([z14.literal("html"), z14.literal("markdown")]),
703
+ defaultValue: z14.string().optional()
513
704
  });
514
- var CodeText = z13.object({
705
+ var CodeText = z14.object({
515
706
  ...common,
516
- control: z13.literal("codetext"),
517
- type: z13.literal("string"),
518
- defaultValue: z13.string().optional()
707
+ control: z14.literal("codetext"),
708
+ type: z14.literal("string"),
709
+ defaultValue: z14.string().optional()
519
710
  });
520
- var Color = z13.object({
711
+ var Color = z14.object({
521
712
  ...common,
522
- control: z13.literal("color"),
523
- type: z13.literal("string"),
524
- defaultValue: z13.string().optional()
713
+ control: z14.literal("color"),
714
+ type: z14.literal("string"),
715
+ defaultValue: z14.string().optional()
525
716
  });
526
- var Boolean = z13.object({
717
+ var Boolean = z14.object({
527
718
  ...common,
528
- control: z13.literal("boolean"),
529
- type: z13.literal("boolean"),
530
- defaultValue: z13.boolean().optional()
719
+ control: z14.literal("boolean"),
720
+ type: z14.literal("boolean"),
721
+ defaultValue: z14.boolean().optional()
531
722
  });
532
- var Radio = z13.object({
723
+ var Radio = z14.object({
533
724
  ...common,
534
- control: z13.literal("radio"),
535
- type: z13.literal("string"),
536
- defaultValue: z13.string().optional(),
537
- options: z13.array(z13.string())
725
+ control: z14.literal("radio"),
726
+ type: z14.literal("string"),
727
+ defaultValue: z14.string().optional(),
728
+ options: z14.array(z14.string())
538
729
  });
539
- var InlineRadio = z13.object({
730
+ var InlineRadio = z14.object({
540
731
  ...common,
541
- control: z13.literal("inline-radio"),
542
- type: z13.literal("string"),
543
- defaultValue: z13.string().optional(),
544
- options: z13.array(z13.string())
732
+ control: z14.literal("inline-radio"),
733
+ type: z14.literal("string"),
734
+ defaultValue: z14.string().optional(),
735
+ options: z14.array(z14.string())
545
736
  });
546
- var Select = z13.object({
737
+ var Select = z14.object({
547
738
  ...common,
548
- control: z13.literal("select"),
549
- type: z13.literal("string"),
550
- defaultValue: z13.string().optional(),
551
- options: z13.array(z13.string())
739
+ control: z14.literal("select"),
740
+ type: z14.literal("string"),
741
+ defaultValue: z14.string().optional(),
742
+ options: z14.array(z14.string())
552
743
  });
553
- var Check = z13.object({
744
+ var Check = z14.object({
554
745
  ...common,
555
- control: z13.literal("check"),
556
- type: z13.literal("string[]"),
557
- defaultValue: z13.array(z13.string()).optional(),
558
- options: z13.array(z13.string())
746
+ control: z14.literal("check"),
747
+ type: z14.literal("string[]"),
748
+ defaultValue: z14.array(z14.string()).optional(),
749
+ options: z14.array(z14.string())
559
750
  });
560
- var InlineCheck = z13.object({
751
+ var InlineCheck = z14.object({
561
752
  ...common,
562
- control: z13.literal("inline-check"),
563
- type: z13.literal("string[]"),
564
- defaultValue: z13.array(z13.string()).optional(),
565
- options: z13.array(z13.string())
753
+ control: z14.literal("inline-check"),
754
+ type: z14.literal("string[]"),
755
+ defaultValue: z14.array(z14.string()).optional(),
756
+ options: z14.array(z14.string())
566
757
  });
567
- var MultiSelect = z13.object({
758
+ var MultiSelect = z14.object({
568
759
  ...common,
569
- control: z13.literal("multi-select"),
570
- type: z13.literal("string[]"),
571
- defaultValue: z13.array(z13.string()).optional(),
572
- options: z13.array(z13.string())
760
+ control: z14.literal("multi-select"),
761
+ type: z14.literal("string[]"),
762
+ defaultValue: z14.array(z14.string()).optional(),
763
+ options: z14.array(z14.string())
573
764
  });
574
- var File = z13.object({
765
+ var File = z14.object({
575
766
  ...common,
576
- control: z13.literal("file"),
577
- type: z13.literal("string"),
578
- defaultValue: z13.string().optional(),
767
+ control: z14.literal("file"),
768
+ type: z14.literal("string"),
769
+ defaultValue: z14.string().optional(),
579
770
  /** https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept */
580
- accept: z13.string().optional()
771
+ accept: z14.string().optional()
581
772
  });
582
- var Url = z13.object({
773
+ var Url = z14.object({
583
774
  ...common,
584
- control: z13.literal("url"),
585
- type: z13.literal("string"),
586
- defaultValue: z13.string().optional()
775
+ control: z14.literal("url"),
776
+ type: z14.literal("string"),
777
+ defaultValue: z14.string().optional()
587
778
  });
588
- var Json = z13.object({
779
+ var Json = z14.object({
589
780
  ...common,
590
- control: z13.literal("json"),
591
- type: z13.literal("json"),
592
- defaultValue: z13.unknown().optional()
781
+ control: z14.literal("json"),
782
+ type: z14.literal("json"),
783
+ defaultValue: z14.unknown().optional()
593
784
  });
594
- var Date = z13.object({
785
+ var Date = z14.object({
595
786
  ...common,
596
- control: z13.literal("date"),
787
+ control: z14.literal("date"),
597
788
  // @todo not sure what type should be here
598
789
  // (we don't support Date yet, added for completeness)
599
- type: z13.literal("string"),
600
- defaultValue: z13.string().optional()
790
+ type: z14.literal("string"),
791
+ defaultValue: z14.string().optional()
601
792
  });
602
- var Action = z13.object({
793
+ var Action = z14.object({
603
794
  ...common,
604
- control: z13.literal("action"),
605
- type: z13.literal("action"),
606
- defaultValue: z13.undefined().optional()
795
+ control: z14.literal("action"),
796
+ type: z14.literal("action"),
797
+ defaultValue: z14.undefined().optional()
607
798
  });
608
- var TextContent = z13.object({
799
+ var TextContent = z14.object({
609
800
  ...common,
610
- control: z13.literal("textContent"),
611
- type: z13.literal("string"),
612
- defaultValue: z13.string().optional()
801
+ control: z14.literal("textContent"),
802
+ type: z14.literal("string"),
803
+ defaultValue: z14.string().optional()
613
804
  });
614
- var PropMeta = z13.union([
805
+ var AnimationAction = z14.object({
806
+ ...common,
807
+ control: z14.literal("animationAction"),
808
+ type: z14.literal("animationAction"),
809
+ defaultValue: z14.undefined().optional()
810
+ });
811
+ var PropMeta = z14.union([
812
+ Tag,
615
813
  Number,
616
814
  Range,
617
815
  Text,
816
+ Resource2,
618
817
  Code,
619
818
  CodeText,
620
819
  Color,
@@ -630,109 +829,24 @@ var PropMeta = z13.union([
630
829
  Json,
631
830
  Date,
632
831
  Action,
633
- TextContent
832
+ TextContent,
833
+ AnimationAction
634
834
  ]);
635
835
 
636
- // src/schema/embed-template.ts
637
- import { z as z14 } from "zod";
638
- import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
639
- var EmbedTemplateText = z14.object({
640
- type: z14.literal("text"),
641
- value: z14.string(),
642
- placeholder: z14.boolean().optional()
643
- });
644
- var EmbedTemplateExpression = z14.object({
645
- type: z14.literal("expression"),
646
- value: z14.string()
647
- });
648
- var EmbedTemplateVariable = z14.object({
649
- alias: z14.optional(z14.string()),
650
- initialValue: z14.unknown()
651
- });
652
- var EmbedTemplateProp = z14.union([
653
- z14.object({
654
- type: z14.literal("number"),
655
- name: z14.string(),
656
- value: z14.number()
657
- }),
658
- z14.object({
659
- type: z14.literal("string"),
660
- name: z14.string(),
661
- value: z14.string()
662
- }),
663
- z14.object({
664
- type: z14.literal("boolean"),
665
- name: z14.string(),
666
- value: z14.boolean()
667
- }),
668
- z14.object({
669
- type: z14.literal("string[]"),
670
- name: z14.string(),
671
- value: z14.array(z14.string())
672
- }),
673
- z14.object({
674
- type: z14.literal("json"),
675
- name: z14.string(),
676
- value: z14.unknown()
677
- }),
678
- z14.object({
679
- type: z14.literal("expression"),
680
- name: z14.string(),
681
- code: z14.string()
682
- }),
683
- z14.object({
684
- type: z14.literal("parameter"),
685
- name: z14.string(),
686
- variableName: z14.string(),
687
- variableAlias: z14.optional(z14.string())
688
- }),
689
- z14.object({
690
- type: z14.literal("action"),
691
- name: z14.string(),
692
- value: z14.array(
693
- z14.object({
694
- type: z14.literal("execute"),
695
- args: z14.optional(z14.array(z14.string())),
696
- code: z14.string()
697
- })
698
- )
699
- })
700
- ]);
701
- var EmbedTemplateStyleDeclRaw = z14.object({
702
- // State selector, e.g. :hover
703
- state: z14.optional(z14.string()),
704
- property: z14.string(),
705
- value: StyleValue2
706
- });
707
- var EmbedTemplateStyleDecl = EmbedTemplateStyleDeclRaw;
708
- var EmbedTemplateInstance = z14.lazy(
709
- () => z14.object({
710
- type: z14.literal("instance"),
711
- component: z14.string(),
712
- label: z14.optional(z14.string()),
713
- variables: z14.optional(z14.record(z14.string(), EmbedTemplateVariable)),
714
- props: z14.optional(z14.array(EmbedTemplateProp)),
715
- styles: z14.optional(z14.array(EmbedTemplateStyleDecl)),
716
- children: WsEmbedTemplate
717
- })
718
- );
719
- var WsEmbedTemplate = z14.lazy(
720
- () => z14.array(
721
- z14.union([EmbedTemplateInstance, EmbedTemplateText, EmbedTemplateExpression])
722
- )
723
- );
724
-
725
836
  // src/schema/component-meta.ts
726
837
  import { z as z15 } from "zod";
727
- var WsComponentPropsMeta = z15.object({
728
- props: z15.record(PropMeta),
729
- // Props that will be always visible in properties panel.
730
- initialProps: z15.array(z15.string()).optional()
838
+ import { StyleValue as StyleValue3 } from "@webstudio-is/css-engine";
839
+ var PresetStyleDecl = z15.object({
840
+ // State selector, e.g. :hover
841
+ state: z15.optional(z15.string()),
842
+ property: z15.string(),
843
+ value: StyleValue3
731
844
  });
732
845
  var componentCategories = [
733
846
  "general",
734
847
  "typography",
735
848
  "media",
849
+ "animations",
736
850
  "data",
737
851
  "forms",
738
852
  "localization",
@@ -741,27 +855,29 @@ var componentCategories = [
741
855
  "hidden",
742
856
  "internal"
743
857
  ];
744
- var stateCategories = ["states", "component-states"];
745
858
  var ComponentState = z15.object({
746
- category: z15.enum(stateCategories).optional(),
747
859
  selector: z15.string(),
748
860
  label: z15.string()
749
861
  });
750
- var defaultStates = [
751
- { selector: ":hover", label: "Hover" },
752
- { selector: ":active", label: "Active" },
753
- { selector: ":focus", label: "Focus" },
754
- { selector: ":focus-visible", label: "Focus Visible" },
755
- { selector: ":focus-within", label: "Focus Within" }
756
- ];
862
+ var ComponentContent = z15.string();
863
+ var ContentModel = z15.object({
864
+ /*
865
+ * instance - accepted by any parent with "instance" in children categories
866
+ * none - accepted by parents with this component name in children categories
867
+ */
868
+ category: z15.union([z15.literal("instance"), z15.literal("none")]),
869
+ /**
870
+ * enforce direct children of category or components
871
+ */
872
+ children: z15.array(ComponentContent),
873
+ /**
874
+ * enforce descendants of category or components
875
+ */
876
+ descendants: z15.array(ComponentContent).optional()
877
+ });
757
878
  var WsComponentMeta = z15.object({
758
879
  category: z15.enum(componentCategories).optional(),
759
- // container - can accept other components with dnd or be edited as text
760
- // control - usually form controls like inputs, without children
761
- // embed - images, videos or other embeddable components, without children
762
- // rich-text-child - formatted text fragment, not listed in components list
763
- type: z15.enum(["container", "control", "embed", "rich-text-child"]),
764
- constraints: Matchers.optional(),
880
+ contentModel: ContentModel.optional(),
765
881
  // when this field is specified component receives
766
882
  // prop with index of same components withiin specified ancestor
767
883
  // important to automatically enumerate collections without
@@ -769,13 +885,13 @@ var WsComponentMeta = z15.object({
769
885
  indexWithinAncestor: z15.optional(z15.string()),
770
886
  label: z15.optional(z15.string()),
771
887
  description: z15.string().optional(),
772
- icon: z15.string(),
773
- presetStyle: z15.optional(
774
- z15.record(z15.string(), z15.array(EmbedTemplateStyleDecl))
775
- ),
888
+ icon: z15.string().optional(),
889
+ presetStyle: z15.optional(z15.record(z15.string(), z15.array(PresetStyleDecl))),
776
890
  states: z15.optional(z15.array(ComponentState)),
777
- template: z15.optional(WsEmbedTemplate),
778
- order: z15.number().optional()
891
+ order: z15.number().optional(),
892
+ // properties and html attributes that will be always visible in properties panel
893
+ initialProps: z15.array(z15.string()).optional(),
894
+ props: z15.record(PropMeta).optional()
779
895
  });
780
896
 
781
897
  // src/core-metas.ts
@@ -788,67 +904,763 @@ import {
788
904
  } from "@webstudio-is/icons/svg";
789
905
 
790
906
  // src/__generated__/normalize.css.ts
907
+ var normalize_css_exports = {};
908
+ __export(normalize_css_exports, {
909
+ a: () => a,
910
+ address: () => address,
911
+ article: () => article,
912
+ aside: () => aside,
913
+ b: () => b,
914
+ body: () => body,
915
+ button: () => button,
916
+ checkbox: () => checkbox,
917
+ code: () => code,
918
+ div: () => div,
919
+ figure: () => figure,
920
+ footer: () => footer,
921
+ form: () => form,
922
+ h1: () => h1,
923
+ h2: () => h2,
924
+ h3: () => h3,
925
+ h4: () => h4,
926
+ h5: () => h5,
927
+ h6: () => h6,
928
+ header: () => header,
929
+ hr: () => hr,
930
+ html: () => html,
931
+ i: () => i,
932
+ img: () => img,
933
+ input: () => input,
934
+ kbd: () => kbd,
935
+ label: () => label,
936
+ legend: () => legend,
937
+ li: () => li,
938
+ main: () => main,
939
+ nav: () => nav,
940
+ ol: () => ol,
941
+ optgroup: () => optgroup,
942
+ p: () => p,
943
+ pre: () => pre,
944
+ progress: () => progress,
945
+ radio: () => radio,
946
+ samp: () => samp,
947
+ section: () => section,
948
+ select: () => select,
949
+ small: () => small,
950
+ span: () => span,
951
+ strong: () => strong,
952
+ sub: () => sub,
953
+ summary: () => summary,
954
+ sup: () => sup,
955
+ table: () => table,
956
+ textarea: () => textarea,
957
+ time: () => time,
958
+ ul: () => ul
959
+ });
960
+ var div = [
961
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
962
+ {
963
+ property: "border-top-width",
964
+ value: { type: "unit", unit: "px", value: 1 }
965
+ },
966
+ {
967
+ property: "border-right-width",
968
+ value: { type: "unit", unit: "px", value: 1 }
969
+ },
970
+ {
971
+ property: "border-bottom-width",
972
+ value: { type: "unit", unit: "px", value: 1 }
973
+ },
974
+ {
975
+ property: "border-left-width",
976
+ value: { type: "unit", unit: "px", value: 1 }
977
+ },
978
+ { property: "outline-width", value: { type: "unit", unit: "px", value: 1 } }
979
+ ];
980
+ var address = div;
981
+ var article = div;
982
+ var aside = div;
983
+ var figure = div;
984
+ var footer = div;
985
+ var header = div;
986
+ var main = div;
987
+ var nav = div;
988
+ var section = div;
989
+ var form = div;
990
+ var label = div;
991
+ var time = div;
992
+ var h1 = div;
993
+ var h2 = div;
994
+ var h3 = div;
995
+ var h4 = div;
996
+ var h5 = div;
997
+ var h6 = div;
998
+ var i = div;
999
+ var img = div;
1000
+ var a = div;
1001
+ var li = div;
1002
+ var ul = div;
1003
+ var ol = div;
1004
+ var p = div;
1005
+ var span = div;
791
1006
  var html = [
792
1007
  { property: "display", value: { type: "keyword", value: "grid" } },
793
- { property: "minHeight", value: { type: "unit", unit: "%", value: 100 } },
1008
+ { property: "min-height", value: { type: "unit", unit: "%", value: 100 } },
794
1009
  {
795
- property: "fontFamily",
1010
+ property: "font-family",
796
1011
  value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
797
1012
  },
798
- { property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
1013
+ { property: "font-size", value: { type: "unit", unit: "px", value: 16 } },
799
1014
  {
800
- property: "lineHeight",
1015
+ property: "line-height",
801
1016
  value: { type: "unit", unit: "number", value: 1.2 }
802
1017
  },
803
1018
  {
804
- property: "whiteSpaceCollapse",
1019
+ property: "white-space-collapse",
805
1020
  value: { type: "keyword", value: "preserve" }
806
1021
  }
807
1022
  ];
1023
+ var body = [
1024
+ { property: "margin-top", value: { type: "unit", unit: "number", value: 0 } },
1025
+ {
1026
+ property: "margin-right",
1027
+ value: { type: "unit", unit: "number", value: 0 }
1028
+ },
1029
+ {
1030
+ property: "margin-bottom",
1031
+ value: { type: "unit", unit: "number", value: 0 }
1032
+ },
1033
+ {
1034
+ property: "margin-left",
1035
+ value: { type: "unit", unit: "number", value: 0 }
1036
+ },
1037
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1038
+ {
1039
+ property: "border-top-width",
1040
+ value: { type: "unit", unit: "px", value: 1 }
1041
+ },
1042
+ {
1043
+ property: "border-right-width",
1044
+ value: { type: "unit", unit: "px", value: 1 }
1045
+ },
1046
+ {
1047
+ property: "border-bottom-width",
1048
+ value: { type: "unit", unit: "px", value: 1 }
1049
+ },
1050
+ {
1051
+ property: "border-left-width",
1052
+ value: { type: "unit", unit: "px", value: 1 }
1053
+ },
1054
+ {
1055
+ property: "-webkit-font-smoothing",
1056
+ value: { type: "keyword", value: "antialiased" }
1057
+ },
1058
+ {
1059
+ property: "-moz-osx-font-smoothing",
1060
+ value: { type: "keyword", value: "grayscale" }
1061
+ }
1062
+ ];
1063
+ var hr = [
1064
+ { property: "height", value: { type: "unit", unit: "number", value: 0 } },
1065
+ { property: "color", value: { type: "keyword", value: "inherit" } }
1066
+ ];
1067
+ var b = [
1068
+ {
1069
+ property: "font-weight",
1070
+ value: { type: "unit", unit: "number", value: 700 }
1071
+ },
1072
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1073
+ {
1074
+ property: "border-top-width",
1075
+ value: { type: "unit", unit: "px", value: 1 }
1076
+ },
1077
+ {
1078
+ property: "border-right-width",
1079
+ value: { type: "unit", unit: "px", value: 1 }
1080
+ },
1081
+ {
1082
+ property: "border-bottom-width",
1083
+ value: { type: "unit", unit: "px", value: 1 }
1084
+ },
1085
+ {
1086
+ property: "border-left-width",
1087
+ value: { type: "unit", unit: "px", value: 1 }
1088
+ }
1089
+ ];
1090
+ var strong = b;
1091
+ var code = [
1092
+ {
1093
+ property: "font-family",
1094
+ value: {
1095
+ type: "fontFamily",
1096
+ value: [
1097
+ "ui-monospace",
1098
+ "SFMono-Regular",
1099
+ "Consolas",
1100
+ "Liberation Mono",
1101
+ "Menlo",
1102
+ "monospace"
1103
+ ]
1104
+ }
1105
+ },
1106
+ { property: "font-size", value: { type: "unit", unit: "em", value: 1 } },
1107
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1108
+ {
1109
+ property: "border-top-width",
1110
+ value: { type: "unit", unit: "px", value: 1 }
1111
+ },
1112
+ {
1113
+ property: "border-right-width",
1114
+ value: { type: "unit", unit: "px", value: 1 }
1115
+ },
1116
+ {
1117
+ property: "border-bottom-width",
1118
+ value: { type: "unit", unit: "px", value: 1 }
1119
+ },
1120
+ {
1121
+ property: "border-left-width",
1122
+ value: { type: "unit", unit: "px", value: 1 }
1123
+ }
1124
+ ];
1125
+ var kbd = code;
1126
+ var samp = code;
1127
+ var pre = code;
1128
+ var small = [
1129
+ { property: "font-size", value: { type: "unit", unit: "%", value: 80 } },
1130
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1131
+ {
1132
+ property: "border-top-width",
1133
+ value: { type: "unit", unit: "px", value: 1 }
1134
+ },
1135
+ {
1136
+ property: "border-right-width",
1137
+ value: { type: "unit", unit: "px", value: 1 }
1138
+ },
1139
+ {
1140
+ property: "border-bottom-width",
1141
+ value: { type: "unit", unit: "px", value: 1 }
1142
+ },
1143
+ {
1144
+ property: "border-left-width",
1145
+ value: { type: "unit", unit: "px", value: 1 }
1146
+ }
1147
+ ];
1148
+ var sub = [
1149
+ { property: "font-size", value: { type: "unit", unit: "%", value: 75 } },
1150
+ {
1151
+ property: "line-height",
1152
+ value: { type: "unit", unit: "number", value: 0 }
1153
+ },
1154
+ { property: "position", value: { type: "keyword", value: "relative" } },
1155
+ { property: "vertical-align", value: { type: "keyword", value: "baseline" } },
1156
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1157
+ {
1158
+ property: "border-top-width",
1159
+ value: { type: "unit", unit: "px", value: 1 }
1160
+ },
1161
+ {
1162
+ property: "border-right-width",
1163
+ value: { type: "unit", unit: "px", value: 1 }
1164
+ },
1165
+ {
1166
+ property: "border-bottom-width",
1167
+ value: { type: "unit", unit: "px", value: 1 }
1168
+ },
1169
+ {
1170
+ property: "border-left-width",
1171
+ value: { type: "unit", unit: "px", value: 1 }
1172
+ },
1173
+ { property: "bottom", value: { type: "unit", unit: "em", value: -0.25 } }
1174
+ ];
1175
+ var sup = [
1176
+ { property: "font-size", value: { type: "unit", unit: "%", value: 75 } },
1177
+ {
1178
+ property: "line-height",
1179
+ value: { type: "unit", unit: "number", value: 0 }
1180
+ },
1181
+ { property: "position", value: { type: "keyword", value: "relative" } },
1182
+ { property: "vertical-align", value: { type: "keyword", value: "baseline" } },
1183
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1184
+ {
1185
+ property: "border-top-width",
1186
+ value: { type: "unit", unit: "px", value: 1 }
1187
+ },
1188
+ {
1189
+ property: "border-right-width",
1190
+ value: { type: "unit", unit: "px", value: 1 }
1191
+ },
1192
+ {
1193
+ property: "border-bottom-width",
1194
+ value: { type: "unit", unit: "px", value: 1 }
1195
+ },
1196
+ {
1197
+ property: "border-left-width",
1198
+ value: { type: "unit", unit: "px", value: 1 }
1199
+ },
1200
+ { property: "top", value: { type: "unit", unit: "em", value: -0.5 } }
1201
+ ];
1202
+ var table = [
1203
+ {
1204
+ property: "text-indent",
1205
+ value: { type: "unit", unit: "number", value: 0 }
1206
+ },
1207
+ {
1208
+ property: "border-top-width",
1209
+ value: { type: "unit", unit: "px", value: 1 }
1210
+ },
1211
+ {
1212
+ property: "border-right-width",
1213
+ value: { type: "unit", unit: "px", value: 1 }
1214
+ },
1215
+ {
1216
+ property: "border-bottom-width",
1217
+ value: { type: "unit", unit: "px", value: 1 }
1218
+ },
1219
+ {
1220
+ property: "border-left-width",
1221
+ value: { type: "unit", unit: "px", value: 1 }
1222
+ },
1223
+ {
1224
+ property: "border-top-color",
1225
+ value: { type: "keyword", value: "inherit" }
1226
+ },
1227
+ {
1228
+ property: "border-right-color",
1229
+ value: { type: "keyword", value: "inherit" }
1230
+ },
1231
+ {
1232
+ property: "border-bottom-color",
1233
+ value: { type: "keyword", value: "inherit" }
1234
+ },
1235
+ {
1236
+ property: "border-left-color",
1237
+ value: { type: "keyword", value: "inherit" }
1238
+ },
1239
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } }
1240
+ ];
1241
+ var input = [
1242
+ { property: "font-family", value: { type: "keyword", value: "inherit" } },
1243
+ { property: "font-size", value: { type: "unit", unit: "%", value: 100 } },
1244
+ {
1245
+ property: "line-height",
1246
+ value: { type: "unit", unit: "number", value: 1.15 }
1247
+ },
1248
+ { property: "margin-top", value: { type: "unit", unit: "number", value: 0 } },
1249
+ {
1250
+ property: "margin-right",
1251
+ value: { type: "unit", unit: "number", value: 0 }
1252
+ },
1253
+ {
1254
+ property: "margin-bottom",
1255
+ value: { type: "unit", unit: "number", value: 0 }
1256
+ },
1257
+ {
1258
+ property: "margin-left",
1259
+ value: { type: "unit", unit: "number", value: 0 }
1260
+ },
1261
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1262
+ {
1263
+ property: "border-top-width",
1264
+ value: { type: "unit", unit: "px", value: 1 }
1265
+ },
1266
+ {
1267
+ property: "border-right-width",
1268
+ value: { type: "unit", unit: "px", value: 1 }
1269
+ },
1270
+ {
1271
+ property: "border-bottom-width",
1272
+ value: { type: "unit", unit: "px", value: 1 }
1273
+ },
1274
+ {
1275
+ property: "border-left-width",
1276
+ value: { type: "unit", unit: "px", value: 1 }
1277
+ },
1278
+ { property: "border-top-style", value: { type: "keyword", value: "solid" } },
1279
+ {
1280
+ property: "border-right-style",
1281
+ value: { type: "keyword", value: "solid" }
1282
+ },
1283
+ {
1284
+ property: "border-bottom-style",
1285
+ value: { type: "keyword", value: "solid" }
1286
+ },
1287
+ { property: "border-left-style", value: { type: "keyword", value: "solid" } }
1288
+ ];
1289
+ var textarea = input;
1290
+ var optgroup = [
1291
+ { property: "font-family", value: { type: "keyword", value: "inherit" } },
1292
+ { property: "font-size", value: { type: "unit", unit: "%", value: 100 } },
1293
+ {
1294
+ property: "line-height",
1295
+ value: { type: "unit", unit: "number", value: 1.15 }
1296
+ },
1297
+ { property: "margin-top", value: { type: "unit", unit: "number", value: 0 } },
1298
+ {
1299
+ property: "margin-right",
1300
+ value: { type: "unit", unit: "number", value: 0 }
1301
+ },
1302
+ {
1303
+ property: "margin-bottom",
1304
+ value: { type: "unit", unit: "number", value: 0 }
1305
+ },
1306
+ {
1307
+ property: "margin-left",
1308
+ value: { type: "unit", unit: "number", value: 0 }
1309
+ },
1310
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1311
+ {
1312
+ property: "border-top-width",
1313
+ value: { type: "unit", unit: "px", value: 1 }
1314
+ },
1315
+ {
1316
+ property: "border-right-width",
1317
+ value: { type: "unit", unit: "px", value: 1 }
1318
+ },
1319
+ {
1320
+ property: "border-bottom-width",
1321
+ value: { type: "unit", unit: "px", value: 1 }
1322
+ },
1323
+ {
1324
+ property: "border-left-width",
1325
+ value: { type: "unit", unit: "px", value: 1 }
1326
+ }
1327
+ ];
1328
+ var radio = [
1329
+ { property: "font-family", value: { type: "keyword", value: "inherit" } },
1330
+ { property: "font-size", value: { type: "unit", unit: "%", value: 100 } },
1331
+ {
1332
+ property: "line-height",
1333
+ value: { type: "unit", unit: "number", value: 1.15 }
1334
+ },
1335
+ { property: "margin-top", value: { type: "unit", unit: "number", value: 0 } },
1336
+ {
1337
+ property: "margin-right",
1338
+ value: { type: "unit", unit: "number", value: 0 }
1339
+ },
1340
+ {
1341
+ property: "margin-bottom",
1342
+ value: { type: "unit", unit: "number", value: 0 }
1343
+ },
1344
+ {
1345
+ property: "margin-left",
1346
+ value: { type: "unit", unit: "number", value: 0 }
1347
+ },
1348
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1349
+ {
1350
+ property: "border-top-width",
1351
+ value: { type: "unit", unit: "px", value: 1 }
1352
+ },
1353
+ {
1354
+ property: "border-right-width",
1355
+ value: { type: "unit", unit: "px", value: 1 }
1356
+ },
1357
+ {
1358
+ property: "border-bottom-width",
1359
+ value: { type: "unit", unit: "px", value: 1 }
1360
+ },
1361
+ {
1362
+ property: "border-left-width",
1363
+ value: { type: "unit", unit: "px", value: 1 }
1364
+ },
1365
+ { property: "border-top-style", value: { type: "keyword", value: "none" } },
1366
+ { property: "border-right-style", value: { type: "keyword", value: "none" } },
1367
+ {
1368
+ property: "border-bottom-style",
1369
+ value: { type: "keyword", value: "none" }
1370
+ },
1371
+ { property: "border-left-style", value: { type: "keyword", value: "none" } }
1372
+ ];
1373
+ var checkbox = radio;
1374
+ var button = [
1375
+ { property: "font-family", value: { type: "keyword", value: "inherit" } },
1376
+ { property: "font-size", value: { type: "unit", unit: "%", value: 100 } },
1377
+ {
1378
+ property: "line-height",
1379
+ value: { type: "unit", unit: "number", value: 1.15 }
1380
+ },
1381
+ { property: "margin-top", value: { type: "unit", unit: "number", value: 0 } },
1382
+ {
1383
+ property: "margin-right",
1384
+ value: { type: "unit", unit: "number", value: 0 }
1385
+ },
1386
+ {
1387
+ property: "margin-bottom",
1388
+ value: { type: "unit", unit: "number", value: 0 }
1389
+ },
1390
+ {
1391
+ property: "margin-left",
1392
+ value: { type: "unit", unit: "number", value: 0 }
1393
+ },
1394
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1395
+ {
1396
+ property: "border-top-width",
1397
+ value: { type: "unit", unit: "px", value: 1 }
1398
+ },
1399
+ {
1400
+ property: "border-right-width",
1401
+ value: { type: "unit", unit: "px", value: 1 }
1402
+ },
1403
+ {
1404
+ property: "border-bottom-width",
1405
+ value: { type: "unit", unit: "px", value: 1 }
1406
+ },
1407
+ {
1408
+ property: "border-left-width",
1409
+ value: { type: "unit", unit: "px", value: 1 }
1410
+ },
1411
+ { property: "border-top-style", value: { type: "keyword", value: "solid" } },
1412
+ {
1413
+ property: "border-right-style",
1414
+ value: { type: "keyword", value: "solid" }
1415
+ },
1416
+ {
1417
+ property: "border-bottom-style",
1418
+ value: { type: "keyword", value: "solid" }
1419
+ },
1420
+ { property: "border-left-style", value: { type: "keyword", value: "solid" } },
1421
+ { property: "text-transform", value: { type: "keyword", value: "none" } }
1422
+ ];
1423
+ var select = button;
1424
+ var legend = [
1425
+ {
1426
+ property: "padding-top",
1427
+ value: { type: "unit", unit: "number", value: 0 }
1428
+ },
1429
+ {
1430
+ property: "padding-right",
1431
+ value: { type: "unit", unit: "number", value: 0 }
1432
+ },
1433
+ {
1434
+ property: "padding-bottom",
1435
+ value: { type: "unit", unit: "number", value: 0 }
1436
+ },
1437
+ {
1438
+ property: "padding-left",
1439
+ value: { type: "unit", unit: "number", value: 0 }
1440
+ },
1441
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1442
+ {
1443
+ property: "border-top-width",
1444
+ value: { type: "unit", unit: "px", value: 1 }
1445
+ },
1446
+ {
1447
+ property: "border-right-width",
1448
+ value: { type: "unit", unit: "px", value: 1 }
1449
+ },
1450
+ {
1451
+ property: "border-bottom-width",
1452
+ value: { type: "unit", unit: "px", value: 1 }
1453
+ },
1454
+ {
1455
+ property: "border-left-width",
1456
+ value: { type: "unit", unit: "px", value: 1 }
1457
+ }
1458
+ ];
1459
+ var progress = [
1460
+ { property: "vertical-align", value: { type: "keyword", value: "baseline" } },
1461
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1462
+ {
1463
+ property: "border-top-width",
1464
+ value: { type: "unit", unit: "px", value: 1 }
1465
+ },
1466
+ {
1467
+ property: "border-right-width",
1468
+ value: { type: "unit", unit: "px", value: 1 }
1469
+ },
1470
+ {
1471
+ property: "border-bottom-width",
1472
+ value: { type: "unit", unit: "px", value: 1 }
1473
+ },
1474
+ {
1475
+ property: "border-left-width",
1476
+ value: { type: "unit", unit: "px", value: 1 }
1477
+ }
1478
+ ];
1479
+ var summary = [
1480
+ { property: "display", value: { type: "keyword", value: "list-item" } },
1481
+ { property: "box-sizing", value: { type: "keyword", value: "border-box" } },
1482
+ {
1483
+ property: "border-top-width",
1484
+ value: { type: "unit", unit: "px", value: 1 }
1485
+ },
1486
+ {
1487
+ property: "border-right-width",
1488
+ value: { type: "unit", unit: "px", value: 1 }
1489
+ },
1490
+ {
1491
+ property: "border-bottom-width",
1492
+ value: { type: "unit", unit: "px", value: 1 }
1493
+ },
1494
+ {
1495
+ property: "border-left-width",
1496
+ value: { type: "unit", unit: "px", value: 1 }
1497
+ }
1498
+ ];
1499
+
1500
+ // src/runtime.ts
1501
+ var tagProperty = "data-ws-tag";
1502
+
1503
+ // src/__generated__/tags.ts
1504
+ var tags = [
1505
+ "div",
1506
+ "span",
1507
+ "a",
1508
+ "abbr",
1509
+ "address",
1510
+ "area",
1511
+ "article",
1512
+ "aside",
1513
+ "audio",
1514
+ "b",
1515
+ "bdi",
1516
+ "bdo",
1517
+ "blockquote",
1518
+ "body",
1519
+ "br",
1520
+ "button",
1521
+ "canvas",
1522
+ "caption",
1523
+ "cite",
1524
+ "code",
1525
+ "col",
1526
+ "colgroup",
1527
+ "data",
1528
+ "datalist",
1529
+ "dd",
1530
+ "del",
1531
+ "details",
1532
+ "dfn",
1533
+ "dialog",
1534
+ "dl",
1535
+ "dt",
1536
+ "em",
1537
+ "embed",
1538
+ "fieldset",
1539
+ "figcaption",
1540
+ "figure",
1541
+ "footer",
1542
+ "form",
1543
+ "h1",
1544
+ "h2",
1545
+ "h3",
1546
+ "h4",
1547
+ "h5",
1548
+ "h6",
1549
+ "head",
1550
+ "header",
1551
+ "hgroup",
1552
+ "hr",
1553
+ "html",
1554
+ "i",
1555
+ "iframe",
1556
+ "img",
1557
+ "input",
1558
+ "ins",
1559
+ "kbd",
1560
+ "label",
1561
+ "legend",
1562
+ "li",
1563
+ "main",
1564
+ "map",
1565
+ "mark",
1566
+ "menu",
1567
+ "meter",
1568
+ "nav",
1569
+ "object",
1570
+ "ol",
1571
+ "optgroup",
1572
+ "option",
1573
+ "output",
1574
+ "p",
1575
+ "picture",
1576
+ "pre",
1577
+ "progress",
1578
+ "q",
1579
+ "rp",
1580
+ "rt",
1581
+ "ruby",
1582
+ "s",
1583
+ "samp",
1584
+ "search",
1585
+ "section",
1586
+ "select",
1587
+ "slot",
1588
+ "small",
1589
+ "source",
1590
+ "strong",
1591
+ "sub",
1592
+ "summary",
1593
+ "sup",
1594
+ "table",
1595
+ "tbody",
1596
+ "td",
1597
+ "textarea",
1598
+ "tfoot",
1599
+ "th",
1600
+ "thead",
1601
+ "time",
1602
+ "tr",
1603
+ "track",
1604
+ "u",
1605
+ "ul",
1606
+ "var",
1607
+ "video",
1608
+ "wbr"
1609
+ ];
808
1610
 
809
1611
  // src/core-metas.ts
810
1612
  var rootComponent = "ws:root";
811
1613
  var rootMeta = {
812
- type: "container",
813
1614
  label: "Global Root",
814
1615
  icon: SettingsIcon,
815
1616
  presetStyle: {
816
1617
  html
817
1618
  }
818
1619
  };
819
- var rootPropsMeta = {
820
- props: {}
1620
+ var elementComponent = "ws:element";
1621
+ var elementMeta = {
1622
+ label: "Element",
1623
+ // convert [object Module] to [object Object] to enable structured cloning
1624
+ presetStyle: { ...normalize_css_exports },
1625
+ initialProps: [tagProperty, "id", "class"],
1626
+ props: {
1627
+ [tagProperty]: {
1628
+ type: "string",
1629
+ control: "tag",
1630
+ required: true,
1631
+ options: tags
1632
+ }
1633
+ }
821
1634
  };
822
1635
  var portalComponent = "Slot";
823
1636
  var collectionComponent = "ws:collection";
824
1637
  var collectionMeta = {
825
- type: "container",
826
1638
  label: "Collection",
827
- icon: ListViewIcon
828
- };
829
- var collectionPropsMeta = {
1639
+ icon: ListViewIcon,
1640
+ contentModel: {
1641
+ category: "instance",
1642
+ children: ["instance"]
1643
+ },
1644
+ initialProps: ["data"],
830
1645
  props: {
831
1646
  data: {
832
1647
  required: true,
833
1648
  control: "json",
834
1649
  type: "json"
835
1650
  }
836
- },
837
- initialProps: ["data"]
1651
+ }
838
1652
  };
839
1653
  var descendantComponent = "ws:descendant";
840
1654
  var descendantMeta = {
841
- type: "control",
842
1655
  label: "Descendant",
843
1656
  icon: PaintBrushIcon,
1657
+ contentModel: {
1658
+ category: "none",
1659
+ children: []
1660
+ },
844
1661
  // @todo infer possible presets
845
1662
  presetStyle: {},
846
- constraints: {
847
- relation: "parent",
848
- component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
849
- }
850
- };
851
- var descendantPropsMeta = {
1663
+ initialProps: ["selector"],
852
1664
  props: {
853
1665
  selector: {
854
1666
  required: true,
@@ -873,55 +1685,35 @@ var descendantPropsMeta = {
873
1685
  " hr"
874
1686
  ]
875
1687
  }
876
- },
877
- initialProps: ["selector"]
1688
+ }
878
1689
  };
879
1690
  var blockComponent = "ws:block";
880
1691
  var blockTemplateComponent = "ws:block-template";
881
1692
  var blockTemplateMeta = {
882
- type: "container",
883
1693
  icon: AddTemplateInstanceIcon,
884
- constraints: {
885
- relation: "parent",
886
- component: { $eq: blockComponent }
1694
+ contentModel: {
1695
+ category: "none",
1696
+ children: ["instance"]
887
1697
  }
888
1698
  };
889
- var blockTemplatePropsMeta = {
890
- props: {}
891
- };
892
1699
  var blockMeta = {
893
- type: "container",
894
1700
  label: "Content Block",
895
1701
  icon: ContentBlockIcon,
896
- constraints: [
897
- {
898
- relation: "ancestor",
899
- component: { $nin: [collectionComponent, blockComponent] }
900
- },
901
- {
902
- relation: "child",
903
- component: { $eq: blockTemplateComponent }
904
- }
905
- ]
906
- };
907
- var blockPropsMeta = {
908
- props: {}
1702
+ contentModel: {
1703
+ category: "instance",
1704
+ children: [blockTemplateComponent, "instance"]
1705
+ }
909
1706
  };
910
1707
  var coreMetas = {
911
1708
  [rootComponent]: rootMeta,
1709
+ [elementComponent]: elementMeta,
912
1710
  [collectionComponent]: collectionMeta,
913
1711
  [descendantComponent]: descendantMeta,
914
1712
  [blockComponent]: blockMeta,
915
1713
  [blockTemplateComponent]: blockTemplateMeta
916
1714
  };
917
- var corePropsMetas = {
918
- [rootComponent]: rootPropsMeta,
919
- [collectionComponent]: collectionPropsMeta,
920
- [descendantComponent]: descendantPropsMeta,
921
- [blockComponent]: blockPropsMeta,
922
- [blockTemplateComponent]: blockTemplatePropsMeta
923
- };
924
- var isCoreComponent = (component) => component === rootComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
1715
+ var isCoreComponent = (component) => component === rootComponent || component === elementComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
1716
+ var isComponentDetachable = (component) => component !== rootComponent && component !== blockTemplateComponent && component !== descendantComponent;
925
1717
 
926
1718
  // src/instances-utils.ts
927
1719
  var ROOT_INSTANCE_ID = ":root";
@@ -968,6 +1760,51 @@ var parseComponentName = (componentName) => {
968
1760
  }
969
1761
  return [namespace, name];
970
1762
  };
1763
+ var getIndexesWithinAncestors = (metas, instances, rootIds) => {
1764
+ const ancestors = /* @__PURE__ */ new Set();
1765
+ for (const meta of metas.values()) {
1766
+ if (meta.indexWithinAncestor !== void 0) {
1767
+ ancestors.add(meta.indexWithinAncestor);
1768
+ }
1769
+ }
1770
+ const indexes = /* @__PURE__ */ new Map();
1771
+ const traverseInstances2 = (instances2, instanceId, latestIndexes2 = /* @__PURE__ */ new Map()) => {
1772
+ const instance = instances2.get(instanceId);
1773
+ if (instance === void 0) {
1774
+ return;
1775
+ }
1776
+ const meta = metas.get(instance.component);
1777
+ if (ancestors.has(instance.component)) {
1778
+ latestIndexes2 = new Map(latestIndexes2);
1779
+ latestIndexes2.set(instance.component, /* @__PURE__ */ new Map());
1780
+ }
1781
+ if (instance.component === blockTemplateComponent) {
1782
+ latestIndexes2 = new Map(latestIndexes2);
1783
+ for (const key of latestIndexes2.keys()) {
1784
+ latestIndexes2.set(key, /* @__PURE__ */ new Map());
1785
+ }
1786
+ }
1787
+ if (meta?.indexWithinAncestor !== void 0) {
1788
+ const ancestorIndexes = latestIndexes2.get(meta.indexWithinAncestor);
1789
+ if (ancestorIndexes) {
1790
+ let index = ancestorIndexes.get(instance.component) ?? -1;
1791
+ index += 1;
1792
+ ancestorIndexes.set(instance.component, index);
1793
+ indexes.set(instance.id, index);
1794
+ }
1795
+ }
1796
+ for (const child of instance.children) {
1797
+ if (child.type === "id") {
1798
+ traverseInstances2(instances2, child.value, latestIndexes2);
1799
+ }
1800
+ }
1801
+ };
1802
+ const latestIndexes = /* @__PURE__ */ new Map();
1803
+ for (const instanceId of rootIds) {
1804
+ traverseInstances2(instances, instanceId, latestIndexes);
1805
+ }
1806
+ return indexes;
1807
+ };
971
1808
 
972
1809
  // src/expression.ts
973
1810
  import {
@@ -975,6 +1812,13 @@ import {
975
1812
  parseExpressionAt
976
1813
  } from "acorn";
977
1814
  import { simple } from "acorn-walk";
1815
+ var SYSTEM_VARIABLE_ID = ":system";
1816
+ var systemParameter = {
1817
+ id: SYSTEM_VARIABLE_ID,
1818
+ scopeInstanceId: ROOT_INSTANCE_ID,
1819
+ type: "parameter",
1820
+ name: "system"
1821
+ };
978
1822
  var lintExpression = ({
979
1823
  expression,
980
1824
  availableVariables = /* @__PURE__ */ new Set(),
@@ -1085,6 +1929,9 @@ var lintExpression = ({
1085
1929
  return diagnostics;
1086
1930
  };
1087
1931
  var isLiteralNode = (node) => {
1932
+ if (node.type === "Identifier" && node.name === "undefined") {
1933
+ return true;
1934
+ }
1088
1935
  if (node.type === "Literal") {
1089
1936
  return true;
1090
1937
  }
@@ -1226,11 +2073,17 @@ var generateObjectExpression = (map) => {
1226
2073
  return generated;
1227
2074
  };
1228
2075
  var dataSourceVariablePrefix = "$ws$dataSource$";
1229
- var encodeDataSourceVariable = (id) => {
2076
+ var encodeDataVariableId = (id) => {
2077
+ if (id === SYSTEM_VARIABLE_ID) {
2078
+ return "$ws$system";
2079
+ }
1230
2080
  const encoded = id.replaceAll("-", "__DASH__");
1231
2081
  return `${dataSourceVariablePrefix}${encoded}`;
1232
2082
  };
1233
- var decodeDataSourceVariable = (name) => {
2083
+ var decodeDataVariableId = (name) => {
2084
+ if (name === "$ws$system") {
2085
+ return SYSTEM_VARIABLE_ID;
2086
+ }
1234
2087
  if (name.startsWith(dataSourceVariablePrefix)) {
1235
2088
  const encoded = name.slice(dataSourceVariablePrefix.length);
1236
2089
  return encoded.replaceAll("__DASH__", "-");
@@ -1247,8 +2100,11 @@ var generateExpression = ({
1247
2100
  expression,
1248
2101
  executable: true,
1249
2102
  replaceVariable: (identifier) => {
1250
- const depId = decodeDataSourceVariable(identifier);
1251
- const dep = depId ? dataSources.get(depId) : void 0;
2103
+ const depId = decodeDataVariableId(identifier);
2104
+ let dep = depId ? dataSources.get(depId) : void 0;
2105
+ if (depId === SYSTEM_VARIABLE_ID) {
2106
+ dep = systemParameter;
2107
+ }
1252
2108
  if (dep) {
1253
2109
  usedDataSources?.set(dep.id, dep);
1254
2110
  return scope.getName(dep.id, dep.name);
@@ -1405,26 +2261,26 @@ var generateResources = ({
1405
2261
  `;
1406
2262
  generatedRequest += ` headers: [
1407
2263
  `;
1408
- for (const header of resource.headers) {
2264
+ for (const header2 of resource.headers) {
1409
2265
  const value = generateExpression({
1410
- expression: header.value,
2266
+ expression: header2.value,
1411
2267
  dataSources,
1412
2268
  usedDataSources,
1413
2269
  scope
1414
2270
  });
1415
- generatedRequest += ` { name: "${header.name}", value: ${value} },
2271
+ generatedRequest += ` { name: "${header2.name}", value: ${value} },
1416
2272
  `;
1417
2273
  }
1418
2274
  generatedRequest += ` ],
1419
2275
  `;
1420
2276
  if (resource.body !== void 0 && resource.body.length > 0) {
1421
- const body = generateExpression({
2277
+ const body2 = generateExpression({
1422
2278
  expression: resource.body,
1423
2279
  dataSources,
1424
2280
  usedDataSources,
1425
2281
  scope
1426
2282
  });
1427
- generatedRequest += ` body: ${body},
2283
+ generatedRequest += ` body: ${body2},
1428
2284
  `;
1429
2285
  }
1430
2286
  generatedRequest += ` }
@@ -1440,12 +2296,11 @@ var generateResources = ({
1440
2296
  `;
1441
2297
  }
1442
2298
  if (dataSource.type === "parameter") {
1443
- if (dataSource.id !== page.systemDataSourceId) {
1444
- continue;
1445
- }
1446
- const name = scope.getName(dataSource.id, dataSource.name);
1447
- generatedVariables += ` const ${name} = _props.system
2299
+ if (dataSource.id === page.systemDataSourceId || dataSource.id === SYSTEM_VARIABLE_ID) {
2300
+ const name = scope.getName(dataSource.id, dataSource.name);
2301
+ generatedVariables += ` const ${name} = _props.system
1448
2302
  `;
2303
+ }
1449
2304
  }
1450
2305
  }
1451
2306
  let generated = "";
@@ -1534,7 +2389,9 @@ var replaceFormActionsWithResources = ({
1534
2389
  name: "action",
1535
2390
  method: getMethod(method),
1536
2391
  url: JSON.stringify(action),
1537
- headers: []
2392
+ headers: [
2393
+ { name: "Content-Type", value: JSON.stringify("application/json") }
2394
+ ]
1538
2395
  });
1539
2396
  }
1540
2397
  }
@@ -1642,7 +2499,7 @@ var generatePageMeta = ({
1642
2499
  continue;
1643
2500
  }
1644
2501
  if (dataSource.type === "parameter") {
1645
- if (dataSource.id === page.systemDataSourceId) {
2502
+ if (dataSource.id === page.systemDataSourceId || dataSource.id === SYSTEM_VARIABLE_ID) {
1646
2503
  const valueName = localScope.getName(dataSource.id, dataSource.name);
1647
2504
  generated += ` let ${valueName} = system
1648
2505
  `;
@@ -1686,6 +2543,208 @@ var generatePageMeta = ({
1686
2543
  `;
1687
2544
  return generated;
1688
2545
  };
2546
+
2547
+ // src/css.ts
2548
+ import { kebabCase } from "change-case";
2549
+ import {
2550
+ createRegularStyleSheet,
2551
+ generateAtomic
2552
+ } from "@webstudio-is/css-engine";
2553
+ import { getFontFaces } from "@webstudio-is/fonts";
2554
+ var addFontRules = ({
2555
+ sheet,
2556
+ assets,
2557
+ assetBaseUrl
2558
+ }) => {
2559
+ const fontAssets = [];
2560
+ for (const asset of assets.values()) {
2561
+ if (asset.type === "font") {
2562
+ fontAssets.push(asset);
2563
+ }
2564
+ }
2565
+ const fontFaces = getFontFaces(fontAssets, { assetBaseUrl });
2566
+ for (const fontFace of fontFaces) {
2567
+ sheet.addFontFaceRule(fontFace);
2568
+ }
2569
+ };
2570
+ var createImageValueTransformer = (assets, { assetBaseUrl }) => (styleValue) => {
2571
+ if (styleValue.type === "image" && styleValue.value.type === "asset") {
2572
+ const asset = assets.get(styleValue.value.value);
2573
+ if (asset === void 0) {
2574
+ return { type: "keyword", value: "none" };
2575
+ }
2576
+ const url = `${assetBaseUrl}${asset.name}`;
2577
+ return {
2578
+ type: "image",
2579
+ value: {
2580
+ type: "url",
2581
+ url
2582
+ },
2583
+ hidden: styleValue.hidden
2584
+ };
2585
+ }
2586
+ };
2587
+ var normalizeClassName = (name) => kebabCase(name);
2588
+ var generateCss = ({
2589
+ assets,
2590
+ instances,
2591
+ props,
2592
+ breakpoints,
2593
+ styles,
2594
+ styleSourceSelections,
2595
+ componentMetas,
2596
+ assetBaseUrl,
2597
+ atomic
2598
+ }) => {
2599
+ const fontSheet = createRegularStyleSheet({ name: "ssr" });
2600
+ const presetSheet = createRegularStyleSheet({ name: "ssr" });
2601
+ const userSheet = createRegularStyleSheet({ name: "ssr" });
2602
+ addFontRules({ sheet: fontSheet, assets, assetBaseUrl });
2603
+ presetSheet.addMediaRule("presets");
2604
+ const presetClasses = /* @__PURE__ */ new Map();
2605
+ const scope = createScope([], normalizeClassName, "-");
2606
+ const tagsByComponent = /* @__PURE__ */ new Map();
2607
+ tagsByComponent.set(rootComponent, /* @__PURE__ */ new Set(["html"]));
2608
+ const tagByInstanceId = /* @__PURE__ */ new Map();
2609
+ for (const prop of props.values()) {
2610
+ if (prop.type === "string" && prop.name === "tag") {
2611
+ tagByInstanceId.set(prop.instanceId, prop.value);
2612
+ }
2613
+ }
2614
+ for (const instance of instances.values()) {
2615
+ const propTag = tagByInstanceId.get(instance.id);
2616
+ const meta = componentMetas.get(instance.component);
2617
+ const metaTag = Object.keys(meta?.presetStyle ?? {}).at(0);
2618
+ let componentTags = tagsByComponent.get(instance.component);
2619
+ if (componentTags === void 0) {
2620
+ componentTags = /* @__PURE__ */ new Set();
2621
+ tagsByComponent.set(instance.component, componentTags);
2622
+ }
2623
+ const tag = instance.tag ?? propTag ?? metaTag;
2624
+ if (tag) {
2625
+ componentTags.add(tag);
2626
+ }
2627
+ }
2628
+ for (const [component, meta] of componentMetas) {
2629
+ const componentTags = tagsByComponent.get(component);
2630
+ const [_namespace, componentName] = parseComponentName(component);
2631
+ const className = `w-${scope.getName(component, meta.label ?? componentName)}`;
2632
+ const presetStyle = Object.entries(meta.presetStyle ?? {});
2633
+ if (presetStyle.length > 0) {
2634
+ presetClasses.set(component, className);
2635
+ }
2636
+ for (const [tag, styles2] of presetStyle) {
2637
+ if (!componentTags?.has(tag)) {
2638
+ continue;
2639
+ }
2640
+ const selector = component === rootComponent ? ":root" : `${tag}.${className}`;
2641
+ const rule = presetSheet.addNestingRule(selector);
2642
+ for (const declaration of styles2) {
2643
+ rule.setDeclaration({
2644
+ breakpoint: "presets",
2645
+ selector: declaration.state ?? "",
2646
+ property: declaration.property,
2647
+ value: declaration.value
2648
+ });
2649
+ }
2650
+ }
2651
+ }
2652
+ for (const breakpoint of breakpoints.values()) {
2653
+ userSheet.addMediaRule(breakpoint.id, breakpoint);
2654
+ }
2655
+ const imageValueTransformer = createImageValueTransformer(assets, {
2656
+ assetBaseUrl
2657
+ });
2658
+ userSheet.setTransformer(imageValueTransformer);
2659
+ for (const styleDecl of styles.values()) {
2660
+ const rule = userSheet.addMixinRule(styleDecl.styleSourceId);
2661
+ rule.setDeclaration({
2662
+ breakpoint: styleDecl.breakpointId,
2663
+ selector: styleDecl.state ?? "",
2664
+ property: styleDecl.property,
2665
+ value: styleDecl.value
2666
+ });
2667
+ }
2668
+ const classes = /* @__PURE__ */ new Map();
2669
+ const parentIdByInstanceId = /* @__PURE__ */ new Map();
2670
+ for (const instance of instances.values()) {
2671
+ const presetClass = presetClasses.get(instance.component);
2672
+ if (presetClass) {
2673
+ classes.set(instance.id, [presetClass]);
2674
+ }
2675
+ for (const child of instance.children) {
2676
+ if (child.type === "id") {
2677
+ parentIdByInstanceId.set(child.value, instance.id);
2678
+ }
2679
+ }
2680
+ }
2681
+ const descendantSelectorByInstanceId = /* @__PURE__ */ new Map();
2682
+ for (const prop of props.values()) {
2683
+ if (prop.name === "selector" && prop.type === "string") {
2684
+ descendantSelectorByInstanceId.set(prop.instanceId, prop.value);
2685
+ }
2686
+ }
2687
+ const instanceByRule = /* @__PURE__ */ new Map();
2688
+ for (const selection of styleSourceSelections.values()) {
2689
+ let { instanceId } = selection;
2690
+ const { values } = selection;
2691
+ if (instanceId === ROOT_INSTANCE_ID) {
2692
+ const rule2 = userSheet.addNestingRule(`:root`);
2693
+ rule2.applyMixins(values);
2694
+ continue;
2695
+ }
2696
+ let descendantSuffix = "";
2697
+ const instance = instances.get(instanceId);
2698
+ if (instance === void 0) {
2699
+ continue;
2700
+ }
2701
+ if (instance.component === descendantComponent) {
2702
+ const parentId = parentIdByInstanceId.get(instanceId);
2703
+ const descendantSelector = descendantSelectorByInstanceId.get(instanceId);
2704
+ if (parentId && descendantSelector) {
2705
+ descendantSuffix = descendantSelector;
2706
+ instanceId = parentId;
2707
+ }
2708
+ }
2709
+ const meta = componentMetas.get(instance.component);
2710
+ const [_namespace, shortName] = parseComponentName(instance.component);
2711
+ const baseName = instance.label ?? meta?.label ?? shortName;
2712
+ const className = `w-${scope.getName(instanceId, baseName)}`;
2713
+ if (atomic === false) {
2714
+ let classList = classes.get(instanceId);
2715
+ if (classList === void 0) {
2716
+ classList = [];
2717
+ classes.set(instanceId, classList);
2718
+ }
2719
+ classList.push(className);
2720
+ }
2721
+ const rule = userSheet.addNestingRule(`.${className}`, descendantSuffix);
2722
+ rule.applyMixins(values);
2723
+ instanceByRule.set(rule, instanceId);
2724
+ }
2725
+ const fontCss = fontSheet.cssText;
2726
+ const presetCss = presetSheet.cssText.replaceAll(
2727
+ "@media all ",
2728
+ "@layer presets "
2729
+ );
2730
+ if (atomic) {
2731
+ const { cssText } = generateAtomic(userSheet, {
2732
+ getKey: (rule) => instanceByRule.get(rule),
2733
+ transformValue: imageValueTransformer,
2734
+ classes
2735
+ });
2736
+ return {
2737
+ cssText: `${fontCss}${presetCss}
2738
+ ${cssText}`,
2739
+ classes
2740
+ };
2741
+ }
2742
+ return {
2743
+ cssText: `${fontCss}${presetCss}
2744
+ ${userSheet.cssText}`,
2745
+ classes
2746
+ };
2747
+ };
1689
2748
  export {
1690
2749
  Asset,
1691
2750
  Assets,
@@ -1693,14 +2752,11 @@ export {
1693
2752
  Breakpoints,
1694
2753
  CompilerSettings,
1695
2754
  ComponentState,
2755
+ ContentModel,
1696
2756
  DataSource,
1697
2757
  DataSourceVariableValue,
1698
2758
  DataSources,
1699
2759
  Deployment,
1700
- EmbedTemplateInstance,
1701
- EmbedTemplateProp,
1702
- EmbedTemplateStyleDecl,
1703
- EmbedTemplateVariable,
1704
2760
  ExpressionChild,
1705
2761
  Folder,
1706
2762
  FolderName,
@@ -1712,24 +2768,24 @@ export {
1712
2768
  Instance,
1713
2769
  InstanceChild,
1714
2770
  Instances,
1715
- Matcher,
1716
- MatcherOperation,
1717
- MatcherRelation,
1718
- Matchers,
2771
+ OldPagePath,
1719
2772
  PageName,
1720
2773
  PagePath,
1721
2774
  PageRedirect,
1722
2775
  PageTitle,
1723
2776
  Pages,
2777
+ PresetStyleDecl,
1724
2778
  ProjectNewRedirectPath,
1725
2779
  Prop,
1726
2780
  PropMeta,
1727
2781
  Props,
2782
+ RANGE_UNITS,
1728
2783
  ROOT_FOLDER_ID,
1729
2784
  ROOT_INSTANCE_ID,
1730
2785
  Resource,
1731
2786
  ResourceRequest,
1732
2787
  Resources,
2788
+ SYSTEM_VARIABLE_ID,
1733
2789
  StyleDecl,
1734
2790
  StyleSource,
1735
2791
  StyleSourceSelection,
@@ -1740,36 +2796,43 @@ export {
1740
2796
  TextChild,
1741
2797
  WebstudioFragment,
1742
2798
  WsComponentMeta,
1743
- WsEmbedTemplate,
2799
+ addFontRules,
2800
+ animationActionSchema,
2801
+ animationKeyframeSchema,
1744
2802
  blockComponent,
1745
2803
  blockTemplateComponent,
1746
2804
  blockTemplateMeta,
1747
2805
  collectionComponent,
1748
2806
  componentCategories,
1749
2807
  coreMetas,
1750
- corePropsMetas,
2808
+ createImageValueTransformer,
1751
2809
  createScope,
1752
- decodeDataSourceVariable,
1753
- decodeDataSourceVariable as decodeDataVariableId,
1754
- defaultStates,
2810
+ decodeDataVariableId as decodeDataSourceVariable,
2811
+ decodeDataVariableId,
1755
2812
  descendantComponent,
1756
2813
  documentTypes,
1757
- encodeDataSourceVariable,
1758
- encodeDataSourceVariable as encodeDataVariableId,
2814
+ durationUnitValueSchema,
2815
+ elementComponent,
2816
+ encodeDataVariableId as encodeDataSourceVariable,
2817
+ encodeDataVariableId,
1759
2818
  executeExpression,
1760
2819
  findPageByIdOrPath,
1761
2820
  findParentFolderByChildId,
1762
2821
  findTreeInstanceIds,
1763
2822
  findTreeInstanceIdsExcludingSlotDescendants,
2823
+ generateCss,
1764
2824
  generateExpression,
1765
2825
  generateObjectExpression,
1766
2826
  generatePageMeta,
1767
2827
  generateResources,
1768
2828
  getExpressionIdentifiers,
2829
+ getIndexesWithinAncestors,
1769
2830
  getPagePath,
1770
2831
  getStaticSiteMapXml,
1771
2832
  getStyleDeclKey,
1772
2833
  initialBreakpoints,
2834
+ insetUnitValueSchema,
2835
+ isComponentDetachable,
1773
2836
  isCoreComponent,
1774
2837
  isLiteralExpression,
1775
2838
  isPathnamePattern,
@@ -1779,8 +2842,12 @@ export {
1779
2842
  parseComponentName,
1780
2843
  parseObjectExpression,
1781
2844
  portalComponent,
2845
+ rangeUnitValueSchema,
1782
2846
  replaceFormActionsWithResources,
1783
2847
  rootComponent,
1784
- stateCategories,
1785
- transpileExpression
2848
+ scrollAnimationSchema,
2849
+ systemParameter,
2850
+ tags,
2851
+ transpileExpression,
2852
+ viewAnimationSchema
1786
2853
  };