@yannosay/sinth 5.1.1 → 5.2.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.2.1
4
+
5
+ - The E0104 hint now covers projects without a `pages/` folder, where root files are pages.
6
+
7
+ ## 5.2.0
8
+
9
+ - **The `page` keyword is removed.** A file that starts with `page` now fails with E0104 and a hint to delete the line. Every `.sinth` file in `pages/` is a page, and files outside it are modules. `page` can still be used as a variable name.
10
+ - Editors no longer suggest or highlight `page` as a keyword.
11
+
3
12
  ## 5.1.1
4
13
 
5
14
  - Dynamic routes and page detection now work when the project path contains a symlink or junction (macOS temp folders, linked workspaces).
package/DOCS.md CHANGED
@@ -115,7 +115,7 @@ There are two kinds of `.sinth` files.
115
115
 
116
116
  **Modules** (files outside `pages/`, usually in `components/`) contain components, functions and shared variables that pages import.
117
117
 
118
- > Sinth 4 required pages to start with the keyword `page`. That keyword is no longer needed. It is still accepted, and a file that starts with it is a page wherever it lives.
118
+ > Sinth 4 required pages to start with the keyword `page`. That keyword has been removed: a file that still starts with it fails with E0104. Delete the line; where a file lives decides whether it is a page.
119
119
 
120
120
  Order inside a page is flexible, but the usual layout is:
121
121
 
@@ -1268,6 +1268,7 @@ Errors are `SinthError` instances with `code`, `loc` and `diagnostic`; `formatDi
1268
1268
  | E0100 | Syntax error |
1269
1269
  | E0102 | Reserved word used as a name |
1270
1270
  | E0103 | Invalid assignment target |
1271
+ | E0104 | The removed `page` keyword (delete the line) |
1271
1272
  | E0201 | Unknown type |
1272
1273
  | E0202 | Name declared twice in the same scope |
1273
1274
  | E0210 | `persist` outside page or component state |
@@ -1317,7 +1318,7 @@ Most Sinth 4 code compiles unchanged. Things to check:
1317
1318
 
1318
1319
  | Sinth 4 | Sinth 5 |
1319
1320
  |---|---|
1320
- | `page` at the top of every page | not needed: every file in `pages/` is a page (`page` is still accepted) |
1321
+ | `page` at the top of every page | removed: delete the line (E0104). Every file in `pages/` is a page; move pages that lived elsewhere into `pages/` |
1321
1322
  | `dist/pages/index.html` | `dist/index.html`: pages are now relative to `pages/` |
1322
1323
  | `var int x` | `var num x` (`int` still works with a warning) |
1323
1324
  | `==` was loose | `==` is strict: `1 == "1"` is a compile error |
@@ -138,9 +138,7 @@ style {
138
138
  }
139
139
  }
140
140
  `;
141
- files["pages/about.sinth"] = `page
142
-
143
- import { Layout } from "../components/Layout.sinth"
141
+ files["pages/about.sinth"] = `import { Layout } from "../components/Layout.sinth"
144
142
 
145
143
  title = "About | ${name}"
146
144
  descr = "About this site."
@@ -150,9 +148,7 @@ Layout(current: "/about") {
150
148
  Paragraph { "This page is static, so Sinth ships it without any JavaScript." }
151
149
  }
152
150
  `;
153
- files["pages/404.sinth"] = `page
154
-
155
- import { Layout } from "../components/Layout.sinth"
151
+ files["pages/404.sinth"] = `import { Layout } from "../components/Layout.sinth"
156
152
  import { Button } from "sinth:ui"
157
153
 
158
154
  title = "Page not found"
@@ -182,7 +182,7 @@ class ModuleCompiler {
182
182
  }
183
183
  else if (file.body.length) {
184
184
  const first = file.body[0];
185
- this.diagnostics.warn("W0101", "Markup outside a component in a non-page file is ignored", first.loc, "Add 'page' at the top of the file, or wrap the markup in a component");
185
+ this.diagnostics.warn("W0101", "Markup outside a component in a non-page file is ignored", first.loc, "Move the file into pages/ to make it a page, or wrap the markup in a component");
186
186
  }
187
187
  for (const c of file.components) {
188
188
  if (!c.customTag)
@@ -111,9 +111,8 @@ class Parser {
111
111
  path: this.file, source: this.source, isPage: false, imports: [], meta: [], externs: [], vars: [], functions: [],
112
112
  components: [], styles: [], scripts: [], lifecycle: [], watchers: [], body: [],
113
113
  };
114
- if (this.isIdent("page")) {
115
- this.next();
116
- file.isPage = true;
114
+ if (this.isIdent("page") && (this.peek(1).kind === "eof" || this.peek(1).newlineBefore)) {
115
+ throw new diagnostics_1.SinthError("E0104", "The 'page' keyword was removed", this.tok.loc, "Delete this line. Files in pages/ (or in the project root when there is no pages/ folder) are pages automatically");
117
116
  }
118
117
  const declared = new Set();
119
118
  while (this.tok.kind !== "eof") {
@@ -47,8 +47,7 @@ export declare class Project {
47
47
  getFile(file: string): SinthFile;
48
48
  /**
49
49
  * A file is a page when it lives in the pages folder (or, without one, in the project root),
50
- * is not hidden behind a leading underscore, and is not a pure component module. The Sinth 4
51
- * `page` keyword still forces a page anywhere.
50
+ * is not hidden behind a leading underscore, and is not a pure component module.
52
51
  */
53
52
  private isPageFile;
54
53
  scss(): ScssCompiler | undefined;
@@ -92,12 +92,9 @@ class Project {
92
92
  }
93
93
  /**
94
94
  * A file is a page when it lives in the pages folder (or, without one, in the project root),
95
- * is not hidden behind a leading underscore, and is not a pure component module. The Sinth 4
96
- * `page` keyword still forces a page anywhere.
95
+ * is not hidden behind a leading underscore, and is not a pure component module.
97
96
  */
98
97
  isPageFile(abs, parsed) {
99
- if (parsed.isPage)
100
- return true;
101
98
  const pagesDir = this.config.pagesDir;
102
99
  const hasPagesDir = fs.existsSync(pagesDir);
103
100
  const base = hasPagesDir ? pagesDir : this.root;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "5.1.1",
3
+ "version": "5.2.1",
4
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",