@silkui/core 0.1.12 → 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 +17 -2
- package/package.json +1 -1
- package/src/globals.d.ts +4 -2
- package/src/globals.js +607 -21
- package/src/index.d.ts +58 -3
- package/src/index.js +670 -22
- package/src/indexeddb.js +975 -0
- package/src/location.js +198 -0
- package/src/storage.js +146 -0
- package/src/worker.js +136 -0
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"
|
|
89
|
-
|
|
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
package/src/globals.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
// Installs a
|
|
2
|
-
//
|
|
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 {};
|