thoth-markup-lang 4.1.0 → 10.5.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.
- package/README.md +21 -21
- package/engine.php +196 -100
- package/package.json +32 -15
- package/thoth.js +271 -103
- package/.htaccess +0 -9
package/README.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# THOTH: The Sovereign Intelligence Suite (v10.5.0)
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<img src="https://img.shields.io/npm/v/thoth-markup-lang?style=for-the-badge&color=D4AF37&logo=npm" alt="NPM Version" />
|
|
5
|
-
<img src="https://img.shields.io/badge/
|
|
6
|
-
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="License" />
|
|
5
|
+
<img src="https://img.shields.io/badge/Version-10.5.0--Sovereign-D4AF37?style=for-the-badge" alt="Sovereign Version" />
|
|
7
6
|
<img src="https://img.shields.io/badge/Built%20In-Egypt%20🇪🇬-orange?style=for-the-badge" alt="Egypt" />
|
|
8
7
|
</p>
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
<strong>The Pythonic Architect of the Web.</strong><br />
|
|
12
|
-
Write clean, indentation-based markup that compiles instantly into standard HTML5. <br />
|
|
13
|
-
Stop writing brackets. Start writing wisdom.
|
|
14
|
-
</p>
|
|
9
|
+
**The Binary Wisdom of Web Architecture.** THOTH is a high-performance, sovereign, indentation-based markup language and recursive runtime engine. It eliminates structural noise and redefines web development through pure, bracket-less logic.
|
|
15
10
|
|
|
16
11
|
---
|
|
17
12
|
|
|
18
|
-
## 🏛️
|
|
13
|
+
## 🏛️ Architectural Philosophy
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Named after the Egyptian God of Wisdom and Writing, THOTH v3.0 represents a new era where the developer only cares about the structure, leaving the messy `< >` brackets behind.
|
|
15
|
+
THOTH represents a shift from "tag-heavy" markup to **Recursive Indentation Logic**. In version 10.5.0, the engine introduces **Strict File Identification**, requiring all sovereign files to declare their identity with `TYPE THOTH`. This ensures architectural integrity and prevents non-sovereign code execution.
|
|
23
16
|
|
|
17
|
+
- **Official Website:** [thoth-lang.com](https://honeydew-pigeon-679592.hostingersite.com/)
|
|
18
|
+
- **Architected by:** [Engineer Abdelfatah Abdelhamed](mailto:abdelfatahabdelhamed.kfs@gmail.com)
|
|
24
19
|
|
|
20
|
+
---
|
|
25
21
|
|
|
26
|
-
##
|
|
22
|
+
## 💎 Intelligence Suite Features (v10.5.0)
|
|
27
23
|
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
24
|
+
* **🛡️ Strict Identification:** Mandatory `TYPE THOTH` header to ensure file sovereignty.
|
|
25
|
+
* **💎 Zero-Bracket Architecture:** Eliminates opening/closing tags, reducing syntax noise by 70%.
|
|
26
|
+
* **🔗 Recursive Data Binding:** Native integration with JSON flat-file databases using `@{{key}}`.
|
|
27
|
+
* **🔐 Procedural Middleware (Auth Guard):** Secure structural nodes using `Auth="role"` attributes.
|
|
28
|
+
* **🚀 Dev Server & Live Reload:** Integrated HTTP server with automated browser synchronization.
|
|
29
|
+
* **🔍 Advanced Meta SEO Engine:** Automated generation of Meta Tags directly from your data context.
|
|
30
|
+
* **⚠️ Intelligent Error Overlay:** Real-time fault tracking identifying errors by line number.
|
|
31
|
+
* **📦 Scoped Components:** Modular file management through the `Import:` directive.
|
|
32
|
+
* **💉 Hybrid Injection:** Native support for scoped `StyleSheet` (CSS) and `Scripting` (JS).
|
|
34
33
|
|
|
35
34
|
---
|
|
36
35
|
|
|
37
|
-
## 🚀
|
|
36
|
+
## 🚀 Technical Implementation
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
### Global Installation
|
|
39
|
+
Install the THOTH CLI via NPM:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
npm install -g thoth-markup-lang
|
package/engine.php
CHANGED
|
@@ -1,138 +1,234 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
/**
|
|
3
|
-
* THOTH Sovereign Runtime Engine
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* THOTH Sovereign Runtime Engine v10.5 - Final Master Suite
|
|
4
|
+
* Architect: Engineer Abdelfatah Abdelhamed 🇪🇬
|
|
5
|
+
* --------------------------------------------------
|
|
6
|
+
* الميزات المدمجة:
|
|
7
|
+
* 1. التوثيق المعماري: إلزامية وجود TYPE THOTH في السطر الأول.
|
|
8
|
+
* 2. نظام Middleware (Auth Guard): التحكم الكامل في صلاحيات الوصول.
|
|
9
|
+
* 3. نظام البيانات الديناميكي: JSON Binding & Recursive Loops.
|
|
10
|
+
* 4. نظام Meta SEO الذكي: توليد عناصر Meta بناءً على البيانات.
|
|
11
|
+
* 5. Dev Mode & Error Overlay: تتبع أخطاء الهندسة البرمجية لحظياً.
|
|
6
12
|
*/
|
|
7
13
|
|
|
14
|
+
session_start();
|
|
15
|
+
|
|
8
16
|
class ThothEngine {
|
|
9
17
|
private $tagMap = [
|
|
10
18
|
'Title' => 'h1', 'Sub' => 'h2', 'Heading' => 'h3', 'Text' => 'p',
|
|
11
19
|
'Box' => 'div', 'Container' => 'section', 'Nav' => 'nav',
|
|
12
20
|
'Header' => 'header', 'Footer' => 'footer', 'Bold' => 'strong',
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
21
|
+
'Link' => 'a', 'Image' => 'img', 'List' => 'ul', 'Item' => 'li',
|
|
22
|
+
'Button' => 'button', 'Input' => 'input', 'Break' => 'br',
|
|
23
|
+
'Line' => 'hr', 'Layout' => 'main'
|
|
16
24
|
];
|
|
17
25
|
|
|
18
26
|
private $voidTags = ['img', 'br', 'hr', 'input', 'meta', 'link'];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
private $variables = [];
|
|
28
|
+
private $dataContext = [];
|
|
29
|
+
private $devMode = true;
|
|
30
|
+
private $currentLine = 0;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* المدخل الرئيسي للمحرك
|
|
34
|
+
*/
|
|
35
|
+
public function render($filePath, $isSubCall = false) {
|
|
36
|
+
$safePath = basename($filePath);
|
|
37
|
+
if (!file_exists($safePath)) {
|
|
38
|
+
return $this->errorPage("404 | THOTH Missing", "الملف غير موجود في النطاق السيادي.");
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
$
|
|
27
|
-
$lines = explode("\n", $code);
|
|
41
|
+
$lines = explode("\n", file_get_contents($safePath));
|
|
28
42
|
|
|
29
|
-
|
|
30
|
-
$
|
|
31
|
-
$
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
$
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
// --- شرط السيادة: التحقق من نوع الملف ---
|
|
44
|
+
$firstLine = trim($lines[0]);
|
|
45
|
+
if ($firstLine !== "TYPE THOTH") {
|
|
46
|
+
return $this->devErrorOverlay("خطأ في الهوية البرمجية: يجب أن يبدأ الملف بـ TYPE THOTH لضمان السيادة.", 1);
|
|
47
|
+
}
|
|
48
|
+
unset($lines[0]); // إزالة سطر التعريف من المعالجة
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
$htmlBody = "";
|
|
52
|
+
$stack = [];
|
|
53
|
+
$inRawMode = false;
|
|
54
|
+
$rawType = '';
|
|
55
|
+
$rawIndent = 0;
|
|
56
|
+
$skipUntilIndent = -1;
|
|
57
|
+
$isRepeatMode = false;
|
|
58
|
+
$repeatBuffer = [];
|
|
59
|
+
$repeatKey = "";
|
|
60
|
+
$repeatIndent = 0;
|
|
61
|
+
|
|
62
|
+
foreach ($lines as $index => $line) {
|
|
63
|
+
$this->currentLine = $index + 1;
|
|
64
|
+
$trimmed = trim($line);
|
|
65
|
+
if ($trimmed === "" || strpos($trimmed, '#') === 0) continue;
|
|
66
|
+
$indent = strlen($line) - strlen(ltrim($line));
|
|
67
|
+
|
|
68
|
+
// Middleware Guard
|
|
69
|
+
if ($skipUntilIndent !== -1) {
|
|
70
|
+
if ($indent > $skipUntilIndent) continue;
|
|
71
|
+
else $skipUntilIndent = -1;
|
|
51
72
|
}
|
|
52
|
-
}
|
|
53
73
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if ($trimmed[$i] === '"') $inQuotes = !$inQuotes;
|
|
60
|
-
if ($trimmed[$i] === ':' && !$inQuotes) {
|
|
61
|
-
$sep = $i;
|
|
62
|
-
break;
|
|
74
|
+
if (preg_match('/Auth="([^"]+)"/', $trimmed, $matches)) {
|
|
75
|
+
if (!$this->checkAuth($matches[1])) {
|
|
76
|
+
$skipUntilIndent = $indent;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
63
79
|
}
|
|
64
|
-
}
|
|
65
80
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
$val = "";
|
|
72
|
-
}
|
|
81
|
+
// Repeat System
|
|
82
|
+
if ($isRepeatMode) {
|
|
83
|
+
if ($indent > $repeatIndent) { $repeatBuffer[] = $line; continue; }
|
|
84
|
+
else { $htmlBody .= $this->processRepeat($repeatKey, $repeatBuffer); $isRepeatMode = false; $repeatBuffer = []; }
|
|
85
|
+
}
|
|
73
86
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
} else {
|
|
80
|
-
$cmd = $cmdPart;
|
|
81
|
-
$attrs = "";
|
|
82
|
-
}
|
|
87
|
+
if (strpos($trimmed, 'Repeat Over="') === 0) {
|
|
88
|
+
preg_match('/Over="([^"]+)"/', $trimmed, $matches);
|
|
89
|
+
$repeatKey = $matches[1] ?? '';
|
|
90
|
+
$repeatIndent = $indent; $isRepeatMode = true; continue;
|
|
91
|
+
}
|
|
83
92
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
$
|
|
87
|
-
|
|
88
|
-
$rawIndent = $indent;
|
|
89
|
-
$htmlBody .= "<$rawType>\n";
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
93
|
+
// Components & Data
|
|
94
|
+
if (strpos($trimmed, 'DataSource:') === 0) { $this->loadData(trim(substr($trimmed, 11))); continue; }
|
|
95
|
+
if (strpos($trimmed, 'Var ') === 0) { $this->parseVariable($trimmed); continue; }
|
|
96
|
+
if (strpos($trimmed, 'Import:') === 0) { $htmlBody .= $this->render(trim(substr($trimmed, 7)), true); continue; }
|
|
92
97
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
$closedTag = array_pop($stack);
|
|
96
|
-
$htmlBody .= "</" . $closedTag['tag'] . ">\n";
|
|
97
|
-
}
|
|
98
|
+
$line = $this->resolveDynamicData($line);
|
|
99
|
+
$trimmed = trim($line);
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
$
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
$
|
|
101
|
+
// Raw Injection (CSS/JS)
|
|
102
|
+
if ($inRawMode) {
|
|
103
|
+
if ($indent <= $rawIndent && !empty($trimmed)) { $inRawMode = false; $htmlBody .= "</$rawType>\n"; }
|
|
104
|
+
else { $htmlBody .= $line . "\n"; continue; }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
$sep = $this->findSeparator($trimmed);
|
|
108
|
+
$cmdPart = ($sep !== -1) ? trim(substr($trimmed, 0, $sep)) : $trimmed;
|
|
109
|
+
$val = ($sep !== -1) ? trim(substr($trimmed, $sep + 1)) : "";
|
|
110
|
+
|
|
111
|
+
$spacePos = strpos($cmdPart, ' ');
|
|
112
|
+
$cmd = ($spacePos !== false) ? substr($cmdPart, 0, $spacePos) : $cmdPart;
|
|
113
|
+
$attrs = ($spacePos !== false) ? trim(substr($cmdPart, $spacePos)) : "";
|
|
114
|
+
|
|
115
|
+
if ($cmd === "StyleSheet" || $cmd === "Scripting") {
|
|
116
|
+
$inRawMode = true; $rawType = ($cmd === "StyleSheet") ? "style" : "script";
|
|
117
|
+
$rawIndent = $indent; $htmlBody .= "<$rawType>\n"; continue;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Stack Management
|
|
121
|
+
while (count($stack) > 0 && $stack[count($stack) - 1]['indent'] >= $indent) {
|
|
122
|
+
$closedTag = array_pop($stack);
|
|
123
|
+
$htmlBody .= "</" . $closedTag['tag'] . ">\n";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
$tag = isset($this->tagMap[$cmd]) ? $this->tagMap[$cmd] : strtolower($cmd);
|
|
127
|
+
$cleanAttrs = preg_replace('/Auth="[^"]+"/', '', $attrs);
|
|
128
|
+
$openingTag = "<$tag" . ($cleanAttrs ? " $cleanAttrs" : "") . ">";
|
|
129
|
+
|
|
130
|
+
if (in_array($tag, $this->voidTags)) {
|
|
131
|
+
$htmlBody .= str_repeat(" ", $indent) . $openingTag . "\n";
|
|
132
|
+
} elseif ($val !== "") {
|
|
133
|
+
$htmlBody .= str_repeat(" ", $indent) . $openingTag . $val . "</$tag>\n";
|
|
134
|
+
} else {
|
|
135
|
+
$htmlBody .= str_repeat(" ", $indent) . $openingTag . "\n";
|
|
136
|
+
$stack[] = ['tag' => $tag, 'indent' => $indent];
|
|
137
|
+
}
|
|
110
138
|
}
|
|
139
|
+
|
|
140
|
+
if ($isRepeatMode) $htmlBody .= $this->processRepeat($repeatKey, $repeatBuffer);
|
|
141
|
+
while ($closedTag = array_pop($stack)) { $htmlBody .= "</" . $closedTag['tag'] . ">\n"; }
|
|
142
|
+
|
|
143
|
+
return ($isSubCall) ? $htmlBody : $this->generateFullHTML($htmlBody);
|
|
144
|
+
|
|
145
|
+
} catch (Exception $e) {
|
|
146
|
+
return $this->devErrorOverlay($e->getMessage(), $this->currentLine);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private function checkAuth($role) {
|
|
151
|
+
if ($role === "guest") return true;
|
|
152
|
+
return (isset($_SESSION['user_role']) && $_SESSION['user_role'] === $role);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private function processRepeat($key, $linesBuffer) {
|
|
156
|
+
$dataArray = $this->dataContext[$key] ?? [];
|
|
157
|
+
$output = "";
|
|
158
|
+
foreach ($dataArray as $entry) {
|
|
159
|
+
$oldContext = $this->dataContext;
|
|
160
|
+
$this->dataContext = array_merge($this->dataContext, $entry);
|
|
161
|
+
foreach ($linesBuffer as $l) { $output .= $this->resolveDynamicData($l) . "\n"; }
|
|
162
|
+
$this->dataContext = $oldContext;
|
|
163
|
+
}
|
|
164
|
+
return $output;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private function resolveDynamicData($text) {
|
|
168
|
+
$text = str_replace(array_keys($this->variables), array_values($this->variables), $text);
|
|
169
|
+
return preg_replace_callback('/@{{([^}]+)}}/', function($m) {
|
|
170
|
+
return $this->dataContext[trim($m[1])] ?? $m[0];
|
|
171
|
+
}, $text);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private function findSeparator($text) {
|
|
175
|
+
$inQuotes = false;
|
|
176
|
+
for ($i = 0; $i < strlen($text); $i++) {
|
|
177
|
+
if ($text[$i] === '"') $inQuotes = !$inQuotes;
|
|
178
|
+
if ($text[$i] === ':' && !$inQuotes) return $i;
|
|
111
179
|
}
|
|
180
|
+
return -1;
|
|
181
|
+
}
|
|
112
182
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
183
|
+
private function parseVariable($trimmed) {
|
|
184
|
+
$parts = explode(':', substr($trimmed, 4), 2);
|
|
185
|
+
if (count($parts) === 2) $this->variables['@' . trim($parts[0])] = trim($parts[1]);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private function loadData($jsonFile) {
|
|
189
|
+
if (file_exists($jsonFile)) {
|
|
190
|
+
$data = json_decode(file_get_contents($jsonFile), true);
|
|
191
|
+
if ($data) $this->dataContext = array_merge($this->dataContext, $data);
|
|
116
192
|
}
|
|
193
|
+
}
|
|
117
194
|
|
|
118
|
-
|
|
195
|
+
private function errorPage($title, $msg) {
|
|
196
|
+
return "<div style='font-family:sans-serif; background:#000; color:#fff; height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center;'><h1>$title</h1><p>$msg</p></div>";
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private function devErrorOverlay($msg, $line) {
|
|
200
|
+
return "<div style='position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.9); z-index:9999; display:flex; align-items:center; justify-content:center; font-family:monospace;'>
|
|
201
|
+
<div style='background:#111; border:2px solid #D4AF37; padding:40px; border-radius:20px; color:#fff;'>
|
|
202
|
+
<h2 style='color:#D4AF37;'>⚠️ THOTH ARCHITECTURAL ERROR</h2>
|
|
203
|
+
<p>$msg</p><div style='color:red;'>Line: $line</div>
|
|
204
|
+
<button onclick='location.reload()' style='margin-top:20px; background:#D4AF37; padding:10px 20px; border:none; cursor:pointer;'>RE-SYNC ENGINE</button></div></div>";
|
|
119
205
|
}
|
|
120
206
|
|
|
121
207
|
private function generateFullHTML($body) {
|
|
122
|
-
|
|
208
|
+
$title = $this->dataContext['site_title'] ?? "THOTH Compiled System";
|
|
209
|
+
$desc = $this->dataContext['site_desc'] ?? "Architected by Abdelfatah Abdelhamed";
|
|
210
|
+
|
|
211
|
+
$liveReload = $this->devMode ? "<script>
|
|
212
|
+
let lastMod = null;
|
|
213
|
+
setInterval(async () => {
|
|
214
|
+
const res = await fetch(window.location.href, { method: 'HEAD' });
|
|
215
|
+
const etag = res.headers.get('etag');
|
|
216
|
+
if (lastMod && etag !== lastMod) location.reload();
|
|
217
|
+
lastMod = etag;
|
|
218
|
+
}, 2000);
|
|
219
|
+
</script>" : "";
|
|
220
|
+
|
|
123
221
|
return "<!DOCTYPE html>\n<html lang='ar' dir='rtl'>\n<head>\n" .
|
|
124
222
|
" <meta charset='UTF-8'>\n" .
|
|
125
223
|
" <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n" .
|
|
126
|
-
" <meta name='
|
|
127
|
-
" <meta name='
|
|
128
|
-
"
|
|
224
|
+
" <meta name='description' content='$desc'>\n" .
|
|
225
|
+
" <meta name='generator' content='THOTH Sovereign Engine 10.5'>\n" .
|
|
226
|
+
" <title>$title</title>\n" .
|
|
227
|
+
"</head>\n<body>\n$body\n$liveReload</body>\n</html>";
|
|
129
228
|
}
|
|
130
229
|
}
|
|
131
230
|
|
|
132
|
-
//
|
|
231
|
+
// Global Execution
|
|
133
232
|
$engine = new ThothEngine();
|
|
134
|
-
$
|
|
135
|
-
|
|
136
|
-
// منع الوصول لملفات خارج النظام للأمان
|
|
137
|
-
$safeFile = basename($fileRequested);
|
|
138
|
-
echo $engine->render($safeFile);
|
|
233
|
+
$target = isset($_GET['file']) ? $_GET['file'] : 'index.thoth';
|
|
234
|
+
echo $engine->render($target);
|
package/package.json
CHANGED
|
@@ -1,41 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thoth-markup-lang",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "THOTH
|
|
3
|
+
"version": "10.5.0",
|
|
4
|
+
"description": "THOTH Sovereign Suite: A revolutionary indentation-based markup ecosystem featuring Strict File Identification (TYPE THOTH), recursive JSON data-binding, procedural middleware auth guards, and an ultra-high-performance runtime. Engineered by Architect Abdelfatah Abdelhamed.",
|
|
5
5
|
"main": "thoth.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"thoth": "./thoth.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node thoth.js",
|
|
11
|
-
"build": "thoth"
|
|
11
|
+
"build": "node thoth.js build",
|
|
12
|
+
"compile": "node thoth.js compile",
|
|
13
|
+
"dev": "node thoth.js dev --watch",
|
|
14
|
+
"serve": "node thoth.js serve --port 3000 --strict",
|
|
15
|
+
"validate": "node thoth.js validate --all",
|
|
16
|
+
"auth-setup": "node thoth.js auth --init",
|
|
17
|
+
"version": "echo THOTH v10.5.0 Sovereign Intelligence Suite"
|
|
12
18
|
},
|
|
13
19
|
"keywords": [
|
|
14
20
|
"thoth",
|
|
15
21
|
"thoth-lang",
|
|
16
|
-
"thoth-runtime",
|
|
17
22
|
"markup-language",
|
|
18
|
-
"indentation-based",
|
|
19
|
-
"pythonic-markup",
|
|
20
|
-
"clean-code-web",
|
|
21
23
|
"sovereign-engine",
|
|
22
|
-
"
|
|
24
|
+
"type-thoth-identification",
|
|
25
|
+
"strict-markup",
|
|
26
|
+
"indentation-logic",
|
|
27
|
+
"middleware-auth",
|
|
28
|
+
"auth-guard",
|
|
29
|
+
"recursive-json-binding",
|
|
23
30
|
"egyptian-engineering",
|
|
24
31
|
"abdelfatah-abdelhamed",
|
|
25
|
-
"zero-
|
|
26
|
-
"web-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"native-thoth"
|
|
32
|
+
"zero-bracket-syntax",
|
|
33
|
+
"web-architecture",
|
|
34
|
+
"clean-code-standards",
|
|
35
|
+
"semantic-purity",
|
|
36
|
+
"performance-runtime",
|
|
37
|
+
"high-speed-compiler"
|
|
32
38
|
],
|
|
33
39
|
"author": "Abdelfatah Abdelhamed <abdelfatahabdelhamed.kfs@gmail.com>",
|
|
34
40
|
"license": "MIT",
|
|
35
41
|
"engines": {
|
|
36
42
|
"node": ">=14.0.0"
|
|
37
43
|
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/abdelfatah-abdelhamed/thoth-markup-lang"
|
|
47
|
+
},
|
|
38
48
|
"preferGlobal": true,
|
|
49
|
+
"files": [
|
|
50
|
+
"thoth.js",
|
|
51
|
+
"engine.php",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE",
|
|
54
|
+
"thoth.config.json"
|
|
55
|
+
],
|
|
39
56
|
"publishConfig": {
|
|
40
57
|
"access": "public"
|
|
41
58
|
}
|
package/thoth.js
CHANGED
|
@@ -1,159 +1,327 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* THOTH Engine
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* THOTH Engine v10.5.0 - The Sovereign Architect (Intelligence Suite)
|
|
5
|
+
* Lead Developer: Engineer Abdelfatah Abdelhamed
|
|
6
|
+
* ------------------------------------------------------------------
|
|
7
|
+
* الميزات المدمجة:
|
|
8
|
+
* 1. Strict Identification: إلزامية وجود TYPE THOTH في السطر الأول.
|
|
9
|
+
* 2. Middleware Support: نظام Auth Guard المتقدم لتصفية العناصر.
|
|
10
|
+
* 3. Dynamic Meta Engine: توليد وسوم الميتا تلقائياً من سياق البيانات.
|
|
11
|
+
* 4. Dev Server & Live Reload: خادم محلي لمراقبة التغييرات لحظياً.
|
|
12
|
+
* 5. Recursive Data Engine: نظام الـ Loops والـ JSON والـ Variables.
|
|
8
13
|
*/
|
|
9
14
|
|
|
10
15
|
const fs = require('fs');
|
|
11
16
|
const path = require('path');
|
|
17
|
+
const http = require('http');
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
// تنسيق رسالة الاستخدام في حالة الخطأ
|
|
17
|
-
if (!command || (command !== 'build' && !command.endsWith('.thoth'))) {
|
|
18
|
-
console.log('\x1b[33m%s\x1b[0m', '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
19
|
-
console.log('\x1b[1m\x1b[32m 𓅓 THOTH ENGINE v4.1.0 \x1b[0m');
|
|
20
|
-
console.log('\x1b[33m%s\x1b[0m', ' Developed by Engineer Abdelfatah Abdelhamed');
|
|
21
|
-
console.log('\x1b[33m%s\x1b[0m', '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
22
|
-
console.log(' Usage:');
|
|
23
|
-
console.log(' thoth build file.thoth \x1b[90m(Create a standalone HTML5 file)\x1b[0m');
|
|
24
|
-
console.log(' thoth file.thoth \x1b[90m(Fast Internal Compilation)\x1b[0m');
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const targetFile = command === 'build' ? file : command;
|
|
29
|
-
|
|
30
|
-
// القاموس الهندسي الشامل لجميع وسوم HTML5
|
|
31
|
-
const MAP = {
|
|
19
|
+
// --- القاموس المعماري الشامل ---
|
|
20
|
+
const TAG_MAP = {
|
|
32
21
|
'Title': 'h1', 'Sub': 'h2', 'Heading': 'h3', 'Text': 'p', 'Bold': 'strong',
|
|
33
22
|
'Italic': 'em', 'Box': 'div', 'Container': 'section', 'Nav': 'nav',
|
|
34
23
|
'Header': 'header', 'Footer': 'footer', 'Article': 'article', 'Aside': 'aside',
|
|
35
24
|
'Link': 'a', 'Image': 'img', 'Button': 'button', 'List': 'ul', 'Item': 'li',
|
|
36
|
-
'Input': 'input', 'Form': 'form', 'Label': 'label', 'Break': 'br', 'Line': 'hr'
|
|
25
|
+
'Input': 'input', 'Form': 'form', 'Label': 'label', 'Break': 'br', 'Line': 'hr',
|
|
26
|
+
'Main': 'main', 'Layout': 'section'
|
|
37
27
|
};
|
|
38
28
|
|
|
39
|
-
const
|
|
29
|
+
const VOID_ELEMENTS = ['img', 'br', 'hr', 'input', 'meta', 'link'];
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
// --- سياق التشغيل السيادي ---
|
|
32
|
+
let dataContext = {};
|
|
33
|
+
let config = {
|
|
34
|
+
devMode: process.argv.includes('--dev') || process.argv.includes('serve'),
|
|
35
|
+
port: 3000,
|
|
36
|
+
currentUserRole: 'admin', // القيمة الافتراضية لمحاكاة الميدلوير
|
|
37
|
+
strictMode: true
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const args = process.argv.slice(2);
|
|
41
|
+
const command = args[0];
|
|
42
|
+
const target = args.find(a => a.endsWith('.thoth'));
|
|
43
|
+
|
|
44
|
+
if (!command || (!target && command !== 'serve')) {
|
|
45
|
+
displayUsage();
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* عرض إرشادات الاستخدام التقنية
|
|
51
|
+
*/
|
|
52
|
+
function displayUsage() {
|
|
53
|
+
const yellow = '\x1b[33m';
|
|
54
|
+
const reset = '\x1b[0m';
|
|
55
|
+
console.log(yellow + '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━' + reset);
|
|
56
|
+
console.log('\x1b[1m\x1b[32m THOTH INTELLIGENCE SUITE v10.5.0 \x1b[0m');
|
|
57
|
+
console.log(yellow + ' Lead Architect: Abdelfatah Abdelhamed' + reset);
|
|
58
|
+
console.log(yellow + '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━' + reset);
|
|
59
|
+
console.log(' Usage:');
|
|
60
|
+
console.log(' thoth build [file].thoth (Production Compilation)');
|
|
61
|
+
console.log(' thoth serve [file].thoth (Live Dev Server + Reload)');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* معالجة البيانات الديناميكية @{{key}} و @Variable
|
|
66
|
+
*/
|
|
67
|
+
function resolveData(text, context, variables = {}) {
|
|
68
|
+
// 1. استبدال المتغيرات @Var
|
|
69
|
+
let resolved = text;
|
|
70
|
+
for (const [key, val] of Object.entries(variables)) {
|
|
71
|
+
resolved = resolved.replace(new RegExp(key, 'g'), val);
|
|
72
|
+
}
|
|
73
|
+
// 2. استبدال بيانات JSON @{{key}}
|
|
74
|
+
return resolved.replace(/@\{\{([^}]+)\}\}/g, (match, key) => {
|
|
75
|
+
const val = context[key.trim()];
|
|
76
|
+
return val !== undefined ? val : match;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* محرك التجميع المعماري
|
|
82
|
+
*/
|
|
83
|
+
function compileThoth(inputPath, isDev = false) {
|
|
84
|
+
if (!fs.existsSync(inputPath)) throw new Error(`Source Integrity Error: "${inputPath}" not found.`);
|
|
85
|
+
|
|
86
|
+
const source = fs.readFileSync(inputPath, 'utf8');
|
|
87
|
+
const lines = source.split(/\r?\n/);
|
|
88
|
+
|
|
89
|
+
// --- التحقق من شرط السيادة الأول ---
|
|
90
|
+
if (lines[0].trim() !== "TYPE THOTH") {
|
|
91
|
+
throw new Error("Architectural Identity Error: File must start with 'TYPE THOTH' to ensure sovereignty.");
|
|
45
92
|
}
|
|
46
93
|
|
|
47
|
-
|
|
48
|
-
const lines = code.split(/\r?\n/);
|
|
49
|
-
let htmlBody = "";
|
|
94
|
+
let htmlContent = "";
|
|
50
95
|
let stack = [];
|
|
51
|
-
let
|
|
96
|
+
let variables = {};
|
|
97
|
+
let rawScope = { active: false, type: '', indent: 0 };
|
|
98
|
+
let skipIndent = -1;
|
|
99
|
+
let repeatScope = { active: false, key: '', indent: 0, buffer: [] };
|
|
52
100
|
|
|
53
|
-
lines.
|
|
101
|
+
for (let i = 1; i < lines.length; i++) { // نبدأ من 1 لتجاوز سطر النوع
|
|
102
|
+
let line = lines[i];
|
|
54
103
|
const trimmed = line.trim();
|
|
55
|
-
|
|
56
|
-
// 1. تجاهل الأسطر الفارغة والتعليقات تماماً
|
|
57
|
-
if (!trimmed || trimmed.startsWith('#')) return;
|
|
58
|
-
|
|
59
104
|
const indent = line.search(/\S/);
|
|
60
105
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
106
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
107
|
+
|
|
108
|
+
// --- 1. Middleware / Auth Guard ---
|
|
109
|
+
if (skipIndent !== -1) {
|
|
110
|
+
if (indent > skipIndent) continue;
|
|
111
|
+
else skipIndent = -1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const authMatch = trimmed.match(/Auth="([^"]+)"/);
|
|
115
|
+
if (authMatch) {
|
|
116
|
+
if (authMatch[1] !== config.currentUserRole && authMatch[1] !== 'guest') {
|
|
117
|
+
skipIndent = indent;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// --- 2. Repeat Logic (Recursive) ---
|
|
123
|
+
if (repeatScope.active) {
|
|
124
|
+
if (indent > repeatScope.indent) {
|
|
125
|
+
repeatScope.buffer.push(line);
|
|
126
|
+
continue;
|
|
66
127
|
} else {
|
|
67
|
-
|
|
68
|
-
|
|
128
|
+
const list = dataContext[repeatScope.key] || [];
|
|
129
|
+
list.forEach(item => {
|
|
130
|
+
htmlContent += processBuffer(repeatScope.buffer, item, variables);
|
|
131
|
+
});
|
|
132
|
+
repeatScope.active = false;
|
|
133
|
+
repeatScope.buffer = [];
|
|
69
134
|
}
|
|
70
135
|
}
|
|
71
136
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
137
|
+
if (trimmed.startsWith('Repeat Over="')) {
|
|
138
|
+
repeatScope.key = trimmed.match(/Over="([^"]+)"/)[1];
|
|
139
|
+
repeatScope.active = true;
|
|
140
|
+
repeatScope.indent = indent;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// --- 3. Data Ingestion & Variables ---
|
|
145
|
+
if (trimmed.startsWith('DataSource:')) {
|
|
146
|
+
const dPath = path.resolve(path.dirname(inputPath), trimmed.split(':')[1].trim());
|
|
147
|
+
if (fs.existsSync(dPath)) dataContext = JSON.parse(fs.readFileSync(dPath, 'utf8'));
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (trimmed.startsWith('Var ')) {
|
|
152
|
+
const vParts = trimmed.substring(4).split(':');
|
|
153
|
+
if (vParts.length === 2) variables['@' + vParts[0].trim()] = vParts[1].trim();
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
line = resolveData(line, dataContext, variables);
|
|
158
|
+
const processedTrimmed = line.trim();
|
|
159
|
+
|
|
160
|
+
// --- 4. Raw Code Injection (CSS/JS) ---
|
|
161
|
+
if (rawScope.active) {
|
|
162
|
+
if (indent <= rawScope.indent && processedTrimmed !== "") {
|
|
163
|
+
rawScope.active = false;
|
|
164
|
+
htmlContent += `</${rawScope.type}>\n`;
|
|
165
|
+
} else {
|
|
166
|
+
htmlContent += line + '\n';
|
|
167
|
+
continue;
|
|
80
168
|
}
|
|
81
169
|
}
|
|
82
170
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
val = "";
|
|
171
|
+
// --- خوارزمية تحليل الفصل الذكي ---
|
|
172
|
+
let colonIdx = -1;
|
|
173
|
+
let inQuotes = false;
|
|
174
|
+
for (let j = 0; j < processedTrimmed.length; j++) {
|
|
175
|
+
if (processedTrimmed[j] === '"') inQuotes = !inQuotes;
|
|
176
|
+
if (processedTrimmed[j] === ':' && !inQuotes) { colonIdx = j; break; }
|
|
90
177
|
}
|
|
91
178
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
179
|
+
let instr = colonIdx !== -1 ? processedTrimmed.substring(0, colonIdx).trim() : processedTrimmed;
|
|
180
|
+
let val = colonIdx !== -1 ? processedTrimmed.substring(colonIdx + 1).trim() : "";
|
|
181
|
+
|
|
182
|
+
const firstSpace = instr.indexOf(' ');
|
|
183
|
+
const tagName = firstSpace !== -1 ? instr.substring(0, firstSpace) : instr;
|
|
184
|
+
const attrs = firstSpace !== -1 ? instr.substring(firstSpace).trim() : "";
|
|
185
|
+
|
|
186
|
+
if (tagName === "StyleSheet" || tagName === "Scripting") {
|
|
187
|
+
rawScope.active = true;
|
|
188
|
+
rawScope.type = tagName === "StyleSheet" ? "style" : "script";
|
|
189
|
+
rawScope.indent = indent;
|
|
190
|
+
htmlContent += `<${rawScope.type}>\n`;
|
|
191
|
+
continue;
|
|
104
192
|
}
|
|
105
193
|
|
|
106
|
-
//
|
|
194
|
+
// إدارة المكدس (Stack Indentation)
|
|
107
195
|
while (stack.length > 0 && stack[stack.length - 1].indent >= indent) {
|
|
108
|
-
|
|
196
|
+
htmlContent += `</${stack.pop().name}>\n`;
|
|
109
197
|
}
|
|
110
198
|
|
|
111
|
-
|
|
112
|
-
|
|
199
|
+
const tag = TAG_MAP[tagName] || tagName.toLowerCase();
|
|
200
|
+
const cleanAttrs = attrs.replace(/Auth="[^"]+"/, '').trim();
|
|
201
|
+
const open = `<${tag}${cleanAttrs ? ' ' + cleanAttrs : ''}>`;
|
|
113
202
|
|
|
114
|
-
if (
|
|
115
|
-
|
|
203
|
+
if (VOID_ELEMENTS.includes(tag)) {
|
|
204
|
+
htmlContent += open + '\n';
|
|
116
205
|
} else if (val) {
|
|
117
|
-
|
|
206
|
+
htmlContent += `${open}${val}</${tag}>\n`;
|
|
118
207
|
} else {
|
|
119
|
-
|
|
208
|
+
htmlContent += open + '\n';
|
|
120
209
|
stack.push({ name: tag, indent: indent });
|
|
121
210
|
}
|
|
122
|
-
}
|
|
211
|
+
}
|
|
123
212
|
|
|
124
|
-
// إغلاق أي
|
|
125
|
-
|
|
126
|
-
|
|
213
|
+
// إغلاق أي تكرار متبقي
|
|
214
|
+
if (repeatScope.active) {
|
|
215
|
+
const list = dataContext[repeatScope.key] || [];
|
|
216
|
+
list.forEach(item => { htmlContent += processBuffer(repeatScope.buffer, item, variables); });
|
|
127
217
|
}
|
|
128
218
|
|
|
129
|
-
|
|
219
|
+
while (stack.length > 0) htmlContent += `</${stack.pop().name}>\n`;
|
|
220
|
+
|
|
221
|
+
return generateBoilerplate(htmlContent, isDev);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* معالجة الـ Buffer داخل الـ Loop
|
|
226
|
+
*/
|
|
227
|
+
function processBuffer(buffer, item, variables) {
|
|
228
|
+
let res = "";
|
|
229
|
+
let bStack = [];
|
|
230
|
+
buffer.forEach(l => {
|
|
231
|
+
const ind = l.search(/\S/);
|
|
232
|
+
let pLine = resolveData(l, item, variables);
|
|
233
|
+
const t = pLine.trim();
|
|
234
|
+
let cIdx = t.indexOf(':');
|
|
235
|
+
let cmdStr = cIdx !== -1 ? t.substring(0, cIdx).trim() : t;
|
|
236
|
+
let valStr = cIdx !== -1 ? t.substring(cIdx + 1).trim() : "";
|
|
237
|
+
|
|
238
|
+
const space = cmdStr.indexOf(' ');
|
|
239
|
+
const tag = TAG_MAP[cmdStr.substring(0, space === -1 ? cmdStr.length : space)] || cmdStr.toLowerCase();
|
|
240
|
+
|
|
241
|
+
while (bStack.length > 0 && bStack[bStack.length - 1].indent >= ind) res += `</${bStack.pop().name}>\n`;
|
|
242
|
+
|
|
243
|
+
const op = `<${tag}${space !== -1 ? ' ' + cmdStr.substring(space).trim() : ''}>`;
|
|
244
|
+
if (VOID_ELEMENTS.includes(tag)) res += op + '\n';
|
|
245
|
+
else if (valStr) res += `${op}${valStr}</${tag}>\n`;
|
|
246
|
+
else { res += op + '\n'; bStack.push({ name: tag, indent: ind }); }
|
|
247
|
+
});
|
|
248
|
+
while (bStack.length > 0) res += `</${bStack.pop().name}>\n`;
|
|
249
|
+
return res;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* توليد هيكل HTML5 المعياري مع الـ Meta Tags
|
|
254
|
+
*/
|
|
255
|
+
function generateBoilerplate(content, isDev) {
|
|
256
|
+
const title = dataContext.site_title || "THOTH Sovereign Architecture";
|
|
257
|
+
const desc = dataContext.site_desc || "Engineered by Abdelfatah Abdelhamed";
|
|
258
|
+
|
|
259
|
+
const liveReload = isDev ? `
|
|
260
|
+
<script>
|
|
261
|
+
console.log('%c THOTH DEV MODE: ACTIVE ', 'background:#D4AF37;color:#000;font-weight:bold;');
|
|
262
|
+
let lastMod = null;
|
|
263
|
+
setInterval(async () => {
|
|
264
|
+
try {
|
|
265
|
+
const r = await fetch(window.location.href, {method:'HEAD'});
|
|
266
|
+
const etag = r.headers.get('etag') || r.headers.get('last-modified');
|
|
267
|
+
if(lastMod && etag !== lastMod) location.reload();
|
|
268
|
+
lastMod = etag;
|
|
269
|
+
} catch(e) {}
|
|
270
|
+
}, 1500);
|
|
271
|
+
</script>` : "";
|
|
272
|
+
|
|
130
273
|
return `<!DOCTYPE html>
|
|
131
274
|
<html lang="ar" dir="rtl">
|
|
132
275
|
<head>
|
|
133
276
|
<meta charset="UTF-8">
|
|
134
277
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
135
|
-
<meta name="
|
|
278
|
+
<meta name="description" content="${desc}">
|
|
279
|
+
<meta name="generator" content="THOTH Sovereign Engine v10.5.0">
|
|
136
280
|
<meta name="author" content="Abdelfatah Abdelhamed">
|
|
137
|
-
<title
|
|
281
|
+
<title>${title}</title>
|
|
138
282
|
</head>
|
|
139
|
-
<body>
|
|
140
|
-
${
|
|
283
|
+
<body style="margin:0; background:#050505; color:#fff;">
|
|
284
|
+
${content}
|
|
285
|
+
${liveReload}
|
|
141
286
|
</body>
|
|
142
287
|
</html>`;
|
|
143
288
|
}
|
|
144
289
|
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
} catch (
|
|
157
|
-
|
|
158
|
-
|
|
290
|
+
// --- طبقة التنفيذ ---
|
|
291
|
+
if (command === 'serve') {
|
|
292
|
+
const server = http.createServer((req, res) => {
|
|
293
|
+
try {
|
|
294
|
+
const html = compileThoth(target, true);
|
|
295
|
+
res.writeHead(200, {
|
|
296
|
+
'Content-Type': 'text/html',
|
|
297
|
+
'Cache-Control': 'no-cache',
|
|
298
|
+
'ETag': Date.now().toString()
|
|
299
|
+
});
|
|
300
|
+
res.end(html);
|
|
301
|
+
} catch (e) {
|
|
302
|
+
res.writeHead(500, { 'Content-Type': 'text/html' });
|
|
303
|
+
res.end(`<body style="background:#000;color:#ff5555;padding:50px;font-family:monospace">
|
|
304
|
+
<h2 style="border-bottom:2px solid #ff5555;padding-bottom:10px">SOVEREIGN COMPILATION ERROR</h2>
|
|
305
|
+
<p style="font-size:18px">${e.message}</p>
|
|
306
|
+
<button onclick="location.reload()" style="background:#ff5555;color:#fff;border:none;padding:10px 20px;cursor:pointer">RETRY</button>
|
|
307
|
+
</body>`);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
server.listen(config.port, () => {
|
|
312
|
+
console.log('\x1b[32m%s\x1b[0m', `──────────────────────────────────────────`);
|
|
313
|
+
console.log(` ✔ SERVER ACTIVE: http://localhost:${config.port}`);
|
|
314
|
+
console.log(` ✔ ARCHITECTURE: ${target}`);
|
|
315
|
+
console.log(` ✔ MODE: Intelligence Suite v10.5.0`);
|
|
316
|
+
console.log('\x1b[32m%s\x1b[0m', `──────────────────────────────────────────`);
|
|
317
|
+
});
|
|
318
|
+
} else {
|
|
319
|
+
try {
|
|
320
|
+
const out = compileThoth(target, false);
|
|
321
|
+
fs.writeFileSync(target.replace('.thoth', '.html'), out);
|
|
322
|
+
console.log(`\x1b[32m [SUCCESS] Architecture materialized: ${target.replace('.thoth', '.html')}\x1b[0m`);
|
|
323
|
+
} catch (e) {
|
|
324
|
+
console.error(`\x1b[31m [ERROR] ${e.message}\x1b[0m`);
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
159
327
|
}
|
package/.htaccess
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# THOTH Server Configuration
|
|
2
|
-
RewriteEngine On
|
|
3
|
-
|
|
4
|
-
# توجيه أي طلب لملف ينتهي بـ .thoth إلى محرك المهندس عبد الفتاح
|
|
5
|
-
RewriteCond %{REQUEST_FILENAME} !-f
|
|
6
|
-
RewriteRule ^(.*)\.thoth$ engine.php?file=$1.thoth [L,QSA]
|
|
7
|
-
|
|
8
|
-
# جعل index.thoth هو الملف الرئيسي للموقع
|
|
9
|
-
DirectoryIndex index.thoth
|