@webstudio-is/sdk 0.0.0-588fe22 → 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,7 +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((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(
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(
92
98
  (path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
93
99
  "Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
94
100
  ).refine(
@@ -101,6 +107,24 @@ var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refin
101
107
  (path) => path !== "/build" && path.startsWith("/build/") === false,
102
108
  "/build prefix is reserved for the system"
103
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
+ );
104
128
  var Page = z2.object({
105
129
  ...commonPageFields,
106
130
  path: PagePath
@@ -112,21 +136,16 @@ var ProjectMeta = z2.object({
112
136
  faviconAssetId: z2.string().optional(),
113
137
  code: z2.string().optional()
114
138
  });
115
- var ProjectNewRedirectPath = PagePath.or(
116
- z2.string().refine((data) => {
117
- if (data === "/") {
118
- return true;
119
- }
120
- try {
121
- new URL(data);
122
- return true;
123
- } catch {
124
- return false;
125
- }
126
- }, "Must be a valid URL")
127
- );
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");
128
147
  var PageRedirect = z2.object({
129
- old: PagePath,
148
+ old: OldPagePath,
130
149
  new: ProjectNewRedirectPath,
131
150
  status: z2.enum(["301", "302"]).optional()
132
151
  });
@@ -164,29 +183,11 @@ var Instance = z3.object({
164
183
  type: z3.literal("instance"),
165
184
  id: InstanceId,
166
185
  component: z3.string(),
186
+ tag: z3.string().optional(),
167
187
  label: z3.string().optional(),
168
188
  children: z3.array(InstanceChild)
169
189
  });
170
190
  var Instances = z3.map(InstanceId, Instance);
171
- var MatcherRelation = z3.union([
172
- z3.literal("ancestor"),
173
- z3.literal("parent"),
174
- z3.literal("self"),
175
- z3.literal("child"),
176
- z3.literal("descendant")
177
- ]);
178
- var MatcherOperation = z3.object({
179
- $eq: z3.string().optional(),
180
- $neq: z3.string().optional(),
181
- $in: z3.array(z3.string()).optional(),
182
- $nin: z3.array(z3.string()).optional()
183
- });
184
- var Matcher = z3.object({
185
- relation: MatcherRelation,
186
- component: MatcherOperation.optional(),
187
- tag: MatcherOperation.optional()
188
- });
189
- var Matchers = z3.union([Matcher, z3.array(Matcher)]);
190
191
 
191
192
  // src/schema/data-sources.ts
192
193
  import { z as z4 } from "zod";
@@ -218,20 +219,25 @@ var DataSource = z4.union([
218
219
  z4.object({
219
220
  type: z4.literal("variable"),
220
221
  id: DataSourceId,
221
- 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(),
222
228
  name: z4.string(),
223
229
  value: DataSourceVariableValue
224
230
  }),
225
231
  z4.object({
226
232
  type: z4.literal("parameter"),
227
233
  id: DataSourceId,
228
- scopeInstanceId: z4.string(),
234
+ scopeInstanceId: z4.string().optional(),
229
235
  name: z4.string()
230
236
  }),
231
237
  z4.object({
232
238
  type: z4.literal("resource"),
233
239
  id: DataSourceId,
234
- scopeInstanceId: z4.string(),
240
+ scopeInstanceId: z4.string().optional(),
235
241
  name: z4.string(),
236
242
  resourceId: z4.string()
237
243
  })
@@ -274,98 +280,280 @@ var ResourceRequest = z5.object({
274
280
  var Resources = z5.map(ResourceId, Resource);
275
281
 
276
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";
277
287
  import { z as z6 } from "zod";
278
- 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();
279
462
  var baseProp = {
280
463
  id: PropId,
281
- instanceId: z6.string(),
282
- name: z6.string(),
283
- required: z6.optional(z6.boolean())
464
+ instanceId: z7.string(),
465
+ name: z7.string(),
466
+ required: z7.optional(z7.boolean())
284
467
  };
285
- var Prop = z6.union([
286
- z6.object({
468
+ var Prop = z7.union([
469
+ z7.object({
287
470
  ...baseProp,
288
- type: z6.literal("number"),
289
- value: z6.number()
471
+ type: z7.literal("number"),
472
+ value: z7.number()
290
473
  }),
291
- z6.object({
474
+ z7.object({
292
475
  ...baseProp,
293
- type: z6.literal("string"),
294
- value: z6.string()
476
+ type: z7.literal("string"),
477
+ value: z7.string()
295
478
  }),
296
- z6.object({
479
+ z7.object({
297
480
  ...baseProp,
298
- type: z6.literal("boolean"),
299
- value: z6.boolean()
481
+ type: z7.literal("boolean"),
482
+ value: z7.boolean()
300
483
  }),
301
- z6.object({
484
+ z7.object({
302
485
  ...baseProp,
303
- type: z6.literal("json"),
304
- value: z6.unknown()
486
+ type: z7.literal("json"),
487
+ value: z7.unknown()
305
488
  }),
306
- z6.object({
489
+ z7.object({
307
490
  ...baseProp,
308
- type: z6.literal("asset"),
309
- value: z6.string()
491
+ type: z7.literal("asset"),
492
+ value: z7.string()
310
493
  // asset id
311
494
  }),
312
- z6.object({
495
+ z7.object({
313
496
  ...baseProp,
314
- type: z6.literal("page"),
315
- value: z6.union([
316
- z6.string(),
497
+ type: z7.literal("page"),
498
+ value: z7.union([
499
+ z7.string(),
317
500
  // page id
318
- z6.object({
319
- pageId: z6.string(),
320
- instanceId: z6.string()
501
+ z7.object({
502
+ pageId: z7.string(),
503
+ instanceId: z7.string()
321
504
  })
322
505
  ])
323
506
  }),
324
- z6.object({
507
+ z7.object({
325
508
  ...baseProp,
326
- type: z6.literal("string[]"),
327
- value: z6.array(z6.string())
509
+ type: z7.literal("string[]"),
510
+ value: z7.array(z7.string())
328
511
  }),
329
- z6.object({
512
+ z7.object({
330
513
  ...baseProp,
331
- type: z6.literal("parameter"),
514
+ type: z7.literal("parameter"),
332
515
  // data source id
333
- value: z6.string()
516
+ value: z7.string()
334
517
  }),
335
- z6.object({
518
+ z7.object({
336
519
  ...baseProp,
337
- type: z6.literal("resource"),
520
+ type: z7.literal("resource"),
338
521
  // resource id
339
- value: z6.string()
522
+ value: z7.string()
340
523
  }),
341
- z6.object({
524
+ z7.object({
342
525
  ...baseProp,
343
- type: z6.literal("expression"),
526
+ type: z7.literal("expression"),
344
527
  // expression code
345
- value: z6.string()
528
+ value: z7.string()
346
529
  }),
347
- z6.object({
530
+ z7.object({
348
531
  ...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()
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()
355
538
  })
356
539
  )
540
+ }),
541
+ z7.object({
542
+ ...baseProp,
543
+ type: z7.literal("animationAction"),
544
+ value: animationActionSchema
357
545
  })
358
546
  ]);
359
- var Props = z6.map(PropId, Prop);
547
+ var Props = z7.map(PropId, Prop);
360
548
 
361
549
  // src/schema/breakpoints.ts
362
- import { z as z7 } from "zod";
363
- var BreakpointId = z7.string();
364
- var Breakpoint = z7.object({
550
+ import { z as z8 } from "zod";
551
+ var BreakpointId = z8.string();
552
+ var Breakpoint = z8.object({
365
553
  id: BreakpointId,
366
- label: z7.string(),
367
- minWidth: z7.number().optional(),
368
- maxWidth: z7.number().optional()
554
+ label: z8.string(),
555
+ minWidth: z8.number().optional(),
556
+ maxWidth: z8.number().optional()
369
557
  }).refine(({ minWidth, maxWidth }) => {
370
558
  return (
371
559
  // Either min or max width have to be defined
@@ -373,7 +561,7 @@ var Breakpoint = z7.object({
373
561
  minWidth === void 0 && maxWidth === void 0
374
562
  );
375
563
  }, "Either minWidth or maxWidth should be defined");
376
- var Breakpoints = z7.map(BreakpointId, Breakpoint);
564
+ var Breakpoints = z8.map(BreakpointId, Breakpoint);
377
565
  var initialBreakpoints = [
378
566
  { id: "placeholder", label: "Base" },
379
567
  { id: "placeholder", label: "Tablet", maxWidth: 991 },
@@ -382,236 +570,255 @@ var initialBreakpoints = [
382
570
  ];
383
571
 
384
572
  // 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"),
573
+ import { z as z9 } from "zod";
574
+ var StyleSourceId = z9.string();
575
+ var StyleSourceToken = z9.object({
576
+ type: z9.literal("token"),
389
577
  id: StyleSourceId,
390
- name: z8.string()
578
+ name: z9.string()
391
579
  });
392
- var StyleSourceLocal = z8.object({
393
- type: z8.literal("local"),
580
+ var StyleSourceLocal = z9.object({
581
+ type: z9.literal("local"),
394
582
  id: StyleSourceId
395
583
  });
396
- var StyleSource = z8.union([StyleSourceToken, StyleSourceLocal]);
397
- var StyleSources = z8.map(StyleSourceId, StyleSource);
584
+ var StyleSource = z9.union([StyleSourceToken, StyleSourceLocal]);
585
+ var StyleSources = z9.map(StyleSourceId, StyleSource);
398
586
 
399
587
  // 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({
588
+ import { z as z10 } from "zod";
589
+ var InstanceId2 = z10.string();
590
+ var StyleSourceId2 = z10.string();
591
+ var StyleSourceSelection = z10.object({
404
592
  instanceId: InstanceId2,
405
- values: z9.array(StyleSourceId2)
593
+ values: z10.array(StyleSourceId2)
406
594
  });
407
- var StyleSourceSelections = z9.map(InstanceId2, StyleSourceSelection);
595
+ var StyleSourceSelections = z10.map(InstanceId2, StyleSourceSelection);
408
596
 
409
597
  // 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()),
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()),
416
604
  // @todo can't figure out how to make property to be enum
417
- property: z10.string(),
418
- value: StyleValue,
419
- 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")
420
608
  });
421
609
  var StyleDecl = StyleDeclRaw;
422
610
  var getStyleDeclKey = (styleDecl) => {
423
611
  return `${styleDecl.styleSourceId}:${styleDecl.breakpointId}:${styleDecl.property}:${styleDecl.state ?? ""}`;
424
612
  };
425
- var Styles = z10.map(z10.string(), StyleDecl);
613
+ var Styles = z11.map(z11.string(), StyleDecl);
426
614
 
427
615
  // src/schema/deployment.ts
428
- import { z as z11 } from "zod";
429
- var Templates = z11.enum([
430
- "vanilla",
616
+ import { z as z12 } from "zod";
617
+ var Templates = z12.enum([
431
618
  "docker",
432
619
  "vercel",
433
- "netlify-functions",
434
- "netlify-edge-functions",
620
+ "netlify",
435
621
  "ssg",
436
622
  "ssg-netlify",
437
623
  "ssg-vercel"
438
624
  ]);
439
- var Deployment = z11.union([
440
- z11.object({
441
- destination: z11.literal("static"),
442
- name: z11.string(),
443
- assetsDomain: z11.string(),
625
+ var Deployment = z12.union([
626
+ z12.object({
627
+ destination: z12.literal("static"),
628
+ name: z12.string(),
629
+ assetsDomain: z12.string(),
444
630
  // Must be validated very strictly
445
- templates: z11.array(Templates)
631
+ templates: z12.array(Templates)
446
632
  }),
447
- z11.object({
448
- destination: z11.literal("saas").optional(),
449
- domains: z11.array(z11.string()),
450
- assetsDomain: z11.string().optional(),
633
+ z12.object({
634
+ destination: z12.literal("saas").optional(),
635
+ domains: z12.array(z12.string()),
636
+ assetsDomain: z12.string().optional(),
451
637
  /**
452
638
  * @deprecated This field is deprecated, use `domains` instead.
453
639
  */
454
- projectDomain: z11.string().optional(),
455
- excludeWstdDomainFromSearch: z11.boolean().optional()
640
+ projectDomain: z12.string().optional(),
641
+ excludeWstdDomainFromSearch: z12.boolean().optional()
456
642
  })
457
643
  ]);
458
644
 
459
645
  // src/schema/webstudio.ts
460
- import { z as z12 } from "zod";
461
- var WebstudioFragment = z12.object({
462
- children: z12.array(InstanceChild),
463
- instances: z12.array(Instance),
464
- assets: z12.array(Asset),
465
- dataSources: z12.array(DataSource),
466
- resources: z12.array(Resource),
467
- props: z12.array(Prop),
468
- breakpoints: z12.array(Breakpoint),
469
- styleSourceSelections: z12.array(StyleSourceSelection),
470
- styleSources: z12.array(StyleSource),
471
- styles: z12.array(StyleDecl)
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)
472
658
  });
473
659
 
474
660
  // src/schema/prop-meta.ts
475
- import { z as z13 } from "zod";
661
+ import { z as z14 } from "zod";
476
662
  var common = {
477
- label: z13.string().optional(),
478
- description: z13.string().optional(),
479
- required: z13.boolean()
663
+ label: z14.string().optional(),
664
+ description: z14.string().optional(),
665
+ required: z14.boolean()
480
666
  };
481
- 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({
482
675
  ...common,
483
- control: z13.literal("number"),
484
- type: z13.literal("number"),
485
- defaultValue: z13.number().optional()
676
+ control: z14.literal("number"),
677
+ type: z14.literal("number"),
678
+ defaultValue: z14.number().optional()
486
679
  });
487
- var Range = z13.object({
680
+ var Range = z14.object({
488
681
  ...common,
489
- control: z13.literal("range"),
490
- type: z13.literal("number"),
491
- defaultValue: z13.number().optional()
682
+ control: z14.literal("range"),
683
+ type: z14.literal("number"),
684
+ defaultValue: z14.number().optional()
492
685
  });
493
- var Text = z13.object({
686
+ var Text = z14.object({
494
687
  ...common,
495
- control: z13.literal("text"),
496
- type: z13.literal("string"),
497
- defaultValue: z13.string().optional(),
688
+ control: z14.literal("text"),
689
+ type: z14.literal("string"),
690
+ defaultValue: z14.string().optional(),
498
691
  /**
499
692
  * The number of rows in <textarea>. If set to 0 an <input> will be used instead.
500
693
  * In line with Storybook team's plan: https://github.com/storybookjs/storybook/issues/21100
501
694
  */
502
- 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()
503
702
  });
504
- var Code = z13.object({
703
+ var Code = z14.object({
505
704
  ...common,
506
- control: z13.literal("code"),
507
- type: z13.literal("string"),
508
- language: z13.union([z13.literal("html"), z13.literal("markdown")]),
509
- defaultValue: z13.string().optional()
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()
510
709
  });
511
- var CodeText = z13.object({
710
+ var CodeText = z14.object({
512
711
  ...common,
513
- control: z13.literal("codetext"),
514
- type: z13.literal("string"),
515
- defaultValue: z13.string().optional()
712
+ control: z14.literal("codetext"),
713
+ type: z14.literal("string"),
714
+ defaultValue: z14.string().optional()
516
715
  });
517
- var Color = z13.object({
716
+ var Color = z14.object({
518
717
  ...common,
519
- control: z13.literal("color"),
520
- type: z13.literal("string"),
521
- defaultValue: z13.string().optional()
718
+ control: z14.literal("color"),
719
+ type: z14.literal("string"),
720
+ defaultValue: z14.string().optional()
522
721
  });
523
- var Boolean = z13.object({
722
+ var Boolean = z14.object({
524
723
  ...common,
525
- control: z13.literal("boolean"),
526
- type: z13.literal("boolean"),
527
- defaultValue: z13.boolean().optional()
724
+ control: z14.literal("boolean"),
725
+ type: z14.literal("boolean"),
726
+ defaultValue: z14.boolean().optional()
528
727
  });
529
- var Radio = z13.object({
728
+ var Radio = z14.object({
530
729
  ...common,
531
- control: z13.literal("radio"),
532
- type: z13.literal("string"),
533
- defaultValue: z13.string().optional(),
534
- 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())
535
734
  });
536
- var InlineRadio = z13.object({
735
+ var InlineRadio = z14.object({
537
736
  ...common,
538
- control: z13.literal("inline-radio"),
539
- type: z13.literal("string"),
540
- defaultValue: z13.string().optional(),
541
- 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())
542
741
  });
543
- var Select = z13.object({
742
+ var Select = z14.object({
544
743
  ...common,
545
- control: z13.literal("select"),
546
- type: z13.literal("string"),
547
- defaultValue: z13.string().optional(),
548
- 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())
549
748
  });
550
- var Check = z13.object({
749
+ var Check = z14.object({
551
750
  ...common,
552
- control: z13.literal("check"),
553
- type: z13.literal("string[]"),
554
- defaultValue: z13.array(z13.string()).optional(),
555
- 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())
556
755
  });
557
- var InlineCheck = z13.object({
756
+ var InlineCheck = z14.object({
558
757
  ...common,
559
- control: z13.literal("inline-check"),
560
- type: z13.literal("string[]"),
561
- defaultValue: z13.array(z13.string()).optional(),
562
- options: z13.array(z13.string())
758
+ control: z14.literal("inline-check"),
759
+ type: z14.literal("string[]"),
760
+ defaultValue: z14.array(z14.string()).optional(),
761
+ options: z14.array(z14.string())
563
762
  });
564
- var MultiSelect = z13.object({
763
+ var MultiSelect = z14.object({
565
764
  ...common,
566
- control: z13.literal("multi-select"),
567
- type: z13.literal("string[]"),
568
- defaultValue: z13.array(z13.string()).optional(),
569
- options: z13.array(z13.string())
765
+ control: z14.literal("multi-select"),
766
+ type: z14.literal("string[]"),
767
+ defaultValue: z14.array(z14.string()).optional(),
768
+ options: z14.array(z14.string())
570
769
  });
571
- var File = z13.object({
770
+ var File = z14.object({
572
771
  ...common,
573
- control: z13.literal("file"),
574
- type: z13.literal("string"),
575
- defaultValue: z13.string().optional(),
772
+ control: z14.literal("file"),
773
+ type: z14.literal("string"),
774
+ defaultValue: z14.string().optional(),
576
775
  /** https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept */
577
- accept: z13.string().optional()
776
+ accept: z14.string().optional()
578
777
  });
579
- var Url = z13.object({
778
+ var Url = z14.object({
580
779
  ...common,
581
- control: z13.literal("url"),
582
- type: z13.literal("string"),
583
- defaultValue: z13.string().optional()
780
+ control: z14.literal("url"),
781
+ type: z14.literal("string"),
782
+ defaultValue: z14.string().optional()
584
783
  });
585
- var Json = z13.object({
784
+ var Json = z14.object({
586
785
  ...common,
587
- control: z13.literal("json"),
588
- type: z13.literal("json"),
589
- defaultValue: z13.unknown().optional()
786
+ control: z14.literal("json"),
787
+ type: z14.literal("json"),
788
+ defaultValue: z14.unknown().optional()
590
789
  });
591
- var Date = z13.object({
790
+ var Date = z14.object({
592
791
  ...common,
593
- control: z13.literal("date"),
792
+ control: z14.literal("date"),
594
793
  // @todo not sure what type should be here
595
794
  // (we don't support Date yet, added for completeness)
596
- type: z13.literal("string"),
597
- defaultValue: z13.string().optional()
795
+ type: z14.literal("string"),
796
+ defaultValue: z14.string().optional()
598
797
  });
599
- var Action = z13.object({
798
+ var Action = z14.object({
600
799
  ...common,
601
- control: z13.literal("action"),
602
- type: z13.literal("action"),
603
- defaultValue: z13.undefined().optional()
800
+ control: z14.literal("action"),
801
+ type: z14.literal("action"),
802
+ defaultValue: z14.undefined().optional()
604
803
  });
605
- var TextContent = z13.object({
804
+ var TextContent = z14.object({
606
805
  ...common,
607
- control: z13.literal("textContent"),
608
- type: z13.literal("string"),
609
- defaultValue: z13.string().optional()
806
+ control: z14.literal("textContent"),
807
+ type: z14.literal("string"),
808
+ defaultValue: z14.string().optional()
610
809
  });
611
- 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,
612
818
  Number,
613
819
  Range,
614
820
  Text,
821
+ Resource2,
615
822
  Code,
616
823
  CodeText,
617
824
  Color,
@@ -627,138 +834,56 @@ var PropMeta = z13.union([
627
834
  Json,
628
835
  Date,
629
836
  Action,
630
- TextContent
837
+ TextContent,
838
+ AnimationAction
631
839
  ]);
632
840
 
633
- // src/schema/embed-template.ts
634
- import { z as z14 } from "zod";
635
- import { StyleValue as StyleValue2 } from "@webstudio-is/css-engine";
636
- var EmbedTemplateText = z14.object({
637
- type: z14.literal("text"),
638
- value: z14.string(),
639
- placeholder: z14.boolean().optional()
640
- });
641
- var EmbedTemplateExpression = z14.object({
642
- type: z14.literal("expression"),
643
- value: z14.string()
644
- });
645
- var EmbedTemplateVariable = z14.object({
646
- alias: z14.optional(z14.string()),
647
- initialValue: z14.unknown()
648
- });
649
- var EmbedTemplateProp = z14.union([
650
- z14.object({
651
- type: z14.literal("number"),
652
- name: z14.string(),
653
- value: z14.number()
654
- }),
655
- z14.object({
656
- type: z14.literal("string"),
657
- name: z14.string(),
658
- value: z14.string()
659
- }),
660
- z14.object({
661
- type: z14.literal("boolean"),
662
- name: z14.string(),
663
- value: z14.boolean()
664
- }),
665
- z14.object({
666
- type: z14.literal("string[]"),
667
- name: z14.string(),
668
- value: z14.array(z14.string())
669
- }),
670
- z14.object({
671
- type: z14.literal("json"),
672
- name: z14.string(),
673
- value: z14.unknown()
674
- }),
675
- z14.object({
676
- type: z14.literal("expression"),
677
- name: z14.string(),
678
- code: z14.string()
679
- }),
680
- z14.object({
681
- type: z14.literal("parameter"),
682
- name: z14.string(),
683
- variableName: z14.string(),
684
- variableAlias: z14.optional(z14.string())
685
- }),
686
- z14.object({
687
- type: z14.literal("action"),
688
- name: z14.string(),
689
- value: z14.array(
690
- z14.object({
691
- type: z14.literal("execute"),
692
- args: z14.optional(z14.array(z14.string())),
693
- code: z14.string()
694
- })
695
- )
696
- })
697
- ]);
698
- var EmbedTemplateStyleDeclRaw = z14.object({
699
- // State selector, e.g. :hover
700
- state: z14.optional(z14.string()),
701
- property: z14.string(),
702
- value: StyleValue2
703
- });
704
- var EmbedTemplateStyleDecl = EmbedTemplateStyleDeclRaw;
705
- var EmbedTemplateInstance = z14.lazy(
706
- () => z14.object({
707
- type: z14.literal("instance"),
708
- component: z14.string(),
709
- label: z14.optional(z14.string()),
710
- variables: z14.optional(z14.record(z14.string(), EmbedTemplateVariable)),
711
- props: z14.optional(z14.array(EmbedTemplateProp)),
712
- styles: z14.optional(z14.array(EmbedTemplateStyleDecl)),
713
- children: WsEmbedTemplate
714
- })
715
- );
716
- var WsEmbedTemplate = z14.lazy(
717
- () => z14.array(
718
- z14.union([EmbedTemplateInstance, EmbedTemplateText, EmbedTemplateExpression])
719
- )
720
- );
721
-
722
841
  // src/schema/component-meta.ts
723
842
  import { z as z15 } from "zod";
724
- var WsComponentPropsMeta = z15.object({
725
- props: z15.record(PropMeta),
726
- // Props that will be always visible in properties panel.
727
- 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
728
849
  });
729
850
  var componentCategories = [
730
851
  "general",
731
852
  "typography",
732
853
  "media",
854
+ "animations",
733
855
  "data",
734
856
  "forms",
735
857
  "localization",
736
858
  "radix",
737
859
  "xml",
860
+ "other",
738
861
  "hidden",
739
862
  "internal"
740
863
  ];
741
- var stateCategories = ["states", "component-states"];
742
864
  var ComponentState = z15.object({
743
- category: z15.enum(stateCategories).optional(),
744
865
  selector: z15.string(),
745
866
  label: z15.string()
746
867
  });
747
- var defaultStates = [
748
- { selector: ":hover", label: "Hover" },
749
- { selector: ":active", label: "Active" },
750
- { selector: ":focus", label: "Focus" },
751
- { selector: ":focus-visible", label: "Focus Visible" },
752
- { selector: ":focus-within", label: "Focus Within" }
753
- ];
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
+ });
754
884
  var WsComponentMeta = z15.object({
755
885
  category: z15.enum(componentCategories).optional(),
756
- // container - can accept other components with dnd or be edited as text
757
- // control - usually form controls like inputs, without children
758
- // embed - images, videos or other embeddable components, without children
759
- // rich-text-child - formatted text fragment, not listed in components list
760
- type: z15.enum(["container", "control", "embed", "rich-text-child"]),
761
- constraints: Matchers.optional(),
886
+ contentModel: ContentModel.optional(),
762
887
  // when this field is specified component receives
763
888
  // prop with index of same components withiin specified ancestor
764
889
  // important to automatically enumerate collections without
@@ -766,13 +891,13 @@ var WsComponentMeta = z15.object({
766
891
  indexWithinAncestor: z15.optional(z15.string()),
767
892
  label: z15.optional(z15.string()),
768
893
  description: z15.string().optional(),
769
- icon: z15.string(),
770
- presetStyle: z15.optional(
771
- z15.record(z15.string(), z15.array(EmbedTemplateStyleDecl))
772
- ),
894
+ icon: z15.string().optional(),
895
+ presetStyle: z15.optional(z15.record(z15.string(), z15.array(PresetStyleDecl))),
773
896
  states: z15.optional(z15.array(ComponentState)),
774
- template: z15.optional(WsEmbedTemplate),
775
- 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()
776
901
  });
777
902
 
778
903
  // src/core-metas.ts
@@ -785,67 +910,822 @@ import {
785
910
  } from "@webstudio-is/icons/svg";
786
911
 
787
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;
788
1012
  var html = [
789
1013
  { property: "display", value: { type: "keyword", value: "grid" } },
790
- { property: "minHeight", value: { type: "unit", unit: "%", value: 100 } },
1014
+ { property: "min-height", value: { type: "unit", unit: "%", value: 100 } },
791
1015
  {
792
- property: "fontFamily",
1016
+ property: "font-family",
793
1017
  value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
794
1018
  },
795
- { property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
1019
+ { property: "font-size", value: { type: "unit", unit: "px", value: 16 } },
796
1020
  {
797
- property: "lineHeight",
1021
+ property: "line-height",
798
1022
  value: { type: "unit", unit: "number", value: 1.2 }
799
1023
  },
800
1024
  {
801
- property: "whiteSpaceCollapse",
1025
+ property: "white-space-collapse",
802
1026
  value: { type: "keyword", value: "preserve" }
803
1027
  }
804
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
+ ];
805
1675
 
806
1676
  // src/core-metas.ts
807
1677
  var rootComponent = "ws:root";
808
1678
  var rootMeta = {
809
- type: "container",
810
1679
  label: "Global Root",
811
1680
  icon: SettingsIcon,
812
1681
  presetStyle: {
813
1682
  html
814
1683
  }
815
1684
  };
816
- var rootPropsMeta = {
817
- 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
+ }
818
1699
  };
819
1700
  var portalComponent = "Slot";
820
1701
  var collectionComponent = "ws:collection";
821
1702
  var collectionMeta = {
822
- type: "container",
823
1703
  label: "Collection",
824
- icon: ListViewIcon
825
- };
826
- var collectionPropsMeta = {
1704
+ icon: ListViewIcon,
1705
+ contentModel: {
1706
+ category: "instance",
1707
+ children: ["instance"]
1708
+ },
1709
+ initialProps: ["data"],
827
1710
  props: {
828
1711
  data: {
829
1712
  required: true,
830
1713
  control: "json",
831
1714
  type: "json"
832
1715
  }
833
- },
834
- initialProps: ["data"]
1716
+ }
835
1717
  };
836
1718
  var descendantComponent = "ws:descendant";
837
1719
  var descendantMeta = {
838
- type: "control",
839
1720
  label: "Descendant",
840
1721
  icon: PaintBrushIcon,
1722
+ contentModel: {
1723
+ category: "none",
1724
+ children: []
1725
+ },
841
1726
  // @todo infer possible presets
842
1727
  presetStyle: {},
843
- constraints: {
844
- relation: "parent",
845
- component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
846
- }
847
- };
848
- var descendantPropsMeta = {
1728
+ initialProps: ["selector"],
849
1729
  props: {
850
1730
  selector: {
851
1731
  required: true,
@@ -870,55 +1750,35 @@ var descendantPropsMeta = {
870
1750
  " hr"
871
1751
  ]
872
1752
  }
873
- },
874
- initialProps: ["selector"]
1753
+ }
875
1754
  };
876
1755
  var blockComponent = "ws:block";
877
1756
  var blockTemplateComponent = "ws:block-template";
878
1757
  var blockTemplateMeta = {
879
- type: "container",
880
1758
  icon: AddTemplateInstanceIcon,
881
- constraints: {
882
- relation: "parent",
883
- component: { $eq: blockComponent }
1759
+ contentModel: {
1760
+ category: "none",
1761
+ children: ["instance"]
884
1762
  }
885
1763
  };
886
- var blockTemplatePropsMeta = {
887
- props: {}
888
- };
889
1764
  var blockMeta = {
890
- type: "container",
891
1765
  label: "Content Block",
892
1766
  icon: ContentBlockIcon,
893
- constraints: [
894
- {
895
- relation: "ancestor",
896
- component: { $nin: [collectionComponent, blockComponent] }
897
- },
898
- {
899
- relation: "child",
900
- component: { $eq: blockTemplateComponent }
901
- }
902
- ]
903
- };
904
- var blockPropsMeta = {
905
- props: {}
1767
+ contentModel: {
1768
+ category: "instance",
1769
+ children: [blockTemplateComponent, "instance"]
1770
+ }
906
1771
  };
907
1772
  var coreMetas = {
908
1773
  [rootComponent]: rootMeta,
1774
+ [elementComponent]: elementMeta,
909
1775
  [collectionComponent]: collectionMeta,
910
1776
  [descendantComponent]: descendantMeta,
911
1777
  [blockComponent]: blockMeta,
912
1778
  [blockTemplateComponent]: blockTemplateMeta
913
1779
  };
914
- var corePropsMetas = {
915
- [rootComponent]: rootPropsMeta,
916
- [collectionComponent]: collectionPropsMeta,
917
- [descendantComponent]: descendantPropsMeta,
918
- [blockComponent]: blockPropsMeta,
919
- [blockTemplateComponent]: blockTemplatePropsMeta
920
- };
921
- 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;
922
1782
 
923
1783
  // src/instances-utils.ts
924
1784
  var ROOT_INSTANCE_ID = ":root";
@@ -965,10 +1825,65 @@ var parseComponentName = (componentName) => {
965
1825
  }
966
1826
  return [namespace, name];
967
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
+ };
968
1873
 
969
1874
  // src/expression.ts
970
- import { parseExpressionAt } from "acorn";
1875
+ import {
1876
+ parse,
1877
+ parseExpressionAt
1878
+ } from "acorn";
971
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
+ };
972
1887
  var lintExpression = ({
973
1888
  expression,
974
1889
  availableVariables = /* @__PURE__ */ new Set(),
@@ -996,7 +1911,7 @@ var lintExpression = ({
996
1911
  return diagnostics;
997
1912
  }
998
1913
  try {
999
- const root = parseExpressionAt(`(${expression})`, 0, {
1914
+ const root = parse(`(${expression})`, {
1000
1915
  ecmaVersion: "latest",
1001
1916
  // support parsing import to forbid explicitly
1002
1917
  sourceType: "module"
@@ -1079,6 +1994,9 @@ var lintExpression = ({
1079
1994
  return diagnostics;
1080
1995
  };
1081
1996
  var isLiteralNode = (node) => {
1997
+ if (node.type === "Identifier" && node.name === "undefined") {
1998
+ return true;
1999
+ }
1082
2000
  if (node.type === "Literal") {
1083
2001
  return true;
1084
2002
  }
@@ -1220,11 +2138,17 @@ var generateObjectExpression = (map) => {
1220
2138
  return generated;
1221
2139
  };
1222
2140
  var dataSourceVariablePrefix = "$ws$dataSource$";
1223
- var encodeDataSourceVariable = (id) => {
2141
+ var encodeDataVariableId = (id) => {
2142
+ if (id === SYSTEM_VARIABLE_ID) {
2143
+ return "$ws$system";
2144
+ }
1224
2145
  const encoded = id.replaceAll("-", "__DASH__");
1225
2146
  return `${dataSourceVariablePrefix}${encoded}`;
1226
2147
  };
1227
- var decodeDataSourceVariable = (name) => {
2148
+ var decodeDataVariableId = (name) => {
2149
+ if (name === "$ws$system") {
2150
+ return SYSTEM_VARIABLE_ID;
2151
+ }
1228
2152
  if (name.startsWith(dataSourceVariablePrefix)) {
1229
2153
  const encoded = name.slice(dataSourceVariablePrefix.length);
1230
2154
  return encoded.replaceAll("__DASH__", "-");
@@ -1241,8 +2165,11 @@ var generateExpression = ({
1241
2165
  expression,
1242
2166
  executable: true,
1243
2167
  replaceVariable: (identifier) => {
1244
- const depId = decodeDataSourceVariable(identifier);
1245
- 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
+ }
1246
2173
  if (dep) {
1247
2174
  usedDataSources?.set(dep.id, dep);
1248
2175
  return scope.getName(dep.id, dep.name);
@@ -1399,26 +2326,26 @@ var generateResources = ({
1399
2326
  `;
1400
2327
  generatedRequest += ` headers: [
1401
2328
  `;
1402
- for (const header of resource.headers) {
2329
+ for (const header2 of resource.headers) {
1403
2330
  const value = generateExpression({
1404
- expression: header.value,
2331
+ expression: header2.value,
1405
2332
  dataSources,
1406
2333
  usedDataSources,
1407
2334
  scope
1408
2335
  });
1409
- generatedRequest += ` { name: "${header.name}", value: ${value} },
2336
+ generatedRequest += ` { name: "${header2.name}", value: ${value} },
1410
2337
  `;
1411
2338
  }
1412
2339
  generatedRequest += ` ],
1413
2340
  `;
1414
2341
  if (resource.body !== void 0 && resource.body.length > 0) {
1415
- const body = generateExpression({
2342
+ const body2 = generateExpression({
1416
2343
  expression: resource.body,
1417
2344
  dataSources,
1418
2345
  usedDataSources,
1419
2346
  scope
1420
2347
  });
1421
- generatedRequest += ` body: ${body},
2348
+ generatedRequest += ` body: ${body2},
1422
2349
  `;
1423
2350
  }
1424
2351
  generatedRequest += ` }
@@ -1434,12 +2361,11 @@ var generateResources = ({
1434
2361
  `;
1435
2362
  }
1436
2363
  if (dataSource.type === "parameter") {
1437
- if (dataSource.id !== page.systemDataSourceId) {
1438
- continue;
1439
- }
1440
- const name = scope.getName(dataSource.id, dataSource.name);
1441
- generatedVariables += ` const ${name} = _props.system
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
1442
2367
  `;
2368
+ }
1443
2369
  }
1444
2370
  }
1445
2371
  let generated = "";
@@ -1528,7 +2454,9 @@ var replaceFormActionsWithResources = ({
1528
2454
  name: "action",
1529
2455
  method: getMethod(method),
1530
2456
  url: JSON.stringify(action),
1531
- headers: []
2457
+ headers: [
2458
+ { name: "Content-Type", value: JSON.stringify("application/json") }
2459
+ ]
1532
2460
  });
1533
2461
  }
1534
2462
  }
@@ -1636,7 +2564,7 @@ var generatePageMeta = ({
1636
2564
  continue;
1637
2565
  }
1638
2566
  if (dataSource.type === "parameter") {
1639
- if (dataSource.id === page.systemDataSourceId) {
2567
+ if (dataSource.id === page.systemDataSourceId || dataSource.id === SYSTEM_VARIABLE_ID) {
1640
2568
  const valueName = localScope.getName(dataSource.id, dataSource.name);
1641
2569
  generated += ` let ${valueName} = system
1642
2570
  `;
@@ -1680,6 +2608,208 @@ var generatePageMeta = ({
1680
2608
  `;
1681
2609
  return generated;
1682
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
+ };
1683
2813
  export {
1684
2814
  Asset,
1685
2815
  Assets,
@@ -1687,14 +2817,11 @@ export {
1687
2817
  Breakpoints,
1688
2818
  CompilerSettings,
1689
2819
  ComponentState,
2820
+ ContentModel,
1690
2821
  DataSource,
1691
2822
  DataSourceVariableValue,
1692
2823
  DataSources,
1693
2824
  Deployment,
1694
- EmbedTemplateInstance,
1695
- EmbedTemplateProp,
1696
- EmbedTemplateStyleDecl,
1697
- EmbedTemplateVariable,
1698
2825
  ExpressionChild,
1699
2826
  Folder,
1700
2827
  FolderName,
@@ -1706,24 +2833,24 @@ export {
1706
2833
  Instance,
1707
2834
  InstanceChild,
1708
2835
  Instances,
1709
- Matcher,
1710
- MatcherOperation,
1711
- MatcherRelation,
1712
- Matchers,
2836
+ OldPagePath,
1713
2837
  PageName,
1714
2838
  PagePath,
1715
2839
  PageRedirect,
1716
2840
  PageTitle,
1717
2841
  Pages,
2842
+ PresetStyleDecl,
1718
2843
  ProjectNewRedirectPath,
1719
2844
  Prop,
1720
2845
  PropMeta,
1721
2846
  Props,
2847
+ RANGE_UNITS,
1722
2848
  ROOT_FOLDER_ID,
1723
2849
  ROOT_INSTANCE_ID,
1724
2850
  Resource,
1725
2851
  ResourceRequest,
1726
2852
  Resources,
2853
+ SYSTEM_VARIABLE_ID,
1727
2854
  StyleDecl,
1728
2855
  StyleSource,
1729
2856
  StyleSourceSelection,
@@ -1734,36 +2861,43 @@ export {
1734
2861
  TextChild,
1735
2862
  WebstudioFragment,
1736
2863
  WsComponentMeta,
1737
- WsEmbedTemplate,
2864
+ addFontRules,
2865
+ animationActionSchema,
2866
+ animationKeyframeSchema,
1738
2867
  blockComponent,
1739
2868
  blockTemplateComponent,
1740
2869
  blockTemplateMeta,
1741
2870
  collectionComponent,
1742
2871
  componentCategories,
1743
2872
  coreMetas,
1744
- corePropsMetas,
2873
+ createImageValueTransformer,
1745
2874
  createScope,
1746
- decodeDataSourceVariable,
1747
- decodeDataSourceVariable as decodeDataVariableId,
1748
- defaultStates,
2875
+ decodeDataVariableId as decodeDataSourceVariable,
2876
+ decodeDataVariableId,
1749
2877
  descendantComponent,
1750
2878
  documentTypes,
1751
- encodeDataSourceVariable,
1752
- encodeDataSourceVariable as encodeDataVariableId,
2879
+ durationUnitValueSchema,
2880
+ elementComponent,
2881
+ encodeDataVariableId as encodeDataSourceVariable,
2882
+ encodeDataVariableId,
1753
2883
  executeExpression,
1754
2884
  findPageByIdOrPath,
1755
2885
  findParentFolderByChildId,
1756
2886
  findTreeInstanceIds,
1757
2887
  findTreeInstanceIdsExcludingSlotDescendants,
2888
+ generateCss,
1758
2889
  generateExpression,
1759
2890
  generateObjectExpression,
1760
2891
  generatePageMeta,
1761
2892
  generateResources,
1762
2893
  getExpressionIdentifiers,
2894
+ getIndexesWithinAncestors,
1763
2895
  getPagePath,
1764
2896
  getStaticSiteMapXml,
1765
2897
  getStyleDeclKey,
1766
2898
  initialBreakpoints,
2899
+ insetUnitValueSchema,
2900
+ isComponentDetachable,
1767
2901
  isCoreComponent,
1768
2902
  isLiteralExpression,
1769
2903
  isPathnamePattern,
@@ -1773,8 +2907,12 @@ export {
1773
2907
  parseComponentName,
1774
2908
  parseObjectExpression,
1775
2909
  portalComponent,
2910
+ rangeUnitValueSchema,
1776
2911
  replaceFormActionsWithResources,
1777
2912
  rootComponent,
1778
- stateCategories,
1779
- transpileExpression
2913
+ scrollAnimationSchema,
2914
+ systemParameter,
2915
+ tags,
2916
+ transpileExpression,
2917
+ viewAnimationSchema
1780
2918
  };