@yannosay/sinth 4.1.0 → 5.1.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/DOCS.md +1359 -0
  3. package/README.md +83 -74
  4. package/bin/sinth.js +2 -1
  5. package/dist/cli/args.d.ts +11 -0
  6. package/dist/cli/args.js +74 -0
  7. package/dist/cli/index.d.ts +1 -0
  8. package/dist/cli/index.js +437 -0
  9. package/dist/cli/templates.d.ts +10 -0
  10. package/dist/cli/templates.js +193 -0
  11. package/dist/cli/ui.d.ts +28 -0
  12. package/dist/cli/ui.js +61 -0
  13. package/dist/cli/update-check.d.ts +2 -0
  14. package/dist/cli/update-check.js +124 -0
  15. package/dist/compiler/ast.d.ts +315 -0
  16. package/dist/compiler/ast.js +4 -0
  17. package/dist/compiler/codegen.d.ts +143 -0
  18. package/dist/compiler/codegen.js +1326 -0
  19. package/dist/compiler/diagnostics.d.ts +36 -0
  20. package/dist/compiler/diagnostics.js +142 -0
  21. package/dist/compiler/elements.d.ts +14 -0
  22. package/dist/compiler/elements.js +78 -0
  23. package/dist/compiler/globals.d.ts +2 -0
  24. package/dist/compiler/globals.js +27 -0
  25. package/dist/compiler/html.d.ts +37 -0
  26. package/dist/compiler/html.js +152 -0
  27. package/dist/compiler/lexer.d.ts +42 -0
  28. package/dist/compiler/lexer.js +404 -0
  29. package/dist/compiler/parser.d.ts +95 -0
  30. package/dist/compiler/parser.js +1374 -0
  31. package/dist/compiler/prerender.d.ts +72 -0
  32. package/dist/compiler/prerender.js +910 -0
  33. package/dist/compiler/script-analysis.d.ts +6 -0
  34. package/dist/compiler/script-analysis.js +106 -0
  35. package/dist/compiler/style.d.ts +39 -0
  36. package/dist/compiler/style.js +463 -0
  37. package/dist/deploy/cloudflare.d.ts +9 -0
  38. package/dist/deploy/cloudflare.js +111 -0
  39. package/dist/index.d.ts +13 -0
  40. package/dist/index.js +23 -0
  41. package/dist/project/build.d.ts +31 -0
  42. package/dist/project/build.js +425 -0
  43. package/dist/project/config.d.ts +33 -0
  44. package/dist/project/config.js +142 -0
  45. package/dist/project/project.d.ts +74 -0
  46. package/dist/project/project.js +535 -0
  47. package/dist/runtime/index.d.ts +68 -0
  48. package/dist/runtime/index.js +912 -0
  49. package/dist/server/client.d.ts +1 -0
  50. package/dist/server/client.js +112 -0
  51. package/dist/server/dev.d.ts +8 -0
  52. package/dist/server/dev.js +244 -0
  53. package/dist/server/preview.d.ts +6 -0
  54. package/dist/server/preview.js +106 -0
  55. package/dist/server/static.d.ts +10 -0
  56. package/dist/server/static.js +136 -0
  57. package/lib/ui/index.sinth +436 -0
  58. package/package.json +33 -15
  59. package/schema/sinth.config.schema.json +54 -0
  60. package/dist/browser/compile.js +0 -63
  61. package/dist/cli.js +0 -509
  62. package/dist/core/builtins.js +0 -117
  63. package/dist/core/cli-compiler.js +0 -705
  64. package/dist/core/compiler.js +0 -1489
  65. package/dist/core/expr.js +0 -129
  66. package/dist/core/head-builder.js +0 -130
  67. package/dist/core/lexer.js +0 -410
  68. package/dist/core/parser.js +0 -1646
  69. package/dist/core/runtime/custom-element.js +0 -81
  70. package/dist/core/runtime/functions.js +0 -99
  71. package/dist/core/runtime/helpers.js +0 -347
  72. package/dist/core/runtime/render.js +0 -136
  73. package/dist/core/style-processor.js +0 -317
  74. package/dist/core/types.js +0 -93
  75. package/dist/resolver.js +0 -175
  76. package/dist/server.js +0 -174
  77. package/dist/update-check.js +0 -109
  78. package/dist/utils.js +0 -80
@@ -0,0 +1,436 @@
1
+ -- sinth:ui: the official Sinth component library.
2
+ -- Usage: import { Button, Card } from "sinth:ui"
3
+ -- Theme it by overriding the --ui-* custom properties on :root.
4
+
5
+ component Button(str variant = "primary", str size = "md", str? href, bool disabled = false, str type = "button", bool block = false) {
6
+ if href {
7
+ Link(class: ["ui-btn", "ui-btn--" + variant, "ui-btn--" + size, block ? "ui-btn--block" : ""], href: href, ariaDisabled: disabled ? "true" : null) {
8
+ $slot
9
+ }
10
+ } else {
11
+ Button(class: ["ui-btn", "ui-btn--" + variant, "ui-btn--" + size, block ? "ui-btn--block" : ""], type: type, disabled: disabled) {
12
+ $slot
13
+ }
14
+ }
15
+ }
16
+
17
+ component Card(str? title, str? subtitle, bool interactive = false) {
18
+ Article(class: ["ui-card", interactive ? "ui-card--interactive" : ""]) {
19
+ if title {
20
+ Header(class: "ui-card__header") {
21
+ Heading(level: 3, class: "ui-card__title") { title }
22
+ if subtitle {
23
+ Paragraph(class: "ui-card__subtitle") { subtitle }
24
+ }
25
+ }
26
+ }
27
+ Div(class: "ui-card__body") {
28
+ $slot
29
+ }
30
+ $slot(name: "footer")
31
+ }
32
+ }
33
+
34
+ component Badge(str tone = "neutral") {
35
+ Span(class: ["ui-badge", "ui-badge--" + tone]) {
36
+ $slot
37
+ }
38
+ }
39
+
40
+ component Alert(str tone = "info", str? title) {
41
+ Div(class: ["ui-alert", "ui-alert--" + tone], role: tone == "danger" ? "alert" : "status") {
42
+ if title {
43
+ Strong(class: "ui-alert__title") { title }
44
+ }
45
+ Div(class: "ui-alert__body") {
46
+ $slot
47
+ }
48
+ }
49
+ }
50
+
51
+ component Content(str width = "lg") {
52
+ Div(class: ["ui-content", "ui-content--" + width]) {
53
+ $slot
54
+ }
55
+ }
56
+
57
+ component Columns(str min = "16rem", str gap = "1rem") {
58
+ Div(class: "ui-columns", style: { gridTemplateColumns: "repeat(auto-fill, minmax(min(" + min + ", 100%), 1fr))", gap: gap }) {
59
+ $slot
60
+ }
61
+ }
62
+
63
+ component Inline(str gap = "0.5rem", str align = "center", str justify = "flex-start", bool wrap = true) {
64
+ Div(class: "ui-inline", style: { gap: gap, alignItems: align, justifyContent: justify, flexWrap: wrap ? "wrap" : "nowrap" }) {
65
+ $slot
66
+ }
67
+ }
68
+
69
+ component VStack(str gap = "1rem", str align = "stretch") {
70
+ Div(class: "ui-vstack", style: { gap: gap, alignItems: align }) {
71
+ $slot
72
+ }
73
+ }
74
+
75
+ component Field(str label, bind value, str type = "text", str placeholder = "", str? hint, str? error, bool required = false, str? name) {
76
+ Label(class: ["ui-field", error ? "ui-field--invalid" : ""]) {
77
+ Span(class: "ui-field__label") {
78
+ label
79
+ if required {
80
+ Span(class: "ui-field__required", ariaHidden: "true") { " *" }
81
+ }
82
+ }
83
+ if type == "textarea" {
84
+ Textarea(class: "ui-field__control", model: value, placeholder: placeholder, required: required, name: name, ariaInvalid: error ? "true" : null)
85
+ } else {
86
+ Input(class: "ui-field__control", type: type, model: value, placeholder: placeholder, required: required, name: name, ariaInvalid: error ? "true" : null)
87
+ }
88
+ if error {
89
+ Span(class: "ui-field__error") { error }
90
+ } else if hint {
91
+ Span(class: "ui-field__hint") { hint }
92
+ }
93
+ }
94
+ }
95
+
96
+ component Toggle(bind checked, str? label) {
97
+ Label(class: "ui-toggle") {
98
+ Input(type: "checkbox", role: "switch", class: "ui-toggle__input", model: checked)
99
+ Span(class: "ui-toggle__track", ariaHidden: "true") {
100
+ Span(class: "ui-toggle__thumb")
101
+ }
102
+ if label {
103
+ Span(class: "ui-toggle__label") { label }
104
+ }
105
+ }
106
+ }
107
+
108
+ component Modal(bind open, str? title, str width = "32rem") {
109
+ var obj dialog = null
110
+
111
+ watch open {
112
+ if open {
113
+ setTimeout(() => dialog?.focus(), 0)
114
+ }
115
+ }
116
+
117
+ if open transition("ui-fade") {
118
+ Div(class: "ui-modal", onClick.self: open = false, onKeyDown.esc: open = false) {
119
+ Div(class: "ui-modal__dialog", ref: dialog, role: "dialog", ariaModal: "true", ariaLabel: title, tabindex: "-1", style: { maxWidth: width }) {
120
+ Header(class: "ui-modal__header") {
121
+ if title {
122
+ Heading(level: 2, class: "ui-modal__title") { title }
123
+ }
124
+ Button(class: "ui-modal__close", ariaLabel: "Close", onClick: open = false) { "×" }
125
+ }
126
+ Div(class: "ui-modal__body") {
127
+ $slot
128
+ }
129
+ $slot(name: "footer")
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ component Avatar(str name, str? src, str size = "2.5rem") {
136
+ if src {
137
+ Img(class: "ui-avatar", src: src, alt: name, style: { width: size, height: size })
138
+ } else {
139
+ Span(class: "ui-avatar ui-avatar--initials", title: name, style: { width: size, height: size }) {
140
+ name.split(" ").map((part) => part.slice(0, 1)).join("").slice(0, 2).toUpperCase()
141
+ }
142
+ }
143
+ }
144
+
145
+ component Spinner(str size = "1.25rem", str label = "Loading") {
146
+ Span(class: "ui-spinner", role: "status", ariaLabel: label, style: { width: size, height: size })
147
+ }
148
+
149
+ component Navbar(str? brand, str brandHref = "/") {
150
+ Header(class: "ui-navbar") {
151
+ Nav(class: "ui-navbar__inner") {
152
+ if brand {
153
+ Link(class: "ui-navbar__brand", href: brandHref) { brand }
154
+ }
155
+ $slot(name: "brand")
156
+ Div(class: "ui-navbar__links") {
157
+ $slot
158
+ }
159
+ }
160
+ }
161
+ }
162
+
163
+ component Divider(str? label) {
164
+ if label {
165
+ Div(class: "ui-divider ui-divider--label", role: "separator") {
166
+ Span { label }
167
+ }
168
+ } else {
169
+ Hr(class: "ui-divider")
170
+ }
171
+ }
172
+
173
+ style global {
174
+ :root {
175
+ --ui-bg: "#ffffff"
176
+ --ui-surface: "#f7f7f8"
177
+ --ui-surface-2: "#efeff1"
178
+ --ui-text: "#0a0a0b"
179
+ --ui-muted: "#5f5f6b"
180
+ --ui-border: "#e3e3e8"
181
+ --ui-accent: "#9333ea"
182
+ --ui-accent-hover: "#7e22ce"
183
+ --ui-accent-text: "#ffffff"
184
+ --ui-success: "#15803d"
185
+ --ui-warning: "#b45309"
186
+ --ui-danger: "#dc2626"
187
+ --ui-info: "#2563eb"
188
+ --ui-radius: "10px"
189
+ --ui-radius-lg: "16px"
190
+ --ui-shadow: "0 1px 2px rgba(10, 10, 11, 0.06), 0 8px 24px rgba(10, 10, 11, 0.06)"
191
+ --ui-font: "system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif"
192
+ --ui-mono: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"
193
+ colorScheme: "light dark"
194
+ }
195
+ dark {
196
+ :root {
197
+ --ui-bg: "#0a0a0b"
198
+ --ui-surface: "#141416"
199
+ --ui-surface-2: "#1c1c20"
200
+ --ui-text: "#f5f5f6"
201
+ --ui-muted: "#a1a1aa"
202
+ --ui-border: "#2a2a2f"
203
+ --ui-accent: "#c084fc"
204
+ --ui-accent-hover: "#d8b4fe"
205
+ --ui-accent-text: "#0a0a0b"
206
+ --ui-shadow: "0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35)"
207
+ }
208
+ }
209
+ *, *::before, *::after { boxSizing: "border-box" }
210
+ body {
211
+ margin: 0
212
+ background: "var(--ui-bg)"
213
+ color: "var(--ui-text)"
214
+ fontFamily: "var(--ui-font)"
215
+ lineHeight: "1.6"
216
+ WebkitFontSmoothing: "antialiased"
217
+ }
218
+ img, svg, video { maxWidth: "100%" }
219
+ a { color: "var(--ui-accent)" }
220
+ :focus-visible { outline: "2px solid var(--ui-accent)"; outlineOffset: "2px" }
221
+
222
+ .ui-btn {
223
+ display: "inline-flex"
224
+ alignItems: "center"
225
+ justifyContent: "center"
226
+ gap: "0.5rem"
227
+ border: "1px solid transparent"
228
+ borderRadius: "var(--ui-radius)"
229
+ font: "inherit"
230
+ fontWeight: "600"
231
+ lineHeight: "1.2"
232
+ textDecoration: "none"
233
+ cursor: "pointer"
234
+ transition: "background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.05s"
235
+ &:active { transform: "translateY(1px)" }
236
+ &:disabled, &[aria-disabled="true"] { opacity: "0.5"; cursor: "not-allowed"; pointerEvents: "none" }
237
+ }
238
+ .ui-btn--sm { padding: "0.375rem 0.75rem"; fontSize: "0.875rem" }
239
+ .ui-btn--md { padding: "0.625rem 1.125rem"; fontSize: "0.95rem" }
240
+ .ui-btn--lg { padding: "0.8rem 1.5rem"; fontSize: "1.05rem" }
241
+ .ui-btn--block { display: "flex"; width: "100%" }
242
+ .ui-btn--primary { background: "var(--ui-accent)"; color: "var(--ui-accent-text)" }
243
+ .ui-btn--primary:hover { background: "var(--ui-accent-hover)" }
244
+ .ui-btn--secondary { background: "var(--ui-surface)"; color: "var(--ui-text)"; borderColor: "var(--ui-border)" }
245
+ .ui-btn--secondary:hover { background: "var(--ui-surface-2)" }
246
+ .ui-btn--ghost { background: "transparent"; color: "var(--ui-text)" }
247
+ .ui-btn--ghost:hover { background: "var(--ui-surface)" }
248
+ .ui-btn--danger { background: "var(--ui-danger)"; color: "#ffffff" }
249
+
250
+ .ui-card {
251
+ background: "var(--ui-surface)"
252
+ border: "1px solid var(--ui-border)"
253
+ borderRadius: "var(--ui-radius-lg)"
254
+ padding: "1.25rem"
255
+ display: "flex"
256
+ flexDirection: "column"
257
+ gap: "0.75rem"
258
+ }
259
+ .ui-card--interactive { transition: "transform 0.15s, box-shadow 0.15s" }
260
+ .ui-card--interactive:hover { transform: "translateY(-2px)"; boxShadow: "var(--ui-shadow)" }
261
+ .ui-card__title { margin: "0"; fontSize: "1.1rem" }
262
+ .ui-card__subtitle { margin: "0.25rem 0 0"; color: "var(--ui-muted)"; fontSize: "0.9rem" }
263
+ .ui-card__body > :first-child { marginTop: "0" }
264
+ .ui-card__body > :last-child { marginBottom: "0" }
265
+
266
+ .ui-badge {
267
+ display: "inline-flex"
268
+ alignItems: "center"
269
+ padding: "0.125rem 0.6rem"
270
+ borderRadius: "999px"
271
+ fontSize: "0.78rem"
272
+ fontWeight: "600"
273
+ background: "var(--ui-surface-2)"
274
+ color: "var(--ui-text)"
275
+ }
276
+ .ui-badge--accent { background: "color-mix(in srgb, var(--ui-accent) 18%, transparent)"; color: "var(--ui-accent)" }
277
+ .ui-badge--success { background: "color-mix(in srgb, var(--ui-success) 16%, transparent)"; color: "var(--ui-success)" }
278
+ .ui-badge--warning { background: "color-mix(in srgb, var(--ui-warning) 16%, transparent)"; color: "var(--ui-warning)" }
279
+ .ui-badge--danger { background: "color-mix(in srgb, var(--ui-danger) 16%, transparent)"; color: "var(--ui-danger)" }
280
+
281
+ .ui-alert {
282
+ display: "flex"
283
+ flexDirection: "column"
284
+ gap: "0.25rem"
285
+ padding: "0.875rem 1rem"
286
+ borderRadius: "var(--ui-radius)"
287
+ borderLeft: "4px solid var(--ui-info)"
288
+ background: "color-mix(in srgb, var(--ui-info) 10%, var(--ui-bg))"
289
+ }
290
+ .ui-alert--success { borderLeftColor: "var(--ui-success)"; background: "color-mix(in srgb, var(--ui-success) 10%, var(--ui-bg))" }
291
+ .ui-alert--warning { borderLeftColor: "var(--ui-warning)"; background: "color-mix(in srgb, var(--ui-warning) 10%, var(--ui-bg))" }
292
+ .ui-alert--danger { borderLeftColor: "var(--ui-danger)"; background: "color-mix(in srgb, var(--ui-danger) 10%, var(--ui-bg))" }
293
+
294
+ .ui-content { width: "100%"; marginInline: "auto"; paddingInline: "1.25rem" }
295
+ .ui-content--sm { maxWidth: "40rem" }
296
+ .ui-content--md { maxWidth: "56rem" }
297
+ .ui-content--lg { maxWidth: "72rem" }
298
+ .ui-content--full { maxWidth: "none" }
299
+ .ui-columns { display: "grid" }
300
+ .ui-inline { display: "flex" }
301
+ .ui-vstack { display: "flex"; flexDirection: "column" }
302
+
303
+ .ui-field { display: "flex"; flexDirection: "column"; gap: "0.375rem"; fontSize: "0.95rem" }
304
+ .ui-field__label { fontWeight: "600" }
305
+ .ui-field__required { color: "var(--ui-danger)" }
306
+ .ui-field__control {
307
+ font: "inherit"
308
+ color: "inherit"
309
+ padding: "0.6rem 0.75rem"
310
+ borderRadius: "var(--ui-radius)"
311
+ border: "1px solid var(--ui-border)"
312
+ background: "var(--ui-bg)"
313
+ transition: "border-color 0.15s, box-shadow 0.15s"
314
+ &:focus { outline: "none"; borderColor: "var(--ui-accent)"; boxShadow: "0 0 0 3px color-mix(in srgb, var(--ui-accent) 25%, transparent)" }
315
+ }
316
+ textarea.ui-field__control { minHeight: "6rem"; resize: "vertical" }
317
+ .ui-field--invalid .ui-field__control { borderColor: "var(--ui-danger)" }
318
+ .ui-field__hint { color: "var(--ui-muted)"; fontSize: "0.85rem" }
319
+ .ui-field__error { color: "var(--ui-danger)"; fontSize: "0.85rem" }
320
+
321
+ .ui-toggle { display: "inline-flex"; alignItems: "center"; gap: "0.6rem"; cursor: "pointer"; position: "relative" }
322
+ .ui-toggle__input { position: "absolute"; opacity: "0"; width: "1px"; height: "1px" }
323
+ .ui-toggle__track {
324
+ width: "2.5rem"
325
+ height: "1.45rem"
326
+ borderRadius: "999px"
327
+ background: "var(--ui-surface-2)"
328
+ border: "1px solid var(--ui-border)"
329
+ position: "relative"
330
+ transition: "background-color 0.15s"
331
+ }
332
+ .ui-toggle__thumb {
333
+ position: "absolute"
334
+ top: "2px"
335
+ left: "2px"
336
+ width: "1.1rem"
337
+ height: "1.1rem"
338
+ borderRadius: "50%"
339
+ background: "var(--ui-text)"
340
+ transition: "transform 0.15s"
341
+ }
342
+ .ui-toggle__input:checked + .ui-toggle__track { background: "var(--ui-accent)"; borderColor: "var(--ui-accent)" }
343
+ .ui-toggle__input:checked + .ui-toggle__track .ui-toggle__thumb { transform: "translateX(1.05rem)"; background: "var(--ui-accent-text)" }
344
+ .ui-toggle__input:focus-visible + .ui-toggle__track { outline: "2px solid var(--ui-accent)"; outlineOffset: "2px" }
345
+
346
+ .ui-modal {
347
+ position: "fixed"
348
+ inset: "0"
349
+ zIndex: "1000"
350
+ display: "flex"
351
+ alignItems: "center"
352
+ justifyContent: "center"
353
+ padding: "1rem"
354
+ background: "rgba(10, 10, 11, 0.55)"
355
+ backdropFilter: "blur(4px)"
356
+ transition: "opacity 0.18s"
357
+ }
358
+ .ui-modal__dialog {
359
+ width: "100%"
360
+ background: "var(--ui-bg)"
361
+ color: "var(--ui-text)"
362
+ borderRadius: "var(--ui-radius-lg)"
363
+ border: "1px solid var(--ui-border)"
364
+ boxShadow: "var(--ui-shadow)"
365
+ padding: "1.25rem"
366
+ display: "flex"
367
+ flexDirection: "column"
368
+ gap: "1rem"
369
+ maxHeight: "90vh"
370
+ overflow: "auto"
371
+ }
372
+ .ui-modal__header { display: "flex"; alignItems: "center"; justifyContent: "space-between"; gap: "1rem" }
373
+ .ui-modal__title { margin: "0"; fontSize: "1.2rem" }
374
+ .ui-modal__close {
375
+ border: "0"
376
+ background: "transparent"
377
+ color: "var(--ui-muted)"
378
+ fontSize: "1.5rem"
379
+ lineHeight: "1"
380
+ cursor: "pointer"
381
+ padding: "0.25rem 0.5rem"
382
+ borderRadius: "var(--ui-radius)"
383
+ marginLeft: "auto"
384
+ &:hover { background: "var(--ui-surface)"; color: "var(--ui-text)" }
385
+ }
386
+ .ui-fade-enter, .ui-fade-leave { opacity: "0" }
387
+
388
+ .ui-avatar { borderRadius: "50%"; objectFit: "cover"; flexShrink: "0" }
389
+ .ui-avatar--initials {
390
+ display: "inline-flex"
391
+ alignItems: "center"
392
+ justifyContent: "center"
393
+ background: "color-mix(in srgb, var(--ui-accent) 20%, var(--ui-surface))"
394
+ color: "var(--ui-accent)"
395
+ fontWeight: "700"
396
+ fontSize: "0.85em"
397
+ }
398
+
399
+ .ui-spinner {
400
+ display: "inline-block"
401
+ borderRadius: "50%"
402
+ border: "2px solid var(--ui-border)"
403
+ borderTopColor: "var(--ui-accent)"
404
+ animation: "ui-spin 0.7s linear infinite"
405
+ }
406
+ @keyframes ui-spin { to { transform: "rotate(360deg)" } }
407
+ reducedMotion {
408
+ .ui-spinner { animationDuration: "2s" }
409
+ .ui-btn, .ui-card--interactive, .ui-modal { transition: "none" }
410
+ }
411
+
412
+ .ui-navbar {
413
+ position: "sticky"
414
+ top: "0"
415
+ zIndex: "100"
416
+ background: "color-mix(in srgb, var(--ui-bg) 85%, transparent)"
417
+ backdropFilter: "saturate(1.4) blur(10px)"
418
+ borderBottom: "1px solid var(--ui-border)"
419
+ }
420
+ .ui-navbar__inner { maxWidth: "72rem"; margin: "0 auto"; padding: "0.75rem 1.25rem"; display: "flex"; alignItems: "center"; gap: "1.5rem" }
421
+ .ui-navbar__brand { fontWeight: "800"; fontSize: "1.1rem"; color: "var(--ui-text)"; textDecoration: "none" }
422
+ .ui-navbar__links { display: "flex"; alignItems: "center"; gap: "1rem"; marginLeft: "auto"; flexWrap: "wrap" }
423
+ .ui-navbar__links a { color: "var(--ui-muted)"; textDecoration: "none"; fontWeight: "500" }
424
+ .ui-navbar__links a:hover { color: "var(--ui-text)" }
425
+
426
+ .ui-divider { border: "0"; borderTop: "1px solid var(--ui-border)"; margin: "1.5rem 0" }
427
+ .ui-divider--label {
428
+ display: "flex"
429
+ alignItems: "center"
430
+ gap: "0.75rem"
431
+ color: "var(--ui-muted)"
432
+ fontSize: "0.85rem"
433
+ borderTop: "0"
434
+ &::before, &::after { content: "''"; flex: "1"; borderTop: "1px solid var(--ui-border)" }
435
+ }
436
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "4.1.0",
4
- "description": "An easy, powerful, declarative & reactive language that compiles to pure HTML, CSS, and JavaScript.",
3
+ "version": "5.1.0",
4
+ "description": "A declarative, reactive UI language that compiles to fast, secure, static-first HTML, CSS and JavaScript.",
5
5
  "author": "Yannosay Productions",
6
6
  "license": "AGPL-3.0",
7
7
  "homepage": "https://sinth.yannosay.com",
@@ -13,16 +13,18 @@
13
13
  "url": "https://github.com/Yannosay/sinth/issues"
14
14
  },
15
15
  "keywords": [
16
- "html",
17
- "css",
18
- "javascript",
16
+ "sinth",
17
+ "language",
19
18
  "compiler",
19
+ "ui",
20
+ "reactive",
20
21
  "declarative",
22
+ "static-site",
23
+ "html",
24
+ "css",
21
25
  "web",
22
26
  "components",
23
- "scss",
24
- "reactive",
25
- "react"
27
+ "cloudflare-pages"
26
28
  ],
27
29
  "bin": {
28
30
  "sinth": "bin/sinth.js"
@@ -30,15 +32,20 @@
30
32
  "files": [
31
33
  "bin/",
32
34
  "dist/",
33
- "assets/",
35
+ "lib/",
36
+ "schema/",
34
37
  "README.md",
38
+ "DOCS.md",
39
+ "CHANGELOG.md",
35
40
  "LICENSE"
36
41
  ],
37
42
  "scripts": {
38
- "build": "tsc",
39
- "lint": "eslint src --ext .ts",
40
- "lint:fix": "eslint src --ext .ts --fix",
41
- "prepublishOnly": "npm run build"
43
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.runtime.json",
44
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
45
+ "lint": "eslint src",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.runtime.json --noEmit",
47
+ "test": "npm run build && node scripts/test.js",
48
+ "prepublishOnly": "npm run clean && npm run build && npm run lint && node scripts/test.js"
42
49
  },
43
50
  "devDependencies": {
44
51
  "@eslint/js": "^10.0.1",
@@ -46,11 +53,22 @@
46
53
  "@typescript-eslint/eslint-plugin": "^8.61.0",
47
54
  "@typescript-eslint/parser": "^8.61.0",
48
55
  "eslint": "^10.5.0",
49
- "ts-node": "^10.9.0",
56
+ "jsdom": "^25.0.1",
57
+ "sass": "^1.108.1",
50
58
  "typescript": "^5.3.0",
51
59
  "typescript-eslint": "^8.61.0"
52
60
  },
53
61
  "engines": {
54
- "node": ">=18.0.0"
62
+ "node": ">=18.17"
63
+ },
64
+ "dependencies": {
65
+ "acorn": "^8.19.0",
66
+ "esbuild": "^0.25.12"
67
+ },
68
+ "main": "dist/index.js",
69
+ "types": "dist/index.d.ts",
70
+ "publishConfig": {
71
+ "access": "public",
72
+ "provenance": true
55
73
  }
56
74
  }
@@ -0,0 +1,54 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Sinth configuration",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "definitions": {
7
+ "options": {
8
+ "type": "object",
9
+ "properties": {
10
+ "outDir": { "type": "string", "description": "Build output folder", "default": "dist" },
11
+ "pagesDir": { "type": "string", "description": "Folder containing pages", "default": "pages" },
12
+ "publicDir": { "type": "string", "description": "Copied to the output root", "default": "public" },
13
+ "staticDirs": { "type": "array", "items": { "type": "string" }, "description": "Folders copied to <outDir>/<name>", "default": ["assets"] },
14
+ "libraryPaths": { "type": "array", "items": { "type": "string" }, "description": "Folders searched for bare imports", "default": ["libraries"] },
15
+ "site": { "type": "string", "pattern": "^https?://", "description": "Public URL, enables sitemap.xml and robots.txt" },
16
+ "base": { "type": "string", "description": "URL prefix when hosting in a subfolder", "default": "/" },
17
+ "minify": { "type": "boolean", "description": "Minify JS and CSS" },
18
+ "sourcemap": { "type": "boolean", "description": "Emit source maps" },
19
+ "port": { "type": "integer", "minimum": 1, "maximum": 65535, "default": 3000 },
20
+ "host": { "type": "string", "default": "127.0.0.1" },
21
+ "previewPort": { "type": "integer", "minimum": 1, "maximum": 65535, "default": 4000 },
22
+ "target": { "type": "array", "items": { "type": "string" }, "description": "esbuild targets" },
23
+ "security": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "headers": { "type": "boolean", "default": true, "description": "Write a _headers file" },
28
+ "csp": { "type": ["boolean", "string"], "default": true, "description": "true (generated), false, or a custom Content-Security-Policy" }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ },
34
+ "allOf": [{ "$ref": "#/definitions/options" }],
35
+ "properties": {
36
+ "$schema": { "type": "string" },
37
+ "outDir": {}, "pagesDir": {}, "publicDir": {}, "staticDirs": {}, "libraryPaths": {}, "site": {}, "base": {},
38
+ "minify": {}, "sourcemap": {}, "port": {}, "host": {}, "previewPort": {}, "target": {}, "security": {},
39
+ "cloudflare": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "properties": {
43
+ "projectName": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,56}[a-z0-9]$" },
44
+ "accountId": { "type": "string", "pattern": "^[a-f0-9]{32}$" },
45
+ "productionBranch": { "type": "string", "default": "main" }
46
+ }
47
+ },
48
+ "development": { "$ref": "#/definitions/options" },
49
+ "production": { "$ref": "#/definitions/options" },
50
+ "sharedRuntime": { "deprecated": true, "description": "Ignored since Sinth 5" },
51
+ "inlineJS": { "deprecated": true, "description": "Ignored since Sinth 5" },
52
+ "inlineCSS": { "deprecated": true, "description": "Ignored since Sinth 5" }
53
+ }
54
+ }
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileSinth = compileSinth;
4
- const lexer_1 = require("../core/lexer");
5
- const parser_1 = require("../core/parser");
6
- const compiler_1 = require("../core/compiler");
7
- const utils_1 = require("../utils");
8
- const style_processor_1 = require("../core/style-processor");
9
- function compileSinth(source) {
10
- const tokens = new lexer_1.Lexer(source, "<script>").tokenize();
11
- const parser = new parser_1.Parser(tokens, "<script>");
12
- const file = parser.parse();
13
- if (!file.isPage)
14
- return null;
15
- const hash = (0, utils_1.fnv1a)("<script>" + Math.random().toString(36));
16
- const instanceId = "s" + Math.random().toString(36).slice(2, 8);
17
- const ctx = {
18
- allDefs: new Map(),
19
- functionDefs: file.functions,
20
- customEls: new Map(),
21
- cssLinks: [],
22
- jsLinks: [],
23
- scopeHash: hash,
24
- pageFile: "<script>",
25
- extraCSS: [],
26
- mixedBlocks: [],
27
- mixedCounter: 0,
28
- logicBlocks: [],
29
- ifIdCounter: 0,
30
- exprRegistry: [],
31
- exprMap: new Map(),
32
- varDecls: file.varDecls,
33
- actionButtons: [],
34
- diffingEnabled: false,
35
- declaredVars: new Set(file.varDecls.map(v => v.name)),
36
- namespace: instanceId,
37
- };
38
- const bodyHTML = file.uses.map(u => (0, compiler_1.renderCompUse)(u, ctx, new Map(), 0)).join("\n");
39
- const pageCSS = file.styles.map(s => (0, style_processor_1.processStyleBlock)(s, hash, new Map())).join("\n");
40
- const allVarDecls = [...file.varDecls, ...(ctx.varDecls?.filter(v => !file.varDecls.some(fv => fv.name === v.name)) ?? [])];
41
- const assignedVars = new Set();
42
- for (const v of allVarDecls) {
43
- if (v.value)
44
- assignedVars.add(v.name);
45
- }
46
- const runtime = (0, compiler_1.buildRuntime)({
47
- varDecls: allVarDecls,
48
- bodyHTML,
49
- logicBlocks: ctx.logicBlocks,
50
- mixedBlocks: ctx.mixedBlocks,
51
- assignedVars,
52
- exprRegistry: ctx.exprRegistry,
53
- sharedRuntime: false,
54
- functionsJS: "",
55
- namespace: instanceId,
56
- });
57
- const js = typeof runtime === 'string' ? runtime : runtime.page;
58
- const scopedJs = js;
59
- return {
60
- html: `<div data-s="${hash}">${bodyHTML}</div><style>${pageCSS}</style>`,
61
- js: scopedJs,
62
- };
63
- }