@yannosay/sinth 4.1.0 → 5.1.1
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/CHANGELOG.md +89 -0
- package/DOCS.md +1359 -0
- package/README.md +83 -74
- package/bin/sinth.js +2 -1
- package/dist/cli/args.d.ts +11 -0
- package/dist/cli/args.js +74 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +437 -0
- package/dist/cli/templates.d.ts +10 -0
- package/dist/cli/templates.js +193 -0
- package/dist/cli/ui.d.ts +28 -0
- package/dist/cli/ui.js +61 -0
- package/dist/cli/update-check.d.ts +2 -0
- package/dist/cli/update-check.js +124 -0
- package/dist/compiler/ast.d.ts +315 -0
- package/dist/compiler/ast.js +4 -0
- package/dist/compiler/codegen.d.ts +143 -0
- package/dist/compiler/codegen.js +1326 -0
- package/dist/compiler/diagnostics.d.ts +36 -0
- package/dist/compiler/diagnostics.js +142 -0
- package/dist/compiler/elements.d.ts +14 -0
- package/dist/compiler/elements.js +78 -0
- package/dist/compiler/globals.d.ts +2 -0
- package/dist/compiler/globals.js +27 -0
- package/dist/compiler/html.d.ts +37 -0
- package/dist/compiler/html.js +152 -0
- package/dist/compiler/lexer.d.ts +42 -0
- package/dist/compiler/lexer.js +404 -0
- package/dist/compiler/parser.d.ts +95 -0
- package/dist/compiler/parser.js +1374 -0
- package/dist/compiler/prerender.d.ts +72 -0
- package/dist/compiler/prerender.js +910 -0
- package/dist/compiler/script-analysis.d.ts +6 -0
- package/dist/compiler/script-analysis.js +106 -0
- package/dist/compiler/style.d.ts +39 -0
- package/dist/compiler/style.js +463 -0
- package/dist/deploy/cloudflare.d.ts +9 -0
- package/dist/deploy/cloudflare.js +111 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +23 -0
- package/dist/project/build.d.ts +31 -0
- package/dist/project/build.js +425 -0
- package/dist/project/config.d.ts +33 -0
- package/dist/project/config.js +142 -0
- package/dist/project/project.d.ts +74 -0
- package/dist/project/project.js +555 -0
- package/dist/runtime/index.d.ts +68 -0
- package/dist/runtime/index.js +912 -0
- package/dist/server/client.d.ts +1 -0
- package/dist/server/client.js +112 -0
- package/dist/server/dev.d.ts +8 -0
- package/dist/server/dev.js +244 -0
- package/dist/server/preview.d.ts +6 -0
- package/dist/server/preview.js +106 -0
- package/dist/server/static.d.ts +10 -0
- package/dist/server/static.js +136 -0
- package/lib/ui/index.sinth +436 -0
- package/package.json +33 -15
- package/schema/sinth.config.schema.json +54 -0
- package/dist/browser/compile.js +0 -63
- package/dist/cli.js +0 -509
- package/dist/core/builtins.js +0 -117
- package/dist/core/cli-compiler.js +0 -705
- package/dist/core/compiler.js +0 -1489
- package/dist/core/expr.js +0 -129
- package/dist/core/head-builder.js +0 -130
- package/dist/core/lexer.js +0 -410
- package/dist/core/parser.js +0 -1646
- package/dist/core/runtime/custom-element.js +0 -81
- package/dist/core/runtime/functions.js +0 -99
- package/dist/core/runtime/helpers.js +0 -347
- package/dist/core/runtime/render.js +0 -136
- package/dist/core/style-processor.js +0 -317
- package/dist/core/types.js +0 -93
- package/dist/resolver.js +0 -175
- package/dist/server.js +0 -174
- package/dist/update-check.js +0 -109
- package/dist/utils.js +0 -80
package/README.md
CHANGED
|
@@ -1,96 +1,105 @@
|
|
|
1
|
-
# 
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@yannosay/sinth) [](https://www.npmjs.com/package/@yannosay/sinth) [](https://github.com/Yannosay/sinth/actions) [](./LICENSE)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Sinth is a reactive language for building websites and web apps of any size, from a landing page to a large multi-page product.** Write pages and components in one readable syntax. The compiler type-checks your whole project and turns it into static-first HTML, CSS and JavaScript, with no framework to learn.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```sinth
|
|
8
|
+
title = "Counter"
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
* **Simple to setup:** You don't need to download 5 different packages. Download Sinth, create `.sinth` files, and easily transform them into usable HTML right in your CLI.
|
|
10
|
+
var num count = 0
|
|
11
11
|
|
|
12
|
-
## Install
|
|
13
|
-
|
|
14
|
-
* To install Sinth, use this command:
|
|
15
|
-
* `npm install -g @yannosay/sinth`
|
|
16
|
-
|
|
17
|
-
The Sinth compiler is designed as a CLI tool that should work from anywhere. Therefore, it is best installed globally.
|
|
18
|
-
|
|
19
|
-
## Init
|
|
20
|
-
|
|
21
|
-
* You can initialize your Sinth project via your CLI:
|
|
22
|
-
* `sinth init my-sinth-project`
|
|
23
|
-
* `cd my-sinth-project`
|
|
24
|
-
* After that's done, you can start a Dev Server to preview your change:
|
|
25
|
-
* `sinth dev pages/index.sinth`
|
|
26
|
-
|
|
27
|
-
## Documentation
|
|
28
|
-
|
|
29
|
-
You can find the complete documentation, including all notes and tips [here](https://sinth.yannosay.com).
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
page
|
|
35
|
-
|
|
36
|
-
title = "Increment Showcase"
|
|
37
|
-
fav = "./assets/fav.ico"
|
|
38
|
-
|
|
39
|
-
var str userName = "User"
|
|
40
|
-
var int count = 0
|
|
41
12
|
Main {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Input(bind: userName, placeholder: "Type in your username")
|
|
45
|
-
Paragraph() { userName + " has reached Count " + count + "!" }
|
|
13
|
+
Heading(level: 1) { "Count: " + count }
|
|
14
|
+
Button(onClick: count += 1) { "Increment" }
|
|
46
15
|
}
|
|
47
16
|
```
|
|
48
17
|
|
|
49
|
-
##
|
|
18
|
+
## Why Sinth
|
|
50
19
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
- SCSS support
|
|
59
|
-
- Tree-shaken output
|
|
60
|
-
- VS Code extension
|
|
61
|
-
- Live reload dev server
|
|
62
|
-
- Self-contained HTML
|
|
63
|
-
- Reactive Sinth variables affecting CSS
|
|
64
|
-
- Reactivity in functions
|
|
65
|
-
- Exporting custom HTML Tags to use in non-sinth HTML Projects
|
|
20
|
+
- **Easy to read, easy to learn.** Markup, state, logic and styles live together in one file with no boilerplate.
|
|
21
|
+
- **Reactive by default.** Change a variable and exactly the affected parts of the page update.
|
|
22
|
+
- **Built to scale.** File-based routing with dynamic routes (`pages/blog/[slug].sinth` generates one page per post), shared layouts and components, project-wide type checking, code splitting and cached chunks. Thousands of pages build in seconds.
|
|
23
|
+
- **Static first.** Every page is prerendered to HTML. Pages without interactivity ship zero JavaScript; interactive ones load a ~5 kB runtime.
|
|
24
|
+
- **Catches mistakes before the browser does.** Unknown names, missing arguments, wrong types and missing component props are compile errors with "did you mean" hints.
|
|
25
|
+
- **Secure by default.** No `eval`, escaped output, no inline handlers, strict CSP and security headers out of the box.
|
|
26
|
+
- **Batteries included.** Dev server with hot reload that keeps state, scoped CSS, a component library (`sinth:ui`), npm packages, SCSS, JSON imports, Google Fonts, custom elements, sitemaps and one-command Cloudflare deploys.
|
|
66
27
|
|
|
67
|
-
##
|
|
28
|
+
## Get started
|
|
68
29
|
|
|
69
|
-
|
|
30
|
+
```bash
|
|
31
|
+
npx @yannosay/sinth create my-site
|
|
32
|
+
cd my-site
|
|
33
|
+
npm install
|
|
34
|
+
npm run dev
|
|
35
|
+
```
|
|
70
36
|
|
|
71
|
-
|
|
37
|
+
Requires Node.js 18.17 or newer.
|
|
38
|
+
|
|
39
|
+
## A component
|
|
40
|
+
|
|
41
|
+
```sinth
|
|
42
|
+
-- components/TodoList.sinth
|
|
43
|
+
import { Button, Field } from "sinth:ui"
|
|
44
|
+
|
|
45
|
+
component TodoList(str title = "Todos") {
|
|
46
|
+
var str draft = ""
|
|
47
|
+
var obj[] todos = []
|
|
48
|
+
computed num left = todos.filter((t) => not t.done).length
|
|
49
|
+
|
|
50
|
+
function add() {
|
|
51
|
+
if draft.trim() == "" return
|
|
52
|
+
todos.push({ text: draft.trim(), done: false })
|
|
53
|
+
draft = ""
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Section(class: "todos") {
|
|
57
|
+
Heading(level: 2) { title + " (" + left + " left)" }
|
|
58
|
+
Form(onSubmit.prevent: add()) {
|
|
59
|
+
Field(label: "New todo", value: draft)
|
|
60
|
+
Button(type: "submit") { "Add" }
|
|
61
|
+
}
|
|
62
|
+
Ul {
|
|
63
|
+
for todo in todos {
|
|
64
|
+
Li(class: { done: todo.done }) {
|
|
65
|
+
Checkbox(model: todo.done)
|
|
66
|
+
" " + todo.text
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
Li { "Nothing to do." }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
style {
|
|
75
|
+
.done { textDecoration: "line-through"; opacity: 0.6 }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
72
79
|
|
|
73
|
-
##
|
|
80
|
+
## Commands
|
|
74
81
|
|
|
75
|
-
|
|
82
|
+
| Command | |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `sinth create [name]` | Scaffold a project |
|
|
85
|
+
| `sinth dev` | Dev server with hot reload and error overlay |
|
|
86
|
+
| `sinth build` | Production build in `dist/` |
|
|
87
|
+
| `sinth preview` | Serve the build locally |
|
|
88
|
+
| `sinth deploy` | Deploy to Cloudflare Pages |
|
|
89
|
+
| `sinth check` | Type-check without building |
|
|
90
|
+
| `sinth new page/component` | Add files |
|
|
76
91
|
|
|
77
|
-
##
|
|
92
|
+
## Documentation
|
|
78
93
|
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
- `sinth version`
|
|
94
|
+
- **[Full reference (DOCS.md)](./DOCS.md)**: every feature, option and error code
|
|
95
|
+
- [Website](https://sinth.yannosay.com)
|
|
96
|
+
- [Changelog](./CHANGELOG.md)
|
|
97
|
+
- [VS Code extension](https://marketplace.visualstudio.com/items?itemName=YannosayProductions.sinth-vscode)
|
|
84
98
|
|
|
85
|
-
##
|
|
99
|
+
## Community
|
|
86
100
|
|
|
87
|
-
|
|
88
|
-
- Website: [Yannosay Production Website](https://yannosay.com/)
|
|
89
|
-
- Discord: [Join here](https://discord.gg/SUvcrafTQm)
|
|
90
|
-
- VS Code Extension: [Download here](https://marketplace.visualstudio.com/items?itemName=YannosayProductions.sinth-vscode)
|
|
101
|
+
Questions and ideas: [Discord](https://discord.gg/SUvcrafTQm) · Bugs: [GitHub issues](https://github.com/Yannosay/sinth/issues) · Security reports: [SECURITY.md](./SECURITY.md) · Contributing: [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
91
102
|
|
|
92
103
|
## License
|
|
93
104
|
|
|
94
|
-
[AGPL-3.0](
|
|
95
|
-
|
|
96
|
-
**Notice**: All generated output you made with Sinth is entirely your intellectual property and free of any license obligations of Sinth.
|
|
105
|
+
[AGPL-3.0](./LICENSE). Everything you build with Sinth (the generated HTML, CSS and JavaScript) is yours, free of any license obligations.
|
package/bin/sinth.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FlagSpec {
|
|
2
|
+
type: "boolean" | "string" | "number";
|
|
3
|
+
alias?: string;
|
|
4
|
+
description: string;
|
|
5
|
+
optionalValue?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ParsedArgs {
|
|
8
|
+
positionals: string[];
|
|
9
|
+
flags: Record<string, string | number | boolean | undefined>;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseArgs(argv: string[], spec: Record<string, FlagSpec>): ParsedArgs;
|
package/dist/cli/args.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseArgs = parseArgs;
|
|
4
|
+
const diagnostics_1 = require("../compiler/diagnostics");
|
|
5
|
+
function parseArgs(argv, spec) {
|
|
6
|
+
const positionals = [];
|
|
7
|
+
const flags = {};
|
|
8
|
+
const aliases = new Map();
|
|
9
|
+
for (const [name, s] of Object.entries(spec))
|
|
10
|
+
if (s.alias)
|
|
11
|
+
aliases.set(s.alias, name);
|
|
12
|
+
for (let i = 0; i < argv.length; i++) {
|
|
13
|
+
const arg = argv[i];
|
|
14
|
+
if (arg === "--") {
|
|
15
|
+
positionals.push(...argv.slice(i + 1));
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
if (!arg.startsWith("-") || arg === "-") {
|
|
19
|
+
positionals.push(arg);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
let name;
|
|
23
|
+
let inline;
|
|
24
|
+
if (arg.startsWith("--")) {
|
|
25
|
+
const eq = arg.indexOf("=");
|
|
26
|
+
name = eq === -1 ? arg.slice(2) : arg.slice(2, eq);
|
|
27
|
+
inline = eq === -1 ? undefined : arg.slice(eq + 1);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const alias = aliases.get(arg.slice(1));
|
|
31
|
+
if (!alias)
|
|
32
|
+
throw new diagnostics_1.SinthError("E1200", `Unknown option '${arg}'`);
|
|
33
|
+
name = alias;
|
|
34
|
+
}
|
|
35
|
+
let negated = false;
|
|
36
|
+
if (!spec[name] && name.startsWith("no-") && spec[name.slice(3)]?.type === "boolean") {
|
|
37
|
+
name = name.slice(3);
|
|
38
|
+
negated = true;
|
|
39
|
+
}
|
|
40
|
+
const s = spec[name];
|
|
41
|
+
if (!s) {
|
|
42
|
+
const near = (0, diagnostics_1.suggest)(name, Object.keys(spec));
|
|
43
|
+
throw new diagnostics_1.SinthError("E1200", `Unknown option '--${name}'`, undefined, near ? `Did you mean '--${near}'?` : "Run 'sinth help' to see all options");
|
|
44
|
+
}
|
|
45
|
+
if (s.type === "boolean") {
|
|
46
|
+
flags[name] = inline !== undefined ? inline !== "false" : !negated;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
let value = inline;
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
const next = argv[i + 1];
|
|
52
|
+
if (next !== undefined && !next.startsWith("-")) {
|
|
53
|
+
value = next;
|
|
54
|
+
i++;
|
|
55
|
+
}
|
|
56
|
+
else if (s.optionalValue !== undefined) {
|
|
57
|
+
value = s.optionalValue;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw new diagnostics_1.SinthError("E1201", `Option '--${name}' needs a value`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (s.type === "number") {
|
|
64
|
+
const n = Number(value);
|
|
65
|
+
if (!Number.isFinite(n))
|
|
66
|
+
throw new diagnostics_1.SinthError("E1202", `Option '--${name}' expects a number, got '${value}'`);
|
|
67
|
+
flags[name] = n;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
flags[name] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { positionals, flags };
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function main(argv: string[]): Promise<void>;
|