@wp-typia/project-tools 0.23.0 → 0.24.0

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 (228) hide show
  1. package/dist/runtime/ai-feature-artifacts.js +4 -1
  2. package/dist/runtime/block-generator-service-spec.js +2 -1
  3. package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
  4. package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
  5. package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
  6. package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
  7. package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
  8. package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
  9. package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
  10. package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
  11. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
  12. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
  13. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
  14. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
  15. package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
  16. package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
  17. package/dist/runtime/cli-add-block-json.js +5 -1
  18. package/dist/runtime/cli-add-collision.js +8 -0
  19. package/dist/runtime/cli-add-help.js +14 -10
  20. package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
  21. package/dist/runtime/cli-add-kind-ids.js +1 -0
  22. package/dist/runtime/cli-add-types.d.ts +45 -6
  23. package/dist/runtime/cli-add-types.js +2 -0
  24. package/dist/runtime/cli-add-validation.d.ts +7 -0
  25. package/dist/runtime/cli-add-validation.js +9 -0
  26. package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
  27. package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
  28. package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
  29. package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
  30. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
  31. package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
  32. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
  33. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
  34. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
  35. package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
  36. package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
  37. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
  38. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
  39. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
  40. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
  41. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
  42. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
  43. package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
  44. package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
  45. package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
  46. package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
  47. package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
  48. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
  49. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
  50. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
  51. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
  52. package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
  53. package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
  54. package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
  55. package/dist/runtime/cli-add-workspace-assets.js +6 -950
  56. package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
  57. package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
  58. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
  59. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
  60. package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
  61. package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
  62. package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
  63. package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
  64. package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
  65. package/dist/runtime/cli-add-workspace-block-style.js +148 -0
  66. package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
  67. package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
  68. package/dist/runtime/cli-add-workspace-contract.js +1 -1
  69. package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
  70. package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
  71. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
  72. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
  73. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
  74. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
  75. package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
  76. package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
  77. package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
  78. package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
  79. package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
  80. package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
  81. package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
  82. package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
  83. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
  84. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
  85. package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
  86. package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
  87. package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
  88. package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
  89. package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
  90. package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
  91. package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
  92. package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
  93. package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
  94. package/dist/runtime/cli-add-workspace-pattern.js +99 -0
  95. package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
  96. package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
  97. package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
  98. package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
  99. package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
  100. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
  101. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
  102. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
  103. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
  104. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
  105. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
  106. package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
  107. package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
  108. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
  109. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
  110. package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
  111. package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
  112. package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
  113. package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
  114. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
  115. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
  116. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
  117. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
  118. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
  119. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
  120. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
  121. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
  122. package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
  123. package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
  124. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
  125. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
  126. package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
  127. package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
  128. package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
  129. package/dist/runtime/cli-add-workspace-rest.js +33 -788
  130. package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
  131. package/dist/runtime/cli-add-workspace-variation.js +162 -0
  132. package/dist/runtime/cli-add-workspace.d.ts +42 -107
  133. package/dist/runtime/cli-add-workspace.js +42 -674
  134. package/dist/runtime/cli-add.d.ts +3 -3
  135. package/dist/runtime/cli-add.js +2 -2
  136. package/dist/runtime/cli-core.d.ts +3 -2
  137. package/dist/runtime/cli-core.js +2 -2
  138. package/dist/runtime/cli-diagnostics.d.ts +3 -1
  139. package/dist/runtime/cli-diagnostics.js +17 -5
  140. package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
  141. package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
  142. package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
  143. package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
  144. package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
  145. package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
  146. package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
  147. package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
  148. package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
  149. package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
  150. package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
  151. package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
  152. package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
  153. package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
  154. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
  155. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
  156. package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
  157. package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
  158. package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
  159. package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
  160. package/dist/runtime/cli-doctor-workspace-features.js +14 -487
  161. package/dist/runtime/cli-doctor.d.ts +54 -3
  162. package/dist/runtime/cli-doctor.js +92 -10
  163. package/dist/runtime/cli-help.js +12 -7
  164. package/dist/runtime/cli-init-package-json.js +4 -2
  165. package/dist/runtime/cli-prompt.d.ts +16 -2
  166. package/dist/runtime/cli-prompt.js +29 -12
  167. package/dist/runtime/cli-scaffold.d.ts +2 -1
  168. package/dist/runtime/cli-scaffold.js +19 -10
  169. package/dist/runtime/external-template-guards.js +4 -6
  170. package/dist/runtime/index.d.ts +6 -3
  171. package/dist/runtime/index.js +4 -2
  172. package/dist/runtime/json-utils.d.ts +62 -4
  173. package/dist/runtime/json-utils.js +78 -4
  174. package/dist/runtime/local-dev-presets.js +6 -2
  175. package/dist/runtime/migration-ui-capability.js +4 -1
  176. package/dist/runtime/migration-utils.js +4 -1
  177. package/dist/runtime/package-managers.js +6 -1
  178. package/dist/runtime/package-versions.d.ts +1 -0
  179. package/dist/runtime/package-versions.js +16 -3
  180. package/dist/runtime/pattern-catalog.d.ts +122 -0
  181. package/dist/runtime/pattern-catalog.js +471 -0
  182. package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
  183. package/dist/runtime/post-meta-binding-fields.js +135 -0
  184. package/dist/runtime/scaffold-bootstrap.js +7 -2
  185. package/dist/runtime/scaffold-package-manager-files.js +5 -1
  186. package/dist/runtime/scaffold-repository-reference.js +4 -2
  187. package/dist/runtime/scaffold-template-variables.js +2 -1
  188. package/dist/runtime/scaffold.d.ts +18 -1
  189. package/dist/runtime/scaffold.js +55 -2
  190. package/dist/runtime/temp-roots.js +4 -1
  191. package/dist/runtime/template-layers.js +4 -1
  192. package/dist/runtime/template-registry.js +9 -3
  193. package/dist/runtime/template-source-contracts.d.ts +2 -0
  194. package/dist/runtime/template-source-normalization.js +2 -1
  195. package/dist/runtime/template-source-remote.js +18 -5
  196. package/dist/runtime/template-source-seeds.js +10 -3
  197. package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
  198. package/dist/runtime/typia-llm-json-schema.js +33 -0
  199. package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
  200. package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
  201. package/dist/runtime/typia-llm-projection.d.ts +25 -0
  202. package/dist/runtime/typia-llm-projection.js +58 -0
  203. package/dist/runtime/typia-llm-render.d.ts +21 -0
  204. package/dist/runtime/typia-llm-render.js +252 -0
  205. package/dist/runtime/typia-llm-sync.d.ts +10 -0
  206. package/dist/runtime/typia-llm-sync.js +63 -0
  207. package/dist/runtime/typia-llm-types.d.ts +197 -0
  208. package/dist/runtime/typia-llm-types.js +1 -0
  209. package/dist/runtime/typia-llm.d.ts +9 -255
  210. package/dist/runtime/typia-llm.js +5 -634
  211. package/dist/runtime/workspace-inventory-mutations.js +15 -1
  212. package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
  213. package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
  214. package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
  215. package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
  216. package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
  217. package/dist/runtime/workspace-inventory-parser.js +3 -581
  218. package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
  219. package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
  220. package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
  221. package/dist/runtime/workspace-inventory-templates.js +10 -1
  222. package/dist/runtime/workspace-inventory-types.d.ts +10 -1
  223. package/dist/runtime/workspace-project.js +4 -6
  224. package/package.json +8 -3
  225. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
  226. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
  227. package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
  228. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
@@ -0,0 +1,197 @@
1
+ import { promises as fsp } from "node:fs";
2
+ import path from "node:path";
3
+ import { assertFullBlockName, resolveWorkspaceTargetBlockName, } from "./block-targets.js";
4
+ import { pathExists } from "./fs-async.js";
5
+ import { assertBlockTransformDoesNotExist, assertValidGeneratedSlug, normalizeBlockSlug, quoteTsString, resolveWorkspaceBlock, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
6
+ import { ensureWorkspaceRegistrationSettingsCall } from "./cli-add-workspace-registration-hooks.js";
7
+ import { appendWorkspaceInventoryEntries, readWorkspaceInventoryAsync, } from "./workspace-inventory.js";
8
+ import { resolveWorkspaceProject } from "./workspace-project.js";
9
+ import { toSnakeCase, toTitleCase } from "./string-case.js";
10
+ const BLOCK_TRANSFORMS_IMPORT_LINE = "import { applyWorkspaceBlockTransforms } from './transforms';";
11
+ const BLOCK_TRANSFORMS_IMPORT_PATTERN = /^\s*import\s*\{\s*applyWorkspaceBlockTransforms\s*\}\s*from\s*["']\.\/transforms["']\s*;?\s*$/mu;
12
+ const BLOCK_TRANSFORMS_CALL_LINE = "applyWorkspaceBlockTransforms(registration.settings);";
13
+ const BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
14
+ function buildWorkspaceConstName(prefix, slug) {
15
+ return `workspace${prefix}_${toSnakeCase(slug)}`;
16
+ }
17
+ function buildBlockTransformConfigEntry(options) {
18
+ return [
19
+ "\t{",
20
+ `\t\tblock: ${quoteTsString(options.blockSlug)},`,
21
+ `\t\tfile: ${quoteTsString(`src/blocks/${options.blockSlug}/transforms/${options.transformSlug}.ts`)},`,
22
+ `\t\tfrom: ${quoteTsString(options.fromBlockName)},`,
23
+ `\t\tslug: ${quoteTsString(options.transformSlug)},`,
24
+ `\t\tto: ${quoteTsString(options.toBlockName)},`,
25
+ "\t},",
26
+ ].join("\n");
27
+ }
28
+ function getBlockTransformConstBindings(transformSlugs) {
29
+ const seenConstNames = new Map();
30
+ return transformSlugs.map((transformSlug) => {
31
+ const constName = buildWorkspaceConstName("BlockTransform", transformSlug);
32
+ const previousSlug = seenConstNames.get(constName);
33
+ if (previousSlug && previousSlug !== transformSlug) {
34
+ throw new Error(`Transform slugs "${previousSlug}" and "${transformSlug}" generate the same registry identifier "${constName}". Rename one of the transforms.`);
35
+ }
36
+ seenConstNames.set(constName, transformSlug);
37
+ return { constName, transformSlug };
38
+ });
39
+ }
40
+ function buildBlockTransformSource(options) {
41
+ const transformTitle = toTitleCase(options.transformSlug);
42
+ const transformConstName = buildWorkspaceConstName("BlockTransform", options.transformSlug);
43
+ return `import { createBlock } from '@wordpress/blocks';
44
+ import { __ } from '@wordpress/i18n';
45
+ import metadata from '../block.json';
46
+
47
+ type TransformAttributes = Record<string, unknown>;
48
+ type TransformInnerBlock = ReturnType<typeof createBlock>;
49
+
50
+ function mapTransformAttributes(attributes: TransformAttributes): TransformAttributes {
51
+ \tconst content = attributes.content;
52
+
53
+ \treturn typeof content === 'string' ? { content } : {};
54
+ }
55
+
56
+ export const ${transformConstName} = {
57
+ \ttype: 'block',
58
+ \tblocks: [${quoteTsString(options.fromBlockName)}],
59
+ \ttitle: __( ${quoteTsString(transformTitle)}, ${quoteTsString(options.textDomain)} ),
60
+ \ttransform: (
61
+ \t\tattributes: TransformAttributes,
62
+ \t\tinnerBlocks: TransformInnerBlock[] = [],
63
+ \t) => createBlock(metadata.name, mapTransformAttributes(attributes), innerBlocks),
64
+ } as const;
65
+ `;
66
+ }
67
+ function buildBlockTransformIndexSource(transformSlugs) {
68
+ const transformBindings = getBlockTransformConstBindings(transformSlugs);
69
+ const importLines = transformBindings
70
+ .map(({ constName, transformSlug }) => `import { ${constName} } from './${transformSlug}';`)
71
+ .join("\n");
72
+ const transformConstNames = transformBindings
73
+ .map(({ constName }) => constName)
74
+ .join(",\n\t");
75
+ return `${importLines ? `${importLines}\n\n` : ""}type BlockSettingsWithTransforms = {
76
+ \ttransforms?: {
77
+ \t\tfrom?: unknown[];
78
+ \t\tto?: unknown[];
79
+ \t};
80
+ };
81
+
82
+ const WORKSPACE_BLOCK_TRANSFORMS = [
83
+ \t${transformConstNames}
84
+ \t// wp-typia add transform entries
85
+ ] as const;
86
+
87
+ export function applyWorkspaceBlockTransforms(settings: BlockSettingsWithTransforms) {
88
+ \tconst transforms = settings.transforms ?? {};
89
+
90
+ \tsettings.transforms = {
91
+ \t\t...transforms,
92
+ \t\tfrom: [...(transforms.from ?? []), ...WORKSPACE_BLOCK_TRANSFORMS],
93
+ \t};
94
+ }
95
+ `;
96
+ }
97
+ async function ensureBlockTransformRegistrationHook(blockIndexPath) {
98
+ await ensureWorkspaceRegistrationSettingsCall({
99
+ blockIndexPath,
100
+ callLine: BLOCK_TRANSFORMS_CALL_LINE,
101
+ callPattern: BLOCK_TRANSFORMS_CALL_PATTERN,
102
+ importLine: BLOCK_TRANSFORMS_IMPORT_LINE,
103
+ importPattern: BLOCK_TRANSFORMS_IMPORT_PATTERN,
104
+ });
105
+ }
106
+ async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug) {
107
+ const transformsDir = path.join(projectDir, "src", "blocks", blockSlug, "transforms");
108
+ const transformsIndexPath = path.join(transformsDir, "index.ts");
109
+ await fsp.mkdir(transformsDir, { recursive: true });
110
+ const existingTransformSlugs = (await fsp.readdir(transformsDir))
111
+ .filter((entry) => entry.endsWith(".ts") && entry !== "index.ts")
112
+ .map((entry) => entry.replace(/\.ts$/u, ""));
113
+ const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
114
+ await fsp.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
115
+ }
116
+ /**
117
+ * Add one block-to-block transform registration to an existing workspace block.
118
+ *
119
+ * @param options Command options for the block transform scaffold workflow.
120
+ * @param options.cwd Working directory used to resolve the nearest official workspace.
121
+ * Defaults to `process.cwd()`.
122
+ * @param options.fromBlockName Source block name for `--from`. This must be the
123
+ * full `namespace/block` form because transforms may originate from WordPress
124
+ * core or third-party blocks outside the workspace.
125
+ * @param options.toBlockName Target block for `--to`. A workspace block slug is
126
+ * resolved against the workspace namespace, while a full `namespace/block` name
127
+ * must still point at an existing workspace block.
128
+ * @param options.transformName Human-entered transform name that will be
129
+ * normalized and validated before files are written.
130
+ * @returns A promise that resolves with the normalized target `blockSlug`,
131
+ * resolved `fromBlockName`, resolved `toBlockName`, `transformSlug`, and owning
132
+ * `projectDir` after the transform module, transform registry, entrypoint hook,
133
+ * and inventory entry have been written successfully.
134
+ * @throws {Error} When the command is run outside an official workspace, when
135
+ * the target block is unknown, when `--from` is not a full block name, when
136
+ * `--to` uses a non-workspace namespace, when the target block entrypoint does
137
+ * not expose `registration.settings`, when the transform slug is invalid, or
138
+ * when a conflicting file or inventory entry already exists.
139
+ */
140
+ export async function runAddBlockTransformCommand({ cwd = process.cwd(), fromBlockName, toBlockName, transformName, }) {
141
+ const workspace = resolveWorkspaceProject(cwd);
142
+ const transformSlug = assertValidGeneratedSlug("Transform name", normalizeBlockSlug(transformName), "wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>");
143
+ const resolvedFromBlockName = assertFullBlockName(fromBlockName, "--from");
144
+ const target = resolveWorkspaceTargetBlockName(toBlockName, workspace.workspace.namespace, "--to");
145
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
146
+ resolveWorkspaceBlock(inventory, target.blockSlug);
147
+ assertBlockTransformDoesNotExist(workspace.projectDir, target.blockSlug, transformSlug, inventory);
148
+ const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
149
+ const blockIndexPath = path.join(workspace.projectDir, "src", "blocks", target.blockSlug, "index.tsx");
150
+ const transformsDir = path.join(workspace.projectDir, "src", "blocks", target.blockSlug, "transforms");
151
+ const transformFilePath = path.join(transformsDir, `${transformSlug}.ts`);
152
+ const transformsIndexPath = path.join(transformsDir, "index.ts");
153
+ const shouldRemoveTransformsDirOnRollback = !(await pathExists(transformsDir));
154
+ const mutationSnapshot = {
155
+ fileSources: await snapshotWorkspaceFiles([
156
+ blockConfigPath,
157
+ blockIndexPath,
158
+ transformsIndexPath,
159
+ ]),
160
+ snapshotDirs: [],
161
+ targetPaths: [
162
+ transformFilePath,
163
+ ...(shouldRemoveTransformsDirOnRollback ? [transformsDir] : []),
164
+ ],
165
+ };
166
+ try {
167
+ await fsp.mkdir(transformsDir, { recursive: true });
168
+ await fsp.writeFile(transformFilePath, buildBlockTransformSource({
169
+ fromBlockName: resolvedFromBlockName,
170
+ textDomain: workspace.workspace.textDomain,
171
+ transformSlug,
172
+ }), "utf8");
173
+ await writeBlockTransformRegistry(workspace.projectDir, target.blockSlug, transformSlug);
174
+ await ensureBlockTransformRegistrationHook(blockIndexPath);
175
+ await appendWorkspaceInventoryEntries(workspace.projectDir, {
176
+ blockTransformEntries: [
177
+ buildBlockTransformConfigEntry({
178
+ blockSlug: target.blockSlug,
179
+ fromBlockName: resolvedFromBlockName,
180
+ toBlockName: target.blockName,
181
+ transformSlug,
182
+ }),
183
+ ],
184
+ });
185
+ return {
186
+ blockSlug: target.blockSlug,
187
+ fromBlockName: resolvedFromBlockName,
188
+ projectDir: workspace.projectDir,
189
+ toBlockName: target.blockName,
190
+ transformSlug,
191
+ };
192
+ }
193
+ catch (error) {
194
+ await rollbackWorkspaceMutation(mutationSnapshot);
195
+ throw error;
196
+ }
197
+ }
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { pathExists } from "./fs-async.js";
4
4
  import { assertContractDoesNotExist, assertValidGeneratedSlug, assertValidTypeScriptIdentifier, normalizeBlockSlug, } from "./cli-add-shared.js";
5
5
  import { executeWorkspaceMutationPlan } from "./cli-add-workspace-mutation.js";
6
- import { ensureContractSyncScriptAnchors } from "./cli-add-workspace-rest-anchors.js";
6
+ import { ensureContractSyncScriptAnchors, } from "./cli-add-workspace-rest-contract-sync-anchors.js";
7
7
  import { buildContractConfigEntry, buildContractTypesSource, } from "./cli-add-workspace-contract-source-emitters.js";
8
8
  import { syncStandaloneContractArtifacts } from "./contract-artifacts.js";
9
9
  import { toPascalCase } from "./string-case.js";
@@ -0,0 +1,20 @@
1
+ import { type RunAddCoreVariationCommandOptions } from "./cli-add-shared.js";
2
+ /**
3
+ * Add one editor-side variation registration for an existing core or external block.
4
+ *
5
+ * @param options Command options for the core-variation scaffold workflow.
6
+ * @param options.cwd Working directory used to resolve the nearest official workspace.
7
+ * Defaults to `process.cwd()`.
8
+ * @param options.targetBlockName Full `namespace/block` name that receives the variation.
9
+ * @param options.variationName Human-entered variation name normalized into the generated slug.
10
+ * @returns The normalized variation metadata and owning workspace directory.
11
+ * @throws {Error} When the command is run outside an official workspace, the
12
+ * target block name is not full `namespace/block` form, or the generated file
13
+ * already exists.
14
+ */
15
+ export declare function runAddCoreVariationCommand({ cwd, targetBlockName, variationName, }: RunAddCoreVariationCommandOptions): Promise<{
16
+ projectDir: string;
17
+ targetBlockName: string;
18
+ variationFile: string;
19
+ variationSlug: string;
20
+ }>;
@@ -0,0 +1,322 @@
1
+ import fs, { promises as fsp } from "node:fs";
2
+ import path from "node:path";
3
+ import { assertFullBlockName } from "./block-targets.js";
4
+ import { assertValidGeneratedSlug, normalizeBlockSlug, quoteTsString, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
5
+ import { ensureEditorPluginBootstrapAnchors, ensureEditorPluginBuildScriptAnchors, ensureEditorPluginWebpackAnchors, resolveEditorPluginRegistryPath, writeEditorPluginRegistry, } from "./cli-add-workspace-editor-plugin.js";
6
+ import { pathExists } from "./fs-async.js";
7
+ import { toKebabCase, toPascalCase, toTitleCase } from "./string-case.js";
8
+ import { resolveWorkspaceProject } from "./workspace-project.js";
9
+ const CORE_VARIATIONS_EDITOR_PLUGIN_SLUG = "core-variations";
10
+ const CORE_VARIATION_USAGE = "wp-typia add core-variation <block-name> <name> or wp-typia add core-variation <name> --block <namespace/block>";
11
+ const CORE_VARIATION_SIMPLE_CONTAINER_BLOCKS = new Set([
12
+ "core/column",
13
+ "core/cover",
14
+ "core/group",
15
+ "core/media-text",
16
+ ]);
17
+ function getCoreVariationRootDir(projectDir) {
18
+ return path.join(projectDir, "src", "editor-plugins", CORE_VARIATIONS_EDITOR_PLUGIN_SLUG);
19
+ }
20
+ function getCoreVariationBlockDir(projectDir, targetBlockName) {
21
+ const [namespace, blockSlug] = targetBlockName.split("/");
22
+ return path.join(getCoreVariationRootDir(projectDir), namespace ?? "", blockSlug ?? "");
23
+ }
24
+ function getCoreVariationFilePath(projectDir, targetBlockName, variationSlug) {
25
+ return path.join(getCoreVariationBlockDir(projectDir, targetBlockName), `${variationSlug}.ts`);
26
+ }
27
+ function getCoreVariationIndexPath(projectDir) {
28
+ return path.join(getCoreVariationRootDir(projectDir), "index.ts");
29
+ }
30
+ function buildCoreVariationIdentifier(targetBlockName, variationSlug) {
31
+ return toKebabCase(`${targetBlockName}-${variationSlug}`)
32
+ .split("-")
33
+ .filter(Boolean)
34
+ .join("_");
35
+ }
36
+ function buildCoreVariationConstName(targetBlockName, variationSlug) {
37
+ return `coreVariation_${buildCoreVariationIdentifier(targetBlockName, variationSlug)}`;
38
+ }
39
+ function buildCoreVariationBlockConstName(targetBlockName, variationSlug) {
40
+ return `${buildCoreVariationIdentifier(targetBlockName, variationSlug).toUpperCase()}_BLOCK_NAME`;
41
+ }
42
+ function buildCoreVariationAttributesTypeName(targetBlockName, variationSlug) {
43
+ return `${toPascalCase(`${targetBlockName}-${variationSlug}`)}Attributes`;
44
+ }
45
+ function buildCoreVariationAttributesConstName(targetBlockName, variationSlug) {
46
+ return `${buildCoreVariationIdentifier(targetBlockName, variationSlug)}Attributes`;
47
+ }
48
+ function buildCoreVariationInnerBlocksConstName(targetBlockName, variationSlug) {
49
+ return `${buildCoreVariationIdentifier(targetBlockName, variationSlug)}InnerBlocks`;
50
+ }
51
+ function buildCoreVariationImportPath(ref) {
52
+ return `./${ref.targetBlockName}/${ref.variationSlug}`;
53
+ }
54
+ function formatCoreVariationTitle(variationSlug) {
55
+ return toTitleCase(variationSlug);
56
+ }
57
+ function assertCoreVariationDoesNotExist(projectDir, targetBlockName, variationSlug) {
58
+ const variationFilePath = getCoreVariationFilePath(projectDir, targetBlockName, variationSlug);
59
+ if (fs.existsSync(variationFilePath)) {
60
+ throw new Error(`A core block variation already exists at ${path.relative(projectDir, variationFilePath)}. Choose a different name.`);
61
+ }
62
+ }
63
+ function assertCoreVariationSlugIsNotRegistryIndex(variationSlug) {
64
+ if (variationSlug === "index") {
65
+ throw new Error("Core variation name must not normalize to `index`. Choose a different name so the variation module can be registered.");
66
+ }
67
+ }
68
+ function buildCoreVariationInnerBlocksSource(options) {
69
+ if (options.targetBlockName === "core/columns") {
70
+ return `export const ${options.constName} = [
71
+ \t[
72
+ \t\t'core/column',
73
+ \t\t{},
74
+ \t\t[
75
+ \t\t\t[
76
+ \t\t\t\t'core/heading',
77
+ \t\t\t\t{
78
+ \t\t\t\t\tlevel: 2,
79
+ \t\t\t\t\tplaceholder: __( ${quoteTsString("Add a section heading")}, ${quoteTsString(options.textDomain)} ),
80
+ \t\t\t\t},
81
+ \t\t\t],
82
+ \t\t\t[
83
+ \t\t\t\t'core/paragraph',
84
+ \t\t\t\t{
85
+ \t\t\t\t\tplaceholder: __( ${quoteTsString("Add supporting copy")}, ${quoteTsString(options.textDomain)} ),
86
+ \t\t\t\t},
87
+ \t\t\t],
88
+ \t\t],
89
+ \t],
90
+ ] satisfies BlockTemplate;`;
91
+ }
92
+ if (CORE_VARIATION_SIMPLE_CONTAINER_BLOCKS.has(options.targetBlockName)) {
93
+ return `export const ${options.constName} = [
94
+ \t[
95
+ \t\t'core/heading',
96
+ \t\t{
97
+ \t\t\tlevel: 2,
98
+ \t\t\tplaceholder: __( ${quoteTsString("Add a section heading")}, ${quoteTsString(options.textDomain)} ),
99
+ \t\t},
100
+ \t],
101
+ \t[
102
+ \t\t'core/paragraph',
103
+ \t\t{
104
+ \t\t\tplaceholder: __( ${quoteTsString("Add supporting copy")}, ${quoteTsString(options.textDomain)} ),
105
+ \t\t},
106
+ \t],
107
+ ] satisfies BlockTemplate;`;
108
+ }
109
+ return `// Non-container core blocks can keep this empty or replace it with a
110
+ // block-supported InnerBlocks template when the target block accepts children.
111
+ export const ${options.constName} = [] satisfies BlockTemplate;`;
112
+ }
113
+ function buildCoreVariationSource(options) {
114
+ const attributesTypeName = buildCoreVariationAttributesTypeName(options.targetBlockName, options.variationSlug);
115
+ const blockConstName = buildCoreVariationBlockConstName(options.targetBlockName, options.variationSlug);
116
+ const attributesConstName = buildCoreVariationAttributesConstName(options.targetBlockName, options.variationSlug);
117
+ const innerBlocksConstName = buildCoreVariationInnerBlocksConstName(options.targetBlockName, options.variationSlug);
118
+ const variationConstName = buildCoreVariationConstName(options.targetBlockName, options.variationSlug);
119
+ const variationTitle = formatCoreVariationTitle(options.variationSlug);
120
+ const variationClassName = `is-${options.variationSlug}`;
121
+ return `import type {
122
+ \tBlockTemplate,
123
+ \tBlockVariation,
124
+ } from '@wp-typia/block-types/blocks/registration';
125
+ import { __ } from '@wordpress/i18n';
126
+
127
+ export const ${blockConstName} = ${quoteTsString(options.targetBlockName)};
128
+
129
+ export interface ${attributesTypeName} {
130
+ \tclassName?: string;
131
+ \tmetadata?: {
132
+ \t\tname?: string;
133
+ \t};
134
+ \t[key: string]: unknown;
135
+ }
136
+
137
+ export const ${attributesConstName} = {
138
+ \tclassName: ${quoteTsString(variationClassName)},
139
+ \tmetadata: {
140
+ \t\tname: ${quoteTsString(variationTitle)},
141
+ \t},
142
+ } satisfies ${attributesTypeName};
143
+
144
+ ${buildCoreVariationInnerBlocksSource({
145
+ constName: innerBlocksConstName,
146
+ targetBlockName: options.targetBlockName,
147
+ textDomain: options.textDomain,
148
+ })}
149
+
150
+ export const ${variationConstName} = {
151
+ \tname: ${quoteTsString(options.variationSlug)},
152
+ \ttitle: __( ${quoteTsString(variationTitle)}, ${quoteTsString(options.textDomain)} ),
153
+ \tdescription: __(
154
+ \t\t${quoteTsString(`A starter ${options.targetBlockName} variation for ${variationTitle}.`)},
155
+ \t\t${quoteTsString(options.textDomain)},
156
+ \t),
157
+ \tcategory: 'design',
158
+ \ticon: 'layout',
159
+ \tkeywords: [
160
+ \t\t__( ${quoteTsString("variation")}, ${quoteTsString(options.textDomain)} ),
161
+ \t\t__( ${quoteTsString(variationTitle)}, ${quoteTsString(options.textDomain)} ),
162
+ \t],
163
+ \tattributes: ${attributesConstName},
164
+ \tinnerBlocks: ${innerBlocksConstName},
165
+ \tisActive: ['className'],
166
+ \tscope: ['block', 'inserter', 'transform'],
167
+ } satisfies BlockVariation<${attributesTypeName}>;
168
+ `;
169
+ }
170
+ async function readCoreVariationModuleRefs(coreVariationsDir) {
171
+ if (!(await pathExists(coreVariationsDir))) {
172
+ return [];
173
+ }
174
+ const refs = [];
175
+ const namespaceEntries = await fsp.readdir(coreVariationsDir, {
176
+ withFileTypes: true,
177
+ });
178
+ for (const namespaceEntry of namespaceEntries) {
179
+ if (!namespaceEntry.isDirectory()) {
180
+ continue;
181
+ }
182
+ const namespaceDir = path.join(coreVariationsDir, namespaceEntry.name);
183
+ const blockEntries = await fsp.readdir(namespaceDir, {
184
+ withFileTypes: true,
185
+ });
186
+ for (const blockEntry of blockEntries) {
187
+ if (!blockEntry.isDirectory()) {
188
+ continue;
189
+ }
190
+ const blockDir = path.join(namespaceDir, blockEntry.name);
191
+ const variationEntries = await fsp.readdir(blockDir, {
192
+ withFileTypes: true,
193
+ });
194
+ for (const variationEntry of variationEntries) {
195
+ if (!variationEntry.isFile() || !variationEntry.name.endsWith(".ts")) {
196
+ continue;
197
+ }
198
+ const variationSlug = variationEntry.name.replace(/\.ts$/u, "");
199
+ if (variationSlug === "index") {
200
+ continue;
201
+ }
202
+ refs.push({
203
+ targetBlockName: `${namespaceEntry.name}/${blockEntry.name}`,
204
+ variationSlug,
205
+ });
206
+ }
207
+ }
208
+ }
209
+ return refs.sort((left, right) => {
210
+ const leftKey = `${left.targetBlockName}/${left.variationSlug}`;
211
+ const rightKey = `${right.targetBlockName}/${right.variationSlug}`;
212
+ return leftKey.localeCompare(rightKey);
213
+ });
214
+ }
215
+ function buildCoreVariationIndexSource(refs) {
216
+ const importLines = refs
217
+ .map((ref, index) => {
218
+ const blockConstName = buildCoreVariationBlockConstName(ref.targetBlockName, ref.variationSlug);
219
+ const variationConstName = buildCoreVariationConstName(ref.targetBlockName, ref.variationSlug);
220
+ return `import { ${blockConstName} as CORE_VARIATION_BLOCK_${index}, ${variationConstName} as coreVariationEntry${index} } from '${buildCoreVariationImportPath(ref)}';`;
221
+ })
222
+ .join("\n");
223
+ const entryLines = refs
224
+ .map((_, index) => {
225
+ return `\t{ blockName: CORE_VARIATION_BLOCK_${index}, variation: coreVariationEntry${index} },`;
226
+ })
227
+ .join("\n");
228
+ return `import { registerBlockVariation } from '@wordpress/blocks';
229
+ ${importLines ? `\n${importLines}\n` : ""}
230
+ const WORKSPACE_CORE_VARIATIONS = [
231
+ ${entryLines}
232
+ ] as const;
233
+
234
+ export function registerWorkspaceCoreVariations() {
235
+ \tfor (const { blockName, variation } of WORKSPACE_CORE_VARIATIONS) {
236
+ \t\tregisterBlockVariation(blockName, variation);
237
+ \t}
238
+ }
239
+
240
+ registerWorkspaceCoreVariations();
241
+ `;
242
+ }
243
+ async function writeCoreVariationRegistry(projectDir, targetBlockName, textDomain, variationSlug) {
244
+ const coreVariationsDir = getCoreVariationRootDir(projectDir);
245
+ const targetBlockDir = getCoreVariationBlockDir(projectDir, targetBlockName);
246
+ const variationFilePath = getCoreVariationFilePath(projectDir, targetBlockName, variationSlug);
247
+ await fsp.mkdir(targetBlockDir, { recursive: true });
248
+ await fsp.writeFile(variationFilePath, buildCoreVariationSource({
249
+ targetBlockName,
250
+ textDomain,
251
+ variationSlug,
252
+ }), "utf8");
253
+ const refs = await readCoreVariationModuleRefs(coreVariationsDir);
254
+ await fsp.writeFile(getCoreVariationIndexPath(projectDir), buildCoreVariationIndexSource(refs), "utf8");
255
+ }
256
+ /**
257
+ * Add one editor-side variation registration for an existing core or external block.
258
+ *
259
+ * @param options Command options for the core-variation scaffold workflow.
260
+ * @param options.cwd Working directory used to resolve the nearest official workspace.
261
+ * Defaults to `process.cwd()`.
262
+ * @param options.targetBlockName Full `namespace/block` name that receives the variation.
263
+ * @param options.variationName Human-entered variation name normalized into the generated slug.
264
+ * @returns The normalized variation metadata and owning workspace directory.
265
+ * @throws {Error} When the command is run outside an official workspace, the
266
+ * target block name is not full `namespace/block` form, or the generated file
267
+ * already exists.
268
+ */
269
+ export async function runAddCoreVariationCommand({ cwd = process.cwd(), targetBlockName, variationName, }) {
270
+ const workspace = resolveWorkspaceProject(cwd);
271
+ const resolvedTargetBlockName = assertFullBlockName(targetBlockName, "core-variation target");
272
+ const variationSlug = assertValidGeneratedSlug("Core variation name", normalizeBlockSlug(variationName), CORE_VARIATION_USAGE);
273
+ assertCoreVariationSlugIsNotRegistryIndex(variationSlug);
274
+ assertCoreVariationDoesNotExist(workspace.projectDir, resolvedTargetBlockName, variationSlug);
275
+ const bootstrapPath = path.join(workspace.projectDir, `${workspace.packageName.split("/").pop() ?? workspace.packageName}.php`);
276
+ const buildScriptPath = path.join(workspace.projectDir, "scripts", "build-workspace.mjs");
277
+ const webpackConfigPath = path.join(workspace.projectDir, "webpack.config.js");
278
+ const editorPluginsIndexPath = await resolveEditorPluginRegistryPath(workspace.projectDir);
279
+ const coreVariationsDir = getCoreVariationRootDir(workspace.projectDir);
280
+ const targetNamespaceDir = path.join(coreVariationsDir, resolvedTargetBlockName.split("/")[0] ?? "");
281
+ const targetBlockDir = getCoreVariationBlockDir(workspace.projectDir, resolvedTargetBlockName);
282
+ const variationFilePath = getCoreVariationFilePath(workspace.projectDir, resolvedTargetBlockName, variationSlug);
283
+ const coreVariationsIndexPath = getCoreVariationIndexPath(workspace.projectDir);
284
+ const shouldRemoveCoreVariationsDir = !(await pathExists(coreVariationsDir));
285
+ const shouldRemoveTargetNamespaceDir = !shouldRemoveCoreVariationsDir && !(await pathExists(targetNamespaceDir));
286
+ const shouldRemoveTargetBlockDir = !shouldRemoveCoreVariationsDir &&
287
+ !shouldRemoveTargetNamespaceDir &&
288
+ !(await pathExists(targetBlockDir));
289
+ const mutationSnapshot = {
290
+ fileSources: await snapshotWorkspaceFiles([
291
+ bootstrapPath,
292
+ buildScriptPath,
293
+ editorPluginsIndexPath,
294
+ webpackConfigPath,
295
+ coreVariationsIndexPath,
296
+ ]),
297
+ snapshotDirs: [],
298
+ targetPaths: [
299
+ variationFilePath,
300
+ ...(shouldRemoveCoreVariationsDir ? [coreVariationsDir] : []),
301
+ ...(shouldRemoveTargetNamespaceDir ? [targetNamespaceDir] : []),
302
+ ...(shouldRemoveTargetBlockDir ? [targetBlockDir] : []),
303
+ ],
304
+ };
305
+ try {
306
+ await ensureEditorPluginBootstrapAnchors(workspace);
307
+ await ensureEditorPluginBuildScriptAnchors(workspace);
308
+ await ensureEditorPluginWebpackAnchors(workspace);
309
+ await writeCoreVariationRegistry(workspace.projectDir, resolvedTargetBlockName, workspace.workspace.textDomain, variationSlug);
310
+ await writeEditorPluginRegistry(workspace.projectDir, CORE_VARIATIONS_EDITOR_PLUGIN_SLUG);
311
+ return {
312
+ projectDir: workspace.projectDir,
313
+ targetBlockName: resolvedTargetBlockName,
314
+ variationFile: path.relative(workspace.projectDir, variationFilePath),
315
+ variationSlug,
316
+ };
317
+ }
318
+ catch (error) {
319
+ await rollbackWorkspaceMutation(mutationSnapshot);
320
+ throw error;
321
+ }
322
+ }
@@ -0,0 +1,37 @@
1
+ import type { WorkspaceProject } from "./workspace-project.js";
2
+ /**
3
+ * Ensures the workspace bootstrap enqueues the shared editor plugin bundle.
4
+ *
5
+ * @param workspace Official workspace metadata used to locate and patch the bootstrap file.
6
+ * @returns A promise that resolves after the bootstrap anchors are present.
7
+ */
8
+ export declare function ensureEditorPluginBootstrapAnchors(workspace: WorkspaceProject): Promise<void>;
9
+ /**
10
+ * Ensures the workspace build script includes the shared editor plugin entry.
11
+ *
12
+ * @param workspace Official workspace metadata used to locate the build script.
13
+ * @returns A promise that resolves after the build script anchors are present.
14
+ */
15
+ export declare function ensureEditorPluginBuildScriptAnchors(workspace: WorkspaceProject): Promise<void>;
16
+ /**
17
+ * Ensures the workspace webpack config builds the shared editor plugin entry.
18
+ *
19
+ * @param workspace Official workspace metadata used to locate the webpack config.
20
+ * @returns A promise that resolves after the webpack anchors are present.
21
+ */
22
+ export declare function ensureEditorPluginWebpackAnchors(workspace: WorkspaceProject): Promise<void>;
23
+ /**
24
+ * Resolves the editor plugin registry path, preferring existing TypeScript or JavaScript registries.
25
+ *
26
+ * @param projectDir Workspace root directory to inspect.
27
+ * @returns A promise for the registry path to read or write.
28
+ */
29
+ export declare function resolveEditorPluginRegistryPath(projectDir: string): Promise<string>;
30
+ /**
31
+ * Rewrites the shared editor plugin registry with the requested plugin slug included.
32
+ *
33
+ * @param projectDir Workspace root directory that owns `src/editor-plugins`.
34
+ * @param editorPluginSlug Editor plugin slug that must be imported by the registry.
35
+ * @returns A promise that resolves after the registry has been written.
36
+ */
37
+ export declare function writeEditorPluginRegistry(projectDir: string, editorPluginSlug: string): Promise<void>;