onelaraveljs 1.0.0 → 1.1.3

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 (121) hide show
  1. package/README.md +1 -1
  2. package/bin/onejs-build.js +32 -0
  3. package/index.js +3 -1
  4. package/package.json +11 -3
  5. package/scripts/README-template-compiler.md +133 -0
  6. package/scripts/README.md +61 -0
  7. package/scripts/__pycache__/build.cpython-314.pyc +0 -0
  8. package/scripts/__pycache__/compile.cpython-313.pyc +0 -0
  9. package/scripts/__pycache__/compile.cpython-314.pyc +0 -0
  10. package/scripts/build.py +574 -0
  11. package/scripts/check-system-errors.php +214 -0
  12. package/scripts/compile.py +101 -0
  13. package/scripts/compiler/README_CONFIG.md +196 -0
  14. package/scripts/compiler/__init__.py +18 -0
  15. package/scripts/compiler/__pycache__/__init__.cpython-313.pyc +0 -0
  16. package/scripts/compiler/__pycache__/__init__.cpython-314.pyc +0 -0
  17. package/scripts/compiler/__pycache__/binding_directive_service.cpython-314.pyc +0 -0
  18. package/scripts/compiler/__pycache__/class_binding_handler.cpython-314.pyc +0 -0
  19. package/scripts/compiler/__pycache__/compiler_utils.cpython-313.pyc +0 -0
  20. package/scripts/compiler/__pycache__/compiler_utils.cpython-314.pyc +0 -0
  21. package/scripts/compiler/__pycache__/conditional_handlers.cpython-313.pyc +0 -0
  22. package/scripts/compiler/__pycache__/conditional_handlers.cpython-314.pyc +0 -0
  23. package/scripts/compiler/__pycache__/config.cpython-313.pyc +0 -0
  24. package/scripts/compiler/__pycache__/config.cpython-314.pyc +0 -0
  25. package/scripts/compiler/__pycache__/declaration_tracker.cpython-314.pyc +0 -0
  26. package/scripts/compiler/__pycache__/directive_processors.cpython-313.pyc +0 -0
  27. package/scripts/compiler/__pycache__/directive_processors.cpython-314.pyc +0 -0
  28. package/scripts/compiler/__pycache__/echo_processor.cpython-314.pyc +0 -0
  29. package/scripts/compiler/__pycache__/event_directive_processor.cpython-313.pyc +0 -0
  30. package/scripts/compiler/__pycache__/event_directive_processor.cpython-314.pyc +0 -0
  31. package/scripts/compiler/__pycache__/function_generators.cpython-313.pyc +0 -0
  32. package/scripts/compiler/__pycache__/function_generators.cpython-314.pyc +0 -0
  33. package/scripts/compiler/__pycache__/loop_handlers.cpython-313.pyc +0 -0
  34. package/scripts/compiler/__pycache__/loop_handlers.cpython-314.pyc +0 -0
  35. package/scripts/compiler/__pycache__/main_compiler.cpython-313.pyc +0 -0
  36. package/scripts/compiler/__pycache__/main_compiler.cpython-314.pyc +0 -0
  37. package/scripts/compiler/__pycache__/parsers.cpython-313.pyc +0 -0
  38. package/scripts/compiler/__pycache__/parsers.cpython-314.pyc +0 -0
  39. package/scripts/compiler/__pycache__/php_converter.cpython-313.pyc +0 -0
  40. package/scripts/compiler/__pycache__/php_converter.cpython-314.pyc +0 -0
  41. package/scripts/compiler/__pycache__/php_js_converter.cpython-313.pyc +0 -0
  42. package/scripts/compiler/__pycache__/php_js_converter.cpython-314.pyc +0 -0
  43. package/scripts/compiler/__pycache__/register_parser.cpython-313.pyc +0 -0
  44. package/scripts/compiler/__pycache__/register_parser.cpython-314.pyc +0 -0
  45. package/scripts/compiler/__pycache__/section_handlers.cpython-313.pyc +0 -0
  46. package/scripts/compiler/__pycache__/section_handlers.cpython-314.pyc +0 -0
  47. package/scripts/compiler/__pycache__/show_directive_handler.cpython-314.pyc +0 -0
  48. package/scripts/compiler/__pycache__/style_directive_handler.cpython-314.pyc +0 -0
  49. package/scripts/compiler/__pycache__/template_analyzer.cpython-313.pyc +0 -0
  50. package/scripts/compiler/__pycache__/template_analyzer.cpython-314.pyc +0 -0
  51. package/scripts/compiler/__pycache__/template_processor.cpython-313.pyc +0 -0
  52. package/scripts/compiler/__pycache__/template_processor.cpython-314.pyc +0 -0
  53. package/scripts/compiler/__pycache__/template_processors.cpython-313.pyc +0 -0
  54. package/scripts/compiler/__pycache__/template_processors.cpython-314.pyc +0 -0
  55. package/scripts/compiler/__pycache__/utils.cpython-313.pyc +0 -0
  56. package/scripts/compiler/__pycache__/utils.cpython-314.pyc +0 -0
  57. package/scripts/compiler/__pycache__/wrapper_parser.cpython-313.pyc +0 -0
  58. package/scripts/compiler/__pycache__/wrapper_parser.cpython-314.pyc +0 -0
  59. package/scripts/compiler/binding_directive_service.py +103 -0
  60. package/scripts/compiler/class_binding_handler.py +347 -0
  61. package/scripts/compiler/cli.py +34 -0
  62. package/scripts/compiler/code_generator.py +141 -0
  63. package/scripts/compiler/compiler.config.json +36 -0
  64. package/scripts/compiler/compiler_utils.py +55 -0
  65. package/scripts/compiler/conditional_handlers.py +252 -0
  66. package/scripts/compiler/config.py +107 -0
  67. package/scripts/compiler/declaration_tracker.py +420 -0
  68. package/scripts/compiler/directive_processors.py +603 -0
  69. package/scripts/compiler/echo_processor.py +667 -0
  70. package/scripts/compiler/event_directive_processor.py +1099 -0
  71. package/scripts/compiler/fetch_parser.py +49 -0
  72. package/scripts/compiler/function_generators.py +310 -0
  73. package/scripts/compiler/loop_handlers.py +224 -0
  74. package/scripts/compiler/main_compiler.py +1763 -0
  75. package/scripts/compiler/parsers.py +1418 -0
  76. package/scripts/compiler/php_converter.py +470 -0
  77. package/scripts/compiler/php_js_converter.py +603 -0
  78. package/scripts/compiler/register_parser.py +480 -0
  79. package/scripts/compiler/section_handlers.py +122 -0
  80. package/scripts/compiler/show_directive_handler.py +85 -0
  81. package/scripts/compiler/style_directive_handler.py +169 -0
  82. package/scripts/compiler/template_analyzer.py +162 -0
  83. package/scripts/compiler/template_processor.py +1167 -0
  84. package/scripts/compiler/template_processors.py +1557 -0
  85. package/scripts/compiler/test_compiler.py +69 -0
  86. package/scripts/compiler/utils.py +54 -0
  87. package/scripts/compiler/variables_analyzer.py +135 -0
  88. package/scripts/compiler/view_identifier_generator.py +278 -0
  89. package/scripts/compiler/wrapper_parser.py +78 -0
  90. package/scripts/dev-context.js +311 -0
  91. package/scripts/dev.js +109 -0
  92. package/scripts/generate-assets-order.js +208 -0
  93. package/scripts/migrate-namespace.php +146 -0
  94. package/scripts/node/MIGRATION.md +190 -0
  95. package/scripts/node/README.md +269 -0
  96. package/scripts/node/build.js +208 -0
  97. package/scripts/node/compiler/compiler-utils.js +38 -0
  98. package/scripts/node/compiler/conditional-handlers.js +45 -0
  99. package/scripts/node/compiler/config.js +178 -0
  100. package/scripts/node/compiler/directive-processors.js +51 -0
  101. package/scripts/node/compiler/event-directive-processor.js +182 -0
  102. package/scripts/node/compiler/function-generators.js +239 -0
  103. package/scripts/node/compiler/loop-handlers.js +45 -0
  104. package/scripts/node/compiler/main-compiler.js +236 -0
  105. package/scripts/node/compiler/parsers.js +358 -0
  106. package/scripts/node/compiler/php-converter.js +227 -0
  107. package/scripts/node/compiler/register-parser.js +32 -0
  108. package/scripts/node/compiler/section-handlers.js +46 -0
  109. package/scripts/node/compiler/template-analyzer.js +50 -0
  110. package/scripts/node/compiler/template-processor.js +371 -0
  111. package/scripts/node/compiler/template-processors.js +219 -0
  112. package/scripts/node/compiler/utils.js +203 -0
  113. package/scripts/node/compiler/wrapper-parser.js +25 -0
  114. package/scripts/node/package.json +24 -0
  115. package/scripts/node/test-compiler.js +52 -0
  116. package/scripts/node-run.cjs +28 -0
  117. package/scripts/standardize-directories.php +92 -0
  118. package/src/core/ViewManager.js +4 -4
  119. package/templates/view.module.js +2 -0
  120. package/templates/view.tpl-raw.js +13 -0
  121. package/templates/wraper.js +71 -0
@@ -0,0 +1,214 @@
1
+ <?php
2
+
3
+ /**
4
+ * Script Kiểm Tra Lỗi Hệ Thống
5
+ *
6
+ * Script này kiểm tra các lỗi phổ biến trong hệ thống:
7
+ * - Namespace không đúng
8
+ * - Đường dẫn thư mục không đúng
9
+ * - Class không tồn tại
10
+ * - Syntax errors
11
+ */
12
+
13
+ class SystemErrorChecker
14
+ {
15
+ private array $errors = [];
16
+ private array $warnings = [];
17
+ private int $filesChecked = 0;
18
+
19
+ public function check(): void
20
+ {
21
+ echo "🔍 Bắt đầu kiểm tra hệ thống...\n\n";
22
+
23
+ $this->checkNamespaces();
24
+ $this->checkDirectoryPaths();
25
+ $this->checkClassExists();
26
+ $this->checkSyntax();
27
+
28
+ $this->printReport();
29
+ }
30
+
31
+ private function checkNamespaces(): void
32
+ {
33
+ echo "📦 Kiểm tra namespace...\n";
34
+
35
+ $directories = ['app', 'src'];
36
+ $oldNamespaces = ['Shared\\', 'Core\\', 'Modules\\', 'Contexts\\', 'Support\\', 'Infrastructure\\'];
37
+
38
+ foreach ($directories as $dir) {
39
+ if (!is_dir($dir)) {
40
+ continue;
41
+ }
42
+
43
+ $iterator = new RecursiveIteratorIterator(
44
+ new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
45
+ RecursiveIteratorIterator::SELF_FIRST
46
+ );
47
+
48
+ foreach ($iterator as $file) {
49
+ if (!$file->isFile() || $file->getExtension() !== 'php') {
50
+ continue;
51
+ }
52
+
53
+ $this->filesChecked++;
54
+ $content = file_get_contents($file->getPathname());
55
+
56
+ foreach ($oldNamespaces as $oldNs) {
57
+ // Kiểm tra namespace declaration
58
+ if (preg_match('/^namespace\s+' . preg_quote($oldNs, '/') . '/m', $content)) {
59
+ $this->errors[] = "❌ Namespace cũ trong: {$file->getPathname()}";
60
+ }
61
+
62
+ // Kiểm tra use statements (nhưng không phải One\...)
63
+ if (preg_match('/^use\s+' . preg_quote($oldNs, '/') . '(?!One)/m', $content)) {
64
+ $this->warnings[] = "⚠️ Use statement cũ trong: {$file->getPathname()}";
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ private function checkDirectoryPaths(): void
72
+ {
73
+ echo "📁 Kiểm tra đường dẫn thư mục...\n";
74
+
75
+ $paths = [
76
+ 'src/support' => 'src/Support',
77
+ 'src/modules' => 'src/Modules',
78
+ 'src/core' => 'src/App',
79
+ 'src/shared' => 'src/Shared',
80
+ 'src/contexts' => 'src/Contexts',
81
+ 'src/infrastructure' => 'src/Infrastructure',
82
+ ];
83
+
84
+ foreach ($paths as $old => $new) {
85
+ if (is_dir($old) && !is_dir($new)) {
86
+ $this->warnings[] = "⚠️ Thư mục cũ còn tồn tại: {$old} (nên là: {$new})";
87
+ }
88
+ }
89
+
90
+ // Kiểm tra trong code
91
+ $files = ['app/Providers/AppServiceProvider.php'];
92
+ foreach ($files as $file) {
93
+ if (!file_exists($file)) {
94
+ continue;
95
+ }
96
+
97
+ $content = file_get_contents($file);
98
+ foreach ($paths as $old => $new) {
99
+ if (strpos($content, $old) !== false) {
100
+ $this->errors[] = "❌ Đường dẫn cũ trong: {$file} (tìm thấy: {$old})";
101
+ }
102
+ }
103
+ }
104
+ }
105
+
106
+ private function checkClassExists(): void
107
+ {
108
+ echo "🔎 Kiểm tra class tồn tại...\n";
109
+
110
+ // Load autoload nếu có
111
+ $autoloadPath = __DIR__ . '/../vendor/autoload.php';
112
+ if (file_exists($autoloadPath)) {
113
+ require_once $autoloadPath;
114
+ }
115
+
116
+ $criticalClasses = [
117
+ 'One\\App\\System',
118
+ 'One\\App\\Context',
119
+ 'One\\Shared\\BaseController',
120
+ 'One\\Support\\ValidationRules',
121
+ 'One\\Infrastructure\\Database\\DatabaseService',
122
+ ];
123
+
124
+ foreach ($criticalClasses as $class) {
125
+ if (!class_exists($class) && !interface_exists($class)) {
126
+ // Kiểm tra xem file có tồn tại không
127
+ $relativePath = str_replace('One\\', 'src/', $class);
128
+ $relativePath = str_replace('\\', '/', $relativePath) . '.php';
129
+ $fullPath = __DIR__ . '/../' . $relativePath;
130
+
131
+ if (!file_exists($fullPath)) {
132
+ $this->errors[] = "❌ Class không tồn tại: {$class} (file: {$relativePath})";
133
+ } else {
134
+ $this->warnings[] = "⚠️ Class tồn tại nhưng chưa được autoload: {$class}";
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ private function checkSyntax(): void
141
+ {
142
+ echo "🔤 Kiểm tra syntax...\n";
143
+
144
+ $directories = ['app', 'src'];
145
+
146
+ foreach ($directories as $dir) {
147
+ if (!is_dir($dir)) {
148
+ continue;
149
+ }
150
+
151
+ $iterator = new RecursiveIteratorIterator(
152
+ new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
153
+ RecursiveIteratorIterator::SELF_FIRST
154
+ );
155
+
156
+ foreach ($iterator as $file) {
157
+ if (!$file->isFile() || $file->getExtension() !== 'php') {
158
+ continue;
159
+ }
160
+
161
+ $output = [];
162
+ $return = 0;
163
+ exec("php -l {$file->getPathname()} 2>&1", $output, $return);
164
+
165
+ if ($return !== 0) {
166
+ $this->errors[] = "❌ Syntax error trong: {$file->getPathname()}\n " . implode("\n ", $output);
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ private function printReport(): void
173
+ {
174
+ echo "\n" . str_repeat("=", 60) . "\n";
175
+ echo "📊 BÁO CÁO KIỂM TRA\n";
176
+ echo str_repeat("=", 60) . "\n\n";
177
+
178
+ echo "📈 Thống kê:\n";
179
+ echo " - Số file đã kiểm tra: {$this->filesChecked}\n";
180
+ echo " - Số lỗi: " . count($this->errors) . "\n";
181
+ echo " - Số cảnh báo: " . count($this->warnings) . "\n\n";
182
+
183
+ if (!empty($this->errors)) {
184
+ echo "❌ LỖI:\n";
185
+ foreach ($this->errors as $error) {
186
+ echo " {$error}\n";
187
+ }
188
+ echo "\n";
189
+ }
190
+
191
+ if (!empty($this->warnings)) {
192
+ echo "⚠️ CẢNH BÁO:\n";
193
+ foreach ($this->warnings as $warning) {
194
+ echo " {$warning}\n";
195
+ }
196
+ echo "\n";
197
+ }
198
+
199
+ if (empty($this->errors) && empty($this->warnings)) {
200
+ echo "✅ Không có lỗi nào được phát hiện!\n";
201
+ } else {
202
+ echo "💡 Tổng kết: " . (empty($this->errors) ? "✅ Không có lỗi nghiêm trọng" : "❌ Có lỗi cần sửa") . "\n";
203
+ }
204
+ }
205
+ }
206
+
207
+ // Chạy kiểm tra
208
+ if (php_sapi_name() === 'cli') {
209
+ $checker = new SystemErrorChecker();
210
+ $checker->check();
211
+ } else {
212
+ echo "Script này chỉ chạy được từ command line.\n";
213
+ }
214
+
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Blade to JavaScript Compiler - Modular Architecture
4
+ Sử dụng kiến trúc modular mới để dễ dàng phát triển và maintain
5
+ """
6
+
7
+ import sys
8
+ import os
9
+ from compiler import BladeCompiler
10
+ # Add current directory to Python path
11
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
12
+
13
+ blade_compiler = BladeCompiler()
14
+
15
+ def compile_blade_to_js(blade_code, view_name="view"):
16
+ """
17
+ Compile blade code to JavaScript
18
+ """
19
+ return blade_compiler.compile_blade_to_js(blade_code, view_name)
20
+
21
+ def compile_blade_to_js_legacy(blade_code, view_name="view"):
22
+ """
23
+ Legacy wrapper function để tương thích với code cũ
24
+ """
25
+ return blade_compiler.compile_blade_to_js(blade_code, view_name)
26
+
27
+
28
+ def test_compiler_legacy():
29
+ """
30
+ Legacy test function để tương thích với code cũ
31
+ """
32
+ # Simple test function
33
+ test_code = '<h1>Hello World</h1>'
34
+ result = blade_compiler.compile_blade_to_js(test_code, 'test_view')
35
+ print("Test compilation successful!")
36
+ print(f"Result length: {len(result)}")
37
+ return result
38
+
39
+
40
+ def main_legacy():
41
+ """
42
+ Legacy main function để tương thích với code cũ
43
+ """
44
+ if len(sys.argv) < 3:
45
+ print("Sử dụng: python compile.py <input.blade> <output.js>")
46
+ sys.exit(1)
47
+
48
+ input_file = sys.argv[1]
49
+ output_file = sys.argv[2]
50
+
51
+ try:
52
+ with open(input_file, 'r', encoding='utf-8') as f:
53
+ blade_code = f.read()
54
+
55
+ js_code = blade_compiler.compile_blade_to_js(blade_code, input_file)
56
+
57
+ with open(output_file, 'w', encoding='utf-8') as f:
58
+ f.write(js_code)
59
+
60
+ print(f"Đã compile thành công từ {input_file} sang {output_file}")
61
+ except Exception as e:
62
+ print(f"Lỗi: {e}")
63
+ sys.exit(1)
64
+
65
+
66
+ # Export functions for backward compatibility
67
+ __all__ = [
68
+ 'compile_blade_to_js',
69
+ 'compile_blade_to_js_legacy',
70
+ 'test_compiler_legacy',
71
+ 'main_legacy'
72
+ ]
73
+
74
+ # Legacy function aliases for backward compatibility
75
+ extract_balanced_parentheses = None
76
+ normalize_quotes = None
77
+ convert_php_array_to_json = None
78
+ php_to_js = None
79
+ format_js_output = None
80
+ parse_fetch_directive = None
81
+ convert_php_to_js = None
82
+ parse_array_value = None
83
+ analyze_section_variables = None
84
+ analyze_render_uses_vars = None
85
+ analyze_sections_info = None
86
+ analyze_has_section_preload = None
87
+ analyze_needs_prerender = None
88
+ generate_prerender = None
89
+
90
+ # All functions are now in main_compiler.py
91
+ # Legacy function aliases are set to None for backward compatibility
92
+
93
+
94
+ if __name__ == "__main__":
95
+ # If command line arguments provided, run main function
96
+ if len(sys.argv) > 1:
97
+ main_legacy()
98
+ else:
99
+ # Run tests by default if no arguments
100
+ test_compiler_legacy()
101
+
@@ -0,0 +1,196 @@
1
+ # Compiler Configuration
2
+
3
+ Hệ thống config cho Python Blade Compiler cho phép dễ dàng chỉnh sửa input path và output path.
4
+
5
+ ## Cấu trúc Config
6
+
7
+ ### File JSON: `compiler.config.json`
8
+
9
+ ```json
10
+ {
11
+ "paths": {
12
+ "views_input": "resources/views",
13
+ "js_input": "resources/js/app",
14
+ "public_static": "public/static",
15
+ "app_output": "public/static/app",
16
+ "scopes_output": "public/static/app/scopes"
17
+ },
18
+ "files": {
19
+ "view_templates": "view.templates.js",
20
+ "wrapper": "wraper.js",
21
+ "main": "main.js"
22
+ },
23
+ "patterns": {
24
+ "blade": "**/*.blade.php",
25
+ "js": "**/*.js"
26
+ },
27
+ "settings": {
28
+ "default_scope": "web",
29
+ "auto_create_dirs": true,
30
+ "verbose": false
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Sử dụng Config
36
+
37
+ ### 1. Chỉnh sửa đường dẫn
38
+
39
+ Để thay đổi input/output paths, chỉ cần sửa file `compiler.config.json`:
40
+
41
+ ```json
42
+ {
43
+ "paths": {
44
+ "views_input": "custom/views/path",
45
+ "js_input": "custom/js/path",
46
+ "app_output": "custom/output/path"
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### 2. Sử dụng trong Python
52
+
53
+ ```python
54
+ from compiler.config import config
55
+
56
+ # In config hiện tại
57
+ config.print_config()
58
+
59
+ # Lấy đường dẫn
60
+ views_path = config.get_views_path('web')
61
+ js_path = config.get_js_input_path()
62
+ output_path = config.get_view_templates_output_path()
63
+
64
+ # Reload config từ file
65
+ config.reload_config()
66
+
67
+ # Cập nhật config động
68
+ config.update_paths(views_input_path="/new/path")
69
+ ```
70
+
71
+ ### 3. Test Config
72
+
73
+ ```bash
74
+ python3 test_config.py
75
+ ```
76
+
77
+ ## Các đường dẫn chính
78
+
79
+ - **Views Input**: `resources/views` - Nơi chứa các file Blade template
80
+ - **JS Input**: `resources/js/app` - Nơi chứa các file JavaScript modules
81
+ - **Build Output**: `resources/js/build` - Nơi build tạm thời (không deploy)
82
+ - **Build Scopes**: `resources/js/build/scopes` - Nơi build scope files tạm thời
83
+ - **App Output**: `public/static/app` - Nơi xuất các file JavaScript đã compile (deploy)
84
+ - **Scopes Output**: `public/static/app/scopes` - Nơi xuất các file scope (deploy)
85
+
86
+ ## Workflow Build
87
+
88
+ ### 1. Build Process
89
+ 1. **Compile Blade templates** → `resources/js/build/scopes/`
90
+ 2. **Build view.templates.js** → `resources/js/build/view.templates.js`
91
+ 3. **Copy view.templates.js** → `resources/js/app/view.templates.js`
92
+ 4. **Build main.js** → `resources/js/build/main.js`
93
+ 5. **Copy only main.js** → `public/static/app/main.js`
94
+
95
+ ### 2. Lợi ích
96
+ - ✅ **Tách biệt build và deploy**: Build trong `resources`, deploy vào `public`
97
+ - ✅ **Dễ debug**: Có thể kiểm tra files trong `resources/build` trước khi deploy
98
+ - ✅ **Rollback dễ dàng**: Có thể giữ lại version cũ trong `public`
99
+ - ✅ **Preserve originals**: Giữ nguyên tất cả file gốc tại `resources/build/`
100
+ - ✅ **CI/CD friendly**: Có thể build riêng, deploy riêng
101
+
102
+ ## Tính năng
103
+
104
+ - ✅ **Auto Create Dirs**: Tự động tạo thư mục nếu chưa tồn tại
105
+ - ✅ **Verbose Mode**: Hiển thị thông tin chi tiết khi compile
106
+ - ✅ **Backward Compatibility**: Tương thích với code cũ
107
+ - ✅ **Dynamic Reload**: Có thể reload config mà không cần restart
108
+ - ✅ **Build-Deploy Separation**: Tách biệt quá trình build và deploy
109
+
110
+ ## Ví dụ sử dụng
111
+
112
+ ### Thay đổi build directories
113
+
114
+ ```json
115
+ {
116
+ "build_directories": [
117
+ "web",
118
+ "admin",
119
+ "layouts",
120
+ "partials",
121
+ "custom"
122
+ ]
123
+ }
124
+ ```
125
+
126
+ **Lưu ý:** Chỉ cần nhập tên thư mục, không cần path đầy đủ. Path sẽ được tính từ `resources/views`.
127
+
128
+ ### Thay đổi output path
129
+
130
+ ```json
131
+ {
132
+ "paths": {
133
+ "app_output": "dist/js",
134
+ "scopes_output": "dist/js/scopes"
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### Thay đổi input path
140
+
141
+ ```json
142
+ {
143
+ "paths": {
144
+ "views_input": "src/templates",
145
+ "js_input": "src/assets/js"
146
+ }
147
+ }
148
+ ```
149
+
150
+ ### Bật verbose mode
151
+
152
+ ```json
153
+ {
154
+ "settings": {
155
+ "verbose": true
156
+ }
157
+ }
158
+ ```
159
+
160
+ ## Cách sử dụng mới
161
+
162
+ ### Chạy build đơn giản
163
+
164
+ ```bash
165
+ # Không cần tham số
166
+ python3 build.py
167
+ ```
168
+
169
+ ### Thêm thư mục mới vào build
170
+
171
+ 1. Thêm vào `compiler.config.json`:
172
+ ```json
173
+ {
174
+ "build_directories": [
175
+ "web",
176
+ "admin",
177
+ "layouts",
178
+ "partials",
179
+ "custom"
180
+ ]
181
+ }
182
+ ```
183
+
184
+ 2. Chạy build:
185
+ ```bash
186
+ python3 build.py
187
+ ```
188
+
189
+ ### View naming convention
190
+
191
+ Views sẽ được đặt tên theo cấu trúc thư mục từ `resources/views`:
192
+
193
+ - `resources/views/web/user-detail.blade.php` → `web.user-detail`
194
+ - `resources/views/admin/dashboard.blade.php` → `admin.dashboard`
195
+ - `resources/views/layouts/base.blade.php` → `layouts.base`
196
+ - `resources/views/partials/footer.blade.php` → `partials.footer`
@@ -0,0 +1,18 @@
1
+ """
2
+ Blade Template Compiler Package
3
+ """
4
+
5
+ import sys
6
+ import os
7
+
8
+ # Add current directory to Python path for relative imports
9
+ current_dir = os.path.dirname(os.path.abspath(__file__))
10
+ if current_dir not in sys.path:
11
+ sys.path.insert(0, current_dir)
12
+
13
+ from main_compiler import BladeCompiler
14
+
15
+ __version__ = "1.0.0"
16
+ __author__ = "Blade Compiler Team"
17
+
18
+ __all__ = ['BladeCompiler']