@webstudio-is/sdk 0.0.0-588fe22 → 0.0.0-bdb8a58

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
@@ -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,10 @@ var HomePage = z2.object({
88
88
  ...commonPageFields,
89
89
  path: HomePagePath
90
90
  });
91
- var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine((path) => path === "" || path.startsWith("/"), "Must start with a /").refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
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(
92
95
  (path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
93
96
  "Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
94
97
  ).refine(
@@ -218,20 +221,25 @@ var DataSource = z4.union([
218
221
  z4.object({
219
222
  type: z4.literal("variable"),
220
223
  id: DataSourceId,
221
- scopeInstanceId: z4.string(),
224
+ // The instance should always be specified for variables,
225
+ // however, there was a bug in the embed template
226
+ // which produced variables without an instance
227
+ // and these variables will fail validation
228
+ // if we make it required
229
+ scopeInstanceId: z4.string().optional(),
222
230
  name: z4.string(),
223
231
  value: DataSourceVariableValue
224
232
  }),
225
233
  z4.object({
226
234
  type: z4.literal("parameter"),
227
235
  id: DataSourceId,
228
- scopeInstanceId: z4.string(),
236
+ scopeInstanceId: z4.string().optional(),
229
237
  name: z4.string()
230
238
  }),
231
239
  z4.object({
232
240
  type: z4.literal("resource"),
233
241
  id: DataSourceId,
234
- scopeInstanceId: z4.string(),
242
+ scopeInstanceId: z4.string().optional(),
235
243
  name: z4.string(),
236
244
  resourceId: z4.string()
237
245
  })
@@ -274,98 +282,261 @@ var ResourceRequest = z5.object({
274
282
  var Resources = z5.map(ResourceId, Resource);
275
283
 
276
284
  // src/schema/props.ts
285
+ import { z as z7 } from "zod";
286
+
287
+ // src/schema/animation-schema.ts
288
+ import { StyleValue } from "@webstudio-is/css-engine";
277
289
  import { z as z6 } from "zod";
278
- var PropId = z6.string();
290
+ var literalUnion = (arr) => z6.union(
291
+ arr.map((val) => z6.literal(val))
292
+ );
293
+ var RANGE_UNITS = [
294
+ "%",
295
+ "px",
296
+ "cm",
297
+ "mm",
298
+ "q",
299
+ "in",
300
+ "pt",
301
+ "pc",
302
+ "em",
303
+ "rem",
304
+ "ex",
305
+ "rex",
306
+ "cap",
307
+ "rcap",
308
+ "ch",
309
+ "rch",
310
+ "lh",
311
+ "rlh",
312
+ "vw",
313
+ "svw",
314
+ "lvw",
315
+ "dvw",
316
+ "vh",
317
+ "svh",
318
+ "lvh",
319
+ "dvh",
320
+ "vi",
321
+ "svi",
322
+ "lvi",
323
+ "dvi",
324
+ "vb",
325
+ "svb",
326
+ "lvb",
327
+ "dvb",
328
+ "vmin",
329
+ "svmin",
330
+ "lvmin",
331
+ "dvmin",
332
+ "vmax",
333
+ "svmax",
334
+ "lvmax",
335
+ "dvmax"
336
+ ];
337
+ var rangeUnitSchema = literalUnion(RANGE_UNITS);
338
+ var rangeUnitValueSchema = z6.union([
339
+ z6.object({
340
+ type: z6.literal("unit"),
341
+ value: z6.number(),
342
+ unit: rangeUnitSchema
343
+ }),
344
+ z6.object({
345
+ type: z6.literal("unparsed"),
346
+ value: z6.string()
347
+ })
348
+ ]);
349
+ var insetUnitValueSchema = z6.union([
350
+ rangeUnitValueSchema,
351
+ z6.object({
352
+ type: z6.literal("keyword"),
353
+ value: z6.literal("auto")
354
+ })
355
+ ]);
356
+ var keyframeStylesSchema = z6.record(StyleValue);
357
+ var animationKeyframeSchema = z6.object({
358
+ offset: z6.number().optional(),
359
+ styles: keyframeStylesSchema
360
+ });
361
+ var keyframeEffectOptionsSchema = z6.object({
362
+ easing: z6.string().optional(),
363
+ fill: z6.union([
364
+ z6.literal("none"),
365
+ z6.literal("forwards"),
366
+ z6.literal("backwards"),
367
+ z6.literal("both")
368
+ ]).optional()
369
+ // FillMode
370
+ });
371
+ var scrollNamedRangeSchema = z6.union([
372
+ z6.literal("start"),
373
+ z6.literal("end")
374
+ ]);
375
+ var scrollRangeValueSchema = z6.tuple([
376
+ scrollNamedRangeSchema,
377
+ rangeUnitValueSchema
378
+ ]);
379
+ var scrollRangeOptionsSchema = z6.object({
380
+ rangeStart: scrollRangeValueSchema.optional(),
381
+ rangeEnd: scrollRangeValueSchema.optional()
382
+ });
383
+ var animationAxisSchema = z6.union([
384
+ z6.literal("block"),
385
+ z6.literal("inline"),
386
+ z6.literal("x"),
387
+ z6.literal("y")
388
+ ]);
389
+ var viewNamedRangeSchema = z6.union([
390
+ z6.literal("contain"),
391
+ z6.literal("cover"),
392
+ z6.literal("entry"),
393
+ z6.literal("exit"),
394
+ z6.literal("entry-crossing"),
395
+ z6.literal("exit-crossing")
396
+ ]);
397
+ var viewRangeValueSchema = z6.tuple([
398
+ viewNamedRangeSchema,
399
+ rangeUnitValueSchema
400
+ ]);
401
+ var viewRangeOptionsSchema = z6.object({
402
+ rangeStart: viewRangeValueSchema.optional(),
403
+ rangeEnd: viewRangeValueSchema.optional()
404
+ });
405
+ var baseAnimation = z6.object({
406
+ name: z6.string().optional(),
407
+ description: z6.string().optional(),
408
+ keyframes: z6.array(animationKeyframeSchema)
409
+ });
410
+ var scrollAnimationSchema = baseAnimation.merge(
411
+ z6.object({
412
+ timing: keyframeEffectOptionsSchema.merge(scrollRangeOptionsSchema)
413
+ })
414
+ );
415
+ var scrollActionSchema = z6.object({
416
+ type: z6.literal("scroll"),
417
+ source: z6.union([z6.literal("closest"), z6.literal("nearest"), z6.literal("root")]).optional(),
418
+ axis: animationAxisSchema.optional(),
419
+ animations: z6.array(scrollAnimationSchema),
420
+ isPinned: z6.boolean().optional(),
421
+ debug: z6.boolean().optional()
422
+ });
423
+ var viewAnimationSchema = baseAnimation.merge(
424
+ z6.object({
425
+ timing: keyframeEffectOptionsSchema.merge(viewRangeOptionsSchema)
426
+ })
427
+ );
428
+ var viewActionSchema = z6.object({
429
+ type: z6.literal("view"),
430
+ subject: z6.string().optional(),
431
+ axis: animationAxisSchema.optional(),
432
+ animations: z6.array(viewAnimationSchema),
433
+ insetStart: insetUnitValueSchema.optional(),
434
+ insetEnd: insetUnitValueSchema.optional(),
435
+ isPinned: z6.boolean().optional(),
436
+ debug: z6.boolean().optional()
437
+ });
438
+ var animationActionSchema = z6.discriminatedUnion("type", [
439
+ scrollActionSchema,
440
+ viewActionSchema
441
+ ]);
442
+
443
+ // src/schema/props.ts
444
+ var PropId = z7.string();
279
445
  var baseProp = {
280
446
  id: PropId,
281
- instanceId: z6.string(),
282
- name: z6.string(),
283
- required: z6.optional(z6.boolean())
447
+ instanceId: z7.string(),
448
+ name: z7.string(),
449
+ required: z7.optional(z7.boolean())
284
450
  };
285
- var Prop = z6.union([
286
- z6.object({
451
+ var Prop = z7.union([
452
+ z7.object({
287
453
  ...baseProp,
288
- type: z6.literal("number"),
289
- value: z6.number()
454
+ type: z7.literal("number"),
455
+ value: z7.number()
290
456
  }),
291
- z6.object({
457
+ z7.object({
292
458
  ...baseProp,
293
- type: z6.literal("string"),
294
- value: z6.string()
459
+ type: z7.literal("string"),
460
+ value: z7.string()
295
461
  }),
296
- z6.object({
462
+ z7.object({
297
463
  ...baseProp,
298
- type: z6.literal("boolean"),
299
- value: z6.boolean()
464
+ type: z7.literal("boolean"),
465
+ value: z7.boolean()
300
466
  }),
301
- z6.object({
467
+ z7.object({
302
468
  ...baseProp,
303
- type: z6.literal("json"),
304
- value: z6.unknown()
469
+ type: z7.literal("json"),
470
+ value: z7.unknown()
305
471
  }),
306
- z6.object({
472
+ z7.object({
307
473
  ...baseProp,
308
- type: z6.literal("asset"),
309
- value: z6.string()
474
+ type: z7.literal("asset"),
475
+ value: z7.string()
310
476
  // asset id
311
477
  }),
312
- z6.object({
478
+ z7.object({
313
479
  ...baseProp,
314
- type: z6.literal("page"),
315
- value: z6.union([
316
- z6.string(),
480
+ type: z7.literal("page"),
481
+ value: z7.union([
482
+ z7.string(),
317
483
  // page id
318
- z6.object({
319
- pageId: z6.string(),
320
- instanceId: z6.string()
484
+ z7.object({
485
+ pageId: z7.string(),
486
+ instanceId: z7.string()
321
487
  })
322
488
  ])
323
489
  }),
324
- z6.object({
490
+ z7.object({
325
491
  ...baseProp,
326
- type: z6.literal("string[]"),
327
- value: z6.array(z6.string())
492
+ type: z7.literal("string[]"),
493
+ value: z7.array(z7.string())
328
494
  }),
329
- z6.object({
495
+ z7.object({
330
496
  ...baseProp,
331
- type: z6.literal("parameter"),
497
+ type: z7.literal("parameter"),
332
498
  // data source id
333
- value: z6.string()
499
+ value: z7.string()
334
500
  }),
335
- z6.object({
501
+ z7.object({
336
502
  ...baseProp,
337
- type: z6.literal("resource"),
503
+ type: z7.literal("resource"),
338
504
  // resource id
339
- value: z6.string()
505
+ value: z7.string()
340
506
  }),
341
- z6.object({
507
+ z7.object({
342
508
  ...baseProp,
343
- type: z6.literal("expression"),
509
+ type: z7.literal("expression"),
344
510
  // expression code
345
- value: z6.string()
511
+ value: z7.string()
346
512
  }),
347
- z6.object({
513
+ z7.object({
348
514
  ...baseProp,
349
- type: z6.literal("action"),
350
- value: z6.array(
351
- z6.object({
352
- type: z6.literal("execute"),
353
- args: z6.array(z6.string()),
354
- code: z6.string()
515
+ type: z7.literal("action"),
516
+ value: z7.array(
517
+ z7.object({
518
+ type: z7.literal("execute"),
519
+ args: z7.array(z7.string()),
520
+ code: z7.string()
355
521
  })
356
522
  )
523
+ }),
524
+ z7.object({
525
+ ...baseProp,
526
+ type: z7.literal("animationAction"),
527
+ value: animationActionSchema
357
528
  })
358
529
  ]);
359
- var Props = z6.map(PropId, Prop);
530
+ var Props = z7.map(PropId, Prop);
360
531
 
361
532
  // src/schema/breakpoints.ts
362
- import { z as z7 } from "zod";
363
- var BreakpointId = z7.string();
364
- var Breakpoint = z7.object({
533
+ import { z as z8 } from "zod";
534
+ var BreakpointId = z8.string();
535
+ var Breakpoint = z8.object({
365
536
  id: BreakpointId,
366
- label: z7.string(),
367
- minWidth: z7.number().optional(),
368
- maxWidth: z7.number().optional()
537
+ label: z8.string(),
538
+ minWidth: z8.number().optional(),
539
+ maxWidth: z8.number().optional()
369
540
  }).refine(({ minWidth, maxWidth }) => {
370
541
  return (
371
542
  // Either min or max width have to be defined
@@ -373,7 +544,7 @@ var Breakpoint = z7.object({
373
544
  minWidth === void 0 && maxWidth === void 0
374
545
  );
375
546
  }, "Either minWidth or maxWidth should be defined");
376
- var Breakpoints = z7.map(BreakpointId, Breakpoint);
547
+ var Breakpoints = z8.map(BreakpointId, Breakpoint);
377
548
  var initialBreakpoints = [
378
549
  { id: "placeholder", label: "Base" },
379
550
  { id: "placeholder", label: "Tablet", maxWidth: 991 },
@@ -382,233 +553,237 @@ var initialBreakpoints = [
382
553
  ];
383
554
 
384
555
  // src/schema/style-sources.ts
385
- import { z as z8 } from "zod";
386
- var StyleSourceId = z8.string();
387
- var StyleSourceToken = z8.object({
388
- type: z8.literal("token"),
556
+ import { z as z9 } from "zod";
557
+ var StyleSourceId = z9.string();
558
+ var StyleSourceToken = z9.object({
559
+ type: z9.literal("token"),
389
560
  id: StyleSourceId,
390
- name: z8.string()
561
+ name: z9.string()
391
562
  });
392
- var StyleSourceLocal = z8.object({
393
- type: z8.literal("local"),
563
+ var StyleSourceLocal = z9.object({
564
+ type: z9.literal("local"),
394
565
  id: StyleSourceId
395
566
  });
396
- var StyleSource = z8.union([StyleSourceToken, StyleSourceLocal]);
397
- var StyleSources = z8.map(StyleSourceId, StyleSource);
567
+ var StyleSource = z9.union([StyleSourceToken, StyleSourceLocal]);
568
+ var StyleSources = z9.map(StyleSourceId, StyleSource);
398
569
 
399
570
  // src/schema/style-source-selections.ts
400
- import { z as z9 } from "zod";
401
- var InstanceId2 = z9.string();
402
- var StyleSourceId2 = z9.string();
403
- var StyleSourceSelection = z9.object({
571
+ import { z as z10 } from "zod";
572
+ var InstanceId2 = z10.string();
573
+ var StyleSourceId2 = z10.string();
574
+ var StyleSourceSelection = z10.object({
404
575
  instanceId: InstanceId2,
405
- values: z9.array(StyleSourceId2)
576
+ values: z10.array(StyleSourceId2)
406
577
  });
407
- var StyleSourceSelections = z9.map(InstanceId2, StyleSourceSelection);
578
+ var StyleSourceSelections = z10.map(InstanceId2, StyleSourceSelection);
408
579
 
409
580
  // src/schema/styles.ts
410
- import { z as z10 } from "zod";
411
- import { StyleValue } from "@webstudio-is/css-engine";
412
- var StyleDeclRaw = z10.object({
413
- styleSourceId: z10.string(),
414
- breakpointId: z10.string(),
415
- state: z10.optional(z10.string()),
581
+ import { z as z11 } from "zod";
582
+ import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
583
+ var StyleDeclRaw = z11.object({
584
+ styleSourceId: z11.string(),
585
+ breakpointId: z11.string(),
586
+ state: z11.optional(z11.string()),
416
587
  // @todo can't figure out how to make property to be enum
417
- property: z10.string(),
418
- value: StyleValue,
419
- listed: z10.boolean().optional()
588
+ property: z11.string(),
589
+ value: StyleValue2,
590
+ listed: z11.boolean().optional()
420
591
  });
421
592
  var StyleDecl = StyleDeclRaw;
422
593
  var getStyleDeclKey = (styleDecl) => {
423
594
  return `${styleDecl.styleSourceId}:${styleDecl.breakpointId}:${styleDecl.property}:${styleDecl.state ?? ""}`;
424
595
  };
425
- var Styles = z10.map(z10.string(), StyleDecl);
596
+ var Styles = z11.map(z11.string(), StyleDecl);
426
597
 
427
598
  // src/schema/deployment.ts
428
- import { z as z11 } from "zod";
429
- var Templates = z11.enum([
430
- "vanilla",
599
+ import { z as z12 } from "zod";
600
+ var Templates = z12.enum([
431
601
  "docker",
432
602
  "vercel",
433
- "netlify-functions",
434
- "netlify-edge-functions",
603
+ "netlify",
435
604
  "ssg",
436
605
  "ssg-netlify",
437
606
  "ssg-vercel"
438
607
  ]);
439
- var Deployment = z11.union([
440
- z11.object({
441
- destination: z11.literal("static"),
442
- name: z11.string(),
443
- assetsDomain: z11.string(),
608
+ var Deployment = z12.union([
609
+ z12.object({
610
+ destination: z12.literal("static"),
611
+ name: z12.string(),
612
+ assetsDomain: z12.string(),
444
613
  // Must be validated very strictly
445
- templates: z11.array(Templates)
614
+ templates: z12.array(Templates)
446
615
  }),
447
- z11.object({
448
- destination: z11.literal("saas").optional(),
449
- domains: z11.array(z11.string()),
450
- assetsDomain: z11.string().optional(),
616
+ z12.object({
617
+ destination: z12.literal("saas").optional(),
618
+ domains: z12.array(z12.string()),
619
+ assetsDomain: z12.string().optional(),
451
620
  /**
452
621
  * @deprecated This field is deprecated, use `domains` instead.
453
622
  */
454
- projectDomain: z11.string().optional(),
455
- excludeWstdDomainFromSearch: z11.boolean().optional()
623
+ projectDomain: z12.string().optional(),
624
+ excludeWstdDomainFromSearch: z12.boolean().optional()
456
625
  })
457
626
  ]);
458
627
 
459
628
  // src/schema/webstudio.ts
460
- import { z as z12 } from "zod";
461
- var WebstudioFragment = z12.object({
462
- children: z12.array(InstanceChild),
463
- instances: z12.array(Instance),
464
- assets: z12.array(Asset),
465
- dataSources: z12.array(DataSource),
466
- resources: z12.array(Resource),
467
- props: z12.array(Prop),
468
- breakpoints: z12.array(Breakpoint),
469
- styleSourceSelections: z12.array(StyleSourceSelection),
470
- styleSources: z12.array(StyleSource),
471
- styles: z12.array(StyleDecl)
629
+ import { z as z13 } from "zod";
630
+ var WebstudioFragment = z13.object({
631
+ children: z13.array(InstanceChild),
632
+ instances: z13.array(Instance),
633
+ assets: z13.array(Asset),
634
+ dataSources: z13.array(DataSource),
635
+ resources: z13.array(Resource),
636
+ props: z13.array(Prop),
637
+ breakpoints: z13.array(Breakpoint),
638
+ styleSourceSelections: z13.array(StyleSourceSelection),
639
+ styleSources: z13.array(StyleSource),
640
+ styles: z13.array(StyleDecl)
472
641
  });
473
642
 
474
643
  // src/schema/prop-meta.ts
475
- import { z as z13 } from "zod";
644
+ import { z as z14 } from "zod";
476
645
  var common = {
477
- label: z13.string().optional(),
478
- description: z13.string().optional(),
479
- required: z13.boolean()
646
+ label: z14.string().optional(),
647
+ description: z14.string().optional(),
648
+ required: z14.boolean()
480
649
  };
481
- var Number = z13.object({
650
+ var Number = z14.object({
482
651
  ...common,
483
- control: z13.literal("number"),
484
- type: z13.literal("number"),
485
- defaultValue: z13.number().optional()
652
+ control: z14.literal("number"),
653
+ type: z14.literal("number"),
654
+ defaultValue: z14.number().optional()
486
655
  });
487
- var Range = z13.object({
656
+ var Range = z14.object({
488
657
  ...common,
489
- control: z13.literal("range"),
490
- type: z13.literal("number"),
491
- defaultValue: z13.number().optional()
658
+ control: z14.literal("range"),
659
+ type: z14.literal("number"),
660
+ defaultValue: z14.number().optional()
492
661
  });
493
- var Text = z13.object({
662
+ var Text = z14.object({
494
663
  ...common,
495
- control: z13.literal("text"),
496
- type: z13.literal("string"),
497
- defaultValue: z13.string().optional(),
664
+ control: z14.literal("text"),
665
+ type: z14.literal("string"),
666
+ defaultValue: z14.string().optional(),
498
667
  /**
499
668
  * The number of rows in <textarea>. If set to 0 an <input> will be used instead.
500
669
  * In line with Storybook team's plan: https://github.com/storybookjs/storybook/issues/21100
501
670
  */
502
- rows: z13.number().optional()
671
+ rows: z14.number().optional()
503
672
  });
504
- var Code = z13.object({
673
+ var Code = z14.object({
505
674
  ...common,
506
- control: z13.literal("code"),
507
- type: z13.literal("string"),
508
- language: z13.union([z13.literal("html"), z13.literal("markdown")]),
509
- defaultValue: z13.string().optional()
675
+ control: z14.literal("code"),
676
+ type: z14.literal("string"),
677
+ language: z14.union([z14.literal("html"), z14.literal("markdown")]),
678
+ defaultValue: z14.string().optional()
510
679
  });
511
- var CodeText = z13.object({
680
+ var CodeText = z14.object({
512
681
  ...common,
513
- control: z13.literal("codetext"),
514
- type: z13.literal("string"),
515
- defaultValue: z13.string().optional()
682
+ control: z14.literal("codetext"),
683
+ type: z14.literal("string"),
684
+ defaultValue: z14.string().optional()
516
685
  });
517
- var Color = z13.object({
686
+ var Color = z14.object({
518
687
  ...common,
519
- control: z13.literal("color"),
520
- type: z13.literal("string"),
521
- defaultValue: z13.string().optional()
688
+ control: z14.literal("color"),
689
+ type: z14.literal("string"),
690
+ defaultValue: z14.string().optional()
522
691
  });
523
- var Boolean = z13.object({
692
+ var Boolean = z14.object({
524
693
  ...common,
525
- control: z13.literal("boolean"),
526
- type: z13.literal("boolean"),
527
- defaultValue: z13.boolean().optional()
694
+ control: z14.literal("boolean"),
695
+ type: z14.literal("boolean"),
696
+ defaultValue: z14.boolean().optional()
528
697
  });
529
- var Radio = z13.object({
698
+ var Radio = z14.object({
530
699
  ...common,
531
- control: z13.literal("radio"),
532
- type: z13.literal("string"),
533
- defaultValue: z13.string().optional(),
534
- options: z13.array(z13.string())
700
+ control: z14.literal("radio"),
701
+ type: z14.literal("string"),
702
+ defaultValue: z14.string().optional(),
703
+ options: z14.array(z14.string())
535
704
  });
536
- var InlineRadio = z13.object({
705
+ var InlineRadio = z14.object({
537
706
  ...common,
538
- control: z13.literal("inline-radio"),
539
- type: z13.literal("string"),
540
- defaultValue: z13.string().optional(),
541
- options: z13.array(z13.string())
707
+ control: z14.literal("inline-radio"),
708
+ type: z14.literal("string"),
709
+ defaultValue: z14.string().optional(),
710
+ options: z14.array(z14.string())
542
711
  });
543
- var Select = z13.object({
712
+ var Select = z14.object({
544
713
  ...common,
545
- control: z13.literal("select"),
546
- type: z13.literal("string"),
547
- defaultValue: z13.string().optional(),
548
- options: z13.array(z13.string())
714
+ control: z14.literal("select"),
715
+ type: z14.literal("string"),
716
+ defaultValue: z14.string().optional(),
717
+ options: z14.array(z14.string())
549
718
  });
550
- var Check = z13.object({
719
+ var Check = z14.object({
551
720
  ...common,
552
- control: z13.literal("check"),
553
- type: z13.literal("string[]"),
554
- defaultValue: z13.array(z13.string()).optional(),
555
- options: z13.array(z13.string())
721
+ control: z14.literal("check"),
722
+ type: z14.literal("string[]"),
723
+ defaultValue: z14.array(z14.string()).optional(),
724
+ options: z14.array(z14.string())
556
725
  });
557
- var InlineCheck = z13.object({
726
+ var InlineCheck = z14.object({
558
727
  ...common,
559
- control: z13.literal("inline-check"),
560
- type: z13.literal("string[]"),
561
- defaultValue: z13.array(z13.string()).optional(),
562
- options: z13.array(z13.string())
728
+ control: z14.literal("inline-check"),
729
+ type: z14.literal("string[]"),
730
+ defaultValue: z14.array(z14.string()).optional(),
731
+ options: z14.array(z14.string())
563
732
  });
564
- var MultiSelect = z13.object({
733
+ var MultiSelect = z14.object({
565
734
  ...common,
566
- control: z13.literal("multi-select"),
567
- type: z13.literal("string[]"),
568
- defaultValue: z13.array(z13.string()).optional(),
569
- options: z13.array(z13.string())
735
+ control: z14.literal("multi-select"),
736
+ type: z14.literal("string[]"),
737
+ defaultValue: z14.array(z14.string()).optional(),
738
+ options: z14.array(z14.string())
570
739
  });
571
- var File = z13.object({
740
+ var File = z14.object({
572
741
  ...common,
573
- control: z13.literal("file"),
574
- type: z13.literal("string"),
575
- defaultValue: z13.string().optional(),
742
+ control: z14.literal("file"),
743
+ type: z14.literal("string"),
744
+ defaultValue: z14.string().optional(),
576
745
  /** https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept */
577
- accept: z13.string().optional()
746
+ accept: z14.string().optional()
578
747
  });
579
- var Url = z13.object({
748
+ var Url = z14.object({
580
749
  ...common,
581
- control: z13.literal("url"),
582
- type: z13.literal("string"),
583
- defaultValue: z13.string().optional()
750
+ control: z14.literal("url"),
751
+ type: z14.literal("string"),
752
+ defaultValue: z14.string().optional()
584
753
  });
585
- var Json = z13.object({
754
+ var Json = z14.object({
586
755
  ...common,
587
- control: z13.literal("json"),
588
- type: z13.literal("json"),
589
- defaultValue: z13.unknown().optional()
756
+ control: z14.literal("json"),
757
+ type: z14.literal("json"),
758
+ defaultValue: z14.unknown().optional()
590
759
  });
591
- var Date = z13.object({
760
+ var Date = z14.object({
592
761
  ...common,
593
- control: z13.literal("date"),
762
+ control: z14.literal("date"),
594
763
  // @todo not sure what type should be here
595
764
  // (we don't support Date yet, added for completeness)
596
- type: z13.literal("string"),
597
- defaultValue: z13.string().optional()
765
+ type: z14.literal("string"),
766
+ defaultValue: z14.string().optional()
598
767
  });
599
- var Action = z13.object({
768
+ var Action = z14.object({
600
769
  ...common,
601
- control: z13.literal("action"),
602
- type: z13.literal("action"),
603
- defaultValue: z13.undefined().optional()
770
+ control: z14.literal("action"),
771
+ type: z14.literal("action"),
772
+ defaultValue: z14.undefined().optional()
604
773
  });
605
- var TextContent = z13.object({
774
+ var TextContent = z14.object({
606
775
  ...common,
607
- control: z13.literal("textContent"),
608
- type: z13.literal("string"),
609
- defaultValue: z13.string().optional()
776
+ control: z14.literal("textContent"),
777
+ type: z14.literal("string"),
778
+ defaultValue: z14.string().optional()
610
779
  });
611
- var PropMeta = z13.union([
780
+ var AnimationAction = z14.object({
781
+ ...common,
782
+ control: z14.literal("animationAction"),
783
+ type: z14.literal("animationAction"),
784
+ defaultValue: z14.undefined().optional()
785
+ });
786
+ var PropMeta = z14.union([
612
787
  Number,
613
788
  Range,
614
789
  Text,
@@ -627,104 +802,112 @@ var PropMeta = z13.union([
627
802
  Json,
628
803
  Date,
629
804
  Action,
630
- TextContent
805
+ TextContent,
806
+ AnimationAction
631
807
  ]);
632
808
 
633
809
  // src/schema/embed-template.ts
634
- import { z as z14 } from "zod";
635
- import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
636
- var EmbedTemplateText = z14.object({
637
- type: z14.literal("text"),
638
- value: z14.string(),
639
- placeholder: z14.boolean().optional()
810
+ import { z as z15 } from "zod";
811
+ import { StyleValue as StyleValue3 } from "@webstudio-is/css-engine";
812
+ var EmbedTemplateText = z15.object({
813
+ type: z15.literal("text"),
814
+ value: z15.string(),
815
+ placeholder: z15.boolean().optional()
640
816
  });
641
- var EmbedTemplateExpression = z14.object({
642
- type: z14.literal("expression"),
643
- value: z14.string()
817
+ var EmbedTemplateExpression = z15.object({
818
+ type: z15.literal("expression"),
819
+ value: z15.string()
644
820
  });
645
- var EmbedTemplateVariable = z14.object({
646
- alias: z14.optional(z14.string()),
647
- initialValue: z14.unknown()
821
+ var EmbedTemplateVariable = z15.object({
822
+ alias: z15.optional(z15.string()),
823
+ initialValue: z15.unknown()
648
824
  });
649
- var EmbedTemplateProp = z14.union([
650
- z14.object({
651
- type: z14.literal("number"),
652
- name: z14.string(),
653
- value: z14.number()
825
+ var EmbedTemplateProp = z15.union([
826
+ z15.object({
827
+ type: z15.literal("number"),
828
+ name: z15.string(),
829
+ value: z15.number()
654
830
  }),
655
- z14.object({
656
- type: z14.literal("string"),
657
- name: z14.string(),
658
- value: z14.string()
831
+ z15.object({
832
+ type: z15.literal("string"),
833
+ name: z15.string(),
834
+ value: z15.string()
659
835
  }),
660
- z14.object({
661
- type: z14.literal("boolean"),
662
- name: z14.string(),
663
- value: z14.boolean()
836
+ z15.object({
837
+ type: z15.literal("boolean"),
838
+ name: z15.string(),
839
+ value: z15.boolean()
664
840
  }),
665
- z14.object({
666
- type: z14.literal("string[]"),
667
- name: z14.string(),
668
- value: z14.array(z14.string())
841
+ z15.object({
842
+ type: z15.literal("string[]"),
843
+ name: z15.string(),
844
+ value: z15.array(z15.string())
669
845
  }),
670
- z14.object({
671
- type: z14.literal("json"),
672
- name: z14.string(),
673
- value: z14.unknown()
846
+ z15.object({
847
+ type: z15.literal("json"),
848
+ name: z15.string(),
849
+ value: z15.unknown()
674
850
  }),
675
- z14.object({
676
- type: z14.literal("expression"),
677
- name: z14.string(),
678
- code: z14.string()
851
+ z15.object({
852
+ type: z15.literal("expression"),
853
+ name: z15.string(),
854
+ code: z15.string()
679
855
  }),
680
- z14.object({
681
- type: z14.literal("parameter"),
682
- name: z14.string(),
683
- variableName: z14.string(),
684
- variableAlias: z14.optional(z14.string())
856
+ z15.object({
857
+ type: z15.literal("parameter"),
858
+ name: z15.string(),
859
+ variableName: z15.string(),
860
+ variableAlias: z15.optional(z15.string())
685
861
  }),
686
- z14.object({
687
- type: z14.literal("action"),
688
- name: z14.string(),
689
- value: z14.array(
690
- z14.object({
691
- type: z14.literal("execute"),
692
- args: z14.optional(z14.array(z14.string())),
693
- code: z14.string()
862
+ z15.object({
863
+ type: z15.literal("action"),
864
+ name: z15.string(),
865
+ value: z15.array(
866
+ z15.object({
867
+ type: z15.literal("execute"),
868
+ args: z15.optional(z15.array(z15.string())),
869
+ code: z15.string()
694
870
  })
695
871
  )
696
872
  })
697
873
  ]);
698
- var EmbedTemplateStyleDeclRaw = z14.object({
874
+ var EmbedTemplateStyleDeclRaw = z15.object({
699
875
  // State selector, e.g. :hover
700
- state: z14.optional(z14.string()),
701
- property: z14.string(),
702
- value: StyleValue2
876
+ state: z15.optional(z15.string()),
877
+ property: z15.string(),
878
+ value: StyleValue3
703
879
  });
704
880
  var EmbedTemplateStyleDecl = EmbedTemplateStyleDeclRaw;
705
- var EmbedTemplateInstance = z14.lazy(
706
- () => z14.object({
707
- type: z14.literal("instance"),
708
- component: z14.string(),
709
- label: z14.optional(z14.string()),
710
- variables: z14.optional(z14.record(z14.string(), EmbedTemplateVariable)),
711
- props: z14.optional(z14.array(EmbedTemplateProp)),
712
- styles: z14.optional(z14.array(EmbedTemplateStyleDecl)),
881
+ var EmbedTemplateInstance = z15.lazy(
882
+ () => z15.object({
883
+ type: z15.literal("instance"),
884
+ component: z15.string(),
885
+ label: z15.optional(z15.string()),
886
+ variables: z15.optional(z15.record(z15.string(), EmbedTemplateVariable)),
887
+ props: z15.optional(z15.array(EmbedTemplateProp)),
888
+ styles: z15.optional(z15.array(EmbedTemplateStyleDecl)),
713
889
  children: WsEmbedTemplate
714
890
  })
715
891
  );
716
- var WsEmbedTemplate = z14.lazy(
717
- () => z14.array(
718
- z14.union([EmbedTemplateInstance, EmbedTemplateText, EmbedTemplateExpression])
892
+ var WsEmbedTemplate = z15.lazy(
893
+ () => z15.array(
894
+ z15.union([EmbedTemplateInstance, EmbedTemplateText, EmbedTemplateExpression])
719
895
  )
720
896
  );
721
897
 
722
898
  // src/schema/component-meta.ts
723
- import { z as z15 } from "zod";
724
- var WsComponentPropsMeta = z15.object({
725
- props: z15.record(PropMeta),
899
+ import { z as z16 } from "zod";
900
+ import { StyleValue as StyleValue4 } from "@webstudio-is/css-engine";
901
+ var PresetStyleDecl = z16.object({
902
+ // State selector, e.g. :hover
903
+ state: z16.optional(z16.string()),
904
+ property: z16.string(),
905
+ value: StyleValue4
906
+ });
907
+ var WsComponentPropsMeta = z16.object({
908
+ props: z16.record(PropMeta),
726
909
  // Props that will be always visible in properties panel.
727
- initialProps: z15.array(z15.string()).optional()
910
+ initialProps: z16.array(z16.string()).optional()
728
911
  });
729
912
  var componentCategories = [
730
913
  "general",
@@ -739,10 +922,10 @@ var componentCategories = [
739
922
  "internal"
740
923
  ];
741
924
  var stateCategories = ["states", "component-states"];
742
- var ComponentState = z15.object({
743
- category: z15.enum(stateCategories).optional(),
744
- selector: z15.string(),
745
- label: z15.string()
925
+ var ComponentState = z16.object({
926
+ category: z16.enum(stateCategories).optional(),
927
+ selector: z16.string(),
928
+ label: z16.string()
746
929
  });
747
930
  var defaultStates = [
748
931
  { selector: ":hover", label: "Hover" },
@@ -751,28 +934,31 @@ var defaultStates = [
751
934
  { selector: ":focus-visible", label: "Focus Visible" },
752
935
  { selector: ":focus-within", label: "Focus Within" }
753
936
  ];
754
- var WsComponentMeta = z15.object({
755
- category: z15.enum(componentCategories).optional(),
937
+ var WsComponentMeta = z16.object({
938
+ category: z16.enum(componentCategories).optional(),
756
939
  // container - can accept other components with dnd or be edited as text
757
940
  // control - usually form controls like inputs, without children
758
941
  // embed - images, videos or other embeddable components, without children
759
942
  // rich-text-child - formatted text fragment, not listed in components list
760
- type: z15.enum(["container", "control", "embed", "rich-text-child"]),
943
+ type: z16.enum(["container", "control", "embed", "rich-text-child"]),
944
+ /**
945
+ * a property used as textual placeholder when no content specified while in builder
946
+ * also signals to not insert components inside unless dropped explicitly
947
+ */
948
+ placeholder: z16.string().optional(),
761
949
  constraints: Matchers.optional(),
762
950
  // when this field is specified component receives
763
951
  // prop with index of same components withiin specified ancestor
764
952
  // important to automatically enumerate collections without
765
953
  // naming every item manually
766
- indexWithinAncestor: z15.optional(z15.string()),
767
- label: z15.optional(z15.string()),
768
- description: z15.string().optional(),
769
- icon: z15.string(),
770
- presetStyle: z15.optional(
771
- z15.record(z15.string(), z15.array(EmbedTemplateStyleDecl))
772
- ),
773
- states: z15.optional(z15.array(ComponentState)),
774
- template: z15.optional(WsEmbedTemplate),
775
- order: z15.number().optional()
954
+ indexWithinAncestor: z16.optional(z16.string()),
955
+ label: z16.optional(z16.string()),
956
+ description: z16.string().optional(),
957
+ icon: z16.string(),
958
+ presetStyle: z16.optional(z16.record(z16.string(), z16.array(PresetStyleDecl))),
959
+ states: z16.optional(z16.array(ComponentState)),
960
+ template: z16.optional(WsEmbedTemplate),
961
+ order: z16.number().optional()
776
962
  });
777
963
 
778
964
  // src/core-metas.ts
@@ -787,18 +973,18 @@ import {
787
973
  // src/__generated__/normalize.css.ts
788
974
  var html = [
789
975
  { property: "display", value: { type: "keyword", value: "grid" } },
790
- { property: "minHeight", value: { type: "unit", unit: "%", value: 100 } },
976
+ { property: "min-height", value: { type: "unit", unit: "%", value: 100 } },
791
977
  {
792
- property: "fontFamily",
978
+ property: "font-family",
793
979
  value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
794
980
  },
795
- { property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
981
+ { property: "font-size", value: { type: "unit", unit: "px", value: 16 } },
796
982
  {
797
- property: "lineHeight",
983
+ property: "line-height",
798
984
  value: { type: "unit", unit: "number", value: 1.2 }
799
985
  },
800
986
  {
801
- property: "whiteSpaceCollapse",
987
+ property: "white-space-collapse",
802
988
  value: { type: "keyword", value: "preserve" }
803
989
  }
804
990
  ];
@@ -965,10 +1151,65 @@ var parseComponentName = (componentName) => {
965
1151
  }
966
1152
  return [namespace, name];
967
1153
  };
1154
+ var getIndexesWithinAncestors = (metas, instances, rootIds) => {
1155
+ const ancestors = /* @__PURE__ */ new Set();
1156
+ for (const meta of metas.values()) {
1157
+ if (meta.indexWithinAncestor !== void 0) {
1158
+ ancestors.add(meta.indexWithinAncestor);
1159
+ }
1160
+ }
1161
+ const indexes = /* @__PURE__ */ new Map();
1162
+ const traverseInstances2 = (instances2, instanceId, latestIndexes2 = /* @__PURE__ */ new Map()) => {
1163
+ const instance = instances2.get(instanceId);
1164
+ if (instance === void 0) {
1165
+ return;
1166
+ }
1167
+ const meta = metas.get(instance.component);
1168
+ if (ancestors.has(instance.component)) {
1169
+ latestIndexes2 = new Map(latestIndexes2);
1170
+ latestIndexes2.set(instance.component, /* @__PURE__ */ new Map());
1171
+ }
1172
+ if (instance.component === blockTemplateComponent) {
1173
+ latestIndexes2 = new Map(latestIndexes2);
1174
+ for (const key of latestIndexes2.keys()) {
1175
+ latestIndexes2.set(key, /* @__PURE__ */ new Map());
1176
+ }
1177
+ }
1178
+ if (meta?.indexWithinAncestor !== void 0) {
1179
+ const ancestorIndexes = latestIndexes2.get(meta.indexWithinAncestor);
1180
+ if (ancestorIndexes) {
1181
+ let index = ancestorIndexes.get(instance.component) ?? -1;
1182
+ index += 1;
1183
+ ancestorIndexes.set(instance.component, index);
1184
+ indexes.set(instance.id, index);
1185
+ }
1186
+ }
1187
+ for (const child of instance.children) {
1188
+ if (child.type === "id") {
1189
+ traverseInstances2(instances2, child.value, latestIndexes2);
1190
+ }
1191
+ }
1192
+ };
1193
+ const latestIndexes = /* @__PURE__ */ new Map();
1194
+ for (const instanceId of rootIds) {
1195
+ traverseInstances2(instances, instanceId, latestIndexes);
1196
+ }
1197
+ return indexes;
1198
+ };
968
1199
 
969
1200
  // src/expression.ts
970
- import { parseExpressionAt } from "acorn";
1201
+ import {
1202
+ parse,
1203
+ parseExpressionAt
1204
+ } from "acorn";
971
1205
  import { simple } from "acorn-walk";
1206
+ var SYSTEM_VARIABLE_ID = ":system";
1207
+ var systemParameter = {
1208
+ id: SYSTEM_VARIABLE_ID,
1209
+ scopeInstanceId: ROOT_INSTANCE_ID,
1210
+ type: "parameter",
1211
+ name: "system"
1212
+ };
972
1213
  var lintExpression = ({
973
1214
  expression,
974
1215
  availableVariables = /* @__PURE__ */ new Set(),
@@ -996,7 +1237,7 @@ var lintExpression = ({
996
1237
  return diagnostics;
997
1238
  }
998
1239
  try {
999
- const root = parseExpressionAt(`(${expression})`, 0, {
1240
+ const root = parse(`(${expression})`, {
1000
1241
  ecmaVersion: "latest",
1001
1242
  // support parsing import to forbid explicitly
1002
1243
  sourceType: "module"
@@ -1220,11 +1461,17 @@ var generateObjectExpression = (map) => {
1220
1461
  return generated;
1221
1462
  };
1222
1463
  var dataSourceVariablePrefix = "$ws$dataSource$";
1223
- var encodeDataSourceVariable = (id) => {
1464
+ var encodeDataVariableId = (id) => {
1465
+ if (id === SYSTEM_VARIABLE_ID) {
1466
+ return "$ws$system";
1467
+ }
1224
1468
  const encoded = id.replaceAll("-", "__DASH__");
1225
1469
  return `${dataSourceVariablePrefix}${encoded}`;
1226
1470
  };
1227
- var decodeDataSourceVariable = (name) => {
1471
+ var decodeDataVariableId = (name) => {
1472
+ if (name === "$ws$system") {
1473
+ return SYSTEM_VARIABLE_ID;
1474
+ }
1228
1475
  if (name.startsWith(dataSourceVariablePrefix)) {
1229
1476
  const encoded = name.slice(dataSourceVariablePrefix.length);
1230
1477
  return encoded.replaceAll("__DASH__", "-");
@@ -1241,8 +1488,11 @@ var generateExpression = ({
1241
1488
  expression,
1242
1489
  executable: true,
1243
1490
  replaceVariable: (identifier) => {
1244
- const depId = decodeDataSourceVariable(identifier);
1245
- const dep = depId ? dataSources.get(depId) : void 0;
1491
+ const depId = decodeDataVariableId(identifier);
1492
+ let dep = depId ? dataSources.get(depId) : void 0;
1493
+ if (depId === SYSTEM_VARIABLE_ID) {
1494
+ dep = systemParameter;
1495
+ }
1246
1496
  if (dep) {
1247
1497
  usedDataSources?.set(dep.id, dep);
1248
1498
  return scope.getName(dep.id, dep.name);
@@ -1434,12 +1684,11 @@ var generateResources = ({
1434
1684
  `;
1435
1685
  }
1436
1686
  if (dataSource.type === "parameter") {
1437
- if (dataSource.id !== page.systemDataSourceId) {
1438
- continue;
1439
- }
1440
- const name = scope.getName(dataSource.id, dataSource.name);
1441
- generatedVariables += ` const ${name} = _props.system
1687
+ if (dataSource.id === page.systemDataSourceId || dataSource.id === SYSTEM_VARIABLE_ID) {
1688
+ const name = scope.getName(dataSource.id, dataSource.name);
1689
+ generatedVariables += ` const ${name} = _props.system
1442
1690
  `;
1691
+ }
1443
1692
  }
1444
1693
  }
1445
1694
  let generated = "";
@@ -1636,7 +1885,7 @@ var generatePageMeta = ({
1636
1885
  continue;
1637
1886
  }
1638
1887
  if (dataSource.type === "parameter") {
1639
- if (dataSource.id === page.systemDataSourceId) {
1888
+ if (dataSource.id === page.systemDataSourceId || dataSource.id === SYSTEM_VARIABLE_ID) {
1640
1889
  const valueName = localScope.getName(dataSource.id, dataSource.name);
1641
1890
  generated += ` let ${valueName} = system
1642
1891
  `;
@@ -1680,6 +1929,182 @@ var generatePageMeta = ({
1680
1929
  `;
1681
1930
  return generated;
1682
1931
  };
1932
+
1933
+ // src/css.ts
1934
+ import { kebabCase } from "change-case";
1935
+ import {
1936
+ createRegularStyleSheet,
1937
+ generateAtomic
1938
+ } from "@webstudio-is/css-engine";
1939
+ import { getFontFaces } from "@webstudio-is/fonts";
1940
+ var addFontRules = ({
1941
+ sheet,
1942
+ assets,
1943
+ assetBaseUrl
1944
+ }) => {
1945
+ const fontAssets = [];
1946
+ for (const asset of assets.values()) {
1947
+ if (asset.type === "font") {
1948
+ fontAssets.push(asset);
1949
+ }
1950
+ }
1951
+ const fontFaces = getFontFaces(fontAssets, { assetBaseUrl });
1952
+ for (const fontFace of fontFaces) {
1953
+ sheet.addFontFaceRule(fontFace);
1954
+ }
1955
+ };
1956
+ var createImageValueTransformer = (assets, { assetBaseUrl }) => (styleValue) => {
1957
+ if (styleValue.type === "image" && styleValue.value.type === "asset") {
1958
+ const asset = assets.get(styleValue.value.value);
1959
+ if (asset === void 0) {
1960
+ return { type: "keyword", value: "none" };
1961
+ }
1962
+ const url = `${assetBaseUrl}${asset.name}`;
1963
+ return {
1964
+ type: "image",
1965
+ value: {
1966
+ type: "url",
1967
+ url
1968
+ },
1969
+ hidden: styleValue.hidden
1970
+ };
1971
+ }
1972
+ };
1973
+ var normalizeClassName = (name) => kebabCase(name);
1974
+ var generateCss = ({
1975
+ assets,
1976
+ instances,
1977
+ props,
1978
+ breakpoints,
1979
+ styles,
1980
+ styleSourceSelections,
1981
+ componentMetas,
1982
+ assetBaseUrl,
1983
+ atomic
1984
+ }) => {
1985
+ const fontSheet = createRegularStyleSheet({ name: "ssr" });
1986
+ const presetSheet = createRegularStyleSheet({ name: "ssr" });
1987
+ const userSheet = createRegularStyleSheet({ name: "ssr" });
1988
+ addFontRules({ sheet: fontSheet, assets, assetBaseUrl });
1989
+ presetSheet.addMediaRule("presets");
1990
+ const presetClasses = /* @__PURE__ */ new Map();
1991
+ const scope = createScope([], normalizeClassName, "-");
1992
+ for (const [component, meta] of componentMetas) {
1993
+ const [_namespace, componentName] = parseComponentName(component);
1994
+ const className = `w-${scope.getName(component, meta.label ?? componentName)}`;
1995
+ const presetStyle = Object.entries(meta.presetStyle ?? {});
1996
+ if (presetStyle.length > 0) {
1997
+ presetClasses.set(component, className);
1998
+ }
1999
+ for (const [tag, styles2] of presetStyle) {
2000
+ const selector = component === rootComponent ? ":root" : `${tag}.${className}`;
2001
+ const rule = presetSheet.addNestingRule(selector);
2002
+ for (const declaration of styles2) {
2003
+ rule.setDeclaration({
2004
+ breakpoint: "presets",
2005
+ selector: declaration.state ?? "",
2006
+ property: declaration.property,
2007
+ value: declaration.value
2008
+ });
2009
+ }
2010
+ }
2011
+ }
2012
+ for (const breakpoint of breakpoints.values()) {
2013
+ userSheet.addMediaRule(breakpoint.id, breakpoint);
2014
+ }
2015
+ const imageValueTransformer = createImageValueTransformer(assets, {
2016
+ assetBaseUrl
2017
+ });
2018
+ userSheet.setTransformer(imageValueTransformer);
2019
+ for (const styleDecl of styles.values()) {
2020
+ const rule = userSheet.addMixinRule(styleDecl.styleSourceId);
2021
+ rule.setDeclaration({
2022
+ breakpoint: styleDecl.breakpointId,
2023
+ selector: styleDecl.state ?? "",
2024
+ property: styleDecl.property,
2025
+ value: styleDecl.value
2026
+ });
2027
+ }
2028
+ const classes = /* @__PURE__ */ new Map();
2029
+ const parentIdByInstanceId = /* @__PURE__ */ new Map();
2030
+ for (const instance of instances.values()) {
2031
+ const presetClass = presetClasses.get(instance.component);
2032
+ if (presetClass) {
2033
+ classes.set(instance.id, [presetClass]);
2034
+ }
2035
+ for (const child of instance.children) {
2036
+ if (child.type === "id") {
2037
+ parentIdByInstanceId.set(child.value, instance.id);
2038
+ }
2039
+ }
2040
+ }
2041
+ const descendantSelectorByInstanceId = /* @__PURE__ */ new Map();
2042
+ for (const prop of props.values()) {
2043
+ if (prop.name === "selector" && prop.type === "string") {
2044
+ descendantSelectorByInstanceId.set(prop.instanceId, prop.value);
2045
+ }
2046
+ }
2047
+ const instanceByRule = /* @__PURE__ */ new Map();
2048
+ for (const selection of styleSourceSelections.values()) {
2049
+ let { instanceId } = selection;
2050
+ const { values } = selection;
2051
+ if (instanceId === ROOT_INSTANCE_ID) {
2052
+ const rule2 = userSheet.addNestingRule(`:root`);
2053
+ rule2.applyMixins(values);
2054
+ continue;
2055
+ }
2056
+ let descendantSuffix = "";
2057
+ const instance = instances.get(instanceId);
2058
+ if (instance === void 0) {
2059
+ continue;
2060
+ }
2061
+ if (instance.component === descendantComponent) {
2062
+ const parentId = parentIdByInstanceId.get(instanceId);
2063
+ const descendantSelector = descendantSelectorByInstanceId.get(instanceId);
2064
+ if (parentId && descendantSelector) {
2065
+ descendantSuffix = descendantSelector;
2066
+ instanceId = parentId;
2067
+ }
2068
+ }
2069
+ const meta = componentMetas.get(instance.component);
2070
+ const [_namespace, shortName] = parseComponentName(instance.component);
2071
+ const baseName = instance.label ?? meta?.label ?? shortName;
2072
+ const className = `w-${scope.getName(instanceId, baseName)}`;
2073
+ if (atomic === false) {
2074
+ let classList = classes.get(instanceId);
2075
+ if (classList === void 0) {
2076
+ classList = [];
2077
+ classes.set(instanceId, classList);
2078
+ }
2079
+ classList.push(className);
2080
+ }
2081
+ const rule = userSheet.addNestingRule(`.${className}`, descendantSuffix);
2082
+ rule.applyMixins(values);
2083
+ instanceByRule.set(rule, instanceId);
2084
+ }
2085
+ const fontCss = fontSheet.cssText;
2086
+ const presetCss = presetSheet.cssText.replaceAll(
2087
+ "@media all ",
2088
+ "@layer presets "
2089
+ );
2090
+ if (atomic) {
2091
+ const { cssText } = generateAtomic(userSheet, {
2092
+ getKey: (rule) => instanceByRule.get(rule),
2093
+ transformValue: imageValueTransformer,
2094
+ classes
2095
+ });
2096
+ return {
2097
+ cssText: `${fontCss}${presetCss}
2098
+ ${cssText}`,
2099
+ classes
2100
+ };
2101
+ }
2102
+ return {
2103
+ cssText: `${fontCss}${presetCss}
2104
+ ${userSheet.cssText}`,
2105
+ classes
2106
+ };
2107
+ };
1683
2108
  export {
1684
2109
  Asset,
1685
2110
  Assets,
@@ -1715,15 +2140,18 @@ export {
1715
2140
  PageRedirect,
1716
2141
  PageTitle,
1717
2142
  Pages,
2143
+ PresetStyleDecl,
1718
2144
  ProjectNewRedirectPath,
1719
2145
  Prop,
1720
2146
  PropMeta,
1721
2147
  Props,
2148
+ RANGE_UNITS,
1722
2149
  ROOT_FOLDER_ID,
1723
2150
  ROOT_INSTANCE_ID,
1724
2151
  Resource,
1725
2152
  ResourceRequest,
1726
2153
  Resources,
2154
+ SYSTEM_VARIABLE_ID,
1727
2155
  StyleDecl,
1728
2156
  StyleSource,
1729
2157
  StyleSourceSelection,
@@ -1735,6 +2163,9 @@ export {
1735
2163
  WebstudioFragment,
1736
2164
  WsComponentMeta,
1737
2165
  WsEmbedTemplate,
2166
+ addFontRules,
2167
+ animationActionSchema,
2168
+ animationKeyframeSchema,
1738
2169
  blockComponent,
1739
2170
  blockTemplateComponent,
1740
2171
  blockTemplateMeta,
@@ -1742,28 +2173,32 @@ export {
1742
2173
  componentCategories,
1743
2174
  coreMetas,
1744
2175
  corePropsMetas,
2176
+ createImageValueTransformer,
1745
2177
  createScope,
1746
- decodeDataSourceVariable,
1747
- decodeDataSourceVariable as decodeDataVariableId,
2178
+ decodeDataVariableId as decodeDataSourceVariable,
2179
+ decodeDataVariableId,
1748
2180
  defaultStates,
1749
2181
  descendantComponent,
1750
2182
  documentTypes,
1751
- encodeDataSourceVariable,
1752
- encodeDataSourceVariable as encodeDataVariableId,
2183
+ encodeDataVariableId as encodeDataSourceVariable,
2184
+ encodeDataVariableId,
1753
2185
  executeExpression,
1754
2186
  findPageByIdOrPath,
1755
2187
  findParentFolderByChildId,
1756
2188
  findTreeInstanceIds,
1757
2189
  findTreeInstanceIdsExcludingSlotDescendants,
2190
+ generateCss,
1758
2191
  generateExpression,
1759
2192
  generateObjectExpression,
1760
2193
  generatePageMeta,
1761
2194
  generateResources,
1762
2195
  getExpressionIdentifiers,
2196
+ getIndexesWithinAncestors,
1763
2197
  getPagePath,
1764
2198
  getStaticSiteMapXml,
1765
2199
  getStyleDeclKey,
1766
2200
  initialBreakpoints,
2201
+ insetUnitValueSchema,
1767
2202
  isCoreComponent,
1768
2203
  isLiteralExpression,
1769
2204
  isPathnamePattern,
@@ -1773,8 +2208,12 @@ export {
1773
2208
  parseComponentName,
1774
2209
  parseObjectExpression,
1775
2210
  portalComponent,
2211
+ rangeUnitValueSchema,
1776
2212
  replaceFormActionsWithResources,
1777
2213
  rootComponent,
2214
+ scrollAnimationSchema,
1778
2215
  stateCategories,
1779
- transpileExpression
2216
+ systemParameter,
2217
+ transpileExpression,
2218
+ viewAnimationSchema
1780
2219
  };