@webstudio-is/sdk 0.0.0-2738e1e → 0.0.0-50b8685

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