wp-typia 0.16.15 → 0.17.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 CHANGED
@@ -5,6 +5,7 @@ Canonical CLI package for `wp-typia`.
5
5
  Use this package for new installs:
6
6
 
7
7
  - `npx wp-typia create my-block`
8
+ - `npx wp-typia create my-books --template query-loop --query-post-type book`
8
9
  - `bunx wp-typia create my-block`
9
10
  - `npx wp-typia create my-plugin --template @wp-typia/create-workspace-template`
10
11
  - `wp-typia add block counter-card --template basic`
@@ -211121,6 +211121,10 @@ var init_template_defaults = __esm(() => {
211121
211121
  compound: Object.freeze({
211122
211122
  category: "widgets",
211123
211123
  icon: "screenoptions"
211124
+ }),
211125
+ "query-loop": Object.freeze({
211126
+ category: "widgets",
211127
+ icon: "query-pagination"
211124
211128
  })
211125
211129
  });
211126
211130
  COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS = Object.freeze({
@@ -211192,7 +211196,13 @@ var init_template_registry = __esm(() => {
211192
211196
  SHARED_WORKSPACE_TEMPLATE_ROOT = path25.join(SHARED_TEMPLATE_ROOT, "workspace");
211193
211197
  SHARED_TEST_PRESET_TEMPLATE_ROOT = path25.join(SHARED_PRESET_TEMPLATE_ROOT, "test-preset");
211194
211198
  SHARED_WP_ENV_PRESET_TEMPLATE_ROOT = path25.join(SHARED_PRESET_TEMPLATE_ROOT, "wp-env");
211195
- BUILTIN_TEMPLATE_IDS = ["basic", "interactivity", "persistence", "compound"];
211199
+ BUILTIN_TEMPLATE_IDS = [
211200
+ "basic",
211201
+ "interactivity",
211202
+ "persistence",
211203
+ "compound",
211204
+ "query-loop"
211205
+ ];
211196
211206
  TEMPLATE_REGISTRY = Object.freeze([
211197
211207
  {
211198
211208
  id: "basic",
@@ -211222,6 +211232,13 @@ var init_template_registry = __esm(() => {
211222
211232
  features: ["InnerBlocks", "Hidden child blocks", "Optional persistence layer"],
211223
211233
  templateDir: path25.join(TEMPLATE_ROOT, "compound")
211224
211234
  },
211235
+ {
211236
+ id: "query-loop",
211237
+ description: "A Query Loop block variation scaffold with stable namespace-based identity, inline starter layout, connected pattern presets, custom query seams, and runtime parity hooks",
211238
+ defaultCategory: getBuiltInTemplateMetadataDefaults("query-loop").category,
211239
+ features: ["core/query variation", "Default innerBlocks", "Connected patterns", "Custom query hooks", "Runtime parity hooks", "Allowed controls"],
211240
+ templateDir: path25.join(TEMPLATE_ROOT, "query-loop")
211241
+ },
211225
211242
  {
211226
211243
  id: OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE,
211227
211244
  description: "The official empty workspace template that powers `wp-typia add ...` workflows",
@@ -211867,6 +211884,9 @@ import path27 from "path";
211867
211884
  function templateHasPersistenceSync(templateId, compoundPersistenceEnabled) {
211868
211885
  return templateId === "persistence" || templateId === "compound" && compoundPersistenceEnabled;
211869
211886
  }
211887
+ function templateSupportsGeneratedSyncWatchers(templateId) {
211888
+ return templateId === "basic" || templateId === "interactivity" || templateId === "persistence" || templateId === "compound";
211889
+ }
211870
211890
  function getWatchSyncTypesScript(packageManager, templateId) {
211871
211891
  if (templateId === "compound") {
211872
211892
  return `chokidar "src/blocks/**/types.ts" "scripts/block-config.ts" --debounce 200 -c "${formatRunScript2(packageManager, "sync-types")}"`;
@@ -211943,11 +211963,14 @@ async function applyGeneratedProjectDxPackageJson({
211943
211963
  withWpEnv = false
211944
211964
  }) {
211945
211965
  const hasPersistenceSync = templateHasPersistenceSync(templateId, compoundPersistenceEnabled);
211966
+ const supportsGeneratedSyncWatchers = templateSupportsGeneratedSyncWatchers(templateId);
211946
211967
  await mutatePackageJson(projectDir, (packageJson) => {
211947
211968
  packageJson.devDependencies = {
211948
211969
  ...packageJson.devDependencies ?? {},
211949
- "chokidar-cli": "^3.0.0",
211950
- concurrently: "^9.0.1"
211970
+ ...supportsGeneratedSyncWatchers ? {
211971
+ "chokidar-cli": "^3.0.0",
211972
+ concurrently: "^9.0.1"
211973
+ } : {}
211951
211974
  };
211952
211975
  if (withWpEnv || withTestPreset) {
211953
211976
  packageJson.devDependencies["@wordpress/env"] = "^11.2.0";
@@ -211958,12 +211981,16 @@ async function applyGeneratedProjectDxPackageJson({
211958
211981
  const scripts = {
211959
211982
  ...packageJson.scripts ?? {}
211960
211983
  };
211961
- scripts["start:editor"] = "wp-scripts start --experimental-modules";
211962
- scripts["watch:sync-types"] = getWatchSyncTypesScript(packageManager, templateId);
211984
+ if (supportsGeneratedSyncWatchers) {
211985
+ scripts["start:editor"] = "wp-scripts start --experimental-modules";
211986
+ scripts["watch:sync-types"] = getWatchSyncTypesScript(packageManager, templateId);
211987
+ }
211963
211988
  if (hasPersistenceSync) {
211964
211989
  scripts["watch:sync-rest"] = getWatchSyncRestScript(packageManager, templateId);
211965
211990
  }
211966
- scripts.dev = getDevScript(packageManager, compoundPersistenceEnabled, templateId);
211991
+ if (supportsGeneratedSyncWatchers) {
211992
+ scripts.dev = getDevScript(packageManager, compoundPersistenceEnabled, templateId);
211993
+ }
211967
211994
  if (withWpEnv) {
211968
211995
  scripts["wp-env:start"] = "wp-env start";
211969
211996
  scripts["wp-env:stop"] = "wp-env stop";
@@ -211980,7 +212007,7 @@ async function applyGeneratedProjectDxPackageJson({
211980
212007
  });
211981
212008
  }
211982
212009
  function getPrimaryDevelopmentScript(templateId) {
211983
- return templateId === "basic" || templateId === "interactivity" || templateId === "persistence" || templateId === "compound" ? "dev" : "start";
212010
+ return templateSupportsGeneratedSyncWatchers(templateId) ? "dev" : "start";
211984
212011
  }
211985
212012
  var init_local_dev_presets = __esm(() => {
211986
212013
  init_package_managers();
@@ -212265,6 +212292,9 @@ function templateHasPersistenceSync2(templateId, { compoundPersistenceEnabled =
212265
212292
  return templateId === "persistence" || templateId === "compound" && compoundPersistenceEnabled;
212266
212293
  }
212267
212294
  function getOptionalSyncScriptNames(templateId, options = {}) {
212295
+ if (templateId === "query-loop") {
212296
+ return [];
212297
+ }
212268
212298
  const availableScripts = new Set(options.availableScripts ?? []);
212269
212299
  if (availableScripts.has("sync")) {
212270
212300
  return ["sync"];
@@ -212282,6 +212312,9 @@ function getOptionalOnboardingSteps(packageManager, templateId, options = {}) {
212282
212312
  return getOptionalSyncScriptNames(templateId, options).map((scriptName) => formatRunScript2(packageManager, scriptName));
212283
212313
  }
212284
212314
  function getQuickStartWorkflowNote(packageManager, templateId = "basic", options = {}) {
212315
+ if (templateId === "query-loop") {
212316
+ return `${formatRunScript2(packageManager, "start")} runs the editor build/watch loop that registers your Query Loop variation in the block editor. This scaffold is editor-facing by design: update \`src/index.ts\` when you want to change the variation namespace, default query, allowed controls, or the minimal inline starter layout, update \`src/patterns/*.php\` when you want richer connected layout presets in the inserter, use \`src/query-extension.ts\` when the variation needs custom query params or optional editor-side hooks, and mirror frontend/editor preview query mapping in \`inc/query-runtime.php\`.`;
212317
+ }
212285
212318
  const developmentScript = getPrimaryDevelopmentScript(templateId);
212286
212319
  const devCommand = formatRunScript2(packageManager, developmentScript);
212287
212320
  const startCommand = formatRunScript2(packageManager, "start");
@@ -212297,6 +212330,9 @@ function getQuickStartWorkflowNote(packageManager, templateId = "basic", options
212297
212330
  return `${devCommand} keeps the editor and type-derived artifacts moving together during local development. Use ${startCommand} when you want a one-shot sync plus editor startup without the long-running watch loop.`;
212298
212331
  }
212299
212332
  function getOptionalOnboardingNote(packageManager, templateId = "basic", options = {}) {
212333
+ if (templateId === "query-loop") {
212334
+ return `This scaffold does not generate \`block.json\` or Typia manifests. Edit \`src/index.ts\` to change the variation contract, edit \`src/patterns/*.php\` when you want richer connected layouts beyond the inline fallback, edit \`src/query-extension.ts\` when you need variation-specific query params or custom editor hooks, and edit \`inc/query-runtime.php\` when those params need frontend or editor preview parity. Then rerun ${formatRunScript2(packageManager, "build")}, ${formatRunScript2(packageManager, "start")}, or ${formatRunScript2(packageManager, "typecheck")} as needed.`;
212335
+ }
212300
212336
  const optionalSyncScripts = getOptionalSyncScriptNames(templateId, options);
212301
212337
  const hasUnifiedSync = optionalSyncScripts.includes("sync");
212302
212338
  const syncSteps = optionalSyncScripts.map((scriptName) => formatRunScript2(packageManager, scriptName));
@@ -212326,6 +212362,9 @@ function getInitialCommitNote() {
212326
212362
  return "Skip `git init` if this directory already lives inside an existing repository. If you want generated artifacts refreshed before the first checkpoint, run your manual sync step first and then create the commit.";
212327
212363
  }
212328
212364
  function getTemplateSourceOfTruthNote(templateId, { compoundPersistenceEnabled = false } = {}) {
212365
+ if (templateId === "query-loop") {
212366
+ return "`src/index.ts` remains the source of truth for the Query Loop variation name, default query attributes, `allowedControls`, and the minimal inline starter `innerBlocks`. Use `src/patterns/*.php` for richer connected layout presets that stay tied to the same variation namespace, use `src/query-extension.ts` for custom query seed values or optional editor-only hook registration, and use `inc/query-runtime.php` to keep frontend and editor preview query mapping aligned for those custom keys. The generated plugin bootstrap should stay focused on script registration, pattern loading, and explicit runtime glue for the variation.";
212367
+ }
212329
212368
  if (templateId === "compound") {
212330
212369
  const compoundBase = "`src/blocks/*/types.ts` files remain the source of truth for each block's `block.json`, `typia.manifest.json`, and `typia-validator.php`. Fresh scaffolds include starter `typia.manifest.json` files so editor imports resolve before the first sync.";
212331
212370
  if (compoundPersistenceEnabled) {
@@ -212456,6 +212495,20 @@ ${formatRunScript2(packageManager, "migration:fuzz")}
212456
212495
  \`\`\`
212457
212496
 
212458
212497
  Run \`migration:init\` only when retrofitting migration support into an older project that was not scaffolded with \`--with-migration-ui\`.` : "";
212498
+ const advancedSyncSection = optionalOnboardingSteps.length > 0 ? `## Advanced Sync
212499
+
212500
+ \`\`\`bash
212501
+ ${optionalOnboardingSteps.join(`
212502
+ `)}
212503
+ \`\`\`
212504
+
212505
+ ${getOptionalOnboardingNote(packageManager, templateId, {
212506
+ compoundPersistenceEnabled
212507
+ })}` : `## Artifact Refresh
212508
+
212509
+ ${getOptionalOnboardingNote(packageManager, templateId, {
212510
+ compoundPersistenceEnabled
212511
+ })}`;
212459
212512
  return `# ${variables.title}
212460
212513
 
212461
212514
  ${variables.description}
@@ -212482,16 +212535,7 @@ ${formatRunScript2(packageManager, "build")}
212482
212535
  ${formatRunScript2(packageManager, "typecheck")}
212483
212536
  \`\`\`
212484
212537
 
212485
- ## Advanced Sync
212486
-
212487
- \`\`\`bash
212488
- ${optionalOnboardingSteps.join(`
212489
- `)}
212490
- \`\`\`
212491
-
212492
- ${getOptionalOnboardingNote(packageManager, templateId, {
212493
- compoundPersistenceEnabled
212494
- })}
212538
+ ${advancedSyncSection}
212495
212539
 
212496
212540
  ## Before First Commit
212497
212541
 
@@ -222121,6 +222165,15 @@ function createBuiltInBlockSpec({
222121
222165
  project: {
222122
222166
  author: answers.author.trim()
222123
222167
  },
222168
+ queryLoop: templateId === "query-loop" ? {
222169
+ allowedControls: DEFAULT_QUERY_LOOP_ALLOWED_CONTROLS,
222170
+ enabled: true,
222171
+ postType: (answers.queryPostType ?? "post").trim() || "post"
222172
+ } : {
222173
+ allowedControls: [],
222174
+ enabled: false,
222175
+ postType: "post"
222176
+ },
222124
222177
  runtime: {
222125
222178
  withMigrationUi,
222126
222179
  withTestPreset,
@@ -222155,6 +222208,7 @@ function buildTemplateVariablesFromBlockSpec(spec) {
222155
222208
  const persistenceEnabled = spec.persistence.enabled;
222156
222209
  const dataStorageMode = persistenceEnabled ? spec.persistence.dataStorageMode : "custom-table";
222157
222210
  const persistencePolicy = persistenceEnabled ? spec.persistence.persistencePolicy : "authenticated";
222211
+ const queryVariationNamespace = `${namespace}/${slug}`;
222158
222212
  return {
222159
222213
  apiClientPackageVersion,
222160
222214
  author: spec.project.author,
@@ -222174,7 +222228,13 @@ function buildTemplateVariablesFromBlockSpec(spec) {
222174
222228
  dashCase: slug,
222175
222229
  dataStorageMode,
222176
222230
  description: spec.metadata.description,
222231
+ descriptionJson: JSON.stringify(spec.metadata.description),
222177
222232
  frontendCssClassName: buildFrontendCssClassName(cssClassName),
222233
+ queryAllowedControlsJson: JSON.stringify(spec.queryLoop.enabled ? spec.queryLoop.allowedControls : [], null, 2),
222234
+ queryPostType: spec.queryLoop.enabled ? spec.queryLoop.postType : "post",
222235
+ queryPostTypeJson: JSON.stringify(spec.queryLoop.enabled ? spec.queryLoop.postType : "post"),
222236
+ queryVariationNamespace,
222237
+ queryVariationNamespaceJson: JSON.stringify(queryVariationNamespace),
222178
222238
  isAuthenticatedPersistencePolicy: persistencePolicy === "authenticated" ? "true" : "false",
222179
222239
  isPublicPersistencePolicy: persistencePolicy === "public" ? "true" : "false",
222180
222240
  bootstrapCredentialDeclarations: persistencePolicy === "public" ? `publicWriteExpiresAt?: number & tags.Type< 'uint32' >;
@@ -222203,11 +222263,21 @@ function buildTemplateVariablesFromBlockSpec(spec) {
222203
222263
  persistencePolicy
222204
222264
  };
222205
222265
  }
222266
+ var DEFAULT_QUERY_LOOP_ALLOWED_CONTROLS;
222206
222267
  var init_block_generator_service_spec = __esm(() => {
222207
222268
  init_package_versions();
222208
222269
  init_template_defaults();
222209
222270
  init_template_registry();
222210
222271
  init_scaffold_identifiers();
222272
+ DEFAULT_QUERY_LOOP_ALLOWED_CONTROLS = [
222273
+ "inherit",
222274
+ "postType",
222275
+ "order",
222276
+ "sticky",
222277
+ "taxQuery",
222278
+ "author",
222279
+ "search"
222280
+ ];
222211
222281
  });
222212
222282
 
222213
222283
  // ../wp-typia-project-tools/src/runtime/built-in-block-non-ts-artifacts.ts
@@ -222421,6 +222491,8 @@ function buildBuiltInNonTsArtifacts({
222421
222491
  return buildPersistenceArtifacts(variables);
222422
222492
  case "compound":
222423
222493
  return buildCompoundArtifacts(variables);
222494
+ case "query-loop":
222495
+ return [];
222424
222496
  default: {
222425
222497
  const unhandledTemplateId = templateId;
222426
222498
  throw new Error(`Unhandled built-in template id: ${unhandledTemplateId}`);
@@ -224145,6 +224217,78 @@ const { actions, state } = store( '{{slugKebabCase}}', {
224145
224217
  } );
224146
224218
  `;
224147
224219
 
224220
+ // ../wp-typia-project-tools/src/runtime/built-in-block-code-templates/query-loop.ts
224221
+ var QUERY_LOOP_INDEX_TEMPLATE = `import { registerBlockVariation } from '@wordpress/blocks';
224222
+ import type { BlockVariation } from '@wp-typia/block-types/blocks/registration';
224223
+ import { __ } from '@wordpress/i18n';
224224
+ import {
224225
+ getQueryLoopCustomAllowedControls,
224226
+ getQueryLoopCustomQuerySeed,
224227
+ registerQueryLoopEditorExtensions,
224228
+ } from './query-extension';
224229
+
224230
+ type QueryLoopVariationAttributes = {
224231
+ namespace?: string;
224232
+ query?: {
224233
+ inherit?: boolean;
224234
+ order?: 'asc' | 'desc';
224235
+ orderBy?: string;
224236
+ perPage?: number;
224237
+ postType?: string;
224238
+ wpTypiaVariation?: string;
224239
+ [key: string]: unknown;
224240
+ };
224241
+ };
224242
+
224243
+ type QueryLoopVariation = BlockVariation<QueryLoopVariationAttributes> & {
224244
+ allowedControls: string[];
224245
+ };
224246
+
224247
+ const VARIATION_NAME = {{queryVariationNamespaceJson}};
224248
+ const DEFAULT_ALLOWED_CONTROLS = {{queryAllowedControlsJson}};
224249
+ const customQuerySeed = getQueryLoopCustomQuerySeed();
224250
+ const allowedControls = Array.from(
224251
+ new Set([...DEFAULT_ALLOWED_CONTROLS, ...getQueryLoopCustomAllowedControls()]),
224252
+ );
224253
+
224254
+ const queryLoopVariation = {
224255
+ name: VARIATION_NAME,
224256
+ title: __({{titleJson}}, '{{textDomain}}'),
224257
+ description: __({{descriptionJson}}, '{{textDomain}}'),
224258
+ scope: ['inserter'],
224259
+ isActive: ['namespace'],
224260
+ attributes: {
224261
+ namespace: VARIATION_NAME,
224262
+ query: {
224263
+ inherit: false,
224264
+ order: 'desc',
224265
+ orderBy: 'date',
224266
+ perPage: 6,
224267
+ postType: {{queryPostTypeJson}},
224268
+ ...customQuerySeed,
224269
+ wpTypiaVariation: VARIATION_NAME,
224270
+ },
224271
+ },
224272
+ allowedControls,
224273
+ innerBlocks: [
224274
+ [
224275
+ 'core/post-template',
224276
+ {},
224277
+ [
224278
+ ['core/post-featured-image'],
224279
+ ['core/post-title', { isLink: true }],
224280
+ ['core/post-excerpt'],
224281
+ ],
224282
+ ],
224283
+ ['core/query-pagination'],
224284
+ ['core/query-no-results'],
224285
+ ],
224286
+ } satisfies QueryLoopVariation;
224287
+
224288
+ registerBlockVariation('core/query', queryLoopVariation);
224289
+ registerQueryLoopEditorExtensions({ variationName: VARIATION_NAME });
224290
+ `;
224291
+
224148
224292
  // ../wp-typia-project-tools/src/runtime/built-in-block-code-templates/compound-parent.ts
224149
224293
  var COMPOUND_PARENT_EDIT_TEMPLATE = `import type { BlockEditProps } from '@wp-typia/block-types/blocks/registration';
224150
224294
  import { __ } from '@wordpress/i18n';
@@ -225147,6 +225291,17 @@ function buildPersistenceCodeArtifacts(variables) {
225147
225291
  ...buildBuiltInNonTsArtifacts({ templateId: "persistence", variables })
225148
225292
  ]);
225149
225293
  }
225294
+ function buildQueryLoopCodeArtifacts(variables) {
225295
+ return ensureUniqueArtifactPaths([
225296
+ ...createCodeArtifacts([
225297
+ {
225298
+ relativePath: "src/index.ts",
225299
+ template: QUERY_LOOP_INDEX_TEMPLATE
225300
+ }
225301
+ ], variables),
225302
+ ...buildBuiltInNonTsArtifacts({ templateId: "query-loop", variables })
225303
+ ]);
225304
+ }
225150
225305
  function buildBuiltInCodeArtifacts({
225151
225306
  templateId,
225152
225307
  variables
@@ -225160,6 +225315,8 @@ function buildBuiltInCodeArtifacts({
225160
225315
  return buildPersistenceCodeArtifacts(variables);
225161
225316
  case "compound":
225162
225317
  return buildCompoundCodeArtifacts(variables);
225318
+ case "query-loop":
225319
+ return buildQueryLoopCodeArtifacts(variables);
225163
225320
  default: {
225164
225321
  const unhandledTemplateId = templateId;
225165
225322
  throw new Error(`Unhandled built-in template id: ${unhandledTemplateId}`);
@@ -225472,102 +225629,6 @@ var init_block_generator_service = __esm(() => {
225472
225629
  init_block_generator_service_core();
225473
225630
  });
225474
225631
 
225475
- // ../wp-typia-project-tools/src/runtime/scaffold-template-variables.ts
225476
- function getTemplateVariables(templateId, answers) {
225477
- if (isBuiltInTemplateId(templateId)) {
225478
- return buildTemplateVariablesFromBlockSpec(createBuiltInBlockSpec({
225479
- answers,
225480
- dataStorageMode: answers.dataStorageMode,
225481
- persistencePolicy: answers.persistencePolicy,
225482
- templateId
225483
- }));
225484
- }
225485
- const {
225486
- apiClientPackageVersion,
225487
- blockRuntimePackageVersion,
225488
- blockTypesPackageVersion,
225489
- projectToolsPackageVersion,
225490
- restPackageVersion
225491
- } = getPackageVersions();
225492
- const template = isBuiltInTemplateId(templateId) ? getTemplateById(templateId) : null;
225493
- const metadataDefaults = isBuiltInTemplateId(templateId) ? getBuiltInTemplateMetadataDefaults(templateId) : null;
225494
- const identifiers = resolveScaffoldIdentifiers({
225495
- namespace: answers.namespace,
225496
- phpPrefix: answers.phpPrefix,
225497
- slug: answers.slug,
225498
- textDomain: answers.textDomain
225499
- });
225500
- const slug = identifiers.slug;
225501
- const slugSnakeCase = toSnakeCase(slug);
225502
- const pascalCase = toPascalCase(slug);
225503
- const title = answers.title.trim();
225504
- const namespace = identifiers.namespace;
225505
- const description = answers.description.trim();
225506
- const textDomain = identifiers.textDomain;
225507
- const phpPrefix = identifiers.phpPrefix;
225508
- const phpPrefixUpper = phpPrefix.toUpperCase();
225509
- const compoundChildTitle = `${title} Item`;
225510
- const cssClassName = buildBlockCssClassName(namespace, slug);
225511
- const compoundChildCssClassName = buildBlockCssClassName(namespace, `${slug}-item`);
225512
- const compoundPersistenceEnabled = templateId === "persistence" ? true : templateId === "compound" ? Boolean(answers.dataStorageMode || answers.persistencePolicy) : false;
225513
- const dataStorageMode = templateId === "persistence" || compoundPersistenceEnabled ? answers.dataStorageMode ?? "custom-table" : "custom-table";
225514
- const persistencePolicy = templateId === "persistence" || compoundPersistenceEnabled ? answers.persistencePolicy ?? "authenticated" : "authenticated";
225515
- return {
225516
- apiClientPackageVersion,
225517
- author: answers.author.trim(),
225518
- blockRuntimePackageVersion,
225519
- blockMetadataVersion: BUILTIN_BLOCK_METADATA_VERSION,
225520
- blockTypesPackageVersion,
225521
- category: metadataDefaults?.category ?? template?.defaultCategory ?? "widgets",
225522
- icon: metadataDefaults?.icon ?? "smiley",
225523
- compoundChildTitle,
225524
- compoundChildCategory: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.category,
225525
- compoundChildCssClassName,
225526
- compoundChildIcon: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.icon,
225527
- compoundChildTitleJson: JSON.stringify(compoundChildTitle),
225528
- compoundPersistenceEnabled: compoundPersistenceEnabled ? "true" : "false",
225529
- projectToolsPackageVersion,
225530
- cssClassName,
225531
- dataStorageMode,
225532
- dashCase: slug,
225533
- description,
225534
- frontendCssClassName: buildFrontendCssClassName(cssClassName),
225535
- isAuthenticatedPersistencePolicy: persistencePolicy === "authenticated" ? "true" : "false",
225536
- isPublicPersistencePolicy: persistencePolicy === "public" ? "true" : "false",
225537
- bootstrapCredentialDeclarations: persistencePolicy === "public" ? `publicWriteExpiresAt?: number & tags.Type< 'uint32' >;
225538
- publicWriteToken?: string & tags.MinLength< 1 > & tags.MaxLength< 512 >;` : "restNonce?: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;",
225539
- persistencePolicyDescriptionJson: JSON.stringify(persistencePolicy === "authenticated" ? "Writes require a logged-in user and a valid REST nonce." : "Anonymous writes use signed short-lived public tokens, per-request ids, and coarse rate limiting."),
225540
- keyword: slug.replace(/-/g, " "),
225541
- namespace,
225542
- needsMigration: "{{needsMigration}}",
225543
- pascalCase,
225544
- phpPrefix,
225545
- phpPrefixUpper,
225546
- restPackageVersion,
225547
- publicWriteRequestIdDeclaration: persistencePolicy === "public" ? "publicWriteRequestId: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;" : "publicWriteRequestId?: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;",
225548
- restWriteAuthIntent: persistencePolicy === "public" ? "public-write-protected" : "authenticated",
225549
- restWriteAuthMechanism: persistencePolicy === "public" ? "public-signed-token" : "rest-nonce",
225550
- restWriteAuthMode: persistencePolicy === "public" ? "public-signed-token" : "authenticated-rest-nonce",
225551
- slug,
225552
- slugCamelCase: pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1),
225553
- slugKebabCase: slug,
225554
- slugSnakeCase,
225555
- textDomain,
225556
- textdomain: textDomain,
225557
- title,
225558
- titleJson: JSON.stringify(title),
225559
- titleCase: pascalCase,
225560
- persistencePolicy
225561
- };
225562
- }
225563
- var init_scaffold_template_variables = __esm(() => {
225564
- init_block_generator_service();
225565
- init_package_versions();
225566
- init_scaffold_identifiers();
225567
- init_template_defaults();
225568
- init_template_registry();
225569
- });
225570
-
225571
225632
  // ../wp-typia-project-tools/src/runtime/scaffold-answer-resolution.ts
225572
225633
  import { execSync as execSync4 } from "child_process";
225573
225634
  function detectAuthor() {
@@ -225590,11 +225651,32 @@ function getDefaultAnswers(projectName, templateId) {
225590
225651
  namespace: slugDefault,
225591
225652
  persistencePolicy: templateId === "persistence" ? "authenticated" : undefined,
225592
225653
  phpPrefix: toSnakeCase(slugDefault),
225654
+ queryPostType: templateId === "query-loop" ? "post" : undefined,
225593
225655
  slug: slugDefault,
225594
225656
  textDomain: slugDefault,
225595
225657
  title: toTitleCase(slugDefault)
225596
225658
  };
225597
225659
  }
225660
+ function validateQueryPostType(value2) {
225661
+ const normalizedValue = value2.trim().toLowerCase();
225662
+ if (normalizedValue.length === 0) {
225663
+ return "Query post type is required.";
225664
+ }
225665
+ if (!/^[a-z0-9_-]{1,20}$/u.test(normalizedValue)) {
225666
+ return 'Query post type must be lowercase, 1-20 chars, and only a-z, 0-9, "_" or "-".';
225667
+ }
225668
+ return true;
225669
+ }
225670
+ function normalizeQueryPostType(value2) {
225671
+ if (typeof value2 !== "string") {
225672
+ return;
225673
+ }
225674
+ const normalizedValue = value2.trim().toLowerCase();
225675
+ if (validateQueryPostType(normalizedValue) !== true) {
225676
+ throw new Error('Query post type must be lowercase, 1-20 chars, and only a-z, 0-9, "_" or "-".');
225677
+ }
225678
+ return normalizedValue;
225679
+ }
225598
225680
  function normalizeTemplateSelection(templateId) {
225599
225681
  return templateId === WORKSPACE_TEMPLATE_ALIAS ? OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE : templateId;
225600
225682
  }
@@ -225648,6 +225730,7 @@ async function collectScaffoldAnswers({
225648
225730
  persistencePolicy,
225649
225731
  phpPrefix,
225650
225732
  promptText,
225733
+ queryPostType,
225651
225734
  textDomain
225652
225735
  }) {
225653
225736
  const defaults = getDefaultAnswers(projectName, templateId);
@@ -225664,6 +225747,7 @@ async function collectScaffoldAnswers({
225664
225747
  namespace: identifiers2.namespace,
225665
225748
  persistencePolicy: persistencePolicy ?? defaults.persistencePolicy,
225666
225749
  phpPrefix: identifiers2.phpPrefix,
225750
+ queryPostType: normalizeQueryPostType(queryPostType ?? defaults.queryPostType),
225667
225751
  textDomain: identifiers2.textDomain
225668
225752
  };
225669
225753
  }
@@ -225683,6 +225767,7 @@ async function collectScaffoldAnswers({
225683
225767
  namespace: identifiers.namespace,
225684
225768
  persistencePolicy: persistencePolicy ?? defaults.persistencePolicy,
225685
225769
  phpPrefix: identifiers.phpPrefix,
225770
+ queryPostType: templateId === "query-loop" ? normalizeQueryPostType(await promptText("Query post type", queryPostType ?? defaults.queryPostType ?? "post", validateQueryPostType)) : normalizeQueryPostType(queryPostType ?? defaults.queryPostType),
225686
225771
  slug: identifiers.slug,
225687
225772
  textDomain: identifiers.textDomain,
225688
225773
  title: await promptText("Block title", toTitleCase(identifiers.slug))
@@ -225696,6 +225781,108 @@ var init_scaffold_answer_resolution = __esm(() => {
225696
225781
  init_template_defaults();
225697
225782
  });
225698
225783
 
225784
+ // ../wp-typia-project-tools/src/runtime/scaffold-template-variables.ts
225785
+ function getTemplateVariables(templateId, answers) {
225786
+ if (isBuiltInTemplateId(templateId)) {
225787
+ return buildTemplateVariablesFromBlockSpec(createBuiltInBlockSpec({
225788
+ answers,
225789
+ dataStorageMode: answers.dataStorageMode,
225790
+ persistencePolicy: answers.persistencePolicy,
225791
+ templateId
225792
+ }));
225793
+ }
225794
+ const {
225795
+ apiClientPackageVersion,
225796
+ blockRuntimePackageVersion,
225797
+ blockTypesPackageVersion,
225798
+ projectToolsPackageVersion,
225799
+ restPackageVersion
225800
+ } = getPackageVersions();
225801
+ const template = isBuiltInTemplateId(templateId) ? getTemplateById(templateId) : null;
225802
+ const metadataDefaults = isBuiltInTemplateId(templateId) ? getBuiltInTemplateMetadataDefaults(templateId) : null;
225803
+ const identifiers = resolveScaffoldIdentifiers({
225804
+ namespace: answers.namespace,
225805
+ phpPrefix: answers.phpPrefix,
225806
+ slug: answers.slug,
225807
+ textDomain: answers.textDomain
225808
+ });
225809
+ const slug = identifiers.slug;
225810
+ const slugSnakeCase = toSnakeCase(slug);
225811
+ const pascalCase = toPascalCase(slug);
225812
+ const title = answers.title.trim();
225813
+ const namespace = identifiers.namespace;
225814
+ const description = answers.description.trim();
225815
+ const textDomain = identifiers.textDomain;
225816
+ const phpPrefix = identifiers.phpPrefix;
225817
+ const phpPrefixUpper = phpPrefix.toUpperCase();
225818
+ const compoundChildTitle = `${title} Item`;
225819
+ const cssClassName = buildBlockCssClassName(namespace, slug);
225820
+ const compoundChildCssClassName = buildBlockCssClassName(namespace, `${slug}-item`);
225821
+ const compoundPersistenceEnabled = templateId === "persistence" ? true : templateId === "compound" ? Boolean(answers.dataStorageMode || answers.persistencePolicy) : false;
225822
+ const dataStorageMode = templateId === "persistence" || compoundPersistenceEnabled ? answers.dataStorageMode ?? "custom-table" : "custom-table";
225823
+ const persistencePolicy = templateId === "persistence" || compoundPersistenceEnabled ? answers.persistencePolicy ?? "authenticated" : "authenticated";
225824
+ return {
225825
+ apiClientPackageVersion,
225826
+ author: answers.author.trim(),
225827
+ blockRuntimePackageVersion,
225828
+ blockMetadataVersion: BUILTIN_BLOCK_METADATA_VERSION,
225829
+ blockTypesPackageVersion,
225830
+ category: metadataDefaults?.category ?? template?.defaultCategory ?? "widgets",
225831
+ icon: metadataDefaults?.icon ?? "smiley",
225832
+ compoundChildTitle,
225833
+ compoundChildCategory: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.category,
225834
+ compoundChildCssClassName,
225835
+ compoundChildIcon: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.icon,
225836
+ compoundChildTitleJson: JSON.stringify(compoundChildTitle),
225837
+ compoundPersistenceEnabled: compoundPersistenceEnabled ? "true" : "false",
225838
+ projectToolsPackageVersion,
225839
+ cssClassName,
225840
+ dataStorageMode,
225841
+ dashCase: slug,
225842
+ description,
225843
+ descriptionJson: JSON.stringify(description),
225844
+ frontendCssClassName: buildFrontendCssClassName(cssClassName),
225845
+ queryAllowedControlsJson: JSON.stringify([], null, 2),
225846
+ queryPostType: answers.queryPostType?.trim() || "post",
225847
+ queryPostTypeJson: JSON.stringify(answers.queryPostType?.trim() || "post"),
225848
+ queryVariationNamespace: `${namespace}/${slug}`,
225849
+ queryVariationNamespaceJson: JSON.stringify(`${namespace}/${slug}`),
225850
+ isAuthenticatedPersistencePolicy: persistencePolicy === "authenticated" ? "true" : "false",
225851
+ isPublicPersistencePolicy: persistencePolicy === "public" ? "true" : "false",
225852
+ bootstrapCredentialDeclarations: persistencePolicy === "public" ? `publicWriteExpiresAt?: number & tags.Type< 'uint32' >;
225853
+ publicWriteToken?: string & tags.MinLength< 1 > & tags.MaxLength< 512 >;` : "restNonce?: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;",
225854
+ persistencePolicyDescriptionJson: JSON.stringify(persistencePolicy === "authenticated" ? "Writes require a logged-in user and a valid REST nonce." : "Anonymous writes use signed short-lived public tokens, per-request ids, and coarse rate limiting."),
225855
+ keyword: slug.replace(/-/g, " "),
225856
+ namespace,
225857
+ needsMigration: "{{needsMigration}}",
225858
+ pascalCase,
225859
+ phpPrefix,
225860
+ phpPrefixUpper,
225861
+ restPackageVersion,
225862
+ publicWriteRequestIdDeclaration: persistencePolicy === "public" ? "publicWriteRequestId: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;" : "publicWriteRequestId?: string & tags.MinLength< 1 > & tags.MaxLength< 128 >;",
225863
+ restWriteAuthIntent: persistencePolicy === "public" ? "public-write-protected" : "authenticated",
225864
+ restWriteAuthMechanism: persistencePolicy === "public" ? "public-signed-token" : "rest-nonce",
225865
+ restWriteAuthMode: persistencePolicy === "public" ? "public-signed-token" : "authenticated-rest-nonce",
225866
+ slug,
225867
+ slugCamelCase: pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1),
225868
+ slugKebabCase: slug,
225869
+ slugSnakeCase,
225870
+ textDomain,
225871
+ textdomain: textDomain,
225872
+ title,
225873
+ titleJson: JSON.stringify(title),
225874
+ titleCase: pascalCase,
225875
+ persistencePolicy
225876
+ };
225877
+ }
225878
+ var init_scaffold_template_variables = __esm(() => {
225879
+ init_block_generator_service();
225880
+ init_package_versions();
225881
+ init_scaffold_identifiers();
225882
+ init_template_defaults();
225883
+ init_template_registry();
225884
+ });
225885
+
225699
225886
  // ../wp-typia-project-tools/src/runtime/scaffold.ts
225700
225887
  import fs33 from "fs";
225701
225888
  import { promises as fsp13 } from "fs";
@@ -225861,6 +226048,7 @@ var init_scaffold = __esm(() => {
225861
226048
  init_template_registry();
225862
226049
  init_template_source();
225863
226050
  init_block_generator_service();
226051
+ init_scaffold_answer_resolution();
225864
226052
  init_scaffold_template_variables();
225865
226053
  init_scaffold_identifiers();
225866
226054
  init_scaffold_answer_resolution();
@@ -227897,6 +228085,7 @@ async function runScaffoldFlow({
227897
228085
  namespace,
227898
228086
  textDomain,
227899
228087
  phpPrefix,
228088
+ queryPostType,
227900
228089
  yes = false,
227901
228090
  noInstall = false,
227902
228091
  isInteractive = false,
@@ -228000,6 +228189,7 @@ async function runScaffoldFlow({
228000
228189
  persistencePolicy: resolvedPersistencePolicy,
228001
228190
  phpPrefix,
228002
228191
  projectName,
228192
+ queryPostType,
228003
228193
  templateId: resolvedTemplateId,
228004
228194
  textDomain,
228005
228195
  yes,
@@ -280984,6 +281174,7 @@ async function executeCreateCommand({
280984
281174
  phpPrefix: readOptionalLooseStringFlag(flags2, "php-prefix"),
280985
281175
  projectInput: projectDir,
280986
281176
  promptText: activePrompt ? (message, defaultValue, validate) => activePrompt.text(message, defaultValue, validate) : undefined,
281177
+ queryPostType: readOptionalLooseStringFlag(flags2, "query-post-type"),
280987
281178
  selectDataStorage: activePrompt ? () => activePrompt.select("Select a data storage mode", [...DATA_STORAGE_PROMPT_OPTIONS], 1) : undefined,
280988
281179
  selectExternalLayerId: shouldPromptForExternalLayerSelection && activePrompt ? (options) => activePrompt.select("Select an external layer", toExternalLayerPromptOptions(options), 1) : undefined,
280989
281180
  selectPackageManager: activePrompt ? () => activePrompt.select("Select a package manager", [...PACKAGE_MANAGER_PROMPT_OPTIONS], 1) : undefined,
@@ -281823,6 +282014,10 @@ var createOptions = {
281823
282014
  description: "Custom PHP symbol prefix.",
281824
282015
  schema: exports_external.string().optional()
281825
282016
  },
282017
+ "query-post-type": {
282018
+ description: "Default post type assigned to Query Loop variation scaffolds.",
282019
+ schema: exports_external.string().optional()
282020
+ },
281826
282021
  template: {
281827
282022
  description: "Template id or external template package.",
281828
282023
  schema: exports_external.string().optional(),
@@ -281894,6 +282089,7 @@ var createCommand = defineCommand({
281894
282089
  "package-manager": args.flags["package-manager"] ?? config2["package-manager"],
281895
282090
  "persistence-policy": args.flags["persistence-policy"] ?? config2["persistence-policy"],
281896
282091
  "php-prefix": args.flags["php-prefix"] ?? config2["php-prefix"],
282092
+ "query-post-type": args.flags["query-post-type"] ?? config2["query-post-type"],
281897
282093
  "project-dir": args.positional[0] ?? "",
281898
282094
  template: args.flags.template ?? config2.template,
281899
282095
  "text-domain": args.flags["text-domain"] ?? config2["text-domain"],
@@ -282799,4 +282995,4 @@ export {
282799
282995
  cli
282800
282996
  };
282801
282997
 
282802
- //# debugId=49D9C09383E8F29664756E2164756E21
282998
+ //# debugId=9E22CBAFF8C72AF964756E2164756E21