@wp-typia/project-tools 0.24.11 → 0.24.13

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.
Files changed (72) hide show
  1. package/dist/runtime/add/cli-add-block-config.js +7 -15
  2. package/dist/runtime/add/cli-add-block-package-json.d.ts +5 -0
  3. package/dist/runtime/add/cli-add-block-package-json.js +32 -0
  4. package/dist/runtime/add/cli-add-block.js +17 -4
  5. package/dist/runtime/add/cli-add-workspace-admin-view-scaffold.js +1 -5
  6. package/dist/runtime/add/cli-add-workspace-hooked-block.js +15 -20
  7. package/dist/runtime/add/cli-add-workspace-mutation.d.ts +15 -2
  8. package/dist/runtime/add/cli-add-workspace-mutation.js +10 -4
  9. package/dist/runtime/add/persistence-rest-artifacts.d.ts +32 -7
  10. package/dist/runtime/add/persistence-rest-artifacts.js +41 -15
  11. package/dist/runtime/cli/cli-diagnostics.d.ts +9 -0
  12. package/dist/runtime/cli/cli-diagnostics.js +8 -0
  13. package/dist/runtime/cli/cli-init-package-json.js +5 -1
  14. package/dist/runtime/doctor/cli-doctor-standalone-control-flow.d.ts +38 -0
  15. package/dist/runtime/doctor/cli-doctor-standalone-control-flow.js +365 -0
  16. package/dist/runtime/doctor/cli-doctor-standalone-rest.d.ts +21 -0
  17. package/dist/runtime/doctor/cli-doctor-standalone-rest.js +1354 -0
  18. package/dist/runtime/doctor/cli-doctor-standalone-shared.d.ts +24 -0
  19. package/dist/runtime/doctor/cli-doctor-standalone-shared.js +50 -0
  20. package/dist/runtime/doctor/cli-doctor-standalone.d.ts +32 -0
  21. package/dist/runtime/doctor/cli-doctor-standalone.js +2594 -0
  22. package/dist/runtime/doctor/cli-doctor-workspace.d.ts +5 -3
  23. package/dist/runtime/doctor/cli-doctor-workspace.js +27 -3
  24. package/dist/runtime/doctor/cli-doctor.d.ts +4 -2
  25. package/dist/runtime/doctor/cli-doctor.js +4 -2
  26. package/dist/runtime/shared/json-utils.d.ts +7 -0
  27. package/dist/runtime/shared/json-utils.js +10 -0
  28. package/dist/runtime/shared/package-json-types.d.ts +1 -1
  29. package/dist/runtime/shared/package-versions.d.ts +2 -0
  30. package/dist/runtime/shared/package-versions.js +2 -0
  31. package/dist/runtime/shared/php-utils.d.ts +39 -2
  32. package/dist/runtime/shared/php-utils.js +205 -6
  33. package/dist/runtime/templates/block-generator-service-core.d.ts +1 -1
  34. package/dist/runtime/templates/block-generator-service-core.js +9 -3
  35. package/dist/runtime/templates/block-generator-service-spec.d.ts +5 -0
  36. package/dist/runtime/templates/built-in-block-artifact-documents.d.ts +1 -1
  37. package/dist/runtime/templates/built-in-block-artifact-documents.js +1 -1
  38. package/dist/runtime/templates/built-in-block-artifact-types.js +2 -2
  39. package/dist/runtime/templates/built-in-block-artifacts.d.ts +1 -1
  40. package/dist/runtime/templates/built-in-block-artifacts.js +16 -12
  41. package/dist/runtime/templates/built-in-block-attribute-emitters.d.ts +5 -0
  42. package/dist/runtime/templates/built-in-block-attribute-emitters.js +113 -8
  43. package/dist/runtime/templates/built-in-block-attribute-specs.js +4 -9
  44. package/dist/runtime/templates/built-in-block-code-artifacts.js +6 -1
  45. package/dist/runtime/templates/built-in-block-code-templates/compound-persistence.d.ts +2 -2
  46. package/dist/runtime/templates/built-in-block-code-templates/compound-persistence.js +24 -1
  47. package/dist/runtime/templates/built-in-block-code-templates/persistence.d.ts +2 -2
  48. package/dist/runtime/templates/built-in-block-code-templates/persistence.js +22 -1
  49. package/dist/runtime/templates/built-in-block-non-ts-compound-templates.d.ts +2 -2
  50. package/dist/runtime/templates/built-in-block-non-ts-compound-templates.js +6 -2
  51. package/dist/runtime/templates/built-in-block-non-ts-persistence-templates.d.ts +2 -2
  52. package/dist/runtime/templates/built-in-block-non-ts-persistence-templates.js +6 -2
  53. package/dist/runtime/templates/cli-scaffold-emission.d.ts +7 -1
  54. package/dist/runtime/templates/cli-scaffold-emission.js +10 -1
  55. package/dist/runtime/templates/cli-templates.d.ts +47 -0
  56. package/dist/runtime/templates/cli-templates.js +50 -1
  57. package/dist/runtime/templates/local-dev-presets.js +1 -1
  58. package/dist/runtime/templates/scaffold-apply-utils.d.ts +4 -8
  59. package/dist/runtime/templates/scaffold-apply-utils.js +44 -28
  60. package/dist/runtime/templates/scaffold-compiler-artifacts.d.ts +17 -0
  61. package/dist/runtime/templates/scaffold-compiler-artifacts.js +81 -0
  62. package/dist/runtime/templates/scaffold-onboarding.d.ts +5 -0
  63. package/dist/runtime/templates/scaffold-onboarding.js +13 -2
  64. package/dist/runtime/templates/scaffold-template-variable-groups.d.ts +4 -0
  65. package/dist/runtime/templates/scaffold-template-variable-groups.js +7 -0
  66. package/dist/runtime/templates/scaffold.d.ts +3 -1
  67. package/dist/runtime/templates/scaffold.js +2 -1
  68. package/dist/runtime/templates/starter-manifests.js +1 -1
  69. package/package.json +5 -5
  70. package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +1 -1
  71. package/templates/_shared/compound/persistence/package.json.mustache +1 -0
  72. package/templates/_shared/persistence/core/package.json.mustache +1 -0
@@ -5,7 +5,7 @@
5
5
  * plain-text, and web render entries with block identity, namespace, text
6
6
  * domain, storage, policy, CSS class, and title placeholders.
7
7
  */
8
- export declare const COMPOUND_PERSISTENCE_RENDER_TARGETS_TEMPLATE = "<?php\n/**\n * Alternate render target helpers for the {{title}} compound parent block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block ) {\n\t\t$validator_path = __DIR__ . '/typia-validator.php';\n\t\tif ( ! file_exists( $validator_path ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$validator = require $validator_path;\n\t\tif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n\t\t$validation = $validator->validate( $normalized );\n\t\t$resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';\n\t\t$heading = isset( $normalized['heading'] ) ? (string) $normalized['heading'] : {{titlePhpLiteral}};\n\t\t$intro = isset( $normalized['intro'] ) ? (string) $normalized['intro'] : '';\n\t\t$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n\t\t$show_count = ! empty( $normalized['showCount'] );\n\t\t$show_dividers = ! empty( $normalized['showDividers'] );\n\t\t$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t\t\t? (int) $block->context['postId']\n\t\t\t: (int) get_queried_object_id();\n\t\t$storage_mode = '{{dataStorageMode}}';\n\t\t$persistence_policy = '{{persistencePolicy}}';\n\n\t\t$notice_message = 'authenticated' === $persistence_policy\n\t\t\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t\t\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n\n\t\tif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t{{phpPrefix}}_record_rendered_block_instance(\n\t\t\t(int) $post_id,\n\t\t\t'{{namespace}}/{{slugKebabCase}}',\n\t\t\t$resource_key\n\t\t);\n\n\t\t$web_context = array(\n\t\t\t'bootstrapReady' => false,\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'canWrite' => false,\n\t\t\t'client' => array(\n\t\t\t\t'writeExpiry' => 0,\n\t\t\t\t'writeNonce' => '',\n\t\t\t\t'writeToken' => '',\n\t\t\t),\n\t\t\t'count' => 0,\n\t\t\t'error' => '',\n\t\t\t'isBootstrapping' => false,\n\t\t\t'isLoading' => false,\n\t\t\t'isSaving' => false,\n\t\t\t'persistencePolicy' => $persistence_policy,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'showCount' => $show_count,\n\t\t\t'storage' => $storage_mode,\n\t\t);\n\n\t\t$allowed_inner_html = wp_kses_allowed_html( 'post' );\n\n\t\tforeach ( $allowed_inner_html as &$allowed_attributes ) {\n\t\t\tif ( ! is_array( $allowed_attributes ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t$allowed_attributes['data-wp-bind--disabled'] = true;\n\t\t\t$allowed_attributes['data-wp-bind--hidden'] = true;\n\t\t\t$allowed_attributes['data-wp-bind--value'] = true;\n\t\t\t$allowed_attributes['data-wp-class'] = true;\n\t\t\t$allowed_attributes['data-wp-class--active'] = true;\n\t\t\t$allowed_attributes['data-wp-context'] = true;\n\t\t\t$allowed_attributes['data-wp-init'] = true;\n\t\t\t$allowed_attributes['data-wp-interactive'] = true;\n\t\t\t$allowed_attributes['data-wp-on--click'] = true;\n\t\t\t$allowed_attributes['data-wp-on--mouseenter'] = true;\n\t\t\t$allowed_attributes['data-wp-on--mouseleave'] = true;\n\t\t\t$allowed_attributes['data-wp-run--mounted'] = true;\n\t\t\t$allowed_attributes['data-wp-style--width'] = true;\n\t\t\t$allowed_attributes['data-wp-text'] = true;\n\t\t}\n\t\tunset( $allowed_attributes );\n\n\t\treturn array(\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'frontendClassName' => '{{cssClassName}}',\n\t\t\t'heading' => $heading,\n\t\t\t'intro' => $intro,\n\t\t\t'isVisible' => true,\n\t\t\t'normalized' => $normalized,\n\t\t\t'noticeMessage' => $notice_message,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'sanitizedContent' => wp_kses( $content, $allowed_inner_html ),\n\t\t\t'showCount' => $show_count,\n\t\t\t'showDividers' => $show_dividers,\n\t\t\t'title' => {{titleJson}},\n\t\t\t'webContext' => $web_context,\n\t\t);\n\t}\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_render_target' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_render_target( string $target, $attributes, $content = '', $block = null ): string {\n\t\t$context = {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block );\n\t\tif ( null === $context ) {\n\t\t\treturn '';\n\t\t}\n\n\t\t$target_context = apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_context',\n\t\t\t$context,\n\t\t\t$target,\n\t\t\t$attributes,\n\t\t\t$block\n\t\t);\n\n\t\t$markup = '';\n\t\tswitch ( $target ) {\n\t\t\tcase 'email':\n\t\t\t\t$parts = array(\n\t\t\t\t\t'<div class=\"' . esc_attr( $target_context['frontendClassName'] ) . '-email\">',\n\t\t\t\t\t'<h3>' . esc_html( $target_context['heading'] ) . '</h3>',\n\t\t\t\t);\n\t\t\t\tif ( '' !== $target_context['intro'] ) {\n\t\t\t\t\t$parts[] = '<p>' . esc_html( $target_context['intro'] ) . '</p>';\n\t\t\t\t}\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$parts[] = '<p><strong>' . esc_html__( 'Count', '{{textDomain}}' ) . ':</strong> ' . esc_html( (string) $target_context['webContext']['count'] ) . '</p>';\n\t\t\t\t}\n\t\t\t\t$parts[] = wp_kses_post( $target_context['sanitizedContent'] );\n\t\t\t\t$parts[] = '<p>' . esc_html( $target_context['noticeMessage'] ) . '</p>';\n\t\t\t\t$parts[] = '</div>';\n\t\t\t\t$markup = implode( '', $parts );\n\t\t\t\tbreak;\n\t\t\tcase 'mjml':\n\t\t\t\t$markup = '<mjml><mj-body><mj-section><mj-column><mj-text font-weight=\"700\">' . esc_html( $target_context['heading'] ) . '</mj-text>';\n\t\t\t\tif ( '' !== $target_context['intro'] ) {\n\t\t\t\t\t$markup .= '<mj-text>' . esc_html( $target_context['intro'] ) . '</mj-text>';\n\t\t\t\t}\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$markup .= '<mj-text>' . esc_html__( 'Count', '{{textDomain}}' ) . ': ' . esc_html( (string) $target_context['webContext']['count'] ) . '</mj-text>';\n\t\t\t\t}\n\t\t\t\t$markup .= '<mj-text>' . esc_html( wp_strip_all_tags( $target_context['sanitizedContent'] ) ) . '</mj-text>';\n\t\t\t\t$markup .= '<mj-text>' . esc_html( $target_context['noticeMessage'] ) . '</mj-text></mj-column></mj-section></mj-body></mjml>';\n\t\t\t\tbreak;\n\t\t\tcase 'plain-text':\n\t\t\t\t$markup = implode(\n\t\t\t\t\t\"\\n\",\n\t\t\t\t\tarray_filter(\n\t\t\t\t\t\tarray(\n\t\t\t\t\t\t\t$target_context['heading'],\n\t\t\t\t\t\t\t$target_context['intro'],\n\t\t\t\t\t\t\twp_strip_all_tags( $target_context['sanitizedContent'] ),\n\t\t\t\t\t\t\t! empty( $target_context['showCount'] )\n\t\t\t\t\t\t\t\t? sprintf( '%s: %s', __( 'Count', '{{textDomain}}' ), (string) $target_context['webContext']['count'] )\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\t$target_context['noticeMessage'],\n\t\t\t\t\t\t),\n\t\t\t\t\t\tstatic fn( $value ) => is_string( $value ) && '' !== $value\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase 'web':\n\t\t\tdefault:\n\t\t\t\t$wrapper_attributes = get_block_wrapper_attributes(\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'class' => '{{cssClassName}}',\n\t\t\t\t\t\t'data-show-dividers' => $target_context['showDividers'] ? 'true' : 'false',\n\t\t\t\t\t\t'data-wp-context' => wp_json_encode( $target_context['webContext'] ),\n\t\t\t\t\t\t'data-wp-init' => 'callbacks.init',\n\t\t\t\t\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t\t\t\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tob_start();\n\t\t\t\t?>\n<div <?php echo $wrapper_attributes; ?>>\n\t<h3 class=\"{{cssClassName}}__heading\"><?php echo esc_html( $target_context['heading'] ); ?></h3>\n\t<?php if ( '' !== $target_context['intro'] ) : ?>\n\t\t<p class=\"{{cssClassName}}__intro\"><?php echo esc_html( $target_context['intro'] ); ?></p>\n\t<?php endif; ?>\n\t<p\n\t\tclass=\"{{cssClassName}}__notice\"\n\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\thidden\n\t>\n\t\t<?php echo esc_html( $target_context['noticeMessage'] ); ?>\n\t</p>\n\t<p\n\t\tclass=\"{{cssClassName}}__error\"\n\t\trole=\"status\"\n\t\taria-live=\"polite\"\n\t\taria-atomic=\"true\"\n\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\tdata-wp-text=\"context.error\"\n\t\thidden\n\t></p>\n\t<?php if ( ! empty( $target_context['showCount'] ) ) : ?>\n\t\t<div class=\"{{cssClassName}}__counter\">\n\t\t\t<span\n\t\t\t\tclass=\"{{cssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>0</span>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdisabled\n\t\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t\t>\n\t\t\t\t<?php echo esc_html( $target_context['buttonLabel'] ); ?>\n\t\t\t</button>\n\t\t</div>\n\t<?php endif; ?>\n\t<div class=\"{{cssClassName}}__items\">\n\t\t<?php echo wp_kses_post( $target_context['sanitizedContent'] ); ?>\n\t</div>\n</div>\n\t\t\t\t<?php\n\t\t\t\t$markup = (string) ob_get_clean();\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_markup',\n\t\t\t$markup,\n\t\t\t$target,\n\t\t\t$target_context\n\t\t);\n\t}\n}\n";
8
+ export declare const COMPOUND_PERSISTENCE_RENDER_TARGETS_TEMPLATE = "<?php\n/**\n * Alternate render target helpers for the {{title}} compound parent block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block ) {\n\t\t$validator_path = __DIR__ . '/typia-validator.php';\n\t\tif ( ! file_exists( $validator_path ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$validator = require $validator_path;\n\t\tif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n\t\t$validation = $validator->validate( $normalized );\n\t\t// Preserve the former implicit default only for legacy blocks that omit the key.\n\t\t// Explicitly stored empty keys remain invalid.\n\t\t$resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';\n\t\t$heading = isset( $normalized['heading'] ) ? (string) $normalized['heading'] : {{titlePhpLiteral}};\n\t\t$intro = isset( $normalized['intro'] ) ? (string) $normalized['intro'] : '';\n\t\t$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n\t\t$show_count = ! empty( $normalized['showCount'] );\n\t\t$show_dividers = ! empty( $normalized['showDividers'] );\n\t\t$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t\t\t? (int) $block->context['postId']\n\t\t\t: (int) get_queried_object_id();\n\t\t$storage_mode = '{{dataStorageMode}}';\n\t\t$persistence_policy = '{{persistencePolicy}}';\n\n\t\t$notice_message = 'authenticated' === $persistence_policy\n\t\t\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t\t\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n\n\t\tif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t{{phpPrefix}}_record_rendered_block_instance(\n\t\t\t(int) $post_id,\n\t\t\t'{{namespace}}/{{slugKebabCase}}',\n\t\t\t$resource_key\n\t\t);\n\n\t\t$web_context = array(\n\t\t\t'bootstrapReady' => false,\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'canWrite' => false,\n\t\t\t'client' => array(\n\t\t\t\t'writeExpiry' => 0,\n\t\t\t\t'writeNonce' => '',\n\t\t\t\t'writeToken' => '',\n\t\t\t),\n\t\t\t'count' => 0,\n\t\t\t'error' => '',\n\t\t\t'isBootstrapping' => false,\n\t\t\t'isLoading' => false,\n\t\t\t'isSaving' => false,\n\t\t\t'persistencePolicy' => $persistence_policy,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'showCount' => $show_count,\n\t\t\t'storage' => $storage_mode,\n\t\t);\n\n\t\t$allowed_inner_html = wp_kses_allowed_html( 'post' );\n\n\t\tforeach ( $allowed_inner_html as &$allowed_attributes ) {\n\t\t\tif ( ! is_array( $allowed_attributes ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t$allowed_attributes['data-wp-bind--disabled'] = true;\n\t\t\t$allowed_attributes['data-wp-bind--hidden'] = true;\n\t\t\t$allowed_attributes['data-wp-bind--value'] = true;\n\t\t\t$allowed_attributes['data-wp-class'] = true;\n\t\t\t$allowed_attributes['data-wp-class--active'] = true;\n\t\t\t$allowed_attributes['data-wp-context'] = true;\n\t\t\t$allowed_attributes['data-wp-init'] = true;\n\t\t\t$allowed_attributes['data-wp-interactive'] = true;\n\t\t\t$allowed_attributes['data-wp-on--click'] = true;\n\t\t\t$allowed_attributes['data-wp-on--mouseenter'] = true;\n\t\t\t$allowed_attributes['data-wp-on--mouseleave'] = true;\n\t\t\t$allowed_attributes['data-wp-run--mounted'] = true;\n\t\t\t$allowed_attributes['data-wp-style--width'] = true;\n\t\t\t$allowed_attributes['data-wp-text'] = true;\n\t\t}\n\t\tunset( $allowed_attributes );\n\n\t\treturn array(\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'frontendClassName' => '{{cssClassName}}',\n\t\t\t'heading' => $heading,\n\t\t\t'intro' => $intro,\n\t\t\t'isVisible' => true,\n\t\t\t'normalized' => $normalized,\n\t\t\t'noticeMessage' => $notice_message,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'sanitizedContent' => wp_kses( $content, $allowed_inner_html ),\n\t\t\t'showCount' => $show_count,\n\t\t\t'showDividers' => $show_dividers,\n\t\t\t'title' => {{titleJson}},\n\t\t\t'webContext' => $web_context,\n\t\t);\n\t}\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_render_target' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_render_target( string $target, $attributes, $content = '', $block = null ): string {\n\t\t$context = {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block );\n\t\tif ( null === $context ) {\n\t\t\treturn '';\n\t\t}\n\n\t\t$target_context = apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_context',\n\t\t\t$context,\n\t\t\t$target,\n\t\t\t$attributes,\n\t\t\t$block\n\t\t);\n\n\t\t$markup = '';\n\t\tswitch ( $target ) {\n\t\t\tcase 'email':\n\t\t\t\t$parts = array(\n\t\t\t\t\t'<div class=\"' . esc_attr( $target_context['frontendClassName'] ) . '-email\">',\n\t\t\t\t\t'<h3>' . esc_html( $target_context['heading'] ) . '</h3>',\n\t\t\t\t);\n\t\t\t\tif ( '' !== $target_context['intro'] ) {\n\t\t\t\t\t$parts[] = '<p>' . esc_html( $target_context['intro'] ) . '</p>';\n\t\t\t\t}\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$parts[] = '<p><strong>' . esc_html__( 'Count', '{{textDomain}}' ) . ':</strong> ' . esc_html( (string) $target_context['webContext']['count'] ) . '</p>';\n\t\t\t\t}\n\t\t\t\t$parts[] = wp_kses_post( $target_context['sanitizedContent'] );\n\t\t\t\t$parts[] = '<p>' . esc_html( $target_context['noticeMessage'] ) . '</p>';\n\t\t\t\t$parts[] = '</div>';\n\t\t\t\t$markup = implode( '', $parts );\n\t\t\t\tbreak;\n\t\t\tcase 'mjml':\n\t\t\t\t$markup = '<mjml><mj-body><mj-section><mj-column><mj-text font-weight=\"700\">' . esc_html( $target_context['heading'] ) . '</mj-text>';\n\t\t\t\tif ( '' !== $target_context['intro'] ) {\n\t\t\t\t\t$markup .= '<mj-text>' . esc_html( $target_context['intro'] ) . '</mj-text>';\n\t\t\t\t}\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$markup .= '<mj-text>' . esc_html__( 'Count', '{{textDomain}}' ) . ': ' . esc_html( (string) $target_context['webContext']['count'] ) . '</mj-text>';\n\t\t\t\t}\n\t\t\t\t$markup .= '<mj-text>' . esc_html( wp_strip_all_tags( $target_context['sanitizedContent'] ) ) . '</mj-text>';\n\t\t\t\t$markup .= '<mj-text>' . esc_html( $target_context['noticeMessage'] ) . '</mj-text></mj-column></mj-section></mj-body></mjml>';\n\t\t\t\tbreak;\n\t\t\tcase 'plain-text':\n\t\t\t\t$markup = implode(\n\t\t\t\t\t\"\\n\",\n\t\t\t\t\tarray_filter(\n\t\t\t\t\t\tarray(\n\t\t\t\t\t\t\t$target_context['heading'],\n\t\t\t\t\t\t\t$target_context['intro'],\n\t\t\t\t\t\t\twp_strip_all_tags( $target_context['sanitizedContent'] ),\n\t\t\t\t\t\t\t! empty( $target_context['showCount'] )\n\t\t\t\t\t\t\t\t? sprintf( '%s: %s', __( 'Count', '{{textDomain}}' ), (string) $target_context['webContext']['count'] )\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\t$target_context['noticeMessage'],\n\t\t\t\t\t\t),\n\t\t\t\t\t\tstatic fn( $value ) => is_string( $value ) && '' !== $value\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase 'web':\n\t\t\tdefault:\n\t\t\t\t$wrapper_attributes = get_block_wrapper_attributes(\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'class' => '{{cssClassName}}',\n\t\t\t\t\t\t'data-show-dividers' => $target_context['showDividers'] ? 'true' : 'false',\n\t\t\t\t\t\t'data-wp-context' => wp_json_encode( $target_context['webContext'] ),\n\t\t\t\t\t\t'data-wp-init' => 'callbacks.init',\n\t\t\t\t\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t\t\t\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tob_start();\n\t\t\t\t?>\n<div <?php echo $wrapper_attributes; ?>>\n\t<h3 class=\"{{cssClassName}}__heading\"><?php echo esc_html( $target_context['heading'] ); ?></h3>\n\t<?php if ( '' !== $target_context['intro'] ) : ?>\n\t\t<p class=\"{{cssClassName}}__intro\"><?php echo esc_html( $target_context['intro'] ); ?></p>\n\t<?php endif; ?>\n\t<p\n\t\tclass=\"{{cssClassName}}__notice\"\n\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\thidden\n\t>\n\t\t<?php echo esc_html( $target_context['noticeMessage'] ); ?>\n\t</p>\n\t<p\n\t\tclass=\"{{cssClassName}}__error\"\n\t\trole=\"status\"\n\t\taria-live=\"polite\"\n\t\taria-atomic=\"true\"\n\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\tdata-wp-text=\"context.error\"\n\t\thidden\n\t></p>\n\t<?php if ( ! empty( $target_context['showCount'] ) ) : ?>\n\t\t<div class=\"{{cssClassName}}__counter\">\n\t\t\t<span\n\t\t\t\tclass=\"{{cssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>0</span>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdisabled\n\t\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t\t>\n\t\t\t\t<?php echo esc_html( $target_context['buttonLabel'] ); ?>\n\t\t\t</button>\n\t\t</div>\n\t<?php endif; ?>\n\t<div class=\"{{cssClassName}}__items\">\n\t\t<?php echo wp_kses_post( $target_context['sanitizedContent'] ); ?>\n\t</div>\n</div>\n\t\t\t\t<?php\n\t\t\t\t$markup = (string) ob_get_clean();\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_markup',\n\t\t\t$markup,\n\t\t\t$target,\n\t\t\t$target_context\n\t\t);\n\t}\n}\n";
9
9
  /**
10
10
  * SCSS template for compound parent block styles.
11
11
  *
@@ -20,4 +20,4 @@ export declare const COMPOUND_STYLE_TEMPLATE = ".{{cssClassName}} {\n\tborder: 1
20
20
  * for block identity, namespace, text domain, storage mode, persistence policy,
21
21
  * CSS class names, and PHP-safe title output.
22
22
  */
23
- export declare const COMPOUND_PERSISTENCE_RENDER_TEMPLATE = "<?php\n/**\n * Dynamic render entry for the {{title}} compound parent block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\n$validator_path = __DIR__ . '/typia-validator.php';\nif ( ! file_exists( $validator_path ) ) {\n\treturn '';\n}\n\n$validator = require $validator_path;\nif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\treturn '';\n}\n\n$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n$validation = $validator->validate( $normalized );\n$resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';\n$heading = isset( $normalized['heading'] ) ? (string) $normalized['heading'] : {{titlePhpLiteral}};\n$intro = isset( $normalized['intro'] ) ? (string) $normalized['intro'] : '';\n$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n$show_count = ! empty( $normalized['showCount'] );\n$show_dividers = ! empty( $normalized['showDividers'] );\n$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t? (int) $block->context['postId']\n\t: (int) get_queried_object_id();\n$storage_mode = '{{dataStorageMode}}';\n$persistence_policy = '{{persistencePolicy}}';\n\n$notice_message = 'authenticated' === $persistence_policy\n\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n\nif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\treturn '';\n}\n\n{{phpPrefix}}_record_rendered_block_instance(\n\t(int) $post_id,\n\t'{{namespace}}/{{slugKebabCase}}',\n\t$resource_key\n);\n\n$context = array(\n\t'bootstrapReady' => false,\n\t'buttonLabel' => $button_label,\n\t'canWrite' => false,\n\t'client' => array(\n\t\t'writeExpiry' => 0,\n\t\t'writeNonce' => '',\n\t\t'writeToken' => '',\n\t),\n\t'count' => 0,\n\t'error' => '',\n\t'isBootstrapping' => false,\n\t'isLoading' => false,\n\t'isSaving' => false,\n\t'persistencePolicy' => $persistence_policy,\n\t'postId' => (int) $post_id,\n\t'resourceKey' => $resource_key,\n\t'showCount' => $show_count,\n\t'storage' => $storage_mode,\n);\n\n$allowed_inner_html = wp_kses_allowed_html( 'post' );\n\nforeach ( $allowed_inner_html as &$allowed_attributes ) {\n\tif ( ! is_array( $allowed_attributes ) ) {\n\t\tcontinue;\n\t}\n\n\t$allowed_attributes['data-wp-bind--disabled'] = true;\n\t$allowed_attributes['data-wp-bind--hidden'] = true;\n\t$allowed_attributes['data-wp-bind--value'] = true;\n\t$allowed_attributes['data-wp-class'] = true;\n\t$allowed_attributes['data-wp-class--active'] = true;\n\t$allowed_attributes['data-wp-context'] = true;\n\t$allowed_attributes['data-wp-init'] = true;\n\t$allowed_attributes['data-wp-interactive'] = true;\n\t$allowed_attributes['data-wp-on--click'] = true;\n\t$allowed_attributes['data-wp-on--mouseenter'] = true;\n\t$allowed_attributes['data-wp-on--mouseleave'] = true;\n\t$allowed_attributes['data-wp-run--mounted'] = true;\n\t$allowed_attributes['data-wp-style--width'] = true;\n\t$allowed_attributes['data-wp-text'] = true;\n}\nunset( $allowed_attributes );\n\n$sanitized_content = wp_kses( $content, $allowed_inner_html );\n\n$wrapper_attributes = get_block_wrapper_attributes(\n\tarray(\n\t\t'class' => '{{cssClassName}}',\n\t\t'data-show-dividers' => $show_dividers ? 'true' : 'false',\n\t\t'data-wp-context' => wp_json_encode( $context ),\n\t\t'data-wp-init' => 'callbacks.init',\n\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t)\n);\n?>\n\n<div <?php echo $wrapper_attributes; ?>>\n\t<h3 class=\"{{cssClassName}}__heading\"><?php echo esc_html( $heading ); ?></h3>\n\t<?php if ( '' !== $intro ) : ?>\n\t\t<p class=\"{{cssClassName}}__intro\"><?php echo esc_html( $intro ); ?></p>\n\t<?php endif; ?>\n\t<p\n\t\tclass=\"{{cssClassName}}__notice\"\n\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\thidden\n\t>\n\t\t<?php echo esc_html( $notice_message ); ?>\n\t</p>\n\t<p\n\t\tclass=\"{{cssClassName}}__error\"\n\t\trole=\"status\"\n\t\taria-live=\"polite\"\n\t\taria-atomic=\"true\"\n\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\tdata-wp-text=\"context.error\"\n\t\thidden\n\t></p>\n\t<?php if ( $show_count ) : ?>\n\t\t<div class=\"{{cssClassName}}__counter\">\n\t\t\t<span\n\t\t\t\tclass=\"{{cssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>0</span>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdisabled\n\t\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t\t>\n\t\t\t\t<?php echo esc_html( $button_label ); ?>\n\t\t\t</button>\n\t\t</div>\n\t<?php endif; ?>\n\t<div class=\"{{cssClassName}}__items\">\n\t\t<?php echo $sanitized_content; ?>\n\t</div>\n</div>\n";
23
+ export declare const COMPOUND_PERSISTENCE_RENDER_TEMPLATE = "<?php\n/**\n * Dynamic render entry for the {{title}} compound parent block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\n$validator_path = __DIR__ . '/typia-validator.php';\nif ( ! file_exists( $validator_path ) ) {\n\treturn '';\n}\n\n$validator = require $validator_path;\nif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\treturn '';\n}\n\n$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n$validation = $validator->validate( $normalized );\n// Preserve the former implicit default only for legacy blocks that omit the key.\n// Explicitly stored empty keys remain invalid.\n$resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';\n$heading = isset( $normalized['heading'] ) ? (string) $normalized['heading'] : {{titlePhpLiteral}};\n$intro = isset( $normalized['intro'] ) ? (string) $normalized['intro'] : '';\n$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n$show_count = ! empty( $normalized['showCount'] );\n$show_dividers = ! empty( $normalized['showDividers'] );\n$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t? (int) $block->context['postId']\n\t: (int) get_queried_object_id();\n$storage_mode = '{{dataStorageMode}}';\n$persistence_policy = '{{persistencePolicy}}';\n\n$notice_message = 'authenticated' === $persistence_policy\n\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n\nif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\treturn '';\n}\n\n{{phpPrefix}}_record_rendered_block_instance(\n\t(int) $post_id,\n\t'{{namespace}}/{{slugKebabCase}}',\n\t$resource_key\n);\n\n$context = array(\n\t'bootstrapReady' => false,\n\t'buttonLabel' => $button_label,\n\t'canWrite' => false,\n\t'client' => array(\n\t\t'writeExpiry' => 0,\n\t\t'writeNonce' => '',\n\t\t'writeToken' => '',\n\t),\n\t'count' => 0,\n\t'error' => '',\n\t'isBootstrapping' => false,\n\t'isLoading' => false,\n\t'isSaving' => false,\n\t'persistencePolicy' => $persistence_policy,\n\t'postId' => (int) $post_id,\n\t'resourceKey' => $resource_key,\n\t'showCount' => $show_count,\n\t'storage' => $storage_mode,\n);\n\n$allowed_inner_html = wp_kses_allowed_html( 'post' );\n\nforeach ( $allowed_inner_html as &$allowed_attributes ) {\n\tif ( ! is_array( $allowed_attributes ) ) {\n\t\tcontinue;\n\t}\n\n\t$allowed_attributes['data-wp-bind--disabled'] = true;\n\t$allowed_attributes['data-wp-bind--hidden'] = true;\n\t$allowed_attributes['data-wp-bind--value'] = true;\n\t$allowed_attributes['data-wp-class'] = true;\n\t$allowed_attributes['data-wp-class--active'] = true;\n\t$allowed_attributes['data-wp-context'] = true;\n\t$allowed_attributes['data-wp-init'] = true;\n\t$allowed_attributes['data-wp-interactive'] = true;\n\t$allowed_attributes['data-wp-on--click'] = true;\n\t$allowed_attributes['data-wp-on--mouseenter'] = true;\n\t$allowed_attributes['data-wp-on--mouseleave'] = true;\n\t$allowed_attributes['data-wp-run--mounted'] = true;\n\t$allowed_attributes['data-wp-style--width'] = true;\n\t$allowed_attributes['data-wp-text'] = true;\n}\nunset( $allowed_attributes );\n\n$sanitized_content = wp_kses( $content, $allowed_inner_html );\n\n$wrapper_attributes = get_block_wrapper_attributes(\n\tarray(\n\t\t'class' => '{{cssClassName}}',\n\t\t'data-show-dividers' => $show_dividers ? 'true' : 'false',\n\t\t'data-wp-context' => wp_json_encode( $context ),\n\t\t'data-wp-init' => 'callbacks.init',\n\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t)\n);\n?>\n\n<div <?php echo $wrapper_attributes; ?>>\n\t<h3 class=\"{{cssClassName}}__heading\"><?php echo esc_html( $heading ); ?></h3>\n\t<?php if ( '' !== $intro ) : ?>\n\t\t<p class=\"{{cssClassName}}__intro\"><?php echo esc_html( $intro ); ?></p>\n\t<?php endif; ?>\n\t<p\n\t\tclass=\"{{cssClassName}}__notice\"\n\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\thidden\n\t>\n\t\t<?php echo esc_html( $notice_message ); ?>\n\t</p>\n\t<p\n\t\tclass=\"{{cssClassName}}__error\"\n\t\trole=\"status\"\n\t\taria-live=\"polite\"\n\t\taria-atomic=\"true\"\n\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\tdata-wp-text=\"context.error\"\n\t\thidden\n\t></p>\n\t<?php if ( $show_count ) : ?>\n\t\t<div class=\"{{cssClassName}}__counter\">\n\t\t\t<span\n\t\t\t\tclass=\"{{cssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>0</span>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdisabled\n\t\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t\t>\n\t\t\t\t<?php echo esc_html( $button_label ); ?>\n\t\t\t</button>\n\t\t</div>\n\t<?php endif; ?>\n\t<div class=\"{{cssClassName}}__items\">\n\t\t<?php echo $sanitized_content; ?>\n\t</div>\n</div>\n";
@@ -30,7 +30,9 @@ if ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' )
30
30
 
31
31
  $normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );
32
32
  $validation = $validator->validate( $normalized );
33
- $resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';
33
+ // Preserve the former implicit default only for legacy blocks that omit the key.
34
+ // Explicitly stored empty keys remain invalid.
35
+ $resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';
34
36
  $heading = isset( $normalized['heading'] ) ? (string) $normalized['heading'] : {{titlePhpLiteral}};
35
37
  $intro = isset( $normalized['intro'] ) ? (string) $normalized['intro'] : '';
36
38
  $button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';
@@ -321,7 +323,9 @@ if ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults'
321
323
 
322
324
  $normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );
323
325
  $validation = $validator->validate( $normalized );
324
- $resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';
326
+ // Preserve the former implicit default only for legacy blocks that omit the key.
327
+ // Explicitly stored empty keys remain invalid.
328
+ $resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';
325
329
  $heading = isset( $normalized['heading'] ) ? (string) $normalized['heading'] : {{titlePhpLiteral}};
326
330
  $intro = isset( $normalized['intro'] ) ? (string) $normalized['intro'] : '';
327
331
  $button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';
@@ -12,7 +12,7 @@ export declare const PERSISTENCE_STYLE_TEMPLATE = ".{{cssClassName}} {\n\tborder
12
12
  * placeholders for block identity, namespace, text domain, storage mode,
13
13
  * persistence policy, and frontend CSS class names.
14
14
  */
15
- export declare const PERSISTENCE_RENDER_TEMPLATE = "<?php\n/**\n * Dynamic render entry for the {{title}} block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\n$validator_path = __DIR__ . '/typia-validator.php';\nif ( ! file_exists( $validator_path ) ) {\n\treturn '';\n}\n\n$validator = require $validator_path;\nif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\treturn '';\n}\n\n$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n$validation = $validator->validate( $normalized );\n$resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';\n\nif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\treturn '';\n}\n\n$alignment = isset( $normalized['alignment'] ) ? (string) $normalized['alignment'] : 'left';\n$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n$content = isset( $normalized['content'] ) ? (string) $normalized['content'] : '';\n$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t? (int) $block->context['postId']\n\t: (int) get_queried_object_id();\n$storage_mode = '{{dataStorageMode}}';\n$persistence_policy = '{{persistencePolicy}}';\n\n{{phpPrefix}}_record_rendered_block_instance(\n\t(int) $post_id,\n\t'{{namespace}}/{{slugKebabCase}}',\n\t$resource_key\n);\n\n$notice_message = 'authenticated' === $persistence_policy\n\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n$context = array(\n\t'bootstrapReady' => false,\n\t'buttonLabel' => $button_label,\n\t'canWrite' => false,\n\t'client' => array(\n\t\t'writeExpiry' => 0,\n\t\t'writeNonce' => '',\n\t\t'writeToken' => '',\n\t),\n\t'count' => 0,\n\t'error' => '',\n\t'isBootstrapping' => false,\n\t'isLoading' => false,\n\t'isSaving' => false,\n\t'isVisible' => ! empty( $normalized['isVisible'] ),\n\t'persistencePolicy' => $persistence_policy,\n\t'postId' => (int) $post_id,\n\t'resourceKey' => $resource_key,\n\t'storage' => $storage_mode,\n);\n\n$wrapper_attributes = get_block_wrapper_attributes(\n\tarray(\n\t\t'data-wp-context' => wp_json_encode( $context ),\n\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t'data-wp-init' => 'callbacks.init',\n\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t)\n);\n?>\n\n<div <?php echo $wrapper_attributes; ?>>\n\t<div class=\"{{frontendCssClassName}}\">\n\t\t<p class=\"{{frontendCssClassName}}__content\" style=\"<?php echo esc_attr( 'text-align:' . $alignment ); ?>\">\n\t\t\t<?php echo esc_html( $content ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__notice\"\n\t\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\t\thidden\n\t\t>\n\t\t\t<?php echo esc_html( $notice_message ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__error\"\n\t\t\trole=\"status\"\n\t\t\taria-live=\"polite\"\n\t\t\taria-atomic=\"true\"\n\t\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\t\tdata-wp-text=\"context.error\"\n\t\t\thidden\n\t\t></p>\n\t\t<?php if ( ! empty( $normalized['showCount'] ) ) : ?>\n\t\t\t<span\n\t\t\t\tclass=\"{{frontendCssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>\n\t\t\t\t0\n\t\t\t</span>\n\t\t<?php endif; ?>\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdisabled\n\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t>\n\t\t\t<?php echo esc_html( $button_label ); ?>\n\t\t</button>\n\t</div>\n</div>\n";
15
+ export declare const PERSISTENCE_RENDER_TEMPLATE = "<?php\n/**\n * Dynamic render entry for the {{title}} block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\n$validator_path = __DIR__ . '/typia-validator.php';\nif ( ! file_exists( $validator_path ) ) {\n\treturn '';\n}\n\n$validator = require $validator_path;\nif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\treturn '';\n}\n\n$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n$validation = $validator->validate( $normalized );\n// Preserve the former implicit default only for legacy blocks that omit the key.\n// Explicitly stored empty keys remain invalid.\n$resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';\n\nif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\treturn '';\n}\n\n$alignment = isset( $normalized['alignment'] ) ? (string) $normalized['alignment'] : 'left';\n$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n$content = isset( $normalized['content'] ) ? (string) $normalized['content'] : '';\n$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t? (int) $block->context['postId']\n\t: (int) get_queried_object_id();\n$storage_mode = '{{dataStorageMode}}';\n$persistence_policy = '{{persistencePolicy}}';\n\n{{phpPrefix}}_record_rendered_block_instance(\n\t(int) $post_id,\n\t'{{namespace}}/{{slugKebabCase}}',\n\t$resource_key\n);\n\n$notice_message = 'authenticated' === $persistence_policy\n\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n$context = array(\n\t'bootstrapReady' => false,\n\t'buttonLabel' => $button_label,\n\t'canWrite' => false,\n\t'client' => array(\n\t\t'writeExpiry' => 0,\n\t\t'writeNonce' => '',\n\t\t'writeToken' => '',\n\t),\n\t'count' => 0,\n\t'error' => '',\n\t'isBootstrapping' => false,\n\t'isLoading' => false,\n\t'isSaving' => false,\n\t'isVisible' => ! empty( $normalized['isVisible'] ),\n\t'persistencePolicy' => $persistence_policy,\n\t'postId' => (int) $post_id,\n\t'resourceKey' => $resource_key,\n\t'storage' => $storage_mode,\n);\n\n$wrapper_attributes = get_block_wrapper_attributes(\n\tarray(\n\t\t'data-wp-context' => wp_json_encode( $context ),\n\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t'data-wp-init' => 'callbacks.init',\n\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t)\n);\n?>\n\n<div <?php echo $wrapper_attributes; ?>>\n\t<div class=\"{{frontendCssClassName}}\">\n\t\t<p class=\"{{frontendCssClassName}}__content\" style=\"<?php echo esc_attr( 'text-align:' . $alignment ); ?>\">\n\t\t\t<?php echo esc_html( $content ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__notice\"\n\t\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\t\thidden\n\t\t>\n\t\t\t<?php echo esc_html( $notice_message ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__error\"\n\t\t\trole=\"status\"\n\t\t\taria-live=\"polite\"\n\t\t\taria-atomic=\"true\"\n\t\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\t\tdata-wp-text=\"context.error\"\n\t\t\thidden\n\t\t></p>\n\t\t<?php if ( ! empty( $normalized['showCount'] ) ) : ?>\n\t\t\t<span\n\t\t\t\tclass=\"{{frontendCssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>\n\t\t\t\t0\n\t\t\t</span>\n\t\t<?php endif; ?>\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdisabled\n\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t>\n\t\t\t<?php echo esc_html( $button_label ); ?>\n\t\t</button>\n\t</div>\n</div>\n";
16
16
  /**
17
17
  * PHP helper template for persistence alternate render targets.
18
18
  *
@@ -20,4 +20,4 @@ export declare const PERSISTENCE_RENDER_TEMPLATE = "<?php\n/**\n * Dynamic rende
20
20
  * plain-text, and web render entries with block identity, namespace, text
21
21
  * domain, storage, policy, frontend class, and title placeholders.
22
22
  */
23
- export declare const PERSISTENCE_RENDER_TARGETS_TEMPLATE = "<?php\n/**\n * Alternate render target helpers for the {{title}} block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block ) {\n\t\t$validator_path = __DIR__ . '/typia-validator.php';\n\t\tif ( ! file_exists( $validator_path ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$validator = require $validator_path;\n\t\tif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n\t\t$validation = $validator->validate( $normalized );\n\t\t$resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';\n\n\t\tif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$alignment = isset( $normalized['alignment'] ) ? (string) $normalized['alignment'] : 'left';\n\t\t$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n\t\t$rendered_content = isset( $normalized['content'] ) ? (string) $normalized['content'] : '';\n\t\t$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t\t\t? (int) $block->context['postId']\n\t\t\t: (int) get_queried_object_id();\n\t\t$storage_mode = '{{dataStorageMode}}';\n\t\t$persistence_policy = '{{persistencePolicy}}';\n\n\t\t{{phpPrefix}}_record_rendered_block_instance(\n\t\t\t(int) $post_id,\n\t\t\t'{{namespace}}/{{slugKebabCase}}',\n\t\t\t$resource_key\n\t\t);\n\n\t\t$notice_message = 'authenticated' === $persistence_policy\n\t\t\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t\t\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n\t\t$web_context = array(\n\t\t\t'bootstrapReady' => false,\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'canWrite' => false,\n\t\t\t'client' => array(\n\t\t\t\t'writeExpiry' => 0,\n\t\t\t\t'writeNonce' => '',\n\t\t\t\t'writeToken' => '',\n\t\t\t),\n\t\t\t'count' => 0,\n\t\t\t'error' => '',\n\t\t\t'isBootstrapping' => false,\n\t\t\t'isLoading' => false,\n\t\t\t'isSaving' => false,\n\t\t\t'isVisible' => ! empty( $normalized['isVisible'] ),\n\t\t\t'persistencePolicy' => $persistence_policy,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'storage' => $storage_mode,\n\t\t);\n\n\t\treturn array(\n\t\t\t'alignment' => $alignment,\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'content' => $rendered_content,\n\t\t\t'frontendClassName' => '{{frontendCssClassName}}',\n\t\t\t'isVisible' => ! empty( $normalized['isVisible'] ),\n\t\t\t'normalized' => $normalized,\n\t\t\t'noticeMessage' => $notice_message,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'showCount' => ! empty( $normalized['showCount'] ),\n\t\t\t'title' => {{titleJson}},\n\t\t\t'webContext' => $web_context,\n\t\t);\n\t}\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_render_target' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_render_target( string $target, $attributes, $content = '', $block = null ): string {\n\t\t$context = {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block );\n\t\tif ( null === $context || empty( $context['isVisible'] ) ) {\n\t\t\treturn '';\n\t\t}\n\n\t\t$target_context = apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_context',\n\t\t\t$context,\n\t\t\t$target,\n\t\t\t$attributes,\n\t\t\t$block\n\t\t);\n\n\t\t$markup = '';\n\t\tswitch ( $target ) {\n\t\t\tcase 'email':\n\t\t\t\t$parts = array(\n\t\t\t\t\t'<div class=\"' . esc_attr( $target_context['frontendClassName'] ) . '-email\">',\n\t\t\t\t\t'<p style=\"text-align:' . esc_attr( $target_context['alignment'] ) . ';\">' . esc_html( $target_context['content'] ) . '</p>',\n\t\t\t\t);\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$parts[] = '<p><strong>' . esc_html__( 'Count', '{{textDomain}}' ) . ':</strong> ' . esc_html( (string) $target_context['webContext']['count'] ) . '</p>';\n\t\t\t\t}\n\t\t\t\t$parts[] = '<p>' . esc_html( $target_context['noticeMessage'] ) . '</p>';\n\t\t\t\t$parts[] = '</div>';\n\t\t\t\t$markup = implode( '', $parts );\n\t\t\t\tbreak;\n\t\t\tcase 'mjml':\n\t\t\t\t$markup = '<mjml><mj-body><mj-section><mj-column><mj-text align=\"' . esc_attr( $target_context['alignment'] ) . '\">' . esc_html( $target_context['content'] ) . '</mj-text>';\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$markup .= '<mj-text>' . esc_html__( 'Count', '{{textDomain}}' ) . ': ' . esc_html( (string) $target_context['webContext']['count'] ) . '</mj-text>';\n\t\t\t\t}\n\t\t\t\t$markup .= '<mj-text>' . esc_html( $target_context['noticeMessage'] ) . '</mj-text></mj-column></mj-section></mj-body></mjml>';\n\t\t\t\tbreak;\n\t\t\tcase 'plain-text':\n\t\t\t\t$markup = implode(\n\t\t\t\t\t\"\\n\",\n\t\t\t\t\tarray_filter(\n\t\t\t\t\t\tarray(\n\t\t\t\t\t\t\t$target_context['title'],\n\t\t\t\t\t\t\t$target_context['content'],\n\t\t\t\t\t\t\t! empty( $target_context['showCount'] )\n\t\t\t\t\t\t\t\t? sprintf( '%s: %s', __( 'Count', '{{textDomain}}' ), (string) $target_context['webContext']['count'] )\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\t$target_context['noticeMessage'],\n\t\t\t\t\t\t),\n\t\t\t\t\t\tstatic fn( $value ) => is_string( $value ) && '' !== $value\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase 'web':\n\t\t\tdefault:\n\t\t\t\t$wrapper_attributes = get_block_wrapper_attributes(\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'data-wp-context' => wp_json_encode( $target_context['webContext'] ),\n\t\t\t\t\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t\t\t\t\t'data-wp-init' => 'callbacks.init',\n\t\t\t\t\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tob_start();\n\t\t\t\t?>\n<div <?php echo $wrapper_attributes; ?>>\n\t<div class=\"{{frontendCssClassName}}\">\n\t\t<p class=\"{{frontendCssClassName}}__content\" style=\"<?php echo esc_attr( 'text-align:' . $target_context['alignment'] ); ?>\">\n\t\t\t<?php echo esc_html( $target_context['content'] ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__notice\"\n\t\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\t\thidden\n\t\t>\n\t\t\t<?php echo esc_html( $target_context['noticeMessage'] ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__error\"\n\t\t\trole=\"status\"\n\t\t\taria-live=\"polite\"\n\t\t\taria-atomic=\"true\"\n\t\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\t\tdata-wp-text=\"context.error\"\n\t\t\thidden\n\t\t></p>\n\t\t<?php if ( ! empty( $target_context['showCount'] ) ) : ?>\n\t\t\t<span\n\t\t\t\tclass=\"{{frontendCssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>\n\t\t\t\t0\n\t\t\t</span>\n\t\t<?php endif; ?>\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdisabled\n\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t>\n\t\t\t<?php echo esc_html( $target_context['buttonLabel'] ); ?>\n\t\t</button>\n\t</div>\n</div>\n\t\t\t\t<?php\n\t\t\t\t$markup = (string) ob_get_clean();\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_markup',\n\t\t\t$markup,\n\t\t\t$target,\n\t\t\t$target_context\n\t\t);\n\t}\n}\n";
23
+ export declare const PERSISTENCE_RENDER_TARGETS_TEMPLATE = "<?php\n/**\n * Alternate render target helpers for the {{title}} block.\n *\n * @package {{pascalCase}}\n */\n\nif ( ! defined( 'ABSPATH' ) ) {\n\texit;\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block ) {\n\t\t$validator_path = __DIR__ . '/typia-validator.php';\n\t\tif ( ! file_exists( $validator_path ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$validator = require $validator_path;\n\t\tif ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );\n\t\t$validation = $validator->validate( $normalized );\n\t\t// Preserve the former implicit default only for legacy blocks that omit the key.\n\t\t// Explicitly stored empty keys remain invalid.\n\t\t$resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';\n\n\t\tif ( empty( $validation['valid'] ) || '' === $resource_key ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t$alignment = isset( $normalized['alignment'] ) ? (string) $normalized['alignment'] : 'left';\n\t\t$button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';\n\t\t$rendered_content = isset( $normalized['content'] ) ? (string) $normalized['content'] : '';\n\t\t$post_id = is_object( $block ) && isset( $block->context['postId'] )\n\t\t\t? (int) $block->context['postId']\n\t\t\t: (int) get_queried_object_id();\n\t\t$storage_mode = '{{dataStorageMode}}';\n\t\t$persistence_policy = '{{persistencePolicy}}';\n\n\t\t{{phpPrefix}}_record_rendered_block_instance(\n\t\t\t(int) $post_id,\n\t\t\t'{{namespace}}/{{slugKebabCase}}',\n\t\t\t$resource_key\n\t\t);\n\n\t\t$notice_message = 'authenticated' === $persistence_policy\n\t\t\t? __( 'Sign in to persist this counter.', '{{textDomain}}' )\n\t\t\t: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );\n\t\t$web_context = array(\n\t\t\t'bootstrapReady' => false,\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'canWrite' => false,\n\t\t\t'client' => array(\n\t\t\t\t'writeExpiry' => 0,\n\t\t\t\t'writeNonce' => '',\n\t\t\t\t'writeToken' => '',\n\t\t\t),\n\t\t\t'count' => 0,\n\t\t\t'error' => '',\n\t\t\t'isBootstrapping' => false,\n\t\t\t'isLoading' => false,\n\t\t\t'isSaving' => false,\n\t\t\t'isVisible' => ! empty( $normalized['isVisible'] ),\n\t\t\t'persistencePolicy' => $persistence_policy,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'storage' => $storage_mode,\n\t\t);\n\n\t\treturn array(\n\t\t\t'alignment' => $alignment,\n\t\t\t'buttonLabel' => $button_label,\n\t\t\t'content' => $rendered_content,\n\t\t\t'frontendClassName' => '{{frontendCssClassName}}',\n\t\t\t'isVisible' => ! empty( $normalized['isVisible'] ),\n\t\t\t'normalized' => $normalized,\n\t\t\t'noticeMessage' => $notice_message,\n\t\t\t'postId' => (int) $post_id,\n\t\t\t'resourceKey' => $resource_key,\n\t\t\t'showCount' => ! empty( $normalized['showCount'] ),\n\t\t\t'title' => {{titleJson}},\n\t\t\t'webContext' => $web_context,\n\t\t);\n\t}\n}\n\nif ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_render_target' ) ) {\n\tfunction {{phpPrefix}}_{{slugSnakeCase}}_render_target( string $target, $attributes, $content = '', $block = null ): string {\n\t\t$context = {{phpPrefix}}_{{slugSnakeCase}}_build_render_context( $attributes, $content, $block );\n\t\tif ( null === $context || empty( $context['isVisible'] ) ) {\n\t\t\treturn '';\n\t\t}\n\n\t\t$target_context = apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_context',\n\t\t\t$context,\n\t\t\t$target,\n\t\t\t$attributes,\n\t\t\t$block\n\t\t);\n\n\t\t$markup = '';\n\t\tswitch ( $target ) {\n\t\t\tcase 'email':\n\t\t\t\t$parts = array(\n\t\t\t\t\t'<div class=\"' . esc_attr( $target_context['frontendClassName'] ) . '-email\">',\n\t\t\t\t\t'<p style=\"text-align:' . esc_attr( $target_context['alignment'] ) . ';\">' . esc_html( $target_context['content'] ) . '</p>',\n\t\t\t\t);\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$parts[] = '<p><strong>' . esc_html__( 'Count', '{{textDomain}}' ) . ':</strong> ' . esc_html( (string) $target_context['webContext']['count'] ) . '</p>';\n\t\t\t\t}\n\t\t\t\t$parts[] = '<p>' . esc_html( $target_context['noticeMessage'] ) . '</p>';\n\t\t\t\t$parts[] = '</div>';\n\t\t\t\t$markup = implode( '', $parts );\n\t\t\t\tbreak;\n\t\t\tcase 'mjml':\n\t\t\t\t$markup = '<mjml><mj-body><mj-section><mj-column><mj-text align=\"' . esc_attr( $target_context['alignment'] ) . '\">' . esc_html( $target_context['content'] ) . '</mj-text>';\n\t\t\t\tif ( ! empty( $target_context['showCount'] ) ) {\n\t\t\t\t\t$markup .= '<mj-text>' . esc_html__( 'Count', '{{textDomain}}' ) . ': ' . esc_html( (string) $target_context['webContext']['count'] ) . '</mj-text>';\n\t\t\t\t}\n\t\t\t\t$markup .= '<mj-text>' . esc_html( $target_context['noticeMessage'] ) . '</mj-text></mj-column></mj-section></mj-body></mjml>';\n\t\t\t\tbreak;\n\t\t\tcase 'plain-text':\n\t\t\t\t$markup = implode(\n\t\t\t\t\t\"\\n\",\n\t\t\t\t\tarray_filter(\n\t\t\t\t\t\tarray(\n\t\t\t\t\t\t\t$target_context['title'],\n\t\t\t\t\t\t\t$target_context['content'],\n\t\t\t\t\t\t\t! empty( $target_context['showCount'] )\n\t\t\t\t\t\t\t\t? sprintf( '%s: %s', __( 'Count', '{{textDomain}}' ), (string) $target_context['webContext']['count'] )\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\t$target_context['noticeMessage'],\n\t\t\t\t\t\t),\n\t\t\t\t\t\tstatic fn( $value ) => is_string( $value ) && '' !== $value\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase 'web':\n\t\t\tdefault:\n\t\t\t\t$wrapper_attributes = get_block_wrapper_attributes(\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'data-wp-context' => wp_json_encode( $target_context['webContext'] ),\n\t\t\t\t\t\t'data-wp-interactive' => '{{slugKebabCase}}',\n\t\t\t\t\t\t'data-wp-init' => 'callbacks.init',\n\t\t\t\t\t\t'data-wp-run--mounted' => 'callbacks.mounted',\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tob_start();\n\t\t\t\t?>\n<div <?php echo $wrapper_attributes; ?>>\n\t<div class=\"{{frontendCssClassName}}\">\n\t\t<p class=\"{{frontendCssClassName}}__content\" style=\"<?php echo esc_attr( 'text-align:' . $target_context['alignment'] ); ?>\">\n\t\t\t<?php echo esc_html( $target_context['content'] ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__notice\"\n\t\t\tdata-wp-bind--hidden=\"!context.bootstrapReady || context.canWrite\"\n\t\t\thidden\n\t\t>\n\t\t\t<?php echo esc_html( $target_context['noticeMessage'] ); ?>\n\t\t</p>\n\t\t<p\n\t\t\tclass=\"{{frontendCssClassName}}__error\"\n\t\t\trole=\"status\"\n\t\t\taria-live=\"polite\"\n\t\t\taria-atomic=\"true\"\n\t\t\tdata-wp-bind--hidden=\"!context.error\"\n\t\t\tdata-wp-text=\"context.error\"\n\t\t\thidden\n\t\t></p>\n\t\t<?php if ( ! empty( $target_context['showCount'] ) ) : ?>\n\t\t\t<span\n\t\t\t\tclass=\"{{frontendCssClassName}}__count\"\n\t\t\t\trole=\"status\"\n\t\t\t\taria-live=\"polite\"\n\t\t\t\taria-atomic=\"true\"\n\t\t\t\tdata-wp-text=\"context.count\"\n\t\t\t>\n\t\t\t\t0\n\t\t\t</span>\n\t\t<?php endif; ?>\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdisabled\n\t\t\tdata-wp-bind--disabled=\"!context.canWrite\"\n\t\t\tdata-wp-on--click=\"actions.increment\"\n\t\t>\n\t\t\t<?php echo esc_html( $target_context['buttonLabel'] ); ?>\n\t\t</button>\n\t</div>\n</div>\n\t\t\t\t<?php\n\t\t\t\t$markup = (string) ob_get_clean();\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn apply_filters(\n\t\t\t'{{phpPrefix}}_{{slugSnakeCase}}_render_target_markup',\n\t\t\t$markup,\n\t\t\t$target,\n\t\t\t$target_context\n\t\t);\n\t}\n}\n";
@@ -81,7 +81,9 @@ if ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults'
81
81
 
82
82
  $normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );
83
83
  $validation = $validator->validate( $normalized );
84
- $resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';
84
+ // Preserve the former implicit default only for legacy blocks that omit the key.
85
+ // Explicitly stored empty keys remain invalid.
86
+ $resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';
85
87
 
86
88
  if ( empty( $validation['valid'] ) || '' === $resource_key ) {
87
89
  return '';
@@ -211,7 +213,9 @@ if ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' )
211
213
 
212
214
  $normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );
213
215
  $validation = $validator->validate( $normalized );
214
- $resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';
216
+ // Preserve the former implicit default only for legacy blocks that omit the key.
217
+ // Explicitly stored empty keys remain invalid.
218
+ $resource_key = array_key_exists( 'resourceKey', $normalized ) ? (string) $normalized['resourceKey'] : 'primary';
215
219
 
216
220
  if ( empty( $validation['valid'] ) || '' === $resource_key ) {
217
221
  return null;
@@ -15,7 +15,9 @@ export interface ScaffoldDryRunPlan {
15
15
  */
16
16
  dependencyInstall: "skipped-by-flag" | "would-install";
17
17
  /**
18
- * Sorted project-relative paths that would be written by the scaffold.
18
+ * Sorted project-relative paths guaranteed by the selected scaffold flags.
19
+ * Compiler-derived paths are omitted with --no-install because their
20
+ * availability then depends on the caller's local generator dependencies.
19
21
  */
20
22
  files: string[];
21
23
  }
@@ -83,6 +85,10 @@ export interface ScaffoldEmissionOptions {
83
85
  * Absolute target directory for the generated project.
84
86
  */
85
87
  projectDir: string;
88
+ /**
89
+ * Internal preview control for compiler-backed metadata and REST seeding.
90
+ */
91
+ seedCompilerArtifacts?: boolean;
86
92
  /**
87
93
  * Resolved template id or external template locator to render.
88
94
  */
@@ -1,6 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { assertDryRunTargetDirectoryReady, listRelativeProjectFiles, } from "./cli-scaffold-files.js";
3
3
  import { scaffoldProject } from "./scaffold.js";
4
+ import { collectBuiltInCompilerArtifactPaths } from "./scaffold-compiler-artifacts.js";
4
5
  import { createManagedTempRoot } from "../shared/temp-roots.js";
5
6
  /**
6
7
  * Emit scaffold files into the target project directory.
@@ -27,8 +28,16 @@ export async function buildScaffoldDryRunPlan(options) {
27
28
  allowExistingDir: false,
28
29
  noInstall: true,
29
30
  projectDir: previewProjectDir,
31
+ seedCompilerArtifacts: false,
30
32
  });
31
- const files = await listRelativeProjectFiles(previewProjectDir);
33
+ const files = [
34
+ ...new Set([
35
+ ...(await listRelativeProjectFiles(previewProjectDir)),
36
+ ...(options.noInstall
37
+ ? []
38
+ : collectBuiltInCompilerArtifactPaths(result.templateId, result.variables)),
39
+ ]),
40
+ ].sort((left, right) => left.localeCompare(right));
32
41
  return {
33
42
  plan: {
34
43
  dependencyInstall: options.noInstall
@@ -1,5 +1,52 @@
1
1
  import { getTemplateById, getTemplateSelectOptions, isBuiltInTemplateId, listTemplates } from "./template-registry.js";
2
2
  import type { TemplateDefinition } from "./template-registry.js";
3
+ /**
4
+ * Stable logical source metadata exposed by structured template discovery.
5
+ *
6
+ * Filesystem paths remain an internal implementation detail used to render a
7
+ * template. CLI consumers receive a built-in id or official package locator
8
+ * instead, so output is reproducible across npm caches and worktrees.
9
+ */
10
+ export type CliTemplateSource = {
11
+ kind: "built-in";
12
+ id: string;
13
+ } | {
14
+ kind: "npm";
15
+ packageName: string;
16
+ alias: string;
17
+ };
18
+ /** Public template metadata returned by `templates ... --format json`. */
19
+ export interface CliTemplateMetadata {
20
+ id: string;
21
+ description: string;
22
+ defaultCategory: string;
23
+ features: string[];
24
+ source: CliTemplateSource;
25
+ }
26
+ /**
27
+ * Converts internal template registry metadata into a portable CLI payload.
28
+ *
29
+ * @param template Internal template definition used for scaffold resolution.
30
+ * @returns Stable public metadata without the installation-local template directory.
31
+ */
32
+ export declare function toCliTemplateMetadata(template: TemplateDefinition): CliTemplateMetadata;
33
+ /** Returns all registered templates as portable structured-output metadata. */
34
+ export declare function listCliTemplateMetadata(): readonly CliTemplateMetadata[];
35
+ /**
36
+ * Finds one registered template as portable structured-output metadata.
37
+ *
38
+ * @param templateId Built-in id, official package name, or workspace alias.
39
+ * @returns Stable public metadata, or `undefined` when the id is not registered.
40
+ */
41
+ export declare function findCliTemplateMetadata(templateId: string): CliTemplateMetadata | undefined;
42
+ /**
43
+ * Resolves one registered template as portable structured-output metadata.
44
+ *
45
+ * @param templateId Built-in id, official package name, or workspace alias.
46
+ * @returns Stable public metadata for the requested template.
47
+ * @throws {Error} When the id does not match a registered template or alias.
48
+ */
49
+ export declare function getCliTemplateMetadata(templateId: string): CliTemplateMetadata;
3
50
  /**
4
51
  * Format one line of template list output for a built-in template.
5
52
  *
@@ -1,4 +1,53 @@
1
- import { OFFICIAL_WORKSPACE_TEMPLATE_ALIAS, OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, getUserFacingTemplateId, getTemplateById, getTemplateSelectOptions, isBuiltInTemplateId, listTemplates, } from "./template-registry.js";
1
+ import { OFFICIAL_WORKSPACE_TEMPLATE_ALIAS, OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, getUserFacingTemplateId, getTemplateById, getTemplateSelectOptions, isBuiltInTemplateId, listTemplates, normalizeTemplateLookupId, } from "./template-registry.js";
2
+ /**
3
+ * Converts internal template registry metadata into a portable CLI payload.
4
+ *
5
+ * @param template Internal template definition used for scaffold resolution.
6
+ * @returns Stable public metadata without the installation-local template directory.
7
+ */
8
+ export function toCliTemplateMetadata(template) {
9
+ return {
10
+ id: template.id,
11
+ description: template.description,
12
+ defaultCategory: template.defaultCategory,
13
+ features: [...template.features],
14
+ source: isBuiltInTemplateId(template.id)
15
+ ? {
16
+ kind: "built-in",
17
+ id: template.id,
18
+ }
19
+ : {
20
+ kind: "npm",
21
+ packageName: OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE,
22
+ alias: OFFICIAL_WORKSPACE_TEMPLATE_ALIAS,
23
+ },
24
+ };
25
+ }
26
+ /** Returns all registered templates as portable structured-output metadata. */
27
+ export function listCliTemplateMetadata() {
28
+ return listTemplates().map(toCliTemplateMetadata);
29
+ }
30
+ /**
31
+ * Finds one registered template as portable structured-output metadata.
32
+ *
33
+ * @param templateId Built-in id, official package name, or workspace alias.
34
+ * @returns Stable public metadata, or `undefined` when the id is not registered.
35
+ */
36
+ export function findCliTemplateMetadata(templateId) {
37
+ const normalizedTemplateId = normalizeTemplateLookupId(templateId);
38
+ const template = listTemplates().find((entry) => entry.id === normalizedTemplateId);
39
+ return template ? toCliTemplateMetadata(template) : undefined;
40
+ }
41
+ /**
42
+ * Resolves one registered template as portable structured-output metadata.
43
+ *
44
+ * @param templateId Built-in id, official package name, or workspace alias.
45
+ * @returns Stable public metadata for the requested template.
46
+ * @throws {Error} When the id does not match a registered template or alias.
47
+ */
48
+ export function getCliTemplateMetadata(templateId) {
49
+ return toCliTemplateMetadata(getTemplateById(templateId));
50
+ }
2
51
  /**
3
52
  * Format one line of template list output for a built-in template.
4
53
  *
@@ -52,7 +52,7 @@ function getDevScript(packageManager, compoundPersistenceEnabled, templateId) {
52
52
  syncProcesses.push(`"${formatRunScript(packageManager, "start:editor")}"`);
53
53
  names.push("editor");
54
54
  colors.push("blue");
55
- return `concurrently -k -n ${names.join(",")} -c ${colors.join(",")} ${syncProcesses.join(" ")}`;
55
+ return `${formatRunScript(packageManager, "sync")} && concurrently -k -n ${names.join(",")} -c ${colors.join(",")} ${syncProcesses.join(" ")}`;
56
56
  }
57
57
  async function mutatePackageJson(projectDir, mutate) {
58
58
  const packageJsonPath = path.join(projectDir, "package.json");
@@ -1,7 +1,7 @@
1
1
  import { type BuiltInBlockArtifact } from "./built-in-block-artifacts.js";
2
2
  import type { BuiltInCodeArtifact } from "./built-in-block-code-artifacts.js";
3
3
  import { type BuiltInTemplateId } from "./template-registry.js";
4
- import type { PackageManagerId } from "../shared/package-managers.js";
4
+ import { type PackageManagerId } from "../shared/package-managers.js";
5
5
  export { applyWorkspaceMigrationCapability, isOfficialWorkspaceProject, } from "./scaffold-bootstrap.js";
6
6
  import type { ScaffoldProgressEvent, ScaffoldTemplateVariables } from "./scaffold.js";
7
7
  export { buildGitignore, buildReadme, mergeTextLines } from "./scaffold-documents.js";
@@ -11,11 +11,6 @@ export interface InstallDependenciesOptions {
11
11
  }
12
12
  export declare function ensureDirectory(targetDir: string, allowExisting?: boolean): Promise<void>;
13
13
  export declare function writeStarterManifestFiles(targetDir: string, templateId: string, variables: ScaffoldTemplateVariables, artifacts?: readonly BuiltInBlockArtifact[]): Promise<void>;
14
- /**
15
- * Seed REST-derived persistence artifacts into a newly scaffolded built-in
16
- * project before the first manual `sync-rest` run.
17
- */
18
- export declare function seedBuiltInPersistenceArtifacts(targetDir: string, templateId: BuiltInTemplateId, variables: ScaffoldTemplateVariables): Promise<void>;
19
14
  export declare function normalizePackageManagerFiles(targetDir: string, packageManagerId: PackageManagerId): Promise<void>;
20
15
  export declare function removeQueryLoopPlaceholderFiles(projectDir: string, templateId: string): Promise<void>;
21
16
  export declare function removeUnexpectedLockfiles(targetDir: string, packageManagerId: PackageManagerId): Promise<void>;
@@ -32,7 +27,7 @@ export declare function defaultInstallDependencies({ projectDir, packageManager,
32
27
  * Applies a built-in scaffold into the target directory, including generated
33
28
  * code artifacts, starter manifests, preset files, and placeholder rewrites.
34
29
  */
35
- export declare function applyBuiltInScaffoldProjectFiles({ projectDir, templateDir, templateId, variables, artifacts, codeArtifacts, readmeContent, gitignoreContent, allowExistingDir, packageManager, withMigrationUi, withTestPreset, withWpEnv, noInstall, installDependencies, repositoryReference, onProgress, }: {
30
+ export declare function applyBuiltInScaffoldProjectFiles({ projectDir, templateDir, templateId, variables, artifacts, codeArtifacts, readmeContent, gitignoreContent, allowExistingDir, packageManager, withMigrationUi, withTestPreset, withWpEnv, noInstall, installDependencies, repositoryReference, onProgress, seedCompilerArtifacts, }: {
36
31
  projectDir: string;
37
32
  templateDir: string;
38
33
  templateId: BuiltInTemplateId;
@@ -50,4 +45,5 @@ export declare function applyBuiltInScaffoldProjectFiles({ projectDir, templateD
50
45
  installDependencies?: ((options: InstallDependenciesOptions) => Promise<void>) | undefined;
51
46
  repositoryReference?: string;
52
47
  onProgress?: ((event: ScaffoldProgressEvent) => void | Promise<void>) | undefined;
53
- }): Promise<void>;
48
+ seedCompilerArtifacts?: boolean;
49
+ }): Promise<string[]>;
@@ -1,6 +1,7 @@
1
1
  import { promises as fsp } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { execSync } from "node:child_process";
4
+ import { syncBlockMetadata } from "@wp-typia/block-runtime/metadata-core";
4
5
  import { applyGeneratedProjectDxPackageJson, applyLocalDevPresetFiles, } from "./local-dev-presets.js";
5
6
  import { applyMigrationUiCapability } from "../migration/migration-ui-capability.js";
6
7
  import { syncPersistenceRestArtifacts, } from "../add/persistence-rest-artifacts.js";
@@ -8,10 +9,13 @@ import { buildGitignore, buildReadme, mergeTextLines, } from "./scaffold-documen
8
9
  import { getStarterManifestFiles, stringifyStarterManifest, } from "./starter-manifests.js";
9
10
  import { formatNonEmptyTargetDirectoryError, } from "./scaffold-bootstrap.js";
10
11
  import { stringifyBuiltInBlockJsonDocument, } from "./built-in-block-artifacts.js";
12
+ import { buildBuiltInBlockMetadataSyncOptions, buildBuiltInPersistenceRestSyncOptions, } from "./scaffold-compiler-artifacts.js";
13
+ import { getDeferredCompilerArtifactsWarning } from "./scaffold-onboarding.js";
11
14
  import { PROJECT_TOOLS_PACKAGE_ROOT, } from "./template-registry.js";
12
15
  import { copyInterpolatedDirectory } from "./template-render.js";
13
16
  import { formatInstallCommand, transformPackageManagerText, } from "../shared/package-managers.js";
14
17
  import { pathExists, readOptionalUtf8File, } from "../shared/fs-async.js";
18
+ import { readJsonFile } from "../shared/json-utils.js";
15
19
  import { normalizePackageJson } from "./scaffold-package-manager-files.js";
16
20
  export { applyWorkspaceMigrationCapability, isOfficialWorkspaceProject, } from "./scaffold-bootstrap.js";
17
21
  import { replaceRepositoryReferencePlaceholders, resolveScaffoldRepositoryReference, } from "./scaffold-repository-reference.js";
@@ -82,48 +86,45 @@ async function withEphemeralScaffoldNodeModules(targetDir, callback) {
82
86
  const targetNodeModulesPath = path.join(targetDir, "node_modules");
83
87
  if (await pathExists(targetNodeModulesPath)) {
84
88
  await callback();
85
- return;
89
+ return true;
86
90
  }
87
91
  const sourceNodeModulesPath = await resolveScaffoldGeneratorNodeModulesPath();
88
92
  if (!sourceNodeModulesPath) {
89
- throw new Error("Unable to resolve a node_modules directory with typia for scaffold-time REST artifact generation.");
93
+ return false;
90
94
  }
91
95
  await fsp.symlink(sourceNodeModulesPath, targetNodeModulesPath, EPHEMERAL_NODE_MODULES_LINK_TYPE);
92
96
  try {
93
97
  await callback();
98
+ return true;
94
99
  }
95
100
  finally {
96
101
  await fsp.rm(targetNodeModulesPath, { force: true, recursive: true });
97
102
  }
98
103
  }
99
- /**
100
- * Seed REST-derived persistence artifacts into a newly scaffolded built-in
101
- * project before the first manual `sync-rest` run.
102
- */
103
- export async function seedBuiltInPersistenceArtifacts(targetDir, templateId, variables) {
104
- const needsPersistenceArtifacts = templateId === "persistence" ||
105
- (templateId === "compound" && isCompoundPersistenceEnabled(variables));
106
- if (!needsPersistenceArtifacts) {
107
- return;
104
+ async function seedBuiltInCompilerArtifacts(targetDir, templateId, artifacts, variables) {
105
+ const blockMetadataSyncOptions = buildBuiltInBlockMetadataSyncOptions(targetDir, templateId, artifacts);
106
+ const persistenceSyncOptions = buildBuiltInPersistenceRestSyncOptions(targetDir, templateId, variables);
107
+ if (blockMetadataSyncOptions.length === 0 && !persistenceSyncOptions) {
108
+ return true;
108
109
  }
109
- await withEphemeralScaffoldNodeModules(targetDir, async () => {
110
- if (templateId === "persistence") {
111
- await syncPersistenceRestArtifacts({
112
- apiTypesFile: path.join("src", "api-types.ts"),
113
- outputDir: "src",
114
- projectDir: targetDir,
115
- variables,
116
- });
117
- return;
110
+ return withEphemeralScaffoldNodeModules(targetDir, async () => {
111
+ for (const options of blockMetadataSyncOptions) {
112
+ await syncBlockMetadata(options);
113
+ }
114
+ if (persistenceSyncOptions) {
115
+ await syncPersistenceRestArtifacts(persistenceSyncOptions);
118
116
  }
119
- await syncPersistenceRestArtifacts({
120
- apiTypesFile: path.join("src", "blocks", variables.slugKebabCase, "api-types.ts"),
121
- outputDir: path.join("src", "blocks", variables.slugKebabCase),
122
- projectDir: targetDir,
123
- variables,
124
- });
125
117
  });
126
118
  }
119
+ async function readScaffoldScriptNames(projectDir) {
120
+ try {
121
+ const packageJson = await readJsonFile(path.join(projectDir, "package.json"), { context: "generated scaffold package manifest" });
122
+ return Object.keys(packageJson.scripts ?? {});
123
+ }
124
+ catch {
125
+ return [];
126
+ }
127
+ }
127
128
  export async function normalizePackageManagerFiles(targetDir, packageManagerId) {
128
129
  const yarnRcPath = path.join(targetDir, ".yarnrc.yml");
129
130
  if (packageManagerId === "yarn") {
@@ -201,7 +202,8 @@ export async function defaultInstallDependencies({ projectDir, packageManager, }
201
202
  * Applies a built-in scaffold into the target directory, including generated
202
203
  * code artifacts, starter manifests, preset files, and placeholder rewrites.
203
204
  */
204
- export async function applyBuiltInScaffoldProjectFiles({ projectDir, templateDir, templateId, variables, artifacts, codeArtifacts, readmeContent, gitignoreContent, allowExistingDir = false, packageManager, withMigrationUi = false, withTestPreset = false, withWpEnv = false, noInstall = false, installDependencies, repositoryReference, onProgress, }) {
205
+ export async function applyBuiltInScaffoldProjectFiles({ projectDir, templateDir, templateId, variables, artifacts, codeArtifacts, readmeContent, gitignoreContent, allowExistingDir = false, packageManager, withMigrationUi = false, withTestPreset = false, withWpEnv = false, noInstall = false, installDependencies, repositoryReference, onProgress, seedCompilerArtifacts = true, }) {
206
+ const warnings = [];
205
207
  await ensureDirectory(projectDir, allowExistingDir);
206
208
  await reportScaffoldProgress(onProgress, {
207
209
  detail: "Copying built-in template files and writing generated source modules.",
@@ -221,7 +223,6 @@ export async function applyBuiltInScaffoldProjectFiles({ projectDir, templateDir
221
223
  title: "Seeding scaffold artifacts",
222
224
  });
223
225
  await writeStarterManifestFiles(projectDir, templateId, variables, artifacts);
224
- await seedBuiltInPersistenceArtifacts(projectDir, templateId, variables);
225
226
  await applyLocalDevPresetFiles({
226
227
  projectDir,
227
228
  variables,
@@ -280,4 +281,19 @@ export async function applyBuiltInScaffoldProjectFiles({ projectDir, templateDir
280
281
  packageManager,
281
282
  });
282
283
  }
284
+ if (seedCompilerArtifacts) {
285
+ const seededCompilerArtifacts = await seedBuiltInCompilerArtifacts(projectDir, templateId, artifacts ?? [], variables);
286
+ if (!seededCompilerArtifacts) {
287
+ const warning = getDeferredCompilerArtifactsWarning(packageManager, templateId, {
288
+ availableScripts: await readScaffoldScriptNames(projectDir),
289
+ });
290
+ warnings.push(warning);
291
+ await reportScaffoldProgress(onProgress, {
292
+ detail: warning,
293
+ phase: "seed-artifacts",
294
+ title: "Deferring compiler-derived artifacts",
295
+ });
296
+ }
297
+ }
298
+ return warnings;
283
299
  }
@@ -0,0 +1,17 @@
1
+ import type { SyncBlockMetadataOptions } from "@wp-typia/block-runtime/metadata-core";
2
+ import { type SyncPersistenceRestArtifactsOptions } from "../add/persistence-rest-artifacts.js";
3
+ import type { BuiltInBlockArtifact } from "./built-in-block-artifacts.js";
4
+ import type { ScaffoldTemplateVariables } from "./scaffold.js";
5
+ import { type BuiltInTemplateId } from "./template-registry.js";
6
+ /**
7
+ * Build the canonical sync options for each typed block in a built-in scaffold.
8
+ */
9
+ export declare function buildBuiltInBlockMetadataSyncOptions(projectDir: string, templateId: BuiltInTemplateId, artifacts: readonly BuiltInBlockArtifact[]): SyncBlockMetadataOptions[];
10
+ /**
11
+ * Resolve the canonical REST sync input for a persistence-enabled scaffold.
12
+ */
13
+ export declare function buildBuiltInPersistenceRestSyncOptions(projectDir: string, templateId: BuiltInTemplateId, variables: ScaffoldTemplateVariables): SyncPersistenceRestArtifactsOptions | null;
14
+ /**
15
+ * Collect every compiler-derived path without executing the compiler.
16
+ */
17
+ export declare function collectBuiltInCompilerArtifactPaths(templateId: string, variables: ScaffoldTemplateVariables): string[];