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