@silkui/core 0.1.11 → 0.1.13

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/README.md CHANGED
@@ -85,8 +85,23 @@ elements make it live from its first draw. The tree draws
85
85
  `g`, `path`, `rect`, `circle`, `ellipse`, `line`, `polyline`, `polygon`, `clipPath` and linear
86
86
  and radial gradients this way; anything else (text, masks, filters, `use`...) puts the `Svg`
87
87
  back to drawing its markup whole, which is right but slower. Browser libraries that build SVG
88
- with `document`, such as lottie-web, run after `import "@silkui/core/globals"`, which adds a
89
- minimal `window` and `document` where the realm has none.
88
+ with `document`, such as lottie-web, run after `import "@silkui/core/globals"`.
89
+
90
+ ### Browser globals
91
+
92
+ `import "@silkui/core/globals"`, first in the app, gives code written for a browser page the
93
+ globals it expects. `document` has an `<html>` element as the tree's root and a `<body>` that
94
+ fills it: render into `document.body`. Events that reach the root go on to `document` and
95
+ `window` in both phases, so `document.addEventListener("keydown", ...)` works, and
96
+ `document.documentElement.classList` and `style.setProperty("--name", value)` style `:root`.
97
+ It also adds `document.activeElement`, `getElementById` and the query methods, `innerWidth`
98
+ and `innerHeight` with `resize` events, `HTMLElement`, `Element`, `Node` and `Text` for
99
+ `instanceof` (their prototypes are the nodes'), `MutationObserver`, `location` and `history`
100
+ (entries in memory with `popstate` and `hashchange`, starting at `http://localhost/` or
101
+ `globalThis.__silkLocation`), `localStorage` (a JSON file under `~/.silkui/storage/<app>` on
102
+ the full runtime, or `$SILKUI_STORAGE_DIR`), `sessionStorage`, `indexedDB` (in memory, saved
103
+ next to local storage on the full runtime), `Worker` on the full runtime (`@silkui/vite` puts a `new Worker(new URL("x.js", import.meta.url))` worker into the bundle), and `navigator`'s
104
+ platform and language. Globals the realm already has stay as they are.
90
105
 
91
106
  A node has `append`, `appendChild`, `insertBefore`, `removeChild`, `remove`, `contains`,
92
107
  `parentNode`, `childNodes`, `firstChild`, `lastChild` and the sibling getters, as in the DOM.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silkui/core",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "The node and event API of a Silk UI tree for JavaScript applications that run on the embedded SilkJS engine",
5
5
  "repository": {
6
6
  "type": "git",
package/src/globals.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- // Installs a minimal `window`, `navigator.userAgent` and `document` for browser libraries that
2
- // build SVG with the DOM. It exports nothing.
1
+ // Installs the browser globals a DOM app expects over the Silk UI tree: `document` (an `<html>`
2
+ // root with a `<body>`), `window` events and size, element classes for `instanceof`,
3
+ // `location`, `history`, `localStorage`, `sessionStorage`, `indexedDB`, `Worker` (full
4
+ // runtime), `MutationObserver` and the observers. It exports nothing.
3
5
  export {};