wp-typia 0.22.7 → 0.22.9

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.
@@ -1,4 +1,11 @@
1
1
  // @bun
2
+ import {
3
+ suggestCloseId
4
+ } from "./cli-cvxvcw7c.js";
5
+ import {
6
+ CLI_DIAGNOSTIC_CODES,
7
+ createCliDiagnosticCodeError
8
+ } from "./cli-p95wr1q8.js";
2
9
  import {
3
10
  WORKSPACE_TEMPLATE_PACKAGE
4
11
  } from "./cli-hhp1d348.js";
@@ -170939,6 +170946,9 @@ var ADD_BLOCK_TEMPLATE_IDS = [
170939
170946
  "persistence",
170940
170947
  "compound"
170941
170948
  ];
170949
+ function suggestAddBlockTemplateId(templateId) {
170950
+ return suggestCloseId(templateId, ADD_BLOCK_TEMPLATE_IDS);
170951
+ }
170942
170952
 
170943
170953
  // ../wp-typia-project-tools/src/runtime/hooked-blocks.ts
170944
170954
  var HOOKED_BLOCK_POSITION_IDS = ["before", "after", "firstChild", "lastChild"];
@@ -170952,7 +170962,9 @@ var COMMON_ACRONYM_PREFIXES = [
170952
170962
  "JSON",
170953
170963
  "REST",
170954
170964
  "UUID",
170965
+ "AJAX",
170955
170966
  "API",
170967
+ "CPT",
170956
170968
  "CSS",
170957
170969
  "CTA",
170958
170970
  "DOM",
@@ -170966,12 +170978,16 @@ var COMMON_ACRONYM_PREFIXES = [
170966
170978
  "UI",
170967
170979
  "WP"
170968
170980
  ];
170981
+ var COMMON_ACRONYM_LOWERCASE_SUFFIXES = ["slug"];
170969
170982
  function capitalizeSegment(segment) {
170970
170983
  return segment.charAt(0).toUpperCase() + segment.slice(1);
170971
170984
  }
170972
170985
  function findCommonAcronymPrefix(segment) {
170973
170986
  return COMMON_ACRONYM_PREFIXES.find((prefix) => segment.startsWith(prefix));
170974
170987
  }
170988
+ function isCommonAcronymLowercaseSuffix(suffix) {
170989
+ return COMMON_ACRONYM_LOWERCASE_SUFFIXES.includes(suffix);
170990
+ }
170975
170991
  function splitKnownAcronymSegment(segment) {
170976
170992
  const prefixes = [];
170977
170993
  let remaining = segment;
@@ -170984,6 +171000,9 @@ function splitKnownAcronymSegment(segment) {
170984
171000
  if (/^[A-Z][a-z]/.test(suffix)) {
170985
171001
  return [...prefixes, prefix, suffix].join("-");
170986
171002
  }
171003
+ if (/^[a-z]+$/.test(suffix) && isCommonAcronymLowercaseSuffix(suffix)) {
171004
+ return [...prefixes, prefix, suffix].join("-");
171005
+ }
170987
171006
  if (!findCommonAcronymPrefix(suffix)) {
170988
171007
  break;
170989
171008
  }
@@ -171085,6 +171104,33 @@ function assertValidEditorPluginSlot(slot = "sidebar") {
171085
171104
  throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}. Legacy aliases: PluginSidebar, PluginDocumentSettingPanel.`);
171086
171105
  }
171087
171106
 
171107
+ // ../wp-typia-project-tools/src/runtime/fs-async.ts
171108
+ import { promises as fsp } from "fs";
171109
+ async function pathExists(filePath) {
171110
+ try {
171111
+ await fsp.access(filePath);
171112
+ return true;
171113
+ } catch {
171114
+ return false;
171115
+ }
171116
+ }
171117
+ async function readOptionalUtf8File(filePath) {
171118
+ try {
171119
+ return await fsp.readFile(filePath, "utf8");
171120
+ } catch (error) {
171121
+ if (isFileNotFoundError(error)) {
171122
+ return null;
171123
+ }
171124
+ throw error;
171125
+ }
171126
+ }
171127
+ function getNodeErrorCode(error) {
171128
+ return typeof error === "object" && error !== null && "code" in error ? String(error.code) : "";
171129
+ }
171130
+ function isFileNotFoundError(error) {
171131
+ return getNodeErrorCode(error) === "ENOENT";
171132
+ }
171133
+
171088
171134
  // ../wp-typia-project-tools/src/runtime/cli-add-help.ts
171089
171135
  function formatAddHelpText() {
171090
171136
  return `Usage:
@@ -171145,7 +171191,7 @@ function validatePhpPrefix(input) {
171145
171191
  function assertValidIdentifier(label, value, validate) {
171146
171192
  const result = validate(value);
171147
171193
  if (result !== true) {
171148
- throw new Error(typeof result === "string" ? `${label}: ${result}` : `${label} is invalid`);
171194
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, typeof result === "string" ? `${label}: ${result}` : `${label} is invalid`);
171149
171195
  }
171150
171196
  return value;
171151
171197
  }
@@ -171158,9 +171204,9 @@ function resolveNonEmptyNormalizedBlockSlug(options) {
171158
171204
  return normalizedSlug;
171159
171205
  }
171160
171206
  if (options.input.trim().length === 0) {
171161
- throw new Error(`${options.label} is required. Use \`${options.usage}\`.`);
171207
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, `${options.label} is required. Use \`${options.usage}\`.`);
171162
171208
  }
171163
- throw new Error(`${options.label} "${options.input.trim()}" normalizes to an empty slug. Use letters or numbers so wp-typia can generate a block slug.`);
171209
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `${options.label} "${options.input.trim()}" normalizes to an empty slug. Use letters or numbers so wp-typia can generate a block slug.`);
171164
171210
  }
171165
171211
  function resolveValidatedBlockSlug(value) {
171166
171212
  return assertValidIdentifier("Block slug", normalizeBlockSlug(value), validateBlockSlug);
@@ -171200,24 +171246,24 @@ function resolveScaffoldIdentifiers({
171200
171246
  };
171201
171247
  }
171202
171248
  // ../wp-typia-project-tools/src/runtime/cli-add-filesystem.ts
171203
- import { promises as fsp } from "fs";
171249
+ import { promises as fsp2 } from "fs";
171204
171250
  import path from "path";
171205
171251
  function getWorkspaceBootstrapPath(workspace) {
171206
171252
  const workspaceBaseName = workspace.packageName.split("/").pop() ?? workspace.packageName;
171207
171253
  return path.join(workspace.projectDir, `${workspaceBaseName}.php`);
171208
171254
  }
171209
171255
  async function patchFile(filePath, transform) {
171210
- const currentSource = await fsp.readFile(filePath, "utf8");
171256
+ const currentSource = await fsp2.readFile(filePath, "utf8");
171211
171257
  const nextSource = transform(currentSource);
171212
171258
  if (nextSource !== currentSource) {
171213
- await fsp.writeFile(filePath, nextSource, "utf8");
171259
+ await fsp2.writeFile(filePath, nextSource, "utf8");
171214
171260
  }
171215
171261
  }
171216
171262
  async function readOptionalFile(filePath) {
171217
171263
  try {
171218
- return await fsp.readFile(filePath, "utf8");
171264
+ return await fsp2.readFile(filePath, "utf8");
171219
171265
  } catch (error) {
171220
- if (isFileNotFoundError(error)) {
171266
+ if (isFileNotFoundError2(error)) {
171221
171267
  return null;
171222
171268
  }
171223
171269
  throw error;
@@ -171225,11 +171271,11 @@ async function readOptionalFile(filePath) {
171225
171271
  }
171226
171272
  async function restoreOptionalFile(filePath, source) {
171227
171273
  if (source === null) {
171228
- await fsp.rm(filePath, { force: true });
171274
+ await fsp2.rm(filePath, { force: true });
171229
171275
  return;
171230
171276
  }
171231
- await fsp.mkdir(path.dirname(filePath), { recursive: true });
171232
- await fsp.writeFile(filePath, source, "utf8");
171277
+ await fsp2.mkdir(path.dirname(filePath), { recursive: true });
171278
+ await fsp2.writeFile(filePath, source, "utf8");
171233
171279
  }
171234
171280
  async function snapshotWorkspaceFiles(filePaths) {
171235
171281
  const uniquePaths = Array.from(new Set(filePaths));
@@ -171240,50 +171286,21 @@ async function snapshotWorkspaceFiles(filePaths) {
171240
171286
  }
171241
171287
  async function rollbackWorkspaceMutation(snapshot) {
171242
171288
  for (const targetPath of snapshot.targetPaths) {
171243
- await fsp.rm(targetPath, { force: true, recursive: true });
171289
+ await fsp2.rm(targetPath, { force: true, recursive: true });
171244
171290
  }
171245
171291
  for (const snapshotDir of snapshot.snapshotDirs) {
171246
- await fsp.rm(snapshotDir, { force: true, recursive: true });
171292
+ await fsp2.rm(snapshotDir, { force: true, recursive: true });
171247
171293
  }
171248
171294
  for (const { filePath, source } of snapshot.fileSources) {
171249
171295
  await restoreOptionalFile(filePath, source);
171250
171296
  }
171251
171297
  }
171252
- function isFileNotFoundError(error) {
171298
+ function isFileNotFoundError2(error) {
171253
171299
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
171254
171300
  }
171255
171301
  // ../wp-typia-project-tools/src/runtime/cli-add-block-json.ts
171256
171302
  import path2 from "path";
171257
171303
  import { parseScaffoldBlockMetadata } from "@wp-typia/block-runtime/blocks";
171258
-
171259
- // ../wp-typia-project-tools/src/runtime/fs-async.ts
171260
- import { promises as fsp2 } from "fs";
171261
- async function pathExists(filePath) {
171262
- try {
171263
- await fsp2.access(filePath);
171264
- return true;
171265
- } catch {
171266
- return false;
171267
- }
171268
- }
171269
- async function readOptionalUtf8File(filePath) {
171270
- try {
171271
- return await fsp2.readFile(filePath, "utf8");
171272
- } catch (error) {
171273
- if (isFileNotFoundError2(error)) {
171274
- return null;
171275
- }
171276
- throw error;
171277
- }
171278
- }
171279
- function getNodeErrorCode(error) {
171280
- return typeof error === "object" && error !== null && "code" in error ? String(error.code) : "";
171281
- }
171282
- function isFileNotFoundError2(error) {
171283
- return getNodeErrorCode(error) === "ENOENT";
171284
- }
171285
-
171286
- // ../wp-typia-project-tools/src/runtime/cli-add-block-json.ts
171287
171304
  function resolveWorkspaceBlock(inventory, blockSlug) {
171288
171305
  const block = inventory.blocks.find((entry) => entry.slug === blockSlug);
171289
171306
  if (!block) {
@@ -171576,8 +171593,8 @@ function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inventory)
171576
171593
  });
171577
171594
  }
171578
171595
  // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171579
- var import_typescript = __toESM(require_typescript(), 1);
171580
- import fs2 from "fs";
171596
+ var import_typescript2 = __toESM(require_typescript(), 1);
171597
+ import { readFileSync } from "fs";
171581
171598
  import path4 from "path";
171582
171599
  import { readFile, writeFile } from "fs/promises";
171583
171600
 
@@ -171726,6 +171743,9 @@ function matchesPhpFunctionCallAt(source, index, functionName) {
171726
171743
  function createPhpScannerState() {
171727
171744
  return {
171728
171745
  heredocDelimiter: "",
171746
+ interpolationComment: "",
171747
+ interpolationDepth: 0,
171748
+ interpolationQuote: "",
171729
171749
  mode: "code"
171730
171750
  };
171731
171751
  }
@@ -171749,11 +171769,73 @@ function advancePhpScanner(source, index, state) {
171749
171769
  if (character === "\\") {
171750
171770
  return { ambiguous: false, inCode: false, index: index + 2 };
171751
171771
  }
171772
+ if (state.mode === "double-quoted" && character === "{" && source[index + 1] === "$") {
171773
+ state.mode = "double-quoted-interpolation";
171774
+ state.interpolationComment = "";
171775
+ state.interpolationDepth = 1;
171776
+ state.interpolationQuote = "";
171777
+ return { ambiguous: false, inCode: false, index: index + 2 };
171778
+ }
171752
171779
  if (character === quote) {
171753
171780
  state.mode = "code";
171754
171781
  }
171755
171782
  return { ambiguous: false, inCode: false, index: index + 1 };
171756
171783
  }
171784
+ if (state.mode === "double-quoted-interpolation") {
171785
+ if (state.interpolationQuote) {
171786
+ if (character === "\\") {
171787
+ return { ambiguous: false, inCode: false, index: index + 2 };
171788
+ }
171789
+ if (character === state.interpolationQuote) {
171790
+ state.interpolationQuote = "";
171791
+ }
171792
+ return { ambiguous: false, inCode: false, index: index + 1 };
171793
+ }
171794
+ if (state.interpolationComment === "line") {
171795
+ if (character === "\r" || character === `
171796
+ `) {
171797
+ state.interpolationComment = "";
171798
+ }
171799
+ return { ambiguous: false, inCode: false, index: index + 1 };
171800
+ }
171801
+ if (state.interpolationComment === "block") {
171802
+ if (character === "*" && source[index + 1] === "/") {
171803
+ state.interpolationComment = "";
171804
+ return { ambiguous: false, inCode: false, index: index + 2 };
171805
+ }
171806
+ return { ambiguous: false, inCode: false, index: index + 1 };
171807
+ }
171808
+ if (character === "/" && source[index + 1] === "/") {
171809
+ state.interpolationComment = "line";
171810
+ return { ambiguous: false, inCode: false, index: index + 2 };
171811
+ }
171812
+ if (character === "#" && source[index + 1] !== "[") {
171813
+ state.interpolationComment = "line";
171814
+ return { ambiguous: false, inCode: false, index: index + 1 };
171815
+ }
171816
+ if (character === "/" && source[index + 1] === "*") {
171817
+ state.interpolationComment = "block";
171818
+ return { ambiguous: false, inCode: false, index: index + 2 };
171819
+ }
171820
+ if (character === "'" || character === '"') {
171821
+ state.interpolationQuote = character;
171822
+ return { ambiguous: false, inCode: false, index: index + 1 };
171823
+ }
171824
+ if (character === "{") {
171825
+ state.interpolationDepth += 1;
171826
+ return { ambiguous: false, inCode: false, index: index + 1 };
171827
+ }
171828
+ if (character === "}") {
171829
+ state.interpolationDepth -= 1;
171830
+ if (state.interpolationDepth <= 0) {
171831
+ state.interpolationComment = "";
171832
+ state.interpolationDepth = 0;
171833
+ state.mode = "double-quoted";
171834
+ }
171835
+ return { ambiguous: false, inCode: false, index: index + 1 };
171836
+ }
171837
+ return { ambiguous: false, inCode: false, index: index + 1 };
171838
+ }
171757
171839
  if (state.mode === "line-comment") {
171758
171840
  if (character === "\r" || character === `
171759
171841
  `) {
@@ -171885,9 +171967,18 @@ function replacePhpFunctionDefinition(source, functionName, replacement, options
171885
171967
  ].join("");
171886
171968
  }
171887
171969
 
171970
+ // ../wp-typia-project-tools/src/runtime/ts-property-names.ts
171971
+ var import_typescript = __toESM(require_typescript(), 1);
171972
+ function getPropertyNameText(name) {
171973
+ if (import_typescript.default.isIdentifier(name) || import_typescript.default.isStringLiteral(name) || import_typescript.default.isNumericLiteral(name)) {
171974
+ return name.text;
171975
+ }
171976
+ return null;
171977
+ }
171978
+
171888
171979
  // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171889
- function defineInventoryEntryParser(descriptor) {
171890
- return descriptor;
171980
+ function defineInventoryEntryParser() {
171981
+ return (descriptor) => descriptor;
171891
171982
  }
171892
171983
  var BLOCK_CONFIG_ENTRY_MARKER = "\t// wp-typia add block entries";
171893
171984
  var VARIATION_CONFIG_ENTRY_MARKER = "\t// wp-typia add variation entries";
@@ -172091,7 +172182,7 @@ var BLOCK_INVENTORY_SECTION = {
172091
172182
  },
172092
172183
  parse: {
172093
172184
  entriesKey: "blocks",
172094
- entry: defineInventoryEntryParser({
172185
+ entry: defineInventoryEntryParser()({
172095
172186
  entryName: "BLOCKS",
172096
172187
  fields: [
172097
172188
  { key: "apiTypesFile" },
@@ -172117,7 +172208,7 @@ var INVENTORY_SECTIONS = [
172117
172208
  },
172118
172209
  parse: {
172119
172210
  entriesKey: "variations",
172120
- entry: defineInventoryEntryParser({
172211
+ entry: defineInventoryEntryParser()({
172121
172212
  entryName: "VARIATIONS",
172122
172213
  fields: [
172123
172214
  { key: "block", required: true },
@@ -172143,7 +172234,7 @@ var INVENTORY_SECTIONS = [
172143
172234
  },
172144
172235
  parse: {
172145
172236
  entriesKey: "blockStyles",
172146
- entry: defineInventoryEntryParser({
172237
+ entry: defineInventoryEntryParser()({
172147
172238
  entryName: "BLOCK_STYLES",
172148
172239
  fields: [
172149
172240
  { key: "block", required: true },
@@ -172169,7 +172260,7 @@ var INVENTORY_SECTIONS = [
172169
172260
  },
172170
172261
  parse: {
172171
172262
  entriesKey: "blockTransforms",
172172
- entry: defineInventoryEntryParser({
172263
+ entry: defineInventoryEntryParser()({
172173
172264
  entryName: "BLOCK_TRANSFORMS",
172174
172265
  fields: [
172175
172266
  { key: "block", required: true },
@@ -172197,7 +172288,7 @@ var INVENTORY_SECTIONS = [
172197
172288
  },
172198
172289
  parse: {
172199
172290
  entriesKey: "patterns",
172200
- entry: defineInventoryEntryParser({
172291
+ entry: defineInventoryEntryParser()({
172201
172292
  entryName: "PATTERNS",
172202
172293
  fields: [
172203
172294
  { key: "file", required: true },
@@ -172222,7 +172313,7 @@ var INVENTORY_SECTIONS = [
172222
172313
  },
172223
172314
  parse: {
172224
172315
  entriesKey: "bindingSources",
172225
- entry: defineInventoryEntryParser({
172316
+ entry: defineInventoryEntryParser()({
172226
172317
  entryName: "BINDING_SOURCES",
172227
172318
  fields: [
172228
172319
  { key: "attribute" },
@@ -172250,7 +172341,7 @@ var INVENTORY_SECTIONS = [
172250
172341
  },
172251
172342
  parse: {
172252
172343
  entriesKey: "restResources",
172253
- entry: defineInventoryEntryParser({
172344
+ entry: defineInventoryEntryParser()({
172254
172345
  entryName: "REST_RESOURCES",
172255
172346
  fields: [
172256
172347
  { key: "apiFile", required: true },
@@ -172294,7 +172385,7 @@ var INVENTORY_SECTIONS = [
172294
172385
  },
172295
172386
  parse: {
172296
172387
  entriesKey: "abilities",
172297
- entry: defineInventoryEntryParser({
172388
+ entry: defineInventoryEntryParser()({
172298
172389
  entryName: "ABILITIES",
172299
172390
  fields: [
172300
172391
  { key: "clientFile", required: true },
@@ -172327,7 +172418,7 @@ var INVENTORY_SECTIONS = [
172327
172418
  },
172328
172419
  parse: {
172329
172420
  entriesKey: "aiFeatures",
172330
- entry: defineInventoryEntryParser({
172421
+ entry: defineInventoryEntryParser()({
172331
172422
  entryName: "AI_FEATURES",
172332
172423
  fields: [
172333
172424
  { key: "aiSchemaFile", required: true },
@@ -172360,7 +172451,7 @@ var INVENTORY_SECTIONS = [
172360
172451
  },
172361
172452
  parse: {
172362
172453
  entriesKey: "adminViews",
172363
- entry: defineInventoryEntryParser({
172454
+ entry: defineInventoryEntryParser()({
172364
172455
  entryName: "ADMIN_VIEWS",
172365
172456
  fields: [
172366
172457
  { key: "file", required: true },
@@ -172387,7 +172478,7 @@ var INVENTORY_SECTIONS = [
172387
172478
  },
172388
172479
  parse: {
172389
172480
  entriesKey: "editorPlugins",
172390
- entry: defineInventoryEntryParser({
172481
+ entry: defineInventoryEntryParser()({
172391
172482
  entryName: "EDITOR_PLUGINS",
172392
172483
  fields: [
172393
172484
  { key: "file", required: true },
@@ -172403,25 +172494,19 @@ var INVENTORY_SECTIONS = [
172403
172494
  }
172404
172495
  }
172405
172496
  ];
172406
- function getPropertyNameText(name) {
172407
- if (import_typescript.default.isIdentifier(name) || import_typescript.default.isStringLiteral(name)) {
172408
- return name.text;
172409
- }
172410
- return null;
172411
- }
172412
172497
  function findExportedArrayLiteral(sourceFile, exportName) {
172413
172498
  for (const statement of sourceFile.statements) {
172414
- if (!import_typescript.default.isVariableStatement(statement)) {
172499
+ if (!import_typescript2.default.isVariableStatement(statement)) {
172415
172500
  continue;
172416
172501
  }
172417
- if (!statement.modifiers?.some((modifier) => modifier.kind === import_typescript.default.SyntaxKind.ExportKeyword)) {
172502
+ if (!statement.modifiers?.some((modifier) => modifier.kind === import_typescript2.default.SyntaxKind.ExportKeyword)) {
172418
172503
  continue;
172419
172504
  }
172420
172505
  for (const declaration of statement.declarationList.declarations) {
172421
- if (!import_typescript.default.isIdentifier(declaration.name) || declaration.name.text !== exportName) {
172506
+ if (!import_typescript2.default.isIdentifier(declaration.name) || declaration.name.text !== exportName) {
172422
172507
  continue;
172423
172508
  }
172424
- if (declaration.initializer && import_typescript.default.isArrayLiteralExpression(declaration.initializer)) {
172509
+ if (declaration.initializer && import_typescript2.default.isArrayLiteralExpression(declaration.initializer)) {
172425
172510
  return {
172426
172511
  array: declaration.initializer,
172427
172512
  found: true
@@ -172440,57 +172525,62 @@ function findExportedArrayLiteral(sourceFile, exportName) {
172440
172525
  }
172441
172526
  function getOptionalStringProperty(entryName, elementIndex, objectLiteral, key) {
172442
172527
  for (const property of objectLiteral.properties) {
172443
- if (!import_typescript.default.isPropertyAssignment(property)) {
172528
+ if (!import_typescript2.default.isPropertyAssignment(property)) {
172444
172529
  continue;
172445
172530
  }
172446
172531
  const propertyName = getPropertyNameText(property.name);
172447
172532
  if (propertyName !== key) {
172448
172533
  continue;
172449
172534
  }
172450
- if (import_typescript.default.isStringLiteralLike(property.initializer)) {
172535
+ if (import_typescript2.default.isStringLiteralLike(property.initializer)) {
172451
172536
  return property.initializer.text;
172452
172537
  }
172453
172538
  throw new Error(`${entryName}[${elementIndex}] must use a string literal for "${key}" in scripts/block-config.ts.`);
172454
172539
  }
172455
172540
  return;
172456
172541
  }
172457
- function getRequiredStringProperty(entryName, elementIndex, objectLiteral, key) {
172458
- const value = getOptionalStringProperty(entryName, elementIndex, objectLiteral, key);
172459
- if (!value) {
172460
- throw new Error(`${entryName}[${elementIndex}] is missing required "${key}" in scripts/block-config.ts.`);
172461
- }
172462
- return value;
172463
- }
172464
- function getRequiredStringArrayProperty(entryName, elementIndex, objectLiteral, key) {
172542
+ function getOptionalStringArrayProperty(entryName, elementIndex, objectLiteral, key) {
172465
172543
  for (const property of objectLiteral.properties) {
172466
- if (!import_typescript.default.isPropertyAssignment(property)) {
172544
+ if (!import_typescript2.default.isPropertyAssignment(property)) {
172467
172545
  continue;
172468
172546
  }
172469
172547
  const propertyName = getPropertyNameText(property.name);
172470
172548
  if (propertyName !== key) {
172471
172549
  continue;
172472
172550
  }
172473
- if (!import_typescript.default.isArrayLiteralExpression(property.initializer)) {
172551
+ if (!import_typescript2.default.isArrayLiteralExpression(property.initializer)) {
172474
172552
  throw new Error(`${entryName}[${elementIndex}] must use an array literal for "${key}" in scripts/block-config.ts.`);
172475
172553
  }
172476
172554
  return property.initializer.elements.map((element, itemIndex) => {
172477
- if (!import_typescript.default.isStringLiteralLike(element)) {
172555
+ if (!import_typescript2.default.isStringLiteralLike(element)) {
172478
172556
  throw new Error(`${entryName}[${elementIndex}].${key}[${itemIndex}] must use a string literal in scripts/block-config.ts.`);
172479
172557
  }
172480
172558
  return element.text;
172481
172559
  });
172482
172560
  }
172483
- throw new Error(`${entryName}[${elementIndex}] is missing required "${key}" in scripts/block-config.ts.`);
172561
+ return;
172562
+ }
172563
+ function isMissingRequiredInventoryValue(value) {
172564
+ return value === undefined || typeof value === "string" && value.length === 0;
172565
+ }
172566
+ function formatMissingRequiredInventoryFields(keys) {
172567
+ return keys.length === 1 ? `required "${keys[0]}"` : `required fields ${keys.map((key) => `"${key}"`).join(", ")}`;
172568
+ }
172569
+ function assertParsedInventoryEntry(entry, descriptor, elementIndex) {
172570
+ const missingRequiredKeys = descriptor.fields.filter((field) => field.required === true && isMissingRequiredInventoryValue(entry[field.key])).map((field) => field.key);
172571
+ if (missingRequiredKeys.length > 0) {
172572
+ throw new Error(`${descriptor.entryName}[${elementIndex}] is missing ${formatMissingRequiredInventoryFields(missingRequiredKeys)} in scripts/block-config.ts.`);
172573
+ }
172484
172574
  }
172485
172575
  function parseInventoryEntries(arrayLiteral, descriptor) {
172486
172576
  return arrayLiteral.elements.map((element, elementIndex) => {
172487
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
172577
+ if (!import_typescript2.default.isObjectLiteralExpression(element)) {
172488
172578
  throw new Error(`${descriptor.entryName}[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172489
172579
  }
172490
172580
  const entry = {};
172491
172581
  for (const field of descriptor.fields) {
172492
172582
  const kind = field.kind ?? "string";
172493
- const value = kind === "stringArray" ? getRequiredStringArrayProperty(descriptor.entryName, elementIndex, element, field.key) : field.required ? getRequiredStringProperty(descriptor.entryName, elementIndex, element, field.key) : getOptionalStringProperty(descriptor.entryName, elementIndex, element, field.key);
172583
+ const value = kind === "stringArray" ? getOptionalStringArrayProperty(descriptor.entryName, elementIndex, element, field.key) : getOptionalStringProperty(descriptor.entryName, elementIndex, element, field.key);
172494
172584
  field.validate?.(value, {
172495
172585
  elementIndex,
172496
172586
  entryName: descriptor.entryName,
@@ -172498,6 +172588,7 @@ function parseInventoryEntries(arrayLiteral, descriptor) {
172498
172588
  });
172499
172589
  entry[field.key] = value;
172500
172590
  }
172591
+ assertParsedInventoryEntry(entry, descriptor, elementIndex);
172501
172592
  return entry;
172502
172593
  });
172503
172594
  }
@@ -172534,7 +172625,7 @@ function parseInventorySection(sourceFile, descriptor) {
172534
172625
  };
172535
172626
  }
172536
172627
  function parseWorkspaceInventorySource(source) {
172537
- const sourceFile = import_typescript.default.createSourceFile("block-config.ts", source, import_typescript.default.ScriptTarget.Latest, true, import_typescript.default.ScriptKind.TS);
172628
+ const sourceFile = import_typescript2.default.createSourceFile("block-config.ts", source, import_typescript2.default.ScriptTarget.Latest, true, import_typescript2.default.ScriptKind.TS);
172538
172629
  const parsedInventory = {
172539
172630
  abilities: [],
172540
172631
  adminViews: [],
@@ -172576,7 +172667,7 @@ function readWorkspaceInventory(projectDir) {
172576
172667
  const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
172577
172668
  let source;
172578
172669
  try {
172579
- source = fs2.readFileSync(blockConfigPath, "utf8");
172670
+ source = readFileSync(blockConfigPath, "utf8");
172580
172671
  } catch (error) {
172581
172672
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
172582
172673
  throw new Error(`Workspace inventory file is missing at ${blockConfigPath}. Expected scripts/block-config.ts to exist.`);
@@ -172588,13 +172679,35 @@ function readWorkspaceInventory(projectDir) {
172588
172679
  ...parseWorkspaceInventorySource(source)
172589
172680
  };
172590
172681
  }
172591
- function getWorkspaceBlockSelectOptions(projectDir) {
172592
- return readWorkspaceInventory(projectDir).blocks.map((block) => ({
172682
+ async function readWorkspaceInventoryAsync(projectDir) {
172683
+ const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
172684
+ let source;
172685
+ try {
172686
+ source = await readFile(blockConfigPath, "utf8");
172687
+ } catch (error) {
172688
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
172689
+ throw new Error(`Workspace inventory file is missing at ${blockConfigPath}. Expected scripts/block-config.ts to exist.`);
172690
+ }
172691
+ throw error;
172692
+ }
172693
+ return {
172694
+ blockConfigPath,
172695
+ ...parseWorkspaceInventorySource(source)
172696
+ };
172697
+ }
172698
+ function toWorkspaceBlockSelectOptions(blocks) {
172699
+ return blocks.map((block) => ({
172593
172700
  description: block.typesFile,
172594
172701
  name: block.slug,
172595
172702
  value: block.slug
172596
172703
  }));
172597
172704
  }
172705
+ function getWorkspaceBlockSelectOptions(projectDir) {
172706
+ return toWorkspaceBlockSelectOptions(readWorkspaceInventory(projectDir).blocks);
172707
+ }
172708
+ async function getWorkspaceBlockSelectOptionsAsync(projectDir) {
172709
+ return toWorkspaceBlockSelectOptions((await readWorkspaceInventoryAsync(projectDir)).blocks);
172710
+ }
172598
172711
  function ensureWorkspaceInventorySections(source) {
172599
172712
  let nextSource = source.trimEnd();
172600
172713
  for (const section of INVENTORY_SECTIONS) {
@@ -172705,6 +172818,6 @@ async function appendWorkspaceInventoryEntries(projectDir, options) {
172705
172818
  }
172706
172819
  }
172707
172820
 
172708
- export { toKebabCase, toSnakeCase, toPascalCase, toCamelCase, toSegmentPascalCase, toTitleCase, validateBlockSlug, validateNamespace, normalizeBlockSlug, resolveNonEmptyNormalizedBlockSlug, buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, REST_RESOURCE_METHOD_IDS, EDITOR_PLUGIN_SLOT_IDS, resolveEditorPluginSlotAlias, ADD_BLOCK_TEMPLATE_IDS, HOOKED_BLOCK_POSITION_SET, HOOKED_BLOCK_ANCHOR_PATTERN, REST_RESOURCE_NAMESPACE_PATTERN, assertValidGeneratedSlug, resolveRestResourceNamespace, assertValidRestResourceMethods, assertValidHookedBlockPosition, buildWorkspacePhpPrefix, isAddBlockTemplateId, quoteTsString, assertValidHookAnchor, assertValidEditorPluginSlot, getWorkspaceBootstrapPath, patchFile, readOptionalFile, snapshotWorkspaceFiles, rollbackWorkspaceMutation, pathExists, readOptionalUtf8File, resolveWorkspaceBlock, readWorkspaceBlockJson, getMutableBlockHooks, assertVariationDoesNotExist, assertBlockStyleDoesNotExist, assertBlockTransformDoesNotExist, assertPatternDoesNotExist, assertBindingSourceDoesNotExist, assertRestResourceDoesNotExist, assertAdminViewDoesNotExist, assertAbilityDoesNotExist, assertAiFeatureDoesNotExist, assertEditorPluginDoesNotExist, formatAddHelpText, require_typescript, escapeRegex, quotePhpString, hasPhpFunctionDefinition, hasPhpFunctionCall, findPhpFunctionRange, replacePhpFunctionDefinition, readWorkspaceInventory, getWorkspaceBlockSelectOptions, updateWorkspaceInventorySource, appendWorkspaceInventoryEntries };
172821
+ export { toKebabCase, toSnakeCase, toPascalCase, toCamelCase, toSegmentPascalCase, toTitleCase, validateBlockSlug, validateNamespace, normalizeBlockSlug, resolveNonEmptyNormalizedBlockSlug, buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, REST_RESOURCE_METHOD_IDS, EDITOR_PLUGIN_SLOT_IDS, resolveEditorPluginSlotAlias, ADD_BLOCK_TEMPLATE_IDS, suggestAddBlockTemplateId, HOOKED_BLOCK_POSITION_SET, HOOKED_BLOCK_ANCHOR_PATTERN, REST_RESOURCE_NAMESPACE_PATTERN, assertValidGeneratedSlug, resolveRestResourceNamespace, assertValidRestResourceMethods, assertValidHookedBlockPosition, buildWorkspacePhpPrefix, isAddBlockTemplateId, quoteTsString, assertValidHookAnchor, assertValidEditorPluginSlot, getWorkspaceBootstrapPath, patchFile, readOptionalFile, snapshotWorkspaceFiles, rollbackWorkspaceMutation, pathExists, readOptionalUtf8File, getNodeErrorCode, resolveWorkspaceBlock, readWorkspaceBlockJson, getMutableBlockHooks, assertVariationDoesNotExist, assertBlockStyleDoesNotExist, assertBlockTransformDoesNotExist, assertPatternDoesNotExist, assertBindingSourceDoesNotExist, assertRestResourceDoesNotExist, assertAdminViewDoesNotExist, assertAbilityDoesNotExist, assertAiFeatureDoesNotExist, assertEditorPluginDoesNotExist, formatAddHelpText, require_typescript, escapeRegex, quotePhpString, hasPhpFunctionDefinition, hasPhpFunctionCall, findPhpFunctionRange, replacePhpFunctionDefinition, getPropertyNameText, readWorkspaceInventory, readWorkspaceInventoryAsync, getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, updateWorkspaceInventorySource, appendWorkspaceInventoryEntries };
172709
172822
 
172710
- //# debugId=6D5B4520C8A1BC7E64756E2164756E21
172823
+ //# debugId=3C14848EF1DAC47E64756E2164756E21
@@ -9,6 +9,7 @@ import {
9
9
  getOptionalOnboardingShortNote,
10
10
  getOptionalOnboardingSteps,
11
11
  getPrimaryDevelopmentScript,
12
+ isCompoundPersistenceEnabled,
12
13
  isDataStorageMode,
13
14
  isPersistencePolicy,
14
15
  normalizeOptionalCliString,
@@ -19,17 +20,21 @@ import {
19
20
  resolvePackageManagerId,
20
21
  resolveTemplateId,
21
22
  scaffoldProject
22
- } from "./cli-8snabymq.js";
23
- import"./cli-2hsp17nd.js";
24
- import"./cli-27v2qpjg.js";
23
+ } from "./cli-2pnk64h0.js";
24
+ import"./cli-arz4rcye.js";
25
+ import"./cli-8reep89s.js";
26
+ import"./cli-ag722tzm.js";
25
27
  import"./cli-2rqf6t0b.js";
26
28
  import"./cli-bq2v559b.js";
27
- import"./cli-10pe4mf8.js";
29
+ import"./cli-xw1wbxf3.js";
28
30
  import {
29
31
  OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE,
30
32
  isBuiltInTemplateId
31
- } from "./cli-tke8twkn.js";
32
- import"./cli-ta3y0hp2.js";
33
+ } from "./cli-qse6myha.js";
34
+ import {
35
+ pathExists
36
+ } from "./cli-regw5384.js";
37
+ import"./cli-cvxvcw7c.js";
33
38
  import {
34
39
  createManagedTempRoot
35
40
  } from "./cli-t73q5aqz.js";
@@ -43,7 +48,6 @@ import {
43
48
  import"./cli-xnn9xjcy.js";
44
49
 
45
50
  // ../wp-typia-project-tools/src/runtime/cli-scaffold.ts
46
- import fs from "fs";
47
51
  import { promises as fsp } from "fs";
48
52
  import path from "path";
49
53
  async function listRelativeProjectFiles(rootDir) {
@@ -63,7 +67,7 @@ async function listRelativeProjectFiles(rootDir) {
63
67
  return relativeFiles.sort((left, right) => left.localeCompare(right));
64
68
  }
65
69
  async function assertDryRunTargetDirectoryReady(projectDir, allowExistingDir) {
66
- if (!fs.existsSync(projectDir) || allowExistingDir) {
70
+ if (!await pathExists(projectDir) || allowExistingDir) {
67
71
  return;
68
72
  }
69
73
  const entries = await fsp.readdir(projectDir);
@@ -508,7 +512,7 @@ async function runScaffoldFlow({
508
512
  let availableScripts;
509
513
  if (!dryRun) {
510
514
  try {
511
- const parsedPackageJson = JSON.parse(fs.readFileSync(path.join(projectDir, "package.json"), "utf8"));
515
+ const parsedPackageJson = JSON.parse(await fsp.readFile(path.join(projectDir, "package.json"), "utf8"));
512
516
  const scripts = parsedPackageJson.scripts && typeof parsedPackageJson.scripts === "object" && !Array.isArray(parsedPackageJson.scripts) ? parsedPackageJson.scripts : {};
513
517
  availableScripts = Object.entries(scripts).filter(([, value]) => typeof value === "string").map(([scriptName]) => scriptName);
514
518
  } catch {
@@ -521,7 +525,7 @@ async function runScaffoldFlow({
521
525
  availableScripts,
522
526
  packageManager: resolvedPackageManager,
523
527
  templateId: resolvedTemplateId,
524
- compoundPersistenceEnabled: resolvedResult.result.variables.compoundPersistenceEnabled === "true"
528
+ compoundPersistenceEnabled: isCompoundPersistenceEnabled(resolvedResult.result.variables)
525
529
  }),
526
530
  plan: resolvedResult.plan,
527
531
  projectDir,
@@ -557,4 +561,4 @@ export {
557
561
  getNextSteps
558
562
  };
559
563
 
560
- //# debugId=B0B154A223C91D5164756E2164756E21
564
+ //# debugId=95A9F724954FBE1164756E2164756E21