@wp-typia/project-tools 0.16.11 → 0.16.13

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 (119) hide show
  1. package/README.md +9 -3
  2. package/dist/runtime/block-generator-service-core.d.ts +8 -0
  3. package/dist/runtime/block-generator-service-core.js +274 -0
  4. package/dist/runtime/block-generator-service-spec.d.ts +104 -0
  5. package/dist/runtime/block-generator-service-spec.js +139 -0
  6. package/dist/runtime/block-generator-service.d.ts +2 -110
  7. package/dist/runtime/block-generator-service.js +2 -389
  8. package/dist/runtime/built-in-block-artifact-documents.d.ts +3 -0
  9. package/dist/runtime/built-in-block-artifact-documents.js +2 -0
  10. package/dist/runtime/built-in-block-artifact-types.d.ts +51 -0
  11. package/dist/runtime/built-in-block-artifact-types.js +304 -0
  12. package/dist/runtime/built-in-block-artifacts.js +4 -803
  13. package/dist/runtime/built-in-block-attribute-emitters.d.ts +71 -0
  14. package/dist/runtime/built-in-block-attribute-emitters.js +176 -0
  15. package/dist/runtime/built-in-block-attribute-specs.d.ts +38 -0
  16. package/dist/runtime/built-in-block-attribute-specs.js +358 -0
  17. package/dist/runtime/built-in-block-code-templates/basic.d.ts +4 -0
  18. package/dist/runtime/built-in-block-code-templates/basic.js +249 -0
  19. package/dist/runtime/built-in-block-code-templates/compound-child.d.ts +4 -0
  20. package/dist/runtime/built-in-block-code-templates/compound-child.js +138 -0
  21. package/dist/runtime/built-in-block-code-templates/compound-parent.d.ts +6 -0
  22. package/dist/runtime/built-in-block-code-templates/compound-parent.js +227 -0
  23. package/dist/runtime/built-in-block-code-templates/compound-persistence.d.ts +4 -0
  24. package/dist/runtime/built-in-block-code-templates/compound-persistence.js +478 -0
  25. package/dist/runtime/built-in-block-code-templates/compound.d.ts +3 -0
  26. package/dist/runtime/built-in-block-code-templates/compound.js +3 -0
  27. package/dist/runtime/built-in-block-code-templates/interactivity.d.ts +5 -0
  28. package/dist/runtime/built-in-block-code-templates/interactivity.js +547 -0
  29. package/dist/runtime/built-in-block-code-templates/persistence.d.ts +5 -0
  30. package/dist/runtime/built-in-block-code-templates/persistence.js +550 -0
  31. package/dist/runtime/built-in-block-code-templates/shared.d.ts +16 -0
  32. package/dist/runtime/built-in-block-code-templates/shared.js +53 -0
  33. package/dist/runtime/built-in-block-code-templates.d.ts +5 -32
  34. package/dist/runtime/built-in-block-code-templates.js +5 -2230
  35. package/dist/runtime/cli-add-block-config.d.ts +6 -0
  36. package/dist/runtime/cli-add-block-config.js +143 -0
  37. package/dist/runtime/cli-add-block-legacy-validator.d.ts +4 -0
  38. package/dist/runtime/cli-add-block-legacy-validator.js +168 -0
  39. package/dist/runtime/cli-add-block.js +3 -301
  40. package/dist/runtime/cli-add-workspace-assets.d.ts +38 -0
  41. package/dist/runtime/cli-add-workspace-assets.js +399 -0
  42. package/dist/runtime/cli-add-workspace.d.ts +2 -38
  43. package/dist/runtime/cli-add-workspace.js +5 -396
  44. package/dist/runtime/cli-diagnostics.js +76 -4
  45. package/dist/runtime/cli-doctor-environment.d.ts +12 -0
  46. package/dist/runtime/cli-doctor-environment.js +123 -0
  47. package/dist/runtime/cli-doctor-workspace.d.ts +18 -0
  48. package/dist/runtime/cli-doctor-workspace.js +308 -0
  49. package/dist/runtime/cli-doctor.d.ts +4 -2
  50. package/dist/runtime/cli-doctor.js +10 -405
  51. package/dist/runtime/cli-help.js +1 -1
  52. package/dist/runtime/cli-scaffold.d.ts +8 -1
  53. package/dist/runtime/cli-scaffold.js +47 -4
  54. package/dist/runtime/migration-command-surface.d.ts +67 -0
  55. package/dist/runtime/migration-command-surface.js +189 -0
  56. package/dist/runtime/migration-diff-rename.d.ts +13 -0
  57. package/dist/runtime/migration-diff-rename.js +192 -0
  58. package/dist/runtime/migration-diff-transform.d.ts +14 -0
  59. package/dist/runtime/migration-diff-transform.js +105 -0
  60. package/dist/runtime/migration-diff.js +12 -297
  61. package/dist/runtime/migration-generated-artifacts.d.ts +3 -0
  62. package/dist/runtime/migration-generated-artifacts.js +41 -0
  63. package/dist/runtime/migration-maintenance-fixtures.d.ts +23 -0
  64. package/dist/runtime/migration-maintenance-fixtures.js +126 -0
  65. package/dist/runtime/migration-maintenance-verify.d.ts +26 -0
  66. package/dist/runtime/migration-maintenance-verify.js +262 -0
  67. package/dist/runtime/migration-maintenance.d.ts +2 -0
  68. package/dist/runtime/migration-maintenance.js +2 -0
  69. package/dist/runtime/migration-planning.d.ts +23 -0
  70. package/dist/runtime/migration-planning.js +131 -0
  71. package/dist/runtime/migration-project-config-source.d.ts +6 -0
  72. package/dist/runtime/migration-project-config-source.js +424 -0
  73. package/dist/runtime/migration-project-layout-discovery.d.ts +61 -0
  74. package/dist/runtime/migration-project-layout-discovery.js +337 -0
  75. package/dist/runtime/migration-project-layout-paths.d.ts +135 -0
  76. package/dist/runtime/migration-project-layout-paths.js +288 -0
  77. package/dist/runtime/migration-project-layout.d.ts +3 -0
  78. package/dist/runtime/migration-project-layout.js +2 -0
  79. package/dist/runtime/migration-project-workspace.d.ts +47 -0
  80. package/dist/runtime/migration-project-workspace.js +212 -0
  81. package/dist/runtime/migration-project.d.ts +4 -94
  82. package/dist/runtime/migration-project.js +3 -1101
  83. package/dist/runtime/migration-render-diff-rule.d.ts +5 -0
  84. package/dist/runtime/migration-render-diff-rule.js +120 -0
  85. package/dist/runtime/migration-render-execution.d.ts +3 -0
  86. package/dist/runtime/migration-render-execution.js +428 -0
  87. package/dist/runtime/migration-render-generated.d.ts +27 -0
  88. package/dist/runtime/migration-render-generated.js +230 -0
  89. package/dist/runtime/migration-render-support.d.ts +3 -0
  90. package/dist/runtime/migration-render-support.js +16 -0
  91. package/dist/runtime/migration-render.d.ts +3 -33
  92. package/dist/runtime/migration-render.js +3 -789
  93. package/dist/runtime/migrations.d.ts +24 -121
  94. package/dist/runtime/migrations.js +12 -700
  95. package/dist/runtime/scaffold-apply-utils.d.ts +9 -0
  96. package/dist/runtime/scaffold-apply-utils.js +27 -4
  97. package/dist/runtime/scaffold-bootstrap.d.ts +45 -0
  98. package/dist/runtime/scaffold-bootstrap.js +185 -0
  99. package/dist/runtime/scaffold-onboarding.d.ts +12 -0
  100. package/dist/runtime/scaffold-onboarding.js +42 -5
  101. package/dist/runtime/scaffold-package-manager-files.d.ts +35 -0
  102. package/dist/runtime/scaffold-package-manager-files.js +79 -0
  103. package/dist/runtime/scaffold.d.ts +1 -12
  104. package/dist/runtime/scaffold.js +11 -394
  105. package/dist/runtime/template-source-contracts.d.ts +81 -0
  106. package/dist/runtime/template-source-contracts.js +1 -0
  107. package/dist/runtime/template-source-external.d.ts +21 -0
  108. package/dist/runtime/template-source-external.js +184 -0
  109. package/dist/runtime/template-source-locators.d.ts +4 -0
  110. package/dist/runtime/template-source-locators.js +72 -0
  111. package/dist/runtime/template-source-normalization.d.ts +7 -0
  112. package/dist/runtime/template-source-normalization.js +53 -0
  113. package/dist/runtime/template-source-remote.d.ts +23 -0
  114. package/dist/runtime/template-source-remote.js +336 -0
  115. package/dist/runtime/template-source-seeds.d.ts +12 -0
  116. package/dist/runtime/template-source-seeds.js +243 -0
  117. package/dist/runtime/template-source.d.ts +4 -86
  118. package/dist/runtime/template-source.js +9 -828
  119. package/package.json +4 -4
@@ -1,389 +1,2 @@
1
- import { getPackageVersions } from "./package-versions.js";
2
- import { BUILTIN_BLOCK_METADATA_VERSION, COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS, getBuiltInTemplateMetadataDefaults, } from "./template-defaults.js";
3
- import { getTemplateById, } from "./template-registry.js";
4
- import { resolveBuiltInTemplateSource } from "./template-builtins.js";
5
- import { toPascalCase, toSnakeCase, } from "./string-case.js";
6
- import { applyBuiltInScaffoldProjectFiles, buildGitignore, buildReadme, } from "./scaffold-apply-utils.js";
7
- import { buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, } from "./scaffold-identifiers.js";
8
- import { buildBuiltInBlockArtifacts, } from "./built-in-block-artifacts.js";
9
- import { buildBuiltInCodeArtifacts, } from "./built-in-block-code-artifacts.js";
10
- import { stableJsonStringify } from "./object-utils.js";
11
- import { getStarterManifestFiles } from "./starter-manifests.js";
12
- import { resolveTemplateSeed, parseTemplateLocator } from "./template-source.js";
13
- import { assertExternalTemplateLayersDoNotWriteProtectedOutputs, resolveExternalTemplateLayers, } from "./template-layers.js";
14
- import { getBuiltInTemplateOverlayDir, getBuiltInTemplateSharedLayerDirs, resolveBuiltInTemplateSourceFromLayerDirs, } from "./template-builtins.js";
15
- const renderedArtifactCache = new WeakMap();
16
- function createVariablesFingerprint(variables) {
17
- return stableJsonStringify(variables);
18
- }
19
- function buildProtectedTemplateOutputPaths({ codeArtifacts, spec, variables, artifacts, }) {
20
- const protectedOutputs = new Set([
21
- ".gitignore",
22
- "package.json",
23
- "scripts/add-compound-child.ts",
24
- "scripts/block-config.ts",
25
- "scripts/sync-project.ts",
26
- "scripts/sync-rest-contracts.ts",
27
- "scripts/sync-types-to-block-json.ts",
28
- "tsconfig.json",
29
- "webpack.config.js",
30
- `${variables.slugKebabCase}.php`,
31
- ]);
32
- for (const artifact of codeArtifacts) {
33
- protectedOutputs.add(artifact.relativePath);
34
- }
35
- for (const artifact of artifacts) {
36
- protectedOutputs.add(`${artifact.relativeDir}/block.json`);
37
- protectedOutputs.add(`${artifact.relativeDir}/types.ts`);
38
- }
39
- for (const manifest of getStarterManifestFiles(spec.template.family, variables)) {
40
- protectedOutputs.add(manifest.relativePath);
41
- }
42
- return protectedOutputs;
43
- }
44
- function buildCombinedTemplateLayerDirs({ baseLayerDirs, externalEntries, templateId, }) {
45
- const orderedLayerDirs = [];
46
- const seenLayerDirs = new Set();
47
- for (const layerDir of baseLayerDirs) {
48
- if (seenLayerDirs.has(layerDir)) {
49
- continue;
50
- }
51
- orderedLayerDirs.push(layerDir);
52
- seenLayerDirs.add(layerDir);
53
- }
54
- for (const entry of externalEntries) {
55
- if (seenLayerDirs.has(entry.dir)) {
56
- continue;
57
- }
58
- orderedLayerDirs.push(entry.dir);
59
- seenLayerDirs.add(entry.dir);
60
- }
61
- const overlayDir = getBuiltInTemplateOverlayDir(templateId);
62
- if (!seenLayerDirs.has(overlayDir)) {
63
- orderedLayerDirs.push(overlayDir);
64
- }
65
- return orderedLayerDirs;
66
- }
67
- function getBuiltInPersistenceSpec({ templateId, dataStorageMode, persistencePolicy, }) {
68
- if (templateId === "persistence") {
69
- return {
70
- dataStorageMode: dataStorageMode ?? "custom-table",
71
- enabled: true,
72
- persistencePolicy: persistencePolicy ?? "authenticated",
73
- scope: "single",
74
- };
75
- }
76
- if (templateId === "compound" && (dataStorageMode || persistencePolicy)) {
77
- return {
78
- dataStorageMode: dataStorageMode ?? "custom-table",
79
- enabled: true,
80
- persistencePolicy: persistencePolicy ?? "authenticated",
81
- scope: "compound-parent",
82
- };
83
- }
84
- return {
85
- enabled: false,
86
- };
87
- }
88
- export function createBuiltInBlockSpec({ answers, dataStorageMode, persistencePolicy, templateId, withMigrationUi = false, withTestPreset = false, withWpEnv = false, }) {
89
- const template = getTemplateById(templateId);
90
- const metadataDefaults = getBuiltInTemplateMetadataDefaults(templateId);
91
- const identifiers = resolveScaffoldIdentifiers({
92
- namespace: answers.namespace,
93
- phpPrefix: answers.phpPrefix,
94
- slug: answers.slug,
95
- textDomain: answers.textDomain,
96
- });
97
- const resolvedDataStorageMode = dataStorageMode ?? answers.dataStorageMode;
98
- const resolvedPersistencePolicy = persistencePolicy ?? answers.persistencePolicy;
99
- return {
100
- block: identifiers,
101
- metadata: {
102
- category: metadataDefaults.category,
103
- description: answers.description.trim(),
104
- icon: metadataDefaults.icon,
105
- keyword: identifiers.slug.replace(/-/g, " "),
106
- title: answers.title.trim(),
107
- },
108
- persistence: getBuiltInPersistenceSpec({
109
- dataStorageMode: resolvedDataStorageMode,
110
- persistencePolicy: resolvedPersistencePolicy,
111
- templateId,
112
- }),
113
- project: {
114
- author: answers.author.trim(),
115
- },
116
- runtime: {
117
- withMigrationUi,
118
- withTestPreset,
119
- withWpEnv,
120
- },
121
- template: {
122
- description: template.description,
123
- family: templateId,
124
- features: [...template.features],
125
- },
126
- };
127
- }
128
- export function buildTemplateVariablesFromBlockSpec(spec) {
129
- const { apiClientPackageVersion, blockRuntimePackageVersion, blockTypesPackageVersion, projectToolsPackageVersion, restPackageVersion, } = getPackageVersions();
130
- const slug = spec.block.slug;
131
- const slugSnakeCase = toSnakeCase(slug);
132
- const pascalCase = toPascalCase(slug);
133
- const title = spec.metadata.title;
134
- const namespace = spec.block.namespace;
135
- const textDomain = spec.block.textDomain;
136
- const phpPrefix = spec.block.phpPrefix;
137
- const phpPrefixUpper = phpPrefix.toUpperCase();
138
- const compoundChildTitle = `${title} Item`;
139
- const cssClassName = buildBlockCssClassName(namespace, slug);
140
- const compoundChildCssClassName = buildBlockCssClassName(namespace, `${slug}-item`);
141
- const persistenceEnabled = spec.persistence.enabled;
142
- const dataStorageMode = persistenceEnabled ? spec.persistence.dataStorageMode : "custom-table";
143
- const persistencePolicy = persistenceEnabled
144
- ? spec.persistence.persistencePolicy
145
- : "authenticated";
146
- return {
147
- apiClientPackageVersion,
148
- author: spec.project.author,
149
- blockRuntimePackageVersion,
150
- blockMetadataVersion: BUILTIN_BLOCK_METADATA_VERSION,
151
- blockTypesPackageVersion,
152
- category: spec.metadata.category,
153
- icon: spec.metadata.icon,
154
- compoundChildTitle,
155
- compoundChildCategory: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.category,
156
- compoundChildCssClassName,
157
- compoundChildIcon: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.icon,
158
- compoundChildTitleJson: JSON.stringify(compoundChildTitle),
159
- compoundPersistenceEnabled: spec.template.family === "compound" && persistenceEnabled ? "true" : "false",
160
- projectToolsPackageVersion,
161
- cssClassName,
162
- dashCase: slug,
163
- dataStorageMode,
164
- description: spec.metadata.description,
165
- frontendCssClassName: buildFrontendCssClassName(cssClassName),
166
- isAuthenticatedPersistencePolicy: persistencePolicy === "authenticated" ? "true" : "false",
167
- isPublicPersistencePolicy: persistencePolicy === "public" ? "true" : "false",
168
- bootstrapCredentialDeclarations: persistencePolicy === "public"
169
- ? "publicWriteExpiresAt?: number & tags.Type< 'uint32' >;\n\tpublicWriteToken?: string & tags.MinLength< 1 > & tags.MaxLength< 512 >;"
170
- : "restNonce?: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;",
171
- persistencePolicyDescriptionJson: JSON.stringify(persistencePolicy === "authenticated"
172
- ? "Writes require a logged-in user and a valid REST nonce."
173
- : "Anonymous writes use signed short-lived public tokens, per-request ids, and coarse rate limiting."),
174
- keyword: spec.metadata.keyword,
175
- namespace,
176
- needsMigration: "{{needsMigration}}",
177
- pascalCase,
178
- phpPrefix,
179
- phpPrefixUpper,
180
- restPackageVersion,
181
- publicWriteRequestIdDeclaration: persistencePolicy === "public"
182
- ? "publicWriteRequestId: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;"
183
- : "publicWriteRequestId?: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;",
184
- restWriteAuthIntent: persistencePolicy === "public"
185
- ? "public-write-protected"
186
- : "authenticated",
187
- restWriteAuthMechanism: persistencePolicy === "public" ? "public-signed-token" : "rest-nonce",
188
- restWriteAuthMode: persistencePolicy === "public" ? "public-signed-token" : "authenticated-rest-nonce",
189
- slug,
190
- slugCamelCase: pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1),
191
- slugKebabCase: slug,
192
- slugSnakeCase,
193
- textDomain,
194
- textdomain: textDomain,
195
- title,
196
- titleJson: JSON.stringify(title),
197
- titleCase: pascalCase,
198
- persistencePolicy,
199
- };
200
- }
201
- export class BlockGeneratorService {
202
- async plan({ allowExistingDir = false, answers, cwd = process.cwd(), dataStorageMode, externalLayerId, externalLayerSource, externalLayerSourceLabel, noInstall = false, packageManager, persistencePolicy, projectDir, repositoryReference, templateId, variant, withMigrationUi = false, withTestPreset = false, withWpEnv = false, }) {
203
- return {
204
- spec: createBuiltInBlockSpec({
205
- answers,
206
- dataStorageMode,
207
- persistencePolicy,
208
- templateId,
209
- withMigrationUi,
210
- withTestPreset,
211
- withWpEnv,
212
- }),
213
- target: {
214
- allowExistingDir,
215
- cwd,
216
- externalLayerId,
217
- externalLayerSource,
218
- externalLayerSourceLabel,
219
- noInstall,
220
- packageManager,
221
- projectDir,
222
- repositoryReference,
223
- variant,
224
- },
225
- };
226
- }
227
- async validate({ plan }) {
228
- if (plan.target.externalLayerId && !plan.target.externalLayerSource) {
229
- throw new Error("externalLayerId requires externalLayerSource when composing built-in template layers.");
230
- }
231
- if (plan.target.variant) {
232
- throw new Error(`--variant is only supported for official external template configs. Received variant "${plan.target.variant}" for built-in template "${plan.spec.template.family}".`);
233
- }
234
- return plan;
235
- }
236
- async render({ validated }) {
237
- const variables = buildTemplateVariablesFromBlockSpec(validated.spec);
238
- const persistenceEnabled = validated.spec.persistence.enabled;
239
- const artifacts = buildBuiltInBlockArtifacts({
240
- templateId: validated.spec.template.family,
241
- variables,
242
- });
243
- const codeArtifacts = buildBuiltInCodeArtifacts({
244
- templateId: validated.spec.template.family,
245
- variables,
246
- });
247
- const templateVariantOptions = {
248
- persistenceEnabled,
249
- persistencePolicy: validated.spec.persistence.enabled &&
250
- validated.spec.persistence.persistencePolicy === "public"
251
- ? "public"
252
- : "authenticated",
253
- };
254
- let templateSource = await resolveBuiltInTemplateSource(validated.spec.template.family, templateVariantOptions);
255
- const warnings = [...(templateSource.warnings ?? [])];
256
- if (validated.target.externalLayerSource) {
257
- let layerSeed;
258
- try {
259
- layerSeed = await resolveTemplateSeed(parseTemplateLocator(validated.target.externalLayerSource), validated.target.cwd);
260
- const resolvedLayers = await resolveExternalTemplateLayers({
261
- externalLayerId: validated.target.externalLayerId,
262
- sourceRoot: layerSeed.rootDir,
263
- });
264
- const baseLayerDirs = getBuiltInTemplateSharedLayerDirs(validated.spec.template.family, templateVariantOptions);
265
- await assertExternalTemplateLayersDoNotWriteProtectedOutputs({
266
- externalEntries: resolvedLayers.entries,
267
- protectedOutputPaths: buildProtectedTemplateOutputPaths({
268
- artifacts,
269
- codeArtifacts,
270
- spec: validated.spec,
271
- variables,
272
- }),
273
- view: variables,
274
- });
275
- await templateSource.cleanup?.();
276
- templateSource = await resolveBuiltInTemplateSourceFromLayerDirs(validated.spec.template.family, buildCombinedTemplateLayerDirs({
277
- baseLayerDirs,
278
- externalEntries: resolvedLayers.entries,
279
- templateId: validated.spec.template.family,
280
- }));
281
- const layerSourceCleanup = layerSeed.cleanup;
282
- const templateCleanup = templateSource.cleanup;
283
- templateSource.cleanup = async () => {
284
- const cleanupErrors = [];
285
- try {
286
- await templateCleanup?.();
287
- }
288
- catch (error) {
289
- cleanupErrors.push(error instanceof Error ? error : new Error(String(error)));
290
- }
291
- try {
292
- await layerSourceCleanup?.();
293
- }
294
- catch (error) {
295
- cleanupErrors.push(error instanceof Error ? error : new Error(String(error)));
296
- }
297
- if (cleanupErrors.length > 0) {
298
- throw new Error([
299
- "Failed to cleanup composed template sources.",
300
- ...cleanupErrors.map((error) => `- ${error.message}`),
301
- ].join("\n"));
302
- }
303
- };
304
- warnings.push(`Applied external layer "${resolvedLayers.selectedLayerId}" from "${validated.target.externalLayerSourceLabel ?? validated.target.externalLayerSource}".`);
305
- }
306
- catch (error) {
307
- await templateSource.cleanup?.();
308
- await layerSeed?.cleanup?.();
309
- throw error;
310
- }
311
- }
312
- const rendered = {
313
- ...validated,
314
- cleanup: templateSource.cleanup,
315
- gitignoreContent: buildGitignore(),
316
- postRender: {
317
- applyLocalDevPresets: true,
318
- applyMigrationUiCapability: validated.spec.runtime.withMigrationUi,
319
- seedPersistenceArtifacts: validated.spec.template.family === "persistence" ||
320
- (validated.spec.template.family === "compound" && persistenceEnabled),
321
- seedStarterManifestFiles: true,
322
- },
323
- readmeContent: buildReadme(validated.spec.template.family, variables, validated.target.packageManager, {
324
- withMigrationUi: validated.spec.runtime.withMigrationUi,
325
- withTestPreset: validated.spec.runtime.withTestPreset,
326
- withWpEnv: validated.spec.runtime.withWpEnv,
327
- }),
328
- selectedVariant: null,
329
- templateDir: templateSource.templateDir,
330
- variables,
331
- warnings,
332
- };
333
- renderedArtifactCache.set(rendered, {
334
- artifacts,
335
- codeArtifacts,
336
- variablesFingerprint: createVariablesFingerprint(variables),
337
- });
338
- return rendered;
339
- }
340
- async apply({ rendered, installDependencies, }) {
341
- const cachedArtifacts = renderedArtifactCache.get(rendered);
342
- const currentVariablesFingerprint = createVariablesFingerprint(rendered.variables);
343
- const artifacts = cachedArtifacts &&
344
- cachedArtifacts.variablesFingerprint === currentVariablesFingerprint
345
- ? cachedArtifacts.artifacts
346
- : buildBuiltInBlockArtifacts({
347
- templateId: rendered.spec.template.family,
348
- variables: rendered.variables,
349
- });
350
- const codeArtifacts = cachedArtifacts &&
351
- cachedArtifacts.variablesFingerprint === currentVariablesFingerprint
352
- ? cachedArtifacts.codeArtifacts
353
- : buildBuiltInCodeArtifacts({
354
- templateId: rendered.spec.template.family,
355
- variables: rendered.variables,
356
- });
357
- try {
358
- await applyBuiltInScaffoldProjectFiles({
359
- allowExistingDir: rendered.target.allowExistingDir,
360
- artifacts,
361
- codeArtifacts,
362
- installDependencies,
363
- noInstall: rendered.target.noInstall,
364
- packageManager: rendered.target.packageManager,
365
- projectDir: rendered.target.projectDir,
366
- repositoryReference: rendered.target.repositoryReference,
367
- gitignoreContent: rendered.gitignoreContent,
368
- readmeContent: rendered.readmeContent,
369
- templateDir: rendered.templateDir,
370
- templateId: rendered.spec.template.family,
371
- variables: rendered.variables,
372
- withMigrationUi: rendered.spec.runtime.withMigrationUi,
373
- withTestPreset: rendered.spec.runtime.withTestPreset,
374
- withWpEnv: rendered.spec.runtime.withWpEnv,
375
- });
376
- }
377
- finally {
378
- await rendered.cleanup?.();
379
- }
380
- return {
381
- packageManager: rendered.target.packageManager,
382
- projectDir: rendered.target.projectDir,
383
- selectedVariant: rendered.selectedVariant,
384
- templateId: rendered.spec.template.family,
385
- variables: rendered.variables,
386
- warnings: rendered.warnings,
387
- };
388
- }
389
- }
1
+ export * from "./block-generator-service-spec.js";
2
+ export * from "./block-generator-service-core.js";
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER, buildBlockJsonAttributes, buildManifestDocument, } from "./built-in-block-attribute-emitters.js";
2
+ export type { AttributeDescription, EmittedAttributeDefinition, } from "./built-in-block-attribute-emitters.js";
3
+ export { buildBasicAttributes, buildCompoundChildAttributes, buildCompoundParentAttributes, buildInteractivityAttributes, buildPersistenceAttributes, } from "./built-in-block-attribute-specs.js";
@@ -0,0 +1,2 @@
1
+ export { DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER, buildBlockJsonAttributes, buildManifestDocument, } from "./built-in-block-attribute-emitters.js";
2
+ export { buildBasicAttributes, buildCompoundChildAttributes, buildCompoundParentAttributes, buildInteractivityAttributes, buildPersistenceAttributes, } from "./built-in-block-attribute-specs.js";
@@ -0,0 +1,51 @@
1
+ import type { ScaffoldTemplateVariables } from "./scaffold.js";
2
+ interface AttributeDescription {
3
+ lines: string[];
4
+ }
5
+ interface EmittedAttributeDefinition {
6
+ description?: AttributeDescription;
7
+ name: string;
8
+ optional: boolean;
9
+ typeExpression: string;
10
+ }
11
+ /**
12
+ * Builds the generated attributes and validation type source for a basic block scaffold.
13
+ *
14
+ * @param variables Resolved scaffold template variables used to name emitted types.
15
+ * @param attributes Emitted built-in attribute definitions that drive the interface members.
16
+ * @returns TypeScript source for the basic block attribute and validation types.
17
+ */
18
+ export declare function buildBasicTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
19
+ /**
20
+ * Builds the generated attributes, context, and validation type source for an interactivity scaffold.
21
+ *
22
+ * @param variables Resolved scaffold template variables used to name emitted types.
23
+ * @param attributes Emitted built-in attribute definitions that drive the interface members.
24
+ * @returns TypeScript source for the interactivity block attribute, context, and validation types.
25
+ */
26
+ export declare function buildInteractivityTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
27
+ /**
28
+ * Builds the generated attributes, context, state, client, and validation type source for a persistence scaffold.
29
+ *
30
+ * @param variables Resolved scaffold template variables used to name emitted types.
31
+ * @param attributes Emitted built-in attribute definitions that drive the interface members.
32
+ * @returns TypeScript source for the persistence block runtime types.
33
+ */
34
+ export declare function buildPersistenceTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
35
+ /**
36
+ * Builds the generated attributes and optional persistence runtime type source for a compound parent scaffold.
37
+ *
38
+ * @param variables Resolved scaffold template variables used to name emitted types.
39
+ * @param attributes Emitted built-in attribute definitions that drive the interface members.
40
+ * @returns TypeScript source for the compound parent runtime types.
41
+ */
42
+ export declare function buildCompoundTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
43
+ /**
44
+ * Builds the generated attributes and validation type source for a compound child scaffold.
45
+ *
46
+ * @param variables Resolved scaffold template variables used to name emitted types.
47
+ * @param attributes Emitted built-in attribute definitions that drive the interface members.
48
+ * @returns TypeScript source for the compound child attribute and validation types.
49
+ */
50
+ export declare function buildCompoundChildTypesSource(variables: ScaffoldTemplateVariables, attributes: readonly EmittedAttributeDefinition[]): string;
51
+ export {};