wp-typia 0.22.7 → 0.22.8

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.
@@ -6,13 +6,12 @@ import {
6
6
  copyInterpolatedDirectory,
7
7
  createScaffoldCompatibilityConfig,
8
8
  getDefaultAnswers,
9
+ isCompoundPersistenceEnabled,
9
10
  listInterpolatedDirectoryOutputs,
10
11
  normalizeOptionalCliString,
11
12
  parseAlternateRenderTargets,
12
13
  parseCompoundInnerBlocksPreset,
13
- parseTemplateLocator,
14
14
  renderScaffoldCompatibilityConfig,
15
- require_semver,
16
15
  resolveExternalTemplateLayers,
17
16
  resolveLocalCliPathOption,
18
17
  resolveOptionalInteractiveExternalLayerId,
@@ -21,7 +20,7 @@ import {
21
20
  scaffoldProject,
22
21
  syncPersistenceRestArtifacts,
23
22
  updatePluginHeaderCompatibility
24
- } from "./cli-8snabymq.js";
23
+ } from "./cli-fa7g1aqm.js";
25
24
  import {
26
25
  DEFAULT_WORDPRESS_ABILITIES_VERSION,
27
26
  DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION,
@@ -31,10 +30,14 @@ import {
31
30
  DEFAULT_WP_TYPIA_DATAVIEWS_VERSION,
32
31
  getPackageVersions,
33
32
  resolveManagedPackageVersionRange
34
- } from "./cli-2hsp17nd.js";
33
+ } from "./cli-arz4rcye.js";
34
+ import {
35
+ parseTemplateLocator,
36
+ require_semver
37
+ } from "./cli-mzvzbpnz.js";
35
38
  import {
36
39
  snapshotProjectVersion
37
- } from "./cli-27v2qpjg.js";
40
+ } from "./cli-bwwssctv.js";
38
41
  import {
39
42
  ensureMigrationDirectories,
40
43
  parseMigrationConfig,
@@ -48,10 +51,10 @@ import {
48
51
  hasUncommentedPattern,
49
52
  maskTypeScriptCommentsAndLiterals
50
53
  } from "./cli-rwjkqjhs.js";
51
- import"./cli-10pe4mf8.js";
54
+ import"./cli-pnjx2e2h.js";
52
55
  import {
53
56
  SHARED_WORKSPACE_TEMPLATE_ROOT
54
- } from "./cli-tke8twkn.js";
57
+ } from "./cli-qse6myha.js";
55
58
  import {
56
59
  ADD_BLOCK_TEMPLATE_IDS,
57
60
  EDITOR_PLUGIN_SLOT_IDS,
@@ -76,6 +79,7 @@ import {
76
79
  findPhpFunctionRange,
77
80
  formatAddHelpText,
78
81
  getMutableBlockHooks,
82
+ getPropertyNameText,
79
83
  getWorkspaceBlockSelectOptions,
80
84
  getWorkspaceBootstrapPath,
81
85
  hasPhpFunctionCall,
@@ -87,8 +91,9 @@ import {
87
91
  quotePhpString,
88
92
  quoteTsString,
89
93
  readOptionalFile,
94
+ readOptionalUtf8File,
90
95
  readWorkspaceBlockJson,
91
- readWorkspaceInventory,
96
+ readWorkspaceInventoryAsync,
92
97
  replacePhpFunctionDefinition,
93
98
  require_typescript,
94
99
  resolveNonEmptyNormalizedBlockSlug,
@@ -101,7 +106,7 @@ import {
101
106
  toPascalCase,
102
107
  toSnakeCase,
103
108
  toTitleCase
104
- } from "./cli-ta3y0hp2.js";
109
+ } from "./cli-bbj0kn1e.js";
105
110
  import {
106
111
  createManagedTempRoot
107
112
  } from "./cli-t73q5aqz.js";
@@ -228,7 +233,7 @@ function buildConfigEntries(templateId, variables) {
228
233
  if (templateId === "persistence") {
229
234
  return [buildPersistenceBlockConfigEntry(variables)];
230
235
  }
231
- if (variables.compoundPersistenceEnabled === "true") {
236
+ if (isCompoundPersistenceEnabled(variables)) {
232
237
  return [
233
238
  buildPersistenceBlockConfigEntry(variables),
234
239
  buildCompoundChildConfigEntry(variables)
@@ -504,7 +509,7 @@ async function copyScaffoldedBlockSlice(projectDir, templateId, tempProjectDir,
504
509
  await ensureCompoundWorkspaceSupportFiles(projectDir, tempProjectDir, legacyValidatorPaths);
505
510
  await copyTempDirectory(path3.join(tempProjectDir, "src", "blocks", variables.slugKebabCase), path3.join(projectDir, "src", "blocks", variables.slugKebabCase));
506
511
  await copyTempDirectory(path3.join(tempProjectDir, "src", "blocks", `${variables.slugKebabCase}-item`), path3.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`));
507
- if (variables.compoundPersistenceEnabled === "true") {
512
+ if (isCompoundPersistenceEnabled(variables)) {
508
513
  await renderWorkspacePersistenceServerModule(projectDir, variables);
509
514
  }
510
515
  return;
@@ -617,7 +622,7 @@ async function syncWorkspaceAddedBlockArtifacts(projectDir, templateId, variable
617
622
  if (templateId === "compound") {
618
623
  await syncWorkspaceBlockMetadata(projectDir, `${variables.slugKebabCase}-item`, `${variables.pascalCase}ItemAttributes`, path3.join("src", "blocks", `${variables.slugKebabCase}-item`, "types.ts"));
619
624
  }
620
- if (templateId === "persistence" || templateId === "compound" && variables.compoundPersistenceEnabled === "true") {
625
+ if (templateId === "persistence" || templateId === "compound" && isCompoundPersistenceEnabled(variables)) {
621
626
  await syncWorkspacePersistenceArtifacts(projectDir, variables);
622
627
  }
623
628
  }
@@ -772,7 +777,7 @@ async function runAddBlockCommand({
772
777
  try {
773
778
  await copyScaffoldedBlockSlice(workspace.projectDir, resolvedTemplateId, tempProjectDir, result.variables, legacyCompoundValidatorPaths);
774
779
  await addCollectionImportsForTemplate(workspace.projectDir, resolvedTemplateId, result.variables);
775
- await appendBlockConfigEntries(workspace.projectDir, buildConfigEntries(resolvedTemplateId, result.variables), resolvedTemplateId === "persistence" || resolvedTemplateId === "compound" && result.variables.compoundPersistenceEnabled === "true");
780
+ await appendBlockConfigEntries(workspace.projectDir, buildConfigEntries(resolvedTemplateId, result.variables), resolvedTemplateId === "persistence" || resolvedTemplateId === "compound" && isCompoundPersistenceEnabled(result.variables));
776
781
  await syncWorkspaceAddedBlockArtifacts(workspace.projectDir, resolvedTemplateId, result.variables);
777
782
  await updateWorkspaceMigrationConfigIfPresent(workspace.projectDir, buildMigrationBlocks(resolvedTemplateId, result.variables));
778
783
  return {
@@ -797,6 +802,49 @@ async function runAddBlockCommand({
797
802
  import { promises as fsp9 } from "fs";
798
803
  import path14 from "path";
799
804
 
805
+ // ../wp-typia-project-tools/src/runtime/block-targets.ts
806
+ var FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
807
+ function assertFullBlockName(blockName, flagName) {
808
+ const trimmed = blockName.trim();
809
+ if (!trimmed) {
810
+ throw new Error(`\`${flagName}\` requires a block name.`);
811
+ }
812
+ if (!FULL_BLOCK_NAME_PATTERN.test(trimmed)) {
813
+ throw new Error(`\`${flagName}\` must use <namespace/block-slug> format.`);
814
+ }
815
+ return trimmed;
816
+ }
817
+ function resolveWorkspaceBlockTargetName(blockName, namespace, diagnostics) {
818
+ const trimmed = blockName.trim();
819
+ if (!trimmed) {
820
+ throw new Error(diagnostics.empty());
821
+ }
822
+ const blockNameSegments = trimmed.split("/");
823
+ if (blockNameSegments.length > 2) {
824
+ throw new Error(diagnostics.invalidFormat(trimmed));
825
+ }
826
+ if (blockNameSegments.some((segment) => segment.trim() === "")) {
827
+ throw new Error(diagnostics.emptySegment(trimmed));
828
+ }
829
+ const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
830
+ if (maybeNamespace && maybeNamespace !== namespace) {
831
+ throw new Error(diagnostics.namespaceMismatch(trimmed, maybeNamespace, namespace));
832
+ }
833
+ const blockSlug = normalizeBlockSlug(maybeSlug ?? "");
834
+ return {
835
+ blockName: `${namespace}/${blockSlug}`,
836
+ blockSlug
837
+ };
838
+ }
839
+ function resolveWorkspaceTargetBlockName(blockName, namespace, flagName) {
840
+ return resolveWorkspaceBlockTargetName(blockName, namespace, {
841
+ empty: () => `\`${flagName}\` requires <block-slug|namespace/block-slug>.`,
842
+ emptySegment: () => `\`${flagName}\` must use <block-slug|namespace/block-slug> format.`,
843
+ invalidFormat: () => `\`${flagName}\` must use <block-slug|namespace/block-slug> format.`,
844
+ namespaceMismatch: (_input, actualNamespace, expectedNamespace) => `\`${flagName}\` references namespace "${actualNamespace}". Expected "${expectedNamespace}".`
845
+ });
846
+ }
847
+
800
848
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-types.ts
801
849
  var ADMIN_VIEW_REST_SOURCE_KIND = "rest-resource";
802
850
  var ADMIN_VIEW_CORE_DATA_SOURCE_KIND = "core-data";
@@ -904,7 +952,6 @@ function resolveAdminViewCoreDataSource(source) {
904
952
  }
905
953
 
906
954
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-scaffold.ts
907
- import fs2 from "fs";
908
955
  import { promises as fsp3 } from "fs";
909
956
  import path5 from "path";
910
957
 
@@ -2085,26 +2132,31 @@ async function ensureAdminViewWebpackAnchors(workspace) {
2085
2132
  return nextSource;
2086
2133
  });
2087
2134
  }
2088
- function resolveAdminViewRegistryPath(projectDir) {
2135
+ async function resolveAdminViewRegistryPath(projectDir) {
2089
2136
  const adminViewsDir = path5.join(projectDir, "src", "admin-views");
2090
- return [
2137
+ for (const candidatePath of [
2091
2138
  path5.join(adminViewsDir, "index.ts"),
2092
2139
  path5.join(adminViewsDir, "index.js")
2093
- ].find((candidatePath) => fs2.existsSync(candidatePath)) ?? path5.join(adminViewsDir, "index.ts");
2140
+ ]) {
2141
+ if (await pathExists(candidatePath)) {
2142
+ return candidatePath;
2143
+ }
2144
+ }
2145
+ return path5.join(adminViewsDir, "index.ts");
2094
2146
  }
2095
- function readAdminViewRegistrySlugs(registryPath) {
2096
- if (!fs2.existsSync(registryPath)) {
2147
+ async function readAdminViewRegistrySlugs(registryPath) {
2148
+ const source = await readOptionalUtf8File(registryPath);
2149
+ if (source === null) {
2097
2150
  return [];
2098
2151
  }
2099
- const source = fs2.readFileSync(registryPath, "utf8");
2100
2152
  return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
2101
2153
  }
2102
2154
  async function writeAdminViewRegistry(projectDir, adminViewSlug) {
2103
2155
  const adminViewsDir = path5.join(projectDir, "src", "admin-views");
2104
- const registryPath = resolveAdminViewRegistryPath(projectDir);
2156
+ const registryPath = await resolveAdminViewRegistryPath(projectDir);
2105
2157
  await fsp3.mkdir(adminViewsDir, { recursive: true });
2106
- const existingAdminViewSlugs = readWorkspaceInventory(projectDir).adminViews.map((entry) => entry.slug);
2107
- const existingRegistrySlugs = readAdminViewRegistrySlugs(registryPath);
2158
+ const existingAdminViewSlugs = (await readWorkspaceInventoryAsync(projectDir)).adminViews.map((entry) => entry.slug);
2159
+ const existingRegistrySlugs = await readAdminViewRegistrySlugs(registryPath);
2108
2160
  const nextAdminViewSlugs = Array.from(new Set([
2109
2161
  ...existingAdminViewSlugs,
2110
2162
  ...existingRegistrySlugs,
@@ -2125,7 +2177,7 @@ async function scaffoldAdminViewWorkspace(options) {
2125
2177
  const buildScriptPath = path5.join(workspace.projectDir, "scripts", "build-workspace.mjs");
2126
2178
  const packageJsonPath = path5.join(workspace.projectDir, "package.json");
2127
2179
  const webpackConfigPath = path5.join(workspace.projectDir, "webpack.config.js");
2128
- const adminViewsIndexPath = resolveAdminViewRegistryPath(workspace.projectDir);
2180
+ const adminViewsIndexPath = await resolveAdminViewRegistryPath(workspace.projectDir);
2129
2181
  const adminViewDir = path5.join(workspace.projectDir, "src", "admin-views", adminViewSlug);
2130
2182
  const adminViewPhpPath = path5.join(workspace.projectDir, "inc", "admin-views", `${adminViewSlug}.php`);
2131
2183
  await executeWorkspaceMutationPlan({
@@ -2173,7 +2225,7 @@ async function runAddAdminViewCommand({
2173
2225
  assertAdminViewPackageAvailability();
2174
2226
  const adminViewSlug = assertValidGeneratedSlug("Admin view name", normalizeBlockSlug(adminViewName), ADD_ADMIN_VIEW_USAGE);
2175
2227
  const parsedSource = parseAdminViewSource(source);
2176
- const inventory = readWorkspaceInventory(workspace.projectDir);
2228
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
2177
2229
  const restResource = resolveRestResourceSource(inventory.restResources, parsedSource);
2178
2230
  const coreDataSource = resolveAdminViewCoreDataSource(parsedSource);
2179
2231
  assertAdminViewDoesNotExist(workspace.projectDir, adminViewSlug, inventory);
@@ -2192,7 +2244,6 @@ async function runAddAdminViewCommand({
2192
2244
  }
2193
2245
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-assets.ts
2194
2246
  var import_typescript = __toESM(require_typescript(), 1);
2195
- import fs3 from "fs";
2196
2247
  import { promises as fsp4 } from "fs";
2197
2248
  import path6 from "path";
2198
2249
  import {
@@ -2238,24 +2289,6 @@ function assertValidBindingAttributeName(attributeName) {
2238
2289
  }
2239
2290
  return trimmed;
2240
2291
  }
2241
- function resolveBindingTargetBlockSlug(blockName, namespace) {
2242
- const trimmed = blockName.trim();
2243
- if (!trimmed) {
2244
- throw new Error("`wp-typia add binding-source` requires --block <block-slug|namespace/block-slug> to include a value when --attribute is provided.");
2245
- }
2246
- const blockNameSegments = trimmed.split("/");
2247
- if (blockNameSegments.length > 2) {
2248
- throw new Error(`Binding target block "${trimmed}" must use <block-slug> or <namespace/block-slug> format.`);
2249
- }
2250
- if (blockNameSegments.some((segment) => segment.trim() === "")) {
2251
- throw new Error(`Binding target block "${trimmed}" must use <block-slug> or <namespace/block-slug> format without empty path segments.`);
2252
- }
2253
- const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
2254
- if (maybeNamespace && maybeNamespace !== namespace) {
2255
- throw new Error(`Binding target block "${trimmed}" uses namespace "${maybeNamespace}". Expected "${namespace}".`);
2256
- }
2257
- return normalizeBlockSlug(maybeSlug ?? "");
2258
- }
2259
2292
  function buildEditorPluginConfigEntry(editorPluginSlug, slot) {
2260
2293
  return [
2261
2294
  "\t{",
@@ -2420,9 +2453,15 @@ function resolveBindingTarget(options, namespace) {
2420
2453
  if (!hasBlock || !hasAttribute) {
2421
2454
  throw new Error("`wp-typia add binding-source` requires --block and --attribute to be provided together.");
2422
2455
  }
2456
+ const targetBlock = resolveWorkspaceBlockTargetName(blockName ?? "", namespace, {
2457
+ empty: () => "`wp-typia add binding-source` requires --block <block-slug|namespace/block-slug> to include a value when --attribute is provided.",
2458
+ emptySegment: (input) => `Binding target block "${input}" must use <block-slug> or <namespace/block-slug> format without empty path segments.`,
2459
+ invalidFormat: (input) => `Binding target block "${input}" must use <block-slug> or <namespace/block-slug> format.`,
2460
+ namespaceMismatch: (input, actualNamespace, expectedNamespace) => `Binding target block "${input}" uses namespace "${actualNamespace}". Expected "${expectedNamespace}".`
2461
+ });
2423
2462
  return {
2424
2463
  attributeName: assertValidBindingAttributeName(attributeName ?? ""),
2425
- blockSlug: resolveBindingTargetBlockSlug(blockName ?? "", namespace)
2464
+ blockSlug: targetBlock.blockSlug
2426
2465
  };
2427
2466
  }
2428
2467
  function formatBindingAttributeTypeMember(attributeName) {
@@ -2448,12 +2487,6 @@ function getInterfaceDeclaration(source, interfaceName) {
2448
2487
  visit(sourceFile);
2449
2488
  return declaration ? { declaration, sourceFile } : undefined;
2450
2489
  }
2451
- function getPropertyNameText(name) {
2452
- if (import_typescript.default.isIdentifier(name) || import_typescript.default.isStringLiteral(name) || import_typescript.default.isNumericLiteral(name)) {
2453
- return name.text;
2454
- }
2455
- return;
2456
- }
2457
2490
  function interfaceHasAttributeMember(declaration, attributeName) {
2458
2491
  return declaration.members.some((member) => import_typescript.default.isPropertySignature(member) && member.name !== undefined && getPropertyNameText(member.name) === attributeName);
2459
2492
  }
@@ -2930,38 +2963,51 @@ async function ensureEditorPluginWebpackAnchors(workspace) {
2930
2963
  return nextSource;
2931
2964
  });
2932
2965
  }
2933
- function resolveBindingSourceRegistryPath(projectDir) {
2966
+ async function resolveBindingSourceRegistryPath(projectDir) {
2934
2967
  const bindingsDir = path6.join(projectDir, "src", "bindings");
2935
- return [path6.join(bindingsDir, "index.ts"), path6.join(bindingsDir, "index.js")].find((candidatePath) => fs3.existsSync(candidatePath)) ?? path6.join(bindingsDir, "index.ts");
2968
+ for (const candidatePath of [
2969
+ path6.join(bindingsDir, "index.ts"),
2970
+ path6.join(bindingsDir, "index.js")
2971
+ ]) {
2972
+ if (await pathExists(candidatePath)) {
2973
+ return candidatePath;
2974
+ }
2975
+ }
2976
+ return path6.join(bindingsDir, "index.ts");
2936
2977
  }
2937
2978
  async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
2938
2979
  const bindingsDir = path6.join(projectDir, "src", "bindings");
2939
- const bindingsIndexPath = resolveBindingSourceRegistryPath(projectDir);
2980
+ const bindingsIndexPath = await resolveBindingSourceRegistryPath(projectDir);
2940
2981
  await fsp4.mkdir(bindingsDir, { recursive: true });
2941
- const existingBindingSourceSlugs = fs3.readdirSync(bindingsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
2982
+ const existingBindingSourceSlugs = (await fsp4.readdir(bindingsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
2942
2983
  const nextBindingSourceSlugs = Array.from(new Set([...existingBindingSourceSlugs, bindingSourceSlug])).sort();
2943
2984
  await fsp4.writeFile(bindingsIndexPath, buildBindingSourceIndexSource(nextBindingSourceSlugs), "utf8");
2944
2985
  }
2945
- function resolveEditorPluginRegistryPath(projectDir) {
2986
+ async function resolveEditorPluginRegistryPath(projectDir) {
2946
2987
  const editorPluginsDir = path6.join(projectDir, "src", "editor-plugins");
2947
- return [
2988
+ for (const candidatePath of [
2948
2989
  path6.join(editorPluginsDir, "index.ts"),
2949
2990
  path6.join(editorPluginsDir, "index.js")
2950
- ].find((candidatePath) => fs3.existsSync(candidatePath)) ?? path6.join(editorPluginsDir, "index.ts");
2991
+ ]) {
2992
+ if (await pathExists(candidatePath)) {
2993
+ return candidatePath;
2994
+ }
2995
+ }
2996
+ return path6.join(editorPluginsDir, "index.ts");
2951
2997
  }
2952
- function readEditorPluginRegistrySlugs(registryPath) {
2953
- if (!fs3.existsSync(registryPath)) {
2998
+ async function readEditorPluginRegistrySlugs(registryPath) {
2999
+ const source = await readOptionalUtf8File(registryPath);
3000
+ if (source === null) {
2954
3001
  return [];
2955
3002
  }
2956
- const source = fs3.readFileSync(registryPath, "utf8");
2957
3003
  return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
2958
3004
  }
2959
3005
  async function writeEditorPluginRegistry(projectDir, editorPluginSlug) {
2960
3006
  const editorPluginsDir = path6.join(projectDir, "src", "editor-plugins");
2961
- const registryPath = resolveEditorPluginRegistryPath(projectDir);
3007
+ const registryPath = await resolveEditorPluginRegistryPath(projectDir);
2962
3008
  await fsp4.mkdir(editorPluginsDir, { recursive: true });
2963
- const existingEditorPluginSlugs = readWorkspaceInventory(projectDir).editorPlugins.map((entry) => entry.slug);
2964
- const existingRegistrySlugs = readEditorPluginRegistrySlugs(registryPath);
3009
+ const existingEditorPluginSlugs = (await readWorkspaceInventoryAsync(projectDir)).editorPlugins.map((entry) => entry.slug);
3010
+ const existingRegistrySlugs = await readEditorPluginRegistrySlugs(registryPath);
2965
3011
  const nextEditorPluginSlugs = Array.from(new Set([...existingEditorPluginSlugs, ...existingRegistrySlugs, editorPluginSlug])).sort();
2966
3012
  await fsp4.writeFile(registryPath, buildEditorPluginRegistrySource(nextEditorPluginSlugs), "utf8");
2967
3013
  }
@@ -2973,12 +3019,12 @@ async function runAddEditorPluginCommand({
2973
3019
  const workspace = resolveWorkspaceProject(cwd);
2974
3020
  const editorPluginSlug = assertValidGeneratedSlug("Editor plugin name", normalizeBlockSlug(editorPluginName), "wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>]");
2975
3021
  const resolvedSlot = assertValidEditorPluginSlot(slot);
2976
- const inventory = readWorkspaceInventory(workspace.projectDir);
3022
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
2977
3023
  assertEditorPluginDoesNotExist(workspace.projectDir, editorPluginSlug, inventory);
2978
3024
  const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
2979
3025
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
2980
3026
  const buildScriptPath = path6.join(workspace.projectDir, "scripts", "build-workspace.mjs");
2981
- const editorPluginsIndexPath = resolveEditorPluginRegistryPath(workspace.projectDir);
3027
+ const editorPluginsIndexPath = await resolveEditorPluginRegistryPath(workspace.projectDir);
2982
3028
  const webpackConfigPath = path6.join(workspace.projectDir, "webpack.config.js");
2983
3029
  const editorPluginDir = path6.join(workspace.projectDir, "src", "editor-plugins", editorPluginSlug);
2984
3030
  const entryFilePath = path6.join(editorPluginDir, "index.tsx");
@@ -3029,7 +3075,7 @@ async function runAddPatternCommand({
3029
3075
  }) {
3030
3076
  const workspace = resolveWorkspaceProject(cwd);
3031
3077
  const patternSlug = assertValidGeneratedSlug("Pattern name", normalizeBlockSlug(patternName), "wp-typia add pattern <name>");
3032
- const inventory = readWorkspaceInventory(workspace.projectDir);
3078
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
3033
3079
  assertPatternDoesNotExist(workspace.projectDir, patternSlug, inventory);
3034
3080
  const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
3035
3081
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
@@ -3063,7 +3109,7 @@ async function runAddBindingSourceCommand({
3063
3109
  }) {
3064
3110
  const workspace = resolveWorkspaceProject(cwd);
3065
3111
  const bindingSourceSlug = assertValidGeneratedSlug("Binding source name", normalizeBlockSlug(bindingSourceName), "wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>]");
3066
- const inventory = readWorkspaceInventory(workspace.projectDir);
3112
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
3067
3113
  assertBindingSourceDoesNotExist(workspace.projectDir, bindingSourceSlug, inventory);
3068
3114
  const target = resolveBindingTarget({
3069
3115
  attributeName,
@@ -3072,7 +3118,7 @@ async function runAddBindingSourceCommand({
3072
3118
  const targetBlock = target ? resolveWorkspaceBlock(inventory, target.blockSlug) : undefined;
3073
3119
  const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
3074
3120
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
3075
- const bindingsIndexPath = resolveBindingSourceRegistryPath(workspace.projectDir);
3121
+ const bindingsIndexPath = await resolveBindingSourceRegistryPath(workspace.projectDir);
3076
3122
  const bindingSourceDir = path6.join(workspace.projectDir, "src", "bindings", bindingSourceSlug);
3077
3123
  const serverFilePath = path6.join(bindingSourceDir, "server.php");
3078
3124
  const editorFilePath = path6.join(bindingSourceDir, "editor.ts");
@@ -4257,7 +4303,7 @@ async function runAddRestResourceCommand({
4257
4303
  const restResourceSlug = assertValidGeneratedSlug("REST resource name", normalizeBlockSlug(restResourceName), "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create>]");
4258
4304
  const resolvedMethods = assertValidRestResourceMethods(methods);
4259
4305
  const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
4260
- const inventory = readWorkspaceInventory(workspace.projectDir);
4306
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
4261
4307
  assertRestResourceDoesNotExist(workspace.projectDir, restResourceSlug, inventory);
4262
4308
  const blockConfigPath = path9.join(workspace.projectDir, "scripts", "block-config.ts");
4263
4309
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
@@ -4320,7 +4366,6 @@ async function runAddRestResourceCommand({
4320
4366
  }
4321
4367
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-scaffold.ts
4322
4368
  var import_semver = __toESM(require_semver(), 1);
4323
- import fs4 from "fs";
4324
4369
  import { promises as fsp6 } from "fs";
4325
4370
  import path10 from "path";
4326
4371
  import { syncTypeSchemas as syncTypeSchemas2 } from "@wp-typia/block-runtime/metadata-core";
@@ -4812,26 +4857,34 @@ function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
4812
4857
  }
4813
4858
  return import_semver.default.gte(existingMinimum, requiredMinimum) ? existingVersion : requiredVersion;
4814
4859
  }
4815
- function resolveAbilityRegistryPath(projectDir) {
4860
+ async function resolveAbilityRegistryPath(projectDir) {
4816
4861
  const abilitiesDir = path10.join(projectDir, "src", "abilities");
4817
- return [path10.join(abilitiesDir, "index.ts"), path10.join(abilitiesDir, "index.js")].find((candidatePath) => fs4.existsSync(candidatePath)) ?? path10.join(abilitiesDir, "index.ts");
4862
+ for (const candidatePath of [
4863
+ path10.join(abilitiesDir, "index.ts"),
4864
+ path10.join(abilitiesDir, "index.js")
4865
+ ]) {
4866
+ if (await pathExists(candidatePath)) {
4867
+ return candidatePath;
4868
+ }
4869
+ }
4870
+ return path10.join(abilitiesDir, "index.ts");
4818
4871
  }
4819
- function readAbilityRegistrySlugs(registryPath) {
4820
- if (!fs4.existsSync(registryPath)) {
4872
+ async function readAbilityRegistrySlugs(registryPath) {
4873
+ const source = await readOptionalUtf8File(registryPath);
4874
+ if (source === null) {
4821
4875
  return [];
4822
4876
  }
4823
- const source = fs4.readFileSync(registryPath, "utf8");
4824
- return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client['"];?\s*$/gmu)).map((match) => match[1]);
4877
+ return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client(?:\.[cm]?[jt]sx?)?['"];?\s*$/gmu)).map((match) => match[1]);
4825
4878
  }
4826
4879
  async function writeAbilityRegistry(projectDir, abilitySlug) {
4827
4880
  const abilitiesDir = path10.join(projectDir, "src", "abilities");
4828
- const registryPath = resolveAbilityRegistryPath(projectDir);
4881
+ const registryPath = await resolveAbilityRegistryPath(projectDir);
4829
4882
  await fsp6.mkdir(abilitiesDir, { recursive: true });
4830
- const existingAbilitySlugs = readWorkspaceInventory(projectDir).abilities.map((entry) => entry.slug);
4831
- const existingRegistrySlugs = readAbilityRegistrySlugs(registryPath);
4883
+ const existingAbilitySlugs = (await readWorkspaceInventoryAsync(projectDir)).abilities.map((entry) => entry.slug);
4884
+ const existingRegistrySlugs = await readAbilityRegistrySlugs(registryPath);
4832
4885
  const nextAbilitySlugs = Array.from(new Set([...existingAbilitySlugs, ...existingRegistrySlugs, abilitySlug])).sort();
4833
4886
  const generatedSection = buildAbilityRegistrySource(nextAbilitySlugs);
4834
- const existingSource = fs4.existsSync(registryPath) ? fs4.readFileSync(registryPath, "utf8") : "";
4887
+ const existingSource = await readOptionalUtf8File(registryPath) ?? "";
4835
4888
  const generatedSectionPattern = new RegExp(`${escapeRegex(ABILITY_REGISTRY_START_MARKER)}[\\s\\S]*?${escapeRegex(ABILITY_REGISTRY_END_MARKER)}\\n?`, "u");
4836
4889
  const nextSource = existingSource ? generatedSectionPattern.test(existingSource) ? existingSource.replace(generatedSectionPattern, generatedSection) : `${existingSource.trimEnd()}
4837
4890
 
@@ -5100,7 +5153,7 @@ async function scaffoldAbilityWorkspace({
5100
5153
  const syncAbilitiesScriptPath = path10.join(workspace.projectDir, "scripts", "sync-abilities.ts");
5101
5154
  const syncProjectScriptPath = path10.join(workspace.projectDir, "scripts", "sync-project.ts");
5102
5155
  const webpackConfigPath = path10.join(workspace.projectDir, "webpack.config.js");
5103
- const abilitiesIndexPath = resolveAbilityRegistryPath(workspace.projectDir);
5156
+ const abilitiesIndexPath = await resolveAbilityRegistryPath(workspace.projectDir);
5104
5157
  const abilityDir = path10.join(workspace.projectDir, "src", "abilities", abilitySlug);
5105
5158
  const configFilePath = path10.join(abilityDir, "ability.config.json");
5106
5159
  const typesFilePath = path10.join(abilityDir, "types.ts");
@@ -5171,7 +5224,7 @@ async function runAddAbilityCommand({
5171
5224
  }) {
5172
5225
  const workspace = resolveWorkspaceProject(cwd);
5173
5226
  const abilitySlug = assertValidGeneratedSlug("Ability name", normalizeBlockSlug(abilityName), "wp-typia add ability <name>");
5174
- const inventory = readWorkspaceInventory(workspace.projectDir);
5227
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
5175
5228
  assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
5176
5229
  const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
5177
5230
  const scaffoldResult = await scaffoldAbilityWorkspace({
@@ -6713,7 +6766,7 @@ async function runAddAiFeatureCommand({
6713
6766
  const aiFeatureSlug = assertValidGeneratedSlug("AI feature name", normalizeBlockSlug(aiFeatureName), "wp-typia add ai-feature <name> [--namespace <vendor/v1>]");
6714
6767
  const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
6715
6768
  const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY);
6716
- const inventory = readWorkspaceInventory(workspace.projectDir);
6769
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
6717
6770
  assertAiFeatureDoesNotExist(workspace.projectDir, aiFeatureSlug, inventory);
6718
6771
  const scaffoldResult = await scaffoldAiFeatureWorkspace({
6719
6772
  aiFeatureSlug,
@@ -6743,7 +6796,6 @@ var BLOCK_TRANSFORMS_IMPORT_PATTERN = /^\s*import\s*\{\s*applyWorkspaceBlockTran
6743
6796
  var BLOCK_TRANSFORMS_CALL_LINE = "applyWorkspaceBlockTransforms(registration.settings);";
6744
6797
  var BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
6745
6798
  var SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN = /registerScaffoldBlockType\s*\(\s*registration\s*\.\s*name\s*,\s*registration\s*\.\s*settings\s*\)\s*;?/u;
6746
- var FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
6747
6799
  function isIdentifierBoundary(source, index) {
6748
6800
  if (index < 0 || index >= source.length) {
6749
6801
  return true;
@@ -7136,35 +7188,6 @@ async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug)
7136
7188
  const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
7137
7189
  await fsp9.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
7138
7190
  }
7139
- function assertFullBlockName(blockName, flagName) {
7140
- const trimmed = blockName.trim();
7141
- if (!trimmed) {
7142
- throw new Error(`\`${flagName}\` requires a block name.`);
7143
- }
7144
- if (!FULL_BLOCK_NAME_PATTERN.test(trimmed)) {
7145
- throw new Error(`\`${flagName}\` must use <namespace/block-slug> format.`);
7146
- }
7147
- return trimmed;
7148
- }
7149
- function resolveWorkspaceTargetBlockName(blockName, namespace, flagName) {
7150
- const trimmed = blockName.trim();
7151
- if (!trimmed) {
7152
- throw new Error(`\`${flagName}\` requires <block-slug|namespace/block-slug>.`);
7153
- }
7154
- const blockNameSegments = trimmed.split("/");
7155
- if (blockNameSegments.length > 2 || blockNameSegments.some((segment) => segment.trim() === "")) {
7156
- throw new Error(`\`${flagName}\` must use <block-slug|namespace/block-slug> format.`);
7157
- }
7158
- const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
7159
- if (maybeNamespace && maybeNamespace !== namespace) {
7160
- throw new Error(`\`${flagName}\` references namespace "${maybeNamespace}". Expected "${namespace}".`);
7161
- }
7162
- const blockSlug = normalizeBlockSlug(maybeSlug ?? "");
7163
- return {
7164
- blockName: `${namespace}/${blockSlug}`,
7165
- blockSlug
7166
- };
7167
- }
7168
7191
  async function runAddVariationCommand({
7169
7192
  blockName,
7170
7193
  cwd = process.cwd(),
@@ -7173,7 +7196,7 @@ async function runAddVariationCommand({
7173
7196
  const workspace = resolveWorkspaceProject(cwd);
7174
7197
  const blockSlug = normalizeBlockSlug(blockName);
7175
7198
  const variationSlug = assertValidGeneratedSlug("Variation name", normalizeBlockSlug(variationName), "wp-typia add variation <name> --block <block-slug>");
7176
- const inventory = readWorkspaceInventory(workspace.projectDir);
7199
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7177
7200
  resolveWorkspaceBlock(inventory, blockSlug);
7178
7201
  assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
7179
7202
  const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
@@ -7220,7 +7243,7 @@ async function runAddBlockStyleCommand({
7220
7243
  const workspace = resolveWorkspaceProject(cwd);
7221
7244
  const blockSlug = normalizeBlockSlug(blockName);
7222
7245
  const styleSlug = assertValidGeneratedSlug("Style name", normalizeBlockSlug(styleName), "wp-typia add style <name> --block <block-slug>");
7223
- const inventory = readWorkspaceInventory(workspace.projectDir);
7246
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7224
7247
  resolveWorkspaceBlock(inventory, blockSlug);
7225
7248
  assertBlockStyleDoesNotExist(workspace.projectDir, blockSlug, styleSlug, inventory);
7226
7249
  const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
@@ -7269,7 +7292,7 @@ async function runAddBlockTransformCommand({
7269
7292
  const transformSlug = assertValidGeneratedSlug("Transform name", normalizeBlockSlug(transformName), "wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>");
7270
7293
  const resolvedFromBlockName = assertFullBlockName(fromBlockName, "--from");
7271
7294
  const target = resolveWorkspaceTargetBlockName(toBlockName, workspace.workspace.namespace, "--to");
7272
- const inventory = readWorkspaceInventory(workspace.projectDir);
7295
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7273
7296
  resolveWorkspaceBlock(inventory, target.blockSlug);
7274
7297
  assertBlockTransformDoesNotExist(workspace.projectDir, target.blockSlug, transformSlug, inventory);
7275
7298
  const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
@@ -7329,7 +7352,7 @@ async function runAddHookedBlockCommand({
7329
7352
  }) {
7330
7353
  const workspace = resolveWorkspaceProject(cwd);
7331
7354
  const blockSlug = normalizeBlockSlug(blockName);
7332
- const inventory = readWorkspaceInventory(workspace.projectDir);
7355
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7333
7356
  resolveWorkspaceBlock(inventory, blockSlug);
7334
7357
  const resolvedAnchorBlockName = assertValidHookAnchor(anchorBlockName);
7335
7358
  const resolvedPosition = assertValidHookedBlockPosition(position);
@@ -7384,4 +7407,4 @@ export {
7384
7407
  ADD_BLOCK_TEMPLATE_IDS
7385
7408
  };
7386
7409
 
7387
- //# debugId=DA912BE06859998764756E2164756E21
7410
+ //# debugId=D2A71082E757E7C764756E2164756E21
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  PROJECT_TOOLS_PACKAGE_ROOT
4
- } from "./cli-tke8twkn.js";
4
+ } from "./cli-qse6myha.js";
5
5
 
6
6
  // ../wp-typia-project-tools/src/runtime/package-versions.ts
7
7
  import fs from "fs";
@@ -54,10 +54,19 @@ function createContentFingerprint(source) {
54
54
  }
55
55
  return (hash >>> 0).toString(16);
56
56
  }
57
+ function readPackageManifestFile(packageJsonPath) {
58
+ const fileDescriptor = fs.openSync(packageJsonPath, "r");
59
+ try {
60
+ const stats = fs.fstatSync(fileDescriptor);
61
+ const source = fs.readFileSync(fileDescriptor, "utf8");
62
+ return { source, stats };
63
+ } finally {
64
+ fs.closeSync(fileDescriptor);
65
+ }
66
+ }
57
67
  function resolvePackageManifestLocation(packageJsonPath) {
58
68
  try {
59
- const stats = fs.statSync(packageJsonPath);
60
- const source = fs.readFileSync(packageJsonPath, "utf8");
69
+ const { source, stats } = readPackageManifestFile(packageJsonPath);
61
70
  return {
62
71
  cacheKey: `file:${packageJsonPath}:${stats.ino}:${stats.mtimeMs}:${stats.ctimeMs}:${stats.size}:${createContentFingerprint(source)}`,
63
72
  packageJsonPath,
@@ -175,4 +184,4 @@ function getPackageVersions() {
175
184
 
176
185
  export { DEFAULT_WORDPRESS_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_DATA_VERSION, DEFAULT_WORDPRESS_DATA_VERSION, DEFAULT_WORDPRESS_DATAVIEWS_VERSION, DEFAULT_WP_TYPIA_DATAVIEWS_VERSION, resolveManagedPackageVersionRange, getPackageVersions };
177
186
 
178
- //# debugId=C72EB21C0A53F5BC64756E2164756E21
187
+ //# debugId=5EDDE195AC44420B64756E2164756E21