wp-typia 0.22.4 → 0.22.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  WORKSPACE_TEMPLATE_PACKAGE
4
- } from "./cli-btbpt84c.js";
4
+ } from "./cli-hhp1d348.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __require,
@@ -170911,45 +170911,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
170911
170911
  } });
170912
170912
  });
170913
170913
 
170914
- // ../wp-typia-project-tools/src/runtime/string-case.ts
170915
- function capitalizeSegment(segment) {
170916
- return segment.charAt(0).toUpperCase() + segment.slice(1);
170917
- }
170918
- function toKebabCase(input) {
170919
- return input.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-").toLowerCase();
170920
- }
170921
- function toSnakeCase(input) {
170922
- return toKebabCase(input).replace(/-/g, "_");
170923
- }
170924
- function toPascalCase(input) {
170925
- return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join("");
170926
- }
170927
- function toCamelCase(input) {
170928
- const pascalCase = toPascalCase(input);
170929
- return `${pascalCase.charAt(0).toLowerCase()}${pascalCase.slice(1)}`;
170930
- }
170931
- function toSegmentPascalCase(input) {
170932
- return input.replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean).map(capitalizeSegment).join("");
170933
- }
170934
- function toTitleCase(input) {
170935
- return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join(" ");
170936
- }
170937
-
170938
170914
  // ../wp-typia-project-tools/src/runtime/cli-add-types.ts
170939
- var ADD_KIND_IDS = [
170940
- "admin-view",
170941
- "block",
170942
- "variation",
170943
- "style",
170944
- "transform",
170945
- "pattern",
170946
- "binding-source",
170947
- "rest-resource",
170948
- "ability",
170949
- "ai-feature",
170950
- "hooked-block",
170951
- "editor-plugin"
170952
- ];
170953
170915
  var REST_RESOURCE_METHOD_IDS = [
170954
170916
  "list",
170955
170917
  "read",
@@ -170983,6 +170945,76 @@ var HOOKED_BLOCK_POSITION_IDS = ["before", "after", "firstChild", "lastChild"];
170983
170945
  var HOOKED_BLOCK_POSITION_SET = new Set(HOOKED_BLOCK_POSITION_IDS);
170984
170946
  var HOOKED_BLOCK_ANCHOR_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/;
170985
170947
 
170948
+ // ../wp-typia-project-tools/src/runtime/string-case.ts
170949
+ var COMMON_ACRONYM_PREFIXES = [
170950
+ "HTML",
170951
+ "HTTP",
170952
+ "JSON",
170953
+ "REST",
170954
+ "UUID",
170955
+ "API",
170956
+ "CSS",
170957
+ "CTA",
170958
+ "DOM",
170959
+ "PHP",
170960
+ "SQL",
170961
+ "SVG",
170962
+ "URL",
170963
+ "XML",
170964
+ "ID",
170965
+ "JS",
170966
+ "UI",
170967
+ "WP"
170968
+ ];
170969
+ function capitalizeSegment(segment) {
170970
+ return segment.charAt(0).toUpperCase() + segment.slice(1);
170971
+ }
170972
+ function findCommonAcronymPrefix(segment) {
170973
+ return COMMON_ACRONYM_PREFIXES.find((prefix) => segment.startsWith(prefix));
170974
+ }
170975
+ function splitKnownAcronymSegment(segment) {
170976
+ const prefixes = [];
170977
+ let remaining = segment;
170978
+ while (remaining.length > 0) {
170979
+ const prefix = findCommonAcronymPrefix(remaining);
170980
+ if (!prefix) {
170981
+ break;
170982
+ }
170983
+ const suffix = remaining.slice(prefix.length);
170984
+ if (/^[A-Z][a-z]/.test(suffix)) {
170985
+ return [...prefixes, prefix, suffix].join("-");
170986
+ }
170987
+ if (!findCommonAcronymPrefix(suffix)) {
170988
+ break;
170989
+ }
170990
+ prefixes.push(prefix);
170991
+ remaining = suffix;
170992
+ }
170993
+ return segment;
170994
+ }
170995
+ function splitAcronymBoundary(value) {
170996
+ return value.replace(/[A-Z]{2,}[a-z]+/g, splitKnownAcronymSegment);
170997
+ }
170998
+ function toKebabCase(input) {
170999
+ return splitAcronymBoundary(input.trim()).replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-").toLowerCase();
171000
+ }
171001
+ function toSnakeCase(input) {
171002
+ return toKebabCase(input).replace(/-/g, "_");
171003
+ }
171004
+ function toPascalCase(input) {
171005
+ return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join("");
171006
+ }
171007
+ function toCamelCase(input) {
171008
+ const pascalCase = toPascalCase(input);
171009
+ return `${pascalCase.charAt(0).toLowerCase()}${pascalCase.slice(1)}`;
171010
+ }
171011
+ function toSegmentPascalCase(input) {
171012
+ return input.replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean).map(capitalizeSegment).join("");
171013
+ }
171014
+ function toTitleCase(input) {
171015
+ return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join(" ");
171016
+ }
171017
+
170986
171018
  // ../wp-typia-project-tools/src/runtime/cli-add-validation.ts
170987
171019
  var WORKSPACE_GENERATED_SLUG_PATTERN = /^[a-z][a-z0-9-]*$/;
170988
171020
  var REST_RESOURCE_NAMESPACE_PATTERN = /^[a-z][a-z0-9-]*(?:\/[a-z0-9-]+)+$/u;
@@ -171053,60 +171085,6 @@ function assertValidEditorPluginSlot(slot = "sidebar") {
171053
171085
  throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}. Legacy aliases: PluginSidebar, PluginDocumentSettingPanel.`);
171054
171086
  }
171055
171087
 
171056
- // ../wp-typia-project-tools/src/runtime/cli-add-filesystem.ts
171057
- import { promises as fsp } from "fs";
171058
- import path from "path";
171059
- function getWorkspaceBootstrapPath(workspace) {
171060
- const workspaceBaseName = workspace.packageName.split("/").pop() ?? workspace.packageName;
171061
- return path.join(workspace.projectDir, `${workspaceBaseName}.php`);
171062
- }
171063
- async function patchFile(filePath, transform) {
171064
- const currentSource = await fsp.readFile(filePath, "utf8");
171065
- const nextSource = transform(currentSource);
171066
- if (nextSource !== currentSource) {
171067
- await fsp.writeFile(filePath, nextSource, "utf8");
171068
- }
171069
- }
171070
- async function readOptionalFile(filePath) {
171071
- try {
171072
- return await fsp.readFile(filePath, "utf8");
171073
- } catch (error) {
171074
- if (isFileNotFoundError(error)) {
171075
- return null;
171076
- }
171077
- throw error;
171078
- }
171079
- }
171080
- async function restoreOptionalFile(filePath, source) {
171081
- if (source === null) {
171082
- await fsp.rm(filePath, { force: true });
171083
- return;
171084
- }
171085
- await fsp.mkdir(path.dirname(filePath), { recursive: true });
171086
- await fsp.writeFile(filePath, source, "utf8");
171087
- }
171088
- async function snapshotWorkspaceFiles(filePaths) {
171089
- const uniquePaths = Array.from(new Set(filePaths));
171090
- return Promise.all(uniquePaths.map(async (filePath) => ({
171091
- filePath,
171092
- source: await readOptionalFile(filePath)
171093
- })));
171094
- }
171095
- async function rollbackWorkspaceMutation(snapshot) {
171096
- for (const targetPath of snapshot.targetPaths) {
171097
- await fsp.rm(targetPath, { force: true, recursive: true });
171098
- }
171099
- for (const snapshotDir of snapshot.snapshotDirs) {
171100
- await fsp.rm(snapshotDir, { force: true, recursive: true });
171101
- }
171102
- for (const { filePath, source } of snapshot.fileSources) {
171103
- await restoreOptionalFile(filePath, source);
171104
- }
171105
- }
171106
- function isFileNotFoundError(error) {
171107
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
171108
- }
171109
-
171110
171088
  // ../wp-typia-project-tools/src/runtime/cli-add-help.ts
171111
171089
  function formatAddHelpText() {
171112
171090
  return `Usage:
@@ -171130,7 +171108,7 @@ Notes:
171130
171108
  \`add admin-view\` scaffolds an opt-in DataViews-powered WordPress admin screen under \`src/admin-views/\`.
171131
171109
  Pass \`--source rest-resource:<slug>\` to reuse a list-capable REST resource.
171132
171110
  Pass \`--source core-data:postType/post\` or \`--source core-data:taxonomy/category\` to bind a WordPress-owned entity collection.
171133
- Public installs currently gate this workflow until \`@wp-typia/dataviews\` is published to npm.
171111
+ Generated admin-view workspaces add \`@wp-typia/dataviews\` and the needed WordPress DataViews packages as opt-in dependencies.
171134
171112
  \`query-loop\` is a create-time scaffold family. Use \`wp-typia create <project-dir> --template query-loop\` instead of \`wp-typia add block\`.
171135
171113
  \`add variation\` targets an existing block slug from \`scripts/block-config.ts\`.
171136
171114
  \`add style\` registers a Block Styles option for an existing generated block.
@@ -171221,6 +171199,59 @@ function resolveScaffoldIdentifiers({
171221
171199
  textDomain: resolveValidatedTextDomain(textDomain ?? normalizedSlug)
171222
171200
  };
171223
171201
  }
171202
+ // ../wp-typia-project-tools/src/runtime/cli-add-filesystem.ts
171203
+ import { promises as fsp } from "fs";
171204
+ import path from "path";
171205
+ function getWorkspaceBootstrapPath(workspace) {
171206
+ const workspaceBaseName = workspace.packageName.split("/").pop() ?? workspace.packageName;
171207
+ return path.join(workspace.projectDir, `${workspaceBaseName}.php`);
171208
+ }
171209
+ async function patchFile(filePath, transform) {
171210
+ const currentSource = await fsp.readFile(filePath, "utf8");
171211
+ const nextSource = transform(currentSource);
171212
+ if (nextSource !== currentSource) {
171213
+ await fsp.writeFile(filePath, nextSource, "utf8");
171214
+ }
171215
+ }
171216
+ async function readOptionalFile(filePath) {
171217
+ try {
171218
+ return await fsp.readFile(filePath, "utf8");
171219
+ } catch (error) {
171220
+ if (isFileNotFoundError(error)) {
171221
+ return null;
171222
+ }
171223
+ throw error;
171224
+ }
171225
+ }
171226
+ async function restoreOptionalFile(filePath, source) {
171227
+ if (source === null) {
171228
+ await fsp.rm(filePath, { force: true });
171229
+ return;
171230
+ }
171231
+ await fsp.mkdir(path.dirname(filePath), { recursive: true });
171232
+ await fsp.writeFile(filePath, source, "utf8");
171233
+ }
171234
+ async function snapshotWorkspaceFiles(filePaths) {
171235
+ const uniquePaths = Array.from(new Set(filePaths));
171236
+ return Promise.all(uniquePaths.map(async (filePath) => ({
171237
+ filePath,
171238
+ source: await readOptionalFile(filePath)
171239
+ })));
171240
+ }
171241
+ async function rollbackWorkspaceMutation(snapshot) {
171242
+ for (const targetPath of snapshot.targetPaths) {
171243
+ await fsp.rm(targetPath, { force: true, recursive: true });
171244
+ }
171245
+ for (const snapshotDir of snapshot.snapshotDirs) {
171246
+ await fsp.rm(snapshotDir, { force: true, recursive: true });
171247
+ }
171248
+ for (const { filePath, source } of snapshot.fileSources) {
171249
+ await restoreOptionalFile(filePath, source);
171250
+ }
171251
+ }
171252
+ function isFileNotFoundError(error) {
171253
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
171254
+ }
171224
171255
  // ../wp-typia-project-tools/src/runtime/cli-add-block-json.ts
171225
171256
  import fs from "fs";
171226
171257
  import path2 from "path";
@@ -171274,179 +171305,244 @@ function assertScaffoldDoesNotExist(options) {
171274
171305
  throw new Error(options.inventoryCollision.message);
171275
171306
  }
171276
171307
  }
171277
- function assertVariationDoesNotExist(projectDir, blockSlug, variationSlug, inventory) {
171308
+ function assertAddKindScaffoldDoesNotExist(options) {
171309
+ const inventoryCollision = options.descriptor.inventoryCollision;
171278
171310
  assertScaffoldDoesNotExist({
171279
- filesystemCollisions: [
171280
- {
171281
- label: "A variation",
171282
- relativePath: path3.join("src", "blocks", blockSlug, "variations", `${variationSlug}.ts`)
171283
- }
171284
- ],
171285
- inventoryCollision: {
171286
- entries: inventory.variations,
171287
- exists: (entry) => entry.block === blockSlug && entry.slug === variationSlug,
171288
- message: `A variation inventory entry already exists for ${blockSlug}/${variationSlug}. Choose a different name.`
171311
+ filesystemCollisions: options.descriptor.filesystemCollisions.map((collision) => ({
171312
+ label: collision.label,
171313
+ relativePath: collision.relativePath(options.context)
171314
+ })),
171315
+ inventoryCollision: inventoryCollision ? {
171316
+ entries: inventoryCollision.entries(options.inventory),
171317
+ exists: (entry) => inventoryCollision.exists(entry, options.context),
171318
+ message: inventoryCollision.message(options.context)
171319
+ } : undefined,
171320
+ projectDir: options.projectDir
171321
+ });
171322
+ }
171323
+ var VARIATION_COLLISION_DESCRIPTOR = {
171324
+ filesystemCollisions: [
171325
+ {
171326
+ label: "A variation",
171327
+ relativePath: ({ blockSlug, slug }) => path3.join("src", "blocks", blockSlug, "variations", `${slug}.ts`)
171328
+ }
171329
+ ],
171330
+ inventoryCollision: {
171331
+ entries: (inventory) => inventory.variations,
171332
+ exists: (entry, { blockSlug, slug }) => entry.block === blockSlug && entry.slug === slug,
171333
+ message: ({ blockSlug, slug }) => `A variation inventory entry already exists for ${blockSlug}/${slug}. Choose a different name.`
171334
+ }
171335
+ };
171336
+ var BLOCK_STYLE_COLLISION_DESCRIPTOR = {
171337
+ filesystemCollisions: [
171338
+ {
171339
+ label: "A block style",
171340
+ relativePath: ({ blockSlug, slug }) => path3.join("src", "blocks", blockSlug, "styles", `${slug}.ts`)
171341
+ }
171342
+ ],
171343
+ inventoryCollision: {
171344
+ entries: (inventory) => inventory.blockStyles,
171345
+ exists: (entry, { blockSlug, slug }) => entry.block === blockSlug && entry.slug === slug,
171346
+ message: ({ blockSlug, slug }) => `A block style inventory entry already exists for ${blockSlug}/${slug}. Choose a different name.`
171347
+ }
171348
+ };
171349
+ var BLOCK_TRANSFORM_COLLISION_DESCRIPTOR = {
171350
+ filesystemCollisions: [
171351
+ {
171352
+ label: "A block transform",
171353
+ relativePath: ({ blockSlug, slug }) => path3.join("src", "blocks", blockSlug, "transforms", `${slug}.ts`)
171354
+ }
171355
+ ],
171356
+ inventoryCollision: {
171357
+ entries: (inventory) => inventory.blockTransforms,
171358
+ exists: (entry, { blockSlug, slug }) => entry.block === blockSlug && entry.slug === slug,
171359
+ message: ({ blockSlug, slug }) => `A block transform inventory entry already exists for ${blockSlug}/${slug}. Choose a different name.`
171360
+ }
171361
+ };
171362
+ var PATTERN_COLLISION_DESCRIPTOR = {
171363
+ filesystemCollisions: [
171364
+ {
171365
+ label: "A pattern",
171366
+ relativePath: ({ slug }) => path3.join("src", "patterns", `${slug}.php`)
171367
+ }
171368
+ ],
171369
+ inventoryCollision: {
171370
+ entries: (inventory) => inventory.patterns,
171371
+ exists: (entry, { slug }) => entry.slug === slug,
171372
+ message: ({ slug }) => `A pattern inventory entry already exists for ${slug}. Choose a different name.`
171373
+ }
171374
+ };
171375
+ var BINDING_SOURCE_COLLISION_DESCRIPTOR = {
171376
+ filesystemCollisions: [
171377
+ {
171378
+ label: "A binding source",
171379
+ relativePath: ({ slug }) => path3.join("src", "bindings", slug)
171380
+ }
171381
+ ],
171382
+ inventoryCollision: {
171383
+ entries: (inventory) => inventory.bindingSources,
171384
+ exists: (entry, { slug }) => entry.slug === slug,
171385
+ message: ({ slug }) => `A binding source inventory entry already exists for ${slug}. Choose a different name.`
171386
+ }
171387
+ };
171388
+ var REST_RESOURCE_COLLISION_DESCRIPTOR = {
171389
+ filesystemCollisions: [
171390
+ {
171391
+ label: "A REST resource",
171392
+ relativePath: ({ slug }) => path3.join("src", "rest", slug)
171393
+ },
171394
+ {
171395
+ label: "A REST resource bootstrap",
171396
+ relativePath: ({ slug }) => path3.join("inc", "rest", `${slug}.php`)
171397
+ }
171398
+ ],
171399
+ inventoryCollision: {
171400
+ entries: (inventory) => inventory.restResources,
171401
+ exists: (entry, { slug }) => entry.slug === slug,
171402
+ message: ({ slug }) => `A REST resource inventory entry already exists for ${slug}. Choose a different name.`
171403
+ }
171404
+ };
171405
+ var ADMIN_VIEW_COLLISION_DESCRIPTOR = {
171406
+ filesystemCollisions: [
171407
+ {
171408
+ label: "An admin view",
171409
+ relativePath: ({ slug }) => path3.join("src", "admin-views", slug)
171410
+ },
171411
+ {
171412
+ label: "An admin view bootstrap",
171413
+ relativePath: ({ slug }) => path3.join("inc", "admin-views", `${slug}.php`)
171414
+ }
171415
+ ],
171416
+ inventoryCollision: {
171417
+ entries: (inventory) => inventory.adminViews,
171418
+ exists: (entry, { slug }) => entry.slug === slug,
171419
+ message: ({ slug }) => `An admin view inventory entry already exists for ${slug}. Choose a different name.`
171420
+ }
171421
+ };
171422
+ var ABILITY_COLLISION_DESCRIPTOR = {
171423
+ filesystemCollisions: [
171424
+ {
171425
+ label: "An ability scaffold",
171426
+ relativePath: ({ slug }) => path3.join("src", "abilities", slug)
171427
+ },
171428
+ {
171429
+ label: "An ability bootstrap",
171430
+ relativePath: ({ slug }) => path3.join("inc", "abilities", `${slug}.php`)
171431
+ }
171432
+ ],
171433
+ inventoryCollision: {
171434
+ entries: (inventory) => inventory.abilities,
171435
+ exists: (entry, { slug }) => entry.slug === slug,
171436
+ message: ({ slug }) => `An ability inventory entry already exists for ${slug}. Choose a different name.`
171437
+ }
171438
+ };
171439
+ var AI_FEATURE_COLLISION_DESCRIPTOR = {
171440
+ filesystemCollisions: [
171441
+ {
171442
+ label: "An AI feature",
171443
+ relativePath: ({ slug }) => path3.join("src", "ai-features", slug)
171289
171444
  },
171445
+ {
171446
+ label: "An AI feature bootstrap",
171447
+ relativePath: ({ slug }) => path3.join("inc", "ai-features", `${slug}.php`)
171448
+ }
171449
+ ],
171450
+ inventoryCollision: {
171451
+ entries: (inventory) => inventory.aiFeatures,
171452
+ exists: (entry, { slug }) => entry.slug === slug,
171453
+ message: ({ slug }) => `An AI feature inventory entry already exists for ${slug}. Choose a different name.`
171454
+ }
171455
+ };
171456
+ var EDITOR_PLUGIN_COLLISION_DESCRIPTOR = {
171457
+ filesystemCollisions: [
171458
+ {
171459
+ label: "An editor plugin",
171460
+ relativePath: ({ slug }) => path3.join("src", "editor-plugins", slug)
171461
+ }
171462
+ ],
171463
+ inventoryCollision: {
171464
+ entries: (inventory) => inventory.editorPlugins,
171465
+ exists: (entry, { slug }) => entry.slug === slug,
171466
+ message: ({ slug }) => `An editor plugin inventory entry already exists for ${slug}. Choose a different name.`
171467
+ }
171468
+ };
171469
+ function assertVariationDoesNotExist(projectDir, blockSlug, variationSlug, inventory) {
171470
+ assertAddKindScaffoldDoesNotExist({
171471
+ context: { blockSlug, slug: variationSlug },
171472
+ descriptor: VARIATION_COLLISION_DESCRIPTOR,
171473
+ inventory,
171290
171474
  projectDir
171291
171475
  });
171292
171476
  }
171293
171477
  function assertBlockStyleDoesNotExist(projectDir, blockSlug, styleSlug, inventory) {
171294
- assertScaffoldDoesNotExist({
171295
- filesystemCollisions: [
171296
- {
171297
- label: "A block style",
171298
- relativePath: path3.join("src", "blocks", blockSlug, "styles", `${styleSlug}.ts`)
171299
- }
171300
- ],
171301
- inventoryCollision: {
171302
- entries: inventory.blockStyles,
171303
- exists: (entry) => entry.block === blockSlug && entry.slug === styleSlug,
171304
- message: `A block style inventory entry already exists for ${blockSlug}/${styleSlug}. Choose a different name.`
171305
- },
171478
+ assertAddKindScaffoldDoesNotExist({
171479
+ context: { blockSlug, slug: styleSlug },
171480
+ descriptor: BLOCK_STYLE_COLLISION_DESCRIPTOR,
171481
+ inventory,
171306
171482
  projectDir
171307
171483
  });
171308
171484
  }
171309
171485
  function assertBlockTransformDoesNotExist(projectDir, blockSlug, transformSlug, inventory) {
171310
- assertScaffoldDoesNotExist({
171311
- filesystemCollisions: [
171312
- {
171313
- label: "A block transform",
171314
- relativePath: path3.join("src", "blocks", blockSlug, "transforms", `${transformSlug}.ts`)
171315
- }
171316
- ],
171317
- inventoryCollision: {
171318
- entries: inventory.blockTransforms,
171319
- exists: (entry) => entry.block === blockSlug && entry.slug === transformSlug,
171320
- message: `A block transform inventory entry already exists for ${blockSlug}/${transformSlug}. Choose a different name.`
171321
- },
171486
+ assertAddKindScaffoldDoesNotExist({
171487
+ context: { blockSlug, slug: transformSlug },
171488
+ descriptor: BLOCK_TRANSFORM_COLLISION_DESCRIPTOR,
171489
+ inventory,
171322
171490
  projectDir
171323
171491
  });
171324
171492
  }
171325
171493
  function assertPatternDoesNotExist(projectDir, patternSlug, inventory) {
171326
- assertScaffoldDoesNotExist({
171327
- filesystemCollisions: [
171328
- {
171329
- label: "A pattern",
171330
- relativePath: path3.join("src", "patterns", `${patternSlug}.php`)
171331
- }
171332
- ],
171333
- inventoryCollision: {
171334
- entries: inventory.patterns,
171335
- exists: (entry) => entry.slug === patternSlug,
171336
- message: `A pattern inventory entry already exists for ${patternSlug}. Choose a different name.`
171337
- },
171494
+ assertAddKindScaffoldDoesNotExist({
171495
+ context: { slug: patternSlug },
171496
+ descriptor: PATTERN_COLLISION_DESCRIPTOR,
171497
+ inventory,
171338
171498
  projectDir
171339
171499
  });
171340
171500
  }
171341
171501
  function assertBindingSourceDoesNotExist(projectDir, bindingSourceSlug, inventory) {
171342
- assertScaffoldDoesNotExist({
171343
- filesystemCollisions: [
171344
- {
171345
- label: "A binding source",
171346
- relativePath: path3.join("src", "bindings", bindingSourceSlug)
171347
- }
171348
- ],
171349
- inventoryCollision: {
171350
- entries: inventory.bindingSources,
171351
- exists: (entry) => entry.slug === bindingSourceSlug,
171352
- message: `A binding source inventory entry already exists for ${bindingSourceSlug}. Choose a different name.`
171353
- },
171502
+ assertAddKindScaffoldDoesNotExist({
171503
+ context: { slug: bindingSourceSlug },
171504
+ descriptor: BINDING_SOURCE_COLLISION_DESCRIPTOR,
171505
+ inventory,
171354
171506
  projectDir
171355
171507
  });
171356
171508
  }
171357
171509
  function assertRestResourceDoesNotExist(projectDir, restResourceSlug, inventory) {
171358
- assertScaffoldDoesNotExist({
171359
- filesystemCollisions: [
171360
- {
171361
- label: "A REST resource",
171362
- relativePath: path3.join("src", "rest", restResourceSlug)
171363
- },
171364
- {
171365
- label: "A REST resource bootstrap",
171366
- relativePath: path3.join("inc", "rest", `${restResourceSlug}.php`)
171367
- }
171368
- ],
171369
- inventoryCollision: {
171370
- entries: inventory.restResources,
171371
- exists: (entry) => entry.slug === restResourceSlug,
171372
- message: `A REST resource inventory entry already exists for ${restResourceSlug}. Choose a different name.`
171373
- },
171510
+ assertAddKindScaffoldDoesNotExist({
171511
+ context: { slug: restResourceSlug },
171512
+ descriptor: REST_RESOURCE_COLLISION_DESCRIPTOR,
171513
+ inventory,
171374
171514
  projectDir
171375
171515
  });
171376
171516
  }
171377
171517
  function assertAdminViewDoesNotExist(projectDir, adminViewSlug, inventory) {
171378
- assertScaffoldDoesNotExist({
171379
- filesystemCollisions: [
171380
- {
171381
- label: "An admin view",
171382
- relativePath: path3.join("src", "admin-views", adminViewSlug)
171383
- },
171384
- {
171385
- label: "An admin view bootstrap",
171386
- relativePath: path3.join("inc", "admin-views", `${adminViewSlug}.php`)
171387
- }
171388
- ],
171389
- inventoryCollision: {
171390
- entries: inventory.adminViews,
171391
- exists: (entry) => entry.slug === adminViewSlug,
171392
- message: `An admin view inventory entry already exists for ${adminViewSlug}. Choose a different name.`
171393
- },
171518
+ assertAddKindScaffoldDoesNotExist({
171519
+ context: { slug: adminViewSlug },
171520
+ descriptor: ADMIN_VIEW_COLLISION_DESCRIPTOR,
171521
+ inventory,
171394
171522
  projectDir
171395
171523
  });
171396
171524
  }
171397
171525
  function assertAbilityDoesNotExist(projectDir, abilitySlug, inventory) {
171398
- assertScaffoldDoesNotExist({
171399
- filesystemCollisions: [
171400
- {
171401
- label: "An ability scaffold",
171402
- relativePath: path3.join("src", "abilities", abilitySlug)
171403
- },
171404
- {
171405
- label: "An ability bootstrap",
171406
- relativePath: path3.join("inc", "abilities", `${abilitySlug}.php`)
171407
- }
171408
- ],
171409
- inventoryCollision: {
171410
- entries: inventory.abilities,
171411
- exists: (entry) => entry.slug === abilitySlug,
171412
- message: `An ability inventory entry already exists for ${abilitySlug}. Choose a different name.`
171413
- },
171526
+ assertAddKindScaffoldDoesNotExist({
171527
+ context: { slug: abilitySlug },
171528
+ descriptor: ABILITY_COLLISION_DESCRIPTOR,
171529
+ inventory,
171414
171530
  projectDir
171415
171531
  });
171416
171532
  }
171417
171533
  function assertAiFeatureDoesNotExist(projectDir, aiFeatureSlug, inventory) {
171418
- assertScaffoldDoesNotExist({
171419
- filesystemCollisions: [
171420
- {
171421
- label: "An AI feature",
171422
- relativePath: path3.join("src", "ai-features", aiFeatureSlug)
171423
- },
171424
- {
171425
- label: "An AI feature bootstrap",
171426
- relativePath: path3.join("inc", "ai-features", `${aiFeatureSlug}.php`)
171427
- }
171428
- ],
171429
- inventoryCollision: {
171430
- entries: inventory.aiFeatures,
171431
- exists: (entry) => entry.slug === aiFeatureSlug,
171432
- message: `An AI feature inventory entry already exists for ${aiFeatureSlug}. Choose a different name.`
171433
- },
171534
+ assertAddKindScaffoldDoesNotExist({
171535
+ context: { slug: aiFeatureSlug },
171536
+ descriptor: AI_FEATURE_COLLISION_DESCRIPTOR,
171537
+ inventory,
171434
171538
  projectDir
171435
171539
  });
171436
171540
  }
171437
171541
  function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inventory) {
171438
- assertScaffoldDoesNotExist({
171439
- filesystemCollisions: [
171440
- {
171441
- label: "An editor plugin",
171442
- relativePath: path3.join("src", "editor-plugins", editorPluginSlug)
171443
- }
171444
- ],
171445
- inventoryCollision: {
171446
- entries: inventory.editorPlugins,
171447
- exists: (entry) => entry.slug === editorPluginSlug,
171448
- message: `An editor plugin inventory entry already exists for ${editorPluginSlug}. Choose a different name.`
171449
- },
171542
+ assertAddKindScaffoldDoesNotExist({
171543
+ context: { slug: editorPluginSlug },
171544
+ descriptor: EDITOR_PLUGIN_COLLISION_DESCRIPTOR,
171545
+ inventory,
171450
171546
  projectDir
171451
171547
  });
171452
171548
  }
@@ -171466,6 +171562,229 @@ function quotePhpString(value) {
171466
171562
  function hasPhpFunctionDefinition(source, functionName) {
171467
171563
  return new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\(`, "u").test(source);
171468
171564
  }
171565
+ function isPhpIdentifierStart(character) {
171566
+ return /^[A-Za-z_]$/u.test(character ?? "");
171567
+ }
171568
+ function isPhpIdentifierPart(character) {
171569
+ return /^[A-Za-z0-9_]$/u.test(character ?? "");
171570
+ }
171571
+ function isPhpLineStart(source, index) {
171572
+ return index === 0 || source[index - 1] === `
171573
+ `;
171574
+ }
171575
+ function isPhpHorizontalWhitespace(character) {
171576
+ return character === " " || character === "\t";
171577
+ }
171578
+ function isPhpWhitespace(character) {
171579
+ return typeof character === "string" && /\s/u.test(character);
171580
+ }
171581
+ function findPhpLineBoundary(source, index) {
171582
+ const newlineIndex = source.indexOf(`
171583
+ `, index);
171584
+ if (newlineIndex === -1) {
171585
+ return {
171586
+ contentEnd: source.endsWith("\r") ? source.length - 1 : source.length,
171587
+ nextStart: source.length
171588
+ };
171589
+ }
171590
+ return {
171591
+ contentEnd: source[newlineIndex - 1] === "\r" ? newlineIndex - 1 : newlineIndex,
171592
+ nextStart: newlineIndex + 1
171593
+ };
171594
+ }
171595
+ function parsePhpHeredocStart(source, index) {
171596
+ if (!source.startsWith("<<<", index)) {
171597
+ return null;
171598
+ }
171599
+ let cursor = index + 3;
171600
+ while (isPhpHorizontalWhitespace(source[cursor])) {
171601
+ cursor += 1;
171602
+ }
171603
+ const quote = source[cursor] === "'" || source[cursor] === '"' ? source[cursor] : "";
171604
+ if (quote) {
171605
+ cursor += 1;
171606
+ }
171607
+ if (!isPhpIdentifierStart(source[cursor])) {
171608
+ return null;
171609
+ }
171610
+ const delimiterStart = cursor;
171611
+ cursor += 1;
171612
+ while (isPhpIdentifierPart(source[cursor])) {
171613
+ cursor += 1;
171614
+ }
171615
+ const delimiter = source.slice(delimiterStart, cursor);
171616
+ if (quote) {
171617
+ if (source[cursor] !== quote) {
171618
+ return null;
171619
+ }
171620
+ cursor += 1;
171621
+ }
171622
+ const lineBoundary = findPhpLineBoundary(source, cursor);
171623
+ if (source.slice(cursor, lineBoundary.contentEnd).trim() !== "") {
171624
+ return null;
171625
+ }
171626
+ return {
171627
+ contentStart: lineBoundary.nextStart,
171628
+ delimiter
171629
+ };
171630
+ }
171631
+ function findPhpHeredocClosingEnd(source, index, delimiter) {
171632
+ if (!isPhpLineStart(source, index)) {
171633
+ return null;
171634
+ }
171635
+ let cursor = index;
171636
+ while (isPhpHorizontalWhitespace(source[cursor])) {
171637
+ cursor += 1;
171638
+ }
171639
+ if (!source.startsWith(delimiter, cursor)) {
171640
+ return null;
171641
+ }
171642
+ cursor += delimiter.length;
171643
+ if (isPhpIdentifierPart(source[cursor])) {
171644
+ return null;
171645
+ }
171646
+ let continuationCursor = cursor;
171647
+ while (isPhpHorizontalWhitespace(source[continuationCursor])) {
171648
+ continuationCursor += 1;
171649
+ }
171650
+ const continuation = source[continuationCursor];
171651
+ if (continuationCursor >= source.length || continuation === "\r" || continuation === `
171652
+ ` || !isPhpIdentifierPart(continuation)) {
171653
+ return cursor;
171654
+ }
171655
+ return null;
171656
+ }
171657
+ function skipPhpCallTrivia(source, index) {
171658
+ let cursor = index;
171659
+ while (cursor < source.length) {
171660
+ while (isPhpWhitespace(source[cursor])) {
171661
+ cursor += 1;
171662
+ }
171663
+ if (source[cursor] === "/" && source[cursor + 1] === "*") {
171664
+ const commentEnd = source.indexOf("*/", cursor + 2);
171665
+ if (commentEnd === -1) {
171666
+ return null;
171667
+ }
171668
+ cursor = commentEnd + 2;
171669
+ continue;
171670
+ }
171671
+ if (source[cursor] === "/" && source[cursor + 1] === "/") {
171672
+ cursor = findPhpLineBoundary(source, cursor + 2).nextStart;
171673
+ continue;
171674
+ }
171675
+ if (source[cursor] === "#" && source[cursor + 1] !== "[") {
171676
+ cursor = findPhpLineBoundary(source, cursor + 1).nextStart;
171677
+ continue;
171678
+ }
171679
+ return cursor;
171680
+ }
171681
+ return cursor;
171682
+ }
171683
+ function matchesPhpFunctionCallAt(source, index, functionName) {
171684
+ if (!source.startsWith(functionName, index)) {
171685
+ return false;
171686
+ }
171687
+ if (isPhpIdentifierPart(source[index - 1])) {
171688
+ return false;
171689
+ }
171690
+ const cursor = index + functionName.length;
171691
+ if (isPhpIdentifierPart(source[cursor])) {
171692
+ return false;
171693
+ }
171694
+ const callStart = skipPhpCallTrivia(source, cursor);
171695
+ return callStart !== null && source[callStart] === "(";
171696
+ }
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" ? "'" : '"';
171720
+ if (character === "\\") {
171721
+ index += 2;
171722
+ continue;
171723
+ }
171724
+ if (character === quote) {
171725
+ mode = "code";
171726
+ }
171727
+ index += 1;
171728
+ continue;
171729
+ }
171730
+ if (mode === "line-comment") {
171731
+ if (character === "\r" || character === `
171732
+ `) {
171733
+ mode = "code";
171734
+ }
171735
+ index += 1;
171736
+ continue;
171737
+ }
171738
+ if (mode === "block-comment") {
171739
+ if (character === "*" && source[index + 1] === "/") {
171740
+ mode = "code";
171741
+ index += 2;
171742
+ continue;
171743
+ }
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;
171756
+ }
171757
+ if (character === "/" && source[index + 1] === "/") {
171758
+ mode = "line-comment";
171759
+ index += 2;
171760
+ continue;
171761
+ }
171762
+ if (character === "#" && source[index + 1] !== "[") {
171763
+ mode = "line-comment";
171764
+ index += 1;
171765
+ continue;
171766
+ }
171767
+ if (character === "/" && source[index + 1] === "*") {
171768
+ mode = "block-comment";
171769
+ index += 2;
171770
+ continue;
171771
+ }
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;
171779
+ }
171780
+ }
171781
+ if (matchesPhpFunctionCallAt(source, index, functionName)) {
171782
+ return true;
171783
+ }
171784
+ index += 1;
171785
+ }
171786
+ return false;
171787
+ }
171469
171788
  function findPhpFunctionRange(source, functionName, options = {}) {
171470
171789
  const signaturePattern = new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\([^)]*\\)\\s*(?::\\s*[^{};]+)?\\s*\\{`, "u");
171471
171790
  const signatureMatch = signaturePattern.exec(source);
@@ -171479,13 +171798,96 @@ function findPhpFunctionRange(source, functionName, options = {}) {
171479
171798
  }
171480
171799
  const openBraceIndex = functionStart + openBraceOffset;
171481
171800
  let depth = 0;
171482
- for (let index = openBraceIndex;index < source.length; index += 1) {
171801
+ let mode = "code";
171802
+ let heredocDelimiter = "";
171803
+ let index = openBraceIndex;
171804
+ while (index < source.length) {
171483
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;
171869
+ }
171870
+ if (character === "/" && source[index + 1] === "*") {
171871
+ mode = "block-comment";
171872
+ index += 2;
171873
+ continue;
171874
+ }
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
+ }
171484
171884
  if (character === "{") {
171485
171885
  depth += 1;
171886
+ index += 1;
171486
171887
  continue;
171487
171888
  }
171488
171889
  if (character !== "}") {
171890
+ index += 1;
171489
171891
  continue;
171490
171892
  }
171491
171893
  depth -= 1;
@@ -171502,6 +171904,7 @@ function findPhpFunctionRange(source, functionName, options = {}) {
171502
171904
  start: functionStart
171503
171905
  };
171504
171906
  }
171907
+ index += 1;
171505
171908
  }
171506
171909
  return null;
171507
171910
  }
@@ -171518,6 +171921,9 @@ function replacePhpFunctionDefinition(source, functionName, replacement, options
171518
171921
  }
171519
171922
 
171520
171923
  // ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
171924
+ function defineInventoryEntryParser(descriptor) {
171925
+ return descriptor;
171926
+ }
171521
171927
  var BLOCK_CONFIG_ENTRY_MARKER = "\t// wp-typia add block entries";
171522
171928
  var VARIATION_CONFIG_ENTRY_MARKER = "\t// wp-typia add variation entries";
171523
171929
  var BLOCK_STYLE_CONFIG_ENTRY_MARKER = "\t// wp-typia add style entries";
@@ -171713,102 +172119,319 @@ export const EDITOR_PLUGINS: WorkspaceEditorPluginConfig[] = [
171713
172119
  // wp-typia add editor-plugin entries
171714
172120
  ];
171715
172121
  `;
172122
+ var BLOCK_INVENTORY_SECTION = {
172123
+ append: {
172124
+ marker: BLOCK_CONFIG_ENTRY_MARKER,
172125
+ optionKey: "blockEntries"
172126
+ },
172127
+ parse: {
172128
+ entriesKey: "blocks",
172129
+ entry: defineInventoryEntryParser({
172130
+ entryName: "BLOCKS",
172131
+ fields: [
172132
+ { key: "apiTypesFile" },
172133
+ { key: "attributeTypeName" },
172134
+ { key: "openApiFile" },
172135
+ { key: "slug", required: true },
172136
+ { key: "typesFile", required: true }
172137
+ ]
172138
+ }),
172139
+ exportName: "BLOCKS",
172140
+ required: true
172141
+ }
172142
+ };
171716
172143
  var INVENTORY_SECTIONS = [
171717
172144
  {
172145
+ append: {
172146
+ marker: VARIATION_CONFIG_ENTRY_MARKER,
172147
+ optionKey: "variationEntries"
172148
+ },
171718
172149
  interface: {
171719
172150
  name: "WorkspaceVariationConfig",
171720
172151
  section: VARIATIONS_INTERFACE_SECTION
171721
172152
  },
172153
+ parse: {
172154
+ entriesKey: "variations",
172155
+ entry: defineInventoryEntryParser({
172156
+ entryName: "VARIATIONS",
172157
+ fields: [
172158
+ { key: "block", required: true },
172159
+ { key: "file", required: true },
172160
+ { key: "slug", required: true }
172161
+ ]
172162
+ }),
172163
+ hasSectionKey: "hasVariationsSection"
172164
+ },
171722
172165
  value: {
171723
172166
  name: "VARIATIONS",
171724
172167
  section: VARIATIONS_CONST_SECTION
171725
172168
  }
171726
172169
  },
171727
172170
  {
172171
+ append: {
172172
+ marker: BLOCK_STYLE_CONFIG_ENTRY_MARKER,
172173
+ optionKey: "blockStyleEntries"
172174
+ },
171728
172175
  interface: {
171729
172176
  name: "WorkspaceBlockStyleConfig",
171730
172177
  section: BLOCK_STYLES_INTERFACE_SECTION
171731
172178
  },
172179
+ parse: {
172180
+ entriesKey: "blockStyles",
172181
+ entry: defineInventoryEntryParser({
172182
+ entryName: "BLOCK_STYLES",
172183
+ fields: [
172184
+ { key: "block", required: true },
172185
+ { key: "file", required: true },
172186
+ { key: "slug", required: true }
172187
+ ]
172188
+ }),
172189
+ hasSectionKey: "hasBlockStylesSection"
172190
+ },
171732
172191
  value: {
171733
172192
  name: "BLOCK_STYLES",
171734
172193
  section: BLOCK_STYLES_CONST_SECTION
171735
172194
  }
171736
172195
  },
171737
172196
  {
172197
+ append: {
172198
+ marker: BLOCK_TRANSFORM_CONFIG_ENTRY_MARKER,
172199
+ optionKey: "blockTransformEntries"
172200
+ },
171738
172201
  interface: {
171739
172202
  name: "WorkspaceBlockTransformConfig",
171740
172203
  section: BLOCK_TRANSFORMS_INTERFACE_SECTION
171741
172204
  },
172205
+ parse: {
172206
+ entriesKey: "blockTransforms",
172207
+ entry: defineInventoryEntryParser({
172208
+ entryName: "BLOCK_TRANSFORMS",
172209
+ fields: [
172210
+ { key: "block", required: true },
172211
+ { key: "file", required: true },
172212
+ { key: "from", required: true },
172213
+ { key: "slug", required: true },
172214
+ { key: "to", required: true }
172215
+ ]
172216
+ }),
172217
+ hasSectionKey: "hasBlockTransformsSection"
172218
+ },
171742
172219
  value: {
171743
172220
  name: "BLOCK_TRANSFORMS",
171744
172221
  section: BLOCK_TRANSFORMS_CONST_SECTION
171745
172222
  }
171746
172223
  },
171747
172224
  {
172225
+ append: {
172226
+ marker: PATTERN_CONFIG_ENTRY_MARKER,
172227
+ optionKey: "patternEntries"
172228
+ },
171748
172229
  interface: {
171749
172230
  name: "WorkspacePatternConfig",
171750
172231
  section: PATTERNS_INTERFACE_SECTION
171751
172232
  },
172233
+ parse: {
172234
+ entriesKey: "patterns",
172235
+ entry: defineInventoryEntryParser({
172236
+ entryName: "PATTERNS",
172237
+ fields: [
172238
+ { key: "file", required: true },
172239
+ { key: "slug", required: true }
172240
+ ]
172241
+ }),
172242
+ hasSectionKey: "hasPatternsSection"
172243
+ },
171752
172244
  value: {
171753
172245
  name: "PATTERNS",
171754
172246
  section: PATTERNS_CONST_SECTION
171755
172247
  }
171756
172248
  },
171757
172249
  {
172250
+ append: {
172251
+ marker: BINDING_SOURCE_CONFIG_ENTRY_MARKER,
172252
+ optionKey: "bindingSourceEntries"
172253
+ },
171758
172254
  interface: {
171759
172255
  name: "WorkspaceBindingSourceConfig",
171760
172256
  section: BINDING_SOURCES_INTERFACE_SECTION
171761
172257
  },
172258
+ parse: {
172259
+ entriesKey: "bindingSources",
172260
+ entry: defineInventoryEntryParser({
172261
+ entryName: "BINDING_SOURCES",
172262
+ fields: [
172263
+ { key: "attribute" },
172264
+ { key: "block" },
172265
+ { key: "editorFile", required: true },
172266
+ { key: "serverFile", required: true },
172267
+ { key: "slug", required: true }
172268
+ ]
172269
+ }),
172270
+ hasSectionKey: "hasBindingSourcesSection"
172271
+ },
171762
172272
  value: {
171763
172273
  name: "BINDING_SOURCES",
171764
172274
  section: BINDING_SOURCES_CONST_SECTION
171765
172275
  }
171766
172276
  },
171767
172277
  {
172278
+ append: {
172279
+ marker: REST_RESOURCE_CONFIG_ENTRY_MARKER,
172280
+ optionKey: "restResourceEntries"
172281
+ },
171768
172282
  interface: {
171769
172283
  name: "WorkspaceRestResourceConfig",
171770
172284
  section: REST_RESOURCES_INTERFACE_SECTION
171771
172285
  },
172286
+ parse: {
172287
+ entriesKey: "restResources",
172288
+ entry: defineInventoryEntryParser({
172289
+ entryName: "REST_RESOURCES",
172290
+ fields: [
172291
+ { key: "apiFile", required: true },
172292
+ { key: "clientFile", required: true },
172293
+ { key: "dataFile", required: true },
172294
+ {
172295
+ key: "methods",
172296
+ kind: "stringArray",
172297
+ required: true,
172298
+ validate: (value, context) => {
172299
+ const methods = Array.isArray(value) ? value : [];
172300
+ const invalidMethods = methods.filter((method) => !REST_RESOURCE_METHOD_IDS.includes(method));
172301
+ if (invalidMethods.length > 0) {
172302
+ throw new Error(`${context.entryName}[${context.elementIndex}].${context.key} includes unsupported values: ${invalidMethods.join(", ")}.`);
172303
+ }
172304
+ }
172305
+ },
172306
+ { key: "namespace", required: true },
172307
+ { key: "openApiFile", required: true },
172308
+ { key: "phpFile", required: true },
172309
+ { key: "slug", required: true },
172310
+ { key: "typesFile", required: true },
172311
+ { key: "validatorsFile", required: true }
172312
+ ]
172313
+ }),
172314
+ hasSectionKey: "hasRestResourcesSection"
172315
+ },
171772
172316
  value: {
171773
172317
  name: "REST_RESOURCES",
171774
172318
  section: REST_RESOURCES_CONST_SECTION
171775
172319
  }
171776
172320
  },
171777
172321
  {
172322
+ append: {
172323
+ marker: ABILITY_CONFIG_ENTRY_MARKER,
172324
+ optionKey: "abilityEntries"
172325
+ },
171778
172326
  interface: {
171779
172327
  name: "WorkspaceAbilityConfig",
171780
172328
  section: ABILITIES_INTERFACE_SECTION
171781
172329
  },
172330
+ parse: {
172331
+ entriesKey: "abilities",
172332
+ entry: defineInventoryEntryParser({
172333
+ entryName: "ABILITIES",
172334
+ fields: [
172335
+ { key: "clientFile", required: true },
172336
+ { key: "configFile", required: true },
172337
+ { key: "dataFile", required: true },
172338
+ { key: "inputSchemaFile", required: true },
172339
+ { key: "inputTypeName", required: true },
172340
+ { key: "outputSchemaFile", required: true },
172341
+ { key: "outputTypeName", required: true },
172342
+ { key: "phpFile", required: true },
172343
+ { key: "slug", required: true },
172344
+ { key: "typesFile", required: true }
172345
+ ]
172346
+ }),
172347
+ hasSectionKey: "hasAbilitiesSection"
172348
+ },
171782
172349
  value: {
171783
172350
  name: "ABILITIES",
171784
172351
  section: ABILITIES_CONST_SECTION
171785
172352
  }
171786
172353
  },
171787
172354
  {
172355
+ append: {
172356
+ marker: AI_FEATURE_CONFIG_ENTRY_MARKER,
172357
+ optionKey: "aiFeatureEntries"
172358
+ },
171788
172359
  interface: {
171789
172360
  name: "WorkspaceAiFeatureConfig",
171790
172361
  section: AI_FEATURES_INTERFACE_SECTION
171791
172362
  },
172363
+ parse: {
172364
+ entriesKey: "aiFeatures",
172365
+ entry: defineInventoryEntryParser({
172366
+ entryName: "AI_FEATURES",
172367
+ fields: [
172368
+ { key: "aiSchemaFile", required: true },
172369
+ { key: "apiFile", required: true },
172370
+ { key: "clientFile", required: true },
172371
+ { key: "dataFile", required: true },
172372
+ { key: "namespace", required: true },
172373
+ { key: "openApiFile", required: true },
172374
+ { key: "phpFile", required: true },
172375
+ { key: "slug", required: true },
172376
+ { key: "typesFile", required: true },
172377
+ { key: "validatorsFile", required: true }
172378
+ ]
172379
+ }),
172380
+ hasSectionKey: "hasAiFeaturesSection"
172381
+ },
171792
172382
  value: {
171793
172383
  name: "AI_FEATURES",
171794
172384
  section: AI_FEATURES_CONST_SECTION
171795
172385
  }
171796
172386
  },
171797
172387
  {
172388
+ append: {
172389
+ marker: ADMIN_VIEW_CONFIG_ENTRY_MARKER,
172390
+ optionKey: "adminViewEntries"
172391
+ },
171798
172392
  interface: {
171799
172393
  name: "WorkspaceAdminViewConfig",
171800
172394
  section: ADMIN_VIEWS_INTERFACE_SECTION
171801
172395
  },
172396
+ parse: {
172397
+ entriesKey: "adminViews",
172398
+ entry: defineInventoryEntryParser({
172399
+ entryName: "ADMIN_VIEWS",
172400
+ fields: [
172401
+ { key: "file", required: true },
172402
+ { key: "phpFile", required: true },
172403
+ { key: "slug", required: true },
172404
+ { key: "source" }
172405
+ ]
172406
+ }),
172407
+ hasSectionKey: "hasAdminViewsSection"
172408
+ },
171802
172409
  value: {
171803
172410
  name: "ADMIN_VIEWS",
171804
172411
  section: ADMIN_VIEWS_CONST_SECTION
171805
172412
  }
171806
172413
  },
171807
172414
  {
172415
+ append: {
172416
+ marker: EDITOR_PLUGIN_CONFIG_ENTRY_MARKER,
172417
+ optionKey: "editorPluginEntries"
172418
+ },
171808
172419
  interface: {
171809
172420
  name: "WorkspaceEditorPluginConfig",
171810
172421
  section: EDITOR_PLUGINS_INTERFACE_SECTION
171811
172422
  },
172423
+ parse: {
172424
+ entriesKey: "editorPlugins",
172425
+ entry: defineInventoryEntryParser({
172426
+ entryName: "EDITOR_PLUGINS",
172427
+ fields: [
172428
+ { key: "file", required: true },
172429
+ { key: "slug", required: true },
172430
+ { key: "slot", required: true }
172431
+ ]
172432
+ }),
172433
+ hasSectionKey: "hasEditorPluginsSection"
172434
+ },
171812
172435
  value: {
171813
172436
  name: "EDITOR_PLUGINS",
171814
172437
  section: EDITOR_PLUGINS_CONST_SECTION
@@ -171894,240 +172517,95 @@ function getRequiredStringArrayProperty(entryName, elementIndex, objectLiteral,
171894
172517
  }
171895
172518
  throw new Error(`${entryName}[${elementIndex}] is missing required "${key}" in scripts/block-config.ts.`);
171896
172519
  }
171897
- function parseBlockEntries(arrayLiteral) {
171898
- return arrayLiteral.elements.map((element, elementIndex) => {
171899
- 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) {
172520
+ function parseInventoryEntries(arrayLiteral, descriptor) {
171975
172521
  return arrayLiteral.elements.map((element, elementIndex) => {
171976
172522
  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.`);
172523
+ throw new Error(`${descriptor.entryName}[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
172524
+ }
172525
+ const entry = {};
172526
+ for (const field of descriptor.fields) {
172527
+ const kind = field.kind ?? "string";
172528
+ 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);
172529
+ field.validate?.(value, {
172530
+ elementIndex,
172531
+ entryName: descriptor.entryName,
172532
+ key: field.key
172533
+ });
172534
+ entry[field.key] = value;
172002
172535
  }
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
- };
172536
+ return entry;
172015
172537
  });
172016
172538
  }
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
- }
172539
+ function parseInventorySection(sourceFile, descriptor) {
172540
+ if (!descriptor.parse) {
172022
172541
  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")
172542
+ entries: [],
172543
+ found: false
172033
172544
  };
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.`);
172545
+ }
172546
+ const exportName = descriptor.parse.exportName ?? descriptor.value?.name;
172547
+ if (!exportName) {
172548
+ throw new Error("Inventory parser descriptor is missing an export name.");
172549
+ }
172550
+ const exportedArray = findExportedArrayLiteral(sourceFile, exportName);
172551
+ if (!exportedArray.found) {
172552
+ if (descriptor.parse.required) {
172553
+ throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
172040
172554
  }
172041
172555
  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")
172556
+ entries: [],
172557
+ found: false
172045
172558
  };
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.`);
172559
+ }
172560
+ if (!exportedArray.array) {
172561
+ if (descriptor.parse.required) {
172562
+ throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
172052
172563
  }
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
- });
172564
+ throw new Error(`scripts/block-config.ts must export ${exportName} as an array literal.`);
172565
+ }
172566
+ return {
172567
+ entries: parseInventoryEntries(exportedArray.array, descriptor.parse.entry),
172568
+ found: true
172569
+ };
172060
172570
  }
172061
172571
  function parseWorkspaceInventorySource(source) {
172062
172572
  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) : [],
172573
+ const parsedInventory = {
172574
+ abilities: [],
172575
+ adminViews: [],
172576
+ aiFeatures: [],
172577
+ bindingSources: [],
172578
+ blockStyles: [],
172579
+ blockTransforms: [],
172580
+ blocks: parseInventorySection(sourceFile, BLOCK_INVENTORY_SECTION).entries,
172581
+ editorPlugins: [],
172582
+ hasAbilitiesSection: false,
172583
+ hasAdminViewsSection: false,
172584
+ hasAiFeaturesSection: false,
172585
+ hasBindingSourcesSection: false,
172586
+ hasBlockStylesSection: false,
172587
+ hasBlockTransformsSection: false,
172588
+ hasEditorPluginsSection: false,
172589
+ hasPatternsSection: false,
172590
+ hasRestResourcesSection: false,
172591
+ hasVariationsSection: false,
172592
+ patterns: [],
172593
+ restResources: [],
172128
172594
  source,
172129
- variations: variationArray.array ? parseVariationEntries(variationArray.array) : []
172595
+ variations: []
172130
172596
  };
172597
+ const mutableInventory = parsedInventory;
172598
+ for (const section of INVENTORY_SECTIONS) {
172599
+ if (!section.parse) {
172600
+ continue;
172601
+ }
172602
+ const parsedSection = parseInventorySection(sourceFile, section);
172603
+ mutableInventory[section.parse.entriesKey] = parsedSection.entries;
172604
+ if (section.parse.hasSectionKey) {
172605
+ mutableInventory[section.parse.hasSectionKey] = parsedSection.found;
172606
+ }
172607
+ }
172608
+ return parsedInventory;
172131
172609
  }
172132
172610
  function readWorkspaceInventory(projectDir) {
172133
172611
  const blockConfigPath = path4.join(projectDir, "scripts", "block-config.ts");
@@ -172182,6 +172660,16 @@ function appendEntriesAtMarker(source, marker, entries) {
172182
172660
  `)}
172183
172661
  ${marker}`);
172184
172662
  }
172663
+ function appendInventorySectionEntries(source, options) {
172664
+ let nextSource = source;
172665
+ for (const section of [BLOCK_INVENTORY_SECTION, ...INVENTORY_SECTIONS]) {
172666
+ if (!section.append) {
172667
+ continue;
172668
+ }
172669
+ nextSource = appendEntriesAtMarker(nextSource, section.append.marker, options[section.append.optionKey] ?? []);
172670
+ }
172671
+ return nextSource;
172672
+ }
172185
172673
  function ensureInterfaceField(source, interfaceName, fieldName, fieldSource) {
172186
172674
  const interfacePattern = new RegExp(`(export\\s+interface\\s+${escapeRegex(interfaceName)}\\s*\\{\\r?\\n)([\\s\\S]*?)(\\r?\\n\\})`, "u");
172187
172675
  return source.replace(interfacePattern, (match, start, body, end) => {
@@ -172229,41 +172717,18 @@ function normalizeInterfaceFieldBlock(source, interfaceName, fieldName, fieldSou
172229
172717
  return `${start}${body.slice(0, fieldMatch.index)}${formattedFieldSource}${body.slice(fieldMatch.index + existingFieldSource.length)}${end}`;
172230
172718
  });
172231
172719
  }
172232
- function updateWorkspaceInventorySource(source, {
172233
- blockEntries = [],
172234
- blockStyleEntries = [],
172235
- blockTransformEntries = [],
172236
- bindingSourceEntries = [],
172237
- abilityEntries = [],
172238
- adminViewEntries = [],
172239
- aiFeatureEntries = [],
172240
- editorPluginEntries = [],
172241
- patternEntries = [],
172242
- restResourceEntries = [],
172243
- variationEntries = [],
172244
- transformSource
172245
- } = {}) {
172720
+ function updateWorkspaceInventorySource(source, options = {}) {
172246
172721
  let nextSource = ensureWorkspaceInventorySections(source);
172247
- if (transformSource) {
172248
- nextSource = transformSource(nextSource);
172722
+ if (options.transformSource) {
172723
+ nextSource = options.transformSource(nextSource);
172249
172724
  }
172250
- nextSource = appendEntriesAtMarker(nextSource, BLOCK_CONFIG_ENTRY_MARKER, blockEntries);
172251
- nextSource = appendEntriesAtMarker(nextSource, VARIATION_CONFIG_ENTRY_MARKER, variationEntries);
172252
- nextSource = appendEntriesAtMarker(nextSource, BLOCK_STYLE_CONFIG_ENTRY_MARKER, blockStyleEntries);
172253
- nextSource = appendEntriesAtMarker(nextSource, BLOCK_TRANSFORM_CONFIG_ENTRY_MARKER, blockTransformEntries);
172254
- nextSource = appendEntriesAtMarker(nextSource, PATTERN_CONFIG_ENTRY_MARKER, patternEntries);
172255
- nextSource = appendEntriesAtMarker(nextSource, BINDING_SOURCE_CONFIG_ENTRY_MARKER, bindingSourceEntries);
172256
- nextSource = appendEntriesAtMarker(nextSource, REST_RESOURCE_CONFIG_ENTRY_MARKER, restResourceEntries);
172257
- nextSource = appendEntriesAtMarker(nextSource, ABILITY_CONFIG_ENTRY_MARKER, abilityEntries);
172258
- nextSource = appendEntriesAtMarker(nextSource, AI_FEATURE_CONFIG_ENTRY_MARKER, aiFeatureEntries);
172259
- nextSource = appendEntriesAtMarker(nextSource, ADMIN_VIEW_CONFIG_ENTRY_MARKER, adminViewEntries);
172725
+ nextSource = appendInventorySectionEntries(nextSource, options);
172260
172726
  nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "attribute", "\tattribute?: string;");
172261
172727
  nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "block", "\tblock?: string;");
172262
172728
  nextSource = ensureInterfaceField(nextSource, "WorkspaceAbilityConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
172263
172729
  nextSource = normalizeInterfaceFieldBlock(nextSource, "WorkspaceAbilityConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD, ["optionalFeatureIds: string[];", "requiredFeatureIds: string[];"]);
172264
172730
  nextSource = ensureInterfaceField(nextSource, "WorkspaceAiFeatureConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
172265
172731
  nextSource = normalizeInterfaceFieldBlock(nextSource, "WorkspaceAiFeatureConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD, ["optionalFeatureIds: string[];", "requiredFeatureIds: string[];"]);
172266
- nextSource = appendEntriesAtMarker(nextSource, EDITOR_PLUGIN_CONFIG_ENTRY_MARKER, editorPluginEntries);
172267
172732
  return nextSource;
172268
172733
  }
172269
172734
  async function appendWorkspaceInventoryEntries(projectDir, options) {
@@ -172275,6 +172740,6 @@ async function appendWorkspaceInventoryEntries(projectDir, options) {
172275
172740
  }
172276
172741
  }
172277
172742
 
172278
- 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 };
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 };
172279
172744
 
172280
- //# debugId=42C4B300381ECACF64756E2164756E21
172745
+ //# debugId=17AFFAD165D90DE964756E2164756E21