wp-typia 0.20.4 → 0.21.0
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.
- package/README.md +5 -0
- package/bin/argv-walker.d.ts +19 -0
- package/bin/argv-walker.js +53 -0
- package/bin/routing-metadata.generated.d.ts +1 -1
- package/bin/routing-metadata.generated.js +38 -38
- package/bin/wp-typia.js +75 -87
- package/dist-bunli/.bunli/commands.gen.js +4940 -1246
- package/dist-bunli/{cli-68145vb5.js → cli-9x01fjna.js} +346 -41
- package/dist-bunli/{cli-add-a27wjrk4.js → cli-add-93945fc2.js} +1900 -385
- package/dist-bunli/{cli-diagnostics-db6kxv83.js → cli-diagnostics-5dvztm7q.js} +8 -2
- package/dist-bunli/{cli-doctor-31djnnxs.js → cli-doctor-zsndr5sw.js} +492 -20
- package/dist-bunli/{cli-3w3qxq9w.js → cli-hx88xwr4.js} +257 -25
- package/dist-bunli/cli-init-6xxc0snz.js +844 -0
- package/dist-bunli/{cli-2rev5hqm.js → cli-jfj54qej.js} +1 -1
- package/dist-bunli/{cli-jcd4wgam.js → cli-p95wr1q8.js} +77 -5
- package/dist-bunli/{cli-c5021kqy.js → cli-pav309dt.js} +896 -286
- package/dist-bunli/{cli-scaffold-r0yxfhbq.js → cli-scaffold-d2vtf740.js} +6 -5
- package/dist-bunli/{cli-tesygdnr.js → cli-syg9qpxw.js} +22 -1
- package/dist-bunli/cli.js +31 -117
- package/dist-bunli/{command-list-kx7q3f18.js → command-list-p452y8td.js} +561 -319
- package/dist-bunli/{migrations-1p6mbkyw.js → migrations-aj1rv3h8.js} +2 -2
- package/dist-bunli/node-cli.js +1035 -555
- package/package.json +5 -3
- package/dist-bunli/cli-init-gdyp9enw.js +0 -341
|
@@ -170911,17 +170911,6 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
170911
170911
|
} });
|
|
170912
170912
|
});
|
|
170913
170913
|
|
|
170914
|
-
// ../wp-typia-project-tools/src/runtime/cli-add-shared.ts
|
|
170915
|
-
import fs from "fs";
|
|
170916
|
-
import { promises as fsp } from "fs";
|
|
170917
|
-
import path from "path";
|
|
170918
|
-
import { parseScaffoldBlockMetadata } from "@wp-typia/block-runtime/blocks";
|
|
170919
|
-
|
|
170920
|
-
// ../wp-typia-project-tools/src/runtime/hooked-blocks.ts
|
|
170921
|
-
var HOOKED_BLOCK_POSITION_IDS = ["before", "after", "firstChild", "lastChild"];
|
|
170922
|
-
var HOOKED_BLOCK_POSITION_SET = new Set(HOOKED_BLOCK_POSITION_IDS);
|
|
170923
|
-
var HOOKED_BLOCK_ANCHOR_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/;
|
|
170924
|
-
|
|
170925
170914
|
// ../wp-typia-project-tools/src/runtime/string-case.ts
|
|
170926
170915
|
function capitalizeSegment(segment) {
|
|
170927
170916
|
return segment.charAt(0).toUpperCase() + segment.slice(1);
|
|
@@ -170942,6 +170931,17 @@ function toTitleCase(input) {
|
|
|
170942
170931
|
return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join(" ");
|
|
170943
170932
|
}
|
|
170944
170933
|
|
|
170934
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-shared.ts
|
|
170935
|
+
import fs from "fs";
|
|
170936
|
+
import { promises as fsp } from "fs";
|
|
170937
|
+
import path from "path";
|
|
170938
|
+
import { parseScaffoldBlockMetadata } from "@wp-typia/block-runtime/blocks";
|
|
170939
|
+
|
|
170940
|
+
// ../wp-typia-project-tools/src/runtime/hooked-blocks.ts
|
|
170941
|
+
var HOOKED_BLOCK_POSITION_IDS = ["before", "after", "firstChild", "lastChild"];
|
|
170942
|
+
var HOOKED_BLOCK_POSITION_SET = new Set(HOOKED_BLOCK_POSITION_IDS);
|
|
170943
|
+
var HOOKED_BLOCK_ANCHOR_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/;
|
|
170944
|
+
|
|
170945
170945
|
// ../wp-typia-project-tools/src/runtime/scaffold-identifiers.ts
|
|
170946
170946
|
var BLOCK_SLUG_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
170947
170947
|
var PHP_PREFIX_PATTERN = /^[a-z_][a-z0-9_]*$/;
|
|
@@ -171022,8 +171022,11 @@ function resolveScaffoldIdentifiers({
|
|
|
171022
171022
|
|
|
171023
171023
|
// ../wp-typia-project-tools/src/runtime/cli-add-shared.ts
|
|
171024
171024
|
var ADD_KIND_IDS = [
|
|
171025
|
+
"admin-view",
|
|
171025
171026
|
"block",
|
|
171026
171027
|
"variation",
|
|
171028
|
+
"style",
|
|
171029
|
+
"transform",
|
|
171027
171030
|
"pattern",
|
|
171028
171031
|
"binding-source",
|
|
171029
171032
|
"rest-resource",
|
|
@@ -171039,7 +171042,20 @@ var REST_RESOURCE_METHOD_IDS = [
|
|
|
171039
171042
|
"update",
|
|
171040
171043
|
"delete"
|
|
171041
171044
|
];
|
|
171042
|
-
var EDITOR_PLUGIN_SLOT_IDS = ["
|
|
171045
|
+
var EDITOR_PLUGIN_SLOT_IDS = ["sidebar", "document-setting-panel"];
|
|
171046
|
+
var EDITOR_PLUGIN_SLOT_ALIASES = {
|
|
171047
|
+
PluginDocumentSettingPanel: "document-setting-panel",
|
|
171048
|
+
PluginSidebar: "sidebar",
|
|
171049
|
+
"document-setting-panel": "document-setting-panel",
|
|
171050
|
+
sidebar: "sidebar"
|
|
171051
|
+
};
|
|
171052
|
+
function resolveEditorPluginSlotAlias(slot) {
|
|
171053
|
+
const trimmed = slot.trim();
|
|
171054
|
+
if (!Object.prototype.hasOwnProperty.call(EDITOR_PLUGIN_SLOT_ALIASES, trimmed)) {
|
|
171055
|
+
return;
|
|
171056
|
+
}
|
|
171057
|
+
return EDITOR_PLUGIN_SLOT_ALIASES[trimmed];
|
|
171058
|
+
}
|
|
171043
171059
|
var ADD_BLOCK_TEMPLATE_IDS = [
|
|
171044
171060
|
"basic",
|
|
171045
171061
|
"interactivity",
|
|
@@ -171157,11 +171173,12 @@ function assertValidHookAnchor(anchorBlockName) {
|
|
|
171157
171173
|
}
|
|
171158
171174
|
return trimmed;
|
|
171159
171175
|
}
|
|
171160
|
-
function assertValidEditorPluginSlot(slot = "
|
|
171161
|
-
|
|
171162
|
-
|
|
171176
|
+
function assertValidEditorPluginSlot(slot = "sidebar") {
|
|
171177
|
+
const alias = resolveEditorPluginSlotAlias(slot);
|
|
171178
|
+
if (alias) {
|
|
171179
|
+
return alias;
|
|
171163
171180
|
}
|
|
171164
|
-
throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}.`);
|
|
171181
|
+
throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}. Legacy aliases: PluginSidebar, PluginDocumentSettingPanel.`);
|
|
171165
171182
|
}
|
|
171166
171183
|
function readWorkspaceBlockJson(projectDir, blockSlug) {
|
|
171167
171184
|
const blockJsonPath = path.join(projectDir, "src", "blocks", blockSlug, "block.json");
|
|
@@ -171231,6 +171248,19 @@ function assertRestResourceDoesNotExist(projectDir, restResourceSlug, inventory)
|
|
|
171231
171248
|
throw new Error(`A REST resource inventory entry already exists for ${restResourceSlug}. Choose a different name.`);
|
|
171232
171249
|
}
|
|
171233
171250
|
}
|
|
171251
|
+
function assertAdminViewDoesNotExist(projectDir, adminViewSlug, inventory) {
|
|
171252
|
+
const adminViewDir = path.join(projectDir, "src", "admin-views", adminViewSlug);
|
|
171253
|
+
const adminViewPhpPath = path.join(projectDir, "inc", "admin-views", `${adminViewSlug}.php`);
|
|
171254
|
+
if (fs.existsSync(adminViewDir)) {
|
|
171255
|
+
throw new Error(`An admin view already exists at ${path.relative(projectDir, adminViewDir)}. Choose a different name.`);
|
|
171256
|
+
}
|
|
171257
|
+
if (fs.existsSync(adminViewPhpPath)) {
|
|
171258
|
+
throw new Error(`An admin view bootstrap already exists at ${path.relative(projectDir, adminViewPhpPath)}. Choose a different name.`);
|
|
171259
|
+
}
|
|
171260
|
+
if (inventory.adminViews.some((entry) => entry.slug === adminViewSlug)) {
|
|
171261
|
+
throw new Error(`An admin view inventory entry already exists for ${adminViewSlug}. Choose a different name.`);
|
|
171262
|
+
}
|
|
171263
|
+
}
|
|
171234
171264
|
function assertAbilityDoesNotExist(projectDir, abilitySlug, inventory) {
|
|
171235
171265
|
const abilityDir = path.join(projectDir, "src", "abilities", abilitySlug);
|
|
171236
171266
|
const abilityPhpPath = path.join(projectDir, "inc", "abilities", `${abilitySlug}.php`);
|
|
@@ -171268,10 +171298,13 @@ function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inventory)
|
|
|
171268
171298
|
}
|
|
171269
171299
|
function formatAddHelpText() {
|
|
171270
171300
|
return `Usage:
|
|
171271
|
-
wp-typia add
|
|
171301
|
+
wp-typia add admin-view <name> [--source <rest-resource:slug>] [--dry-run]
|
|
171302
|
+
wp-typia add block <name> [--template <${ADD_BLOCK_TEMPLATE_IDS.join("|")}>] [--external-layer-source <./path|github:owner/repo/path[#ref]|npm-package>] [--external-layer-id <layer-id>] [--inner-blocks-preset <freeform|ordered|horizontal|locked-structure>] [--alternate-render-targets <email,mjml,plain-text>] [--data-storage <post-meta|custom-table>] [--persistence-policy <authenticated|public>] [--dry-run]
|
|
171272
171303
|
wp-typia add variation <name> --block <block-slug> [--dry-run]
|
|
171304
|
+
wp-typia add style <name> --block <block-slug> [--dry-run]
|
|
171305
|
+
wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug> [--dry-run]
|
|
171273
171306
|
wp-typia add pattern <name> [--dry-run]
|
|
171274
|
-
wp-typia add binding-source <name> [--dry-run]
|
|
171307
|
+
wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--dry-run]
|
|
171275
171308
|
wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--dry-run]
|
|
171276
171309
|
wp-typia add ability <name> [--dry-run]
|
|
171277
171310
|
wp-typia add ai-feature <name> [--namespace <vendor/v1>] [--dry-run]
|
|
@@ -171281,15 +171314,19 @@ function formatAddHelpText() {
|
|
|
171281
171314
|
Notes:
|
|
171282
171315
|
\`wp-typia add\` runs only inside official ${WORKSPACE_TEMPLATE_PACKAGE} workspaces scaffolded via \`wp-typia create <project-dir> --template workspace\`.
|
|
171283
171316
|
Pass \`--dry-run\` to preview the workspace files that would change without writing them.
|
|
171317
|
+
Interactive add flows let you choose a template when \`--template\` is omitted; non-interactive runs default to \`basic\`.
|
|
171318
|
+
\`add admin-view\` scaffolds an opt-in DataViews-powered WordPress admin screen under \`src/admin-views/\`; pass \`--source rest-resource:<slug>\` to reuse a list-capable REST resource.
|
|
171284
171319
|
\`query-loop\` is a create-time scaffold family. Use \`wp-typia create <project-dir> --template query-loop\` instead of \`wp-typia add block\`.
|
|
171285
171320
|
\`add variation\` targets an existing block slug from \`scripts/block-config.ts\`.
|
|
171321
|
+
\`add style\` registers a Block Styles option for an existing generated block.
|
|
171322
|
+
\`add transform\` adds a block-to-block transform into an existing generated block.
|
|
171286
171323
|
\`add pattern\` scaffolds a namespaced PHP pattern shell under \`src/patterns/\`.
|
|
171287
|
-
\`add binding-source\` scaffolds shared PHP and editor registration under \`src/bindings
|
|
171324
|
+
\`add binding-source\` scaffolds shared PHP and editor registration under \`src/bindings/\`; pass \`--block\` and \`--attribute\` together to declare an end-to-end bindable attribute on an existing generated block.
|
|
171288
171325
|
\`add rest-resource\` scaffolds plugin-level TypeScript REST contracts under \`src/rest/\` and PHP route glue under \`inc/rest/\`.
|
|
171289
171326
|
\`add ability\` scaffolds typed workflow abilities under \`src/abilities/\` and server registration under \`inc/abilities/\`.
|
|
171290
171327
|
\`add ai-feature\` scaffolds server-owned AI feature endpoints under \`src/ai-features/\` and PHP route glue under \`inc/ai-features/\`.
|
|
171291
171328
|
\`add hooked-block\` patches an existing workspace block's \`block.json\` \`blockHooks\` metadata.
|
|
171292
|
-
\`add editor-plugin\` scaffolds a document-level editor extension under \`src/editor-plugins
|
|
171329
|
+
\`add editor-plugin\` scaffolds a document-level editor extension under \`src/editor-plugins/\`; legacy aliases \`PluginSidebar\` and \`PluginDocumentSettingPanel\` resolve to \`sidebar\` and \`document-setting-panel\`.`;
|
|
171293
171330
|
}
|
|
171294
171331
|
|
|
171295
171332
|
// ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
|
|
@@ -171297,13 +171334,79 @@ var import_typescript = __toESM(require_typescript(), 1);
|
|
|
171297
171334
|
import fs2 from "fs";
|
|
171298
171335
|
import path2 from "path";
|
|
171299
171336
|
import { readFile, writeFile } from "fs/promises";
|
|
171337
|
+
|
|
171338
|
+
// ../wp-typia-project-tools/src/runtime/php-utils.ts
|
|
171339
|
+
function escapeRegex(value) {
|
|
171340
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
171341
|
+
}
|
|
171342
|
+
function quotePhpString(value) {
|
|
171343
|
+
return `'${value.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
|
|
171344
|
+
}
|
|
171345
|
+
function hasPhpFunctionDefinition(source, functionName) {
|
|
171346
|
+
return new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\(`, "u").test(source);
|
|
171347
|
+
}
|
|
171348
|
+
function findPhpFunctionRange(source, functionName, options = {}) {
|
|
171349
|
+
const signaturePattern = new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\([^)]*\\)\\s*(?::\\s*[^{};]+)?\\s*\\{`, "u");
|
|
171350
|
+
const signatureMatch = signaturePattern.exec(source);
|
|
171351
|
+
if (!signatureMatch) {
|
|
171352
|
+
return null;
|
|
171353
|
+
}
|
|
171354
|
+
const functionStart = signatureMatch.index;
|
|
171355
|
+
const openBraceOffset = signatureMatch[0].lastIndexOf("{");
|
|
171356
|
+
if (openBraceOffset === -1) {
|
|
171357
|
+
return null;
|
|
171358
|
+
}
|
|
171359
|
+
const openBraceIndex = functionStart + openBraceOffset;
|
|
171360
|
+
let depth = 0;
|
|
171361
|
+
for (let index = openBraceIndex;index < source.length; index += 1) {
|
|
171362
|
+
const character = source[index];
|
|
171363
|
+
if (character === "{") {
|
|
171364
|
+
depth += 1;
|
|
171365
|
+
continue;
|
|
171366
|
+
}
|
|
171367
|
+
if (character !== "}") {
|
|
171368
|
+
continue;
|
|
171369
|
+
}
|
|
171370
|
+
depth -= 1;
|
|
171371
|
+
if (depth === 0) {
|
|
171372
|
+
let end = index + 1;
|
|
171373
|
+
if (options.includeTrailingNewlines ?? true) {
|
|
171374
|
+
while (end < source.length && /[\r\n]/u.test(source[end] ?? "")) {
|
|
171375
|
+
end += 1;
|
|
171376
|
+
}
|
|
171377
|
+
}
|
|
171378
|
+
return {
|
|
171379
|
+
end,
|
|
171380
|
+
source: source.slice(functionStart, end),
|
|
171381
|
+
start: functionStart
|
|
171382
|
+
};
|
|
171383
|
+
}
|
|
171384
|
+
}
|
|
171385
|
+
return null;
|
|
171386
|
+
}
|
|
171387
|
+
function replacePhpFunctionDefinition(source, functionName, replacement, options = {}) {
|
|
171388
|
+
const functionRange = findPhpFunctionRange(source, functionName, options);
|
|
171389
|
+
if (!functionRange) {
|
|
171390
|
+
return null;
|
|
171391
|
+
}
|
|
171392
|
+
return [
|
|
171393
|
+
source.slice(0, functionRange.start),
|
|
171394
|
+
options.trimReplacementStart ? replacement.trimStart() : replacement,
|
|
171395
|
+
source.slice(functionRange.end)
|
|
171396
|
+
].join("");
|
|
171397
|
+
}
|
|
171398
|
+
|
|
171399
|
+
// ../wp-typia-project-tools/src/runtime/workspace-inventory.ts
|
|
171300
171400
|
var BLOCK_CONFIG_ENTRY_MARKER = "\t// wp-typia add block entries";
|
|
171301
171401
|
var VARIATION_CONFIG_ENTRY_MARKER = "\t// wp-typia add variation entries";
|
|
171402
|
+
var BLOCK_STYLE_CONFIG_ENTRY_MARKER = "\t// wp-typia add style entries";
|
|
171403
|
+
var BLOCK_TRANSFORM_CONFIG_ENTRY_MARKER = "\t// wp-typia add transform entries";
|
|
171302
171404
|
var PATTERN_CONFIG_ENTRY_MARKER = "\t// wp-typia add pattern entries";
|
|
171303
171405
|
var BINDING_SOURCE_CONFIG_ENTRY_MARKER = "\t// wp-typia add binding-source entries";
|
|
171304
171406
|
var REST_RESOURCE_CONFIG_ENTRY_MARKER = "\t// wp-typia add rest-resource entries";
|
|
171305
171407
|
var ABILITY_CONFIG_ENTRY_MARKER = "\t// wp-typia add ability entries";
|
|
171306
171408
|
var AI_FEATURE_CONFIG_ENTRY_MARKER = "\t// wp-typia add ai-feature entries";
|
|
171409
|
+
var ADMIN_VIEW_CONFIG_ENTRY_MARKER = "\t// wp-typia add admin-view entries";
|
|
171307
171410
|
var EDITOR_PLUGIN_CONFIG_ENTRY_MARKER = "\t// wp-typia add editor-plugin entries";
|
|
171308
171411
|
var VARIATIONS_INTERFACE_SECTION = `
|
|
171309
171412
|
|
|
@@ -171319,6 +171422,36 @@ export const VARIATIONS: WorkspaceVariationConfig[] = [
|
|
|
171319
171422
|
// wp-typia add variation entries
|
|
171320
171423
|
];
|
|
171321
171424
|
`;
|
|
171425
|
+
var BLOCK_STYLES_INTERFACE_SECTION = `
|
|
171426
|
+
|
|
171427
|
+
export interface WorkspaceBlockStyleConfig {
|
|
171428
|
+
block: string;
|
|
171429
|
+
file: string;
|
|
171430
|
+
slug: string;
|
|
171431
|
+
}
|
|
171432
|
+
`;
|
|
171433
|
+
var BLOCK_STYLES_CONST_SECTION = `
|
|
171434
|
+
|
|
171435
|
+
export const BLOCK_STYLES: WorkspaceBlockStyleConfig[] = [
|
|
171436
|
+
// wp-typia add style entries
|
|
171437
|
+
];
|
|
171438
|
+
`;
|
|
171439
|
+
var BLOCK_TRANSFORMS_INTERFACE_SECTION = `
|
|
171440
|
+
|
|
171441
|
+
export interface WorkspaceBlockTransformConfig {
|
|
171442
|
+
block: string;
|
|
171443
|
+
file: string;
|
|
171444
|
+
from: string;
|
|
171445
|
+
slug: string;
|
|
171446
|
+
to: string;
|
|
171447
|
+
}
|
|
171448
|
+
`;
|
|
171449
|
+
var BLOCK_TRANSFORMS_CONST_SECTION = `
|
|
171450
|
+
|
|
171451
|
+
export const BLOCK_TRANSFORMS: WorkspaceBlockTransformConfig[] = [
|
|
171452
|
+
// wp-typia add transform entries
|
|
171453
|
+
];
|
|
171454
|
+
`;
|
|
171322
171455
|
var PATTERNS_INTERFACE_SECTION = `
|
|
171323
171456
|
|
|
171324
171457
|
export interface WorkspacePatternConfig {
|
|
@@ -171335,6 +171468,8 @@ export const PATTERNS: WorkspacePatternConfig[] = [
|
|
|
171335
171468
|
var BINDING_SOURCES_INTERFACE_SECTION = `
|
|
171336
171469
|
|
|
171337
171470
|
export interface WorkspaceBindingSourceConfig {
|
|
171471
|
+
attribute?: string;
|
|
171472
|
+
block?: string;
|
|
171338
171473
|
editorFile: string;
|
|
171339
171474
|
serverFile: string;
|
|
171340
171475
|
slug: string;
|
|
@@ -171426,6 +171561,21 @@ export const AI_FEATURES: WorkspaceAiFeatureConfig[] = [
|
|
|
171426
171561
|
// wp-typia add ai-feature entries
|
|
171427
171562
|
];
|
|
171428
171563
|
`;
|
|
171564
|
+
var ADMIN_VIEWS_INTERFACE_SECTION = `
|
|
171565
|
+
|
|
171566
|
+
export interface WorkspaceAdminViewConfig {
|
|
171567
|
+
file: string;
|
|
171568
|
+
phpFile: string;
|
|
171569
|
+
slug: string;
|
|
171570
|
+
source?: string;
|
|
171571
|
+
}
|
|
171572
|
+
`;
|
|
171573
|
+
var ADMIN_VIEWS_CONST_SECTION = `
|
|
171574
|
+
|
|
171575
|
+
export const ADMIN_VIEWS: WorkspaceAdminViewConfig[] = [
|
|
171576
|
+
// wp-typia add admin-view entries
|
|
171577
|
+
];
|
|
171578
|
+
`;
|
|
171429
171579
|
var EDITOR_PLUGINS_INTERFACE_SECTION = `
|
|
171430
171580
|
|
|
171431
171581
|
export interface WorkspaceEditorPluginConfig {
|
|
@@ -171545,6 +171695,32 @@ function parseVariationEntries(arrayLiteral) {
|
|
|
171545
171695
|
};
|
|
171546
171696
|
});
|
|
171547
171697
|
}
|
|
171698
|
+
function parseBlockStyleEntries(arrayLiteral) {
|
|
171699
|
+
return arrayLiteral.elements.map((element, elementIndex) => {
|
|
171700
|
+
if (!import_typescript.default.isObjectLiteralExpression(element)) {
|
|
171701
|
+
throw new Error(`BLOCK_STYLES[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
|
|
171702
|
+
}
|
|
171703
|
+
return {
|
|
171704
|
+
block: getRequiredStringProperty("BLOCK_STYLES", elementIndex, element, "block"),
|
|
171705
|
+
file: getRequiredStringProperty("BLOCK_STYLES", elementIndex, element, "file"),
|
|
171706
|
+
slug: getRequiredStringProperty("BLOCK_STYLES", elementIndex, element, "slug")
|
|
171707
|
+
};
|
|
171708
|
+
});
|
|
171709
|
+
}
|
|
171710
|
+
function parseBlockTransformEntries(arrayLiteral) {
|
|
171711
|
+
return arrayLiteral.elements.map((element, elementIndex) => {
|
|
171712
|
+
if (!import_typescript.default.isObjectLiteralExpression(element)) {
|
|
171713
|
+
throw new Error(`BLOCK_TRANSFORMS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
|
|
171714
|
+
}
|
|
171715
|
+
return {
|
|
171716
|
+
block: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "block"),
|
|
171717
|
+
file: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "file"),
|
|
171718
|
+
from: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "from"),
|
|
171719
|
+
slug: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "slug"),
|
|
171720
|
+
to: getRequiredStringProperty("BLOCK_TRANSFORMS", elementIndex, element, "to")
|
|
171721
|
+
};
|
|
171722
|
+
});
|
|
171723
|
+
}
|
|
171548
171724
|
function parsePatternEntries(arrayLiteral) {
|
|
171549
171725
|
return arrayLiteral.elements.map((element, elementIndex) => {
|
|
171550
171726
|
if (!import_typescript.default.isObjectLiteralExpression(element)) {
|
|
@@ -171562,6 +171738,8 @@ function parseBindingSourceEntries(arrayLiteral) {
|
|
|
171562
171738
|
throw new Error(`BINDING_SOURCES[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
|
|
171563
171739
|
}
|
|
171564
171740
|
return {
|
|
171741
|
+
attribute: getOptionalStringProperty("BINDING_SOURCES", elementIndex, element, "attribute"),
|
|
171742
|
+
block: getOptionalStringProperty("BINDING_SOURCES", elementIndex, element, "block"),
|
|
171565
171743
|
editorFile: getRequiredStringProperty("BINDING_SOURCES", elementIndex, element, "editorFile"),
|
|
171566
171744
|
serverFile: getRequiredStringProperty("BINDING_SOURCES", elementIndex, element, "serverFile"),
|
|
171567
171745
|
slug: getRequiredStringProperty("BINDING_SOURCES", elementIndex, element, "slug")
|
|
@@ -171642,6 +171820,19 @@ function parseEditorPluginEntries(arrayLiteral) {
|
|
|
171642
171820
|
};
|
|
171643
171821
|
});
|
|
171644
171822
|
}
|
|
171823
|
+
function parseAdminViewEntries(arrayLiteral) {
|
|
171824
|
+
return arrayLiteral.elements.map((element, elementIndex) => {
|
|
171825
|
+
if (!import_typescript.default.isObjectLiteralExpression(element)) {
|
|
171826
|
+
throw new Error(`ADMIN_VIEWS[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
|
|
171827
|
+
}
|
|
171828
|
+
return {
|
|
171829
|
+
file: getRequiredStringProperty("ADMIN_VIEWS", elementIndex, element, "file"),
|
|
171830
|
+
phpFile: getRequiredStringProperty("ADMIN_VIEWS", elementIndex, element, "phpFile"),
|
|
171831
|
+
slug: getRequiredStringProperty("ADMIN_VIEWS", elementIndex, element, "slug"),
|
|
171832
|
+
source: getOptionalStringProperty("ADMIN_VIEWS", elementIndex, element, "source")
|
|
171833
|
+
};
|
|
171834
|
+
});
|
|
171835
|
+
}
|
|
171645
171836
|
function parseWorkspaceInventorySource(source) {
|
|
171646
171837
|
const sourceFile = import_typescript.default.createSourceFile("block-config.ts", source, import_typescript.default.ScriptTarget.Latest, true, import_typescript.default.ScriptKind.TS);
|
|
171647
171838
|
const blockArray = findExportedArrayLiteral(sourceFile, "BLOCKS");
|
|
@@ -171649,15 +171840,24 @@ function parseWorkspaceInventorySource(source) {
|
|
|
171649
171840
|
throw new Error("scripts/block-config.ts must export a BLOCKS array.");
|
|
171650
171841
|
}
|
|
171651
171842
|
const variationArray = findExportedArrayLiteral(sourceFile, "VARIATIONS");
|
|
171843
|
+
const blockStyleArray = findExportedArrayLiteral(sourceFile, "BLOCK_STYLES");
|
|
171844
|
+
const blockTransformArray = findExportedArrayLiteral(sourceFile, "BLOCK_TRANSFORMS");
|
|
171652
171845
|
const patternArray = findExportedArrayLiteral(sourceFile, "PATTERNS");
|
|
171653
171846
|
const bindingSourceArray = findExportedArrayLiteral(sourceFile, "BINDING_SOURCES");
|
|
171654
171847
|
const restResourceArray = findExportedArrayLiteral(sourceFile, "REST_RESOURCES");
|
|
171655
171848
|
const abilityArray = findExportedArrayLiteral(sourceFile, "ABILITIES");
|
|
171656
171849
|
const aiFeatureArray = findExportedArrayLiteral(sourceFile, "AI_FEATURES");
|
|
171850
|
+
const adminViewArray = findExportedArrayLiteral(sourceFile, "ADMIN_VIEWS");
|
|
171657
171851
|
const editorPluginArray = findExportedArrayLiteral(sourceFile, "EDITOR_PLUGINS");
|
|
171658
171852
|
if (variationArray.found && !variationArray.array) {
|
|
171659
171853
|
throw new Error("scripts/block-config.ts must export VARIATIONS as an array literal.");
|
|
171660
171854
|
}
|
|
171855
|
+
if (blockStyleArray.found && !blockStyleArray.array) {
|
|
171856
|
+
throw new Error("scripts/block-config.ts must export BLOCK_STYLES as an array literal.");
|
|
171857
|
+
}
|
|
171858
|
+
if (blockTransformArray.found && !blockTransformArray.array) {
|
|
171859
|
+
throw new Error("scripts/block-config.ts must export BLOCK_TRANSFORMS as an array literal.");
|
|
171860
|
+
}
|
|
171661
171861
|
if (patternArray.found && !patternArray.array) {
|
|
171662
171862
|
throw new Error("scripts/block-config.ts must export PATTERNS as an array literal.");
|
|
171663
171863
|
}
|
|
@@ -171673,17 +171873,26 @@ function parseWorkspaceInventorySource(source) {
|
|
|
171673
171873
|
if (aiFeatureArray.found && !aiFeatureArray.array) {
|
|
171674
171874
|
throw new Error("scripts/block-config.ts must export AI_FEATURES as an array literal.");
|
|
171675
171875
|
}
|
|
171876
|
+
if (adminViewArray.found && !adminViewArray.array) {
|
|
171877
|
+
throw new Error("scripts/block-config.ts must export ADMIN_VIEWS as an array literal.");
|
|
171878
|
+
}
|
|
171676
171879
|
if (editorPluginArray.found && !editorPluginArray.array) {
|
|
171677
171880
|
throw new Error("scripts/block-config.ts must export EDITOR_PLUGINS as an array literal.");
|
|
171678
171881
|
}
|
|
171679
171882
|
return {
|
|
171680
171883
|
abilities: abilityArray.array ? parseAbilityEntries(abilityArray.array) : [],
|
|
171884
|
+
adminViews: adminViewArray.array ? parseAdminViewEntries(adminViewArray.array) : [],
|
|
171681
171885
|
aiFeatures: aiFeatureArray.array ? parseAiFeatureEntries(aiFeatureArray.array) : [],
|
|
171682
171886
|
bindingSources: bindingSourceArray.array ? parseBindingSourceEntries(bindingSourceArray.array) : [],
|
|
171887
|
+
blockStyles: blockStyleArray.array ? parseBlockStyleEntries(blockStyleArray.array) : [],
|
|
171888
|
+
blockTransforms: blockTransformArray.array ? parseBlockTransformEntries(blockTransformArray.array) : [],
|
|
171683
171889
|
blocks: parseBlockEntries(blockArray.array),
|
|
171684
171890
|
hasAbilitiesSection: abilityArray.found,
|
|
171891
|
+
hasAdminViewsSection: adminViewArray.found,
|
|
171685
171892
|
hasAiFeaturesSection: aiFeatureArray.found,
|
|
171686
171893
|
hasBindingSourcesSection: bindingSourceArray.found,
|
|
171894
|
+
hasBlockStylesSection: blockStyleArray.found,
|
|
171895
|
+
hasBlockTransformsSection: blockTransformArray.found,
|
|
171687
171896
|
hasEditorPluginsSection: editorPluginArray.found,
|
|
171688
171897
|
hasPatternsSection: patternArray.found,
|
|
171689
171898
|
hasRestResourcesSection: restResourceArray.found,
|
|
@@ -171726,6 +171935,18 @@ function ensureWorkspaceInventorySections(source) {
|
|
|
171726
171935
|
if (!/export\s+const\s+VARIATIONS\b/u.test(nextSource)) {
|
|
171727
171936
|
nextSource += VARIATIONS_CONST_SECTION;
|
|
171728
171937
|
}
|
|
171938
|
+
if (!/export\s+interface\s+WorkspaceBlockStyleConfig\b/u.test(nextSource)) {
|
|
171939
|
+
nextSource += BLOCK_STYLES_INTERFACE_SECTION;
|
|
171940
|
+
}
|
|
171941
|
+
if (!/export\s+const\s+BLOCK_STYLES\b/u.test(nextSource)) {
|
|
171942
|
+
nextSource += BLOCK_STYLES_CONST_SECTION;
|
|
171943
|
+
}
|
|
171944
|
+
if (!/export\s+interface\s+WorkspaceBlockTransformConfig\b/u.test(nextSource)) {
|
|
171945
|
+
nextSource += BLOCK_TRANSFORMS_INTERFACE_SECTION;
|
|
171946
|
+
}
|
|
171947
|
+
if (!/export\s+const\s+BLOCK_TRANSFORMS\b/u.test(nextSource)) {
|
|
171948
|
+
nextSource += BLOCK_TRANSFORMS_CONST_SECTION;
|
|
171949
|
+
}
|
|
171729
171950
|
if (!/export\s+interface\s+WorkspacePatternConfig\b/u.test(nextSource)) {
|
|
171730
171951
|
nextSource += PATTERNS_INTERFACE_SECTION;
|
|
171731
171952
|
}
|
|
@@ -171756,6 +171977,12 @@ function ensureWorkspaceInventorySections(source) {
|
|
|
171756
171977
|
if (!/export\s+const\s+AI_FEATURES\b/u.test(nextSource)) {
|
|
171757
171978
|
nextSource += AI_FEATURES_CONST_SECTION;
|
|
171758
171979
|
}
|
|
171980
|
+
if (!/export\s+interface\s+WorkspaceAdminViewConfig\b/u.test(nextSource)) {
|
|
171981
|
+
nextSource += ADMIN_VIEWS_INTERFACE_SECTION;
|
|
171982
|
+
}
|
|
171983
|
+
if (!/export\s+const\s+ADMIN_VIEWS\b/u.test(nextSource)) {
|
|
171984
|
+
nextSource += ADMIN_VIEWS_CONST_SECTION;
|
|
171985
|
+
}
|
|
171759
171986
|
if (!/export\s+interface\s+WorkspaceEditorPluginConfig\b/u.test(nextSource)) {
|
|
171760
171987
|
nextSource += EDITOR_PLUGINS_INTERFACE_SECTION;
|
|
171761
171988
|
}
|
|
@@ -171776,9 +172003,6 @@ function appendEntriesAtMarker(source, marker, entries) {
|
|
|
171776
172003
|
`)}
|
|
171777
172004
|
${marker}`);
|
|
171778
172005
|
}
|
|
171779
|
-
function escapeRegex(value) {
|
|
171780
|
-
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
171781
|
-
}
|
|
171782
172006
|
function ensureInterfaceField(source, interfaceName, fieldName, fieldSource) {
|
|
171783
172007
|
const interfacePattern = new RegExp(`(export\\s+interface\\s+${escapeRegex(interfaceName)}\\s*\\{\\r?\\n)([\\s\\S]*?)(\\r?\\n\\})`, "u");
|
|
171784
172008
|
return source.replace(interfacePattern, (match, start, body, end) => {
|
|
@@ -171807,8 +172031,11 @@ function ensureInterfaceField(source, interfaceName, fieldName, fieldSource) {
|
|
|
171807
172031
|
}
|
|
171808
172032
|
function updateWorkspaceInventorySource(source, {
|
|
171809
172033
|
blockEntries = [],
|
|
172034
|
+
blockStyleEntries = [],
|
|
172035
|
+
blockTransformEntries = [],
|
|
171810
172036
|
bindingSourceEntries = [],
|
|
171811
172037
|
abilityEntries = [],
|
|
172038
|
+
adminViewEntries = [],
|
|
171812
172039
|
aiFeatureEntries = [],
|
|
171813
172040
|
editorPluginEntries = [],
|
|
171814
172041
|
patternEntries = [],
|
|
@@ -171822,11 +172049,16 @@ function updateWorkspaceInventorySource(source, {
|
|
|
171822
172049
|
}
|
|
171823
172050
|
nextSource = appendEntriesAtMarker(nextSource, BLOCK_CONFIG_ENTRY_MARKER, blockEntries);
|
|
171824
172051
|
nextSource = appendEntriesAtMarker(nextSource, VARIATION_CONFIG_ENTRY_MARKER, variationEntries);
|
|
172052
|
+
nextSource = appendEntriesAtMarker(nextSource, BLOCK_STYLE_CONFIG_ENTRY_MARKER, blockStyleEntries);
|
|
172053
|
+
nextSource = appendEntriesAtMarker(nextSource, BLOCK_TRANSFORM_CONFIG_ENTRY_MARKER, blockTransformEntries);
|
|
171825
172054
|
nextSource = appendEntriesAtMarker(nextSource, PATTERN_CONFIG_ENTRY_MARKER, patternEntries);
|
|
171826
172055
|
nextSource = appendEntriesAtMarker(nextSource, BINDING_SOURCE_CONFIG_ENTRY_MARKER, bindingSourceEntries);
|
|
171827
172056
|
nextSource = appendEntriesAtMarker(nextSource, REST_RESOURCE_CONFIG_ENTRY_MARKER, restResourceEntries);
|
|
171828
172057
|
nextSource = appendEntriesAtMarker(nextSource, ABILITY_CONFIG_ENTRY_MARKER, abilityEntries);
|
|
171829
172058
|
nextSource = appendEntriesAtMarker(nextSource, AI_FEATURE_CONFIG_ENTRY_MARKER, aiFeatureEntries);
|
|
172059
|
+
nextSource = appendEntriesAtMarker(nextSource, ADMIN_VIEW_CONFIG_ENTRY_MARKER, adminViewEntries);
|
|
172060
|
+
nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "attribute", "\tattribute?: string;");
|
|
172061
|
+
nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "block", "\tblock?: string;");
|
|
171830
172062
|
nextSource = ensureInterfaceField(nextSource, "WorkspaceAbilityConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
|
|
171831
172063
|
nextSource = ensureInterfaceField(nextSource, "WorkspaceAiFeatureConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
|
|
171832
172064
|
nextSource = appendEntriesAtMarker(nextSource, EDITOR_PLUGIN_CONFIG_ENTRY_MARKER, editorPluginEntries);
|
|
@@ -171841,6 +172073,6 @@ async function appendWorkspaceInventoryEntries(projectDir, options) {
|
|
|
171841
172073
|
}
|
|
171842
172074
|
}
|
|
171843
172075
|
|
|
171844
|
-
export { HOOKED_BLOCK_POSITION_SET, HOOKED_BLOCK_ANCHOR_PATTERN, toKebabCase, toSnakeCase, toPascalCase, toSegmentPascalCase, toTitleCase, validateBlockSlug, validateNamespace, normalizeBlockSlug, resolveNonEmptyNormalizedBlockSlug, buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, ADD_KIND_IDS, REST_RESOURCE_METHOD_IDS, EDITOR_PLUGIN_SLOT_IDS, ADD_BLOCK_TEMPLATE_IDS, REST_RESOURCE_NAMESPACE_PATTERN, assertValidGeneratedSlug, resolveRestResourceNamespace, assertValidRestResourceMethods, assertValidHookedBlockPosition, getWorkspaceBootstrapPath, buildWorkspacePhpPrefix, isAddBlockTemplateId, quoteTsString, patchFile, readOptionalFile, snapshotWorkspaceFiles, rollbackWorkspaceMutation, resolveWorkspaceBlock, assertValidHookAnchor, assertValidEditorPluginSlot, readWorkspaceBlockJson, getMutableBlockHooks, assertVariationDoesNotExist, assertPatternDoesNotExist, assertBindingSourceDoesNotExist, assertRestResourceDoesNotExist, assertAbilityDoesNotExist, assertAiFeatureDoesNotExist, assertEditorPluginDoesNotExist, formatAddHelpText, readWorkspaceInventory, getWorkspaceBlockSelectOptions, appendWorkspaceInventoryEntries };
|
|
172076
|
+
export { HOOKED_BLOCK_POSITION_SET, HOOKED_BLOCK_ANCHOR_PATTERN, toKebabCase, toSnakeCase, toPascalCase, 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, REST_RESOURCE_NAMESPACE_PATTERN, assertValidGeneratedSlug, resolveRestResourceNamespace, assertValidRestResourceMethods, assertValidHookedBlockPosition, getWorkspaceBootstrapPath, buildWorkspacePhpPrefix, isAddBlockTemplateId, quoteTsString, patchFile, readOptionalFile, snapshotWorkspaceFiles, rollbackWorkspaceMutation, resolveWorkspaceBlock, assertValidHookAnchor, assertValidEditorPluginSlot, readWorkspaceBlockJson, getMutableBlockHooks, assertVariationDoesNotExist, assertPatternDoesNotExist, assertBindingSourceDoesNotExist, assertRestResourceDoesNotExist, assertAdminViewDoesNotExist, assertAbilityDoesNotExist, assertAiFeatureDoesNotExist, assertEditorPluginDoesNotExist, formatAddHelpText, require_typescript, escapeRegex, quotePhpString, hasPhpFunctionDefinition, findPhpFunctionRange, replacePhpFunctionDefinition, readWorkspaceInventory, getWorkspaceBlockSelectOptions, updateWorkspaceInventorySource, appendWorkspaceInventoryEntries };
|
|
171845
172077
|
|
|
171846
|
-
//# debugId=
|
|
172078
|
+
//# debugId=642A58A7D4B95C5964756E2164756E21
|