@webstudio-is/sdk 0.0.0-5844e28 → 0.0.0-73cd6ea

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