wp-typia 0.22.8 → 0.22.10

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,7 @@
1
1
  // @bun
2
+ import {
3
+ suggestCloseId
4
+ } from "./cli-cvxvcw7c.js";
2
5
  import {
3
6
  CLI_DIAGNOSTIC_CODES,
4
7
  createCliDiagnosticCodeError
@@ -170943,6 +170946,11 @@ var ADD_BLOCK_TEMPLATE_IDS = [
170943
170946
  "persistence",
170944
170947
  "compound"
170945
170948
  ];
170949
+ function suggestAddBlockTemplateId(templateId) {
170950
+ return suggestCloseId(templateId, ADD_BLOCK_TEMPLATE_IDS, {
170951
+ maxDistance: 3
170952
+ });
170953
+ }
170946
170954
 
170947
170955
  // ../wp-typia-project-tools/src/runtime/hooked-blocks.ts
170948
170956
  var HOOKED_BLOCK_POSITION_IDS = ["before", "after", "firstChild", "lastChild"];
@@ -171098,6 +171106,36 @@ function assertValidEditorPluginSlot(slot = "sidebar") {
171098
171106
  throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}. Legacy aliases: PluginSidebar, PluginDocumentSettingPanel.`);
171099
171107
  }
171100
171108
 
171109
+ // ../wp-typia-project-tools/src/runtime/fs-async.ts
171110
+ import { promises as fsp } from "fs";
171111
+ async function pathExists(filePath) {
171112
+ try {
171113
+ await fsp.access(filePath);
171114
+ return true;
171115
+ } catch {
171116
+ return false;
171117
+ }
171118
+ }
171119
+ async function readOptionalUtf8File(filePath) {
171120
+ try {
171121
+ return await fsp.readFile(filePath, "utf8");
171122
+ } catch (error) {
171123
+ if (isFileNotFoundError(error)) {
171124
+ return null;
171125
+ }
171126
+ throw error;
171127
+ }
171128
+ }
171129
+ function getNodeErrorCode(error) {
171130
+ return getOptionalNodeErrorCode(error) ?? "";
171131
+ }
171132
+ function getOptionalNodeErrorCode(error) {
171133
+ return typeof error === "object" && error !== null && "code" in error ? String(error.code) : undefined;
171134
+ }
171135
+ function isFileNotFoundError(error) {
171136
+ return getOptionalNodeErrorCode(error) === "ENOENT";
171137
+ }
171138
+
171101
171139
  // ../wp-typia-project-tools/src/runtime/cli-add-help.ts
171102
171140
  function formatAddHelpText() {
171103
171141
  return `Usage:
@@ -171213,36 +171251,29 @@ function resolveScaffoldIdentifiers({
171213
171251
  };
171214
171252
  }
171215
171253
  // ../wp-typia-project-tools/src/runtime/cli-add-filesystem.ts
171216
- import { promises as fsp } from "fs";
171254
+ import { promises as fsp2 } from "fs";
171217
171255
  import path from "path";
171218
171256
  function getWorkspaceBootstrapPath(workspace) {
171219
171257
  const workspaceBaseName = workspace.packageName.split("/").pop() ?? workspace.packageName;
171220
171258
  return path.join(workspace.projectDir, `${workspaceBaseName}.php`);
171221
171259
  }
171222
171260
  async function patchFile(filePath, transform) {
171223
- const currentSource = await fsp.readFile(filePath, "utf8");
171261
+ const currentSource = await fsp2.readFile(filePath, "utf8");
171224
171262
  const nextSource = transform(currentSource);
171225
171263
  if (nextSource !== currentSource) {
171226
- await fsp.writeFile(filePath, nextSource, "utf8");
171264
+ await fsp2.writeFile(filePath, nextSource, "utf8");
171227
171265
  }
171228
171266
  }
171229
171267
  async function readOptionalFile(filePath) {
171230
- try {
171231
- return await fsp.readFile(filePath, "utf8");
171232
- } catch (error) {
171233
- if (isFileNotFoundError(error)) {
171234
- return null;
171235
- }
171236
- throw error;
171237
- }
171268
+ return readOptionalUtf8File(filePath);
171238
171269
  }
171239
171270
  async function restoreOptionalFile(filePath, source) {
171240
171271
  if (source === null) {
171241
- await fsp.rm(filePath, { force: true });
171272
+ await fsp2.rm(filePath, { force: true });
171242
171273
  return;
171243
171274
  }
171244
- await fsp.mkdir(path.dirname(filePath), { recursive: true });
171245
- await fsp.writeFile(filePath, source, "utf8");
171275
+ await fsp2.mkdir(path.dirname(filePath), { recursive: true });
171276
+ await fsp2.writeFile(filePath, source, "utf8");
171246
171277
  }
171247
171278
  async function snapshotWorkspaceFiles(filePaths) {
171248
171279
  const uniquePaths = Array.from(new Set(filePaths));
@@ -171253,50 +171284,18 @@ async function snapshotWorkspaceFiles(filePaths) {
171253
171284
  }
171254
171285
  async function rollbackWorkspaceMutation(snapshot) {
171255
171286
  for (const targetPath of snapshot.targetPaths) {
171256
- await fsp.rm(targetPath, { force: true, recursive: true });
171287
+ await fsp2.rm(targetPath, { force: true, recursive: true });
171257
171288
  }
171258
171289
  for (const snapshotDir of snapshot.snapshotDirs) {
171259
- await fsp.rm(snapshotDir, { force: true, recursive: true });
171290
+ await fsp2.rm(snapshotDir, { force: true, recursive: true });
171260
171291
  }
171261
171292
  for (const { filePath, source } of snapshot.fileSources) {
171262
171293
  await restoreOptionalFile(filePath, source);
171263
171294
  }
171264
171295
  }
171265
- function isFileNotFoundError(error) {
171266
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
171267
- }
171268
171296
  // ../wp-typia-project-tools/src/runtime/cli-add-block-json.ts
171269
171297
  import path2 from "path";
171270
171298
  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
171300
171299
  function resolveWorkspaceBlock(inventory, blockSlug) {
171301
171300
  const block = inventory.blocks.find((entry) => entry.slug === blockSlug);
171302
171301
  if (!block) {
@@ -171588,380 +171587,13 @@ function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inventory)
171588
171587
  projectDir
171589
171588
  });
171590
171589
  }
171591
- // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171592
- var import_typescript2 = __toESM(require_typescript(), 1);
171590
+ // ../wp-typia-project-tools/src/runtime/workspace-inventory-read.ts
171593
171591
  import { readFileSync } from "fs";
171594
171592
  import path4 from "path";
171595
- import { readFile, writeFile } from "fs/promises";
171593
+ import { readFile } from "fs/promises";
171596
171594
 
171597
- // ../wp-typia-project-tools/src/runtime/php-utils.ts
171598
- function escapeRegex(value) {
171599
- return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
171600
- }
171601
- function quotePhpString(value) {
171602
- return `'${value.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
171603
- }
171604
- function hasPhpFunctionDefinition(source, functionName) {
171605
- return new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\(`, "u").test(source);
171606
- }
171607
- function isPhpIdentifierStart(character) {
171608
- return /^[A-Za-z_]$/u.test(character ?? "");
171609
- }
171610
- function isPhpIdentifierPart(character) {
171611
- return /^[A-Za-z0-9_]$/u.test(character ?? "");
171612
- }
171613
- function isPhpLineStart(source, index) {
171614
- return index === 0 || source[index - 1] === `
171615
- `;
171616
- }
171617
- function isPhpHorizontalWhitespace(character) {
171618
- return character === " " || character === "\t";
171619
- }
171620
- function isPhpWhitespace(character) {
171621
- return typeof character === "string" && /\s/u.test(character);
171622
- }
171623
- function findPhpLineBoundary(source, index) {
171624
- const newlineIndex = source.indexOf(`
171625
- `, index);
171626
- if (newlineIndex === -1) {
171627
- return {
171628
- contentEnd: source.endsWith("\r") ? source.length - 1 : source.length,
171629
- nextStart: source.length
171630
- };
171631
- }
171632
- return {
171633
- contentEnd: source[newlineIndex - 1] === "\r" ? newlineIndex - 1 : newlineIndex,
171634
- nextStart: newlineIndex + 1
171635
- };
171636
- }
171637
- function parsePhpHeredocStart(source, index) {
171638
- if (!source.startsWith("<<<", index)) {
171639
- return null;
171640
- }
171641
- let cursor = index + 3;
171642
- while (isPhpHorizontalWhitespace(source[cursor])) {
171643
- cursor += 1;
171644
- }
171645
- const quote = source[cursor] === "'" || source[cursor] === '"' ? source[cursor] : "";
171646
- if (quote) {
171647
- cursor += 1;
171648
- }
171649
- if (!isPhpIdentifierStart(source[cursor])) {
171650
- return null;
171651
- }
171652
- const delimiterStart = cursor;
171653
- cursor += 1;
171654
- while (isPhpIdentifierPart(source[cursor])) {
171655
- cursor += 1;
171656
- }
171657
- const delimiter = source.slice(delimiterStart, cursor);
171658
- if (quote) {
171659
- if (source[cursor] !== quote) {
171660
- return null;
171661
- }
171662
- cursor += 1;
171663
- }
171664
- const lineBoundary = findPhpLineBoundary(source, cursor);
171665
- if (source.slice(cursor, lineBoundary.contentEnd).trim() !== "") {
171666
- return null;
171667
- }
171668
- return {
171669
- contentStart: lineBoundary.nextStart,
171670
- delimiter
171671
- };
171672
- }
171673
- function findPhpHeredocClosingEnd(source, index, delimiter) {
171674
- if (!isPhpLineStart(source, index)) {
171675
- return null;
171676
- }
171677
- let cursor = index;
171678
- while (isPhpHorizontalWhitespace(source[cursor])) {
171679
- cursor += 1;
171680
- }
171681
- if (!source.startsWith(delimiter, cursor)) {
171682
- return null;
171683
- }
171684
- cursor += delimiter.length;
171685
- if (isPhpIdentifierPart(source[cursor])) {
171686
- return null;
171687
- }
171688
- let continuationCursor = cursor;
171689
- while (isPhpHorizontalWhitespace(source[continuationCursor])) {
171690
- continuationCursor += 1;
171691
- }
171692
- const continuation = source[continuationCursor];
171693
- if (continuationCursor >= source.length || continuation === "\r" || continuation === `
171694
- ` || !isPhpIdentifierPart(continuation)) {
171695
- return cursor;
171696
- }
171697
- return null;
171698
- }
171699
- function skipPhpCallTrivia(source, index) {
171700
- let cursor = index;
171701
- while (cursor < source.length) {
171702
- while (isPhpWhitespace(source[cursor])) {
171703
- cursor += 1;
171704
- }
171705
- if (source[cursor] === "/" && source[cursor + 1] === "*") {
171706
- const commentEnd = source.indexOf("*/", cursor + 2);
171707
- if (commentEnd === -1) {
171708
- return null;
171709
- }
171710
- cursor = commentEnd + 2;
171711
- continue;
171712
- }
171713
- if (source[cursor] === "/" && source[cursor + 1] === "/") {
171714
- cursor = findPhpLineBoundary(source, cursor + 2).nextStart;
171715
- continue;
171716
- }
171717
- if (source[cursor] === "#" && source[cursor + 1] !== "[") {
171718
- cursor = findPhpLineBoundary(source, cursor + 1).nextStart;
171719
- continue;
171720
- }
171721
- return cursor;
171722
- }
171723
- return cursor;
171724
- }
171725
- function matchesPhpFunctionCallAt(source, index, functionName) {
171726
- if (!source.startsWith(functionName, index)) {
171727
- return false;
171728
- }
171729
- if (isPhpIdentifierPart(source[index - 1])) {
171730
- return false;
171731
- }
171732
- const cursor = index + functionName.length;
171733
- if (isPhpIdentifierPart(source[cursor])) {
171734
- return false;
171735
- }
171736
- const callStart = skipPhpCallTrivia(source, cursor);
171737
- return callStart !== null && source[callStart] === "(";
171738
- }
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) {
171782
- if (character === "\\") {
171783
- return { ambiguous: false, inCode: false, index: index + 2 };
171784
- }
171785
- if (character === state.interpolationQuote) {
171786
- state.interpolationQuote = "";
171787
- }
171788
- return { ambiguous: false, inCode: false, index: index + 1 };
171789
- }
171790
- if (state.interpolationComment === "line") {
171791
- if (character === "\r" || character === `
171792
- `) {
171793
- state.interpolationComment = "";
171794
- }
171795
- return { ambiguous: false, inCode: false, index: index + 1 };
171796
- }
171797
- if (state.interpolationComment === "block") {
171798
- if (character === "*" && source[index + 1] === "/") {
171799
- state.interpolationComment = "";
171800
- return { ambiguous: false, inCode: false, index: index + 2 };
171801
- }
171802
- return { ambiguous: false, inCode: false, index: index + 1 };
171803
- }
171804
- if (character === "/" && source[index + 1] === "/") {
171805
- state.interpolationComment = "line";
171806
- return { ambiguous: false, inCode: false, index: index + 2 };
171807
- }
171808
- if (character === "#" && source[index + 1] !== "[") {
171809
- state.interpolationComment = "line";
171810
- return { ambiguous: false, inCode: false, index: index + 1 };
171811
- }
171812
- if (character === "/" && source[index + 1] === "*") {
171813
- state.interpolationComment = "block";
171814
- return { ambiguous: false, inCode: false, index: index + 2 };
171815
- }
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";
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;
171894
- }
171895
- if (matchesPhpFunctionCallAt(source, index, functionName)) {
171896
- return true;
171897
- }
171898
- index += 1;
171899
- }
171900
- return false;
171901
- }
171902
- function findPhpFunctionRange(source, functionName, options = {}) {
171903
- const signaturePattern = new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\([^)]*\\)\\s*(?::\\s*[^{};]+)?\\s*\\{`, "u");
171904
- const signatureMatch = signaturePattern.exec(source);
171905
- if (!signatureMatch) {
171906
- return null;
171907
- }
171908
- const functionStart = signatureMatch.index;
171909
- const openBraceOffset = signatureMatch[0].lastIndexOf("{");
171910
- if (openBraceOffset === -1) {
171911
- return null;
171912
- }
171913
- const openBraceIndex = functionStart + openBraceOffset;
171914
- let depth = 0;
171915
- const scanner = createPhpScannerState();
171916
- let index = openBraceIndex;
171917
- while (index < source.length) {
171918
- const scan = advancePhpScanner(source, index, scanner);
171919
- if (scan.ambiguous) {
171920
- return null;
171921
- }
171922
- if (!scan.inCode) {
171923
- index = scan.index;
171924
- continue;
171925
- }
171926
- const character = source[index];
171927
- if (character === "{") {
171928
- depth += 1;
171929
- index += 1;
171930
- continue;
171931
- }
171932
- if (character !== "}") {
171933
- index += 1;
171934
- continue;
171935
- }
171936
- depth -= 1;
171937
- if (depth === 0) {
171938
- let end = index + 1;
171939
- if (options.includeTrailingNewlines ?? true) {
171940
- while (end < source.length && /[\r\n]/u.test(source[end] ?? "")) {
171941
- end += 1;
171942
- }
171943
- }
171944
- return {
171945
- end,
171946
- source: source.slice(functionStart, end),
171947
- start: functionStart
171948
- };
171949
- }
171950
- index += 1;
171951
- }
171952
- return null;
171953
- }
171954
- function replacePhpFunctionDefinition(source, functionName, replacement, options = {}) {
171955
- const functionRange = findPhpFunctionRange(source, functionName, options);
171956
- if (!functionRange) {
171957
- return null;
171958
- }
171959
- return [
171960
- source.slice(0, functionRange.start),
171961
- options.trimReplacementStart ? replacement.trimStart() : replacement,
171962
- source.slice(functionRange.end)
171963
- ].join("");
171964
- }
171595
+ // ../wp-typia-project-tools/src/runtime/workspace-inventory-parser.ts
171596
+ var import_typescript2 = __toESM(require_typescript(), 1);
171965
171597
 
171966
171598
  // ../wp-typia-project-tools/src/runtime/ts-property-names.ts
171967
171599
  var import_typescript = __toESM(require_typescript(), 1);
@@ -171972,10 +171604,7 @@ function getPropertyNameText(name) {
171972
171604
  return null;
171973
171605
  }
171974
171606
 
171975
- // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171976
- function defineInventoryEntryParser(descriptor) {
171977
- return descriptor;
171978
- }
171607
+ // ../wp-typia-project-tools/src/runtime/workspace-inventory-templates.ts
171979
171608
  var BLOCK_CONFIG_ENTRY_MARKER = "\t// wp-typia add block entries";
171980
171609
  var VARIATION_CONFIG_ENTRY_MARKER = "\t// wp-typia add variation entries";
171981
171610
  var BLOCK_STYLE_CONFIG_ENTRY_MARKER = "\t// wp-typia add style entries";
@@ -172171,6 +171800,11 @@ export const EDITOR_PLUGINS: WorkspaceEditorPluginConfig[] = [
172171
171800
  // wp-typia add editor-plugin entries
172172
171801
  ];
172173
171802
  `;
171803
+
171804
+ // ../wp-typia-project-tools/src/runtime/workspace-inventory-parser.ts
171805
+ function defineInventoryEntryParser() {
171806
+ return (descriptor) => descriptor;
171807
+ }
172174
171808
  var BLOCK_INVENTORY_SECTION = {
172175
171809
  append: {
172176
171810
  marker: BLOCK_CONFIG_ENTRY_MARKER,
@@ -172178,7 +171812,7 @@ var BLOCK_INVENTORY_SECTION = {
172178
171812
  },
172179
171813
  parse: {
172180
171814
  entriesKey: "blocks",
172181
- entry: defineInventoryEntryParser({
171815
+ entry: defineInventoryEntryParser()({
172182
171816
  entryName: "BLOCKS",
172183
171817
  fields: [
172184
171818
  { key: "apiTypesFile" },
@@ -172204,7 +171838,7 @@ var INVENTORY_SECTIONS = [
172204
171838
  },
172205
171839
  parse: {
172206
171840
  entriesKey: "variations",
172207
- entry: defineInventoryEntryParser({
171841
+ entry: defineInventoryEntryParser()({
172208
171842
  entryName: "VARIATIONS",
172209
171843
  fields: [
172210
171844
  { key: "block", required: true },
@@ -172230,7 +171864,7 @@ var INVENTORY_SECTIONS = [
172230
171864
  },
172231
171865
  parse: {
172232
171866
  entriesKey: "blockStyles",
172233
- entry: defineInventoryEntryParser({
171867
+ entry: defineInventoryEntryParser()({
172234
171868
  entryName: "BLOCK_STYLES",
172235
171869
  fields: [
172236
171870
  { key: "block", required: true },
@@ -172256,7 +171890,7 @@ var INVENTORY_SECTIONS = [
172256
171890
  },
172257
171891
  parse: {
172258
171892
  entriesKey: "blockTransforms",
172259
- entry: defineInventoryEntryParser({
171893
+ entry: defineInventoryEntryParser()({
172260
171894
  entryName: "BLOCK_TRANSFORMS",
172261
171895
  fields: [
172262
171896
  { key: "block", required: true },
@@ -172284,7 +171918,7 @@ var INVENTORY_SECTIONS = [
172284
171918
  },
172285
171919
  parse: {
172286
171920
  entriesKey: "patterns",
172287
- entry: defineInventoryEntryParser({
171921
+ entry: defineInventoryEntryParser()({
172288
171922
  entryName: "PATTERNS",
172289
171923
  fields: [
172290
171924
  { key: "file", required: true },
@@ -172309,7 +171943,7 @@ var INVENTORY_SECTIONS = [
172309
171943
  },
172310
171944
  parse: {
172311
171945
  entriesKey: "bindingSources",
172312
- entry: defineInventoryEntryParser({
171946
+ entry: defineInventoryEntryParser()({
172313
171947
  entryName: "BINDING_SOURCES",
172314
171948
  fields: [
172315
171949
  { key: "attribute" },
@@ -172337,7 +171971,7 @@ var INVENTORY_SECTIONS = [
172337
171971
  },
172338
171972
  parse: {
172339
171973
  entriesKey: "restResources",
172340
- entry: defineInventoryEntryParser({
171974
+ entry: defineInventoryEntryParser()({
172341
171975
  entryName: "REST_RESOURCES",
172342
171976
  fields: [
172343
171977
  { key: "apiFile", required: true },
@@ -172381,7 +172015,7 @@ var INVENTORY_SECTIONS = [
172381
172015
  },
172382
172016
  parse: {
172383
172017
  entriesKey: "abilities",
172384
- entry: defineInventoryEntryParser({
172018
+ entry: defineInventoryEntryParser()({
172385
172019
  entryName: "ABILITIES",
172386
172020
  fields: [
172387
172021
  { key: "clientFile", required: true },
@@ -172414,7 +172048,7 @@ var INVENTORY_SECTIONS = [
172414
172048
  },
172415
172049
  parse: {
172416
172050
  entriesKey: "aiFeatures",
172417
- entry: defineInventoryEntryParser({
172051
+ entry: defineInventoryEntryParser()({
172418
172052
  entryName: "AI_FEATURES",
172419
172053
  fields: [
172420
172054
  { key: "aiSchemaFile", required: true },
@@ -172447,7 +172081,7 @@ var INVENTORY_SECTIONS = [
172447
172081
  },
172448
172082
  parse: {
172449
172083
  entriesKey: "adminViews",
172450
- entry: defineInventoryEntryParser({
172084
+ entry: defineInventoryEntryParser()({
172451
172085
  entryName: "ADMIN_VIEWS",
172452
172086
  fields: [
172453
172087
  { key: "file", required: true },
@@ -172474,7 +172108,7 @@ var INVENTORY_SECTIONS = [
172474
172108
  },
172475
172109
  parse: {
172476
172110
  entriesKey: "editorPlugins",
172477
- entry: defineInventoryEntryParser({
172111
+ entry: defineInventoryEntryParser()({
172478
172112
  entryName: "EDITOR_PLUGINS",
172479
172113
  fields: [
172480
172114
  { key: "file", required: true },
@@ -172535,14 +172169,7 @@ function getOptionalStringProperty(entryName, elementIndex, objectLiteral, key)
172535
172169
  }
172536
172170
  return;
172537
172171
  }
172538
- function getRequiredStringProperty(entryName, elementIndex, objectLiteral, key) {
172539
- const value = getOptionalStringProperty(entryName, elementIndex, objectLiteral, key);
172540
- if (!value) {
172541
- throw new Error(`${entryName}[${elementIndex}] is missing required "${key}" in scripts/block-config.ts.`);
172542
- }
172543
- return value;
172544
- }
172545
- function getRequiredStringArrayProperty(entryName, elementIndex, objectLiteral, key) {
172172
+ function getOptionalStringArrayProperty(entryName, elementIndex, objectLiteral, key) {
172546
172173
  for (const property of objectLiteral.properties) {
172547
172174
  if (!import_typescript2.default.isPropertyAssignment(property)) {
172548
172175
  continue;
@@ -172561,7 +172188,19 @@ function getRequiredStringArrayProperty(entryName, elementIndex, objectLiteral,
172561
172188
  return element.text;
172562
172189
  });
172563
172190
  }
172564
- throw new Error(`${entryName}[${elementIndex}] is missing required "${key}" in scripts/block-config.ts.`);
172191
+ return;
172192
+ }
172193
+ function isMissingRequiredInventoryValue(value) {
172194
+ return value === undefined || typeof value === "string" && value.length === 0;
172195
+ }
172196
+ function formatMissingRequiredInventoryFields(keys) {
172197
+ return keys.length === 1 ? `required "${keys[0]}"` : `required fields ${keys.map((key) => `"${key}"`).join(", ")}`;
172198
+ }
172199
+ function assertParsedInventoryEntry(entry, descriptor, elementIndex) {
172200
+ const missingRequiredKeys = descriptor.fields.filter((field) => field.required === true && isMissingRequiredInventoryValue(entry[field.key])).map((field) => field.key);
172201
+ if (missingRequiredKeys.length > 0) {
172202
+ throw new Error(`${descriptor.entryName}[${elementIndex}] is missing ${formatMissingRequiredInventoryFields(missingRequiredKeys)} in scripts/block-config.ts.`);
172203
+ }
172565
172204
  }
172566
172205
  function parseInventoryEntries(arrayLiteral, descriptor) {
172567
172206
  return arrayLiteral.elements.map((element, elementIndex) => {
@@ -172571,7 +172210,7 @@ function parseInventoryEntries(arrayLiteral, descriptor) {
172571
172210
  const entry = {};
172572
172211
  for (const field of descriptor.fields) {
172573
172212
  const kind = field.kind ?? "string";
172574
- const value = kind === "stringArray" ? getRequiredStringArrayProperty(descriptor.entryName, elementIndex, element, field.key) : field.required ? getRequiredStringProperty(descriptor.entryName, elementIndex, element, field.key) : getOptionalStringProperty(descriptor.entryName, elementIndex, element, field.key);
172213
+ const value = kind === "stringArray" ? getOptionalStringArrayProperty(descriptor.entryName, elementIndex, element, field.key) : getOptionalStringProperty(descriptor.entryName, elementIndex, element, field.key);
172575
172214
  field.validate?.(value, {
172576
172215
  elementIndex,
172577
172216
  entryName: descriptor.entryName,
@@ -172579,6 +172218,7 @@ function parseInventoryEntries(arrayLiteral, descriptor) {
172579
172218
  });
172580
172219
  entry[field.key] = value;
172581
172220
  }
172221
+ assertParsedInventoryEntry(entry, descriptor, elementIndex);
172582
172222
  return entry;
172583
172223
  });
172584
172224
  }
@@ -172653,13 +172293,15 @@ function parseWorkspaceInventorySource(source) {
172653
172293
  }
172654
172294
  return parsedInventory;
172655
172295
  }
172296
+
172297
+ // ../wp-typia-project-tools/src/runtime/workspace-inventory-read.ts
172656
172298
  function readWorkspaceInventory(projectDir) {
172657
172299
  const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
172658
172300
  let source;
172659
172301
  try {
172660
172302
  source = readFileSync(blockConfigPath, "utf8");
172661
172303
  } catch (error) {
172662
- if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
172304
+ if (isFileNotFoundError(error)) {
172663
172305
  throw new Error(`Workspace inventory file is missing at ${blockConfigPath}. Expected scripts/block-config.ts to exist.`);
172664
172306
  }
172665
172307
  throw error;
@@ -172675,7 +172317,7 @@ async function readWorkspaceInventoryAsync(projectDir) {
172675
172317
  try {
172676
172318
  source = await readFile(blockConfigPath, "utf8");
172677
172319
  } catch (error) {
172678
- if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
172320
+ if (isFileNotFoundError(error)) {
172679
172321
  throw new Error(`Workspace inventory file is missing at ${blockConfigPath}. Expected scripts/block-config.ts to exist.`);
172680
172322
  }
172681
172323
  throw error;
@@ -172685,13 +172327,393 @@ async function readWorkspaceInventoryAsync(projectDir) {
172685
172327
  ...parseWorkspaceInventorySource(source)
172686
172328
  };
172687
172329
  }
172688
- function getWorkspaceBlockSelectOptions(projectDir) {
172689
- return readWorkspaceInventory(projectDir).blocks.map((block) => ({
172330
+ function toWorkspaceBlockSelectOptions(blocks) {
172331
+ return blocks.map((block) => ({
172690
172332
  description: block.typesFile,
172691
172333
  name: block.slug,
172692
172334
  value: block.slug
172693
172335
  }));
172694
172336
  }
172337
+ function getWorkspaceBlockSelectOptions(projectDir) {
172338
+ return toWorkspaceBlockSelectOptions(readWorkspaceInventory(projectDir).blocks);
172339
+ }
172340
+ async function getWorkspaceBlockSelectOptionsAsync(projectDir) {
172341
+ return toWorkspaceBlockSelectOptions((await readWorkspaceInventoryAsync(projectDir)).blocks);
172342
+ }
172343
+ // ../wp-typia-project-tools/src/runtime/workspace-inventory-mutations.ts
172344
+ import path5 from "path";
172345
+ import { readFile as readFile2, writeFile } from "fs/promises";
172346
+
172347
+ // ../wp-typia-project-tools/src/runtime/php-utils.ts
172348
+ function escapeRegex(value) {
172349
+ return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
172350
+ }
172351
+ function quotePhpString(value) {
172352
+ return `'${value.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
172353
+ }
172354
+ function hasPhpFunctionDefinition(source, functionName) {
172355
+ return new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\(`, "u").test(source);
172356
+ }
172357
+ function isPhpIdentifierStart(character) {
172358
+ return /^[A-Za-z_]$/u.test(character ?? "");
172359
+ }
172360
+ function isPhpIdentifierPart(character) {
172361
+ return /^[A-Za-z0-9_]$/u.test(character ?? "");
172362
+ }
172363
+ function isPhpLineStart(source, index) {
172364
+ return index === 0 || source[index - 1] === `
172365
+ `;
172366
+ }
172367
+ function isPhpHorizontalWhitespace(character) {
172368
+ return character === " " || character === "\t";
172369
+ }
172370
+ function isPhpWhitespace(character) {
172371
+ return typeof character === "string" && /\s/u.test(character);
172372
+ }
172373
+ function findPhpLineBoundary(source, index) {
172374
+ const newlineIndex = source.indexOf(`
172375
+ `, index);
172376
+ if (newlineIndex === -1) {
172377
+ return {
172378
+ contentEnd: source.endsWith("\r") ? source.length - 1 : source.length,
172379
+ nextStart: source.length
172380
+ };
172381
+ }
172382
+ return {
172383
+ contentEnd: source[newlineIndex - 1] === "\r" ? newlineIndex - 1 : newlineIndex,
172384
+ nextStart: newlineIndex + 1
172385
+ };
172386
+ }
172387
+ function parsePhpHeredocStart(source, index) {
172388
+ if (!source.startsWith("<<<", index)) {
172389
+ return null;
172390
+ }
172391
+ let cursor = index + 3;
172392
+ while (isPhpHorizontalWhitespace(source[cursor])) {
172393
+ cursor += 1;
172394
+ }
172395
+ const quote = source[cursor] === "'" || source[cursor] === '"' ? source[cursor] : "";
172396
+ if (quote) {
172397
+ cursor += 1;
172398
+ }
172399
+ if (!isPhpIdentifierStart(source[cursor])) {
172400
+ return null;
172401
+ }
172402
+ const delimiterStart = cursor;
172403
+ cursor += 1;
172404
+ while (isPhpIdentifierPart(source[cursor])) {
172405
+ cursor += 1;
172406
+ }
172407
+ const delimiter = source.slice(delimiterStart, cursor);
172408
+ if (quote) {
172409
+ if (source[cursor] !== quote) {
172410
+ return null;
172411
+ }
172412
+ cursor += 1;
172413
+ }
172414
+ const lineBoundary = findPhpLineBoundary(source, cursor);
172415
+ if (source.slice(cursor, lineBoundary.contentEnd).trim() !== "") {
172416
+ return null;
172417
+ }
172418
+ return {
172419
+ contentStart: lineBoundary.nextStart,
172420
+ delimiter
172421
+ };
172422
+ }
172423
+ function findPhpHeredocClosingEnd(source, index, delimiter) {
172424
+ if (!isPhpLineStart(source, index)) {
172425
+ return null;
172426
+ }
172427
+ let cursor = index;
172428
+ while (isPhpHorizontalWhitespace(source[cursor])) {
172429
+ cursor += 1;
172430
+ }
172431
+ if (!source.startsWith(delimiter, cursor)) {
172432
+ return null;
172433
+ }
172434
+ cursor += delimiter.length;
172435
+ if (isPhpIdentifierPart(source[cursor])) {
172436
+ return null;
172437
+ }
172438
+ let continuationCursor = cursor;
172439
+ while (isPhpHorizontalWhitespace(source[continuationCursor])) {
172440
+ continuationCursor += 1;
172441
+ }
172442
+ const continuation = source[continuationCursor];
172443
+ if (continuationCursor >= source.length || continuation === "\r" || continuation === `
172444
+ ` || !isPhpIdentifierPart(continuation)) {
172445
+ return cursor;
172446
+ }
172447
+ return null;
172448
+ }
172449
+ function skipPhpCallTrivia(source, index) {
172450
+ let cursor = index;
172451
+ while (cursor < source.length) {
172452
+ while (isPhpWhitespace(source[cursor])) {
172453
+ cursor += 1;
172454
+ }
172455
+ if (source[cursor] === "/" && source[cursor + 1] === "*") {
172456
+ const commentEnd = source.indexOf("*/", cursor + 2);
172457
+ if (commentEnd === -1) {
172458
+ return null;
172459
+ }
172460
+ cursor = commentEnd + 2;
172461
+ continue;
172462
+ }
172463
+ if (source[cursor] === "/" && source[cursor + 1] === "/") {
172464
+ cursor = findPhpLineBoundary(source, cursor + 2).nextStart;
172465
+ continue;
172466
+ }
172467
+ if (source[cursor] === "#" && source[cursor + 1] !== "[") {
172468
+ cursor = findPhpLineBoundary(source, cursor + 1).nextStart;
172469
+ continue;
172470
+ }
172471
+ return cursor;
172472
+ }
172473
+ return cursor;
172474
+ }
172475
+ function matchesPhpFunctionCallAt(source, index, functionName) {
172476
+ if (!source.startsWith(functionName, index)) {
172477
+ return false;
172478
+ }
172479
+ if (isPhpIdentifierPart(source[index - 1])) {
172480
+ return false;
172481
+ }
172482
+ const cursor = index + functionName.length;
172483
+ if (isPhpIdentifierPart(source[cursor])) {
172484
+ return false;
172485
+ }
172486
+ const callStart = skipPhpCallTrivia(source, cursor);
172487
+ return callStart !== null && source[callStart] === "(";
172488
+ }
172489
+ function createPhpScannerState() {
172490
+ return {
172491
+ heredocDelimiter: "",
172492
+ interpolationComment: "",
172493
+ interpolationDepth: 0,
172494
+ interpolationQuote: "",
172495
+ mode: "code"
172496
+ };
172497
+ }
172498
+ function advancePhpScanner(source, index, state) {
172499
+ const character = source[index];
172500
+ if (state.mode === "heredoc") {
172501
+ const closingEnd = findPhpHeredocClosingEnd(source, index, state.heredocDelimiter);
172502
+ if (closingEnd !== null) {
172503
+ state.mode = "code";
172504
+ state.heredocDelimiter = "";
172505
+ return { ambiguous: false, inCode: false, index: closingEnd };
172506
+ }
172507
+ const nextLineStart = findPhpLineBoundary(source, index).nextStart;
172508
+ if (nextLineStart <= index) {
172509
+ return { ambiguous: true, inCode: false, index };
172510
+ }
172511
+ return { ambiguous: false, inCode: false, index: nextLineStart };
172512
+ }
172513
+ if (state.mode === "single-quoted" || state.mode === "double-quoted") {
172514
+ const quote = state.mode === "single-quoted" ? "'" : '"';
172515
+ if (character === "\\") {
172516
+ return { ambiguous: false, inCode: false, index: index + 2 };
172517
+ }
172518
+ if (state.mode === "double-quoted" && character === "{" && source[index + 1] === "$") {
172519
+ state.mode = "double-quoted-interpolation";
172520
+ state.interpolationComment = "";
172521
+ state.interpolationDepth = 1;
172522
+ state.interpolationQuote = "";
172523
+ return { ambiguous: false, inCode: false, index: index + 2 };
172524
+ }
172525
+ if (character === quote) {
172526
+ state.mode = "code";
172527
+ }
172528
+ return { ambiguous: false, inCode: false, index: index + 1 };
172529
+ }
172530
+ if (state.mode === "double-quoted-interpolation") {
172531
+ if (state.interpolationQuote) {
172532
+ if (character === "\\") {
172533
+ return { ambiguous: false, inCode: false, index: index + 2 };
172534
+ }
172535
+ if (character === state.interpolationQuote) {
172536
+ state.interpolationQuote = "";
172537
+ }
172538
+ return { ambiguous: false, inCode: false, index: index + 1 };
172539
+ }
172540
+ if (state.interpolationComment === "line") {
172541
+ if (character === "\r" || character === `
172542
+ `) {
172543
+ state.interpolationComment = "";
172544
+ }
172545
+ return { ambiguous: false, inCode: false, index: index + 1 };
172546
+ }
172547
+ if (state.interpolationComment === "block") {
172548
+ if (character === "*" && source[index + 1] === "/") {
172549
+ state.interpolationComment = "";
172550
+ return { ambiguous: false, inCode: false, index: index + 2 };
172551
+ }
172552
+ return { ambiguous: false, inCode: false, index: index + 1 };
172553
+ }
172554
+ if (character === "/" && source[index + 1] === "/") {
172555
+ state.interpolationComment = "line";
172556
+ return { ambiguous: false, inCode: false, index: index + 2 };
172557
+ }
172558
+ if (character === "#" && source[index + 1] !== "[") {
172559
+ state.interpolationComment = "line";
172560
+ return { ambiguous: false, inCode: false, index: index + 1 };
172561
+ }
172562
+ if (character === "/" && source[index + 1] === "*") {
172563
+ state.interpolationComment = "block";
172564
+ return { ambiguous: false, inCode: false, index: index + 2 };
172565
+ }
172566
+ if (character === "'" || character === '"') {
172567
+ state.interpolationQuote = character;
172568
+ return { ambiguous: false, inCode: false, index: index + 1 };
172569
+ }
172570
+ if (character === "{") {
172571
+ state.interpolationDepth += 1;
172572
+ return { ambiguous: false, inCode: false, index: index + 1 };
172573
+ }
172574
+ if (character === "}") {
172575
+ state.interpolationDepth -= 1;
172576
+ if (state.interpolationDepth <= 0) {
172577
+ state.interpolationComment = "";
172578
+ state.interpolationDepth = 0;
172579
+ state.mode = "double-quoted";
172580
+ }
172581
+ return { ambiguous: false, inCode: false, index: index + 1 };
172582
+ }
172583
+ return { ambiguous: false, inCode: false, index: index + 1 };
172584
+ }
172585
+ if (state.mode === "line-comment") {
172586
+ if (character === "\r" || character === `
172587
+ `) {
172588
+ state.mode = "code";
172589
+ }
172590
+ return { ambiguous: false, inCode: false, index: index + 1 };
172591
+ }
172592
+ if (state.mode === "block-comment") {
172593
+ if (character === "*" && source[index + 1] === "/") {
172594
+ state.mode = "code";
172595
+ return { ambiguous: false, inCode: false, index: index + 2 };
172596
+ }
172597
+ return { ambiguous: false, inCode: false, index: index + 1 };
172598
+ }
172599
+ if (character === "'") {
172600
+ state.mode = "single-quoted";
172601
+ return { ambiguous: false, inCode: false, index: index + 1 };
172602
+ }
172603
+ if (character === '"') {
172604
+ state.mode = "double-quoted";
172605
+ return { ambiguous: false, inCode: false, index: index + 1 };
172606
+ }
172607
+ if (character === "/" && source[index + 1] === "/") {
172608
+ state.mode = "line-comment";
172609
+ return { ambiguous: false, inCode: false, index: index + 2 };
172610
+ }
172611
+ if (character === "#" && source[index + 1] !== "[") {
172612
+ state.mode = "line-comment";
172613
+ return { ambiguous: false, inCode: false, index: index + 1 };
172614
+ }
172615
+ if (character === "/" && source[index + 1] === "*") {
172616
+ state.mode = "block-comment";
172617
+ return { ambiguous: false, inCode: false, index: index + 2 };
172618
+ }
172619
+ if (character === "<") {
172620
+ const heredocStart = parsePhpHeredocStart(source, index);
172621
+ if (heredocStart) {
172622
+ state.mode = "heredoc";
172623
+ state.heredocDelimiter = heredocStart.delimiter;
172624
+ return {
172625
+ ambiguous: false,
172626
+ inCode: false,
172627
+ index: heredocStart.contentStart
172628
+ };
172629
+ }
172630
+ }
172631
+ return { ambiguous: false, inCode: true, index };
172632
+ }
172633
+ function hasPhpFunctionCall(source, functionName) {
172634
+ const scanner = createPhpScannerState();
172635
+ let index = 0;
172636
+ while (index < source.length) {
172637
+ const scan = advancePhpScanner(source, index, scanner);
172638
+ if (scan.ambiguous) {
172639
+ return false;
172640
+ }
172641
+ if (!scan.inCode) {
172642
+ index = scan.index;
172643
+ continue;
172644
+ }
172645
+ if (matchesPhpFunctionCallAt(source, index, functionName)) {
172646
+ return true;
172647
+ }
172648
+ index += 1;
172649
+ }
172650
+ return false;
172651
+ }
172652
+ function findPhpFunctionRange(source, functionName, options = {}) {
172653
+ const signaturePattern = new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\([^)]*\\)\\s*(?::\\s*[^{};]+)?\\s*\\{`, "u");
172654
+ const signatureMatch = signaturePattern.exec(source);
172655
+ if (!signatureMatch) {
172656
+ return null;
172657
+ }
172658
+ const functionStart = signatureMatch.index;
172659
+ const openBraceOffset = signatureMatch[0].lastIndexOf("{");
172660
+ if (openBraceOffset === -1) {
172661
+ return null;
172662
+ }
172663
+ const openBraceIndex = functionStart + openBraceOffset;
172664
+ let depth = 0;
172665
+ const scanner = createPhpScannerState();
172666
+ let index = openBraceIndex;
172667
+ while (index < source.length) {
172668
+ const scan = advancePhpScanner(source, index, scanner);
172669
+ if (scan.ambiguous) {
172670
+ return null;
172671
+ }
172672
+ if (!scan.inCode) {
172673
+ index = scan.index;
172674
+ continue;
172675
+ }
172676
+ const character = source[index];
172677
+ if (character === "{") {
172678
+ depth += 1;
172679
+ index += 1;
172680
+ continue;
172681
+ }
172682
+ if (character !== "}") {
172683
+ index += 1;
172684
+ continue;
172685
+ }
172686
+ depth -= 1;
172687
+ if (depth === 0) {
172688
+ let end = index + 1;
172689
+ if (options.includeTrailingNewlines ?? true) {
172690
+ while (end < source.length && /[\r\n]/u.test(source[end] ?? "")) {
172691
+ end += 1;
172692
+ }
172693
+ }
172694
+ return {
172695
+ end,
172696
+ source: source.slice(functionStart, end),
172697
+ start: functionStart
172698
+ };
172699
+ }
172700
+ index += 1;
172701
+ }
172702
+ return null;
172703
+ }
172704
+ function replacePhpFunctionDefinition(source, functionName, replacement, options = {}) {
172705
+ const functionRange = findPhpFunctionRange(source, functionName, options);
172706
+ if (!functionRange) {
172707
+ return null;
172708
+ }
172709
+ return [
172710
+ source.slice(0, functionRange.start),
172711
+ options.trimReplacementStart ? replacement.trimStart() : replacement,
172712
+ source.slice(functionRange.end)
172713
+ ].join("");
172714
+ }
172715
+
172716
+ // ../wp-typia-project-tools/src/runtime/workspace-inventory-mutations.ts
172695
172717
  function ensureWorkspaceInventorySections(source) {
172696
172718
  let nextSource = source.trimEnd();
172697
172719
  for (const section of INVENTORY_SECTIONS) {
@@ -172718,9 +172740,10 @@ function appendEntriesAtMarker(source, marker, entries) {
172718
172740
  if (!source.includes(marker)) {
172719
172741
  throw new Error(`Workspace inventory marker "${marker}" is missing in scripts/block-config.ts.`);
172720
172742
  }
172721
- return source.replace(marker, `${entries.join(`
172743
+ const replacement = `${entries.join(`
172722
172744
  `)}
172723
- ${marker}`);
172745
+ ${marker}`;
172746
+ return source.replace(marker, () => replacement);
172724
172747
  }
172725
172748
  function appendInventorySectionEntries(source, options) {
172726
172749
  let nextSource = source;
@@ -172794,14 +172817,13 @@ function updateWorkspaceInventorySource(source, options = {}) {
172794
172817
  return nextSource;
172795
172818
  }
172796
172819
  async function appendWorkspaceInventoryEntries(projectDir, options) {
172797
- const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
172798
- const source = await readFile(blockConfigPath, "utf8");
172820
+ const blockConfigPath = path5.join(projectDir, "scripts", "block-config.ts");
172821
+ const source = await readFile2(blockConfigPath, "utf8");
172799
172822
  const nextSource = updateWorkspaceInventorySource(source, options);
172800
172823
  if (nextSource !== source) {
172801
172824
  await writeFile(blockConfigPath, nextSource, "utf8");
172802
172825
  }
172803
172826
  }
172827
+ export { toKebabCase, toSnakeCase, toPascalCase, toCamelCase, toSegmentPascalCase, toTitleCase, validateBlockSlug, validateNamespace, normalizeBlockSlug, resolveNonEmptyNormalizedBlockSlug, buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, REST_RESOURCE_METHOD_IDS, EDITOR_PLUGIN_SLOT_IDS, resolveEditorPluginSlotAlias, ADD_BLOCK_TEMPLATE_IDS, suggestAddBlockTemplateId, HOOKED_BLOCK_POSITION_SET, HOOKED_BLOCK_ANCHOR_PATTERN, REST_RESOURCE_NAMESPACE_PATTERN, assertValidGeneratedSlug, resolveRestResourceNamespace, assertValidRestResourceMethods, assertValidHookedBlockPosition, buildWorkspacePhpPrefix, isAddBlockTemplateId, quoteTsString, assertValidHookAnchor, assertValidEditorPluginSlot, pathExists, readOptionalUtf8File, getNodeErrorCode, getOptionalNodeErrorCode, isFileNotFoundError, getWorkspaceBootstrapPath, patchFile, readOptionalFile, snapshotWorkspaceFiles, rollbackWorkspaceMutation, resolveWorkspaceBlock, readWorkspaceBlockJson, getMutableBlockHooks, assertVariationDoesNotExist, assertBlockStyleDoesNotExist, assertBlockTransformDoesNotExist, assertPatternDoesNotExist, assertBindingSourceDoesNotExist, assertRestResourceDoesNotExist, assertAdminViewDoesNotExist, assertAbilityDoesNotExist, assertAiFeatureDoesNotExist, assertEditorPluginDoesNotExist, formatAddHelpText, require_typescript, getPropertyNameText, readWorkspaceInventory, readWorkspaceInventoryAsync, getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, escapeRegex, quotePhpString, hasPhpFunctionDefinition, hasPhpFunctionCall, findPhpFunctionRange, replacePhpFunctionDefinition, updateWorkspaceInventorySource, appendWorkspaceInventoryEntries };
172804
172828
 
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 };
172806
-
172807
- //# debugId=282F6AFDCE13C26664756E2164756E21
172829
+ //# debugId=10B8DF3957EF445164756E2164756E21