wp-typia 0.22.4 → 0.22.5

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.
@@ -171518,6 +171518,9 @@ function replacePhpFunctionDefinition(source, functionName, replacement, options
171518
171518
  }
171519
171519
 
171520
171520
  // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171521
+ function defineInventoryEntryParser(descriptor) {
171522
+ return descriptor;
171523
+ }
171521
171524
  var BLOCK_CONFIG_ENTRY_MARKER = "\t// wp-typia add block entries";
171522
171525
  var VARIATION_CONFIG_ENTRY_MARKER = "\t// wp-typia add variation entries";
171523
171526
  var BLOCK_STYLE_CONFIG_ENTRY_MARKER = "\t// wp-typia add style entries";
@@ -171713,12 +171716,41 @@ export const EDITOR_PLUGINS: WorkspaceEditorPluginConfig[] = [
171713
171716
  // wp-typia add editor-plugin entries
171714
171717
  ];
171715
171718
  `;
171719
+ var BLOCK_INVENTORY_SECTION = {
171720
+ parse: {
171721
+ entriesKey: "blocks",
171722
+ entry: defineInventoryEntryParser({
171723
+ entryName: "BLOCKS",
171724
+ fields: [
171725
+ { key: "apiTypesFile" },
171726
+ { key: "attributeTypeName" },
171727
+ { key: "openApiFile" },
171728
+ { key: "slug", required: true },
171729
+ { key: "typesFile", required: true }
171730
+ ]
171731
+ }),
171732
+ exportName: "BLOCKS",
171733
+ required: true
171734
+ }
171735
+ };
171716
171736
  var INVENTORY_SECTIONS = [
171717
171737
  {
171718
171738
  interface: {
171719
171739
  name: "WorkspaceVariationConfig",
171720
171740
  section: VARIATIONS_INTERFACE_SECTION
171721
171741
  },
171742
+ parse: {
171743
+ entriesKey: "variations",
171744
+ entry: defineInventoryEntryParser({
171745
+ entryName: "VARIATIONS",
171746
+ fields: [
171747
+ { key: "block", required: true },
171748
+ { key: "file", required: true },
171749
+ { key: "slug", required: true }
171750
+ ]
171751
+ }),
171752
+ hasSectionKey: "hasVariationsSection"
171753
+ },
171722
171754
  value: {
171723
171755
  name: "VARIATIONS",
171724
171756
  section: VARIATIONS_CONST_SECTION
@@ -171729,6 +171761,18 @@ var INVENTORY_SECTIONS = [
171729
171761
  name: "WorkspaceBlockStyleConfig",
171730
171762
  section: BLOCK_STYLES_INTERFACE_SECTION
171731
171763
  },
171764
+ parse: {
171765
+ entriesKey: "blockStyles",
171766
+ entry: defineInventoryEntryParser({
171767
+ entryName: "BLOCK_STYLES",
171768
+ fields: [
171769
+ { key: "block", required: true },
171770
+ { key: "file", required: true },
171771
+ { key: "slug", required: true }
171772
+ ]
171773
+ }),
171774
+ hasSectionKey: "hasBlockStylesSection"
171775
+ },
171732
171776
  value: {
171733
171777
  name: "BLOCK_STYLES",
171734
171778
  section: BLOCK_STYLES_CONST_SECTION
@@ -171739,6 +171783,20 @@ var INVENTORY_SECTIONS = [
171739
171783
  name: "WorkspaceBlockTransformConfig",
171740
171784
  section: BLOCK_TRANSFORMS_INTERFACE_SECTION
171741
171785
  },
171786
+ parse: {
171787
+ entriesKey: "blockTransforms",
171788
+ entry: defineInventoryEntryParser({
171789
+ entryName: "BLOCK_TRANSFORMS",
171790
+ fields: [
171791
+ { key: "block", required: true },
171792
+ { key: "file", required: true },
171793
+ { key: "from", required: true },
171794
+ { key: "slug", required: true },
171795
+ { key: "to", required: true }
171796
+ ]
171797
+ }),
171798
+ hasSectionKey: "hasBlockTransformsSection"
171799
+ },
171742
171800
  value: {
171743
171801
  name: "BLOCK_TRANSFORMS",
171744
171802
  section: BLOCK_TRANSFORMS_CONST_SECTION
@@ -171749,6 +171807,17 @@ var INVENTORY_SECTIONS = [
171749
171807
  name: "WorkspacePatternConfig",
171750
171808
  section: PATTERNS_INTERFACE_SECTION
171751
171809
  },
171810
+ parse: {
171811
+ entriesKey: "patterns",
171812
+ entry: defineInventoryEntryParser({
171813
+ entryName: "PATTERNS",
171814
+ fields: [
171815
+ { key: "file", required: true },
171816
+ { key: "slug", required: true }
171817
+ ]
171818
+ }),
171819
+ hasSectionKey: "hasPatternsSection"
171820
+ },
171752
171821
  value: {
171753
171822
  name: "PATTERNS",
171754
171823
  section: PATTERNS_CONST_SECTION
@@ -171759,6 +171828,20 @@ var INVENTORY_SECTIONS = [
171759
171828
  name: "WorkspaceBindingSourceConfig",
171760
171829
  section: BINDING_SOURCES_INTERFACE_SECTION
171761
171830
  },
171831
+ parse: {
171832
+ entriesKey: "bindingSources",
171833
+ entry: defineInventoryEntryParser({
171834
+ entryName: "BINDING_SOURCES",
171835
+ fields: [
171836
+ { key: "attribute" },
171837
+ { key: "block" },
171838
+ { key: "editorFile", required: true },
171839
+ { key: "serverFile", required: true },
171840
+ { key: "slug", required: true }
171841
+ ]
171842
+ }),
171843
+ hasSectionKey: "hasBindingSourcesSection"
171844
+ },
171762
171845
  value: {
171763
171846
  name: "BINDING_SOURCES",
171764
171847
  section: BINDING_SOURCES_CONST_SECTION
@@ -171769,6 +171852,36 @@ var INVENTORY_SECTIONS = [
171769
171852
  name: "WorkspaceRestResourceConfig",
171770
171853
  section: REST_RESOURCES_INTERFACE_SECTION
171771
171854
  },
171855
+ parse: {
171856
+ entriesKey: "restResources",
171857
+ entry: defineInventoryEntryParser({
171858
+ entryName: "REST_RESOURCES",
171859
+ fields: [
171860
+ { key: "apiFile", required: true },
171861
+ { key: "clientFile", required: true },
171862
+ { key: "dataFile", required: true },
171863
+ {
171864
+ key: "methods",
171865
+ kind: "stringArray",
171866
+ required: true,
171867
+ validate: (value, context) => {
171868
+ const methods = Array.isArray(value) ? value : [];
171869
+ const invalidMethods = methods.filter((method) => !REST_RESOURCE_METHOD_IDS.includes(method));
171870
+ if (invalidMethods.length > 0) {
171871
+ throw new Error(`${context.entryName}[${context.elementIndex}].${context.key} includes unsupported values: ${invalidMethods.join(", ")}.`);
171872
+ }
171873
+ }
171874
+ },
171875
+ { key: "namespace", required: true },
171876
+ { key: "openApiFile", required: true },
171877
+ { key: "phpFile", required: true },
171878
+ { key: "slug", required: true },
171879
+ { key: "typesFile", required: true },
171880
+ { key: "validatorsFile", required: true }
171881
+ ]
171882
+ }),
171883
+ hasSectionKey: "hasRestResourcesSection"
171884
+ },
171772
171885
  value: {
171773
171886
  name: "REST_RESOURCES",
171774
171887
  section: REST_RESOURCES_CONST_SECTION
@@ -171779,6 +171892,25 @@ var INVENTORY_SECTIONS = [
171779
171892
  name: "WorkspaceAbilityConfig",
171780
171893
  section: ABILITIES_INTERFACE_SECTION
171781
171894
  },
171895
+ parse: {
171896
+ entriesKey: "abilities",
171897
+ entry: defineInventoryEntryParser({
171898
+ entryName: "ABILITIES",
171899
+ fields: [
171900
+ { key: "clientFile", required: true },
171901
+ { key: "configFile", required: true },
171902
+ { key: "dataFile", required: true },
171903
+ { key: "inputSchemaFile", required: true },
171904
+ { key: "inputTypeName", required: true },
171905
+ { key: "outputSchemaFile", required: true },
171906
+ { key: "outputTypeName", required: true },
171907
+ { key: "phpFile", required: true },
171908
+ { key: "slug", required: true },
171909
+ { key: "typesFile", required: true }
171910
+ ]
171911
+ }),
171912
+ hasSectionKey: "hasAbilitiesSection"
171913
+ },
171782
171914
  value: {
171783
171915
  name: "ABILITIES",
171784
171916
  section: ABILITIES_CONST_SECTION
@@ -171789,6 +171921,25 @@ var INVENTORY_SECTIONS = [
171789
171921
  name: "WorkspaceAiFeatureConfig",
171790
171922
  section: AI_FEATURES_INTERFACE_SECTION
171791
171923
  },
171924
+ parse: {
171925
+ entriesKey: "aiFeatures",
171926
+ entry: defineInventoryEntryParser({
171927
+ entryName: "AI_FEATURES",
171928
+ fields: [
171929
+ { key: "aiSchemaFile", required: true },
171930
+ { key: "apiFile", required: true },
171931
+ { key: "clientFile", required: true },
171932
+ { key: "dataFile", required: true },
171933
+ { key: "namespace", required: true },
171934
+ { key: "openApiFile", required: true },
171935
+ { key: "phpFile", required: true },
171936
+ { key: "slug", required: true },
171937
+ { key: "typesFile", required: true },
171938
+ { key: "validatorsFile", required: true }
171939
+ ]
171940
+ }),
171941
+ hasSectionKey: "hasAiFeaturesSection"
171942
+ },
171792
171943
  value: {
171793
171944
  name: "AI_FEATURES",
171794
171945
  section: AI_FEATURES_CONST_SECTION
@@ -171799,6 +171950,19 @@ var INVENTORY_SECTIONS = [
171799
171950
  name: "WorkspaceAdminViewConfig",
171800
171951
  section: ADMIN_VIEWS_INTERFACE_SECTION
171801
171952
  },
171953
+ parse: {
171954
+ entriesKey: "adminViews",
171955
+ entry: defineInventoryEntryParser({
171956
+ entryName: "ADMIN_VIEWS",
171957
+ fields: [
171958
+ { key: "file", required: true },
171959
+ { key: "phpFile", required: true },
171960
+ { key: "slug", required: true },
171961
+ { key: "source" }
171962
+ ]
171963
+ }),
171964
+ hasSectionKey: "hasAdminViewsSection"
171965
+ },
171802
171966
  value: {
171803
171967
  name: "ADMIN_VIEWS",
171804
171968
  section: ADMIN_VIEWS_CONST_SECTION
@@ -171809,6 +171973,18 @@ var INVENTORY_SECTIONS = [
171809
171973
  name: "WorkspaceEditorPluginConfig",
171810
171974
  section: EDITOR_PLUGINS_INTERFACE_SECTION
171811
171975
  },
171976
+ parse: {
171977
+ entriesKey: "editorPlugins",
171978
+ entry: defineInventoryEntryParser({
171979
+ entryName: "EDITOR_PLUGINS",
171980
+ fields: [
171981
+ { key: "file", required: true },
171982
+ { key: "slug", required: true },
171983
+ { key: "slot", required: true }
171984
+ ]
171985
+ }),
171986
+ hasSectionKey: "hasEditorPluginsSection"
171987
+ },
171812
171988
  value: {
171813
171989
  name: "EDITOR_PLUGINS",
171814
171990
  section: EDITOR_PLUGINS_CONST_SECTION
@@ -171894,240 +172070,95 @@ function getRequiredStringArrayProperty(entryName, elementIndex, objectLiteral,
171894
172070
  }
171895
172071
  throw new Error(`${entryName}[${elementIndex}] is missing required "${key}" in scripts/block-config.ts.`);
171896
172072
  }
171897
- function parseBlockEntries(arrayLiteral) {
172073
+ function parseInventoryEntries(arrayLiteral, descriptor) {
171898
172074
  return arrayLiteral.elements.map((element, elementIndex) => {
171899
172075
  if (!import_typescript.default.isObjectLiteralExpression(element)) {
171900
- throw new Error(`BLOCKS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
171901
- }
171902
- return {
171903
- apiTypesFile: getOptionalStringProperty("BLOCKS", elementIndex, element, "apiTypesFile"),
171904
- attributeTypeName: getOptionalStringProperty("BLOCKS", elementIndex, element, "attributeTypeName"),
171905
- openApiFile: getOptionalStringProperty("BLOCKS", elementIndex, element, "openApiFile"),
171906
- slug: getRequiredStringProperty("BLOCKS", elementIndex, element, "slug"),
171907
- typesFile: getRequiredStringProperty("BLOCKS", elementIndex, element, "typesFile")
171908
- };
171909
- });
171910
- }
171911
- function parseVariationEntries(arrayLiteral) {
171912
- return arrayLiteral.elements.map((element, elementIndex) => {
171913
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
171914
- throw new Error(`VARIATIONS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
171915
- }
171916
- return {
171917
- block: getRequiredStringProperty("VARIATIONS", elementIndex, element, "block"),
171918
- file: getRequiredStringProperty("VARIATIONS", elementIndex, element, "file"),
171919
- slug: getRequiredStringProperty("VARIATIONS", elementIndex, element, "slug")
171920
- };
171921
- });
171922
- }
171923
- function parseBlockStyleEntries(arrayLiteral) {
171924
- return arrayLiteral.elements.map((element, elementIndex) => {
171925
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
171926
- throw new Error(`BLOCK_STYLES[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
171927
- }
171928
- return {
171929
- block: getRequiredStringProperty("BLOCK_STYLES", elementIndex, element, "block"),
171930
- file: getRequiredStringProperty("BLOCK_STYLES", elementIndex, element, "file"),
171931
- slug: getRequiredStringProperty("BLOCK_STYLES", elementIndex, element, "slug")
171932
- };
171933
- });
171934
- }
171935
- function parseBlockTransformEntries(arrayLiteral) {
171936
- return arrayLiteral.elements.map((element, elementIndex) => {
171937
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
171938
- throw new Error(`BLOCK_TRANSFORMS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
171939
- }
171940
- return {
171941
- block: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "block"),
171942
- file: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "file"),
171943
- from: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "from"),
171944
- slug: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "slug"),
171945
- to: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "to")
171946
- };
171947
- });
171948
- }
171949
- function parsePatternEntries(arrayLiteral) {
171950
- return arrayLiteral.elements.map((element, elementIndex) => {
171951
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
171952
- throw new Error(`PATTERNS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
171953
- }
171954
- return {
171955
- file: getRequiredStringProperty("PATTERNS", elementIndex, element, "file"),
171956
- slug: getRequiredStringProperty("PATTERNS", elementIndex, element, "slug")
171957
- };
171958
- });
171959
- }
171960
- function parseBindingSourceEntries(arrayLiteral) {
171961
- return arrayLiteral.elements.map((element, elementIndex) => {
171962
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
171963
- throw new Error(`BINDING_SOURCES[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
171964
- }
171965
- return {
171966
- attribute: getOptionalStringProperty("BINDING_SOURCES", elementIndex, element, "attribute"),
171967
- block: getOptionalStringProperty("BINDING_SOURCES", elementIndex, element, "block"),
171968
- editorFile: getRequiredStringProperty("BINDING_SOURCES", elementIndex, element, "editorFile"),
171969
- serverFile: getRequiredStringProperty("BINDING_SOURCES", elementIndex, element, "serverFile"),
171970
- slug: getRequiredStringProperty("BINDING_SOURCES", elementIndex, element, "slug")
171971
- };
171972
- });
171973
- }
171974
- function parseRestResourceEntries(arrayLiteral) {
171975
- return arrayLiteral.elements.map((element, elementIndex) => {
171976
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
171977
- throw new Error(`REST_RESOURCES[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
171978
- }
171979
- const methods = getRequiredStringArrayProperty("REST_RESOURCES", elementIndex, element, "methods");
171980
- const invalidMethods = methods.filter((method) => !REST_RESOURCE_METHOD_IDS.includes(method));
171981
- if (invalidMethods.length > 0) {
171982
- throw new Error(`REST_RESOURCES[${elementIndex}].methods includes unsupported values: ${invalidMethods.join(", ")}.`);
171983
- }
171984
- return {
171985
- apiFile: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "apiFile"),
171986
- clientFile: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "clientFile"),
171987
- dataFile: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "dataFile"),
171988
- methods,
171989
- namespace: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "namespace"),
171990
- openApiFile: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "openApiFile"),
171991
- phpFile: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "phpFile"),
171992
- slug: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "slug"),
171993
- typesFile: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "typesFile"),
171994
- validatorsFile: getRequiredStringProperty("REST_RESOURCES", elementIndex, element, "validatorsFile")
171995
- };
171996
- });
171997
- }
171998
- function parseAiFeatureEntries(arrayLiteral) {
171999
- return arrayLiteral.elements.map((element, elementIndex) => {
172000
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
172001
- throw new Error(`AI_FEATURES[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172076
+ throw new Error(`${descriptor.entryName}[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172077
+ }
172078
+ const entry = {};
172079
+ for (const field of descriptor.fields) {
172080
+ const kind = field.kind ?? "string";
172081
+ 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);
172082
+ field.validate?.(value, {
172083
+ elementIndex,
172084
+ entryName: descriptor.entryName,
172085
+ key: field.key
172086
+ });
172087
+ entry[field.key] = value;
172002
172088
  }
172003
- return {
172004
- aiSchemaFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "aiSchemaFile"),
172005
- apiFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "apiFile"),
172006
- clientFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "clientFile"),
172007
- dataFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "dataFile"),
172008
- namespace: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "namespace"),
172009
- openApiFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "openApiFile"),
172010
- phpFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "phpFile"),
172011
- slug: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "slug"),
172012
- typesFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "typesFile"),
172013
- validatorsFile: getRequiredStringProperty("AI_FEATURES", elementIndex, element, "validatorsFile")
172014
- };
172089
+ return entry;
172015
172090
  });
172016
172091
  }
172017
- function parseAbilityEntries(arrayLiteral) {
172018
- return arrayLiteral.elements.map((element, elementIndex) => {
172019
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
172020
- throw new Error(`ABILITIES[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172021
- }
172092
+ function parseInventorySection(sourceFile, descriptor) {
172093
+ if (!descriptor.parse) {
172022
172094
  return {
172023
- clientFile: getRequiredStringProperty("ABILITIES", elementIndex, element, "clientFile"),
172024
- configFile: getRequiredStringProperty("ABILITIES", elementIndex, element, "configFile"),
172025
- dataFile: getRequiredStringProperty("ABILITIES", elementIndex, element, "dataFile"),
172026
- inputSchemaFile: getRequiredStringProperty("ABILITIES", elementIndex, element, "inputSchemaFile"),
172027
- inputTypeName: getRequiredStringProperty("ABILITIES", elementIndex, element, "inputTypeName"),
172028
- outputSchemaFile: getRequiredStringProperty("ABILITIES", elementIndex, element, "outputSchemaFile"),
172029
- outputTypeName: getRequiredStringProperty("ABILITIES", elementIndex, element, "outputTypeName"),
172030
- phpFile: getRequiredStringProperty("ABILITIES", elementIndex, element, "phpFile"),
172031
- slug: getRequiredStringProperty("ABILITIES", elementIndex, element, "slug"),
172032
- typesFile: getRequiredStringProperty("ABILITIES", elementIndex, element, "typesFile")
172095
+ entries: [],
172096
+ found: false
172033
172097
  };
172034
- });
172035
- }
172036
- function parseEditorPluginEntries(arrayLiteral) {
172037
- return arrayLiteral.elements.map((element, elementIndex) => {
172038
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
172039
- throw new Error(`EDITOR_PLUGINS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172098
+ }
172099
+ const exportName = descriptor.parse.exportName ?? descriptor.value?.name;
172100
+ if (!exportName) {
172101
+ throw new Error("Inventory parser descriptor is missing an export name.");
172102
+ }
172103
+ const exportedArray = findExportedArrayLiteral(sourceFile, exportName);
172104
+ if (!exportedArray.found) {
172105
+ if (descriptor.parse.required) {
172106
+ throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
172040
172107
  }
172041
172108
  return {
172042
- file: getRequiredStringProperty("EDITOR_PLUGINS", elementIndex, element, "file"),
172043
- slug: getRequiredStringProperty("EDITOR_PLUGINS", elementIndex, element, "slug"),
172044
- slot: getRequiredStringProperty("EDITOR_PLUGINS", elementIndex, element, "slot")
172109
+ entries: [],
172110
+ found: false
172045
172111
  };
172046
- });
172047
- }
172048
- function parseAdminViewEntries(arrayLiteral) {
172049
- return arrayLiteral.elements.map((element, elementIndex) => {
172050
- if (!import_typescript.default.isObjectLiteralExpression(element)) {
172051
- throw new Error(`ADMIN_VIEWS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172112
+ }
172113
+ if (!exportedArray.array) {
172114
+ if (descriptor.parse.required) {
172115
+ throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
172052
172116
  }
172053
- return {
172054
- file: getRequiredStringProperty("ADMIN_VIEWS", elementIndex, element, "file"),
172055
- phpFile: getRequiredStringProperty("ADMIN_VIEWS", elementIndex, element, "phpFile"),
172056
- slug: getRequiredStringProperty("ADMIN_VIEWS", elementIndex, element, "slug"),
172057
- source: getOptionalStringProperty("ADMIN_VIEWS", elementIndex, element, "source")
172058
- };
172059
- });
172117
+ throw new Error(`scripts/block-config.ts must export ${exportName} as an array literal.`);
172118
+ }
172119
+ return {
172120
+ entries: parseInventoryEntries(exportedArray.array, descriptor.parse.entry),
172121
+ found: true
172122
+ };
172060
172123
  }
172061
172124
  function parseWorkspaceInventorySource(source) {
172062
172125
  const sourceFile = import_typescript.default.createSourceFile("block-config.ts", source, import_typescript.default.ScriptTarget.Latest, true, import_typescript.default.ScriptKind.TS);
172063
- const blockArray = findExportedArrayLiteral(sourceFile, "BLOCKS");
172064
- if (!blockArray.found || !blockArray.array) {
172065
- throw new Error("scripts/block-config.ts must export a BLOCKS array.");
172066
- }
172067
- const variationArray = findExportedArrayLiteral(sourceFile, "VARIATIONS");
172068
- const blockStyleArray = findExportedArrayLiteral(sourceFile, "BLOCK_STYLES");
172069
- const blockTransformArray = findExportedArrayLiteral(sourceFile, "BLOCK_TRANSFORMS");
172070
- const patternArray = findExportedArrayLiteral(sourceFile, "PATTERNS");
172071
- const bindingSourceArray = findExportedArrayLiteral(sourceFile, "BINDING_SOURCES");
172072
- const restResourceArray = findExportedArrayLiteral(sourceFile, "REST_RESOURCES");
172073
- const abilityArray = findExportedArrayLiteral(sourceFile, "ABILITIES");
172074
- const aiFeatureArray = findExportedArrayLiteral(sourceFile, "AI_FEATURES");
172075
- const adminViewArray = findExportedArrayLiteral(sourceFile, "ADMIN_VIEWS");
172076
- const editorPluginArray = findExportedArrayLiteral(sourceFile, "EDITOR_PLUGINS");
172077
- if (variationArray.found && !variationArray.array) {
172078
- throw new Error("scripts/block-config.ts must export VARIATIONS as an array literal.");
172079
- }
172080
- if (blockStyleArray.found && !blockStyleArray.array) {
172081
- throw new Error("scripts/block-config.ts must export BLOCK_STYLES as an array literal.");
172082
- }
172083
- if (blockTransformArray.found && !blockTransformArray.array) {
172084
- throw new Error("scripts/block-config.ts must export BLOCK_TRANSFORMS as an array literal.");
172085
- }
172086
- if (patternArray.found && !patternArray.array) {
172087
- throw new Error("scripts/block-config.ts must export PATTERNS as an array literal.");
172088
- }
172089
- if (bindingSourceArray.found && !bindingSourceArray.array) {
172090
- throw new Error("scripts/block-config.ts must export BINDING_SOURCES as an array literal.");
172091
- }
172092
- if (restResourceArray.found && !restResourceArray.array) {
172093
- throw new Error("scripts/block-config.ts must export REST_RESOURCES as an array literal.");
172094
- }
172095
- if (abilityArray.found && !abilityArray.array) {
172096
- throw new Error("scripts/block-config.ts must export ABILITIES as an array literal.");
172097
- }
172098
- if (aiFeatureArray.found && !aiFeatureArray.array) {
172099
- throw new Error("scripts/block-config.ts must export AI_FEATURES as an array literal.");
172100
- }
172101
- if (adminViewArray.found && !adminViewArray.array) {
172102
- throw new Error("scripts/block-config.ts must export ADMIN_VIEWS as an array literal.");
172103
- }
172104
- if (editorPluginArray.found && !editorPluginArray.array) {
172105
- throw new Error("scripts/block-config.ts must export EDITOR_PLUGINS as an array literal.");
172106
- }
172107
- return {
172108
- abilities: abilityArray.array ? parseAbilityEntries(abilityArray.array) : [],
172109
- adminViews: adminViewArray.array ? parseAdminViewEntries(adminViewArray.array) : [],
172110
- aiFeatures: aiFeatureArray.array ? parseAiFeatureEntries(aiFeatureArray.array) : [],
172111
- bindingSources: bindingSourceArray.array ? parseBindingSourceEntries(bindingSourceArray.array) : [],
172112
- blockStyles: blockStyleArray.array ? parseBlockStyleEntries(blockStyleArray.array) : [],
172113
- blockTransforms: blockTransformArray.array ? parseBlockTransformEntries(blockTransformArray.array) : [],
172114
- blocks: parseBlockEntries(blockArray.array),
172115
- hasAbilitiesSection: abilityArray.found,
172116
- hasAdminViewsSection: adminViewArray.found,
172117
- hasAiFeaturesSection: aiFeatureArray.found,
172118
- hasBindingSourcesSection: bindingSourceArray.found,
172119
- hasBlockStylesSection: blockStyleArray.found,
172120
- hasBlockTransformsSection: blockTransformArray.found,
172121
- hasEditorPluginsSection: editorPluginArray.found,
172122
- hasPatternsSection: patternArray.found,
172123
- hasRestResourcesSection: restResourceArray.found,
172124
- hasVariationsSection: variationArray.found,
172125
- editorPlugins: editorPluginArray.array ? parseEditorPluginEntries(editorPluginArray.array) : [],
172126
- patterns: patternArray.array ? parsePatternEntries(patternArray.array) : [],
172127
- restResources: restResourceArray.array ? parseRestResourceEntries(restResourceArray.array) : [],
172126
+ const parsedInventory = {
172127
+ abilities: [],
172128
+ adminViews: [],
172129
+ aiFeatures: [],
172130
+ bindingSources: [],
172131
+ blockStyles: [],
172132
+ blockTransforms: [],
172133
+ blocks: parseInventorySection(sourceFile, BLOCK_INVENTORY_SECTION).entries,
172134
+ editorPlugins: [],
172135
+ hasAbilitiesSection: false,
172136
+ hasAdminViewsSection: false,
172137
+ hasAiFeaturesSection: false,
172138
+ hasBindingSourcesSection: false,
172139
+ hasBlockStylesSection: false,
172140
+ hasBlockTransformsSection: false,
172141
+ hasEditorPluginsSection: false,
172142
+ hasPatternsSection: false,
172143
+ hasRestResourcesSection: false,
172144
+ hasVariationsSection: false,
172145
+ patterns: [],
172146
+ restResources: [],
172128
172147
  source,
172129
- variations: variationArray.array ? parseVariationEntries(variationArray.array) : []
172148
+ variations: []
172130
172149
  };
172150
+ const mutableInventory = parsedInventory;
172151
+ for (const section of INVENTORY_SECTIONS) {
172152
+ if (!section.parse) {
172153
+ continue;
172154
+ }
172155
+ const parsedSection = parseInventorySection(sourceFile, section);
172156
+ mutableInventory[section.parse.entriesKey] = parsedSection.entries;
172157
+ if (section.parse.hasSectionKey) {
172158
+ mutableInventory[section.parse.hasSectionKey] = parsedSection.found;
172159
+ }
172160
+ }
172161
+ return parsedInventory;
172131
172162
  }
172132
172163
  function readWorkspaceInventory(projectDir) {
172133
172164
  const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
@@ -172277,4 +172308,4 @@ async function appendWorkspaceInventoryEntries(projectDir, options) {
172277
172308
 
172278
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 };
172279
172310
 
172280
- //# debugId=42C4B300381ECACF64756E2164756E21
172311
+ //# debugId=4D54C6227C5D15E364756E2164756E21