wp-typia 0.22.5 → 0.22.7

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,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  WORKSPACE_TEMPLATE_PACKAGE
4
- } from "./cli-btbpt84c.js";
4
+ } from "./cli-hhp1d348.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __require,
@@ -1734,11 +1734,11 @@ var require_buffer_from = __commonJS((exports, module) => {
1734
1734
  var require_source_map_support = __commonJS((exports, module) => {
1735
1735
  var SourceMapConsumer = require_source_map().SourceMapConsumer;
1736
1736
  var path4 = __require("path");
1737
- var fs3;
1737
+ var fs2;
1738
1738
  try {
1739
- fs3 = __require("fs");
1740
- if (!fs3.existsSync || !fs3.readFileSync) {
1741
- fs3 = null;
1739
+ fs2 = __require("fs");
1740
+ if (!fs2.existsSync || !fs2.readFileSync) {
1741
+ fs2 = null;
1742
1742
  }
1743
1743
  } catch (err) {}
1744
1744
  var bufferFrom = require_buffer_from();
@@ -1805,15 +1805,15 @@ var require_source_map_support = __commonJS((exports, module) => {
1805
1805
  }
1806
1806
  var contents = "";
1807
1807
  try {
1808
- if (!fs3) {
1808
+ if (!fs2) {
1809
1809
  var xhr = new XMLHttpRequest;
1810
1810
  xhr.open("GET", path5, false);
1811
1811
  xhr.send(null);
1812
1812
  if (xhr.readyState === 4 && xhr.status === 200) {
1813
1813
  contents = xhr.responseText;
1814
1814
  }
1815
- } else if (fs3.existsSync(path5)) {
1816
- contents = fs3.readFileSync(path5, "utf8");
1815
+ } else if (fs2.existsSync(path5)) {
1816
+ contents = fs2.readFileSync(path5, "utf8");
1817
1817
  }
1818
1818
  } catch (er) {}
1819
1819
  return fileContentsCache[path5] = contents;
@@ -2077,9 +2077,9 @@ var require_source_map_support = __commonJS((exports, module) => {
2077
2077
  var line = +match[2];
2078
2078
  var column = +match[3];
2079
2079
  var contents = fileContentsCache[source];
2080
- if (!contents && fs3 && fs3.existsSync(source)) {
2080
+ if (!contents && fs2 && fs2.existsSync(source)) {
2081
2081
  try {
2082
- contents = fs3.readFileSync(source, "utf8");
2082
+ contents = fs2.readFileSync(source, "utf8");
2083
2083
  } catch (er) {
2084
2084
  contents = "";
2085
2085
  }
@@ -5875,10 +5875,10 @@ var require_typescript = __commonJS((exports, module) => {
5875
5875
  function and(f, g) {
5876
5876
  return (arg) => f(arg) && g(arg);
5877
5877
  }
5878
- function or(...fs3) {
5878
+ function or(...fs2) {
5879
5879
  return (...args) => {
5880
5880
  let lastResult;
5881
- for (const f of fs3) {
5881
+ for (const f of fs2) {
5882
5882
  lastResult = f(...args);
5883
5883
  if (lastResult) {
5884
5884
  return lastResult;
@@ -7332,7 +7332,7 @@ ${lanes.join(`
7332
7332
  var tracing;
7333
7333
  var tracingEnabled;
7334
7334
  ((tracingEnabled2) => {
7335
- let fs3;
7335
+ let fs2;
7336
7336
  let traceCount = 0;
7337
7337
  let traceFd = 0;
7338
7338
  let mode;
@@ -7341,9 +7341,9 @@ ${lanes.join(`
7341
7341
  const legend = [];
7342
7342
  function startTracing2(tracingMode, traceDir, configFilePath) {
7343
7343
  Debug.assert(!tracing, "Tracing already started");
7344
- if (fs3 === undefined) {
7344
+ if (fs2 === undefined) {
7345
7345
  try {
7346
- fs3 = __require("fs");
7346
+ fs2 = __require("fs");
7347
7347
  } catch (e) {
7348
7348
  throw new Error(`tracing requires having fs
7349
7349
  (original error: ${e.message || e})`);
@@ -7354,8 +7354,8 @@ ${lanes.join(`
7354
7354
  if (legendPath === undefined) {
7355
7355
  legendPath = combinePaths(traceDir, "legend.json");
7356
7356
  }
7357
- if (!fs3.existsSync(traceDir)) {
7358
- fs3.mkdirSync(traceDir, { recursive: true });
7357
+ if (!fs2.existsSync(traceDir)) {
7358
+ fs2.mkdirSync(traceDir, { recursive: true });
7359
7359
  }
7360
7360
  const countPart = mode === "build" ? `.${process.pid}-${++traceCount}` : mode === "server" ? `.${process.pid}` : ``;
7361
7361
  const tracePath = combinePaths(traceDir, `trace${countPart}.json`);
@@ -7365,10 +7365,10 @@ ${lanes.join(`
7365
7365
  tracePath,
7366
7366
  typesPath
7367
7367
  });
7368
- traceFd = fs3.openSync(tracePath, "w");
7368
+ traceFd = fs2.openSync(tracePath, "w");
7369
7369
  tracing = tracingEnabled2;
7370
7370
  const meta = { cat: "__metadata", ph: "M", ts: 1000 * timestamp(), pid: 1, tid: 1 };
7371
- fs3.writeSync(traceFd, `[
7371
+ fs2.writeSync(traceFd, `[
7372
7372
  ` + [{ name: "process_name", args: { name: "tsc" }, ...meta }, { name: "thread_name", args: { name: "Main" }, ...meta }, { name: "TracingStartedInBrowser", ...meta, cat: "disabled-by-default-devtools.timeline" }].map((v) => JSON.stringify(v)).join(`,
7373
7373
  `));
7374
7374
  }
@@ -7376,10 +7376,10 @@ ${lanes.join(`
7376
7376
  function stopTracing() {
7377
7377
  Debug.assert(tracing, "Tracing is not in progress");
7378
7378
  Debug.assert(!!typeCatalog.length === (mode !== "server"));
7379
- fs3.writeSync(traceFd, `
7379
+ fs2.writeSync(traceFd, `
7380
7380
  ]
7381
7381
  `);
7382
- fs3.closeSync(traceFd);
7382
+ fs2.closeSync(traceFd);
7383
7383
  tracing = undefined;
7384
7384
  if (typeCatalog.length) {
7385
7385
  dumpTypes(typeCatalog);
@@ -7444,13 +7444,13 @@ ${lanes.join(`
7444
7444
  if (mode === "server" && phase === "checkTypes")
7445
7445
  return;
7446
7446
  mark("beginTracing");
7447
- fs3.writeSync(traceFd, `,
7447
+ fs2.writeSync(traceFd, `,
7448
7448
  {"pid":1,"tid":1,"ph":"${eventType}","cat":"${phase}","ts":${time},"name":"${name}"`);
7449
7449
  if (extras)
7450
- fs3.writeSync(traceFd, `,${extras}`);
7450
+ fs2.writeSync(traceFd, `,${extras}`);
7451
7451
  if (args)
7452
- fs3.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
7453
- fs3.writeSync(traceFd, `}`);
7452
+ fs2.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
7453
+ fs2.writeSync(traceFd, `}`);
7454
7454
  mark("endTracing");
7455
7455
  measure("Tracing", "beginTracing", "endTracing");
7456
7456
  }
@@ -7472,9 +7472,9 @@ ${lanes.join(`
7472
7472
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
7473
7473
  mark("beginDumpTypes");
7474
7474
  const typesPath = legend[legend.length - 1].typesPath;
7475
- const typesFd = fs3.openSync(typesPath, "w");
7475
+ const typesFd = fs2.openSync(typesPath, "w");
7476
7476
  const recursionIdentityMap = /* @__PURE__ */ new Map;
7477
- fs3.writeSync(typesFd, "[");
7477
+ fs2.writeSync(typesFd, "[");
7478
7478
  const numTypes = types.length;
7479
7479
  for (let i = 0;i < numTypes; i++) {
7480
7480
  const type = types[i];
@@ -7570,15 +7570,15 @@ ${lanes.join(`
7570
7570
  flags: Debug.formatTypeFlags(type.flags).split("|"),
7571
7571
  display
7572
7572
  };
7573
- fs3.writeSync(typesFd, JSON.stringify(descriptor));
7573
+ fs2.writeSync(typesFd, JSON.stringify(descriptor));
7574
7574
  if (i < numTypes - 1) {
7575
- fs3.writeSync(typesFd, `,
7575
+ fs2.writeSync(typesFd, `,
7576
7576
  `);
7577
7577
  }
7578
7578
  }
7579
- fs3.writeSync(typesFd, `]
7579
+ fs2.writeSync(typesFd, `]
7580
7580
  `);
7581
- fs3.closeSync(typesFd);
7581
+ fs2.closeSync(typesFd);
7582
7582
  mark("endDumpTypes");
7583
7583
  measure("Dump types", "beginDumpTypes", "endDumpTypes");
7584
7584
  }
@@ -7586,7 +7586,7 @@ ${lanes.join(`
7586
7586
  if (!legendPath) {
7587
7587
  return;
7588
7588
  }
7589
- fs3.writeFileSync(legendPath, JSON.stringify(legend));
7589
+ fs2.writeFileSync(legendPath, JSON.stringify(legend));
7590
7590
  }
7591
7591
  tracingEnabled2.dumpLegend = dumpLegend;
7592
7592
  })(tracingEnabled || (tracingEnabled = {}));
@@ -170911,45 +170911,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
170911
170911
  } });
170912
170912
  });
170913
170913
 
170914
- // ../wp-typia-project-tools/src/runtime/string-case.ts
170915
- function capitalizeSegment(segment) {
170916
- return segment.charAt(0).toUpperCase() + segment.slice(1);
170917
- }
170918
- function toKebabCase(input) {
170919
- return input.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-").toLowerCase();
170920
- }
170921
- function toSnakeCase(input) {
170922
- return toKebabCase(input).replace(/-/g, "_");
170923
- }
170924
- function toPascalCase(input) {
170925
- return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join("");
170926
- }
170927
- function toCamelCase(input) {
170928
- const pascalCase = toPascalCase(input);
170929
- return `${pascalCase.charAt(0).toLowerCase()}${pascalCase.slice(1)}`;
170930
- }
170931
- function toSegmentPascalCase(input) {
170932
- return input.replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean).map(capitalizeSegment).join("");
170933
- }
170934
- function toTitleCase(input) {
170935
- return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join(" ");
170936
- }
170937
-
170938
170914
  // ../wp-typia-project-tools/src/runtime/cli-add-types.ts
170939
- var ADD_KIND_IDS = [
170940
- "admin-view",
170941
- "block",
170942
- "variation",
170943
- "style",
170944
- "transform",
170945
- "pattern",
170946
- "binding-source",
170947
- "rest-resource",
170948
- "ability",
170949
- "ai-feature",
170950
- "hooked-block",
170951
- "editor-plugin"
170952
- ];
170953
170915
  var REST_RESOURCE_METHOD_IDS = [
170954
170916
  "list",
170955
170917
  "read",
@@ -170983,6 +170945,76 @@ var HOOKED_BLOCK_POSITION_IDS = ["before", "after", "firstChild", "lastChild"];
170983
170945
  var HOOKED_BLOCK_POSITION_SET = new Set(HOOKED_BLOCK_POSITION_IDS);
170984
170946
  var HOOKED_BLOCK_ANCHOR_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/;
170985
170947
 
170948
+ // ../wp-typia-project-tools/src/runtime/string-case.ts
170949
+ var COMMON_ACRONYM_PREFIXES = [
170950
+ "HTML",
170951
+ "HTTP",
170952
+ "JSON",
170953
+ "REST",
170954
+ "UUID",
170955
+ "API",
170956
+ "CSS",
170957
+ "CTA",
170958
+ "DOM",
170959
+ "PHP",
170960
+ "SQL",
170961
+ "SVG",
170962
+ "URL",
170963
+ "XML",
170964
+ "ID",
170965
+ "JS",
170966
+ "UI",
170967
+ "WP"
170968
+ ];
170969
+ function capitalizeSegment(segment) {
170970
+ return segment.charAt(0).toUpperCase() + segment.slice(1);
170971
+ }
170972
+ function findCommonAcronymPrefix(segment) {
170973
+ return COMMON_ACRONYM_PREFIXES.find((prefix) => segment.startsWith(prefix));
170974
+ }
170975
+ function splitKnownAcronymSegment(segment) {
170976
+ const prefixes = [];
170977
+ let remaining = segment;
170978
+ while (remaining.length > 0) {
170979
+ const prefix = findCommonAcronymPrefix(remaining);
170980
+ if (!prefix) {
170981
+ break;
170982
+ }
170983
+ const suffix = remaining.slice(prefix.length);
170984
+ if (/^[A-Z][a-z]/.test(suffix)) {
170985
+ return [...prefixes, prefix, suffix].join("-");
170986
+ }
170987
+ if (!findCommonAcronymPrefix(suffix)) {
170988
+ break;
170989
+ }
170990
+ prefixes.push(prefix);
170991
+ remaining = suffix;
170992
+ }
170993
+ return segment;
170994
+ }
170995
+ function splitAcronymBoundary(value) {
170996
+ return value.replace(/[A-Z]{2,}[a-z]+/g, splitKnownAcronymSegment);
170997
+ }
170998
+ function toKebabCase(input) {
170999
+ return splitAcronymBoundary(input.trim()).replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-").toLowerCase();
171000
+ }
171001
+ function toSnakeCase(input) {
171002
+ return toKebabCase(input).replace(/-/g, "_");
171003
+ }
171004
+ function toPascalCase(input) {
171005
+ return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join("");
171006
+ }
171007
+ function toCamelCase(input) {
171008
+ const pascalCase = toPascalCase(input);
171009
+ return `${pascalCase.charAt(0).toLowerCase()}${pascalCase.slice(1)}`;
171010
+ }
171011
+ function toSegmentPascalCase(input) {
171012
+ return input.replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean).map(capitalizeSegment).join("");
171013
+ }
171014
+ function toTitleCase(input) {
171015
+ return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join(" ");
171016
+ }
171017
+
170986
171018
  // ../wp-typia-project-tools/src/runtime/cli-add-validation.ts
170987
171019
  var WORKSPACE_GENERATED_SLUG_PATTERN = /^[a-z][a-z0-9-]*$/;
170988
171020
  var REST_RESOURCE_NAMESPACE_PATTERN = /^[a-z][a-z0-9-]*(?:\/[a-z0-9-]+)+$/u;
@@ -171053,60 +171085,6 @@ function assertValidEditorPluginSlot(slot = "sidebar") {
171053
171085
  throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}. Legacy aliases: PluginSidebar, PluginDocumentSettingPanel.`);
171054
171086
  }
171055
171087
 
171056
- // ../wp-typia-project-tools/src/runtime/cli-add-filesystem.ts
171057
- import { promises as fsp } from "fs";
171058
- import path from "path";
171059
- function getWorkspaceBootstrapPath(workspace) {
171060
- const workspaceBaseName = workspace.packageName.split("/").pop() ?? workspace.packageName;
171061
- return path.join(workspace.projectDir, `${workspaceBaseName}.php`);
171062
- }
171063
- async function patchFile(filePath, transform) {
171064
- const currentSource = await fsp.readFile(filePath, "utf8");
171065
- const nextSource = transform(currentSource);
171066
- if (nextSource !== currentSource) {
171067
- await fsp.writeFile(filePath, nextSource, "utf8");
171068
- }
171069
- }
171070
- async function readOptionalFile(filePath) {
171071
- try {
171072
- return await fsp.readFile(filePath, "utf8");
171073
- } catch (error) {
171074
- if (isFileNotFoundError(error)) {
171075
- return null;
171076
- }
171077
- throw error;
171078
- }
171079
- }
171080
- async function restoreOptionalFile(filePath, source) {
171081
- if (source === null) {
171082
- await fsp.rm(filePath, { force: true });
171083
- return;
171084
- }
171085
- await fsp.mkdir(path.dirname(filePath), { recursive: true });
171086
- await fsp.writeFile(filePath, source, "utf8");
171087
- }
171088
- async function snapshotWorkspaceFiles(filePaths) {
171089
- const uniquePaths = Array.from(new Set(filePaths));
171090
- return Promise.all(uniquePaths.map(async (filePath) => ({
171091
- filePath,
171092
- source: await readOptionalFile(filePath)
171093
- })));
171094
- }
171095
- async function rollbackWorkspaceMutation(snapshot) {
171096
- for (const targetPath of snapshot.targetPaths) {
171097
- await fsp.rm(targetPath, { force: true, recursive: true });
171098
- }
171099
- for (const snapshotDir of snapshot.snapshotDirs) {
171100
- await fsp.rm(snapshotDir, { force: true, recursive: true });
171101
- }
171102
- for (const { filePath, source } of snapshot.fileSources) {
171103
- await restoreOptionalFile(filePath, source);
171104
- }
171105
- }
171106
- function isFileNotFoundError(error) {
171107
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
171108
- }
171109
-
171110
171088
  // ../wp-typia-project-tools/src/runtime/cli-add-help.ts
171111
171089
  function formatAddHelpText() {
171112
171090
  return `Usage:
@@ -171130,7 +171108,7 @@ Notes:
171130
171108
  \`add admin-view\` scaffolds an opt-in DataViews-powered WordPress admin screen under \`src/admin-views/\`.
171131
171109
  Pass \`--source rest-resource:<slug>\` to reuse a list-capable REST resource.
171132
171110
  Pass \`--source core-data:postType/post\` or \`--source core-data:taxonomy/category\` to bind a WordPress-owned entity collection.
171133
- Public installs currently gate this workflow until \`@wp-typia/dataviews\` is published to npm.
171111
+ Generated admin-view workspaces add \`@wp-typia/dataviews\` and the needed WordPress DataViews packages as opt-in dependencies.
171134
171112
  \`query-loop\` is a create-time scaffold family. Use \`wp-typia create <project-dir> --template query-loop\` instead of \`wp-typia add block\`.
171135
171113
  \`add variation\` targets an existing block slug from \`scripts/block-config.ts\`.
171136
171114
  \`add style\` registers a Block Styles option for an existing generated block.
@@ -171221,10 +171199,91 @@ function resolveScaffoldIdentifiers({
171221
171199
  textDomain: resolveValidatedTextDomain(textDomain ?? normalizedSlug)
171222
171200
  };
171223
171201
  }
171202
+ // ../wp-typia-project-tools/src/runtime/cli-add-filesystem.ts
171203
+ import { promises as fsp } from "fs";
171204
+ import path from "path";
171205
+ function getWorkspaceBootstrapPath(workspace) {
171206
+ const workspaceBaseName = workspace.packageName.split("/").pop() ?? workspace.packageName;
171207
+ return path.join(workspace.projectDir, `${workspaceBaseName}.php`);
171208
+ }
171209
+ async function patchFile(filePath, transform) {
171210
+ const currentSource = await fsp.readFile(filePath, "utf8");
171211
+ const nextSource = transform(currentSource);
171212
+ if (nextSource !== currentSource) {
171213
+ await fsp.writeFile(filePath, nextSource, "utf8");
171214
+ }
171215
+ }
171216
+ async function readOptionalFile(filePath) {
171217
+ try {
171218
+ return await fsp.readFile(filePath, "utf8");
171219
+ } catch (error) {
171220
+ if (isFileNotFoundError(error)) {
171221
+ return null;
171222
+ }
171223
+ throw error;
171224
+ }
171225
+ }
171226
+ async function restoreOptionalFile(filePath, source) {
171227
+ if (source === null) {
171228
+ await fsp.rm(filePath, { force: true });
171229
+ return;
171230
+ }
171231
+ await fsp.mkdir(path.dirname(filePath), { recursive: true });
171232
+ await fsp.writeFile(filePath, source, "utf8");
171233
+ }
171234
+ async function snapshotWorkspaceFiles(filePaths) {
171235
+ const uniquePaths = Array.from(new Set(filePaths));
171236
+ return Promise.all(uniquePaths.map(async (filePath) => ({
171237
+ filePath,
171238
+ source: await readOptionalFile(filePath)
171239
+ })));
171240
+ }
171241
+ async function rollbackWorkspaceMutation(snapshot) {
171242
+ for (const targetPath of snapshot.targetPaths) {
171243
+ await fsp.rm(targetPath, { force: true, recursive: true });
171244
+ }
171245
+ for (const snapshotDir of snapshot.snapshotDirs) {
171246
+ await fsp.rm(snapshotDir, { force: true, recursive: true });
171247
+ }
171248
+ for (const { filePath, source } of snapshot.fileSources) {
171249
+ await restoreOptionalFile(filePath, source);
171250
+ }
171251
+ }
171252
+ function isFileNotFoundError(error) {
171253
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
171254
+ }
171224
171255
  // ../wp-typia-project-tools/src/runtime/cli-add-block-json.ts
171225
- import fs from "fs";
171226
171256
  import path2 from "path";
171227
171257
  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
171228
171287
  function resolveWorkspaceBlock(inventory, blockSlug) {
171229
171288
  const block = inventory.blocks.find((entry) => entry.slug === blockSlug);
171230
171289
  if (!block) {
@@ -171232,14 +171291,15 @@ function resolveWorkspaceBlock(inventory, blockSlug) {
171232
171291
  }
171233
171292
  return block;
171234
171293
  }
171235
- function readWorkspaceBlockJson(projectDir, blockSlug) {
171294
+ async function readWorkspaceBlockJson(projectDir, blockSlug) {
171236
171295
  const blockJsonPath = path2.join(projectDir, "src", "blocks", blockSlug, "block.json");
171237
- if (!fs.existsSync(blockJsonPath)) {
171296
+ const source = await readOptionalUtf8File(blockJsonPath);
171297
+ if (source === null) {
171238
171298
  throw new Error(`Missing ${path2.relative(projectDir, blockJsonPath)} for workspace block "${blockSlug}".`);
171239
171299
  }
171240
171300
  let blockJson;
171241
171301
  try {
171242
- blockJson = parseScaffoldBlockMetadata(JSON.parse(fs.readFileSync(blockJsonPath, "utf8")));
171302
+ blockJson = parseScaffoldBlockMetadata(JSON.parse(source));
171243
171303
  } catch (error) {
171244
171304
  throw new Error(error instanceof Error ? `Failed to parse ${path2.relative(projectDir, blockJsonPath)}: ${error.message}` : `Failed to parse ${path2.relative(projectDir, blockJsonPath)}.`);
171245
171305
  }
@@ -171261,12 +171321,12 @@ function getMutableBlockHooks(blockJson, blockJsonRelativePath) {
171261
171321
  return blockHooks;
171262
171322
  }
171263
171323
  // ../wp-typia-project-tools/src/runtime/cli-add-collision.ts
171264
- import fs2 from "fs";
171324
+ import fs from "fs";
171265
171325
  import path3 from "path";
171266
171326
  function assertScaffoldDoesNotExist(options) {
171267
171327
  for (const collision of options.filesystemCollisions) {
171268
171328
  const targetPath = path3.join(options.projectDir, collision.relativePath);
171269
- if (fs2.existsSync(targetPath)) {
171329
+ if (fs.existsSync(targetPath)) {
171270
171330
  throw new Error(`${collision.label} already exists at ${path3.relative(options.projectDir, targetPath)}. Choose a different name.`);
171271
171331
  }
171272
171332
  }
@@ -171274,185 +171334,250 @@ function assertScaffoldDoesNotExist(options) {
171274
171334
  throw new Error(options.inventoryCollision.message);
171275
171335
  }
171276
171336
  }
171277
- function assertVariationDoesNotExist(projectDir, blockSlug, variationSlug, inventory) {
171337
+ function assertAddKindScaffoldDoesNotExist(options) {
171338
+ const inventoryCollision = options.descriptor.inventoryCollision;
171278
171339
  assertScaffoldDoesNotExist({
171279
- filesystemCollisions: [
171280
- {
171281
- label: "A variation",
171282
- relativePath: path3.join("src", "blocks", blockSlug, "variations", `${variationSlug}.ts`)
171283
- }
171284
- ],
171285
- inventoryCollision: {
171286
- entries: inventory.variations,
171287
- exists: (entry) => entry.block === blockSlug && entry.slug === variationSlug,
171288
- message: `A variation inventory entry already exists for ${blockSlug}/${variationSlug}. Choose a different name.`
171340
+ filesystemCollisions: options.descriptor.filesystemCollisions.map((collision) => ({
171341
+ label: collision.label,
171342
+ relativePath: collision.relativePath(options.context)
171343
+ })),
171344
+ inventoryCollision: inventoryCollision ? {
171345
+ entries: inventoryCollision.entries(options.inventory),
171346
+ exists: (entry) => inventoryCollision.exists(entry, options.context),
171347
+ message: inventoryCollision.message(options.context)
171348
+ } : undefined,
171349
+ projectDir: options.projectDir
171350
+ });
171351
+ }
171352
+ var VARIATION_COLLISION_DESCRIPTOR = {
171353
+ filesystemCollisions: [
171354
+ {
171355
+ label: "A variation",
171356
+ relativePath: ({ blockSlug, slug }) => path3.join("src", "blocks", blockSlug, "variations", `${slug}.ts`)
171357
+ }
171358
+ ],
171359
+ inventoryCollision: {
171360
+ entries: (inventory) => inventory.variations,
171361
+ exists: (entry, { blockSlug, slug }) => entry.block === blockSlug && entry.slug === slug,
171362
+ message: ({ blockSlug, slug }) => `A variation inventory entry already exists for ${blockSlug}/${slug}. Choose a different name.`
171363
+ }
171364
+ };
171365
+ var BLOCK_STYLE_COLLISION_DESCRIPTOR = {
171366
+ filesystemCollisions: [
171367
+ {
171368
+ label: "A block style",
171369
+ relativePath: ({ blockSlug, slug }) => path3.join("src", "blocks", blockSlug, "styles", `${slug}.ts`)
171370
+ }
171371
+ ],
171372
+ inventoryCollision: {
171373
+ entries: (inventory) => inventory.blockStyles,
171374
+ exists: (entry, { blockSlug, slug }) => entry.block === blockSlug && entry.slug === slug,
171375
+ message: ({ blockSlug, slug }) => `A block style inventory entry already exists for ${blockSlug}/${slug}. Choose a different name.`
171376
+ }
171377
+ };
171378
+ var BLOCK_TRANSFORM_COLLISION_DESCRIPTOR = {
171379
+ filesystemCollisions: [
171380
+ {
171381
+ label: "A block transform",
171382
+ relativePath: ({ blockSlug, slug }) => path3.join("src", "blocks", blockSlug, "transforms", `${slug}.ts`)
171383
+ }
171384
+ ],
171385
+ inventoryCollision: {
171386
+ entries: (inventory) => inventory.blockTransforms,
171387
+ exists: (entry, { blockSlug, slug }) => entry.block === blockSlug && entry.slug === slug,
171388
+ message: ({ blockSlug, slug }) => `A block transform inventory entry already exists for ${blockSlug}/${slug}. Choose a different name.`
171389
+ }
171390
+ };
171391
+ var PATTERN_COLLISION_DESCRIPTOR = {
171392
+ filesystemCollisions: [
171393
+ {
171394
+ label: "A pattern",
171395
+ relativePath: ({ slug }) => path3.join("src", "patterns", `${slug}.php`)
171396
+ }
171397
+ ],
171398
+ inventoryCollision: {
171399
+ entries: (inventory) => inventory.patterns,
171400
+ exists: (entry, { slug }) => entry.slug === slug,
171401
+ message: ({ slug }) => `A pattern inventory entry already exists for ${slug}. Choose a different name.`
171402
+ }
171403
+ };
171404
+ var BINDING_SOURCE_COLLISION_DESCRIPTOR = {
171405
+ filesystemCollisions: [
171406
+ {
171407
+ label: "A binding source",
171408
+ relativePath: ({ slug }) => path3.join("src", "bindings", slug)
171409
+ }
171410
+ ],
171411
+ inventoryCollision: {
171412
+ entries: (inventory) => inventory.bindingSources,
171413
+ exists: (entry, { slug }) => entry.slug === slug,
171414
+ message: ({ slug }) => `A binding source inventory entry already exists for ${slug}. Choose a different name.`
171415
+ }
171416
+ };
171417
+ var REST_RESOURCE_COLLISION_DESCRIPTOR = {
171418
+ filesystemCollisions: [
171419
+ {
171420
+ label: "A REST resource",
171421
+ relativePath: ({ slug }) => path3.join("src", "rest", slug)
171289
171422
  },
171423
+ {
171424
+ label: "A REST resource bootstrap",
171425
+ relativePath: ({ slug }) => path3.join("inc", "rest", `${slug}.php`)
171426
+ }
171427
+ ],
171428
+ inventoryCollision: {
171429
+ entries: (inventory) => inventory.restResources,
171430
+ exists: (entry, { slug }) => entry.slug === slug,
171431
+ message: ({ slug }) => `A REST resource inventory entry already exists for ${slug}. Choose a different name.`
171432
+ }
171433
+ };
171434
+ var ADMIN_VIEW_COLLISION_DESCRIPTOR = {
171435
+ filesystemCollisions: [
171436
+ {
171437
+ label: "An admin view",
171438
+ relativePath: ({ slug }) => path3.join("src", "admin-views", slug)
171439
+ },
171440
+ {
171441
+ label: "An admin view bootstrap",
171442
+ relativePath: ({ slug }) => path3.join("inc", "admin-views", `${slug}.php`)
171443
+ }
171444
+ ],
171445
+ inventoryCollision: {
171446
+ entries: (inventory) => inventory.adminViews,
171447
+ exists: (entry, { slug }) => entry.slug === slug,
171448
+ message: ({ slug }) => `An admin view inventory entry already exists for ${slug}. Choose a different name.`
171449
+ }
171450
+ };
171451
+ var ABILITY_COLLISION_DESCRIPTOR = {
171452
+ filesystemCollisions: [
171453
+ {
171454
+ label: "An ability scaffold",
171455
+ relativePath: ({ slug }) => path3.join("src", "abilities", slug)
171456
+ },
171457
+ {
171458
+ label: "An ability bootstrap",
171459
+ relativePath: ({ slug }) => path3.join("inc", "abilities", `${slug}.php`)
171460
+ }
171461
+ ],
171462
+ inventoryCollision: {
171463
+ entries: (inventory) => inventory.abilities,
171464
+ exists: (entry, { slug }) => entry.slug === slug,
171465
+ message: ({ slug }) => `An ability inventory entry already exists for ${slug}. Choose a different name.`
171466
+ }
171467
+ };
171468
+ var AI_FEATURE_COLLISION_DESCRIPTOR = {
171469
+ filesystemCollisions: [
171470
+ {
171471
+ label: "An AI feature",
171472
+ relativePath: ({ slug }) => path3.join("src", "ai-features", slug)
171473
+ },
171474
+ {
171475
+ label: "An AI feature bootstrap",
171476
+ relativePath: ({ slug }) => path3.join("inc", "ai-features", `${slug}.php`)
171477
+ }
171478
+ ],
171479
+ inventoryCollision: {
171480
+ entries: (inventory) => inventory.aiFeatures,
171481
+ exists: (entry, { slug }) => entry.slug === slug,
171482
+ message: ({ slug }) => `An AI feature inventory entry already exists for ${slug}. Choose a different name.`
171483
+ }
171484
+ };
171485
+ var EDITOR_PLUGIN_COLLISION_DESCRIPTOR = {
171486
+ filesystemCollisions: [
171487
+ {
171488
+ label: "An editor plugin",
171489
+ relativePath: ({ slug }) => path3.join("src", "editor-plugins", slug)
171490
+ }
171491
+ ],
171492
+ inventoryCollision: {
171493
+ entries: (inventory) => inventory.editorPlugins,
171494
+ exists: (entry, { slug }) => entry.slug === slug,
171495
+ message: ({ slug }) => `An editor plugin inventory entry already exists for ${slug}. Choose a different name.`
171496
+ }
171497
+ };
171498
+ function assertVariationDoesNotExist(projectDir, blockSlug, variationSlug, inventory) {
171499
+ assertAddKindScaffoldDoesNotExist({
171500
+ context: { blockSlug, slug: variationSlug },
171501
+ descriptor: VARIATION_COLLISION_DESCRIPTOR,
171502
+ inventory,
171290
171503
  projectDir
171291
171504
  });
171292
171505
  }
171293
171506
  function assertBlockStyleDoesNotExist(projectDir, blockSlug, styleSlug, inventory) {
171294
- assertScaffoldDoesNotExist({
171295
- filesystemCollisions: [
171296
- {
171297
- label: "A block style",
171298
- relativePath: path3.join("src", "blocks", blockSlug, "styles", `${styleSlug}.ts`)
171299
- }
171300
- ],
171301
- inventoryCollision: {
171302
- entries: inventory.blockStyles,
171303
- exists: (entry) => entry.block === blockSlug && entry.slug === styleSlug,
171304
- message: `A block style inventory entry already exists for ${blockSlug}/${styleSlug}. Choose a different name.`
171305
- },
171507
+ assertAddKindScaffoldDoesNotExist({
171508
+ context: { blockSlug, slug: styleSlug },
171509
+ descriptor: BLOCK_STYLE_COLLISION_DESCRIPTOR,
171510
+ inventory,
171306
171511
  projectDir
171307
171512
  });
171308
171513
  }
171309
171514
  function assertBlockTransformDoesNotExist(projectDir, blockSlug, transformSlug, inventory) {
171310
- assertScaffoldDoesNotExist({
171311
- filesystemCollisions: [
171312
- {
171313
- label: "A block transform",
171314
- relativePath: path3.join("src", "blocks", blockSlug, "transforms", `${transformSlug}.ts`)
171315
- }
171316
- ],
171317
- inventoryCollision: {
171318
- entries: inventory.blockTransforms,
171319
- exists: (entry) => entry.block === blockSlug && entry.slug === transformSlug,
171320
- message: `A block transform inventory entry already exists for ${blockSlug}/${transformSlug}. Choose a different name.`
171321
- },
171515
+ assertAddKindScaffoldDoesNotExist({
171516
+ context: { blockSlug, slug: transformSlug },
171517
+ descriptor: BLOCK_TRANSFORM_COLLISION_DESCRIPTOR,
171518
+ inventory,
171322
171519
  projectDir
171323
171520
  });
171324
171521
  }
171325
171522
  function assertPatternDoesNotExist(projectDir, patternSlug, inventory) {
171326
- assertScaffoldDoesNotExist({
171327
- filesystemCollisions: [
171328
- {
171329
- label: "A pattern",
171330
- relativePath: path3.join("src", "patterns", `${patternSlug}.php`)
171331
- }
171332
- ],
171333
- inventoryCollision: {
171334
- entries: inventory.patterns,
171335
- exists: (entry) => entry.slug === patternSlug,
171336
- message: `A pattern inventory entry already exists for ${patternSlug}. Choose a different name.`
171337
- },
171523
+ assertAddKindScaffoldDoesNotExist({
171524
+ context: { slug: patternSlug },
171525
+ descriptor: PATTERN_COLLISION_DESCRIPTOR,
171526
+ inventory,
171338
171527
  projectDir
171339
171528
  });
171340
171529
  }
171341
171530
  function assertBindingSourceDoesNotExist(projectDir, bindingSourceSlug, inventory) {
171342
- assertScaffoldDoesNotExist({
171343
- filesystemCollisions: [
171344
- {
171345
- label: "A binding source",
171346
- relativePath: path3.join("src", "bindings", bindingSourceSlug)
171347
- }
171348
- ],
171349
- inventoryCollision: {
171350
- entries: inventory.bindingSources,
171351
- exists: (entry) => entry.slug === bindingSourceSlug,
171352
- message: `A binding source inventory entry already exists for ${bindingSourceSlug}. Choose a different name.`
171353
- },
171531
+ assertAddKindScaffoldDoesNotExist({
171532
+ context: { slug: bindingSourceSlug },
171533
+ descriptor: BINDING_SOURCE_COLLISION_DESCRIPTOR,
171534
+ inventory,
171354
171535
  projectDir
171355
171536
  });
171356
171537
  }
171357
171538
  function assertRestResourceDoesNotExist(projectDir, restResourceSlug, inventory) {
171358
- assertScaffoldDoesNotExist({
171359
- filesystemCollisions: [
171360
- {
171361
- label: "A REST resource",
171362
- relativePath: path3.join("src", "rest", restResourceSlug)
171363
- },
171364
- {
171365
- label: "A REST resource bootstrap",
171366
- relativePath: path3.join("inc", "rest", `${restResourceSlug}.php`)
171367
- }
171368
- ],
171369
- inventoryCollision: {
171370
- entries: inventory.restResources,
171371
- exists: (entry) => entry.slug === restResourceSlug,
171372
- message: `A REST resource inventory entry already exists for ${restResourceSlug}. Choose a different name.`
171373
- },
171539
+ assertAddKindScaffoldDoesNotExist({
171540
+ context: { slug: restResourceSlug },
171541
+ descriptor: REST_RESOURCE_COLLISION_DESCRIPTOR,
171542
+ inventory,
171374
171543
  projectDir
171375
171544
  });
171376
171545
  }
171377
171546
  function assertAdminViewDoesNotExist(projectDir, adminViewSlug, inventory) {
171378
- assertScaffoldDoesNotExist({
171379
- filesystemCollisions: [
171380
- {
171381
- label: "An admin view",
171382
- relativePath: path3.join("src", "admin-views", adminViewSlug)
171383
- },
171384
- {
171385
- label: "An admin view bootstrap",
171386
- relativePath: path3.join("inc", "admin-views", `${adminViewSlug}.php`)
171387
- }
171388
- ],
171389
- inventoryCollision: {
171390
- entries: inventory.adminViews,
171391
- exists: (entry) => entry.slug === adminViewSlug,
171392
- message: `An admin view inventory entry already exists for ${adminViewSlug}. Choose a different name.`
171393
- },
171547
+ assertAddKindScaffoldDoesNotExist({
171548
+ context: { slug: adminViewSlug },
171549
+ descriptor: ADMIN_VIEW_COLLISION_DESCRIPTOR,
171550
+ inventory,
171394
171551
  projectDir
171395
171552
  });
171396
171553
  }
171397
171554
  function assertAbilityDoesNotExist(projectDir, abilitySlug, inventory) {
171398
- assertScaffoldDoesNotExist({
171399
- filesystemCollisions: [
171400
- {
171401
- label: "An ability scaffold",
171402
- relativePath: path3.join("src", "abilities", abilitySlug)
171403
- },
171404
- {
171405
- label: "An ability bootstrap",
171406
- relativePath: path3.join("inc", "abilities", `${abilitySlug}.php`)
171407
- }
171408
- ],
171409
- inventoryCollision: {
171410
- entries: inventory.abilities,
171411
- exists: (entry) => entry.slug === abilitySlug,
171412
- message: `An ability inventory entry already exists for ${abilitySlug}. Choose a different name.`
171413
- },
171555
+ assertAddKindScaffoldDoesNotExist({
171556
+ context: { slug: abilitySlug },
171557
+ descriptor: ABILITY_COLLISION_DESCRIPTOR,
171558
+ inventory,
171414
171559
  projectDir
171415
171560
  });
171416
171561
  }
171417
171562
  function assertAiFeatureDoesNotExist(projectDir, aiFeatureSlug, inventory) {
171418
- assertScaffoldDoesNotExist({
171419
- filesystemCollisions: [
171420
- {
171421
- label: "An AI feature",
171422
- relativePath: path3.join("src", "ai-features", aiFeatureSlug)
171423
- },
171424
- {
171425
- label: "An AI feature bootstrap",
171426
- relativePath: path3.join("inc", "ai-features", `${aiFeatureSlug}.php`)
171427
- }
171428
- ],
171429
- inventoryCollision: {
171430
- entries: inventory.aiFeatures,
171431
- exists: (entry) => entry.slug === aiFeatureSlug,
171432
- message: `An AI feature inventory entry already exists for ${aiFeatureSlug}. Choose a different name.`
171433
- },
171563
+ assertAddKindScaffoldDoesNotExist({
171564
+ context: { slug: aiFeatureSlug },
171565
+ descriptor: AI_FEATURE_COLLISION_DESCRIPTOR,
171566
+ inventory,
171434
171567
  projectDir
171435
171568
  });
171436
171569
  }
171437
171570
  function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inventory) {
171438
- assertScaffoldDoesNotExist({
171439
- filesystemCollisions: [
171440
- {
171441
- label: "An editor plugin",
171442
- relativePath: path3.join("src", "editor-plugins", editorPluginSlug)
171443
- }
171444
- ],
171445
- inventoryCollision: {
171446
- entries: inventory.editorPlugins,
171447
- exists: (entry) => entry.slug === editorPluginSlug,
171448
- message: `An editor plugin inventory entry already exists for ${editorPluginSlug}. Choose a different name.`
171449
- },
171571
+ assertAddKindScaffoldDoesNotExist({
171572
+ context: { slug: editorPluginSlug },
171573
+ descriptor: EDITOR_PLUGIN_COLLISION_DESCRIPTOR,
171574
+ inventory,
171450
171575
  projectDir
171451
171576
  });
171452
171577
  }
171453
171578
  // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171454
171579
  var import_typescript = __toESM(require_typescript(), 1);
171455
- import fs3 from "fs";
171580
+ import fs2 from "fs";
171456
171581
  import path4 from "path";
171457
171582
  import { readFile, writeFile } from "fs/promises";
171458
171583
 
@@ -171466,6 +171591,236 @@ function quotePhpString(value) {
171466
171591
  function hasPhpFunctionDefinition(source, functionName) {
171467
171592
  return new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\(`, "u").test(source);
171468
171593
  }
171594
+ function isPhpIdentifierStart(character) {
171595
+ return /^[A-Za-z_]$/u.test(character ?? "");
171596
+ }
171597
+ function isPhpIdentifierPart(character) {
171598
+ return /^[A-Za-z0-9_]$/u.test(character ?? "");
171599
+ }
171600
+ function isPhpLineStart(source, index) {
171601
+ return index === 0 || source[index - 1] === `
171602
+ `;
171603
+ }
171604
+ function isPhpHorizontalWhitespace(character) {
171605
+ return character === " " || character === "\t";
171606
+ }
171607
+ function isPhpWhitespace(character) {
171608
+ return typeof character === "string" && /\s/u.test(character);
171609
+ }
171610
+ function findPhpLineBoundary(source, index) {
171611
+ const newlineIndex = source.indexOf(`
171612
+ `, index);
171613
+ if (newlineIndex === -1) {
171614
+ return {
171615
+ contentEnd: source.endsWith("\r") ? source.length - 1 : source.length,
171616
+ nextStart: source.length
171617
+ };
171618
+ }
171619
+ return {
171620
+ contentEnd: source[newlineIndex - 1] === "\r" ? newlineIndex - 1 : newlineIndex,
171621
+ nextStart: newlineIndex + 1
171622
+ };
171623
+ }
171624
+ function parsePhpHeredocStart(source, index) {
171625
+ if (!source.startsWith("<<<", index)) {
171626
+ return null;
171627
+ }
171628
+ let cursor = index + 3;
171629
+ while (isPhpHorizontalWhitespace(source[cursor])) {
171630
+ cursor += 1;
171631
+ }
171632
+ const quote = source[cursor] === "'" || source[cursor] === '"' ? source[cursor] : "";
171633
+ if (quote) {
171634
+ cursor += 1;
171635
+ }
171636
+ if (!isPhpIdentifierStart(source[cursor])) {
171637
+ return null;
171638
+ }
171639
+ const delimiterStart = cursor;
171640
+ cursor += 1;
171641
+ while (isPhpIdentifierPart(source[cursor])) {
171642
+ cursor += 1;
171643
+ }
171644
+ const delimiter = source.slice(delimiterStart, cursor);
171645
+ if (quote) {
171646
+ if (source[cursor] !== quote) {
171647
+ return null;
171648
+ }
171649
+ cursor += 1;
171650
+ }
171651
+ const lineBoundary = findPhpLineBoundary(source, cursor);
171652
+ if (source.slice(cursor, lineBoundary.contentEnd).trim() !== "") {
171653
+ return null;
171654
+ }
171655
+ return {
171656
+ contentStart: lineBoundary.nextStart,
171657
+ delimiter
171658
+ };
171659
+ }
171660
+ function findPhpHeredocClosingEnd(source, index, delimiter) {
171661
+ if (!isPhpLineStart(source, index)) {
171662
+ return null;
171663
+ }
171664
+ let cursor = index;
171665
+ while (isPhpHorizontalWhitespace(source[cursor])) {
171666
+ cursor += 1;
171667
+ }
171668
+ if (!source.startsWith(delimiter, cursor)) {
171669
+ return null;
171670
+ }
171671
+ cursor += delimiter.length;
171672
+ if (isPhpIdentifierPart(source[cursor])) {
171673
+ return null;
171674
+ }
171675
+ let continuationCursor = cursor;
171676
+ while (isPhpHorizontalWhitespace(source[continuationCursor])) {
171677
+ continuationCursor += 1;
171678
+ }
171679
+ const continuation = source[continuationCursor];
171680
+ if (continuationCursor >= source.length || continuation === "\r" || continuation === `
171681
+ ` || !isPhpIdentifierPart(continuation)) {
171682
+ return cursor;
171683
+ }
171684
+ return null;
171685
+ }
171686
+ function skipPhpCallTrivia(source, index) {
171687
+ let cursor = index;
171688
+ while (cursor < source.length) {
171689
+ while (isPhpWhitespace(source[cursor])) {
171690
+ cursor += 1;
171691
+ }
171692
+ if (source[cursor] === "/" && source[cursor + 1] === "*") {
171693
+ const commentEnd = source.indexOf("*/", cursor + 2);
171694
+ if (commentEnd === -1) {
171695
+ return null;
171696
+ }
171697
+ cursor = commentEnd + 2;
171698
+ continue;
171699
+ }
171700
+ if (source[cursor] === "/" && source[cursor + 1] === "/") {
171701
+ cursor = findPhpLineBoundary(source, cursor + 2).nextStart;
171702
+ continue;
171703
+ }
171704
+ if (source[cursor] === "#" && source[cursor + 1] !== "[") {
171705
+ cursor = findPhpLineBoundary(source, cursor + 1).nextStart;
171706
+ continue;
171707
+ }
171708
+ return cursor;
171709
+ }
171710
+ return cursor;
171711
+ }
171712
+ function matchesPhpFunctionCallAt(source, index, functionName) {
171713
+ if (!source.startsWith(functionName, index)) {
171714
+ return false;
171715
+ }
171716
+ if (isPhpIdentifierPart(source[index - 1])) {
171717
+ return false;
171718
+ }
171719
+ const cursor = index + functionName.length;
171720
+ if (isPhpIdentifierPart(source[cursor])) {
171721
+ return false;
171722
+ }
171723
+ const callStart = skipPhpCallTrivia(source, cursor);
171724
+ return callStart !== null && source[callStart] === "(";
171725
+ }
171726
+ function createPhpScannerState() {
171727
+ return {
171728
+ heredocDelimiter: "",
171729
+ mode: "code"
171730
+ };
171731
+ }
171732
+ function advancePhpScanner(source, index, state) {
171733
+ const character = source[index];
171734
+ if (state.mode === "heredoc") {
171735
+ const closingEnd = findPhpHeredocClosingEnd(source, index, state.heredocDelimiter);
171736
+ if (closingEnd !== null) {
171737
+ state.mode = "code";
171738
+ state.heredocDelimiter = "";
171739
+ return { ambiguous: false, inCode: false, index: closingEnd };
171740
+ }
171741
+ const nextLineStart = findPhpLineBoundary(source, index).nextStart;
171742
+ if (nextLineStart <= index) {
171743
+ return { ambiguous: true, inCode: false, index };
171744
+ }
171745
+ return { ambiguous: false, inCode: false, index: nextLineStart };
171746
+ }
171747
+ if (state.mode === "single-quoted" || state.mode === "double-quoted") {
171748
+ const quote = state.mode === "single-quoted" ? "'" : '"';
171749
+ if (character === "\\") {
171750
+ return { ambiguous: false, inCode: false, index: index + 2 };
171751
+ }
171752
+ if (character === quote) {
171753
+ state.mode = "code";
171754
+ }
171755
+ return { ambiguous: false, inCode: false, index: index + 1 };
171756
+ }
171757
+ if (state.mode === "line-comment") {
171758
+ if (character === "\r" || character === `
171759
+ `) {
171760
+ state.mode = "code";
171761
+ }
171762
+ return { ambiguous: false, inCode: false, index: index + 1 };
171763
+ }
171764
+ if (state.mode === "block-comment") {
171765
+ if (character === "*" && source[index + 1] === "/") {
171766
+ state.mode = "code";
171767
+ return { ambiguous: false, inCode: false, index: index + 2 };
171768
+ }
171769
+ return { ambiguous: false, inCode: false, index: index + 1 };
171770
+ }
171771
+ if (character === "'") {
171772
+ state.mode = "single-quoted";
171773
+ return { ambiguous: false, inCode: false, index: index + 1 };
171774
+ }
171775
+ if (character === '"') {
171776
+ state.mode = "double-quoted";
171777
+ return { ambiguous: false, inCode: false, index: index + 1 };
171778
+ }
171779
+ if (character === "/" && source[index + 1] === "/") {
171780
+ state.mode = "line-comment";
171781
+ return { ambiguous: false, inCode: false, index: index + 2 };
171782
+ }
171783
+ if (character === "#" && source[index + 1] !== "[") {
171784
+ state.mode = "line-comment";
171785
+ return { ambiguous: false, inCode: false, index: index + 1 };
171786
+ }
171787
+ if (character === "/" && source[index + 1] === "*") {
171788
+ state.mode = "block-comment";
171789
+ return { ambiguous: false, inCode: false, index: index + 2 };
171790
+ }
171791
+ if (character === "<") {
171792
+ const heredocStart = parsePhpHeredocStart(source, index);
171793
+ if (heredocStart) {
171794
+ state.mode = "heredoc";
171795
+ state.heredocDelimiter = heredocStart.delimiter;
171796
+ return {
171797
+ ambiguous: false,
171798
+ inCode: false,
171799
+ index: heredocStart.contentStart
171800
+ };
171801
+ }
171802
+ }
171803
+ return { ambiguous: false, inCode: true, index };
171804
+ }
171805
+ function hasPhpFunctionCall(source, functionName) {
171806
+ const scanner = createPhpScannerState();
171807
+ let index = 0;
171808
+ while (index < source.length) {
171809
+ const scan = advancePhpScanner(source, index, scanner);
171810
+ if (scan.ambiguous) {
171811
+ return false;
171812
+ }
171813
+ if (!scan.inCode) {
171814
+ index = scan.index;
171815
+ continue;
171816
+ }
171817
+ if (matchesPhpFunctionCallAt(source, index, functionName)) {
171818
+ return true;
171819
+ }
171820
+ index += 1;
171821
+ }
171822
+ return false;
171823
+ }
171469
171824
  function findPhpFunctionRange(source, functionName, options = {}) {
171470
171825
  const signaturePattern = new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\([^)]*\\)\\s*(?::\\s*[^{};]+)?\\s*\\{`, "u");
171471
171826
  const signatureMatch = signaturePattern.exec(source);
@@ -171479,13 +171834,25 @@ function findPhpFunctionRange(source, functionName, options = {}) {
171479
171834
  }
171480
171835
  const openBraceIndex = functionStart + openBraceOffset;
171481
171836
  let depth = 0;
171482
- for (let index = openBraceIndex;index < source.length; index += 1) {
171837
+ const scanner = createPhpScannerState();
171838
+ let index = openBraceIndex;
171839
+ while (index < source.length) {
171840
+ const scan = advancePhpScanner(source, index, scanner);
171841
+ if (scan.ambiguous) {
171842
+ return null;
171843
+ }
171844
+ if (!scan.inCode) {
171845
+ index = scan.index;
171846
+ continue;
171847
+ }
171483
171848
  const character = source[index];
171484
171849
  if (character === "{") {
171485
171850
  depth += 1;
171851
+ index += 1;
171486
171852
  continue;
171487
171853
  }
171488
171854
  if (character !== "}") {
171855
+ index += 1;
171489
171856
  continue;
171490
171857
  }
171491
171858
  depth -= 1;
@@ -171502,6 +171869,7 @@ function findPhpFunctionRange(source, functionName, options = {}) {
171502
171869
  start: functionStart
171503
171870
  };
171504
171871
  }
171872
+ index += 1;
171505
171873
  }
171506
171874
  return null;
171507
171875
  }
@@ -171717,6 +172085,10 @@ export const EDITOR_PLUGINS: WorkspaceEditorPluginConfig[] = [
171717
172085
  ];
171718
172086
  `;
171719
172087
  var BLOCK_INVENTORY_SECTION = {
172088
+ append: {
172089
+ marker: BLOCK_CONFIG_ENTRY_MARKER,
172090
+ optionKey: "blockEntries"
172091
+ },
171720
172092
  parse: {
171721
172093
  entriesKey: "blocks",
171722
172094
  entry: defineInventoryEntryParser({
@@ -171735,6 +172107,10 @@ var BLOCK_INVENTORY_SECTION = {
171735
172107
  };
171736
172108
  var INVENTORY_SECTIONS = [
171737
172109
  {
172110
+ append: {
172111
+ marker: VARIATION_CONFIG_ENTRY_MARKER,
172112
+ optionKey: "variationEntries"
172113
+ },
171738
172114
  interface: {
171739
172115
  name: "WorkspaceVariationConfig",
171740
172116
  section: VARIATIONS_INTERFACE_SECTION
@@ -171757,6 +172133,10 @@ var INVENTORY_SECTIONS = [
171757
172133
  }
171758
172134
  },
171759
172135
  {
172136
+ append: {
172137
+ marker: BLOCK_STYLE_CONFIG_ENTRY_MARKER,
172138
+ optionKey: "blockStyleEntries"
172139
+ },
171760
172140
  interface: {
171761
172141
  name: "WorkspaceBlockStyleConfig",
171762
172142
  section: BLOCK_STYLES_INTERFACE_SECTION
@@ -171779,6 +172159,10 @@ var INVENTORY_SECTIONS = [
171779
172159
  }
171780
172160
  },
171781
172161
  {
172162
+ append: {
172163
+ marker: BLOCK_TRANSFORM_CONFIG_ENTRY_MARKER,
172164
+ optionKey: "blockTransformEntries"
172165
+ },
171782
172166
  interface: {
171783
172167
  name: "WorkspaceBlockTransformConfig",
171784
172168
  section: BLOCK_TRANSFORMS_INTERFACE_SECTION
@@ -171803,6 +172187,10 @@ var INVENTORY_SECTIONS = [
171803
172187
  }
171804
172188
  },
171805
172189
  {
172190
+ append: {
172191
+ marker: PATTERN_CONFIG_ENTRY_MARKER,
172192
+ optionKey: "patternEntries"
172193
+ },
171806
172194
  interface: {
171807
172195
  name: "WorkspacePatternConfig",
171808
172196
  section: PATTERNS_INTERFACE_SECTION
@@ -171824,6 +172212,10 @@ var INVENTORY_SECTIONS = [
171824
172212
  }
171825
172213
  },
171826
172214
  {
172215
+ append: {
172216
+ marker: BINDING_SOURCE_CONFIG_ENTRY_MARKER,
172217
+ optionKey: "bindingSourceEntries"
172218
+ },
171827
172219
  interface: {
171828
172220
  name: "WorkspaceBindingSourceConfig",
171829
172221
  section: BINDING_SOURCES_INTERFACE_SECTION
@@ -171848,6 +172240,10 @@ var INVENTORY_SECTIONS = [
171848
172240
  }
171849
172241
  },
171850
172242
  {
172243
+ append: {
172244
+ marker: REST_RESOURCE_CONFIG_ENTRY_MARKER,
172245
+ optionKey: "restResourceEntries"
172246
+ },
171851
172247
  interface: {
171852
172248
  name: "WorkspaceRestResourceConfig",
171853
172249
  section: REST_RESOURCES_INTERFACE_SECTION
@@ -171888,6 +172284,10 @@ var INVENTORY_SECTIONS = [
171888
172284
  }
171889
172285
  },
171890
172286
  {
172287
+ append: {
172288
+ marker: ABILITY_CONFIG_ENTRY_MARKER,
172289
+ optionKey: "abilityEntries"
172290
+ },
171891
172291
  interface: {
171892
172292
  name: "WorkspaceAbilityConfig",
171893
172293
  section: ABILITIES_INTERFACE_SECTION
@@ -171917,6 +172317,10 @@ var INVENTORY_SECTIONS = [
171917
172317
  }
171918
172318
  },
171919
172319
  {
172320
+ append: {
172321
+ marker: AI_FEATURE_CONFIG_ENTRY_MARKER,
172322
+ optionKey: "aiFeatureEntries"
172323
+ },
171920
172324
  interface: {
171921
172325
  name: "WorkspaceAiFeatureConfig",
171922
172326
  section: AI_FEATURES_INTERFACE_SECTION
@@ -171946,6 +172350,10 @@ var INVENTORY_SECTIONS = [
171946
172350
  }
171947
172351
  },
171948
172352
  {
172353
+ append: {
172354
+ marker: ADMIN_VIEW_CONFIG_ENTRY_MARKER,
172355
+ optionKey: "adminViewEntries"
172356
+ },
171949
172357
  interface: {
171950
172358
  name: "WorkspaceAdminViewConfig",
171951
172359
  section: ADMIN_VIEWS_INTERFACE_SECTION
@@ -171969,6 +172377,10 @@ var INVENTORY_SECTIONS = [
171969
172377
  }
171970
172378
  },
171971
172379
  {
172380
+ append: {
172381
+ marker: EDITOR_PLUGIN_CONFIG_ENTRY_MARKER,
172382
+ optionKey: "editorPluginEntries"
172383
+ },
171972
172384
  interface: {
171973
172385
  name: "WorkspaceEditorPluginConfig",
171974
172386
  section: EDITOR_PLUGINS_INTERFACE_SECTION
@@ -172164,7 +172576,7 @@ function readWorkspaceInventory(projectDir) {
172164
172576
  const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
172165
172577
  let source;
172166
172578
  try {
172167
- source = fs3.readFileSync(blockConfigPath, "utf8");
172579
+ source = fs2.readFileSync(blockConfigPath, "utf8");
172168
172580
  } catch (error) {
172169
172581
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
172170
172582
  throw new Error(`Workspace inventory file is missing at ${blockConfigPath}. Expected scripts/block-config.ts to exist.`);
@@ -172213,6 +172625,16 @@ function appendEntriesAtMarker(source, marker, entries) {
172213
172625
  `)}
172214
172626
  ${marker}`);
172215
172627
  }
172628
+ function appendInventorySectionEntries(source, options) {
172629
+ let nextSource = source;
172630
+ for (const section of [BLOCK_INVENTORY_SECTION, ...INVENTORY_SECTIONS]) {
172631
+ if (!section.append) {
172632
+ continue;
172633
+ }
172634
+ nextSource = appendEntriesAtMarker(nextSource, section.append.marker, options[section.append.optionKey] ?? []);
172635
+ }
172636
+ return nextSource;
172637
+ }
172216
172638
  function ensureInterfaceField(source, interfaceName, fieldName, fieldSource) {
172217
172639
  const interfacePattern = new RegExp(`(export\\s+interface\\s+${escapeRegex(interfaceName)}\\s*\\{\\r?\\n)([\\s\\S]*?)(\\r?\\n\\})`, "u");
172218
172640
  return source.replace(interfacePattern, (match, start, body, end) => {
@@ -172260,41 +172682,18 @@ function normalizeInterfaceFieldBlock(source, interfaceName, fieldName, fieldSou
172260
172682
  return `${start}${body.slice(0, fieldMatch.index)}${formattedFieldSource}${body.slice(fieldMatch.index + existingFieldSource.length)}${end}`;
172261
172683
  });
172262
172684
  }
172263
- function updateWorkspaceInventorySource(source, {
172264
- blockEntries = [],
172265
- blockStyleEntries = [],
172266
- blockTransformEntries = [],
172267
- bindingSourceEntries = [],
172268
- abilityEntries = [],
172269
- adminViewEntries = [],
172270
- aiFeatureEntries = [],
172271
- editorPluginEntries = [],
172272
- patternEntries = [],
172273
- restResourceEntries = [],
172274
- variationEntries = [],
172275
- transformSource
172276
- } = {}) {
172685
+ function updateWorkspaceInventorySource(source, options = {}) {
172277
172686
  let nextSource = ensureWorkspaceInventorySections(source);
172278
- if (transformSource) {
172279
- nextSource = transformSource(nextSource);
172687
+ if (options.transformSource) {
172688
+ nextSource = options.transformSource(nextSource);
172280
172689
  }
172281
- nextSource = appendEntriesAtMarker(nextSource, BLOCK_CONFIG_ENTRY_MARKER, blockEntries);
172282
- nextSource = appendEntriesAtMarker(nextSource, VARIATION_CONFIG_ENTRY_MARKER, variationEntries);
172283
- nextSource = appendEntriesAtMarker(nextSource, BLOCK_STYLE_CONFIG_ENTRY_MARKER, blockStyleEntries);
172284
- nextSource = appendEntriesAtMarker(nextSource, BLOCK_TRANSFORM_CONFIG_ENTRY_MARKER, blockTransformEntries);
172285
- nextSource = appendEntriesAtMarker(nextSource, PATTERN_CONFIG_ENTRY_MARKER, patternEntries);
172286
- nextSource = appendEntriesAtMarker(nextSource, BINDING_SOURCE_CONFIG_ENTRY_MARKER, bindingSourceEntries);
172287
- nextSource = appendEntriesAtMarker(nextSource, REST_RESOURCE_CONFIG_ENTRY_MARKER, restResourceEntries);
172288
- nextSource = appendEntriesAtMarker(nextSource, ABILITY_CONFIG_ENTRY_MARKER, abilityEntries);
172289
- nextSource = appendEntriesAtMarker(nextSource, AI_FEATURE_CONFIG_ENTRY_MARKER, aiFeatureEntries);
172290
- nextSource = appendEntriesAtMarker(nextSource, ADMIN_VIEW_CONFIG_ENTRY_MARKER, adminViewEntries);
172690
+ nextSource = appendInventorySectionEntries(nextSource, options);
172291
172691
  nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "attribute", "\tattribute?: string;");
172292
172692
  nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "block", "\tblock?: string;");
172293
172693
  nextSource = ensureInterfaceField(nextSource, "WorkspaceAbilityConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
172294
172694
  nextSource = normalizeInterfaceFieldBlock(nextSource, "WorkspaceAbilityConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD, ["optionalFeatureIds: string[];", "requiredFeatureIds: string[];"]);
172295
172695
  nextSource = ensureInterfaceField(nextSource, "WorkspaceAiFeatureConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
172296
172696
  nextSource = normalizeInterfaceFieldBlock(nextSource, "WorkspaceAiFeatureConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD, ["optionalFeatureIds: string[];", "requiredFeatureIds: string[];"]);
172297
- nextSource = appendEntriesAtMarker(nextSource, EDITOR_PLUGIN_CONFIG_ENTRY_MARKER, editorPluginEntries);
172298
172697
  return nextSource;
172299
172698
  }
172300
172699
  async function appendWorkspaceInventoryEntries(projectDir, options) {
@@ -172306,6 +172705,6 @@ async function appendWorkspaceInventoryEntries(projectDir, options) {
172306
172705
  }
172307
172706
  }
172308
172707
 
172309
- export { toKebabCase, toSnakeCase, toPascalCase, toCamelCase, toSegmentPascalCase, toTitleCase, validateBlockSlug, validateNamespace, normalizeBlockSlug, resolveNonEmptyNormalizedBlockSlug, buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, ADD_KIND_IDS, 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, resolveWorkspaceBlock, readWorkspaceBlockJson, getMutableBlockHooks, assertVariationDoesNotExist, assertBlockStyleDoesNotExist, assertBlockTransformDoesNotExist, assertPatternDoesNotExist, assertBindingSourceDoesNotExist, assertRestResourceDoesNotExist, assertAdminViewDoesNotExist, assertAbilityDoesNotExist, assertAiFeatureDoesNotExist, assertEditorPluginDoesNotExist, formatAddHelpText, require_typescript, escapeRegex, quotePhpString, hasPhpFunctionDefinition, findPhpFunctionRange, replacePhpFunctionDefinition, readWorkspaceInventory, getWorkspaceBlockSelectOptions, updateWorkspaceInventorySource, appendWorkspaceInventoryEntries };
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 };
172310
172709
 
172311
- //# debugId=4D54C6227C5D15E364756E2164756E21
172710
+ //# debugId=6D5B4520C8A1BC7E64756E2164756E21