@wp-typia/project-tools 0.16.8 → 0.16.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 (50) hide show
  1. package/README.md +14 -4
  2. package/dist/runtime/block-generator-service.d.ts +5 -1
  3. package/dist/runtime/block-generator-service.js +7 -3
  4. package/dist/runtime/built-in-block-artifacts.js +388 -572
  5. package/dist/runtime/built-in-block-code-artifacts.js +96 -46
  6. package/dist/runtime/built-in-block-code-templates.d.ts +36 -0
  7. package/dist/runtime/built-in-block-code-templates.js +2234 -0
  8. package/dist/runtime/cli-add-block.d.ts +2 -1
  9. package/dist/runtime/cli-add-block.js +163 -25
  10. package/dist/runtime/cli-add-shared.d.ts +7 -0
  11. package/dist/runtime/cli-add-shared.js +4 -6
  12. package/dist/runtime/cli-add-workspace.js +56 -17
  13. package/dist/runtime/cli-core.d.ts +4 -0
  14. package/dist/runtime/cli-core.js +3 -0
  15. package/dist/runtime/cli-diagnostics.d.ts +58 -0
  16. package/dist/runtime/cli-diagnostics.js +101 -0
  17. package/dist/runtime/cli-doctor.d.ts +2 -1
  18. package/dist/runtime/cli-doctor.js +16 -5
  19. package/dist/runtime/cli-help.js +4 -4
  20. package/dist/runtime/cli-scaffold.d.ts +5 -1
  21. package/dist/runtime/cli-scaffold.js +138 -111
  22. package/dist/runtime/external-layer-selection.d.ts +14 -0
  23. package/dist/runtime/external-layer-selection.js +35 -0
  24. package/dist/runtime/index.d.ts +2 -2
  25. package/dist/runtime/index.js +1 -1
  26. package/dist/runtime/migration-render.d.ts +23 -1
  27. package/dist/runtime/migration-render.js +58 -10
  28. package/dist/runtime/migration-ui-capability.js +17 -8
  29. package/dist/runtime/migration-utils.d.ts +7 -6
  30. package/dist/runtime/migration-utils.js +76 -73
  31. package/dist/runtime/migrations.js +2 -2
  32. package/dist/runtime/object-utils.d.ts +8 -1
  33. package/dist/runtime/object-utils.js +21 -1
  34. package/dist/runtime/scaffold-apply-utils.d.ts +14 -2
  35. package/dist/runtime/scaffold-apply-utils.js +19 -6
  36. package/dist/runtime/scaffold-repository-reference.d.ts +22 -0
  37. package/dist/runtime/scaffold-repository-reference.js +119 -0
  38. package/dist/runtime/scaffold.d.ts +5 -1
  39. package/dist/runtime/scaffold.js +15 -37
  40. package/dist/runtime/template-layers.d.ts +6 -0
  41. package/dist/runtime/template-layers.js +20 -7
  42. package/dist/runtime/template-render.d.ts +13 -2
  43. package/dist/runtime/template-render.js +102 -71
  44. package/dist/runtime/template-source.d.ts +6 -5
  45. package/dist/runtime/template-source.js +284 -217
  46. package/package.json +8 -3
  47. package/templates/_shared/base/src/validator-toolkit.ts.mustache +2 -2
  48. package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +61 -16
  49. package/templates/_shared/migration-ui/common/src/migrations/helpers.ts +19 -47
  50. package/templates/_shared/migration-ui/common/src/migrations/index.ts +40 -11
@@ -63,16 +63,89 @@ function createBlockJsonAttribute({ defaultValue, enumValues = null, selector, s
63
63
  }
64
64
  return attribute;
65
65
  }
66
- function createAttributeDefinition({ blockJson, description, manifest, name, optional, typeExpression, }) {
66
+ function describe(...lines) {
67
67
  return {
68
- blockJson,
68
+ lines,
69
+ };
70
+ }
71
+ function defineAttribute({ blockJsonDefaultValue, constraints, defaultValue, description, enumValues = null, kind, manifestDefaultValue, name, optional, selector = null, source = null, sourceType, typeExpression, }) {
72
+ const resolvedBlockJsonDefaultValue = blockJsonDefaultValue !== undefined ? blockJsonDefaultValue : defaultValue;
73
+ const resolvedManifestDefaultValue = manifestDefaultValue !== undefined ? manifestDefaultValue : defaultValue;
74
+ return {
75
+ blockJson: {
76
+ defaultValue: resolvedBlockJsonDefaultValue,
77
+ enumValues,
78
+ ...(selector ? { selector } : {}),
79
+ ...(source ? { source } : {}),
80
+ type: sourceType,
81
+ },
69
82
  description,
70
- manifest,
83
+ manifest: {
84
+ constraints,
85
+ defaultValue: resolvedManifestDefaultValue,
86
+ enumValues,
87
+ kind,
88
+ required: !optional,
89
+ selector,
90
+ source,
91
+ sourceType,
92
+ },
71
93
  name,
72
94
  optional,
73
95
  typeExpression,
74
96
  };
75
97
  }
98
+ function defineStringAttribute(spec) {
99
+ return defineAttribute({
100
+ ...spec,
101
+ kind: "string",
102
+ sourceType: "string",
103
+ });
104
+ }
105
+ function defineBooleanAttribute(spec) {
106
+ return defineAttribute({
107
+ ...spec,
108
+ kind: "boolean",
109
+ sourceType: "boolean",
110
+ });
111
+ }
112
+ function defineNumberAttribute(spec) {
113
+ return defineAttribute({
114
+ ...spec,
115
+ kind: "number",
116
+ sourceType: "number",
117
+ });
118
+ }
119
+ function resolveBuiltInAttributeValue(value, context) {
120
+ if (typeof value === "function") {
121
+ return value(context);
122
+ }
123
+ return value;
124
+ }
125
+ function buildAttributesFromSpecs(specs, context) {
126
+ return specs.map((spec) => {
127
+ const resolvedSpec = {
128
+ blockJsonDefaultValue: resolveBuiltInAttributeValue(spec.blockJsonDefaultValue, context),
129
+ constraints: resolveBuiltInAttributeValue(spec.constraints, context),
130
+ defaultValue: resolveBuiltInAttributeValue(spec.defaultValue, context),
131
+ description: resolveBuiltInAttributeValue(spec.description, context),
132
+ enumValues: resolveBuiltInAttributeValue(spec.enumValues, context),
133
+ manifestDefaultValue: resolveBuiltInAttributeValue(spec.manifestDefaultValue, context),
134
+ name: spec.name,
135
+ optional: spec.optional,
136
+ selector: resolveBuiltInAttributeValue(spec.selector, context),
137
+ source: resolveBuiltInAttributeValue(spec.source, context),
138
+ typeExpression: resolveBuiltInAttributeValue(spec.typeExpression, context) ?? "unknown",
139
+ };
140
+ if (spec.attributeType === "boolean") {
141
+ return defineBooleanAttribute(resolvedSpec);
142
+ }
143
+ if (spec.attributeType === "number") {
144
+ return defineNumberAttribute(resolvedSpec);
145
+ }
146
+ return defineStringAttribute(resolvedSpec);
147
+ });
148
+ }
76
149
  function buildManifestDocument(sourceType, attributes) {
77
150
  return {
78
151
  attributes: Object.fromEntries(attributes.map((attribute) => [
@@ -132,584 +205,327 @@ function emitTypesModule({ preambleLines, interfaces, typeAliases, }) {
132
205
  function stringifyBlockJsonDocument(document) {
133
206
  return `${JSON.stringify(document, null, "\t")}\n`;
134
207
  }
208
+ const BASIC_ATTRIBUTE_SPECS = [
209
+ {
210
+ attributeType: "string",
211
+ constraints: {
212
+ maxLength: 1000,
213
+ },
214
+ defaultValue: "",
215
+ description: describe("Main block content"),
216
+ name: "content",
217
+ optional: false,
218
+ typeExpression: 'string & tags.MaxLength<1000> & tags.Default<"">',
219
+ },
220
+ {
221
+ attributeType: "string",
222
+ defaultValue: "left",
223
+ description: describe("Alignment"),
224
+ enumValues: [...BASIC_ALIGNMENT_VALUES],
225
+ name: "alignment",
226
+ optional: true,
227
+ typeExpression: 'TextAlignment & tags.Default<"left">',
228
+ },
229
+ {
230
+ attributeType: "boolean",
231
+ defaultValue: true,
232
+ description: describe("Visibility toggle"),
233
+ name: "isVisible",
234
+ optional: true,
235
+ typeExpression: "boolean & tags.Default<true>",
236
+ },
237
+ {
238
+ attributeType: "string",
239
+ constraints: {
240
+ maxLength: 100,
241
+ },
242
+ defaultValue: "",
243
+ description: describe("Custom CSS class"),
244
+ name: "className",
245
+ optional: true,
246
+ typeExpression: 'string & tags.MaxLength<100> & tags.Default<"">',
247
+ },
248
+ {
249
+ attributeType: "string",
250
+ constraints: {
251
+ format: "uuid",
252
+ },
253
+ description: describe("Generated runtime ID"),
254
+ name: "id",
255
+ optional: true,
256
+ typeExpression: 'string & tags.Format<"uuid">',
257
+ },
258
+ {
259
+ attributeType: "number",
260
+ constraints: {
261
+ typeTag: "uint32",
262
+ },
263
+ defaultValue: 1,
264
+ description: describe("Block version for migrations"),
265
+ name: "schemaVersion",
266
+ optional: true,
267
+ typeExpression: 'number & tags.Type<"uint32"> & tags.Default<1>',
268
+ },
269
+ ];
270
+ const INTERACTIVITY_ATTRIBUTE_SPECS = [
271
+ {
272
+ attributeType: "string",
273
+ constraints: {
274
+ maxLength: 1000,
275
+ },
276
+ defaultValue: "",
277
+ name: "content",
278
+ optional: false,
279
+ selector: (variables) => `.${variables.cssClassName}__content`,
280
+ source: "html",
281
+ typeExpression: 'string & tags.MaxLength<1000> & tags.Default<"">',
282
+ },
283
+ {
284
+ attributeType: "string",
285
+ defaultValue: "left",
286
+ enumValues: [...ALIGNMENT_VALUES],
287
+ name: "alignment",
288
+ optional: true,
289
+ typeExpression: 'TextAlignment & tags.Default<"left">',
290
+ },
291
+ {
292
+ attributeType: "boolean",
293
+ defaultValue: true,
294
+ name: "isVisible",
295
+ optional: true,
296
+ typeExpression: "boolean & tags.Default<true>",
297
+ },
298
+ {
299
+ attributeType: "string",
300
+ defaultValue: "click",
301
+ enumValues: [...INTERACTIVE_MODE_VALUES],
302
+ name: "interactiveMode",
303
+ optional: true,
304
+ typeExpression: '("click" | "hover") & tags.Default<"click">',
305
+ },
306
+ {
307
+ attributeType: "string",
308
+ defaultValue: "none",
309
+ enumValues: [...ANIMATION_VALUES],
310
+ name: "animation",
311
+ optional: true,
312
+ typeExpression: '("none" | "bounce" | "pulse" | "shake" | "flip") & tags.Default<"none">',
313
+ },
314
+ {
315
+ attributeType: "number",
316
+ constraints: {
317
+ minimum: 0,
318
+ typeTag: "uint32",
319
+ },
320
+ defaultValue: 0,
321
+ name: "clickCount",
322
+ optional: true,
323
+ typeExpression: 'number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<0>',
324
+ },
325
+ {
326
+ attributeType: "boolean",
327
+ defaultValue: false,
328
+ name: "isAnimating",
329
+ optional: true,
330
+ typeExpression: "boolean & tags.Default<false>",
331
+ },
332
+ {
333
+ attributeType: "boolean",
334
+ defaultValue: true,
335
+ name: "showCounter",
336
+ optional: true,
337
+ typeExpression: "boolean & tags.Default<true>",
338
+ },
339
+ {
340
+ attributeType: "number",
341
+ constraints: {
342
+ minimum: 0,
343
+ typeTag: "uint32",
344
+ },
345
+ defaultValue: 10,
346
+ name: "maxClicks",
347
+ optional: true,
348
+ typeExpression: 'number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<10>',
349
+ },
350
+ ];
351
+ const PERSISTENCE_ATTRIBUTE_SPECS = [
352
+ {
353
+ attributeType: "string",
354
+ constraints: {
355
+ maxLength: 250,
356
+ minLength: 1,
357
+ },
358
+ defaultValue: (variables) => `${variables.title} persistence block`,
359
+ name: "content",
360
+ optional: false,
361
+ selector: (variables) => `.${variables.cssClassName}__content`,
362
+ source: "html",
363
+ typeExpression: (variables) => `string & tags.MinLength<1> & tags.MaxLength<250> & tags.Default<${quote(`${variables.title} persistence block`)}>`,
364
+ },
365
+ {
366
+ attributeType: "string",
367
+ defaultValue: "left",
368
+ enumValues: [...ALIGNMENT_VALUES],
369
+ name: "alignment",
370
+ optional: true,
371
+ typeExpression: 'TextAlignment & tags.Default<"left">',
372
+ },
373
+ {
374
+ attributeType: "boolean",
375
+ defaultValue: true,
376
+ name: "isVisible",
377
+ optional: true,
378
+ typeExpression: "boolean & tags.Default<true>",
379
+ },
380
+ {
381
+ attributeType: "boolean",
382
+ defaultValue: true,
383
+ name: "showCount",
384
+ optional: true,
385
+ typeExpression: "boolean & tags.Default<true>",
386
+ },
387
+ {
388
+ attributeType: "string",
389
+ constraints: {
390
+ maxLength: 40,
391
+ minLength: 1,
392
+ },
393
+ defaultValue: "Persist Count",
394
+ name: "buttonLabel",
395
+ optional: true,
396
+ typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<40> & tags.Default<"Persist Count">',
397
+ },
398
+ {
399
+ attributeType: "string",
400
+ blockJsonDefaultValue: "",
401
+ constraints: {
402
+ maxLength: 100,
403
+ minLength: 1,
404
+ },
405
+ manifestDefaultValue: "primary",
406
+ name: "resourceKey",
407
+ optional: true,
408
+ typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<100> & tags.Default<"primary">',
409
+ },
410
+ ];
411
+ const COMPOUND_PARENT_BASE_ATTRIBUTE_SPECS = [
412
+ {
413
+ attributeType: "string",
414
+ constraints: {
415
+ maxLength: 80,
416
+ minLength: 1,
417
+ },
418
+ defaultValue: (variables) => variables.title,
419
+ name: "heading",
420
+ optional: false,
421
+ selector: (variables) => `.${variables.cssClassName}__heading`,
422
+ source: "html",
423
+ typeExpression: (variables) => `string & tags.MinLength<1> & tags.MaxLength<80> & tags.Default<${quote(variables.title)}>`,
424
+ },
425
+ {
426
+ attributeType: "string",
427
+ constraints: {
428
+ maxLength: 180,
429
+ minLength: 1,
430
+ },
431
+ defaultValue: "Add and reorder internal items inside this compound block.",
432
+ name: "intro",
433
+ optional: true,
434
+ selector: (variables) => `.${variables.cssClassName}__intro`,
435
+ source: "html",
436
+ typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<180> & tags.Default<"Add and reorder internal items inside this compound block.">',
437
+ },
438
+ {
439
+ attributeType: "boolean",
440
+ defaultValue: true,
441
+ name: "showDividers",
442
+ optional: true,
443
+ typeExpression: "boolean & tags.Default<true>",
444
+ },
445
+ ];
446
+ const COMPOUND_PARENT_PERSISTENCE_ATTRIBUTE_SPECS = [
447
+ {
448
+ attributeType: "boolean",
449
+ defaultValue: true,
450
+ name: "showCount",
451
+ optional: true,
452
+ typeExpression: "boolean & tags.Default<true>",
453
+ },
454
+ {
455
+ attributeType: "string",
456
+ constraints: {
457
+ maxLength: 40,
458
+ minLength: 1,
459
+ },
460
+ defaultValue: "Persist Count",
461
+ name: "buttonLabel",
462
+ optional: true,
463
+ typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<40> & tags.Default<"Persist Count">',
464
+ },
465
+ {
466
+ attributeType: "string",
467
+ blockJsonDefaultValue: "",
468
+ constraints: {
469
+ maxLength: 100,
470
+ minLength: 1,
471
+ },
472
+ manifestDefaultValue: "primary",
473
+ name: "resourceKey",
474
+ optional: true,
475
+ typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<100> & tags.Default<"primary">',
476
+ },
477
+ ];
478
+ const COMPOUND_CHILD_ATTRIBUTE_SPECS = [
479
+ {
480
+ attributeType: "string",
481
+ constraints: {
482
+ maxLength: 80,
483
+ minLength: 1,
484
+ },
485
+ defaultValue: ({ childTitle }) => childTitle,
486
+ name: "title",
487
+ optional: false,
488
+ selector: ({ childCssClassName }) => childCssClassName ? `.${childCssClassName}__title` : null,
489
+ source: ({ childCssClassName }) => childCssClassName ? "html" : null,
490
+ typeExpression: ({ childTitle }) => `string & tags.MinLength<1> & tags.MaxLength<80> & tags.Default<${quote(childTitle)}>`,
491
+ },
492
+ {
493
+ attributeType: "string",
494
+ constraints: {
495
+ maxLength: 280,
496
+ minLength: 1,
497
+ },
498
+ defaultValue: ({ bodyPlaceholder }) => bodyPlaceholder,
499
+ name: "body",
500
+ optional: false,
501
+ selector: ({ childCssClassName }) => childCssClassName ? `.${childCssClassName}__body` : null,
502
+ source: ({ childCssClassName }) => childCssClassName ? "html" : null,
503
+ typeExpression: ({ bodyPlaceholder }) => `string & tags.MinLength<1> & tags.MaxLength<280> & tags.Default<${quote(bodyPlaceholder)}>`,
504
+ },
505
+ ];
135
506
  function buildBasicAttributes() {
136
- return [
137
- createAttributeDefinition({
138
- blockJson: {
139
- defaultValue: "",
140
- type: "string",
141
- },
142
- description: {
143
- lines: ["Main block content"],
144
- },
145
- manifest: {
146
- constraints: {
147
- maxLength: 1000,
148
- },
149
- defaultValue: "",
150
- kind: "string",
151
- required: true,
152
- sourceType: "string",
153
- },
154
- name: "content",
155
- optional: false,
156
- typeExpression: 'string & tags.MaxLength<1000> & tags.Default<"">',
157
- }),
158
- createAttributeDefinition({
159
- blockJson: {
160
- defaultValue: "left",
161
- enumValues: [...BASIC_ALIGNMENT_VALUES],
162
- type: "string",
163
- },
164
- description: {
165
- lines: ["Alignment"],
166
- },
167
- manifest: {
168
- defaultValue: "left",
169
- enumValues: [...BASIC_ALIGNMENT_VALUES],
170
- kind: "string",
171
- required: false,
172
- sourceType: "string",
173
- },
174
- name: "alignment",
175
- optional: true,
176
- typeExpression: 'TextAlignment & tags.Default<"left">',
177
- }),
178
- createAttributeDefinition({
179
- blockJson: {
180
- defaultValue: true,
181
- type: "boolean",
182
- },
183
- description: {
184
- lines: ["Visibility toggle"],
185
- },
186
- manifest: {
187
- defaultValue: true,
188
- kind: "boolean",
189
- required: false,
190
- sourceType: "boolean",
191
- },
192
- name: "isVisible",
193
- optional: true,
194
- typeExpression: "boolean & tags.Default<true>",
195
- }),
196
- createAttributeDefinition({
197
- blockJson: {
198
- defaultValue: "",
199
- type: "string",
200
- },
201
- description: {
202
- lines: ["Custom CSS class"],
203
- },
204
- manifest: {
205
- constraints: {
206
- maxLength: 100,
207
- },
208
- defaultValue: "",
209
- kind: "string",
210
- required: false,
211
- sourceType: "string",
212
- },
213
- name: "className",
214
- optional: true,
215
- typeExpression: 'string & tags.MaxLength<100> & tags.Default<"">',
216
- }),
217
- createAttributeDefinition({
218
- blockJson: {
219
- type: "string",
220
- },
221
- description: {
222
- lines: ["Generated runtime ID"],
223
- },
224
- manifest: {
225
- constraints: {
226
- format: "uuid",
227
- },
228
- kind: "string",
229
- required: false,
230
- sourceType: "string",
231
- },
232
- name: "id",
233
- optional: true,
234
- typeExpression: 'string & tags.Format<"uuid">',
235
- }),
236
- createAttributeDefinition({
237
- blockJson: {
238
- defaultValue: 1,
239
- type: "number",
240
- },
241
- description: {
242
- lines: ["Block version for migrations"],
243
- },
244
- manifest: {
245
- constraints: {
246
- typeTag: "uint32",
247
- },
248
- defaultValue: 1,
249
- kind: "number",
250
- required: false,
251
- sourceType: "number",
252
- },
253
- name: "schemaVersion",
254
- optional: true,
255
- typeExpression: 'number & tags.Type<"uint32"> & tags.Default<1>',
256
- }),
257
- ];
507
+ return buildAttributesFromSpecs(BASIC_ATTRIBUTE_SPECS, undefined);
258
508
  }
259
509
  function buildInteractivityAttributes(variables) {
260
- return [
261
- createAttributeDefinition({
262
- blockJson: {
263
- defaultValue: "",
264
- selector: `.${variables.cssClassName}__content`,
265
- source: "html",
266
- type: "string",
267
- },
268
- manifest: {
269
- constraints: {
270
- maxLength: 1000,
271
- },
272
- defaultValue: "",
273
- kind: "string",
274
- required: true,
275
- selector: `.${variables.cssClassName}__content`,
276
- source: "html",
277
- sourceType: "string",
278
- },
279
- name: "content",
280
- optional: false,
281
- typeExpression: 'string & tags.MaxLength<1000> & tags.Default<"">',
282
- }),
283
- createAttributeDefinition({
284
- blockJson: {
285
- defaultValue: "left",
286
- enumValues: [...ALIGNMENT_VALUES],
287
- type: "string",
288
- },
289
- manifest: {
290
- defaultValue: "left",
291
- enumValues: [...ALIGNMENT_VALUES],
292
- kind: "string",
293
- required: false,
294
- sourceType: "string",
295
- },
296
- name: "alignment",
297
- optional: true,
298
- typeExpression: 'TextAlignment & tags.Default<"left">',
299
- }),
300
- createAttributeDefinition({
301
- blockJson: {
302
- defaultValue: true,
303
- type: "boolean",
304
- },
305
- manifest: {
306
- defaultValue: true,
307
- kind: "boolean",
308
- required: false,
309
- sourceType: "boolean",
310
- },
311
- name: "isVisible",
312
- optional: true,
313
- typeExpression: "boolean & tags.Default<true>",
314
- }),
315
- createAttributeDefinition({
316
- blockJson: {
317
- defaultValue: "click",
318
- enumValues: [...INTERACTIVE_MODE_VALUES],
319
- type: "string",
320
- },
321
- manifest: {
322
- defaultValue: "click",
323
- enumValues: [...INTERACTIVE_MODE_VALUES],
324
- kind: "string",
325
- required: false,
326
- sourceType: "string",
327
- },
328
- name: "interactiveMode",
329
- optional: true,
330
- typeExpression: '("click" | "hover") & tags.Default<"click">',
331
- }),
332
- createAttributeDefinition({
333
- blockJson: {
334
- defaultValue: "none",
335
- enumValues: [...ANIMATION_VALUES],
336
- type: "string",
337
- },
338
- manifest: {
339
- defaultValue: "none",
340
- enumValues: [...ANIMATION_VALUES],
341
- kind: "string",
342
- required: false,
343
- sourceType: "string",
344
- },
345
- name: "animation",
346
- optional: true,
347
- typeExpression: '("none" | "bounce" | "pulse" | "shake" | "flip") & tags.Default<"none">',
348
- }),
349
- createAttributeDefinition({
350
- blockJson: {
351
- defaultValue: 0,
352
- type: "number",
353
- },
354
- manifest: {
355
- constraints: {
356
- minimum: 0,
357
- typeTag: "uint32",
358
- },
359
- defaultValue: 0,
360
- kind: "number",
361
- required: false,
362
- sourceType: "number",
363
- },
364
- name: "clickCount",
365
- optional: true,
366
- typeExpression: 'number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<0>',
367
- }),
368
- createAttributeDefinition({
369
- blockJson: {
370
- defaultValue: false,
371
- type: "boolean",
372
- },
373
- manifest: {
374
- defaultValue: false,
375
- kind: "boolean",
376
- required: false,
377
- sourceType: "boolean",
378
- },
379
- name: "isAnimating",
380
- optional: true,
381
- typeExpression: "boolean & tags.Default<false>",
382
- }),
383
- createAttributeDefinition({
384
- blockJson: {
385
- defaultValue: true,
386
- type: "boolean",
387
- },
388
- manifest: {
389
- defaultValue: true,
390
- kind: "boolean",
391
- required: false,
392
- sourceType: "boolean",
393
- },
394
- name: "showCounter",
395
- optional: true,
396
- typeExpression: "boolean & tags.Default<true>",
397
- }),
398
- createAttributeDefinition({
399
- blockJson: {
400
- defaultValue: 10,
401
- type: "number",
402
- },
403
- manifest: {
404
- constraints: {
405
- minimum: 0,
406
- typeTag: "uint32",
407
- },
408
- defaultValue: 10,
409
- kind: "number",
410
- required: false,
411
- sourceType: "number",
412
- },
413
- name: "maxClicks",
414
- optional: true,
415
- typeExpression: 'number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<10>',
416
- }),
417
- ];
510
+ return buildAttributesFromSpecs(INTERACTIVITY_ATTRIBUTE_SPECS, variables);
418
511
  }
419
512
  function buildPersistenceAttributes(variables) {
420
- return [
421
- createAttributeDefinition({
422
- blockJson: {
423
- defaultValue: `${variables.title} persistence block`,
424
- selector: `.${variables.cssClassName}__content`,
425
- source: "html",
426
- type: "string",
427
- },
428
- manifest: {
429
- constraints: {
430
- maxLength: 250,
431
- minLength: 1,
432
- },
433
- defaultValue: `${variables.title} persistence block`,
434
- kind: "string",
435
- required: true,
436
- selector: `.${variables.cssClassName}__content`,
437
- source: "html",
438
- sourceType: "string",
439
- },
440
- name: "content",
441
- optional: false,
442
- typeExpression: `string & tags.MinLength<1> & tags.MaxLength<250> & tags.Default<${quote(`${variables.title} persistence block`)}>`,
443
- }),
444
- createAttributeDefinition({
445
- blockJson: {
446
- defaultValue: "left",
447
- enumValues: [...ALIGNMENT_VALUES],
448
- type: "string",
449
- },
450
- manifest: {
451
- defaultValue: "left",
452
- enumValues: [...ALIGNMENT_VALUES],
453
- kind: "string",
454
- required: false,
455
- sourceType: "string",
456
- },
457
- name: "alignment",
458
- optional: true,
459
- typeExpression: 'TextAlignment & tags.Default<"left">',
460
- }),
461
- createAttributeDefinition({
462
- blockJson: {
463
- defaultValue: true,
464
- type: "boolean",
465
- },
466
- manifest: {
467
- defaultValue: true,
468
- kind: "boolean",
469
- required: false,
470
- sourceType: "boolean",
471
- },
472
- name: "isVisible",
473
- optional: true,
474
- typeExpression: "boolean & tags.Default<true>",
475
- }),
476
- createAttributeDefinition({
477
- blockJson: {
478
- defaultValue: true,
479
- type: "boolean",
480
- },
481
- manifest: {
482
- defaultValue: true,
483
- kind: "boolean",
484
- required: false,
485
- sourceType: "boolean",
486
- },
487
- name: "showCount",
488
- optional: true,
489
- typeExpression: "boolean & tags.Default<true>",
490
- }),
491
- createAttributeDefinition({
492
- blockJson: {
493
- defaultValue: "Persist Count",
494
- type: "string",
495
- },
496
- manifest: {
497
- constraints: {
498
- maxLength: 40,
499
- minLength: 1,
500
- },
501
- defaultValue: "Persist Count",
502
- kind: "string",
503
- required: false,
504
- sourceType: "string",
505
- },
506
- name: "buttonLabel",
507
- optional: true,
508
- typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<40> & tags.Default<"Persist Count">',
509
- }),
510
- createAttributeDefinition({
511
- blockJson: {
512
- defaultValue: "",
513
- type: "string",
514
- },
515
- manifest: {
516
- constraints: {
517
- maxLength: 100,
518
- minLength: 1,
519
- },
520
- defaultValue: "primary",
521
- kind: "string",
522
- required: false,
523
- sourceType: "string",
524
- },
525
- name: "resourceKey",
526
- optional: true,
527
- typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<100> & tags.Default<"primary">',
528
- }),
529
- ];
513
+ return buildAttributesFromSpecs(PERSISTENCE_ATTRIBUTE_SPECS, variables);
530
514
  }
531
515
  function buildCompoundParentAttributes(variables) {
532
- const attributes = [
533
- createAttributeDefinition({
534
- blockJson: {
535
- defaultValue: variables.title,
536
- selector: `.${variables.cssClassName}__heading`,
537
- source: "html",
538
- type: "string",
539
- },
540
- manifest: {
541
- constraints: {
542
- maxLength: 80,
543
- minLength: 1,
544
- },
545
- defaultValue: variables.title,
546
- kind: "string",
547
- required: true,
548
- selector: `.${variables.cssClassName}__heading`,
549
- source: "html",
550
- sourceType: "string",
551
- },
552
- name: "heading",
553
- optional: false,
554
- typeExpression: `string & tags.MinLength<1> & tags.MaxLength<80> & tags.Default<${quote(variables.title)}>`,
555
- }),
556
- createAttributeDefinition({
557
- blockJson: {
558
- defaultValue: "Add and reorder internal items inside this compound block.",
559
- selector: `.${variables.cssClassName}__intro`,
560
- source: "html",
561
- type: "string",
562
- },
563
- manifest: {
564
- constraints: {
565
- maxLength: 180,
566
- minLength: 1,
567
- },
568
- defaultValue: "Add and reorder internal items inside this compound block.",
569
- kind: "string",
570
- required: false,
571
- selector: `.${variables.cssClassName}__intro`,
572
- source: "html",
573
- sourceType: "string",
574
- },
575
- name: "intro",
576
- optional: true,
577
- typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<180> & tags.Default<"Add and reorder internal items inside this compound block.">',
578
- }),
579
- createAttributeDefinition({
580
- blockJson: {
581
- defaultValue: true,
582
- type: "boolean",
583
- },
584
- manifest: {
585
- defaultValue: true,
586
- kind: "boolean",
587
- required: false,
588
- sourceType: "boolean",
589
- },
590
- name: "showDividers",
591
- optional: true,
592
- typeExpression: "boolean & tags.Default<true>",
593
- }),
594
- ];
595
- if (variables.compoundPersistenceEnabled === "true") {
596
- attributes.push(createAttributeDefinition({
597
- blockJson: {
598
- defaultValue: true,
599
- type: "boolean",
600
- },
601
- manifest: {
602
- defaultValue: true,
603
- kind: "boolean",
604
- required: false,
605
- sourceType: "boolean",
606
- },
607
- name: "showCount",
608
- optional: true,
609
- typeExpression: "boolean & tags.Default<true>",
610
- }), createAttributeDefinition({
611
- blockJson: {
612
- defaultValue: "Persist Count",
613
- type: "string",
614
- },
615
- manifest: {
616
- constraints: {
617
- maxLength: 40,
618
- minLength: 1,
619
- },
620
- defaultValue: "Persist Count",
621
- kind: "string",
622
- required: false,
623
- sourceType: "string",
624
- },
625
- name: "buttonLabel",
626
- optional: true,
627
- typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<40> & tags.Default<"Persist Count">',
628
- }), createAttributeDefinition({
629
- blockJson: {
630
- defaultValue: "",
631
- type: "string",
632
- },
633
- manifest: {
634
- constraints: {
635
- maxLength: 100,
636
- minLength: 1,
637
- },
638
- defaultValue: "primary",
639
- kind: "string",
640
- required: false,
641
- sourceType: "string",
642
- },
643
- name: "resourceKey",
644
- optional: true,
645
- typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<100> & tags.Default<"primary">',
646
- }));
647
- }
648
- return attributes;
516
+ return buildAttributesFromSpecs(variables.compoundPersistenceEnabled === "true"
517
+ ? [
518
+ ...COMPOUND_PARENT_BASE_ATTRIBUTE_SPECS,
519
+ ...COMPOUND_PARENT_PERSISTENCE_ATTRIBUTE_SPECS,
520
+ ]
521
+ : COMPOUND_PARENT_BASE_ATTRIBUTE_SPECS, variables);
649
522
  }
650
523
  function buildCompoundChildAttributes(bodyPlaceholder = DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER, childTitle, childCssClassName) {
651
- const titleSelector = childCssClassName
652
- ? `.${childCssClassName}__title`
653
- : null;
654
- const bodySelector = childCssClassName
655
- ? `.${childCssClassName}__body`
656
- : null;
657
- return [
658
- createAttributeDefinition({
659
- blockJson: {
660
- defaultValue: childTitle,
661
- ...(titleSelector
662
- ? {
663
- selector: titleSelector,
664
- source: "html",
665
- }
666
- : {}),
667
- type: "string",
668
- },
669
- manifest: {
670
- constraints: {
671
- maxLength: 80,
672
- minLength: 1,
673
- },
674
- defaultValue: childTitle,
675
- kind: "string",
676
- required: true,
677
- selector: titleSelector,
678
- source: titleSelector ? "html" : null,
679
- sourceType: "string",
680
- },
681
- name: "title",
682
- optional: false,
683
- typeExpression: `string & tags.MinLength<1> & tags.MaxLength<80> & tags.Default<${quote(childTitle)}>`,
684
- }),
685
- createAttributeDefinition({
686
- blockJson: {
687
- defaultValue: bodyPlaceholder,
688
- ...(bodySelector
689
- ? {
690
- selector: bodySelector,
691
- source: "html",
692
- }
693
- : {}),
694
- type: "string",
695
- },
696
- manifest: {
697
- constraints: {
698
- maxLength: 280,
699
- minLength: 1,
700
- },
701
- defaultValue: bodyPlaceholder,
702
- kind: "string",
703
- required: true,
704
- selector: bodySelector,
705
- source: bodySelector ? "html" : null,
706
- sourceType: "string",
707
- },
708
- name: "body",
709
- optional: false,
710
- typeExpression: `string & tags.MinLength<1> & tags.MaxLength<280> & tags.Default<${quote(bodyPlaceholder)}>`,
711
- }),
712
- ];
524
+ return buildAttributesFromSpecs(COMPOUND_CHILD_ATTRIBUTE_SPECS, {
525
+ bodyPlaceholder,
526
+ childCssClassName,
527
+ childTitle,
528
+ });
713
529
  }
714
530
  function buildBasicTypesSource(variables, attributes) {
715
531
  return emitTypesModule({