wp-typia 0.22.6 → 0.22.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,8 @@
1
1
  // @bun
2
+ import {
3
+ CLI_DIAGNOSTIC_CODES,
4
+ createCliDiagnosticCodeError
5
+ } from "./cli-p95wr1q8.js";
2
6
  import {
3
7
  WORKSPACE_TEMPLATE_PACKAGE
4
8
  } from "./cli-hhp1d348.js";
@@ -1734,11 +1738,11 @@ var require_buffer_from = __commonJS((exports, module) => {
1734
1738
  var require_source_map_support = __commonJS((exports, module) => {
1735
1739
  var SourceMapConsumer = require_source_map().SourceMapConsumer;
1736
1740
  var path4 = __require("path");
1737
- var fs3;
1741
+ var fs2;
1738
1742
  try {
1739
- fs3 = __require("fs");
1740
- if (!fs3.existsSync || !fs3.readFileSync) {
1741
- fs3 = null;
1743
+ fs2 = __require("fs");
1744
+ if (!fs2.existsSync || !fs2.readFileSync) {
1745
+ fs2 = null;
1742
1746
  }
1743
1747
  } catch (err) {}
1744
1748
  var bufferFrom = require_buffer_from();
@@ -1805,15 +1809,15 @@ var require_source_map_support = __commonJS((exports, module) => {
1805
1809
  }
1806
1810
  var contents = "";
1807
1811
  try {
1808
- if (!fs3) {
1812
+ if (!fs2) {
1809
1813
  var xhr = new XMLHttpRequest;
1810
1814
  xhr.open("GET", path5, false);
1811
1815
  xhr.send(null);
1812
1816
  if (xhr.readyState === 4 && xhr.status === 200) {
1813
1817
  contents = xhr.responseText;
1814
1818
  }
1815
- } else if (fs3.existsSync(path5)) {
1816
- contents = fs3.readFileSync(path5, "utf8");
1819
+ } else if (fs2.existsSync(path5)) {
1820
+ contents = fs2.readFileSync(path5, "utf8");
1817
1821
  }
1818
1822
  } catch (er) {}
1819
1823
  return fileContentsCache[path5] = contents;
@@ -2077,9 +2081,9 @@ var require_source_map_support = __commonJS((exports, module) => {
2077
2081
  var line = +match[2];
2078
2082
  var column = +match[3];
2079
2083
  var contents = fileContentsCache[source];
2080
- if (!contents && fs3 && fs3.existsSync(source)) {
2084
+ if (!contents && fs2 && fs2.existsSync(source)) {
2081
2085
  try {
2082
- contents = fs3.readFileSync(source, "utf8");
2086
+ contents = fs2.readFileSync(source, "utf8");
2083
2087
  } catch (er) {
2084
2088
  contents = "";
2085
2089
  }
@@ -5875,10 +5879,10 @@ var require_typescript = __commonJS((exports, module) => {
5875
5879
  function and(f, g) {
5876
5880
  return (arg) => f(arg) && g(arg);
5877
5881
  }
5878
- function or(...fs3) {
5882
+ function or(...fs2) {
5879
5883
  return (...args) => {
5880
5884
  let lastResult;
5881
- for (const f of fs3) {
5885
+ for (const f of fs2) {
5882
5886
  lastResult = f(...args);
5883
5887
  if (lastResult) {
5884
5888
  return lastResult;
@@ -7332,7 +7336,7 @@ ${lanes.join(`
7332
7336
  var tracing;
7333
7337
  var tracingEnabled;
7334
7338
  ((tracingEnabled2) => {
7335
- let fs3;
7339
+ let fs2;
7336
7340
  let traceCount = 0;
7337
7341
  let traceFd = 0;
7338
7342
  let mode;
@@ -7341,9 +7345,9 @@ ${lanes.join(`
7341
7345
  const legend = [];
7342
7346
  function startTracing2(tracingMode, traceDir, configFilePath) {
7343
7347
  Debug.assert(!tracing, "Tracing already started");
7344
- if (fs3 === undefined) {
7348
+ if (fs2 === undefined) {
7345
7349
  try {
7346
- fs3 = __require("fs");
7350
+ fs2 = __require("fs");
7347
7351
  } catch (e) {
7348
7352
  throw new Error(`tracing requires having fs
7349
7353
  (original error: ${e.message || e})`);
@@ -7354,8 +7358,8 @@ ${lanes.join(`
7354
7358
  if (legendPath === undefined) {
7355
7359
  legendPath = combinePaths(traceDir, "legend.json");
7356
7360
  }
7357
- if (!fs3.existsSync(traceDir)) {
7358
- fs3.mkdirSync(traceDir, { recursive: true });
7361
+ if (!fs2.existsSync(traceDir)) {
7362
+ fs2.mkdirSync(traceDir, { recursive: true });
7359
7363
  }
7360
7364
  const countPart = mode === "build" ? `.${process.pid}-${++traceCount}` : mode === "server" ? `.${process.pid}` : ``;
7361
7365
  const tracePath = combinePaths(traceDir, `trace${countPart}.json`);
@@ -7365,10 +7369,10 @@ ${lanes.join(`
7365
7369
  tracePath,
7366
7370
  typesPath
7367
7371
  });
7368
- traceFd = fs3.openSync(tracePath, "w");
7372
+ traceFd = fs2.openSync(tracePath, "w");
7369
7373
  tracing = tracingEnabled2;
7370
7374
  const meta = { cat: "__metadata", ph: "M", ts: 1000 * timestamp(), pid: 1, tid: 1 };
7371
- fs3.writeSync(traceFd, `[
7375
+ fs2.writeSync(traceFd, `[
7372
7376
  ` + [{ 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
7377
  `));
7374
7378
  }
@@ -7376,10 +7380,10 @@ ${lanes.join(`
7376
7380
  function stopTracing() {
7377
7381
  Debug.assert(tracing, "Tracing is not in progress");
7378
7382
  Debug.assert(!!typeCatalog.length === (mode !== "server"));
7379
- fs3.writeSync(traceFd, `
7383
+ fs2.writeSync(traceFd, `
7380
7384
  ]
7381
7385
  `);
7382
- fs3.closeSync(traceFd);
7386
+ fs2.closeSync(traceFd);
7383
7387
  tracing = undefined;
7384
7388
  if (typeCatalog.length) {
7385
7389
  dumpTypes(typeCatalog);
@@ -7444,13 +7448,13 @@ ${lanes.join(`
7444
7448
  if (mode === "server" && phase === "checkTypes")
7445
7449
  return;
7446
7450
  mark("beginTracing");
7447
- fs3.writeSync(traceFd, `,
7451
+ fs2.writeSync(traceFd, `,
7448
7452
  {"pid":1,"tid":1,"ph":"${eventType}","cat":"${phase}","ts":${time},"name":"${name}"`);
7449
7453
  if (extras)
7450
- fs3.writeSync(traceFd, `,${extras}`);
7454
+ fs2.writeSync(traceFd, `,${extras}`);
7451
7455
  if (args)
7452
- fs3.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
7453
- fs3.writeSync(traceFd, `}`);
7456
+ fs2.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
7457
+ fs2.writeSync(traceFd, `}`);
7454
7458
  mark("endTracing");
7455
7459
  measure("Tracing", "beginTracing", "endTracing");
7456
7460
  }
@@ -7472,9 +7476,9 @@ ${lanes.join(`
7472
7476
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
7473
7477
  mark("beginDumpTypes");
7474
7478
  const typesPath = legend[legend.length - 1].typesPath;
7475
- const typesFd = fs3.openSync(typesPath, "w");
7479
+ const typesFd = fs2.openSync(typesPath, "w");
7476
7480
  const recursionIdentityMap = /* @__PURE__ */ new Map;
7477
- fs3.writeSync(typesFd, "[");
7481
+ fs2.writeSync(typesFd, "[");
7478
7482
  const numTypes = types.length;
7479
7483
  for (let i = 0;i < numTypes; i++) {
7480
7484
  const type = types[i];
@@ -7570,15 +7574,15 @@ ${lanes.join(`
7570
7574
  flags: Debug.formatTypeFlags(type.flags).split("|"),
7571
7575
  display
7572
7576
  };
7573
- fs3.writeSync(typesFd, JSON.stringify(descriptor));
7577
+ fs2.writeSync(typesFd, JSON.stringify(descriptor));
7574
7578
  if (i < numTypes - 1) {
7575
- fs3.writeSync(typesFd, `,
7579
+ fs2.writeSync(typesFd, `,
7576
7580
  `);
7577
7581
  }
7578
7582
  }
7579
- fs3.writeSync(typesFd, `]
7583
+ fs2.writeSync(typesFd, `]
7580
7584
  `);
7581
- fs3.closeSync(typesFd);
7585
+ fs2.closeSync(typesFd);
7582
7586
  mark("endDumpTypes");
7583
7587
  measure("Dump types", "beginDumpTypes", "endDumpTypes");
7584
7588
  }
@@ -7586,7 +7590,7 @@ ${lanes.join(`
7586
7590
  if (!legendPath) {
7587
7591
  return;
7588
7592
  }
7589
- fs3.writeFileSync(legendPath, JSON.stringify(legend));
7593
+ fs2.writeFileSync(legendPath, JSON.stringify(legend));
7590
7594
  }
7591
7595
  tracingEnabled2.dumpLegend = dumpLegend;
7592
7596
  })(tracingEnabled || (tracingEnabled = {}));
@@ -170952,7 +170956,9 @@ var COMMON_ACRONYM_PREFIXES = [
170952
170956
  "JSON",
170953
170957
  "REST",
170954
170958
  "UUID",
170959
+ "AJAX",
170955
170960
  "API",
170961
+ "CPT",
170956
170962
  "CSS",
170957
170963
  "CTA",
170958
170964
  "DOM",
@@ -170966,12 +170972,16 @@ var COMMON_ACRONYM_PREFIXES = [
170966
170972
  "UI",
170967
170973
  "WP"
170968
170974
  ];
170975
+ var COMMON_ACRONYM_LOWERCASE_SUFFIXES = ["slug"];
170969
170976
  function capitalizeSegment(segment) {
170970
170977
  return segment.charAt(0).toUpperCase() + segment.slice(1);
170971
170978
  }
170972
170979
  function findCommonAcronymPrefix(segment) {
170973
170980
  return COMMON_ACRONYM_PREFIXES.find((prefix) => segment.startsWith(prefix));
170974
170981
  }
170982
+ function isCommonAcronymLowercaseSuffix(suffix) {
170983
+ return COMMON_ACRONYM_LOWERCASE_SUFFIXES.includes(suffix);
170984
+ }
170975
170985
  function splitKnownAcronymSegment(segment) {
170976
170986
  const prefixes = [];
170977
170987
  let remaining = segment;
@@ -170984,6 +170994,9 @@ function splitKnownAcronymSegment(segment) {
170984
170994
  if (/^[A-Z][a-z]/.test(suffix)) {
170985
170995
  return [...prefixes, prefix, suffix].join("-");
170986
170996
  }
170997
+ if (/^[a-z]+$/.test(suffix) && isCommonAcronymLowercaseSuffix(suffix)) {
170998
+ return [...prefixes, prefix, suffix].join("-");
170999
+ }
170987
171000
  if (!findCommonAcronymPrefix(suffix)) {
170988
171001
  break;
170989
171002
  }
@@ -171145,7 +171158,7 @@ function validatePhpPrefix(input) {
171145
171158
  function assertValidIdentifier(label, value, validate) {
171146
171159
  const result = validate(value);
171147
171160
  if (result !== true) {
171148
- throw new Error(typeof result === "string" ? `${label}: ${result}` : `${label} is invalid`);
171161
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, typeof result === "string" ? `${label}: ${result}` : `${label} is invalid`);
171149
171162
  }
171150
171163
  return value;
171151
171164
  }
@@ -171158,9 +171171,9 @@ function resolveNonEmptyNormalizedBlockSlug(options) {
171158
171171
  return normalizedSlug;
171159
171172
  }
171160
171173
  if (options.input.trim().length === 0) {
171161
- throw new Error(`${options.label} is required. Use \`${options.usage}\`.`);
171174
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, `${options.label} is required. Use \`${options.usage}\`.`);
171162
171175
  }
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.`);
171176
+ 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
171177
  }
171165
171178
  function resolveValidatedBlockSlug(value) {
171166
171179
  return assertValidIdentifier("Block slug", normalizeBlockSlug(value), validateBlockSlug);
@@ -171253,9 +171266,37 @@ function isFileNotFoundError(error) {
171253
171266
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
171254
171267
  }
171255
171268
  // ../wp-typia-project-tools/src/runtime/cli-add-block-json.ts
171256
- import fs from "fs";
171257
171269
  import path2 from "path";
171258
171270
  import { parseScaffoldBlockMetadata } from "@wp-typia/block-runtime/blocks";
171271
+
171272
+ // ../wp-typia-project-tools/src/runtime/fs-async.ts
171273
+ import { promises as fsp2 } from "fs";
171274
+ async function pathExists(filePath) {
171275
+ try {
171276
+ await fsp2.access(filePath);
171277
+ return true;
171278
+ } catch {
171279
+ return false;
171280
+ }
171281
+ }
171282
+ async function readOptionalUtf8File(filePath) {
171283
+ try {
171284
+ return await fsp2.readFile(filePath, "utf8");
171285
+ } catch (error) {
171286
+ if (isFileNotFoundError2(error)) {
171287
+ return null;
171288
+ }
171289
+ throw error;
171290
+ }
171291
+ }
171292
+ function getNodeErrorCode(error) {
171293
+ return typeof error === "object" && error !== null && "code" in error ? String(error.code) : "";
171294
+ }
171295
+ function isFileNotFoundError2(error) {
171296
+ return getNodeErrorCode(error) === "ENOENT";
171297
+ }
171298
+
171299
+ // ../wp-typia-project-tools/src/runtime/cli-add-block-json.ts
171259
171300
  function resolveWorkspaceBlock(inventory, blockSlug) {
171260
171301
  const block = inventory.blocks.find((entry) => entry.slug === blockSlug);
171261
171302
  if (!block) {
@@ -171263,14 +171304,15 @@ function resolveWorkspaceBlock(inventory, blockSlug) {
171263
171304
  }
171264
171305
  return block;
171265
171306
  }
171266
- function readWorkspaceBlockJson(projectDir, blockSlug) {
171307
+ async function readWorkspaceBlockJson(projectDir, blockSlug) {
171267
171308
  const blockJsonPath = path2.join(projectDir, "src", "blocks", blockSlug, "block.json");
171268
- if (!fs.existsSync(blockJsonPath)) {
171309
+ const source = await readOptionalUtf8File(blockJsonPath);
171310
+ if (source === null) {
171269
171311
  throw new Error(`Missing ${path2.relative(projectDir, blockJsonPath)} for workspace block "${blockSlug}".`);
171270
171312
  }
171271
171313
  let blockJson;
171272
171314
  try {
171273
- blockJson = parseScaffoldBlockMetadata(JSON.parse(fs.readFileSync(blockJsonPath, "utf8")));
171315
+ blockJson = parseScaffoldBlockMetadata(JSON.parse(source));
171274
171316
  } catch (error) {
171275
171317
  throw new Error(error instanceof Error ? `Failed to parse ${path2.relative(projectDir, blockJsonPath)}: ${error.message}` : `Failed to parse ${path2.relative(projectDir, blockJsonPath)}.`);
171276
171318
  }
@@ -171292,12 +171334,12 @@ function getMutableBlockHooks(blockJson, blockJsonRelativePath) {
171292
171334
  return blockHooks;
171293
171335
  }
171294
171336
  // ../wp-typia-project-tools/src/runtime/cli-add-collision.ts
171295
- import fs2 from "fs";
171337
+ import fs from "fs";
171296
171338
  import path3 from "path";
171297
171339
  function assertScaffoldDoesNotExist(options) {
171298
171340
  for (const collision of options.filesystemCollisions) {
171299
171341
  const targetPath = path3.join(options.projectDir, collision.relativePath);
171300
- if (fs2.existsSync(targetPath)) {
171342
+ if (fs.existsSync(targetPath)) {
171301
171343
  throw new Error(`${collision.label} already exists at ${path3.relative(options.projectDir, targetPath)}. Choose a different name.`);
171302
171344
  }
171303
171345
  }
@@ -171547,8 +171589,8 @@ function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inventory)
171547
171589
  });
171548
171590
  }
171549
171591
  // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171550
- var import_typescript = __toESM(require_typescript(), 1);
171551
- import fs3 from "fs";
171592
+ var import_typescript2 = __toESM(require_typescript(), 1);
171593
+ import { readFileSync } from "fs";
171552
171594
  import path4 from "path";
171553
171595
  import { readFile, writeFile } from "fs/promises";
171554
171596
 
@@ -171694,89 +171736,161 @@ function matchesPhpFunctionCallAt(source, index, functionName) {
171694
171736
  const callStart = skipPhpCallTrivia(source, cursor);
171695
171737
  return callStart !== null && source[callStart] === "(";
171696
171738
  }
171697
- function hasPhpFunctionCall(source, functionName) {
171698
- let mode = "code";
171699
- let heredocDelimiter = "";
171700
- let index = 0;
171701
- while (index < source.length) {
171702
- const character = source[index];
171703
- if (mode === "heredoc") {
171704
- const closingEnd = findPhpHeredocClosingEnd(source, index, heredocDelimiter);
171705
- if (closingEnd !== null) {
171706
- mode = "code";
171707
- heredocDelimiter = "";
171708
- index = closingEnd;
171709
- continue;
171710
- }
171711
- const nextLineStart = findPhpLineBoundary(source, index).nextStart;
171712
- if (nextLineStart <= index) {
171713
- return false;
171714
- }
171715
- index = nextLineStart;
171716
- continue;
171717
- }
171718
- if (mode === "single-quoted" || mode === "double-quoted") {
171719
- const quote = mode === "single-quoted" ? "'" : '"';
171739
+ function createPhpScannerState() {
171740
+ return {
171741
+ heredocDelimiter: "",
171742
+ interpolationComment: "",
171743
+ interpolationDepth: 0,
171744
+ interpolationQuote: "",
171745
+ mode: "code"
171746
+ };
171747
+ }
171748
+ function advancePhpScanner(source, index, state) {
171749
+ const character = source[index];
171750
+ if (state.mode === "heredoc") {
171751
+ const closingEnd = findPhpHeredocClosingEnd(source, index, state.heredocDelimiter);
171752
+ if (closingEnd !== null) {
171753
+ state.mode = "code";
171754
+ state.heredocDelimiter = "";
171755
+ return { ambiguous: false, inCode: false, index: closingEnd };
171756
+ }
171757
+ const nextLineStart = findPhpLineBoundary(source, index).nextStart;
171758
+ if (nextLineStart <= index) {
171759
+ return { ambiguous: true, inCode: false, index };
171760
+ }
171761
+ return { ambiguous: false, inCode: false, index: nextLineStart };
171762
+ }
171763
+ if (state.mode === "single-quoted" || state.mode === "double-quoted") {
171764
+ const quote = state.mode === "single-quoted" ? "'" : '"';
171765
+ if (character === "\\") {
171766
+ return { ambiguous: false, inCode: false, index: index + 2 };
171767
+ }
171768
+ if (state.mode === "double-quoted" && character === "{" && source[index + 1] === "$") {
171769
+ state.mode = "double-quoted-interpolation";
171770
+ state.interpolationComment = "";
171771
+ state.interpolationDepth = 1;
171772
+ state.interpolationQuote = "";
171773
+ return { ambiguous: false, inCode: false, index: index + 2 };
171774
+ }
171775
+ if (character === quote) {
171776
+ state.mode = "code";
171777
+ }
171778
+ return { ambiguous: false, inCode: false, index: index + 1 };
171779
+ }
171780
+ if (state.mode === "double-quoted-interpolation") {
171781
+ if (state.interpolationQuote) {
171720
171782
  if (character === "\\") {
171721
- index += 2;
171722
- continue;
171783
+ return { ambiguous: false, inCode: false, index: index + 2 };
171723
171784
  }
171724
- if (character === quote) {
171725
- mode = "code";
171785
+ if (character === state.interpolationQuote) {
171786
+ state.interpolationQuote = "";
171726
171787
  }
171727
- index += 1;
171728
- continue;
171788
+ return { ambiguous: false, inCode: false, index: index + 1 };
171729
171789
  }
171730
- if (mode === "line-comment") {
171790
+ if (state.interpolationComment === "line") {
171731
171791
  if (character === "\r" || character === `
171732
171792
  `) {
171733
- mode = "code";
171793
+ state.interpolationComment = "";
171734
171794
  }
171735
- index += 1;
171736
- continue;
171795
+ return { ambiguous: false, inCode: false, index: index + 1 };
171737
171796
  }
171738
- if (mode === "block-comment") {
171797
+ if (state.interpolationComment === "block") {
171739
171798
  if (character === "*" && source[index + 1] === "/") {
171740
- mode = "code";
171741
- index += 2;
171742
- continue;
171799
+ state.interpolationComment = "";
171800
+ return { ambiguous: false, inCode: false, index: index + 2 };
171743
171801
  }
171744
- index += 1;
171745
- continue;
171746
- }
171747
- if (character === "'") {
171748
- mode = "single-quoted";
171749
- index += 1;
171750
- continue;
171751
- }
171752
- if (character === '"') {
171753
- mode = "double-quoted";
171754
- index += 1;
171755
- continue;
171802
+ return { ambiguous: false, inCode: false, index: index + 1 };
171756
171803
  }
171757
171804
  if (character === "/" && source[index + 1] === "/") {
171758
- mode = "line-comment";
171759
- index += 2;
171760
- continue;
171805
+ state.interpolationComment = "line";
171806
+ return { ambiguous: false, inCode: false, index: index + 2 };
171761
171807
  }
171762
171808
  if (character === "#" && source[index + 1] !== "[") {
171763
- mode = "line-comment";
171764
- index += 1;
171765
- continue;
171809
+ state.interpolationComment = "line";
171810
+ return { ambiguous: false, inCode: false, index: index + 1 };
171766
171811
  }
171767
171812
  if (character === "/" && source[index + 1] === "*") {
171768
- mode = "block-comment";
171769
- index += 2;
171770
- continue;
171813
+ state.interpolationComment = "block";
171814
+ return { ambiguous: false, inCode: false, index: index + 2 };
171771
171815
  }
171772
- if (character === "<") {
171773
- const heredocStart = parsePhpHeredocStart(source, index);
171774
- if (heredocStart) {
171775
- mode = "heredoc";
171776
- heredocDelimiter = heredocStart.delimiter;
171777
- index = heredocStart.contentStart;
171778
- continue;
171816
+ if (character === "'" || character === '"') {
171817
+ state.interpolationQuote = character;
171818
+ return { ambiguous: false, inCode: false, index: index + 1 };
171819
+ }
171820
+ if (character === "{") {
171821
+ state.interpolationDepth += 1;
171822
+ return { ambiguous: false, inCode: false, index: index + 1 };
171823
+ }
171824
+ if (character === "}") {
171825
+ state.interpolationDepth -= 1;
171826
+ if (state.interpolationDepth <= 0) {
171827
+ state.interpolationComment = "";
171828
+ state.interpolationDepth = 0;
171829
+ state.mode = "double-quoted";
171779
171830
  }
171831
+ return { ambiguous: false, inCode: false, index: index + 1 };
171832
+ }
171833
+ return { ambiguous: false, inCode: false, index: index + 1 };
171834
+ }
171835
+ if (state.mode === "line-comment") {
171836
+ if (character === "\r" || character === `
171837
+ `) {
171838
+ state.mode = "code";
171839
+ }
171840
+ return { ambiguous: false, inCode: false, index: index + 1 };
171841
+ }
171842
+ if (state.mode === "block-comment") {
171843
+ if (character === "*" && source[index + 1] === "/") {
171844
+ state.mode = "code";
171845
+ return { ambiguous: false, inCode: false, index: index + 2 };
171846
+ }
171847
+ return { ambiguous: false, inCode: false, index: index + 1 };
171848
+ }
171849
+ if (character === "'") {
171850
+ state.mode = "single-quoted";
171851
+ return { ambiguous: false, inCode: false, index: index + 1 };
171852
+ }
171853
+ if (character === '"') {
171854
+ state.mode = "double-quoted";
171855
+ return { ambiguous: false, inCode: false, index: index + 1 };
171856
+ }
171857
+ if (character === "/" && source[index + 1] === "/") {
171858
+ state.mode = "line-comment";
171859
+ return { ambiguous: false, inCode: false, index: index + 2 };
171860
+ }
171861
+ if (character === "#" && source[index + 1] !== "[") {
171862
+ state.mode = "line-comment";
171863
+ return { ambiguous: false, inCode: false, index: index + 1 };
171864
+ }
171865
+ if (character === "/" && source[index + 1] === "*") {
171866
+ state.mode = "block-comment";
171867
+ return { ambiguous: false, inCode: false, index: index + 2 };
171868
+ }
171869
+ if (character === "<") {
171870
+ const heredocStart = parsePhpHeredocStart(source, index);
171871
+ if (heredocStart) {
171872
+ state.mode = "heredoc";
171873
+ state.heredocDelimiter = heredocStart.delimiter;
171874
+ return {
171875
+ ambiguous: false,
171876
+ inCode: false,
171877
+ index: heredocStart.contentStart
171878
+ };
171879
+ }
171880
+ }
171881
+ return { ambiguous: false, inCode: true, index };
171882
+ }
171883
+ function hasPhpFunctionCall(source, functionName) {
171884
+ const scanner = createPhpScannerState();
171885
+ let index = 0;
171886
+ while (index < source.length) {
171887
+ const scan = advancePhpScanner(source, index, scanner);
171888
+ if (scan.ambiguous) {
171889
+ return false;
171890
+ }
171891
+ if (!scan.inCode) {
171892
+ index = scan.index;
171893
+ continue;
171780
171894
  }
171781
171895
  if (matchesPhpFunctionCallAt(source, index, functionName)) {
171782
171896
  return true;
@@ -171798,89 +171912,18 @@ function findPhpFunctionRange(source, functionName, options = {}) {
171798
171912
  }
171799
171913
  const openBraceIndex = functionStart + openBraceOffset;
171800
171914
  let depth = 0;
171801
- let mode = "code";
171802
- let heredocDelimiter = "";
171915
+ const scanner = createPhpScannerState();
171803
171916
  let index = openBraceIndex;
171804
171917
  while (index < source.length) {
171805
- const character = source[index];
171806
- if (mode === "heredoc") {
171807
- const closingEnd = findPhpHeredocClosingEnd(source, index, heredocDelimiter);
171808
- if (closingEnd !== null) {
171809
- mode = "code";
171810
- heredocDelimiter = "";
171811
- index = closingEnd;
171812
- continue;
171813
- }
171814
- const nextLineStart = findPhpLineBoundary(source, index).nextStart;
171815
- if (nextLineStart <= index) {
171816
- return null;
171817
- }
171818
- index = nextLineStart;
171819
- continue;
171820
- }
171821
- if (mode === "single-quoted" || mode === "double-quoted") {
171822
- const quote = mode === "single-quoted" ? "'" : '"';
171823
- if (character === "\\") {
171824
- index += 2;
171825
- continue;
171826
- }
171827
- if (character === quote) {
171828
- mode = "code";
171829
- }
171830
- index += 1;
171831
- continue;
171832
- }
171833
- if (mode === "line-comment") {
171834
- if (character === "\r" || character === `
171835
- `) {
171836
- mode = "code";
171837
- }
171838
- index += 1;
171839
- continue;
171840
- }
171841
- if (mode === "block-comment") {
171842
- if (character === "*" && source[index + 1] === "/") {
171843
- mode = "code";
171844
- index += 2;
171845
- continue;
171846
- }
171847
- index += 1;
171848
- continue;
171849
- }
171850
- if (character === "'") {
171851
- mode = "single-quoted";
171852
- index += 1;
171853
- continue;
171854
- }
171855
- if (character === '"') {
171856
- mode = "double-quoted";
171857
- index += 1;
171858
- continue;
171859
- }
171860
- if (character === "/" && source[index + 1] === "/") {
171861
- mode = "line-comment";
171862
- index += 2;
171863
- continue;
171864
- }
171865
- if (character === "#" && source[index + 1] !== "[") {
171866
- mode = "line-comment";
171867
- index += 1;
171868
- continue;
171918
+ const scan = advancePhpScanner(source, index, scanner);
171919
+ if (scan.ambiguous) {
171920
+ return null;
171869
171921
  }
171870
- if (character === "/" && source[index + 1] === "*") {
171871
- mode = "block-comment";
171872
- index += 2;
171922
+ if (!scan.inCode) {
171923
+ index = scan.index;
171873
171924
  continue;
171874
171925
  }
171875
- if (character === "<") {
171876
- const heredocStart = parsePhpHeredocStart(source, index);
171877
- if (heredocStart) {
171878
- mode = "heredoc";
171879
- heredocDelimiter = heredocStart.delimiter;
171880
- index = heredocStart.contentStart;
171881
- continue;
171882
- }
171883
- }
171926
+ const character = source[index];
171884
171927
  if (character === "{") {
171885
171928
  depth += 1;
171886
171929
  index += 1;
@@ -171920,6 +171963,15 @@ function replacePhpFunctionDefinition(source, functionName, replacement, options
171920
171963
  ].join("");
171921
171964
  }
171922
171965
 
171966
+ // ../wp-typia-project-tools/src/runtime/ts-property-names.ts
171967
+ var import_typescript = __toESM(require_typescript(), 1);
171968
+ function getPropertyNameText(name) {
171969
+ if (import_typescript.default.isIdentifier(name) || import_typescript.default.isStringLiteral(name) || import_typescript.default.isNumericLiteral(name)) {
171970
+ return name.text;
171971
+ }
171972
+ return null;
171973
+ }
171974
+
171923
171975
  // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171924
171976
  function defineInventoryEntryParser(descriptor) {
171925
171977
  return descriptor;
@@ -172438,25 +172490,19 @@ var INVENTORY_SECTIONS = [
172438
172490
  }
172439
172491
  }
172440
172492
  ];
172441
- function getPropertyNameText(name) {
172442
- if (import_typescript.default.isIdentifier(name) || import_typescript.default.isStringLiteral(name)) {
172443
- return name.text;
172444
- }
172445
- return null;
172446
- }
172447
172493
  function findExportedArrayLiteral(sourceFile, exportName) {
172448
172494
  for (const statement of sourceFile.statements) {
172449
- if (!import_typescript.default.isVariableStatement(statement)) {
172495
+ if (!import_typescript2.default.isVariableStatement(statement)) {
172450
172496
  continue;
172451
172497
  }
172452
- if (!statement.modifiers?.some((modifier) => modifier.kind === import_typescript.default.SyntaxKind.ExportKeyword)) {
172498
+ if (!statement.modifiers?.some((modifier) => modifier.kind === import_typescript2.default.SyntaxKind.ExportKeyword)) {
172453
172499
  continue;
172454
172500
  }
172455
172501
  for (const declaration of statement.declarationList.declarations) {
172456
- if (!import_typescript.default.isIdentifier(declaration.name) || declaration.name.text !== exportName) {
172502
+ if (!import_typescript2.default.isIdentifier(declaration.name) || declaration.name.text !== exportName) {
172457
172503
  continue;
172458
172504
  }
172459
- if (declaration.initializer && import_typescript.default.isArrayLiteralExpression(declaration.initializer)) {
172505
+ if (declaration.initializer && import_typescript2.default.isArrayLiteralExpression(declaration.initializer)) {
172460
172506
  return {
172461
172507
  array: declaration.initializer,
172462
172508
  found: true
@@ -172475,14 +172521,14 @@ function findExportedArrayLiteral(sourceFile, exportName) {
172475
172521
  }
172476
172522
  function getOptionalStringProperty(entryName, elementIndex, objectLiteral, key) {
172477
172523
  for (const property of objectLiteral.properties) {
172478
- if (!import_typescript.default.isPropertyAssignment(property)) {
172524
+ if (!import_typescript2.default.isPropertyAssignment(property)) {
172479
172525
  continue;
172480
172526
  }
172481
172527
  const propertyName = getPropertyNameText(property.name);
172482
172528
  if (propertyName !== key) {
172483
172529
  continue;
172484
172530
  }
172485
- if (import_typescript.default.isStringLiteralLike(property.initializer)) {
172531
+ if (import_typescript2.default.isStringLiteralLike(property.initializer)) {
172486
172532
  return property.initializer.text;
172487
172533
  }
172488
172534
  throw new Error(`${entryName}[${elementIndex}] must use a string literal for "${key}" in scripts/block-config.ts.`);
@@ -172498,18 +172544,18 @@ function getRequiredStringProperty(entryName, elementIndex, objectLiteral, key)
172498
172544
  }
172499
172545
  function getRequiredStringArrayProperty(entryName, elementIndex, objectLiteral, key) {
172500
172546
  for (const property of objectLiteral.properties) {
172501
- if (!import_typescript.default.isPropertyAssignment(property)) {
172547
+ if (!import_typescript2.default.isPropertyAssignment(property)) {
172502
172548
  continue;
172503
172549
  }
172504
172550
  const propertyName = getPropertyNameText(property.name);
172505
172551
  if (propertyName !== key) {
172506
172552
  continue;
172507
172553
  }
172508
- if (!import_typescript.default.isArrayLiteralExpression(property.initializer)) {
172554
+ if (!import_typescript2.default.isArrayLiteralExpression(property.initializer)) {
172509
172555
  throw new Error(`${entryName}[${elementIndex}] must use an array literal for "${key}" in scripts/block-config.ts.`);
172510
172556
  }
172511
172557
  return property.initializer.elements.map((element, itemIndex) => {
172512
- if (!import_typescript.default.isStringLiteralLike(element)) {
172558
+ if (!import_typescript2.default.isStringLiteralLike(element)) {
172513
172559
  throw new Error(`${entryName}[${elementIndex}].${key}[${itemIndex}] must use a string literal in scripts/block-config.ts.`);
172514
172560
  }
172515
172561
  return element.text;
@@ -172519,7 +172565,7 @@ function getRequiredStringArrayProperty(entryName, elementIndex, objectLiteral,
172519
172565
  }
172520
172566
  function parseInventoryEntries(arrayLiteral, descriptor) {
172521
172567
  return arrayLiteral.elements.map((element, elementIndex) => {
172522
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
172568
+ if (!import_typescript2.default.isObjectLiteralExpression(element)) {
172523
172569
  throw new Error(`${descriptor.entryName}[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172524
172570
  }
172525
172571
  const entry = {};
@@ -172569,7 +172615,7 @@ function parseInventorySection(sourceFile, descriptor) {
172569
172615
  };
172570
172616
  }
172571
172617
  function parseWorkspaceInventorySource(source) {
172572
- const sourceFile = import_typescript.default.createSourceFile("block-config.ts", source, import_typescript.default.ScriptTarget.Latest, true, import_typescript.default.ScriptKind.TS);
172618
+ const sourceFile = import_typescript2.default.createSourceFile("block-config.ts", source, import_typescript2.default.ScriptTarget.Latest, true, import_typescript2.default.ScriptKind.TS);
172573
172619
  const parsedInventory = {
172574
172620
  abilities: [],
172575
172621
  adminViews: [],
@@ -172611,7 +172657,23 @@ function readWorkspaceInventory(projectDir) {
172611
172657
  const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
172612
172658
  let source;
172613
172659
  try {
172614
- source = fs3.readFileSync(blockConfigPath, "utf8");
172660
+ source = readFileSync(blockConfigPath, "utf8");
172661
+ } catch (error) {
172662
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
172663
+ throw new Error(`Workspace inventory file is missing at ${blockConfigPath}. Expected scripts/block-config.ts to exist.`);
172664
+ }
172665
+ throw error;
172666
+ }
172667
+ return {
172668
+ blockConfigPath,
172669
+ ...parseWorkspaceInventorySource(source)
172670
+ };
172671
+ }
172672
+ async function readWorkspaceInventoryAsync(projectDir) {
172673
+ const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
172674
+ let source;
172675
+ try {
172676
+ source = await readFile(blockConfigPath, "utf8");
172615
172677
  } catch (error) {
172616
172678
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
172617
172679
  throw new Error(`Workspace inventory file is missing at ${blockConfigPath}. Expected scripts/block-config.ts to exist.`);
@@ -172740,6 +172802,6 @@ async function appendWorkspaceInventoryEntries(projectDir, options) {
172740
172802
  }
172741
172803
  }
172742
172804
 
172743
- 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, 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 };
172805
+ 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, 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, updateWorkspaceInventorySource, appendWorkspaceInventoryEntries };
172744
172806
 
172745
- //# debugId=17AFFAD165D90DE964756E2164756E21
172807
+ //# debugId=282F6AFDCE13C26664756E2164756E21