create-wp-typia 0.1.0 → 1.0.1

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 (91) hide show
  1. package/README.md +8 -28
  2. package/bin/create-wp-typia.js +3 -0
  3. package/package.json +9 -37
  4. package/dist/cli.js +0 -87837
  5. package/dist/highlights-eq9cgrbb.scm +0 -604
  6. package/dist/highlights-ghv9g403.scm +0 -205
  7. package/dist/highlights-hk7bwhj4.scm +0 -284
  8. package/dist/highlights-r812a2qc.scm +0 -150
  9. package/dist/highlights-x6tmsnaa.scm +0 -115
  10. package/dist/injections-73j83es3.scm +0 -27
  11. package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  12. package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
  13. package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  14. package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  15. package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
  16. package/lib/entry.js +0 -29
  17. package/lib/node-cli.js +0 -326
  18. package/lib/package-managers.d.ts +0 -29
  19. package/lib/package-managers.js +0 -170
  20. package/lib/scaffold.d.ts +0 -64
  21. package/lib/scaffold.js +0 -565
  22. package/lib/template-registry.d.ts +0 -18
  23. package/lib/template-registry.js +0 -58
  24. package/src/cli.ts +0 -329
  25. package/templates/advanced/README.md.mustache +0 -70
  26. package/templates/advanced/block.json.mustache +0 -42
  27. package/templates/advanced/index.js +0 -21
  28. package/templates/advanced/package.json.mustache +0 -48
  29. package/templates/advanced/scripts/generate-migrations.ts.mustache +0 -267
  30. package/templates/advanced/scripts/lib/typia-metadata-core.ts +0 -806
  31. package/templates/advanced/scripts/migration-cli.ts.mustache +0 -260
  32. package/templates/advanced/scripts/sync-types-to-block-json.ts.mustache +0 -25
  33. package/templates/advanced/src/admin/migration-dashboard.tsx.mustache +0 -450
  34. package/templates/advanced/src/components/ErrorBoundary.tsx.mustache +0 -47
  35. package/templates/advanced/src/deprecated.ts.mustache +0 -184
  36. package/templates/advanced/src/edit.tsx.mustache +0 -93
  37. package/templates/advanced/src/hooks/useDebounce.ts.mustache +0 -20
  38. package/templates/advanced/src/hooks/useLocalStorage.ts.mustache +0 -31
  39. package/templates/advanced/src/hooks.ts.mustache +0 -56
  40. package/templates/advanced/src/index.tsx.mustache +0 -16
  41. package/templates/advanced/src/migration-detector.ts.mustache +0 -417
  42. package/templates/advanced/src/migrations/index.ts.mustache +0 -361
  43. package/templates/advanced/src/save.tsx.mustache +0 -40
  44. package/templates/advanced/src/style.scss.mustache +0 -84
  45. package/templates/advanced/src/types/versions.ts.mustache +0 -108
  46. package/templates/advanced/src/types.ts.mustache +0 -45
  47. package/templates/advanced/src/utils/classnames.ts.mustache +0 -51
  48. package/templates/advanced/src/utils/debounce.ts.mustache +0 -37
  49. package/templates/advanced/src/utils/index.ts.mustache +0 -7
  50. package/templates/advanced/src/utils/uuid.ts.mustache +0 -17
  51. package/templates/advanced/src/validators.ts.mustache +0 -39
  52. package/templates/advanced/src/view.ts.mustache +0 -59
  53. package/templates/advanced/tsconfig.json.mustache +0 -9
  54. package/templates/advanced/webpack.config.js.mustache +0 -85
  55. package/templates/basic/package.json.mustache +0 -39
  56. package/templates/basic/scripts/lib/typia-metadata-core.ts +0 -806
  57. package/templates/basic/scripts/sync-types-to-block-json.ts +0 -25
  58. package/templates/basic/src/block.json +0 -51
  59. package/templates/basic/src/edit.tsx +0 -85
  60. package/templates/basic/src/hooks.ts +0 -75
  61. package/templates/basic/src/index.tsx +0 -37
  62. package/templates/basic/src/save.tsx +0 -27
  63. package/templates/basic/src/style.scss +0 -42
  64. package/templates/basic/src/types.ts +0 -47
  65. package/templates/basic/src/validators.ts +0 -39
  66. package/templates/basic/tsconfig.json +0 -20
  67. package/templates/basic/webpack.config.js +0 -85
  68. package/templates/full/package.json.mustache +0 -40
  69. package/templates/full/scripts/lib/typia-metadata-core.ts +0 -806
  70. package/templates/full/scripts/sync-types-to-block-json.ts.mustache +0 -25
  71. package/templates/full/src/block.json.mustache +0 -121
  72. package/templates/full/src/edit.tsx.mustache +0 -300
  73. package/templates/full/src/editor.scss.mustache +0 -251
  74. package/templates/full/src/hooks.ts.mustache +0 -140
  75. package/templates/full/src/index.tsx.mustache +0 -27
  76. package/templates/full/src/save.tsx.mustache +0 -39
  77. package/templates/full/src/style.scss.mustache +0 -224
  78. package/templates/full/src/types.ts.mustache +0 -34
  79. package/templates/full/src/validators.ts.mustache +0 -84
  80. package/templates/full/tsconfig.json.mustache +0 -9
  81. package/templates/full/webpack.config.js.mustache +0 -85
  82. package/templates/interactivity/package.json.mustache +0 -41
  83. package/templates/interactivity/scripts/lib/typia-metadata-core.ts +0 -806
  84. package/templates/interactivity/scripts/sync-types-to-block-json.ts.mustache +0 -25
  85. package/templates/interactivity/src/block.json.mustache +0 -75
  86. package/templates/interactivity/src/edit.tsx.mustache +0 -206
  87. package/templates/interactivity/src/interactivity.ts.mustache +0 -183
  88. package/templates/interactivity/src/save.tsx.mustache +0 -87
  89. package/templates/interactivity/src/types.ts.mustache +0 -29
  90. package/templates/interactivity/tsconfig.json.mustache +0 -9
  91. package/templates/interactivity/webpack.config.js.mustache +0 -85
@@ -1,37 +0,0 @@
1
- /**
2
- * Debounce function
3
- */
4
- export function debounce<T extends (...args: any[]) => void>(
5
- func: T,
6
- wait: number
7
- ): (...args: Parameters<T>) => void {
8
- let timeout: NodeJS.Timeout;
9
-
10
- return function executedFunction(...args: Parameters<T>) {
11
- const later = () => {
12
- clearTimeout(timeout);
13
- func(...args);
14
- };
15
-
16
- clearTimeout(timeout);
17
- timeout = setTimeout(later, wait);
18
- };
19
- }
20
-
21
- /**
22
- * Throttle function
23
- */
24
- export function throttle<T extends (...args: any[]) => void>(
25
- func: T,
26
- limit: number
27
- ): (...args: Parameters<T>) => void {
28
- let inThrottle: boolean;
29
-
30
- return function executedFunction(...args: Parameters<T>) {
31
- if (!inThrottle) {
32
- func.apply(this, args);
33
- inThrottle = true;
34
- setTimeout(() => inThrottle = false, limit);
35
- }
36
- };
37
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * {{title}} utilities
3
- */
4
-
5
- export * from './uuid';
6
- export * from './classnames';
7
- export * from './debounce';
@@ -1,17 +0,0 @@
1
- /**
2
- * Generate UUID v4
3
- */
4
- export function generateUUID(): string {
5
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
6
- const r = Math.random() * 16 | 0;
7
- const v = c === 'x' ? r : (r & 0x3 | 0x8);
8
- return v.toString(16);
9
- });
10
- }
11
-
12
- /**
13
- * Generate short ID (8 characters)
14
- */
15
- export function generateShortId(): string {
16
- return Math.random().toString(36).substring(2, 10);
17
- }
@@ -1,39 +0,0 @@
1
- import typia from "typia";
2
- import { {{titleCase}}Attributes } from "./types";
3
-
4
- /**
5
- * Typia validators for the block attributes
6
- */
7
- export const validators = {
8
- validate: typia.createValidate<{{titleCase}}Attributes>(),
9
- assert: typia.createAssert<{{titleCase}}Attributes>(),
10
- is: typia.createIs<{{titleCase}}Attributes>(),
11
- random: typia.createRandom<{{titleCase}}Attributes>(),
12
- clone: typia.misc.createClone<{{titleCase}}Attributes>(),
13
- prune: typia.misc.createPrune<{{titleCase}}Attributes>(),
14
- };
15
-
16
- /**
17
- * Create safe attribute updater with validation
18
- */
19
- export function createAttributeUpdater(
20
- attributes: {{titleCase}}Attributes,
21
- setAttributes: (attrs: Partial<{{titleCase}}Attributes>) => void,
22
- validator = validators.validate
23
- ) {
24
- return <K extends keyof {{titleCase}}Attributes>(
25
- key: K,
26
- value: {{titleCase}}Attributes[K]
27
- ) => {
28
- const newAttrs = { ...attributes, [key]: value };
29
-
30
- const validation = validator(newAttrs);
31
- if (validation.success) {
32
- setAttributes({ [key]: value } as Partial<{{titleCase}}Attributes>);
33
- return true;
34
- } else {
35
- console.error(`Validation failed for ${String(key)}:`, validation.errors);
36
- return false;
37
- }
38
- };
39
- }
@@ -1,59 +0,0 @@
1
- import { store, getContext } from '@wordpress/interactivity';
2
- import { {{titleCase}}State } from './types';
3
-
4
- const { state, actions, callbacks } = store('{{namespace}}/{{slug}}', {
5
- state: {
6
- isActive: false,
7
- isVisible: true,
8
- isLoading: false,
9
- } as {{titleCase}}State,
10
-
11
- actions: {
12
- toggle() {
13
- state.isActive = !state.isActive;
14
- console.log('{{titleCase}} toggled:', state.isActive);
15
- },
16
-
17
- hide() {
18
- state.isVisible = false;
19
- },
20
-
21
- show() {
22
- state.isVisible = true;
23
- },
24
-
25
- async loadContent() {
26
- state.isLoading = true;
27
-
28
- try {
29
- // Simulate async operation
30
- await new Promise(resolve => setTimeout(resolve, 1000));
31
-
32
- // Get context data
33
- const context = getContext<{
34
- content: string;
35
- alignment: string;
36
- }>();
37
-
38
- console.log('{{titleCase}} content loaded:', context);
39
-
40
- } catch (error) {
41
- state.error = error instanceof Error ? error.message : 'Unknown error';
42
- console.error('{{titleCase}} loading failed:', error);
43
- } finally {
44
- state.isLoading = false;
45
- }
46
- }
47
- },
48
-
49
- callbacks: {
50
- init() {
51
- console.log('{{titleCase}} initialized with Typia validation and Interactivity API');
52
- },
53
-
54
- mounted() {
55
- const context = getContext();
56
- console.log('{{titleCase}} mounted with context:', context);
57
- }
58
- },
59
- });
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "@wordpress/scripts/config/tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "declarationDir": "build/types"
6
- },
7
- "include": ["src/**/*"],
8
- "exclude": ["build/**/*"]
9
- }
@@ -1,85 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const defaultConfig = require("@wordpress/scripts/config/webpack.config");
4
-
5
- class TypiaManifestAssetPlugin {
6
- apply(compiler) {
7
- compiler.hooks.thisCompilation.tap("TypiaManifestAssetPlugin", (compilation) => {
8
- compilation.hooks.processAssets.tap(
9
- {
10
- name: "TypiaManifestAssetPlugin",
11
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
12
- },
13
- () => {
14
- for (const entry of getManifestEntries()) {
15
- if (compilation.getAsset(entry.outputPath)) {
16
- continue;
17
- }
18
-
19
- compilation.emitAsset(
20
- entry.outputPath,
21
- new compiler.webpack.sources.RawSource(fs.readFileSync(entry.inputPath)),
22
- );
23
- }
24
- },
25
- );
26
- });
27
- }
28
- }
29
-
30
- function getManifestEntries() {
31
- const entries = [];
32
- const rootManifestPath = path.resolve(process.cwd(), "typia.manifest.json");
33
-
34
- if (fs.existsSync(rootManifestPath)) {
35
- entries.push({
36
- inputPath: rootManifestPath,
37
- outputPath: "typia.manifest.json",
38
- });
39
- }
40
-
41
- const srcDir = path.resolve(process.cwd(), "src");
42
- if (!fs.existsSync(srcDir)) {
43
- return entries;
44
- }
45
-
46
- for (const inputPath of findManifestFiles(srcDir)) {
47
- entries.push({
48
- inputPath,
49
- outputPath: path.relative(srcDir, inputPath),
50
- });
51
- }
52
-
53
- return entries;
54
- }
55
-
56
- function findManifestFiles(directory) {
57
- const manifestFiles = [];
58
-
59
- for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
60
- const entryPath = path.join(directory, entry.name);
61
-
62
- if (entry.isDirectory()) {
63
- manifestFiles.push(...findManifestFiles(entryPath));
64
- continue;
65
- }
66
- if (entry.isFile() && entry.name === "typia.manifest.json") {
67
- manifestFiles.push(entryPath);
68
- }
69
- }
70
-
71
- return manifestFiles;
72
- }
73
-
74
- module.exports = async () => {
75
- const { default: UnpluginTypia } = await import("@typia/unplugin/webpack");
76
-
77
- return {
78
- ...defaultConfig,
79
- plugins: [
80
- UnpluginTypia(),
81
- ...(defaultConfig.plugins || []),
82
- new TypiaManifestAssetPlugin(),
83
- ],
84
- };
85
- };
@@ -1,39 +0,0 @@
1
- {
2
- "name": "{{slug}}",
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
- "prebuild": "bun run sync-types",
12
- "build": "wp-scripts build",
13
- "start": "bun run sync-types && wp-scripts start",
14
- "dev": "bun run start",
15
- "lint:js": "wp-scripts lint-js",
16
- "lint:css": "wp-scripts lint-style",
17
- "lint": "bun run lint:js && bun run lint:css",
18
- "format": "wp-scripts format"
19
- },
20
- "devDependencies": {
21
- "ajv": "^8.18.0",
22
- "@types/wordpress__block-editor": "^11.5.17",
23
- "@types/wordpress__blocks": "^12.5.18",
24
- "@types/wordpress__components": "^23.8.0",
25
- "@wordpress/browserslist-config": "^6.42.0",
26
- "@wordpress/scripts": "^30.22.0",
27
- "@typia/unplugin": "^12.0.1",
28
- "tsx": "^4.20.5",
29
- "typescript": "^5.9.2",
30
- "typia": "^12.0.1"
31
- },
32
- "dependencies": {
33
- "@wordpress/block-editor": "^15.2.0",
34
- "@wordpress/blocks": "^15.2.0",
35
- "@wordpress/components": "^30.2.0",
36
- "@wordpress/element": "^6.29.0",
37
- "@wordpress/i18n": "^6.2.0"
38
- }
39
- }