kopular 1.1.4 → 1.1.5
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/GUIDE.md +5 -0
- package/LLM.md +3 -2
- package/README.md +1 -1
- package/package.json +1 -1
package/GUIDE.md
CHANGED
|
@@ -43,6 +43,8 @@ both scripts). `ks check src/app.ks` type-checks without building, if you just w
|
|
|
43
43
|
- `try { } catch (string e) { } finally { }` and `throw "message";` all exist — one `catch`
|
|
44
44
|
per `try`, and its parameter type is your choice (it is *not* checked against what was
|
|
45
45
|
actually thrown).
|
|
46
|
+
- **Comments are `//` only** — there is no `/* ... */` block comment, and a `/*` is a parse
|
|
47
|
+
error (`KS2020`), not an ignored region.
|
|
46
48
|
- **Reserved words**: naming a local or parameter one of these is a parse error, not
|
|
47
49
|
shadowing — `raw`, `state`, `task`, `from`, `as`, `get`, `set`, `in`, `base` and `match`
|
|
48
50
|
are the ones easy to pick by accident. Full list: `using extern raw template styles from
|
|
@@ -57,6 +59,9 @@ both scripts). `ks check src/app.ks` type-checks without building, if you just w
|
|
|
57
59
|
`.Split(sep)`, `.Replace(from, to)`, `.CompareTo(other)` (sort comparator), `+` concatenates.
|
|
58
60
|
Both `"double"` and `'single'` quotes work — use whichever the other isn't, e.g. inside
|
|
59
61
|
a template attribute (`*if="Name != ''"`).
|
|
62
|
+
- Arrays are created with a literal and nothing else: `number[] xs = [];`, `[1, 2, 3]`,
|
|
63
|
+
`[new Todo("a")]`. **There is no `new number[3]` form** — that's a parse error, not an
|
|
64
|
+
empty array.
|
|
60
65
|
- Arrays: `xs.Length`, `.Map()/.Filter()/.ForEach()/.Find()/.FindIndex()/.Includes()/.IndexOf()`,
|
|
61
66
|
`.Sort(cmp)/.Reverse()/.Push(x)` (all three **non-mutating**, return a new array),
|
|
62
67
|
`.Slice(a, b)/.Concat(ys)/.Join(sep)/.Reduce(fn, initial)`.
|
package/LLM.md
CHANGED
|
@@ -171,7 +171,7 @@ extern class Router {
|
|
|
171
171
|
// is in flight — default: `<div class="router-loading">Loading...</div>`.
|
|
172
172
|
// Only declare this if you actually override it (a class extending
|
|
173
173
|
// Router) — see "Lazy routes" below.
|
|
174
|
-
|
|
174
|
+
virtual VElement BuildLoadingPlaceholder();
|
|
175
175
|
void Navigate(string path);
|
|
176
176
|
void Mount(Element parent);
|
|
177
177
|
// One guard for the whole Router, not per-route — see "Router" below.
|
|
@@ -320,6 +320,7 @@ w.Bump(); // re-render + diff + patch
|
|
|
320
320
|
component, applied once the handler returns:
|
|
321
321
|
```ks
|
|
322
322
|
private void Save() {
|
|
323
|
+
Item newItem = new Item(this.Draft); // whatever this handler just built
|
|
323
324
|
this.Draft = ""; // a plain field Render() also reads
|
|
324
325
|
this.Items.Value = this.Items.Value.Push(newItem); // triggers the ONE render, via Subscribe
|
|
325
326
|
}
|
|
@@ -503,7 +504,7 @@ Real URLs via the History API (`pushState`/`popstate`), not hash routing.
|
|
|
503
504
|
|
|
504
505
|
```ks
|
|
505
506
|
class NotFoundPage : Component {
|
|
506
|
-
public override VElement Render() {
|
|
507
|
+
public override VElement Render() { return VElement.Create("h1"); }
|
|
507
508
|
}
|
|
508
509
|
class HomePage : Component {
|
|
509
510
|
private Router Nav;
|
package/README.md
CHANGED
|
@@ -641,7 +641,7 @@ own `header.ks`/`nav.ks` use it exactly this way):
|
|
|
641
641
|
```ks
|
|
642
642
|
VElement header = VElement.Create("header");
|
|
643
643
|
header.RawHtml = SiteHeaderHtml; // a raw string ... from "./header.html"; constant
|
|
644
|
-
header.OnClick = (Event e) => {
|
|
644
|
+
header.OnClick = (Event e) => { }; // one delegated listener over the whole subtree
|
|
645
645
|
```
|
|
646
646
|
|
|
647
647
|
**It's unescaped, real `innerHTML` — never assign it anything reachable from user input.**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kopular",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Kopular: a small component framework for KopScript — components, reactive state, constructor-injected services, routing, real compiled templates, and HTTP, with no DI container",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|