@yannosay/sinth 1.8.1 → 1.8.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.
- package/LICENSE +660 -660
- package/README.md +548 -548
- package/package.json +48 -45
- package/src/cli.ts +338 -338
- package/src/core/builtins.ts +116 -116
- package/src/core/compiler.ts +1706 -1706
- package/src/core/expr.ts +88 -88
- package/src/core/head-builder.ts +86 -86
- package/src/core/lexer.ts +275 -275
- package/src/core/parser.ts +1523 -1523
- package/src/core/runtime/custom-element.ts +134 -134
- package/src/core/runtime/functions.ts +46 -46
- package/src/core/runtime/helpers.ts +332 -332
- package/src/core/runtime/render.ts +136 -136
- package/src/core/style-processor.ts +299 -299
- package/src/core/types.ts +192 -192
- package/src/resolver.ts +149 -149
- package/src/server.ts +128 -128
- package/src/utils.ts +76 -76
- package/tsconfig.json +26 -26
package/README.md
CHANGED
|
@@ -1,549 +1,549 @@
|
|
|
1
|
-
|
|
2
|
-
# Sinth <img src="https://sinth.yannosay.com/assets/logosinth.webp" alt="logo" width="48" style="border-radius: 12px; vertical-align: middle; margin-left: 8px;">
|
|
3
|
-
[](https://www.npmjs.com/package/@yannosay/sinth)
|
|
4
|
-
[](https://www.npmjs.com/package/@yannosay/sinth)
|
|
5
|
-
[](https://github.com/Yannosay/sinth/blob/main/LICENSE)
|
|
6
|
-
|
|
7
|
-
The language that makes HTML feel SO easy. Declarative. Reactive. Compiles to pure HTML.
|
|
8
|
-
|
|
9
|
-
**I need YOUR Help to improve Sinth, please consider joining the Discord so Sinth can be optimized more easy, currently I am doing this alone!**
|
|
10
|
-
|
|
11
|
-
* Introduction: https://www.youtube.com/watch?v=W0tOMTiIF0Q
|
|
12
|
-
* Discord: [Join here!](https://discord.gg/SUvcrafTQm)
|
|
13
|
-
* Documentation: [sinth.yannosay.com/docs](https://sinth.yannosay.com/docs) (HIGHLY WIP, not yet finished at all!)
|
|
14
|
-
|
|
15
|
-
#### Try out Sinth directly in Web! (BETA. Uses an older version of Sinth.)
|
|
16
|
-
|
|
17
|
-
```html
|
|
18
|
-
<div id="app"></div>
|
|
19
|
-
<script src="https://lib.yannosay.com/sinth.js/sinth.js"></script>
|
|
20
|
-
<script type="text/sinth">
|
|
21
|
-
page
|
|
22
|
-
title = "Counter"
|
|
23
|
-
var int count = 0
|
|
24
|
-
|
|
25
|
-
Main {
|
|
26
|
-
Heading(level: 1) {count}
|
|
27
|
-
Button(onClick: count = count + 1) {"Increment"}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
$entry-point("app")
|
|
31
|
-
</script>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## Why Sinth?
|
|
36
|
-
|
|
37
|
-
#### Reactive forms in one line.
|
|
38
|
-
```ts
|
|
39
|
-
Input(bind: userName, placeholder: "Enter your name")
|
|
40
|
-
Paragraph { "Hello, " + userName }
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
No useState, onChange or e.target.value.
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
page
|
|
47
|
-
title = "Counter"
|
|
48
|
-
|
|
49
|
-
var int count = 0
|
|
50
|
-
|
|
51
|
-
Main {
|
|
52
|
-
Heading(level: 1) {count}
|
|
53
|
-
Button(onClick: count += 1) {"Increment"}
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
#### Declare your own HTML tags
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
custom MyCounter(export: <awesome-counter />) {
|
|
61
|
-
var int count = 0
|
|
62
|
-
Button(onClick: count += 1) { count }
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
then you can use it in non-sinth HTML projects
|
|
67
|
-
|
|
68
|
-
```html
|
|
69
|
-
<awesome-counter />
|
|
70
|
-
<script src="awesome-counter.js"></script>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
#### Logic and UI live together.
|
|
74
|
-
```ts
|
|
75
|
-
if user.isAdmin {
|
|
76
|
-
Button(onClick: "deletePost()") { "Delete" }
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
No JSX ternaries or v-if or separate script tags. Mixed logic there where you need it.
|
|
81
|
-
|
|
82
|
-
#### Sinth Language Syntax Reference
|
|
83
|
-
|
|
84
|
-
| Syntax | Description |
|
|
85
|
-
|-------------------------------------------------|------------------------------------------------|
|
|
86
|
-
| `--` or --[Hello]-- | Comment |
|
|
87
|
-
| `page` | Declares a full Sinth page |
|
|
88
|
-
| `title = "..."` | Sets the page title |
|
|
89
|
-
| `function myFunction` | Creates a reusable & reactive function |
|
|
90
|
-
| `var str myVar = ""` | Declares a string variable |
|
|
91
|
-
| `var int myVar` | Declares an integer variable |
|
|
92
|
-
| `var bool myVar` | Declares a boolean variable |
|
|
93
|
-
| `var str[] myVar` | Declares a string array |
|
|
94
|
-
| `var obj myVar` | Declares an object variable |
|
|
95
|
-
| `import "./file.sinth"` | Imports another Sinth file |
|
|
96
|
-
| `import css "./file.css"` | Imports a CSS file |
|
|
97
|
-
| `import js "./file.js"` | Imports a JS file |
|
|
98
|
-
| `Heading(level: 1) { "..." }` | Renders a heading (h1-h6) |
|
|
99
|
-
| `Paragraph { "..." }` | Renders a paragraph |
|
|
100
|
-
| `Button(onClick: fn) { "..." }` | Renders a clickable button |
|
|
101
|
-
| `Input(bind: myVar)` | Renders a bound input field |
|
|
102
|
-
| `Checkbox(checked: myBool)` | Renders a checkbox |
|
|
103
|
-
| `if condition { ... }` | Conditional rendering |
|
|
104
|
-
| `if condition { ... } else { ... }` | Conditional with else branch |
|
|
105
|
-
| `for item in array { ... }` | Loops over an array |
|
|
106
|
-
| `for item, index in array { ... }` | Loops with index |
|
|
107
|
-
| `delay: ms` | Delays rendering of an element |
|
|
108
|
-
| `hide: bool` | Conditionally hides an element |
|
|
109
|
-
| `style { ... }` | Defines scoped CSS styles |
|
|
110
|
-
| `script { ... }` | Defines page-level JavaScript |
|
|
111
|
-
| `component MyComp { ... }` | Defines a reusable component |
|
|
112
|
-
| `custom el "my-tag" { ... }` | Defines a custom element |
|
|
113
|
-
| `custom MyCounter(export: <awesome-counter />)` | Exports a custom element tag |
|
|
114
|
-
| `$myFunction()` (e.g. `$alert("displayed once")`)| Indicator for Memorization - Useful for functions that should only show once |
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
#### Functions - easy as you know it
|
|
118
|
-
```ts
|
|
119
|
-
page
|
|
120
|
-
|
|
121
|
-
title = "Functions"
|
|
122
|
-
|
|
123
|
-
var str userName = "Sinth User"
|
|
124
|
-
|
|
125
|
-
function greet(str name) -> str {
|
|
126
|
-
"Hello, " + name
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function renderHeading(str label) -> ui {
|
|
130
|
-
Heading(level: 2) {
|
|
131
|
-
(label)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
Div {
|
|
136
|
-
greet(userName) + " - welcome back!"
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
renderHeading(userName)
|
|
140
|
-
renderHeading("This renders!")
|
|
141
|
-
```
|
|
142
|
-
```ts
|
|
143
|
-
page
|
|
144
|
-
|
|
145
|
-
title = "Checkbox Test"
|
|
146
|
-
|
|
147
|
-
var bool isAdmin = false
|
|
148
|
-
|
|
149
|
-
function toggleAdmin() {
|
|
150
|
-
isAdmin = not isAdmin
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function getStatus() -> str {
|
|
154
|
-
if (isAdmin) {
|
|
155
|
-
return "ON"
|
|
156
|
-
}
|
|
157
|
-
return "OFF"
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
Checkbox(checked: isAdmin label: "Admin mode?")
|
|
161
|
-
|
|
162
|
-
Paragraph {
|
|
163
|
-
"Admin mode is " + getStatus() + "!"
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
#### Code what you need
|
|
167
|
-
```ts
|
|
168
|
-
page
|
|
169
|
-
title = "For Loop Variable Test"
|
|
170
|
-
|
|
171
|
-
var obj historyList = []
|
|
172
|
-
var int kickCount = 0
|
|
173
|
-
var str userName = ""
|
|
174
|
-
var obj newList = []
|
|
175
|
-
var int i = 0
|
|
176
|
-
|
|
177
|
-
function kickUser() {
|
|
178
|
-
if userName != "" {
|
|
179
|
-
historyList.push(userName)
|
|
180
|
-
kickCount = kickCount + 1
|
|
181
|
-
userName = ""
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function removeUser(index) {
|
|
186
|
-
newList = []
|
|
187
|
-
i = 0
|
|
188
|
-
for user in historyList {
|
|
189
|
-
if i != index {
|
|
190
|
-
newList.push(user)
|
|
191
|
-
}
|
|
192
|
-
i = i + 1
|
|
193
|
-
}
|
|
194
|
-
historyList = newList
|
|
195
|
-
kickCount = kickCount - 1
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
Main {
|
|
199
|
-
Heading(level: 1) { "For Loop Test" }
|
|
200
|
-
|
|
201
|
-
Input(bind: userName, placeholder: "Enter username to kick")
|
|
202
|
-
Button(onClick: kickUser()) { "Add User" }
|
|
203
|
-
|
|
204
|
-
Paragraph { "Count: " + kickCount }
|
|
205
|
-
|
|
206
|
-
Heading(level: 2) { "Users:" }
|
|
207
|
-
for kickedUser, index in historyList {
|
|
208
|
-
Paragraph { kickedUser }
|
|
209
|
-
Button(onClick: removeUser(index)) { "Remove" }
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
#### Fullscreen activation + if-else inside Component
|
|
216
|
-
|
|
217
|
-
```ts
|
|
218
|
-
page
|
|
219
|
-
title = "Fullscreen"
|
|
220
|
-
|
|
221
|
-
var bool isFullscreen = false
|
|
222
|
-
var str userName = ""
|
|
223
|
-
|
|
224
|
-
Main {
|
|
225
|
-
Button(onClick: isFullscreen = !isFullscreen, fullscreen: isFullscreen) {
|
|
226
|
-
if isFullscreen {
|
|
227
|
-
"Exit Fullscreen"
|
|
228
|
-
} else {
|
|
229
|
-
"Enter Fullscreen"
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
Input(bind: userName)
|
|
233
|
-
Paragraph {
|
|
234
|
-
if userName == "Sinth" {
|
|
235
|
-
"Oh, welcome back!"
|
|
236
|
-
} else {
|
|
237
|
-
"Hello, " + userName + "!"
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
#### Fullscreen Sync
|
|
244
|
-
|
|
245
|
-
Opt-in Escape key handling. `fullscreenSync` keeps your variable in sync with the browser's fullscreen state.
|
|
246
|
-
|
|
247
|
-
```ts
|
|
248
|
-
Button(onClick: isFullscreen = !isFullscreen, fullscreen: isFullscreen, fullscreenSync: isFullscreen) {
|
|
249
|
-
if isFullscreen { "Exit Fullscreen" } else { "Enter Fullscreen" }
|
|
250
|
-
}
|
|
251
|
-
```
|
|
252
|
-
Without fullscreenSync, pressing Escape exits fullscreen but the variable stays true.
|
|
253
|
-
With it, Escape resets the variable to false and the button text updates automatically.
|
|
254
|
-
|
|
255
|
-
#### Opt-in DOM Diffing
|
|
256
|
-
|
|
257
|
-
Skip re-executing expressions when their variables haven't changed. Perfect for expensive calculations or side effects you only want to fire once. No one
|
|
258
|
-
|
|
259
|
-
```ts
|
|
260
|
-
page
|
|
261
|
-
domdiffing = true -- enables expression memoization
|
|
262
|
-
|
|
263
|
-
var int count = 0
|
|
264
|
-
|
|
265
|
-
Main {
|
|
266
|
-
Heading(level: 1) { count }
|
|
267
|
-
(alert("Fires only once!")) -- no dependencies, runs once and never again
|
|
268
|
-
Button(onClick: count += 1) { "Increment" }
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
Count updates every click because count changed. The alert fires only on page load — zero dependencies means it's cached forever. Just a meta flag.
|
|
272
|
-
|
|
273
|
-
#### Animations that make sense.
|
|
274
|
-
```ts
|
|
275
|
-
page
|
|
276
|
-
|
|
277
|
-
var str[] items = ["First", "Second", "Third", "Fourth", "Fifth"]
|
|
278
|
-
|
|
279
|
-
for item, index in items {
|
|
280
|
-
Paragraph(delay: (index + 1) * 1000) { item }
|
|
281
|
-
}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
Staggered animations. One expression. No useEffect. No setTimeout chains.
|
|
285
|
-
|
|
286
|
-
#### Multiple actions, single handler.
|
|
287
|
-
```ts
|
|
288
|
-
Button(onClick: show = not show; deleted = true) { "Toggle & Delete" }
|
|
289
|
-
Chain statements with ;. No wrapper functions. No script blocks.
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
```ts
|
|
293
|
-
page
|
|
294
|
-
|
|
295
|
-
title = "Remove Test"
|
|
296
|
-
|
|
297
|
-
var bool show = true
|
|
298
|
-
var bool deleted = false
|
|
299
|
-
|
|
300
|
-
Main {
|
|
301
|
-
Button(onClick: show = not show) {
|
|
302
|
-
if show { "Hide Box" } else { "Show Box" }
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
Button(onClick: remove("my-box"); deleted = true) {
|
|
306
|
-
"Delete Box Forever"
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if show and not deleted {
|
|
310
|
-
Div(id: "my-box") {
|
|
311
|
-
Paragraph { "I'm a box!" }
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
```
|
|
317
|
-
Delete elements. Easy.
|
|
318
|
-
|
|
319
|
-
Compiles to pure HTML.
|
|
320
|
-
|
|
321
|
-
#### Reactivity at its finest
|
|
322
|
-
```ts
|
|
323
|
-
page
|
|
324
|
-
title = "Reactivity but easy"
|
|
325
|
-
|
|
326
|
-
var str begForFullscreen = ""
|
|
327
|
-
var bool doFullscreen = false
|
|
328
|
-
|
|
329
|
-
Main {
|
|
330
|
-
Input(bind: begForFullscreen, fullscreen: doFullscreen)
|
|
331
|
-
if begForFullscreen == "do fullscreen pls!!" {
|
|
332
|
-
doFullscreen = true
|
|
333
|
-
} else {
|
|
334
|
-
doFullscreen = false
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
```ts
|
|
342
|
-
page
|
|
343
|
-
title = "Counter Demo"
|
|
344
|
-
|
|
345
|
-
var int count = 0
|
|
346
|
-
var int addVar = 1
|
|
347
|
-
var int stepSize = 1
|
|
348
|
-
|
|
349
|
-
Main {
|
|
350
|
-
Heading(level: 1) {count}
|
|
351
|
-
|
|
352
|
-
Paragraph {"Increment by:"}
|
|
353
|
-
Input(bind: addVar, step: stepSize)
|
|
354
|
-
|
|
355
|
-
Br()
|
|
356
|
-
Button(onClick: count = count + addVar) {"Increment"}
|
|
357
|
-
|
|
358
|
-
Br()
|
|
359
|
-
Br()
|
|
360
|
-
Paragraph {"Step size for arrows:"}
|
|
361
|
-
Input(bind: stepSize, step: 1)
|
|
362
|
-
}
|
|
363
|
-
```
|
|
364
|
-
##### NEW! (0.14.0):
|
|
365
|
-
Sinth now supports Reactivity in Functions!
|
|
366
|
-
```ts
|
|
367
|
-
page
|
|
368
|
-
title = "Reactive Counter"
|
|
369
|
-
|
|
370
|
-
var int apples = 1
|
|
371
|
-
var int bananas = 2
|
|
372
|
-
var int oranges = -6
|
|
373
|
-
|
|
374
|
-
function Counter(int value) -> ui {
|
|
375
|
-
Heading(level: 1) {"Count is at: " + (value) + "!"}
|
|
376
|
-
Button(onClick: value = value + 1) {"Increment"}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
Main {
|
|
380
|
-
Counter(apples)
|
|
381
|
-
Counter(bananas)
|
|
382
|
-
Counter(oranges)
|
|
383
|
-
}
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
## Use in real life
|
|
387
|
-
```ts
|
|
388
|
-
page
|
|
389
|
-
|
|
390
|
-
title = "Kick Users Admin Panel"
|
|
391
|
-
|
|
392
|
-
var str userName = "test username"
|
|
393
|
-
var int count = 0
|
|
394
|
-
|
|
395
|
-
style lang= "scss"{
|
|
396
|
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
|
|
397
|
-
|
|
398
|
-
* {
|
|
399
|
-
font-family: 'Inter', sans-serif;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
Main {
|
|
404
|
-
Div(display: "flex", flexDirection: "column", gap: "16px", alignItems: "center", padding: "40px", fontFamily: "Inter") {
|
|
405
|
-
Heading(level: 1, fontSize: "28px", color: "#000000", fontWeight: "700") {
|
|
406
|
-
"Kick Counter: " + count
|
|
407
|
-
}
|
|
408
|
-
Div(display: "flex", gap: "12px", alignItems: "center") {
|
|
409
|
-
Input(
|
|
410
|
-
bind: userName,
|
|
411
|
-
padding: "10px 14px",
|
|
412
|
-
fontSize: "16px",
|
|
413
|
-
borderRadius: "8px",
|
|
414
|
-
border: "2px solid #6366f1",
|
|
415
|
-
outline: "none",
|
|
416
|
-
width: "250px",
|
|
417
|
-
backgroundColor: "#1e1b4b",
|
|
418
|
-
color: "#e0e7ff",
|
|
419
|
-
fontWeight: "400"
|
|
420
|
-
)
|
|
421
|
-
Button(
|
|
422
|
-
onClick: alert("Kicked: " + userName); console.log("User kicked"); count += 1,
|
|
423
|
-
padding: "10px 20px",
|
|
424
|
-
fontSize: "16px",
|
|
425
|
-
fontWeight: "600",
|
|
426
|
-
borderRadius: "8px",
|
|
427
|
-
border: "none",
|
|
428
|
-
backgroundColor: "#6366f1",
|
|
429
|
-
color: "#ffffff",
|
|
430
|
-
cursor: "pointer",
|
|
431
|
-
minWidth: "180px",
|
|
432
|
-
textAlign: "left"
|
|
433
|
-
) {
|
|
434
|
-
"Kick " + userName
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
Paragraph(fontSize: "14px", color: "#a5b4fc", fontWeight: "400") {
|
|
438
|
-
"Total kicks: " + count
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
# Install
|
|
445
|
-
npm install -g @yannosay/sinth
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
## Quick Start
|
|
452
|
-
`sinth init`
|
|
453
|
-
|
|
454
|
-
`sinth dev pages/index.sinth`
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
Open your browser. Edit your .sinth file. Watch it update live.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
## Your First Sinth File
|
|
462
|
-
```ts
|
|
463
|
-
page
|
|
464
|
-
title = "My Sinth Project"
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
Main {
|
|
468
|
-
var str nameVar = "User"
|
|
469
|
-
Heading(level: 1) { "Hello, " + nameVar }
|
|
470
|
-
Paragraph { "Welcome to Sinth." }
|
|
471
|
-
}
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
## Features
|
|
479
|
-
|
|
480
|
-
- Mixed logic — if, for, and expressions right in your UI
|
|
481
|
-
- Two-way binding — Input(bind: variable) in one line
|
|
482
|
-
- Reactivity
|
|
483
|
-
- Import own Components
|
|
484
|
-
- Expression-based delays ("delay: index * 300") for staggered animations
|
|
485
|
-
- Object support: var obj with dot notation (user.name)
|
|
486
|
-
- Object iteration: for key, value, index in object
|
|
487
|
-
- SCSS support: style blocks with scoped CSS
|
|
488
|
-
- Tree-shaken output: static pages get zero JS, reactive apps get only what they need
|
|
489
|
-
- VS Code extension: full syntax highlighting (search "Sinth" in the marketplace)
|
|
490
|
-
- Live reload dev server: sinth dev watches your files
|
|
491
|
-
- Self-contained HTML
|
|
492
|
-
- \+ more!
|
|
493
|
-
|
|
494
|
-
###### Nothing you like? Give us feedback on our [Discord Server](https://discord.gg/SUvcrafTQm)!
|
|
495
|
-
|
|
496
|
-
## Shared Runtime
|
|
497
|
-
|
|
498
|
-
For multi-page projects, extract helpers into a cached file:
|
|
499
|
-
`sinth build --shared-runtime`
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
This creates a `sinth-runtime.js` file shared across all pages. Each page shrinks to ~25 lines of render logic. The browser caches the helpers once.
|
|
503
|
-
|
|
504
|
-
Helpful when working on big projects.
|
|
505
|
-
|
|
506
|
-
## Security
|
|
507
|
-
|
|
508
|
-
Sinth's reactive runtime does not use eval(). Every expression is pre-compiled into optimized JavaScript functions at build time. No code injection possible. No runtime string evaluation. The most secure way to power reactive UI.
|
|
509
|
-
|
|
510
|
-
###### Don't trust? -> Ctrl+F "eval(" returns nothing!
|
|
511
|
-
|
|
512
|
-
## Commands
|
|
513
|
-
|
|
514
|
-
- sinth init — scaffold a new project
|
|
515
|
-
- sinth dev [file] — start dev server with live reload
|
|
516
|
-
- sinth build — compile to static files
|
|
517
|
-
- sinth build --shared-runtime — build with shared runtime (useful when using a heavier runtime)
|
|
518
|
-
- sinth check — lint without output
|
|
519
|
-
- sinth version — print version
|
|
520
|
-
|
|
521
|
-
## Imports
|
|
522
|
-
|
|
523
|
-
Importing made easy!
|
|
524
|
-
|
|
525
|
-
```ts
|
|
526
|
-
page
|
|
527
|
-
|
|
528
|
-
import components/MyComponent.sinth as Navbar
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
Navbar
|
|
532
|
-
|
|
533
|
-
Main {
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
## Links
|
|
539
|
-
|
|
540
|
-
- GitHub: [Official Sinth Repo](https://github.com/yannosay/sinth)
|
|
541
|
-
- Website: [Sinth](https://sinth.yannosay.com) (Note: Deep in development; documentation and various other aspects are not yet finalized.)
|
|
542
|
-
- Discord: [Join here!](https://discord.gg/SUvcrafTQm)
|
|
543
|
-
- VS Code Extension: [Download here](https://marketplace.visualstudio.com/items?itemName=YannosayProductions.sinth-vscode)
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
## License
|
|
548
|
-
|
|
1
|
+
|
|
2
|
+
# Sinth <img src="https://sinth.yannosay.com/assets/logosinth.webp" alt="logo" width="48" style="border-radius: 12px; vertical-align: middle; margin-left: 8px;">
|
|
3
|
+
[](https://www.npmjs.com/package/@yannosay/sinth)
|
|
4
|
+
[](https://www.npmjs.com/package/@yannosay/sinth)
|
|
5
|
+
[](https://github.com/Yannosay/sinth/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
The language that makes HTML feel SO easy. Declarative. Reactive. Compiles to pure HTML.
|
|
8
|
+
|
|
9
|
+
**I need YOUR Help to improve Sinth, please consider joining the Discord so Sinth can be optimized more easy, currently I am doing this alone!**
|
|
10
|
+
|
|
11
|
+
* Introduction: https://www.youtube.com/watch?v=W0tOMTiIF0Q
|
|
12
|
+
* Discord: [Join here!](https://discord.gg/SUvcrafTQm)
|
|
13
|
+
* Documentation: [sinth.yannosay.com/docs](https://sinth.yannosay.com/docs) (HIGHLY WIP, not yet finished at all!)
|
|
14
|
+
|
|
15
|
+
#### Try out Sinth directly in Web! (BETA. Uses an older version of Sinth.)
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<div id="app"></div>
|
|
19
|
+
<script src="https://lib.yannosay.com/sinth.js/sinth.js"></script>
|
|
20
|
+
<script type="text/sinth">
|
|
21
|
+
page
|
|
22
|
+
title = "Counter"
|
|
23
|
+
var int count = 0
|
|
24
|
+
|
|
25
|
+
Main {
|
|
26
|
+
Heading(level: 1) {count}
|
|
27
|
+
Button(onClick: count = count + 1) {"Increment"}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
$entry-point("app")
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Why Sinth?
|
|
36
|
+
|
|
37
|
+
#### Reactive forms in one line.
|
|
38
|
+
```ts
|
|
39
|
+
Input(bind: userName, placeholder: "Enter your name")
|
|
40
|
+
Paragraph { "Hello, " + userName }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
No useState, onChange or e.target.value.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
page
|
|
47
|
+
title = "Counter"
|
|
48
|
+
|
|
49
|
+
var int count = 0
|
|
50
|
+
|
|
51
|
+
Main {
|
|
52
|
+
Heading(level: 1) {count}
|
|
53
|
+
Button(onClick: count += 1) {"Increment"}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Declare your own HTML tags
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
custom MyCounter(export: <awesome-counter />) {
|
|
61
|
+
var int count = 0
|
|
62
|
+
Button(onClick: count += 1) { count }
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
then you can use it in non-sinth HTML projects
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<awesome-counter />
|
|
70
|
+
<script src="awesome-counter.js"></script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Logic and UI live together.
|
|
74
|
+
```ts
|
|
75
|
+
if user.isAdmin {
|
|
76
|
+
Button(onClick: "deletePost()") { "Delete" }
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
No JSX ternaries or v-if or separate script tags. Mixed logic there where you need it.
|
|
81
|
+
|
|
82
|
+
#### Sinth Language Syntax Reference
|
|
83
|
+
|
|
84
|
+
| Syntax | Description |
|
|
85
|
+
|-------------------------------------------------|------------------------------------------------|
|
|
86
|
+
| `--` or --[Hello]-- | Comment |
|
|
87
|
+
| `page` | Declares a full Sinth page |
|
|
88
|
+
| `title = "..."` | Sets the page title |
|
|
89
|
+
| `function myFunction` | Creates a reusable & reactive function |
|
|
90
|
+
| `var str myVar = ""` | Declares a string variable |
|
|
91
|
+
| `var int myVar` | Declares an integer variable |
|
|
92
|
+
| `var bool myVar` | Declares a boolean variable |
|
|
93
|
+
| `var str[] myVar` | Declares a string array |
|
|
94
|
+
| `var obj myVar` | Declares an object variable |
|
|
95
|
+
| `import "./file.sinth"` | Imports another Sinth file |
|
|
96
|
+
| `import css "./file.css"` | Imports a CSS file |
|
|
97
|
+
| `import js "./file.js"` | Imports a JS file |
|
|
98
|
+
| `Heading(level: 1) { "..." }` | Renders a heading (h1-h6) |
|
|
99
|
+
| `Paragraph { "..." }` | Renders a paragraph |
|
|
100
|
+
| `Button(onClick: fn) { "..." }` | Renders a clickable button |
|
|
101
|
+
| `Input(bind: myVar)` | Renders a bound input field |
|
|
102
|
+
| `Checkbox(checked: myBool)` | Renders a checkbox |
|
|
103
|
+
| `if condition { ... }` | Conditional rendering |
|
|
104
|
+
| `if condition { ... } else { ... }` | Conditional with else branch |
|
|
105
|
+
| `for item in array { ... }` | Loops over an array |
|
|
106
|
+
| `for item, index in array { ... }` | Loops with index |
|
|
107
|
+
| `delay: ms` | Delays rendering of an element |
|
|
108
|
+
| `hide: bool` | Conditionally hides an element |
|
|
109
|
+
| `style { ... }` | Defines scoped CSS styles |
|
|
110
|
+
| `script { ... }` | Defines page-level JavaScript |
|
|
111
|
+
| `component MyComp { ... }` | Defines a reusable component |
|
|
112
|
+
| `custom el "my-tag" { ... }` | Defines a custom element |
|
|
113
|
+
| `custom MyCounter(export: <awesome-counter />)` | Exports a custom element tag |
|
|
114
|
+
| `$myFunction()` (e.g. `$alert("displayed once")`)| Indicator for Memorization - Useful for functions that should only show once |
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
#### Functions - easy as you know it
|
|
118
|
+
```ts
|
|
119
|
+
page
|
|
120
|
+
|
|
121
|
+
title = "Functions"
|
|
122
|
+
|
|
123
|
+
var str userName = "Sinth User"
|
|
124
|
+
|
|
125
|
+
function greet(str name) -> str {
|
|
126
|
+
"Hello, " + name
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function renderHeading(str label) -> ui {
|
|
130
|
+
Heading(level: 2) {
|
|
131
|
+
(label)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
Div {
|
|
136
|
+
greet(userName) + " - welcome back!"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
renderHeading(userName)
|
|
140
|
+
renderHeading("This renders!")
|
|
141
|
+
```
|
|
142
|
+
```ts
|
|
143
|
+
page
|
|
144
|
+
|
|
145
|
+
title = "Checkbox Test"
|
|
146
|
+
|
|
147
|
+
var bool isAdmin = false
|
|
148
|
+
|
|
149
|
+
function toggleAdmin() {
|
|
150
|
+
isAdmin = not isAdmin
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getStatus() -> str {
|
|
154
|
+
if (isAdmin) {
|
|
155
|
+
return "ON"
|
|
156
|
+
}
|
|
157
|
+
return "OFF"
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Checkbox(checked: isAdmin label: "Admin mode?")
|
|
161
|
+
|
|
162
|
+
Paragraph {
|
|
163
|
+
"Admin mode is " + getStatus() + "!"
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
#### Code what you need
|
|
167
|
+
```ts
|
|
168
|
+
page
|
|
169
|
+
title = "For Loop Variable Test"
|
|
170
|
+
|
|
171
|
+
var obj historyList = []
|
|
172
|
+
var int kickCount = 0
|
|
173
|
+
var str userName = ""
|
|
174
|
+
var obj newList = []
|
|
175
|
+
var int i = 0
|
|
176
|
+
|
|
177
|
+
function kickUser() {
|
|
178
|
+
if userName != "" {
|
|
179
|
+
historyList.push(userName)
|
|
180
|
+
kickCount = kickCount + 1
|
|
181
|
+
userName = ""
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function removeUser(index) {
|
|
186
|
+
newList = []
|
|
187
|
+
i = 0
|
|
188
|
+
for user in historyList {
|
|
189
|
+
if i != index {
|
|
190
|
+
newList.push(user)
|
|
191
|
+
}
|
|
192
|
+
i = i + 1
|
|
193
|
+
}
|
|
194
|
+
historyList = newList
|
|
195
|
+
kickCount = kickCount - 1
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
Main {
|
|
199
|
+
Heading(level: 1) { "For Loop Test" }
|
|
200
|
+
|
|
201
|
+
Input(bind: userName, placeholder: "Enter username to kick")
|
|
202
|
+
Button(onClick: kickUser()) { "Add User" }
|
|
203
|
+
|
|
204
|
+
Paragraph { "Count: " + kickCount }
|
|
205
|
+
|
|
206
|
+
Heading(level: 2) { "Users:" }
|
|
207
|
+
for kickedUser, index in historyList {
|
|
208
|
+
Paragraph { kickedUser }
|
|
209
|
+
Button(onClick: removeUser(index)) { "Remove" }
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
#### Fullscreen activation + if-else inside Component
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
page
|
|
219
|
+
title = "Fullscreen"
|
|
220
|
+
|
|
221
|
+
var bool isFullscreen = false
|
|
222
|
+
var str userName = ""
|
|
223
|
+
|
|
224
|
+
Main {
|
|
225
|
+
Button(onClick: isFullscreen = !isFullscreen, fullscreen: isFullscreen) {
|
|
226
|
+
if isFullscreen {
|
|
227
|
+
"Exit Fullscreen"
|
|
228
|
+
} else {
|
|
229
|
+
"Enter Fullscreen"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
Input(bind: userName)
|
|
233
|
+
Paragraph {
|
|
234
|
+
if userName == "Sinth" {
|
|
235
|
+
"Oh, welcome back!"
|
|
236
|
+
} else {
|
|
237
|
+
"Hello, " + userName + "!"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### Fullscreen Sync
|
|
244
|
+
|
|
245
|
+
Opt-in Escape key handling. `fullscreenSync` keeps your variable in sync with the browser's fullscreen state.
|
|
246
|
+
|
|
247
|
+
```ts
|
|
248
|
+
Button(onClick: isFullscreen = !isFullscreen, fullscreen: isFullscreen, fullscreenSync: isFullscreen) {
|
|
249
|
+
if isFullscreen { "Exit Fullscreen" } else { "Enter Fullscreen" }
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
Without fullscreenSync, pressing Escape exits fullscreen but the variable stays true.
|
|
253
|
+
With it, Escape resets the variable to false and the button text updates automatically.
|
|
254
|
+
|
|
255
|
+
#### Opt-in DOM Diffing
|
|
256
|
+
|
|
257
|
+
Skip re-executing expressions when their variables haven't changed. Perfect for expensive calculations or side effects you only want to fire once. No one
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
page
|
|
261
|
+
domdiffing = true -- enables expression memoization
|
|
262
|
+
|
|
263
|
+
var int count = 0
|
|
264
|
+
|
|
265
|
+
Main {
|
|
266
|
+
Heading(level: 1) { count }
|
|
267
|
+
(alert("Fires only once!")) -- no dependencies, runs once and never again
|
|
268
|
+
Button(onClick: count += 1) { "Increment" }
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
Count updates every click because count changed. The alert fires only on page load — zero dependencies means it's cached forever. Just a meta flag.
|
|
272
|
+
|
|
273
|
+
#### Animations that make sense.
|
|
274
|
+
```ts
|
|
275
|
+
page
|
|
276
|
+
|
|
277
|
+
var str[] items = ["First", "Second", "Third", "Fourth", "Fifth"]
|
|
278
|
+
|
|
279
|
+
for item, index in items {
|
|
280
|
+
Paragraph(delay: (index + 1) * 1000) { item }
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Staggered animations. One expression. No useEffect. No setTimeout chains.
|
|
285
|
+
|
|
286
|
+
#### Multiple actions, single handler.
|
|
287
|
+
```ts
|
|
288
|
+
Button(onClick: show = not show; deleted = true) { "Toggle & Delete" }
|
|
289
|
+
Chain statements with ;. No wrapper functions. No script blocks.
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
page
|
|
294
|
+
|
|
295
|
+
title = "Remove Test"
|
|
296
|
+
|
|
297
|
+
var bool show = true
|
|
298
|
+
var bool deleted = false
|
|
299
|
+
|
|
300
|
+
Main {
|
|
301
|
+
Button(onClick: show = not show) {
|
|
302
|
+
if show { "Hide Box" } else { "Show Box" }
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
Button(onClick: remove("my-box"); deleted = true) {
|
|
306
|
+
"Delete Box Forever"
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if show and not deleted {
|
|
310
|
+
Div(id: "my-box") {
|
|
311
|
+
Paragraph { "I'm a box!" }
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
Delete elements. Easy.
|
|
318
|
+
|
|
319
|
+
Compiles to pure HTML.
|
|
320
|
+
|
|
321
|
+
#### Reactivity at its finest
|
|
322
|
+
```ts
|
|
323
|
+
page
|
|
324
|
+
title = "Reactivity but easy"
|
|
325
|
+
|
|
326
|
+
var str begForFullscreen = ""
|
|
327
|
+
var bool doFullscreen = false
|
|
328
|
+
|
|
329
|
+
Main {
|
|
330
|
+
Input(bind: begForFullscreen, fullscreen: doFullscreen)
|
|
331
|
+
if begForFullscreen == "do fullscreen pls!!" {
|
|
332
|
+
doFullscreen = true
|
|
333
|
+
} else {
|
|
334
|
+
doFullscreen = false
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
page
|
|
343
|
+
title = "Counter Demo"
|
|
344
|
+
|
|
345
|
+
var int count = 0
|
|
346
|
+
var int addVar = 1
|
|
347
|
+
var int stepSize = 1
|
|
348
|
+
|
|
349
|
+
Main {
|
|
350
|
+
Heading(level: 1) {count}
|
|
351
|
+
|
|
352
|
+
Paragraph {"Increment by:"}
|
|
353
|
+
Input(bind: addVar, step: stepSize)
|
|
354
|
+
|
|
355
|
+
Br()
|
|
356
|
+
Button(onClick: count = count + addVar) {"Increment"}
|
|
357
|
+
|
|
358
|
+
Br()
|
|
359
|
+
Br()
|
|
360
|
+
Paragraph {"Step size for arrows:"}
|
|
361
|
+
Input(bind: stepSize, step: 1)
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
##### NEW! (0.14.0):
|
|
365
|
+
Sinth now supports Reactivity in Functions!
|
|
366
|
+
```ts
|
|
367
|
+
page
|
|
368
|
+
title = "Reactive Counter"
|
|
369
|
+
|
|
370
|
+
var int apples = 1
|
|
371
|
+
var int bananas = 2
|
|
372
|
+
var int oranges = -6
|
|
373
|
+
|
|
374
|
+
function Counter(int value) -> ui {
|
|
375
|
+
Heading(level: 1) {"Count is at: " + (value) + "!"}
|
|
376
|
+
Button(onClick: value = value + 1) {"Increment"}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
Main {
|
|
380
|
+
Counter(apples)
|
|
381
|
+
Counter(bananas)
|
|
382
|
+
Counter(oranges)
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Use in real life
|
|
387
|
+
```ts
|
|
388
|
+
page
|
|
389
|
+
|
|
390
|
+
title = "Kick Users Admin Panel"
|
|
391
|
+
|
|
392
|
+
var str userName = "test username"
|
|
393
|
+
var int count = 0
|
|
394
|
+
|
|
395
|
+
style lang= "scss"{
|
|
396
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
|
|
397
|
+
|
|
398
|
+
* {
|
|
399
|
+
font-family: 'Inter', sans-serif;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
Main {
|
|
404
|
+
Div(display: "flex", flexDirection: "column", gap: "16px", alignItems: "center", padding: "40px", fontFamily: "Inter") {
|
|
405
|
+
Heading(level: 1, fontSize: "28px", color: "#000000", fontWeight: "700") {
|
|
406
|
+
"Kick Counter: " + count
|
|
407
|
+
}
|
|
408
|
+
Div(display: "flex", gap: "12px", alignItems: "center") {
|
|
409
|
+
Input(
|
|
410
|
+
bind: userName,
|
|
411
|
+
padding: "10px 14px",
|
|
412
|
+
fontSize: "16px",
|
|
413
|
+
borderRadius: "8px",
|
|
414
|
+
border: "2px solid #6366f1",
|
|
415
|
+
outline: "none",
|
|
416
|
+
width: "250px",
|
|
417
|
+
backgroundColor: "#1e1b4b",
|
|
418
|
+
color: "#e0e7ff",
|
|
419
|
+
fontWeight: "400"
|
|
420
|
+
)
|
|
421
|
+
Button(
|
|
422
|
+
onClick: alert("Kicked: " + userName); console.log("User kicked"); count += 1,
|
|
423
|
+
padding: "10px 20px",
|
|
424
|
+
fontSize: "16px",
|
|
425
|
+
fontWeight: "600",
|
|
426
|
+
borderRadius: "8px",
|
|
427
|
+
border: "none",
|
|
428
|
+
backgroundColor: "#6366f1",
|
|
429
|
+
color: "#ffffff",
|
|
430
|
+
cursor: "pointer",
|
|
431
|
+
minWidth: "180px",
|
|
432
|
+
textAlign: "left"
|
|
433
|
+
) {
|
|
434
|
+
"Kick " + userName
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
Paragraph(fontSize: "14px", color: "#a5b4fc", fontWeight: "400") {
|
|
438
|
+
"Total kicks: " + count
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
# Install
|
|
445
|
+
npm install -g @yannosay/sinth
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
## Quick Start
|
|
452
|
+
`sinth init`
|
|
453
|
+
|
|
454
|
+
`sinth dev pages/index.sinth`
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
Open your browser. Edit your .sinth file. Watch it update live.
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
## Your First Sinth File
|
|
462
|
+
```ts
|
|
463
|
+
page
|
|
464
|
+
title = "My Sinth Project"
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
Main {
|
|
468
|
+
var str nameVar = "User"
|
|
469
|
+
Heading(level: 1) { "Hello, " + nameVar }
|
|
470
|
+
Paragraph { "Welcome to Sinth." }
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
## Features
|
|
479
|
+
|
|
480
|
+
- Mixed logic — if, for, and expressions right in your UI
|
|
481
|
+
- Two-way binding — Input(bind: variable) in one line
|
|
482
|
+
- Reactivity
|
|
483
|
+
- Import own Components
|
|
484
|
+
- Expression-based delays ("delay: index * 300") for staggered animations
|
|
485
|
+
- Object support: var obj with dot notation (user.name)
|
|
486
|
+
- Object iteration: for key, value, index in object
|
|
487
|
+
- SCSS support: style blocks with scoped CSS
|
|
488
|
+
- Tree-shaken output: static pages get zero JS, reactive apps get only what they need
|
|
489
|
+
- VS Code extension: full syntax highlighting (search "Sinth" in the marketplace)
|
|
490
|
+
- Live reload dev server: sinth dev watches your files
|
|
491
|
+
- Self-contained HTML
|
|
492
|
+
- \+ more!
|
|
493
|
+
|
|
494
|
+
###### Nothing you like? Give us feedback on our [Discord Server](https://discord.gg/SUvcrafTQm)!
|
|
495
|
+
|
|
496
|
+
## Shared Runtime
|
|
497
|
+
|
|
498
|
+
For multi-page projects, extract helpers into a cached file:
|
|
499
|
+
`sinth build --shared-runtime`
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
This creates a `sinth-runtime.js` file shared across all pages. Each page shrinks to ~25 lines of render logic. The browser caches the helpers once.
|
|
503
|
+
|
|
504
|
+
Helpful when working on big projects.
|
|
505
|
+
|
|
506
|
+
## Security
|
|
507
|
+
|
|
508
|
+
Sinth's reactive runtime does not use eval(). Every expression is pre-compiled into optimized JavaScript functions at build time. No code injection possible. No runtime string evaluation. The most secure way to power reactive UI.
|
|
509
|
+
|
|
510
|
+
###### Don't trust? -> Ctrl+F "eval(" returns nothing!
|
|
511
|
+
|
|
512
|
+
## Commands
|
|
513
|
+
|
|
514
|
+
- sinth init — scaffold a new project
|
|
515
|
+
- sinth dev [file] — start dev server with live reload
|
|
516
|
+
- sinth build — compile to static files
|
|
517
|
+
- sinth build --shared-runtime — build with shared runtime (useful when using a heavier runtime)
|
|
518
|
+
- sinth check — lint without output
|
|
519
|
+
- sinth version — print version
|
|
520
|
+
|
|
521
|
+
## Imports
|
|
522
|
+
|
|
523
|
+
Importing made easy!
|
|
524
|
+
|
|
525
|
+
```ts
|
|
526
|
+
page
|
|
527
|
+
|
|
528
|
+
import components/MyComponent.sinth as Navbar
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
Navbar
|
|
532
|
+
|
|
533
|
+
Main {
|
|
534
|
+
|
|
535
|
+
}
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
## Links
|
|
539
|
+
|
|
540
|
+
- GitHub: [Official Sinth Repo](https://github.com/yannosay/sinth)
|
|
541
|
+
- Website: [Sinth](https://sinth.yannosay.com) (Note: Deep in development; documentation and various other aspects are not yet finalized.)
|
|
542
|
+
- Discord: [Join here!](https://discord.gg/SUvcrafTQm)
|
|
543
|
+
- VS Code Extension: [Download here](https://marketplace.visualstudio.com/items?itemName=YannosayProductions.sinth-vscode)
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
## License
|
|
548
|
+
|
|
549
549
|
AGPL-3.0 (Just the compiler, the generated Output is 100% yours)
|