@wp-typia/project-tools 0.16.13 → 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.
Files changed (38) hide show
  1. package/README.md +0 -1
  2. package/dist/runtime/block-generator-service-spec.d.ts +6 -0
  3. package/dist/runtime/block-generator-service-spec.js +27 -0
  4. package/dist/runtime/built-in-block-code-artifacts.js +14 -1
  5. package/dist/runtime/built-in-block-code-templates/query-loop.d.ts +1 -0
  6. package/dist/runtime/built-in-block-code-templates/query-loop.js +70 -0
  7. package/dist/runtime/built-in-block-code-templates.d.ts +1 -0
  8. package/dist/runtime/built-in-block-code-templates.js +1 -0
  9. package/dist/runtime/built-in-block-non-ts-artifacts.js +2 -0
  10. package/dist/runtime/cli-help.js +1 -0
  11. package/dist/runtime/cli-prompt.js +78 -19
  12. package/dist/runtime/cli-scaffold.d.ts +2 -1
  13. package/dist/runtime/cli-scaffold.js +2 -1
  14. package/dist/runtime/local-dev-presets.js +21 -11
  15. package/dist/runtime/scaffold-answer-resolution.d.ts +37 -0
  16. package/dist/runtime/scaffold-answer-resolution.js +163 -0
  17. package/dist/runtime/scaffold-apply-utils.d.ts +1 -16
  18. package/dist/runtime/scaffold-apply-utils.js +4 -128
  19. package/dist/runtime/scaffold-documents.d.ts +34 -0
  20. package/dist/runtime/scaffold-documents.js +143 -0
  21. package/dist/runtime/scaffold-onboarding.js +12 -0
  22. package/dist/runtime/scaffold-template-variables.d.ts +9 -0
  23. package/dist/runtime/scaffold-template-variables.js +117 -0
  24. package/dist/runtime/scaffold.d.ts +19 -9
  25. package/dist/runtime/scaffold.js +6 -202
  26. package/dist/runtime/template-defaults.d.ts +7 -0
  27. package/dist/runtime/template-defaults.js +4 -0
  28. package/dist/runtime/template-registry.d.ts +1 -1
  29. package/dist/runtime/template-registry.js +14 -1
  30. package/package.json +3 -3
  31. package/templates/query-loop/inc/query-runtime.php.mustache +85 -0
  32. package/templates/query-loop/package.json.mustache +32 -0
  33. package/templates/query-loop/src/patterns/grid.php.mustache +49 -0
  34. package/templates/query-loop/src/patterns/list.php.mustache +48 -0
  35. package/templates/query-loop/src/query-extension.ts.mustache +41 -0
  36. package/templates/query-loop/src/validator-toolkit.ts.mustache +1 -0
  37. package/templates/query-loop/webpack.config.js.mustache +16 -0
  38. package/templates/query-loop/{{slugKebabCase}}.php.mustache +84 -0
@@ -0,0 +1,49 @@
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ $content = sprintf(
7
+ <<<'HTML'
8
+ <!-- wp:query {"namespace":"{{namespace}}/{{slug}}","query":{"inherit":false,"postType":"{{queryPostType}}","perPage":6,"order":"desc","orderBy":"date","wpTypiaVariation":"{{namespace}}/{{slug}}"},"displayLayout":{"type":"grid","columns":3}} -->
9
+ <div class="wp-block-query">
10
+ <!-- wp:post-template -->
11
+ <!-- wp:group {"style":{"spacing":{"blockGap":"0.75rem","padding":{"top":"1rem","right":"1rem","bottom":"1rem","left":"1rem"}}},"layout":{"type":"constrained"}} -->
12
+ <div class="wp-block-group" style="padding-top:1rem;padding-right:1rem;padding-bottom:1rem;padding-left:1rem">
13
+ <!-- wp:post-featured-image /-->
14
+ <!-- wp:post-title {"isLink":true} /-->
15
+ <!-- wp:post-excerpt /-->
16
+ </div>
17
+ <!-- /wp:group -->
18
+ <!-- /wp:post-template -->
19
+
20
+ <!-- wp:query-pagination -->
21
+ <!-- wp:query-pagination-previous /-->
22
+ <!-- wp:query-pagination-numbers /-->
23
+ <!-- wp:query-pagination-next /-->
24
+ <!-- /wp:query-pagination -->
25
+
26
+ <!-- wp:query-no-results -->
27
+ <!-- wp:paragraph -->
28
+ <p>%s</p>
29
+ <!-- /wp:paragraph -->
30
+ <!-- /wp:query-no-results -->
31
+ </div>
32
+ <!-- /wp:query -->
33
+ HTML,
34
+ esc_html__( 'No items matched this preset yet.', '{{textDomain}}' )
35
+ );
36
+
37
+ register_block_pattern(
38
+ '{{namespace}}/{{slug}}-grid',
39
+ array(
40
+ 'title' => __( '{{title}} Grid', '{{textDomain}}' ),
41
+ 'description' => __( 'A connected grid layout preset for the {{title}} Query Loop variation.', '{{textDomain}}' ),
42
+ 'categories' => array( '{{slug}}-query-loop' ),
43
+ 'blockTypes' => array( 'core/query' ),
44
+ 'postTypes' => array( '{{queryPostType}}' ),
45
+ 'inserter' => true,
46
+ 'viewportWidth' => 1280,
47
+ 'content' => $content,
48
+ )
49
+ );
@@ -0,0 +1,48 @@
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ $content = sprintf(
7
+ <<<'HTML'
8
+ <!-- wp:query {"namespace":"{{namespace}}/{{slug}}","query":{"inherit":false,"postType":"{{queryPostType}}","perPage":4,"order":"desc","orderBy":"date","wpTypiaVariation":"{{namespace}}/{{slug}}"}} -->
9
+ <div class="wp-block-query">
10
+ <!-- wp:post-template -->
11
+ <!-- wp:group {"style":{"spacing":{"blockGap":"1rem","padding":{"top":"1.25rem","bottom":"1.25rem"}}},"layout":{"type":"constrained"}} -->
12
+ <div class="wp-block-group" style="padding-top:1.25rem;padding-bottom:1.25rem">
13
+ <!-- wp:post-title {"isLink":true} /-->
14
+ <!-- wp:post-date /-->
15
+ <!-- wp:post-excerpt {"moreText":"Continue reading"} /-->
16
+ </div>
17
+ <!-- /wp:group -->
18
+ <!-- /wp:post-template -->
19
+
20
+ <!-- wp:query-pagination -->
21
+ <!-- wp:query-pagination-previous /-->
22
+ <!-- wp:query-pagination-next /-->
23
+ <!-- /wp:query-pagination -->
24
+
25
+ <!-- wp:query-no-results -->
26
+ <!-- wp:paragraph -->
27
+ <p>%s</p>
28
+ <!-- /wp:paragraph -->
29
+ <!-- /wp:query-no-results -->
30
+ </div>
31
+ <!-- /wp:query -->
32
+ HTML,
33
+ esc_html__( 'No items matched this preset yet.', '{{textDomain}}' )
34
+ );
35
+
36
+ register_block_pattern(
37
+ '{{namespace}}/{{slug}}-list',
38
+ array(
39
+ 'title' => __( '{{title}} List', '{{textDomain}}' ),
40
+ 'description' => __( 'A connected list layout preset for the {{title}} Query Loop variation.', '{{textDomain}}' ),
41
+ 'categories' => array( '{{slug}}-query-loop' ),
42
+ 'blockTypes' => array( 'core/query' ),
43
+ 'postTypes' => array( '{{queryPostType}}' ),
44
+ 'inserter' => true,
45
+ 'viewportWidth' => 1280,
46
+ 'content' => $content,
47
+ )
48
+ );
@@ -0,0 +1,41 @@
1
+ export type QueryLoopEditorExtensionContext = {
2
+ variationName: string;
3
+ };
4
+
5
+ export type QueryLoopCustomQuerySeed = Record<string, unknown>;
6
+
7
+ /**
8
+ * Extend the generated Query Loop variation with variation-specific query params.
9
+ *
10
+ * Add custom keys here only when the variation should always seed them. Runtime
11
+ * parity hooks in `inc/query-runtime.php` can read the same keys later from the
12
+ * Query Loop `query` object.
13
+ */
14
+ export function getQueryLoopCustomQuerySeed(): QueryLoopCustomQuerySeed {
15
+ return {};
16
+ }
17
+
18
+ /**
19
+ * Add extra inspector controls by key when your custom query seed needs them.
20
+ *
21
+ * Keep the generated defaults in `src/index.ts` and return only the additional
22
+ * control ids that your variation-specific query params rely on.
23
+ */
24
+ export function getQueryLoopCustomAllowedControls(): string[] {
25
+ return [];
26
+ }
27
+
28
+ /**
29
+ * Register optional editor-only extension hooks for custom Query Loop params.
30
+ *
31
+ * This stays a no-op by default. When you need custom inspector UI, add your
32
+ * `editor.BlockEdit` filters or other editor hooks here so `src/index.ts` can
33
+ * keep variation registration focused on identity and default query values. If
34
+ * those hooks introduce frontend-affecting query params, mirror them in
35
+ * `inc/query-runtime.php` so editor preview and frontend rendering stay aligned.
36
+ */
37
+ export function registerQueryLoopEditorExtensions(
38
+ _context: QueryLoopEditorExtensionContext,
39
+ ): void {
40
+ // Add optional editor hooks here when this variation introduces custom query UI.
41
+ }
@@ -0,0 +1,16 @@
1
+ const path = require("node:path");
2
+ const defaultConfig = require("@wordpress/scripts/config/webpack.config");
3
+
4
+ const queryLoopEntry = {
5
+ index: path.resolve(process.cwd(), "src/index.ts"),
6
+ };
7
+
8
+ module.exports = Array.isArray(defaultConfig)
9
+ ? defaultConfig.map((config) => ({
10
+ ...config,
11
+ entry: config?.output?.module ? config.entry : queryLoopEntry,
12
+ }))
13
+ : {
14
+ ...defaultConfig,
15
+ entry: queryLoopEntry,
16
+ };
@@ -0,0 +1,84 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: {{title}}
4
+ * Description: {{description}}
5
+ * Version: 0.1.0
6
+ * Requires at least: 6.7
7
+ * Tested up to: 6.9
8
+ * Requires PHP: 8.0
9
+ * Author: {{author}}
10
+ * License: GPL-2.0-or-later
11
+ * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
+ * Text Domain: {{textDomain}}
13
+ * Domain Path: /languages
14
+ */
15
+
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ exit;
18
+ }
19
+
20
+ require_once __DIR__ . '/inc/query-runtime.php';
21
+
22
+ function {{phpPrefix}}_load_textdomain() {
23
+ load_plugin_textdomain(
24
+ '{{textDomain}}',
25
+ false,
26
+ dirname( plugin_basename( __FILE__ ) ) . '/languages'
27
+ );
28
+ }
29
+
30
+ function {{phpPrefix}}_register_query_loop_pattern_category() {
31
+ if ( ! function_exists( 'register_block_pattern_category' ) ) {
32
+ return;
33
+ }
34
+
35
+ register_block_pattern_category(
36
+ '{{slug}}-query-loop',
37
+ array(
38
+ 'label' => __( '{{title}} Query Loop', '{{textDomain}}' ),
39
+ )
40
+ );
41
+ }
42
+
43
+ function {{phpPrefix}}_register_query_loop_patterns() {
44
+ if ( ! function_exists( 'register_block_pattern' ) ) {
45
+ return;
46
+ }
47
+
48
+ foreach ( glob( __DIR__ . '/src/patterns/*.php' ) ?: array() as $pattern_module ) {
49
+ require $pattern_module;
50
+ }
51
+ }
52
+
53
+ function {{phpPrefix}}_register_query_loop_variation_script() {
54
+ $script_path = __DIR__ . '/build/index.js';
55
+ $script_asset_path = __DIR__ . '/build/index.asset.php';
56
+
57
+ if ( ! file_exists( $script_path ) || ! file_exists( $script_asset_path ) ) {
58
+ return;
59
+ }
60
+
61
+ $asset = require $script_asset_path;
62
+ $handle = '{{phpPrefix}}_query_loop_variation';
63
+
64
+ wp_register_script(
65
+ $handle,
66
+ plugins_url( 'build/index.js', __FILE__ ),
67
+ is_array( $asset ) && isset( $asset['dependencies'] ) ? $asset['dependencies'] : array(),
68
+ is_array( $asset ) && isset( $asset['version'] ) ? $asset['version'] : filemtime( $script_path ),
69
+ true
70
+ );
71
+ wp_set_script_translations( $handle, '{{textDomain}}', __DIR__ . '/languages' );
72
+ }
73
+
74
+ function {{phpPrefix}}_enqueue_query_loop_variation_script() {
75
+ {{phpPrefix}}_register_query_loop_variation_script();
76
+ wp_enqueue_script( '{{phpPrefix}}_query_loop_variation' );
77
+ }
78
+
79
+ add_action( 'init', '{{phpPrefix}}_load_textdomain' );
80
+ add_action( 'init', '{{phpPrefix}}_register_query_loop_pattern_category' );
81
+ add_action( 'init', '{{phpPrefix}}_register_query_loop_patterns', 20 );
82
+ add_action( 'enqueue_block_editor_assets', '{{phpPrefix}}_enqueue_query_loop_variation_script' );
83
+ add_filter( 'query_loop_block_query_vars', '{{phpPrefix}}_filter_query_loop_block_query_vars', 10, 3 );
84
+ add_filter( 'rest_{{queryPostType}}_query', '{{phpPrefix}}_filter_query_loop_editor_preview_query_vars', 10, 2 );