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,203 @@
1
+ /**
2
+ * Utility functions for the compiler
3
+ */
4
+
5
+ function extractBalancedParentheses(text, startPos) {
6
+ /** Extract content inside balanced parentheses starting from startPos */
7
+ if (startPos >= text.length || text[startPos] !== '(') {
8
+ return [null, startPos];
9
+ }
10
+
11
+ let parenCount = 0;
12
+ const contentStart = startPos + 1;
13
+ let i = startPos;
14
+
15
+ while (i < text.length) {
16
+ if (text[i] === '(') {
17
+ parenCount += 1;
18
+ } else if (text[i] === ')') {
19
+ parenCount -= 1;
20
+ if (parenCount === 0) {
21
+ const content = text.substring(contentStart, i);
22
+ return [content, i + 1];
23
+ }
24
+ }
25
+ i += 1;
26
+ }
27
+
28
+ // Unbalanced parentheses
29
+ return [text.substring(contentStart), text.length];
30
+ }
31
+
32
+ function formatAttrs(attrsDict) {
33
+ /** Format attributes dictionary to JavaScript object string */
34
+ return JSON.stringify(attrsDict);
35
+ }
36
+
37
+ function normalizeQuotes(expr) {
38
+ /** Normalize single quotes to double quotes in JSON */
39
+ if (!expr) {
40
+ return expr;
41
+ }
42
+
43
+ // Replace single quotes with double quotes, but be careful with nested quotes
44
+ return expr.replace(/'([^']*)'/g, '"$1"');
45
+ }
46
+
47
+ function formatJsOutput(content, indentLevel = 0) {
48
+ /** Format JavaScript output with proper indentation */
49
+ const lines = content.split('\n');
50
+ const formattedLines = [];
51
+
52
+ for (const line of lines) {
53
+ if (line.trim()) {
54
+ formattedLines.push(' '.repeat(indentLevel) + line.trim());
55
+ } else {
56
+ formattedLines.push('');
57
+ }
58
+ }
59
+
60
+ return formattedLines.join('\n');
61
+ }
62
+
63
+ function splitByComma(text) {
64
+ /** Split text by comma, respecting nested parentheses and quotes */
65
+ const result = [];
66
+ let current = '';
67
+ let depth = 0;
68
+ let inQuotes = false;
69
+ let quoteChar = '';
70
+
71
+ for (let i = 0; i < text.length; i++) {
72
+ const char = text[i];
73
+
74
+ if (!inQuotes && (char === '"' || char === "'")) {
75
+ inQuotes = true;
76
+ quoteChar = char;
77
+ } else if (inQuotes && char === quoteChar) {
78
+ inQuotes = false;
79
+ quoteChar = '';
80
+ } else if (!inQuotes && char === '(') {
81
+ depth++;
82
+ } else if (!inQuotes && char === ')') {
83
+ depth--;
84
+ } else if (!inQuotes && depth === 0 && char === ',') {
85
+ result.push(current.trim());
86
+ current = '';
87
+ continue;
88
+ }
89
+
90
+ current += char;
91
+ }
92
+
93
+ if (current.trim()) {
94
+ result.push(current.trim());
95
+ }
96
+
97
+ return result;
98
+ }
99
+
100
+ function escapeRegex(string) {
101
+ /** Escape special regex characters */
102
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
103
+ }
104
+
105
+ function camelCase(str) {
106
+ /** Convert string to camelCase */
107
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => {
108
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
109
+ }).replace(/\s+/g, '');
110
+ }
111
+
112
+ function kebabCase(str) {
113
+ /** Convert string to kebab-case */
114
+ return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
115
+ }
116
+
117
+ function snakeCase(str) {
118
+ /** Convert string to snake_case */
119
+ return str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
120
+ }
121
+
122
+ function pascalCase(str) {
123
+ /** Convert string to PascalCase */
124
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word) => {
125
+ return word.toUpperCase();
126
+ }).replace(/\s+/g, '');
127
+ }
128
+
129
+ function indent(text, level = 1, char = ' ') {
130
+ /** Add indentation to text */
131
+ const indentStr = char.repeat(level);
132
+ return text.split('\n').map(line => line ? indentStr + line : line).join('\n');
133
+ }
134
+
135
+ function dedent(text) {
136
+ /** Remove common leading whitespace from text */
137
+ const lines = text.split('\n');
138
+ const minIndent = lines
139
+ .filter(line => line.trim())
140
+ .reduce((min, line) => Math.min(min, line.match(/^\s*/)[0].length), Infinity);
141
+
142
+ return lines.map(line => line.substring(minIndent)).join('\n');
143
+ }
144
+
145
+ function replaceAll(str, replacements, startDelim = '{', endDelim = '}') {
146
+ /** Replace all placeholders in string with values from object */
147
+ if (typeof replacements !== 'object' || replacements === null) {
148
+ return str;
149
+ }
150
+
151
+ let result = str;
152
+ const regex = new RegExp(`${escapeRegex(startDelim)}([^${escapeRegex(endDelim)}]+)${escapeRegex(endDelim)}`, 'g');
153
+
154
+ return result.replace(regex, (match, key) => {
155
+ const trimmedKey = key.trim();
156
+ return replacements.hasOwnProperty(trimmedKey) ? replacements[trimmedKey] : match;
157
+ });
158
+ }
159
+
160
+ function isString(value) {
161
+ /** Check if value is string */
162
+ return typeof value === 'string';
163
+ }
164
+
165
+ function isObject(value) {
166
+ /** Check if value is object (but not null or array) */
167
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
168
+ }
169
+
170
+ function isArray(value) {
171
+ /** Check if value is array */
172
+ return Array.isArray(value);
173
+ }
174
+
175
+ function isEmpty(value) {
176
+ /** Check if value is empty */
177
+ if (value === null || value === undefined) return true;
178
+ if (isString(value)) return value.length === 0;
179
+ if (isArray(value)) return value.length === 0;
180
+ if (isObject(value)) return Object.keys(value).length === 0;
181
+ return false;
182
+ }
183
+
184
+ module.exports = {
185
+ extractBalancedParentheses,
186
+ formatAttrs,
187
+ normalizeQuotes,
188
+ formatJsOutput,
189
+ splitByComma,
190
+ escapeRegex,
191
+ camelCase,
192
+ kebabCase,
193
+ snakeCase,
194
+ pascalCase,
195
+ indent,
196
+ dedent,
197
+ replaceAll,
198
+ isString,
199
+ isObject,
200
+ isArray,
201
+ isEmpty
202
+ };
203
+
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Wrapper parser
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ class WrapperParser {
9
+ constructor() {
10
+ // No initialization needed
11
+ }
12
+
13
+ parseWrapperFile() {
14
+ /** Parse wrapper file */
15
+ // For now, return empty content
16
+ // In a real implementation, this would read and parse the wrapper file
17
+ return {
18
+ wrapperFunctionContent: '',
19
+ wrapperConfigContent: ''
20
+ };
21
+ }
22
+ }
23
+
24
+ module.exports = WrapperParser;
25
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "one-laravel-blade-compiler",
3
+ "version": "1.0.0",
4
+ "description": "Node.js Blade Compiler for One Laravel",
5
+ "main": "build.js",
6
+ "scripts": {
7
+ "build": "node build.js",
8
+ "build:verbose": "node build.js --verbose",
9
+ "test": "node test-compiler.js"
10
+ },
11
+ "dependencies": {
12
+ "glob": "^8.1.0"
13
+ },
14
+ "devDependencies": {},
15
+ "keywords": [
16
+ "blade",
17
+ "compiler",
18
+ "template",
19
+ "nodejs"
20
+ ],
21
+ "author": "One Laravel Team",
22
+ "license": "MIT"
23
+ }
24
+
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Test script for Node.js Blade Compiler
3
+ */
4
+
5
+ const BladeCompiler = require('./compiler/main-compiler');
6
+
7
+ // Test Blade template
8
+ const testBladeCode = `
9
+ @extends('layouts.base')
10
+
11
+ @section('document.body')
12
+ <div class="container">
13
+ <h1>Welcome {{ $user->name }}</h1>
14
+
15
+ @if($posts && count($posts) > 0)
16
+ <div class="posts">
17
+ @foreach($posts as $post)
18
+ <div class="post" @click(handlePostClick($post->id))>
19
+ <h3>{{ $post->title }}</h3>
20
+ <p>{{ $post->content }}</p>
21
+ </div>
22
+ @endforeach
23
+ </div>
24
+ @else
25
+ <p>No posts available.</p>
26
+ @endif
27
+
28
+ <button @click(handleButtonClick) class="btn btn-primary">
29
+ Click Me
30
+ </button>
31
+ </div>
32
+ @endsection
33
+ `;
34
+
35
+ // Test the compiler
36
+ console.log('Testing Node.js Blade Compiler...\n');
37
+
38
+ try {
39
+ const compiler = new BladeCompiler();
40
+ const jsCode = compiler.compileBladeToJs(testBladeCode, 'web.test');
41
+
42
+ console.log('✅ Compilation successful!');
43
+ console.log('\n=== Generated JavaScript ===');
44
+ console.log(jsCode);
45
+
46
+ } catch (error) {
47
+ console.error('❌ Compilation failed:', error.message);
48
+ console.error(error.stack);
49
+ }
50
+
51
+ console.log('\n=== Test completed ===');
52
+
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Node.js Blade Compiler Runner
5
+ * This script can be used as a drop-in replacement for the Python compiler
6
+ */
7
+
8
+ const path = require('path');
9
+ const NodeBuildScript = require('./node/build');
10
+
11
+ // Change to the project root directory
12
+ process.chdir(path.join(__dirname, '..'));
13
+
14
+ // Create and run the build script
15
+ const buildScript = new NodeBuildScript();
16
+
17
+ // Parse command line arguments
18
+ const args = process.argv.slice(2);
19
+ if (args.includes('--verbose') || args.includes('-v')) {
20
+ buildScript.setVerbose(true);
21
+ }
22
+
23
+ // Run build
24
+ buildScript.run().catch(error => {
25
+ console.error('Build failed:', error);
26
+ process.exit(1);
27
+ });
28
+
@@ -0,0 +1,92 @@
1
+ <?php
2
+
3
+ /**
4
+ * Script Chuẩn Hóa Tên Thư Mục
5
+ *
6
+ * Script này đổi tên các thư mục trong src/ để phù hợp với PSR-4:
7
+ * - core → Core
8
+ * - modules → Modules
9
+ * - contexts → Contexts
10
+ * - shared → Shared
11
+ * - support → Support
12
+ * - infrastructure → Infrastructure
13
+ */
14
+
15
+ class DirectoryStandardizer
16
+ {
17
+ private array $mappings = [
18
+ 'core' => 'Core',
19
+ 'modules' => 'Modules',
20
+ 'contexts' => 'Contexts',
21
+ 'shared' => 'Shared',
22
+ 'support' => 'Support',
23
+ 'infrastructure' => 'Infrastructure',
24
+ ];
25
+
26
+ private string $baseDir;
27
+ private int $directoriesRenamed = 0;
28
+ private array $errors = [];
29
+
30
+ public function __construct(string $baseDir = 'src')
31
+ {
32
+ $this->baseDir = $baseDir;
33
+ }
34
+
35
+ public function standardize(): void
36
+ {
37
+ echo "🚀 Bắt đầu chuẩn hóa tên thư mục...\n\n";
38
+
39
+ if (!is_dir($this->baseDir)) {
40
+ echo "❌ Thư mục {$this->baseDir} không tồn tại!\n";
41
+ return;
42
+ }
43
+
44
+ foreach ($this->mappings as $old => $new) {
45
+ $oldPath = $this->baseDir . '/' . $old;
46
+ $newPath = $this->baseDir . '/' . $new;
47
+
48
+ if (is_dir($oldPath)) {
49
+ if (is_dir($newPath)) {
50
+ echo "⚠️ Thư mục {$newPath} đã tồn tại, bỏ qua {$oldPath}\n";
51
+ continue;
52
+ }
53
+
54
+ if (rename($oldPath, $newPath)) {
55
+ echo "✓ Đã đổi tên: {$old} → {$new}\n";
56
+ $this->directoriesRenamed++;
57
+ } else {
58
+ $error = "❌ Không thể đổi tên: {$oldPath} → {$newPath}";
59
+ echo $error . "\n";
60
+ $this->errors[] = $error;
61
+ }
62
+ } else {
63
+ echo "⚠️ Thư mục {$oldPath} không tồn tại, bỏ qua\n";
64
+ }
65
+ }
66
+
67
+ echo "\n✅ Hoàn thành!\n";
68
+ echo "📊 Thống kê:\n";
69
+ echo " - Số thư mục đã đổi tên: {$this->directoriesRenamed}\n";
70
+
71
+ if (!empty($this->errors)) {
72
+ echo "\n❌ Lỗi:\n";
73
+ foreach ($this->errors as $error) {
74
+ echo " - {$error}\n";
75
+ }
76
+ }
77
+
78
+ echo "\n💡 Lưu ý: Sau khi đổi tên thư mục, cần:\n";
79
+ echo " 1. Cập nhật namespace trong tất cả file PHP\n";
80
+ echo " 2. Chạy: composer dump-autoload\n";
81
+ echo " 3. Cập nhật các đường dẫn trong config files\n";
82
+ }
83
+ }
84
+
85
+ // Chạy standardization
86
+ if (php_sapi_name() === 'cli') {
87
+ $standardizer = new DirectoryStandardizer('src');
88
+ $standardizer->standardize();
89
+ } else {
90
+ echo "Script này chỉ chạy được từ command line.\n";
91
+ }
92
+
@@ -1,5 +1,5 @@
1
1
  import { SEOTagConfig } from './SEOConfig.js';
2
- import { ViewTemplates } from './ViewTemplate.js';
2
+ // ViewTemplates import removed
3
3
  import { hasData, uniqId } from '../helpers/utils.js';
4
4
  import { View, ViewEngine } from './View.js';
5
5
  import { ViewState } from './ViewState.js';
@@ -126,7 +126,7 @@ export class ViewManager {
126
126
  /**
127
127
  * @type {Object<string, ViewEngine>}
128
128
  */
129
- this.templates = ViewTemplates;
129
+ this.templates = viewLoader.registry || {};
130
130
  /**
131
131
  * @type {Object<string, string>}
132
132
  */
@@ -295,8 +295,8 @@ export class ViewManager {
295
295
  this._changedSections = [];
296
296
 
297
297
  // Initialize views if not already done
298
- if (!this.templates) {
299
- this.templates = ViewTemplates;
298
+ if (!this.templates || Object.keys(this.templates).length === 0) {
299
+ this.templates = viewLoader.registry || {};
300
300
  }
301
301
 
302
302
  // Initialize current scope
@@ -0,0 +1,2 @@
1
+ import { View } from '../app/view.js';
2
+ import { App } from '../app/init-global.js';
@@ -0,0 +1,13 @@
1
+ export const initTemplates = function (__SYSTEM_DATA__ = {}) {
2
+ let { App, View, tplData = {} } = __SYSTEM_DATA__ || {};
3
+ const evaluate = (fn) => {
4
+ try {
5
+ return fn();
6
+ } catch (error) {
7
+ console.error(error);
8
+ return '';
9
+ }
10
+ }
11
+
12
+ //allScobe
13
+ };
@@ -0,0 +1,71 @@
1
+ function wraper() {
2
+ // start wrapper
3
+
4
+
5
+ // this is the wrapper element
6
+
7
+ const __WRAPPER_ELEMENT__ = document.createElement('template');
8
+ const __REFS__ = [];
9
+ const self = new View.Engine(__VIEW_PATH__);
10
+ const __STATE__ = self.__.states;
11
+
12
+
13
+
14
+ self.setApp(App);
15
+
16
+
17
+ const parseRefs = (frag) => {
18
+ for (let i = 0; i < frag.childNodes.length; i++) {
19
+ const node = frag.childNodes[i];
20
+ __REFS__.push(node);
21
+ }
22
+ }
23
+ const createHtml = (template) => {
24
+ try {
25
+ __WRAPPER_ELEMENT__.innerHTML = template;
26
+ } catch (error) {
27
+ console.error(error);
28
+ __WRAPPER_ELEMENT__.innerHTML = '';
29
+ }
30
+ let frag = __WRAPPER_ELEMENT__.content;
31
+ parseRefs(frag);
32
+ return frag;
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @param {*} value
38
+ * @returns {[any, function, string]}
39
+ */
40
+ const useState = (value) => {
41
+ return __STATE__.__useState(value);
42
+ };
43
+ const updateRealState = (state) => {
44
+ __STATE__.__.updateRealState(state);
45
+ };
46
+
47
+ const lockUpdateRealState = () => {
48
+ __STATE__.__.lockUpdateRealState();
49
+ };
50
+ const updateStateByKey = (key, state) => {
51
+ __STATE__.__.updateStateByKey(key, state);
52
+ };
53
+
54
+ if(typeof $$$DATA$$$.__SSR_VIEW_ID__ !== 'undefined'){
55
+ delete $$$DATA$$$.__SSR_VIEW_ID__;
56
+ }
57
+
58
+ // end wrapper
59
+
60
+ }
61
+ const WRAPPER_CONFIG = {
62
+ // start wrapper config
63
+
64
+ __props__: ["__WRAPPER_ELEMENT__", "createHtml", "__REFS__", "parseRefs"],
65
+ __WRAPPER_ELEMENT__: __WRAPPER_ELEMENT__,
66
+ refs: __REFS__,
67
+ parseRefs: parseRefs,
68
+ createHtml: createHtml,
69
+
70
+ // end wrapper config
71
+ };