@kumwe/studio-core 0.1.0-alpha.10

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.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/THIRD_PARTY_NOTICES.md +9 -0
  4. package/dist/binding-projection.d.ts +47 -0
  5. package/dist/binding-projection.d.ts.map +1 -0
  6. package/dist/binding-projection.js +253 -0
  7. package/dist/binding-projection.js.map +1 -0
  8. package/dist/canonical.d.ts +20 -0
  9. package/dist/canonical.d.ts.map +1 -0
  10. package/dist/canonical.js +100 -0
  11. package/dist/canonical.js.map +1 -0
  12. package/dist/clone.d.ts +2 -0
  13. package/dist/clone.d.ts.map +1 -0
  14. package/dist/clone.js +4 -0
  15. package/dist/clone.js.map +1 -0
  16. package/dist/commands.d.ts +18 -0
  17. package/dist/commands.d.ts.map +1 -0
  18. package/dist/commands.js +799 -0
  19. package/dist/commands.js.map +1 -0
  20. package/dist/contributions.d.ts +93 -0
  21. package/dist/contributions.d.ts.map +1 -0
  22. package/dist/contributions.js +435 -0
  23. package/dist/contributions.js.map +1 -0
  24. package/dist/entry-commands.d.ts +3 -0
  25. package/dist/entry-commands.d.ts.map +1 -0
  26. package/dist/entry-commands.js +36 -0
  27. package/dist/entry-commands.js.map +1 -0
  28. package/dist/extension-sdk.d.ts +51 -0
  29. package/dist/extension-sdk.d.ts.map +1 -0
  30. package/dist/extension-sdk.js +260 -0
  31. package/dist/extension-sdk.js.map +1 -0
  32. package/dist/history.d.ts +22 -0
  33. package/dist/history.d.ts.map +1 -0
  34. package/dist/history.js +81 -0
  35. package/dist/history.js.map +1 -0
  36. package/dist/host-session.d.ts +74 -0
  37. package/dist/host-session.d.ts.map +1 -0
  38. package/dist/host-session.js +713 -0
  39. package/dist/host-session.js.map +1 -0
  40. package/dist/index.d.ts +23 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +23 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/layout.d.ts +66 -0
  45. package/dist/layout.d.ts.map +1 -0
  46. package/dist/layout.js +240 -0
  47. package/dist/layout.js.map +1 -0
  48. package/dist/migrations.d.ts +47 -0
  49. package/dist/migrations.d.ts.map +1 -0
  50. package/dist/migrations.js +83 -0
  51. package/dist/migrations.js.map +1 -0
  52. package/dist/model-commands.d.ts +3 -0
  53. package/dist/model-commands.d.ts.map +1 -0
  54. package/dist/model-commands.js +21 -0
  55. package/dist/model-commands.js.map +1 -0
  56. package/dist/modes.d.ts +47 -0
  57. package/dist/modes.d.ts.map +1 -0
  58. package/dist/modes.js +280 -0
  59. package/dist/modes.js.map +1 -0
  60. package/dist/negotiation.d.ts +23 -0
  61. package/dist/negotiation.d.ts.map +1 -0
  62. package/dist/negotiation.js +65 -0
  63. package/dist/negotiation.js.map +1 -0
  64. package/dist/production-values.d.ts +12 -0
  65. package/dist/production-values.d.ts.map +1 -0
  66. package/dist/production-values.js +224 -0
  67. package/dist/production-values.js.map +1 -0
  68. package/dist/production.d.ts +86 -0
  69. package/dist/production.d.ts.map +1 -0
  70. package/dist/production.js +811 -0
  71. package/dist/production.js.map +1 -0
  72. package/dist/profile-validator.d.ts +47 -0
  73. package/dist/profile-validator.d.ts.map +1 -0
  74. package/dist/profile-validator.js +887 -0
  75. package/dist/profile-validator.js.map +1 -0
  76. package/dist/recipes.d.ts +15 -0
  77. package/dist/recipes.d.ts.map +1 -0
  78. package/dist/recipes.js +34 -0
  79. package/dist/recipes.js.map +1 -0
  80. package/dist/registry.d.ts +17 -0
  81. package/dist/registry.d.ts.map +1 -0
  82. package/dist/registry.js +56 -0
  83. package/dist/registry.js.map +1 -0
  84. package/dist/schema-profile.d.ts +27 -0
  85. package/dist/schema-profile.d.ts.map +1 -0
  86. package/dist/schema-profile.js +1015 -0
  87. package/dist/schema-profile.js.map +1 -0
  88. package/dist/semver.d.ts +20 -0
  89. package/dist/semver.d.ts.map +1 -0
  90. package/dist/semver.js +128 -0
  91. package/dist/semver.js.map +1 -0
  92. package/dist/session.d.ts +73 -0
  93. package/dist/session.d.ts.map +1 -0
  94. package/dist/session.js +191 -0
  95. package/dist/session.js.map +1 -0
  96. package/dist/url-policy.d.ts +45 -0
  97. package/dist/url-policy.d.ts.map +1 -0
  98. package/dist/url-policy.js +248 -0
  99. package/dist/url-policy.js.map +1 -0
  100. package/dist/validation.d.ts +13 -0
  101. package/dist/validation.d.ts.map +1 -0
  102. package/dist/validation.js +444 -0
  103. package/dist/validation.js.map +1 -0
  104. package/package.json +41 -0
@@ -0,0 +1,811 @@
1
+ import { STUDIO_CONTRACT_VERSION, studioPresentationSchema, } from '@kumwe/studio-protocol';
2
+ import { cloneContractValue } from './clone.js';
3
+ import { CORE_LAYOUT_BLOCK_TYPES, coreLayoutInitialProperties, createCoreLayoutBlockDefinitions, isCoreLayoutBlockType, } from './layout.js';
4
+ export const CORE_PRODUCTION_BLOCK_TYPES = Object.freeze({
5
+ ...CORE_LAYOUT_BLOCK_TYPES,
6
+ accordion: 'studio.core/accordion',
7
+ accordionItem: 'studio.core/accordion-item',
8
+ article: 'studio.core/article',
9
+ attachment: 'studio.core/attachment',
10
+ audio: 'studio.core/audio',
11
+ badge: 'studio.core/badge',
12
+ callToAction: 'studio.core/call-to-action',
13
+ callout: 'studio.core/callout',
14
+ card: 'studio.core/card',
15
+ chart: 'studio.core/chart',
16
+ code: 'studio.core/code',
17
+ contentCollection: 'studio.core/content-collection',
18
+ contentReference: 'studio.core/content-reference',
19
+ countdown: 'studio.core/countdown',
20
+ cover: 'studio.core/cover',
21
+ descriptionItem: 'studio.core/description-item',
22
+ descriptionList: 'studio.core/description-list',
23
+ diagram: 'studio.core/diagram',
24
+ dialog: 'studio.core/dialog',
25
+ divider: 'studio.core/divider',
26
+ drawing: 'studio.core/drawing',
27
+ embed: 'studio.core/embed',
28
+ gallery: 'studio.core/gallery',
29
+ heading: 'studio.core/heading',
30
+ icon: 'studio.core/icon',
31
+ image: 'studio.core/image',
32
+ label: 'studio.core/label',
33
+ math: 'studio.core/math',
34
+ money: 'studio.core/money',
35
+ navigation: 'studio.core/navigation',
36
+ navigationItem: 'studio.core/navigation-item',
37
+ notice: 'studio.core/notice',
38
+ popover: 'studio.core/popover',
39
+ progress: 'studio.core/progress',
40
+ richText: 'studio.core/rich-text',
41
+ search: 'studio.core/search',
42
+ spinner: 'studio.core/spinner',
43
+ tab: 'studio.core/tab',
44
+ table: 'studio.core/table',
45
+ tabs: 'studio.core/tabs',
46
+ video: 'studio.core/video',
47
+ });
48
+ export const CORE_PRODUCTION_CONTROL_IDS = Object.freeze({
49
+ chart: 'studio.control/chart',
50
+ drawing: 'studio.control/drawing',
51
+ mediaCollection: 'studio.control/media-collection',
52
+ mediaReference: 'studio.control/media-reference',
53
+ money: 'studio.control/money',
54
+ presentation: 'studio.control/presentation',
55
+ richText: 'studio.control/rich-text',
56
+ scopedCss: 'studio.control/scoped-css',
57
+ source: 'studio.control/source',
58
+ table: 'studio.control/table',
59
+ });
60
+ /** The ten reusable compositions distributed with the production catalog. */
61
+ export const CORE_PRODUCTION_PATTERN_IDS = Object.freeze([
62
+ 'studio.pattern/article',
63
+ 'studio.pattern/collection-index',
64
+ 'studio.pattern/document-header',
65
+ 'studio.pattern/faq',
66
+ 'studio.pattern/feature-grid',
67
+ 'studio.pattern/hero',
68
+ 'studio.pattern/media-gallery',
69
+ 'studio.pattern/pricing',
70
+ 'studio.pattern/product',
71
+ 'studio.pattern/tabbed-content',
72
+ ]);
73
+ const VERSION = '1.0.0';
74
+ const OWNER = Object.freeze({ id: 'studio.core/blocks', version: VERSION });
75
+ const WEB_RENDERERS = Object.freeze([
76
+ {
77
+ capability: 'studio.renderer/semantic-web',
78
+ surface: 'preview',
79
+ versions: '^1.0.0',
80
+ },
81
+ {
82
+ capability: 'studio.renderer/semantic-web',
83
+ surface: 'web',
84
+ versions: '^1.0.0',
85
+ },
86
+ ]);
87
+ const ALL_TYPES = Object.freeze(Object.values(CORE_PRODUCTION_BLOCK_TYPES));
88
+ const CONTENT_TYPES = Object.freeze(ALL_TYPES.filter((type) => type !== CORE_PRODUCTION_BLOCK_TYPES.accordionItem &&
89
+ type !== CORE_PRODUCTION_BLOCK_TYPES.descriptionItem &&
90
+ type !== CORE_PRODUCTION_BLOCK_TYPES.navigationItem &&
91
+ type !== CORE_PRODUCTION_BLOCK_TYPES.tab));
92
+ const textPort = (id, required = false) => ({
93
+ authoring: { control: 'studio.control/single-line-text' },
94
+ id,
95
+ label: message(`port-${id}`, title(id)),
96
+ multiple: false,
97
+ required,
98
+ valueType: 'text',
99
+ });
100
+ const numberPort = (id, required = false) => ({
101
+ authoring: { control: 'studio.control/integer' },
102
+ id,
103
+ label: message(`port-${id}`, title(id)),
104
+ multiple: false,
105
+ required,
106
+ valueType: 'integer',
107
+ });
108
+ const richTextPort = (id = 'content') => ({
109
+ authoring: {
110
+ control: CORE_PRODUCTION_CONTROL_IDS.richText,
111
+ profile: 'studio.rich-text/marketing',
112
+ },
113
+ id,
114
+ label: message(`port-${id}`, title(id)),
115
+ multiple: false,
116
+ required: false,
117
+ valueType: 'rich-text',
118
+ });
119
+ const mediaPort = (id, multiple = false) => ({
120
+ authoring: {
121
+ control: multiple
122
+ ? CORE_PRODUCTION_CONTROL_IDS.mediaCollection
123
+ : CORE_PRODUCTION_CONTROL_IDS.mediaReference,
124
+ },
125
+ id,
126
+ label: message(`port-${id}`, title(id)),
127
+ multiple,
128
+ required: false,
129
+ valueType: 'media',
130
+ });
131
+ const sourcePort = (profile) => ({
132
+ authoring: { control: CORE_PRODUCTION_CONTROL_IDS.source, profile },
133
+ id: 'source',
134
+ label: message('port-source', 'Source'),
135
+ multiple: false,
136
+ required: true,
137
+ valueType: 'text',
138
+ });
139
+ const resourcePort = (id, multiple) => ({
140
+ authoring: { readOnly: true },
141
+ id,
142
+ label: message(`port-${id}`, title(id)),
143
+ multiple,
144
+ required: true,
145
+ valueType: 'resource',
146
+ });
147
+ const stringSchema = (maximum = 20_000) => ({ maxLength: maximum, type: 'string' });
148
+ const booleanSchema = () => ({ type: 'boolean' });
149
+ const enumSchema = (...values) => ({ enum: values });
150
+ const integerSchema = (minimum, maximum) => ({
151
+ maximum,
152
+ minimum,
153
+ type: 'integer',
154
+ });
155
+ const PRESENTATION_PROPERTY_SCHEMA = presentationPropertySchema();
156
+ const SPECS = Object.freeze({
157
+ accordion: {
158
+ accessibility: 'composite',
159
+ controls: { 'allow-multiple': 'studio.control/switch' },
160
+ defaults: { 'allow-multiple': false },
161
+ properties: { 'allow-multiple': booleanSchema() },
162
+ slots: [{ accepts: [CORE_PRODUCTION_BLOCK_TYPES.accordionItem], id: 'items', maximum: 50 }],
163
+ },
164
+ accordionItem: {
165
+ accessibility: 'composite',
166
+ controls: { expanded: 'studio.control/switch' },
167
+ defaults: { expanded: false },
168
+ ports: [textPort('title', true)],
169
+ properties: { expanded: booleanSchema() },
170
+ slots: [{ accepts: CONTENT_TYPES, id: 'content', maximum: 100 }],
171
+ },
172
+ article: {
173
+ accessibility: 'landmark',
174
+ defaults: {},
175
+ ports: [textPort('title')],
176
+ slots: [{ accepts: CONTENT_TYPES, id: 'content', maximum: 200 }],
177
+ },
178
+ attachment: {
179
+ accessibility: 'media',
180
+ controls: { download: 'studio.control/switch' },
181
+ defaults: { download: true },
182
+ ports: [mediaPort('asset'), textPort('label')],
183
+ properties: { download: booleanSchema() },
184
+ },
185
+ audio: {
186
+ accessibility: 'media',
187
+ controls: { autoplay: 'studio.control/switch', controls: 'studio.control/switch' },
188
+ defaults: { autoplay: false, controls: true },
189
+ ports: [mediaPort('asset'), textPort('transcript')],
190
+ properties: { autoplay: booleanSchema(), controls: booleanSchema() },
191
+ },
192
+ badge: {
193
+ accessibility: 'text',
194
+ controls: { appearance: 'studio.control/select', tone: 'studio.control/select' },
195
+ defaults: { appearance: 'solid', tone: 'neutral' },
196
+ ports: [textPort('label', true)],
197
+ properties: {
198
+ appearance: enumSchema('outline', 'soft', 'solid'),
199
+ tone: enumSchema('error', 'information', 'neutral', 'success', 'warning'),
200
+ },
201
+ },
202
+ callToAction: {
203
+ accessibility: 'interactive',
204
+ controls: { appearance: 'studio.control/select', href: 'studio.control/single-line-text' },
205
+ defaults: { appearance: 'primary', href: '' },
206
+ ports: [textPort('label', true)],
207
+ properties: {
208
+ appearance: enumSchema('primary', 'secondary', 'link'),
209
+ href: stringSchema(2_048),
210
+ },
211
+ },
212
+ callout: {
213
+ accessibility: 'composite',
214
+ controls: { tone: 'studio.control/select' },
215
+ defaults: { tone: 'information' },
216
+ ports: [textPort('title'), richTextPort()],
217
+ properties: { tone: enumSchema('information', 'success', 'warning', 'danger') },
218
+ },
219
+ card: {
220
+ accessibility: 'composite',
221
+ controls: { appearance: 'studio.control/select' },
222
+ defaults: { appearance: 'plain' },
223
+ ports: [mediaPort('media'), textPort('title'), richTextPort('summary')],
224
+ properties: { appearance: enumSchema('plain', 'bordered', 'elevated') },
225
+ slots: [{ accepts: CONTENT_TYPES, id: 'actions', maximum: 5 }],
226
+ },
227
+ chart: {
228
+ accessibility: 'data-display',
229
+ defaults: {},
230
+ ports: [
231
+ {
232
+ authoring: {
233
+ control: CORE_PRODUCTION_CONTROL_IDS.chart,
234
+ profile: 'studio.chart/canonical',
235
+ },
236
+ id: 'chart',
237
+ label: message('port-chart', 'Chart'),
238
+ multiple: false,
239
+ required: true,
240
+ valueType: 'studio.value/chart',
241
+ },
242
+ ],
243
+ },
244
+ code: {
245
+ accessibility: 'text',
246
+ controls: {
247
+ language: 'studio.control/single-line-text',
248
+ 'show-line-numbers': 'studio.control/switch',
249
+ },
250
+ defaults: { language: 'text', 'show-line-numbers': false },
251
+ ports: [sourcePort('studio.source/code')],
252
+ properties: { language: stringSchema(100), 'show-line-numbers': booleanSchema() },
253
+ },
254
+ contentCollection: {
255
+ accessibility: 'data-display',
256
+ controls: { limit: 'studio.control/integer', presentation: 'studio.control/select' },
257
+ defaults: { limit: 12, presentation: 'cards' },
258
+ ports: [resourcePort('items', true)],
259
+ properties: {
260
+ limit: integerSchema(1, 100),
261
+ presentation: enumSchema('cards', 'grid', 'list', 'slideshow'),
262
+ },
263
+ },
264
+ contentReference: {
265
+ accessibility: 'data-display',
266
+ controls: { presentation: 'studio.control/select' },
267
+ defaults: { presentation: 'summary' },
268
+ ports: [resourcePort('item', false)],
269
+ properties: { presentation: enumSchema('full', 'summary', 'title') },
270
+ },
271
+ countdown: {
272
+ accessibility: 'data-display',
273
+ controls: {
274
+ display: 'studio.control/select',
275
+ 'expired-behavior': 'studio.control/select',
276
+ },
277
+ defaults: { display: 'detailed', 'expired-behavior': 'zero' },
278
+ ports: [textPort('target', true), textPort('completion-message')],
279
+ properties: {
280
+ display: enumSchema('compact', 'detailed'),
281
+ 'expired-behavior': enumSchema('hide', 'message', 'zero'),
282
+ },
283
+ },
284
+ cover: {
285
+ accessibility: 'composite',
286
+ controls: { alignment: 'studio.control/select', overlay: 'studio.control/select' },
287
+ defaults: { alignment: 'center', overlay: 'medium' },
288
+ ports: [mediaPort('background')],
289
+ properties: {
290
+ alignment: enumSchema('center', 'end', 'start'),
291
+ overlay: enumSchema('light', 'medium', 'none', 'strong'),
292
+ },
293
+ slots: [{ accepts: CONTENT_TYPES, id: 'content', maximum: 100 }],
294
+ },
295
+ descriptionItem: {
296
+ accessibility: 'text',
297
+ defaults: {},
298
+ ports: [textPort('term', true), richTextPort('description')],
299
+ },
300
+ descriptionList: {
301
+ accessibility: 'data-display',
302
+ defaults: {},
303
+ ports: [textPort('title')],
304
+ slots: [{ accepts: [CORE_PRODUCTION_BLOCK_TYPES.descriptionItem], id: 'items', maximum: 100 }],
305
+ },
306
+ diagram: {
307
+ accessibility: 'data-display',
308
+ controls: { theme: 'studio.control/select' },
309
+ defaults: { theme: 'neutral' },
310
+ ports: [sourcePort('studio.source/mermaid')],
311
+ properties: { theme: enumSchema('dark', 'forest', 'neutral') },
312
+ },
313
+ dialog: {
314
+ accessibility: 'interactive',
315
+ controls: { modal: 'studio.control/switch', presentation: 'studio.control/select' },
316
+ defaults: { modal: true, presentation: 'modal' },
317
+ ports: [textPort('trigger-label', true), textPort('title', true)],
318
+ properties: {
319
+ modal: booleanSchema(),
320
+ presentation: enumSchema('modal', 'offcanvas', 'overlay'),
321
+ },
322
+ slots: [{ accepts: CONTENT_TYPES, id: 'content', maximum: 100 }],
323
+ },
324
+ divider: {
325
+ accessibility: 'structural',
326
+ controls: { style: 'studio.control/select' },
327
+ defaults: { style: 'solid' },
328
+ ports: [textPort('label')],
329
+ properties: { style: enumSchema('dashed', 'dotted', 'solid') },
330
+ },
331
+ drawing: {
332
+ accessibility: 'media',
333
+ defaults: {},
334
+ ports: [
335
+ {
336
+ authoring: {
337
+ control: CORE_PRODUCTION_CONTROL_IDS.drawing,
338
+ profile: 'studio.drawing/canonical',
339
+ },
340
+ id: 'drawing',
341
+ label: message('port-drawing', 'Drawing'),
342
+ multiple: false,
343
+ required: true,
344
+ valueType: 'studio.value/drawing',
345
+ },
346
+ ],
347
+ },
348
+ embed: {
349
+ accessibility: 'media',
350
+ controls: { 'aspect-ratio': 'studio.control/select' },
351
+ defaults: { 'aspect-ratio': '16:9' },
352
+ ports: [resourcePort('resource', false)],
353
+ properties: { 'aspect-ratio': enumSchema('1:1', '4:3', '16:9', '21:9') },
354
+ },
355
+ gallery: {
356
+ accessibility: 'composite',
357
+ controls: {
358
+ autoplay: 'studio.control/switch',
359
+ columns: 'studio.control/integer',
360
+ lightbox: 'studio.control/switch',
361
+ presentation: 'studio.control/select',
362
+ },
363
+ defaults: { autoplay: false, columns: 4, lightbox: false, presentation: 'grid' },
364
+ ports: [mediaPort('items', true)],
365
+ properties: {
366
+ autoplay: booleanSchema(),
367
+ columns: integerSchema(1, 12),
368
+ lightbox: booleanSchema(),
369
+ presentation: enumSchema('grid', 'slideshow'),
370
+ },
371
+ },
372
+ heading: {
373
+ accessibility: 'text',
374
+ controls: { level: 'studio.control/select' },
375
+ defaults: { level: 2 },
376
+ ports: [textPort('text', true)],
377
+ properties: { level: integerSchema(1, 6) },
378
+ },
379
+ icon: {
380
+ accessibility: 'media',
381
+ controls: { decorative: 'studio.control/switch', name: 'studio.control/single-line-text' },
382
+ defaults: { decorative: true, name: 'symbol' },
383
+ ports: [textPort('alternative-text')],
384
+ properties: { decorative: booleanSchema(), name: stringSchema(200) },
385
+ },
386
+ image: {
387
+ accessibility: 'media',
388
+ controls: { fit: 'studio.control/select', loading: 'studio.control/select' },
389
+ defaults: { fit: 'cover', loading: 'lazy' },
390
+ ports: [mediaPort('asset')],
391
+ properties: {
392
+ fit: enumSchema('contain', 'cover', 'fill', 'scale-down'),
393
+ loading: enumSchema('eager', 'lazy'),
394
+ },
395
+ },
396
+ label: {
397
+ accessibility: 'text',
398
+ controls: { tone: 'studio.control/select' },
399
+ defaults: { tone: 'neutral' },
400
+ ports: [textPort('text', true)],
401
+ properties: { tone: enumSchema('error', 'information', 'neutral', 'success', 'warning') },
402
+ },
403
+ math: {
404
+ accessibility: 'text',
405
+ controls: { 'display-mode': 'studio.control/switch' },
406
+ defaults: { 'display-mode': true },
407
+ ports: [sourcePort('studio.source/latex')],
408
+ properties: { 'display-mode': booleanSchema() },
409
+ },
410
+ money: {
411
+ accessibility: 'data-display',
412
+ defaults: {},
413
+ ports: [
414
+ {
415
+ authoring: {
416
+ control: CORE_PRODUCTION_CONTROL_IDS.money,
417
+ profile: 'studio.money/canonical',
418
+ },
419
+ id: 'amount',
420
+ label: message('port-amount', 'Amount'),
421
+ multiple: false,
422
+ required: true,
423
+ valueType: 'money',
424
+ },
425
+ ],
426
+ },
427
+ navigation: {
428
+ accessibility: 'landmark',
429
+ controls: { presentation: 'studio.control/select' },
430
+ defaults: { presentation: 'nav' },
431
+ ports: [textPort('label')],
432
+ properties: {
433
+ presentation: enumSchema('breadcrumbs', 'dotnav', 'dropnav', 'navbar', 'nav', 'pagination', 'subnav', 'thumbnav'),
434
+ },
435
+ slots: [{ accepts: [CORE_PRODUCTION_BLOCK_TYPES.navigationItem], id: 'items', maximum: 100 }],
436
+ },
437
+ navigationItem: {
438
+ accessibility: 'interactive',
439
+ controls: { current: 'studio.control/switch', href: 'studio.control/single-line-text' },
440
+ defaults: { current: false, href: '' },
441
+ ports: [textPort('label', true)],
442
+ properties: { current: booleanSchema(), href: stringSchema(2_048) },
443
+ slots: [{ accepts: [CORE_PRODUCTION_BLOCK_TYPES.navigationItem], id: 'children', maximum: 50 }],
444
+ },
445
+ notice: {
446
+ accessibility: 'composite',
447
+ controls: { dismissible: 'studio.control/switch', tone: 'studio.control/select' },
448
+ defaults: { dismissible: false, tone: 'information' },
449
+ ports: [textPort('title'), richTextPort()],
450
+ properties: {
451
+ dismissible: booleanSchema(),
452
+ tone: enumSchema('comment', 'error', 'information', 'success', 'warning'),
453
+ },
454
+ },
455
+ popover: {
456
+ accessibility: 'interactive',
457
+ controls: {
458
+ 'dismiss-on-blur': 'studio.control/switch',
459
+ placement: 'studio.control/select',
460
+ presentation: 'studio.control/select',
461
+ },
462
+ defaults: { 'dismiss-on-blur': true, placement: 'auto', presentation: 'popover' },
463
+ ports: [textPort('trigger-label', true), textPort('title')],
464
+ properties: {
465
+ 'dismiss-on-blur': booleanSchema(),
466
+ placement: enumSchema('auto', 'bottom', 'left', 'right', 'top'),
467
+ presentation: enumSchema('dropbar', 'dropdown', 'popover', 'tooltip'),
468
+ },
469
+ slots: [{ accepts: CONTENT_TYPES, id: 'content', maximum: 100 }],
470
+ },
471
+ progress: {
472
+ accessibility: 'data-display',
473
+ controls: { maximum: 'studio.control/integer' },
474
+ defaults: { maximum: 100 },
475
+ ports: [textPort('label'), numberPort('value', true)],
476
+ properties: { maximum: integerSchema(1, 1_000_000) },
477
+ },
478
+ richText: {
479
+ accessibility: 'text',
480
+ defaults: {},
481
+ ports: [richTextPort()],
482
+ },
483
+ search: {
484
+ accessibility: 'interactive',
485
+ controls: {
486
+ action: 'studio.control/single-line-text',
487
+ 'query-parameter': 'studio.control/single-line-text',
488
+ },
489
+ defaults: { action: '', 'query-parameter': 'q' },
490
+ ports: [textPort('label'), textPort('placeholder')],
491
+ properties: { action: stringSchema(2_048), 'query-parameter': stringSchema(100) },
492
+ },
493
+ spinner: {
494
+ accessibility: 'data-display',
495
+ controls: { active: 'studio.control/switch', size: 'studio.control/select' },
496
+ defaults: { active: true, size: 'medium' },
497
+ ports: [textPort('label')],
498
+ properties: { active: booleanSchema(), size: enumSchema('large', 'medium', 'small') },
499
+ },
500
+ tab: {
501
+ accessibility: 'composite',
502
+ defaults: {},
503
+ ports: [textPort('title', true)],
504
+ slots: [{ accepts: CONTENT_TYPES, id: 'content', maximum: 100 }],
505
+ },
506
+ tabs: {
507
+ accessibility: 'composite',
508
+ controls: { activation: 'studio.control/select' },
509
+ defaults: { activation: 'automatic' },
510
+ properties: { activation: enumSchema('automatic', 'manual') },
511
+ slots: [{ accepts: [CORE_PRODUCTION_BLOCK_TYPES.tab], id: 'items', maximum: 30 }],
512
+ },
513
+ table: {
514
+ accessibility: 'data-display',
515
+ defaults: {},
516
+ ports: [
517
+ {
518
+ authoring: {
519
+ control: CORE_PRODUCTION_CONTROL_IDS.table,
520
+ profile: 'studio.table/canonical',
521
+ },
522
+ id: 'table',
523
+ label: message('port-table', 'Table'),
524
+ multiple: false,
525
+ required: true,
526
+ valueType: 'studio.value/table',
527
+ },
528
+ ],
529
+ },
530
+ video: {
531
+ accessibility: 'media',
532
+ controls: {
533
+ autoplay: 'studio.control/switch',
534
+ controls: 'studio.control/switch',
535
+ muted: 'studio.control/switch',
536
+ },
537
+ defaults: { autoplay: false, controls: true, muted: false },
538
+ ports: [mediaPort('asset'), mediaPort('poster'), textPort('captions')],
539
+ properties: { autoplay: booleanSchema(), controls: booleanSchema(), muted: booleanSchema() },
540
+ },
541
+ });
542
+ /** Build the entire canonical catalog with explicit allowlists and no host imports. */
543
+ export function createCoreProductionBlockDefinitions() {
544
+ const layouts = createCoreLayoutBlockDefinitions({
545
+ acceptedChildTypes: CONTENT_TYPES,
546
+ rendererRequirements: WEB_RENDERERS,
547
+ }).map(addPresentationCapability);
548
+ const content = Object.keys(SPECS).map((name) => createDefinition(name, SPECS[name]));
549
+ return [...layouts, ...content];
550
+ }
551
+ /** Minimal schema-valid persisted properties for a newly inserted production node. */
552
+ export function coreProductionInitialProperties(type) {
553
+ if (isCoreLayoutBlockType(type)) {
554
+ return coreLayoutInitialProperties(type);
555
+ }
556
+ const name = productionName(type);
557
+ return cloneContractValue(SPECS[name].defaults);
558
+ }
559
+ export function isCoreProductionBlockType(type) {
560
+ return ALL_TYPES.includes(type);
561
+ }
562
+ /** Create the ten deterministic, schema-valid starter patterns. */
563
+ export function createCoreProductionPatterns() {
564
+ return [
565
+ pattern('article', [
566
+ node('article', 'stack', {}, [
567
+ node('article-title', 'heading', { text: 'Article title' }),
568
+ node('article-body', 'richText', { content: richText('Start writing…') }),
569
+ ]),
570
+ ]),
571
+ pattern('collection-index', [
572
+ node('collection-index', 'section', {}, [
573
+ node('collection-heading', 'heading', { text: 'Latest content' }),
574
+ node('collection', 'contentCollection', {}, undefined, {
575
+ items: query('studio.query/content'),
576
+ }),
577
+ ]),
578
+ ]),
579
+ pattern('document-header', [
580
+ node('document-header', 'columns', {}, [
581
+ node('document-logo', 'image'),
582
+ node('document-title', 'heading', { text: 'Document title' }),
583
+ ]),
584
+ ]),
585
+ pattern('faq', [
586
+ node('faq', 'accordion', {}, [
587
+ node('faq-item', 'accordionItem', { title: 'Question' }, [
588
+ node('faq-answer', 'richText', { content: richText('Answer') }),
589
+ ]),
590
+ ]),
591
+ ]),
592
+ pattern('feature-grid', [
593
+ node('features', 'grid', {}, [
594
+ node('feature-one', 'card', { title: 'Feature one' }),
595
+ node('feature-two', 'card', { title: 'Feature two' }),
596
+ node('feature-three', 'card', { title: 'Feature three' }),
597
+ ]),
598
+ ]),
599
+ pattern('hero', [
600
+ node('hero', 'section', {}, [
601
+ node('hero-stack', 'stack', {}, [
602
+ node('hero-title', 'heading', { text: 'Build something meaningful' }),
603
+ node('hero-copy', 'richText', { content: richText('A portable Studio page.') }),
604
+ node('hero-action', 'callToAction', { label: 'Get started' }),
605
+ ]),
606
+ ]),
607
+ ]),
608
+ pattern('media-gallery', [node('media-gallery', 'gallery')]),
609
+ pattern('pricing', [
610
+ node('pricing', 'card', { title: 'Plan' }, [
611
+ node('price', 'money', { amount: { amount: '0.00', currency: 'USD' } }),
612
+ node('price-action', 'callToAction', { label: 'Choose plan' }),
613
+ ]),
614
+ ]),
615
+ pattern('product', [
616
+ node('product', 'columns', {}, [
617
+ node('product-media', 'gallery'),
618
+ node('product-copy', 'stack', {}, [
619
+ node('product-title', 'heading', { text: 'Product' }),
620
+ node('product-description', 'richText', { content: richText('Product description') }),
621
+ node('product-price', 'money', {}, undefined, {
622
+ amount: resource('catalog/product-price', 'studio.resource/money'),
623
+ }),
624
+ ]),
625
+ ]),
626
+ ]),
627
+ pattern('tabbed-content', [
628
+ node('tabbed-content', 'tabs', {}, [
629
+ node('tab-one', 'tab', { title: 'First' }, [
630
+ node('tab-one-copy', 'richText', { content: richText('First panel') }),
631
+ ]),
632
+ node('tab-two', 'tab', { title: 'Second' }, [
633
+ node('tab-two-copy', 'richText', { content: richText('Second panel') }),
634
+ ]),
635
+ ]),
636
+ ]),
637
+ ];
638
+ }
639
+ function createDefinition(name, spec) {
640
+ const type = CORE_PRODUCTION_BLOCK_TYPES[name];
641
+ return {
642
+ accessibility: {
643
+ accessibleName: spec.accessibility === 'decorative' || spec.accessibility === 'structural'
644
+ ? 'not-applicable'
645
+ : 'derived',
646
+ category: spec.accessibility,
647
+ keyboard: message('block-keyboard', 'Use Studio controls to edit and reorder this block.'),
648
+ outputChecks: ['studio.check/accessible-name', 'studio.check/reflow'],
649
+ reducedMotion: ['audio', 'gallery', 'video'].includes(name)
650
+ ? 'disable-motion'
651
+ : 'not-applicable',
652
+ },
653
+ category: `studio.category/${categoryFor(spec.accessibility)}`,
654
+ contractVersion: STUDIO_CONTRACT_VERSION,
655
+ editingModes: ['blueprint', 'content'],
656
+ icon: { kind: 'symbol', value: kebab(name) },
657
+ kind: 'block-definition',
658
+ label: message(`block-${kebab(name)}`, title(name)),
659
+ owner: OWNER,
660
+ ports: cloneContractValue([...(spec.ports ?? [])]),
661
+ propertyControls: [
662
+ ...Object.entries(spec.controls ?? {}).map(([property, control]) => ({
663
+ control,
664
+ property,
665
+ })),
666
+ { control: CORE_PRODUCTION_CONTROL_IDS.presentation, property: 'design' },
667
+ ],
668
+ propertySchema: {
669
+ additionalProperties: false,
670
+ properties: cloneContractValue({
671
+ ...(spec.properties ?? {}),
672
+ design: PRESENTATION_PROPERTY_SCHEMA,
673
+ }),
674
+ ...(spec.required === undefined ? {} : { required: [...spec.required] }),
675
+ type: 'object',
676
+ },
677
+ rendererRequirements: cloneContractValue([...WEB_RENDERERS]),
678
+ revision: `production-${kebab(name)}-r1`,
679
+ slots: (spec.slots ?? []).map((slot) => ({
680
+ accepts: { types: cloneContractValue([...slot.accepts]) },
681
+ id: slot.id,
682
+ label: message(`slot-${slot.id}`, title(slot.id)),
683
+ maximum: slot.maximum ?? 100,
684
+ minimum: slot.minimum ?? 0,
685
+ ordered: true,
686
+ })),
687
+ themeControls: [],
688
+ type,
689
+ version: VERSION,
690
+ };
691
+ }
692
+ function addPresentationCapability(definition) {
693
+ const properties = definition.propertySchema.properties;
694
+ if (!isJsonObject(properties)) {
695
+ throw new TypeError(`${definition.type} property schema must declare an object property map.`);
696
+ }
697
+ return {
698
+ ...definition,
699
+ propertyControls: [
700
+ ...(definition.propertyControls ?? []),
701
+ { control: CORE_PRODUCTION_CONTROL_IDS.presentation, property: 'design' },
702
+ ],
703
+ propertySchema: {
704
+ ...definition.propertySchema,
705
+ properties: cloneContractValue({ ...properties, design: PRESENTATION_PROPERTY_SCHEMA }),
706
+ },
707
+ };
708
+ }
709
+ function presentationPropertySchema() {
710
+ const schema = cloneContractValue(studioPresentationSchema);
711
+ delete schema.$id;
712
+ delete schema.$schema;
713
+ delete schema.title;
714
+ return schema;
715
+ }
716
+ function isJsonObject(value) {
717
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
718
+ }
719
+ function pattern(id, roots) {
720
+ const definitions = new Map(createCoreProductionBlockDefinitions().map((item) => [item.type, item]));
721
+ const used = new Set();
722
+ const visit = (current) => {
723
+ used.add(current.type);
724
+ Object.values(current.slots).flat().forEach(visit);
725
+ };
726
+ roots.forEach(visit);
727
+ return {
728
+ blockDependencies: [...used].sort().map((type) => {
729
+ const definition = definitions.get(type);
730
+ if (definition === undefined)
731
+ throw new Error(`Pattern ${id} uses unknown block ${type}.`);
732
+ return { revision: definition.revision, type, version: definition.version };
733
+ }),
734
+ contractVersion: STUDIO_CONTRACT_VERSION,
735
+ id: `studio.pattern/${id}`,
736
+ kind: 'pattern',
737
+ label: message(`pattern-${id}`, title(id)),
738
+ owner: OWNER,
739
+ revision: `production-pattern-${id}-r1`,
740
+ roots,
741
+ version: VERSION,
742
+ };
743
+ }
744
+ function node(id, name, staticBindings = {}, children, dynamicBindings = {}) {
745
+ const type = CORE_PRODUCTION_BLOCK_TYPES[name];
746
+ const slot = name === 'section' ||
747
+ name === 'accordionItem' ||
748
+ name === 'dialog' ||
749
+ name === 'popover' ||
750
+ name === 'tab'
751
+ ? 'content'
752
+ : name === 'card'
753
+ ? 'actions'
754
+ : 'items';
755
+ const bindings = {};
756
+ for (const [port, value] of Object.entries(staticBindings)) {
757
+ bindings[port] = binding({ kind: 'static-value', value });
758
+ }
759
+ for (const [port, source] of Object.entries(dynamicBindings)) {
760
+ bindings[port] = binding(source);
761
+ }
762
+ const result = {
763
+ authoring: {
764
+ mode: isCoreLayoutBlockType(type) || children !== undefined ? 'structural' : 'content',
765
+ },
766
+ bindings,
767
+ id,
768
+ properties: coreProductionInitialProperties(type),
769
+ slots: children === undefined ? {} : { [slot]: children },
770
+ type,
771
+ version: VERSION,
772
+ };
773
+ if (name === 'grid') {
774
+ result.responsive = { columns: { expanded: 4, medium: 2 } };
775
+ }
776
+ return result;
777
+ }
778
+ function binding(source) {
779
+ return { onError: 'error', onNull: 'empty', source, transforms: [] };
780
+ }
781
+ function query(queryName) {
782
+ return { kind: 'query-reference', parameters: {}, query: queryName, version: VERSION };
783
+ }
784
+ function resource(id, resourceType) {
785
+ return { id, kind: 'resource-reference', resourceType };
786
+ }
787
+ function richText(text) {
788
+ return { content: [{ content: [{ text, type: 'text' }], type: 'paragraph' }], type: 'doc' };
789
+ }
790
+ function productionName(type) {
791
+ const entry = Object.entries(CORE_PRODUCTION_BLOCK_TYPES).find(([, candidate]) => candidate === type);
792
+ if (entry === undefined || isCoreLayoutBlockType(type))
793
+ throw new TypeError(`Unsupported production block ${type}.`);
794
+ return entry[0];
795
+ }
796
+ function message(id, defaultMessage) {
797
+ return { defaultMessage, key: `studio.blocks/${id}` };
798
+ }
799
+ function title(value) {
800
+ return value
801
+ .replace(/([a-z])([A-Z])/gu, '$1 $2')
802
+ .replaceAll('-', ' ')
803
+ .replace(/^./u, (character) => character.toUpperCase());
804
+ }
805
+ function kebab(value) {
806
+ return value.replace(/([a-z])([A-Z])/gu, '$1-$2').toLowerCase();
807
+ }
808
+ function categoryFor(category) {
809
+ return category === 'structural' || category === 'landmark' ? 'layout' : category;
810
+ }
811
+ //# sourceMappingURL=production.js.map