@wp-typia/create 0.1.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 (95) hide show
  1. package/README.md +43 -0
  2. package/dist/cli.js +2492 -0
  3. package/dist/runtime/cli-core.js +222 -0
  4. package/dist/runtime/index.js +4 -0
  5. package/dist/runtime/migration-constants.js +14 -0
  6. package/dist/runtime/migration-diff.js +521 -0
  7. package/dist/runtime/migration-fixtures.js +89 -0
  8. package/dist/runtime/migration-manifest.js +129 -0
  9. package/dist/runtime/migration-project.js +167 -0
  10. package/dist/runtime/migration-render.js +267 -0
  11. package/dist/runtime/migration-types.js +1 -0
  12. package/dist/runtime/migration-utils.js +184 -0
  13. package/dist/runtime/migrations.js +232 -0
  14. package/dist/runtime/package-managers.js +135 -0
  15. package/dist/runtime/scaffold.js +334 -0
  16. package/dist/runtime/template-registry.js +75 -0
  17. package/package.json +65 -0
  18. package/templates/advanced/README.md.mustache +150 -0
  19. package/templates/advanced/block.json.mustache +43 -0
  20. package/templates/advanced/index.js +21 -0
  21. package/templates/advanced/package.json.mustache +47 -0
  22. package/templates/advanced/render.php.mustache +83 -0
  23. package/templates/advanced/scripts/lib/typia-metadata-core.ts +1413 -0
  24. package/templates/advanced/scripts/sync-types-to-block-json.ts.mustache +32 -0
  25. package/templates/advanced/src/admin/migration-dashboard.tsx.mustache +315 -0
  26. package/templates/advanced/src/components/ErrorBoundary.tsx.mustache +47 -0
  27. package/templates/advanced/src/deprecated.ts.mustache +2 -0
  28. package/templates/advanced/src/edit.tsx.mustache +97 -0
  29. package/templates/advanced/src/hooks/useDebounce.ts.mustache +20 -0
  30. package/templates/advanced/src/hooks/useLocalStorage.ts.mustache +31 -0
  31. package/templates/advanced/src/hooks.ts.mustache +56 -0
  32. package/templates/advanced/src/index.tsx.mustache +18 -0
  33. package/templates/advanced/src/migration-detector.ts.mustache +9 -0
  34. package/templates/advanced/src/migrations/config.ts.mustache +8 -0
  35. package/templates/advanced/src/migrations/examples/rename-transform-union/README.md.mustache +23 -0
  36. package/templates/advanced/src/migrations/examples/rename-transform-union/fixture.example.json.mustache +36 -0
  37. package/templates/advanced/src/migrations/examples/rename-transform-union/rule.example.ts.mustache +47 -0
  38. package/templates/advanced/src/migrations/fixtures/README.md.mustache +3 -0
  39. package/templates/advanced/src/migrations/generated/deprecated.ts.mustache +3 -0
  40. package/templates/advanced/src/migrations/generated/registry.ts.mustache +9 -0
  41. package/templates/advanced/src/migrations/generated/verify.ts.mustache +1 -0
  42. package/templates/advanced/src/migrations/helpers.ts.mustache +354 -0
  43. package/templates/advanced/src/migrations/index.ts.mustache +616 -0
  44. package/templates/advanced/src/migrations/rules/README.md.mustache +3 -0
  45. package/templates/advanced/src/migrations/versions/README.md.mustache +3 -0
  46. package/templates/advanced/src/save.tsx.mustache +12 -0
  47. package/templates/advanced/src/style.scss.mustache +84 -0
  48. package/templates/advanced/src/types.ts.mustache +46 -0
  49. package/templates/advanced/src/utils/classnames.ts.mustache +51 -0
  50. package/templates/advanced/src/utils/debounce.ts.mustache +37 -0
  51. package/templates/advanced/src/utils/index.ts.mustache +7 -0
  52. package/templates/advanced/src/utils/uuid.ts.mustache +17 -0
  53. package/templates/advanced/src/validators.ts.mustache +39 -0
  54. package/templates/advanced/src/view.ts.mustache +59 -0
  55. package/templates/advanced/tsconfig.json.mustache +20 -0
  56. package/templates/advanced/webpack.config.js.mustache +95 -0
  57. package/templates/basic/package.json.mustache +39 -0
  58. package/templates/basic/scripts/lib/typia-metadata-core.ts +1413 -0
  59. package/templates/basic/scripts/sync-types-to-block-json.ts +25 -0
  60. package/templates/basic/src/block.json +51 -0
  61. package/templates/basic/src/edit.tsx +85 -0
  62. package/templates/basic/src/hooks.ts +75 -0
  63. package/templates/basic/src/index.tsx +37 -0
  64. package/templates/basic/src/save.tsx +27 -0
  65. package/templates/basic/src/style.scss +42 -0
  66. package/templates/basic/src/types.ts +48 -0
  67. package/templates/basic/src/validators.ts +39 -0
  68. package/templates/basic/tsconfig.json +20 -0
  69. package/templates/basic/webpack.config.js +89 -0
  70. package/templates/full/package.json.mustache +40 -0
  71. package/templates/full/scripts/lib/typia-metadata-core.ts +1413 -0
  72. package/templates/full/scripts/sync-types-to-block-json.ts.mustache +32 -0
  73. package/templates/full/src/block.json.mustache +120 -0
  74. package/templates/full/src/edit.tsx.mustache +300 -0
  75. package/templates/full/src/editor.scss.mustache +251 -0
  76. package/templates/full/src/hooks.ts.mustache +141 -0
  77. package/templates/full/src/index.tsx.mustache +27 -0
  78. package/templates/full/src/save.tsx.mustache +39 -0
  79. package/templates/full/src/style.scss.mustache +224 -0
  80. package/templates/full/src/types.ts.mustache +35 -0
  81. package/templates/full/src/validators.ts.mustache +84 -0
  82. package/templates/full/tsconfig.json.mustache +20 -0
  83. package/templates/full/webpack.config.js.mustache +89 -0
  84. package/templates/interactivity/package.json.mustache +41 -0
  85. package/templates/interactivity/scripts/lib/typia-metadata-core.ts +1413 -0
  86. package/templates/interactivity/scripts/sync-types-to-block-json.ts.mustache +32 -0
  87. package/templates/interactivity/src/block.json.mustache +74 -0
  88. package/templates/interactivity/src/edit.tsx.mustache +206 -0
  89. package/templates/interactivity/src/index.tsx.mustache +20 -0
  90. package/templates/interactivity/src/interactivity.ts.mustache +183 -0
  91. package/templates/interactivity/src/save.tsx.mustache +87 -0
  92. package/templates/interactivity/src/style.scss.mustache +60 -0
  93. package/templates/interactivity/src/types.ts.mustache +30 -0
  94. package/templates/interactivity/tsconfig.json.mustache +20 -0
  95. package/templates/interactivity/webpack.config.js.mustache +89 -0
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "{{slugSnakeCase}}",
3
+ "version": "0.1.0",
4
+ "packageManager": "bun@1.3.10",
5
+ "description": "{{description}}",
6
+ "author": "{{author}}",
7
+ "license": "GPL-2.0-or-later",
8
+ "main": "build/index.js",
9
+ "scripts": {
10
+ "sync-types": "tsx scripts/sync-types-to-block-json.ts",
11
+ "build": "bun run sync-types && wp-scripts build",
12
+ "start": "bun run sync-types && wp-scripts start",
13
+ "dev": "bun run start",
14
+ "migration:init": "wp-typia migrations init --current-version 1.0.0",
15
+ "migration:snapshot": "wp-typia migrations snapshot",
16
+ "migration:diff": "wp-typia migrations diff",
17
+ "migration:scaffold": "wp-typia migrations scaffold",
18
+ "migration:verify": "wp-typia migrations verify --all",
19
+ "lint:js": "wp-scripts lint-js",
20
+ "lint:css": "wp-scripts lint-style",
21
+ "lint": "bun run lint:js && bun run lint:css",
22
+ "format": "wp-scripts format"
23
+ },
24
+ "devDependencies": {
25
+ "@wp-typia/block-types": "^0.1.0",
26
+ "ajv": "^8.18.0",
27
+ "@types/wordpress__block-editor": "^11.5.17",
28
+ "@types/wordpress__blocks": "^12.5.18",
29
+ "@types/wordpress__components": "^23.8.0",
30
+ "@wordpress/browserslist-config": "^6.42.0",
31
+ "@wordpress/scripts": "^30.22.0",
32
+ "@typia/unplugin": "^12.0.1",
33
+ "@wp-typia/create": "^0.1.0",
34
+ "tsx": "^4.20.5",
35
+ "typescript": "^5.9.2",
36
+ "typia": "^12.0.1"
37
+ },
38
+ "dependencies": {
39
+ "@wordpress/api-fetch": "^7.29.0",
40
+ "@wordpress/block-editor": "^15.2.0",
41
+ "@wordpress/blocks": "^15.2.0",
42
+ "@wordpress/components": "^30.2.0",
43
+ "@wordpress/element": "^6.29.0",
44
+ "@wordpress/i18n": "^6.2.0",
45
+ "@wordpress/interactivity": "^6.29.0"
46
+ }
47
+ }
@@ -0,0 +1,83 @@
1
+ <?php
2
+ /**
3
+ * Dynamic render entry for the {{title}} block.
4
+ *
5
+ * Uses the generated Typia PHP validator to normalize and validate the
6
+ * supported attribute subset before rendering.
7
+ *
8
+ * @package {{titleCase}}
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ $validator_path = __DIR__ . '/typia-validator.php';
16
+ if ( ! file_exists( $validator_path ) ) {
17
+ return '';
18
+ }
19
+
20
+ $validator = require $validator_path;
21
+ if ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {
22
+ return '';
23
+ }
24
+
25
+ $normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );
26
+ $validation = $validator->validate( $normalized );
27
+
28
+ if ( empty( $validation['valid'] ) ) {
29
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
30
+ $messages = array_map( 'strval', $validation['errors'] ?? array() );
31
+ return sprintf(
32
+ '<!-- %s -->',
33
+ esc_html( '{{namespace}}/{{slug}} render skipped: ' . implode( ' | ', $messages ) )
34
+ );
35
+ }
36
+
37
+ return '';
38
+ }
39
+
40
+ if ( empty( $normalized['isVisible'] ) ) {
41
+ return '';
42
+ }
43
+
44
+ $content = isset( $normalized['content'] ) ? (string) $normalized['content'] : '';
45
+ $alignment = isset( $normalized['alignment'] ) ? (string) $normalized['alignment'] : 'left';
46
+
47
+ if ( ! in_array( $alignment, array( 'left', 'center', 'right', 'justify' ), true ) ) {
48
+ $alignment = 'left';
49
+ }
50
+
51
+ $wrapper_attributes = get_block_wrapper_attributes(
52
+ array(
53
+ 'data-wp-context' => wp_json_encode(
54
+ array(
55
+ 'alignment' => $alignment,
56
+ 'content' => $content,
57
+ )
58
+ ),
59
+ 'data-wp-interactive' => '{{namespace}}/{{slug}}',
60
+ )
61
+ );
62
+
63
+ ob_start();
64
+ ?>
65
+ <div <?php echo $wrapper_attributes; ?>>
66
+ <p
67
+ style="<?php echo esc_attr( 'text-align: ' . $alignment ); ?>"
68
+ data-wp-bind--hidden="!state.isVisible"
69
+ data-wp-text="context.content"
70
+ >
71
+ <?php echo esc_html( $content ); ?>
72
+ </p>
73
+
74
+ <button
75
+ data-wp-class--active="state.isActive"
76
+ data-wp-on--click="actions.toggle"
77
+ type="button"
78
+ >
79
+ <?php esc_html_e( 'Toggle', '{{textdomain}}' ); ?>
80
+ </button>
81
+ </div>
82
+ <?php
83
+ return trim( (string) ob_get_clean() );