@yannosay/sinth 0.13.1 → 0.13.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/README.md +30 -1
- package/package.json +1 -1
- package/src/core/builtins.ts +117 -0
- package/src/core/compiler.ts +64 -927
- package/src/core/expr.ts +6 -2
- package/src/core/head-builder.ts +86 -0
- package/src/core/parser.ts +8 -10
- package/src/core/runtime/functions.ts +33 -0
- package/src/core/runtime/helpers.ts +296 -0
- package/src/core/runtime/render.ts +82 -0
- package/src/core/style-processor.ts +299 -0
- package/src/resolver.ts +1 -1
- package/src/utils.ts +40 -1
package/README.md
CHANGED
|
@@ -18,7 +18,19 @@ Input(bind: userName, placeholder: "Enter your name")
|
|
|
18
18
|
Paragraph { "Hello, " + userName }
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
No useState. No onChange. No e.target.value.
|
|
21
|
+
No useState. No onChange. No e.target.value.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
page
|
|
25
|
+
title = "Counter"
|
|
26
|
+
|
|
27
|
+
var int count = 0
|
|
28
|
+
|
|
29
|
+
Main {
|
|
30
|
+
Heading(level: 1) {count}
|
|
31
|
+
Button(onClick: count = count + 1) {"Increment"}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
22
34
|
|
|
23
35
|
#### Logic and UI live together.
|
|
24
36
|
```ts
|
|
@@ -148,6 +160,8 @@ Main {
|
|
|
148
160
|
|
|
149
161
|
- Mixed logic — if, for, and expressions right in your UI
|
|
150
162
|
- Two-way binding — Input(bind: variable) in one line
|
|
163
|
+
- Reactivity
|
|
164
|
+
- Import own Components
|
|
151
165
|
- Expression-based delays ("delay: index * 300") for staggered animations
|
|
152
166
|
- Object support: var obj with dot notation (user.name)
|
|
153
167
|
- Object iteration: for key, value, index in object
|
|
@@ -185,7 +199,22 @@ Sinth's reactive runtime does not use eval(). Every expression is pre-compiled i
|
|
|
185
199
|
- sinth check — lint without output
|
|
186
200
|
- sinth version — print version
|
|
187
201
|
|
|
202
|
+
## Imports
|
|
188
203
|
|
|
204
|
+
Importing made easy!
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
page
|
|
208
|
+
|
|
209
|
+
import components/MyComponent.sinth as Navbar
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
Navbar
|
|
213
|
+
|
|
214
|
+
Main {
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
```
|
|
189
218
|
|
|
190
219
|
## Links
|
|
191
220
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export interface BuiltinInfo { tag: string; defaultClass?: string; voidEl?: boolean }
|
|
2
|
+
|
|
3
|
+
export const BUILTIN_MAP: Record<string, BuiltinInfo> = {
|
|
4
|
+
// structural
|
|
5
|
+
Main: { tag: "main" },
|
|
6
|
+
Header: { tag: "header" },
|
|
7
|
+
Footer: { tag: "footer" },
|
|
8
|
+
Nav: { tag: "nav" },
|
|
9
|
+
Section: { tag: "section" },
|
|
10
|
+
Article: { tag: "article" },
|
|
11
|
+
Aside: { tag: "aside" },
|
|
12
|
+
Div: { tag: "div" },
|
|
13
|
+
Span: { tag: "span" },
|
|
14
|
+
Hero: { tag: "section", defaultClass: "hero" },
|
|
15
|
+
Container: { tag: "div", defaultClass: "container" },
|
|
16
|
+
Grid: { tag: "div", defaultClass: "grid" },
|
|
17
|
+
Flex: { tag: "div", defaultClass: "flex" },
|
|
18
|
+
Stack: { tag: "div", defaultClass: "stack" },
|
|
19
|
+
Row: { tag: "div", defaultClass: "row" },
|
|
20
|
+
Column: { tag: "div", defaultClass: "col" },
|
|
21
|
+
CardGrid: { tag: "div", defaultClass: "card-grid" },
|
|
22
|
+
// typography
|
|
23
|
+
Heading: { tag: "h1" },
|
|
24
|
+
SubHeading: { tag: "p", defaultClass: "subheading" },
|
|
25
|
+
Paragraph: { tag: "p" },
|
|
26
|
+
Lead: { tag: "p", defaultClass: "lead" },
|
|
27
|
+
Small: { tag: "small" },
|
|
28
|
+
Strong: { tag: "strong" },
|
|
29
|
+
Em: { tag: "em" },
|
|
30
|
+
Code: { tag: "code" },
|
|
31
|
+
Pre: { tag: "pre" },
|
|
32
|
+
Blockquote: { tag: "blockquote" },
|
|
33
|
+
Mark: { tag: "mark" },
|
|
34
|
+
Label: { tag: "label" },
|
|
35
|
+
Abbr: { tag: "abbr" },
|
|
36
|
+
Del: { tag: "del" },
|
|
37
|
+
Ins: { tag: "ins" },
|
|
38
|
+
Sub: { tag: "sub" },
|
|
39
|
+
Sup: { tag: "sup" },
|
|
40
|
+
Data: { tag: "data" },
|
|
41
|
+
Time: { tag: "time" },
|
|
42
|
+
Bdi: { tag: "bdi" },
|
|
43
|
+
Bdo: { tag: "bdo" },
|
|
44
|
+
Cite: { tag: "cite" },
|
|
45
|
+
Dfn: { tag: "dfn" },
|
|
46
|
+
Kbd: { tag: "kbd" },
|
|
47
|
+
Samp: { tag: "samp" },
|
|
48
|
+
Var: { tag: "var" },
|
|
49
|
+
Address: { tag: "address" },
|
|
50
|
+
Ruby: { tag: "ruby" },
|
|
51
|
+
Rt: { tag: "rt" },
|
|
52
|
+
Rp: { tag: "rp" },
|
|
53
|
+
// interactive
|
|
54
|
+
Button: { tag: "button" },
|
|
55
|
+
Link: { tag: "a" },
|
|
56
|
+
NavLink: { tag: "a" },
|
|
57
|
+
Select: { tag: "select" },
|
|
58
|
+
Form: { tag: "form" },
|
|
59
|
+
Fieldset: { tag: "fieldset" },
|
|
60
|
+
Legend: { tag: "legend" },
|
|
61
|
+
Details: { tag: "details" },
|
|
62
|
+
Summary: { tag: "summary" },
|
|
63
|
+
Dialog: { tag: "dialog" },
|
|
64
|
+
Textarea: { tag: "textarea" },
|
|
65
|
+
Datalist: { tag: "datalist" },
|
|
66
|
+
Optgroup: { tag: "optgroup" },
|
|
67
|
+
Option: { tag: "option" },
|
|
68
|
+
Progress: { tag: "progress" },
|
|
69
|
+
Meter: { tag: "meter" },
|
|
70
|
+
Output: { tag: "output" },
|
|
71
|
+
Map: { tag: "map" },
|
|
72
|
+
// media
|
|
73
|
+
Picture: { tag: "picture" },
|
|
74
|
+
Video: { tag: "video" },
|
|
75
|
+
Audio: { tag: "audio" },
|
|
76
|
+
Figure: { tag: "figure" },
|
|
77
|
+
Figcaption: { tag: "figcaption" },
|
|
78
|
+
Canvas: { tag: "canvas" },
|
|
79
|
+
Svg: { tag: "svg" },
|
|
80
|
+
IFrame: { tag: "iframe" },
|
|
81
|
+
Object: { tag: "object" },
|
|
82
|
+
// void elements
|
|
83
|
+
Img: { tag: "img", voidEl: true },
|
|
84
|
+
Logo: { tag: "img", voidEl: true },
|
|
85
|
+
Input: { tag: "input", voidEl: true },
|
|
86
|
+
Checkbox: { tag: "input", voidEl: true },
|
|
87
|
+
Hr: { tag: "hr", voidEl: true },
|
|
88
|
+
Br: { tag: "br", voidEl: true },
|
|
89
|
+
Wbr: { tag: "wbr", voidEl: true },
|
|
90
|
+
Source: { tag: "source", voidEl: true },
|
|
91
|
+
Embed: { tag: "embed", voidEl: true },
|
|
92
|
+
Col: { tag: "col", voidEl: true },
|
|
93
|
+
Area: { tag: "area", voidEl: true },
|
|
94
|
+
// lists
|
|
95
|
+
Ul: { tag: "ul" }, Ol: { tag: "ol" }, Li: { tag: "li" },
|
|
96
|
+
Dl: { tag: "dl" }, Dt: { tag: "dt" }, Dd: { tag: "dd" },
|
|
97
|
+
// tables
|
|
98
|
+
Table: { tag: "table" },
|
|
99
|
+
Caption: { tag: "caption" },
|
|
100
|
+
Thead: { tag: "thead" },
|
|
101
|
+
Tbody: { tag: "tbody" },
|
|
102
|
+
Tfoot: { tag: "tfoot" },
|
|
103
|
+
Tr: { tag: "tr" },
|
|
104
|
+
Th: { tag: "th" },
|
|
105
|
+
Td: { tag: "td" },
|
|
106
|
+
Colgroup: { tag: "colgroup" },
|
|
107
|
+
// utility
|
|
108
|
+
Template: { tag: "template" },
|
|
109
|
+
Slot: { tag: "slot" },
|
|
110
|
+
NoScript: { tag: "noscript" },
|
|
111
|
+
RawHTML: { tag: "__RAW__" },
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const VOID_TAGS = new Set([
|
|
115
|
+
"area","base","br","col","embed","hr","img","input",
|
|
116
|
+
"link","meta","param","source","track","wbr",
|
|
117
|
+
]);
|