kopular 0.15.0 → 0.15.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.
Files changed (3) hide show
  1. package/LLM.md +61 -1
  2. package/README.md +9 -0
  3. package/package.json +1 -1
package/LLM.md CHANGED
@@ -22,7 +22,67 @@ there is no `kopular/template` entry point to import.
22
22
  ## Consuming Kopular from your own KopScript project
23
23
 
24
24
  `using` only resolves same-project relative paths — reaching into an npm package (Kopular
25
- included) always goes through `extern`, re-describing exactly the members you use:
25
+ included) always goes through `extern`, re-describing exactly the members you use.
26
+
27
+ **`Element`/`Document`/`Event` are NOT part of Kopular's own exports** — they're plain
28
+ ambient browser globals (`extern class Element { ... };`, no `from` clause), genuinely
29
+ present at runtime with no import needed, but Kopular has no re-exportable copy of them
30
+ to reach for: `kopular/dom` is Kopular's own *internal* ambient binding, itself made of
31
+ erased `extern` declarations with nothing real behind them at runtime, so `extern class
32
+ Element { ... } from "kopular/dom";` doesn't work — there's no `Element` symbol actually
33
+ living in that module to bind to. Every consuming project re-declares its own
34
+ Element/Document/Event, same as this one does. **Copy the block below rather than
35
+ hand-rolling a smaller one from scratch and adding members as compile errors demand
36
+ them** — a real, complete first-attempt implementation of a Kopular app hit the exact
37
+ same missing property (`Element.value`) twice from two independently-trimmed subsets,
38
+ because the compile error only ever names the one member actually touched, never warns
39
+ that a *sibling* feature (a template's `placeholder="..."` attribute, a `[(value)]`
40
+ binding's generated `e.target.value` read) will need one you didn't happen to write by
41
+ hand:
42
+
43
+ ```ks
44
+ extern class Event {
45
+ Element target { get; }
46
+ void preventDefault();
47
+ };
48
+
49
+ extern class Element {
50
+ string textContent { get; set; }
51
+ string innerHTML { get; set; }
52
+ string id { get; set; }
53
+ string className { get; set; }
54
+ string href { get; set; }
55
+ string src { get; set; }
56
+ string alt { get; set; }
57
+ // Every `[(value)]="Field"` template binding and any handler reading
58
+ // `e.target.value` needs this — the single most commonly missing member
59
+ // when a hand-trimmed subset breaks.
60
+ string value { get; set; }
61
+ string placeholder { get; set; }
62
+ void appendChild(Element child);
63
+ void replaceChild(Element newChild, Element oldChild);
64
+ void insertBefore(Element newChild, Element? referenceChild);
65
+ void removeChild(Element child);
66
+ void setAttribute(string name, string value);
67
+ void addEventListener(string eventType, (Event) => void handler);
68
+ void removeEventListener(string eventType, (Event) => void handler);
69
+ Element querySelector(string selector);
70
+ Element? closest(string selector);
71
+ };
72
+
73
+ extern class Document {
74
+ Element createElement(string tagName);
75
+ Element getElementById(string id);
76
+ Element body { get; }
77
+ };
78
+
79
+ extern Document document;
80
+ ```
81
+
82
+ Trim what you genuinely never use (this is still "describe exactly the members you
83
+ use," not "always paste everything") — but trim it *after* writing the app, not before,
84
+ so the trim is informed by what actually compiled, not a guess at what a template will
85
+ eventually need.
26
86
 
27
87
  ```ks
28
88
  extern class VElement {
package/README.md CHANGED
@@ -549,6 +549,15 @@ Marking `Render()` `virtual` in the `extern` declaration is what lets a real sub
549
549
  for a full working example (components, a service, and routing, all consuming Kopular
550
550
  this way).
551
551
 
552
+ The snippet above is illustrative, not exhaustive — real code needs a fuller
553
+ `VElement`/`Component`/`Router`, and `Element` itself (used above as `Mount`'s
554
+ parameter type but never shown declared) is a plain ambient browser global your own
555
+ project declares, not something Kopular exports — `LLM.md`'s "Consuming Kopular from
556
+ your own KopScript project" section has the complete, copy-ready block for all of
557
+ these, `Element`/`Document`/`Event` included. `npx kp new` (above) generates this
558
+ boilerplate for a fresh project either way — reach for `LLM.md`'s block when adding to
559
+ an existing one instead.
560
+
552
561
  `extern class` can carry its own `<T>` (kopscript >= 0.5.0), so a generic export like
553
562
  `FormField<T>` describes the same way a real generic class does — see `LLM.md`'s
554
563
  `FormField<T>`/`Validators` section for the full example.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kopular",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
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",