@vanelsas/baredom 4.11.0 → 4.13.0
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 +68 -0
- package/README.md +22 -12
- package/dist/baremirror-alpha.d.ts +200 -0
- package/dist/baremirror-alpha.js +42 -38
- package/dist/base.js +562 -565
- package/dist/integrity.json +112 -112
- package/dist/x-alert.js +17 -17
- package/dist/x-avatar-group.js +10 -10
- package/dist/x-avatar.js +13 -13
- package/dist/x-badge.js +9 -9
- package/dist/x-bento-grid.js +6 -6
- package/dist/x-bento-item.js +4 -4
- package/dist/x-breadcrumbs.js +17 -17
- package/dist/x-button.js +1 -1
- package/dist/x-calendar.js +39 -39
- package/dist/x-cancel-dialogue.js +16 -16
- package/dist/x-card.js +7 -7
- package/dist/x-carousel.js +34 -34
- package/dist/x-chart.js +47 -47
- package/dist/x-checkbox.js +1 -1
- package/dist/x-chip.js +1 -1
- package/dist/x-code.js +30 -30
- package/dist/x-collapse.js +8 -8
- package/dist/x-color-picker.js +43 -43
- package/dist/x-combobox.js +32 -32
- package/dist/x-command-palette.js +28 -28
- package/dist/x-confetti.js +24 -24
- package/dist/x-container.js +6 -6
- package/dist/x-context-menu.js +19 -19
- package/dist/x-copy.js +1 -1
- package/dist/x-currency-field.js +22 -22
- package/dist/x-date-picker.js +43 -43
- package/dist/x-divider.js +7 -7
- package/dist/x-drag-panel.js +32 -32
- package/dist/x-drawer.js +12 -12
- package/dist/x-drop-zone.js +11 -11
- package/dist/x-dropdown.js +11 -11
- package/dist/x-fieldset.js +6 -6
- package/dist/x-file-download.js +14 -14
- package/dist/x-file-upload.js +26 -26
- package/dist/x-floating-panel.js +18 -18
- package/dist/x-form-field.js +17 -17
- package/dist/x-form.js +10 -10
- package/dist/x-gaussian-blur.js +13 -13
- package/dist/x-grid.js +8 -8
- package/dist/x-i18n-provider.js +7 -7
- package/dist/x-i18n.js +4 -4
- package/dist/x-icon.js +7 -7
- package/dist/x-image.js +18 -18
- package/dist/x-kbd.js +13 -13
- package/dist/x-kinetic-canvas.js +23 -23
- package/dist/x-kinetic-font.js +26 -26
- package/dist/x-kinetic-typography.js +34 -34
- package/dist/x-liquid-dock.js +29 -29
- package/dist/x-liquid-fill.js +34 -34
- package/dist/x-liquid-glass.js +26 -26
- package/dist/x-menu-item.js +9 -9
- package/dist/x-menu.js +10 -10
- package/dist/x-metaball-cursor.js +24 -24
- package/dist/x-modal.js +13 -13
- package/dist/x-morph-stack.js +37 -37
- package/dist/x-multi-combobox.js +43 -43
- package/dist/x-navbar.js +14 -14
- package/dist/x-neural-glow.js +27 -28
- package/dist/x-notification-center.js +9 -9
- package/dist/x-organic-divider.js +16 -16
- package/dist/x-organic-progress.js +33 -33
- package/dist/x-organic-shape.js +12 -12
- package/dist/x-otp-input.js +22 -22
- package/dist/x-pagination.js +18 -18
- package/dist/x-particle-button.js +50 -50
- package/dist/x-popover.js +24 -24
- package/dist/x-progress-circle.js +7 -7
- package/dist/x-progress.js +4 -4
- package/dist/x-proximity-list.js +20 -20
- package/dist/x-radio.js +13 -13
- package/dist/x-range-slider.js +29 -29
- package/dist/x-rating.js +22 -22
- package/dist/x-ripple-effect.js +9 -9
- package/dist/x-scroll-parallax.js +17 -17
- package/dist/x-scroll-stack.js +17 -17
- package/dist/x-scroll-story.js +33 -33
- package/dist/x-scroll-timeline.js +49 -49
- package/dist/x-scroll.js +36 -36
- package/dist/x-search-field.js +1 -1
- package/dist/x-select.js +1 -1
- package/dist/x-sidebar.js +16 -16
- package/dist/x-skeleton-group.js +14 -14
- package/dist/x-skeleton.js +1 -1
- package/dist/x-slider.js +16 -16
- package/dist/x-soft-body.js +16 -16
- package/dist/x-spacer.js +3 -3
- package/dist/x-spinner.js +4 -4
- package/dist/x-splash.js +13 -13
- package/dist/x-split-pane.js +14 -14
- package/dist/x-spotlight-card.js +12 -12
- package/dist/x-stat.js +10 -10
- package/dist/x-stepper.js +14 -14
- package/dist/x-switch.js +12 -12
- package/dist/x-tab.js +6 -6
- package/dist/x-table-cell.js +20 -20
- package/dist/x-table-row.js +8 -8
- package/dist/x-table.js +20 -20
- package/dist/x-tabs.js +12 -12
- package/dist/x-text-area.js +20 -20
- package/dist/x-theme.js +26 -26
- package/dist/x-timeline-item.js +18 -18
- package/dist/x-timeline.js +9 -9
- package/dist/x-toast.js +20 -20
- package/dist/x-toaster.js +6 -6
- package/dist/x-tooltip.js +14 -14
- package/dist/x-trace-history.js +115 -114
- package/dist/x-typography.js +6 -6
- package/dist/x-welcome-tour.js +62 -62
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,74 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to BareDOM will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [4.13.0] - 2026-10-22
|
|
6
|
+
|
|
7
|
+
BareDOM 4.13 is the public alpha of BareMirror. BareMirror gets a README and a first look in
|
|
8
|
+
JavaScript and in ClojureScript, and its small updates cost less. The adapters are not released
|
|
9
|
+
with it.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **A README for BareMirror.** `baremirror/README.md` says what BareMirror is, how to install it
|
|
14
|
+
and what alpha means. The README of BareDOM links to it.
|
|
15
|
+
- **A first look at BareMirror.** A list of tasks in plain HTML, in JavaScript in
|
|
16
|
+
`bare-html/first-look.html` and in ClojureScript in `bare-html/first-look-cljs.html`. CI
|
|
17
|
+
renders both, and the demo site publishes them.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **The guide to BareMirror uses the names of JavaScript.** `docs/baremirror.md` says
|
|
22
|
+
`writeItem`, `writeParts` and `nodeMaker` in the text that both languages share. The
|
|
23
|
+
ClojureScript names are in its ClojureScript section and in the table of functions.
|
|
24
|
+
- **Small updates in BareMirror are cheaper.** The `nodes` of a reading from `readPlaces` are
|
|
25
|
+
made when they are first read, so a render that plans and performs never makes them.
|
|
26
|
+
`writeItem` compares the item before it checks the split template, so an item it has written
|
|
27
|
+
already costs less than half what it did.
|
|
28
|
+
|
|
29
|
+
## [4.12.0] - 2026-10-21
|
|
30
|
+
|
|
31
|
+
BareDOM 4.12 can be imported on a server, so a page that uses its components renders with a
|
|
32
|
+
server renderer such as Next.js. BareMirror's `listen` returns a function that stops it, a
|
|
33
|
+
template can make SVG, and the module ships TypeScript types. The adapters are not released
|
|
34
|
+
with it: they work with `@vanelsas/baredom` 4.0.0 or later, and a page that uses them renders
|
|
35
|
+
on a server with 4.12.0 or later.
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- **`listen` in BareMirror returns a function that removes its listeners.** `events/listen!`
|
|
40
|
+
returns the same function.
|
|
41
|
+
- **SVG in a BareMirror template.** An `svg` and the elements below it are made in the SVG
|
|
42
|
+
namespace, and the children of a `foreignObject` are HTML again. An element with an `xmlns`
|
|
43
|
+
attribute is in that namespace, so a template for a `circle` can make rows for an `svg` on
|
|
44
|
+
the page. `splitTemplate` refuses an `xmlns` hole.
|
|
45
|
+
- **Types for BareMirror.** `@vanelsas/baredom/baremirror-alpha` ships `baremirror-alpha.d.ts`.
|
|
46
|
+
The item of a split template follows from its holes, so `writeItem` refuses an item of
|
|
47
|
+
another type and a copy of a split template, and `makeNode` refuses a template with holes.
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- **`x-particle-button` reads a translucent colour the same each time, and `x-neural-glow` reads
|
|
52
|
+
every colour syntax.** `x-particle-button` painted a colour over the one it read before, so
|
|
53
|
+
`rgba(255, 0, 0, 0.5)` took on the colour read before it. `x-neural-glow` drew a colour in
|
|
54
|
+
`oklch`, `lab`, `color()` or `color-mix` as black. Both now read a cleared pixel.
|
|
55
|
+
- **BareDOM loads on a server.** A component module and its `init()` do nothing where there is
|
|
56
|
+
no DOM, so a page that uses the adapters renders on a server, as in a Next.js build.
|
|
57
|
+
`x-neural-glow`, `x-particle-button` and `x-trace-history` make their canvas or media query
|
|
58
|
+
on first use. CI loads each module in Node.
|
|
59
|
+
- **`nodeMaker` and `defineElement` in BareMirror can be called where there is no DOM.**
|
|
60
|
+
`nodeMaker` checks its template at once and makes its first node on its first call, and
|
|
61
|
+
`defineElement` defines nothing where there is no `customElements`. A module that calls them
|
|
62
|
+
when it loads can be imported on a server.
|
|
63
|
+
- **`listen` in BareMirror hears an event that does not bubble.** `focus`, `blur`,
|
|
64
|
+
`pointerenter`, `scroll` and a custom event with no `bubbles` reached no listener. They now
|
|
65
|
+
reach `listen` on their way down. An event that bubbles is handled as before.
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
|
|
69
|
+
- **The README states the bundle size and the runtime as they are.** `base.js` is about 72 KB
|
|
70
|
+
gzipped and holds the ClojureScript core and the shared components, and BareDOM is no longer
|
|
71
|
+
called zero runtime. The npm description says no dependencies instead.
|
|
72
|
+
|
|
5
73
|
## [4.11.0] - 2026-10-20
|
|
6
74
|
|
|
7
75
|
BareDOM 4.11 lets a BareMirror template write the properties of a component, and a component
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</picture>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
**Native web components.
|
|
11
|
+
**Native web components. No framework runtime. No dependencies.**
|
|
12
12
|
|
|
13
13
|
[](https://www.npmjs.com/package/@vanelsas/baredom)
|
|
14
14
|
[](./LICENSE)
|
|
@@ -16,10 +16,16 @@
|
|
|
16
16
|
[](https://www.typescriptlang.org/)
|
|
17
17
|
[](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements)
|
|
18
18
|
|
|
19
|
+
Use BareDOM and BareMirror from JavaScript, TypeScript or ClojureScript. They ship as plain ES
|
|
20
|
+
modules with type declarations, so JavaScript never needs ClojureScript. In ClojureScript you
|
|
21
|
+
require their namespaces directly.
|
|
22
|
+
|
|
19
23
|
---
|
|
20
24
|
|
|
21
25
|
**Part of a set.** [BareDOM](https://github.com/avanelsas/baredom) is a comprehensive web component
|
|
22
|
-
library. [
|
|
26
|
+
library. [BareMirror](https://github.com/avanelsas/baredom/blob/main/baremirror/README.md) ships
|
|
27
|
+
inside it as an alpha, and brings a page to the state your application holds in the browser.
|
|
28
|
+
[BareBuild](https://github.com/avanelsas/barebuild) is a small runtime that drives web
|
|
23
29
|
components from server state alone. [BareReplay](https://github.com/avanelsas/barereplay) is a
|
|
24
30
|
powerful time-travel replay debugger for BareBuild-based apps.
|
|
25
31
|
[BareProbe](https://github.com/avanelsas/bareprobe) reads the same log from a REPL.
|
|
@@ -38,8 +44,6 @@ DOM = f(attributes, properties)
|
|
|
38
44
|
|
|
39
45
|
Components are **stateless**. Every visual state is derived directly from attributes and properties at render time. There are no hidden reactive systems, no internal signals, no component lifecycles to manage. Set an attribute, the DOM updates. Remove it, the DOM updates back.
|
|
40
46
|
|
|
41
|
-
BareDOM is authored in ClojureScript and compiled to optimised, minified ES modules using Google Closure's advanced compilation pass.
|
|
42
|
-
|
|
43
47
|
BareDOM has been created using Claude Code. The CLAUDE.md file is added to the repository for your convenience.
|
|
44
48
|
|
|
45
49
|
All components can be explored in the [live demo](https://avanelsas.github.io/baredom/).
|
|
@@ -52,7 +56,7 @@ All components can be explored in the [live demo](https://avanelsas.github.io/ba
|
|
|
52
56
|
|
|
53
57
|
**Stateless.** Every render is a pure function of attributes and properties — no hidden state, no signals, no virtual DOM. Inspect attributes in DevTools and you see the truth. (And when you need deeper traces, BareDOM ships a time-travel debugger — see below.)
|
|
54
58
|
|
|
55
|
-
**
|
|
59
|
+
**No framework, no dependencies.** Each component is an ES module compiled with Google Closure Advanced. A page loads one shared `base.js`, with the ClojureScript core and what several components share, plus a small module for each component it uses. No framework, no virtual DOM, nothing to install beside BareDOM.
|
|
56
60
|
|
|
57
61
|
**Predictable theming.** Every visual detail is exposed as a `--x-<component>-<property>` CSS custom property. Set it on the component, or wrap the page in [`<x-theme>`](./docs/x-theme.md) for coordinated palettes with built-in presets. Light/dark mode adapts automatically via `prefers-color-scheme`.
|
|
58
62
|
|
|
@@ -107,6 +111,8 @@ BareDOM components are native HTML elements — they work natively in any framew
|
|
|
107
111
|
|
|
108
112
|
All adapters are auto-generated from the same Custom Elements Manifest, so adding a new BareDOM component updates every adapter in lockstep.
|
|
109
113
|
|
|
114
|
+
**Server rendering.** BareDOM can be imported on a server. A component module and its `init()` do nothing where there is no DOM, so a server renderer, as in a Next.js build, writes each component as its tag, attributes and children. The browser makes it a component when the page loads. The server does not render a component's shadow tree: to send a page with it, [prerender](./docs/PRERENDER.md) the page.
|
|
115
|
+
|
|
110
116
|
---
|
|
111
117
|
|
|
112
118
|
## Components
|
|
@@ -154,7 +160,7 @@ Register your own preset, override individual tokens via CSS, or nest themes for
|
|
|
154
160
|
|
|
155
161
|
## BareMirror (alpha)
|
|
156
162
|
|
|
157
|
-
A small set of functions for an application on top of the components: they place keyed nodes, write values into the parts of a template and turn events into messages, with no comparing of old and new in your code. It ships inside this package as an alpha, for JavaScript and ClojureScript.
|
|
163
|
+
A small set of functions for an application on top of the components: they place keyed nodes, write values into the parts of a template and turn events into messages, with no comparing of old and new in your code. It ships inside this package as an alpha, for JavaScript and ClojureScript. Start with the [BareMirror README](https://github.com/avanelsas/baredom/blob/main/baremirror/README.md), and see [`docs/baremirror.md`](./docs/baremirror.md) for the guide. The [demo](https://avanelsas.github.io/baredom/bare-html/mirror.html) renders one task list three ways, side by side.
|
|
158
164
|
|
|
159
165
|
---
|
|
160
166
|
|
|
@@ -175,18 +181,22 @@ Try the [live editor](https://avanelsas.github.io/bareforge/) or see the [reposi
|
|
|
175
181
|
|
|
176
182
|
## Bundle Size
|
|
177
183
|
|
|
178
|
-
BareDOM
|
|
184
|
+
BareDOM is written in ClojureScript and compiled to ES modules with the advanced compilation of
|
|
185
|
+
Google Closure. The runtime in `base.js` is the core library of ClojureScript. Sizes below are
|
|
186
|
+
gzipped:
|
|
179
187
|
|
|
180
188
|
| Module | Gzipped |
|
|
181
189
|
|--------|---------|
|
|
182
|
-
| `base.js` (shared runtime) | ~
|
|
190
|
+
| `base.js` (shared runtime and shared components) | ~72 KB |
|
|
183
191
|
| Median component | ~3 KB |
|
|
184
|
-
|
|
|
185
|
-
| Largest (`x-chart`) | ~9 KB |
|
|
192
|
+
| Largest (`x-particle-button`) | ~11 KB |
|
|
186
193
|
|
|
187
|
-
Each
|
|
194
|
+
Each page loads `base.js` once, plus a module per component. `base.js` holds what several
|
|
195
|
+
modules share: the runtime, and the components that others are built from, such as
|
|
196
|
+
`x-button`, `x-checkbox`, `x-select` and `x-search-field`. Those add almost nothing on their
|
|
197
|
+
own. A page using 5–10 other components weighs about **85–105 KB** gzipped.
|
|
188
198
|
|
|
189
|
-
> **ESM only.** BareDOM ships ES modules exclusively — there is no CommonJS or UMD build. This works natively in all modern browsers and with any bundler that supports ESM (webpack 5+, Vite, esbuild, Rollup, Parcel). TypeScript declarations (`.d.ts`) are included for every component.
|
|
199
|
+
> **ESM only.** BareDOM ships ES modules exclusively — there is no CommonJS or UMD build. This works natively in all modern browsers and with any bundler that supports ESM (webpack 5+, Vite, esbuild, Rollup, Parcel). TypeScript declarations (`.d.ts`) are included for every component. For a server, see [Server rendering](#framework-adapters).
|
|
190
200
|
|
|
191
201
|
---
|
|
192
202
|
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// baremirror-alpha.d.ts — the types of @vanelsas/baredom/baremirror-alpha. Written by hand.
|
|
2
|
+
// generate_types.bb copies this file into dist. test/types/baremirror.ts checks it.
|
|
3
|
+
|
|
4
|
+
import type { ForeignWrite } from "./foreign-writes";
|
|
5
|
+
|
|
6
|
+
// ── Templates ───────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
/** What an attribute takes: text, a number or a boolean. `false`, `null` and `undefined` remove it. */
|
|
9
|
+
export type AttrValue = string | number | boolean | null | undefined;
|
|
10
|
+
|
|
11
|
+
/** A function of an item. It says where a value goes. */
|
|
12
|
+
export type Hole<Item> = (item: Item) => unknown;
|
|
13
|
+
|
|
14
|
+
/** A hole of an attribute. It gives what an attribute takes. */
|
|
15
|
+
export type AttrHole<Item> = (item: Item) => AttrValue;
|
|
16
|
+
|
|
17
|
+
/** Holes by name. */
|
|
18
|
+
export type Holes<Item> = Readonly<Record<string, Hole<Item>>>;
|
|
19
|
+
|
|
20
|
+
/** Attribute holes by name. */
|
|
21
|
+
export type AttrHoles<Item> = Readonly<Record<string, AttrHole<Item>>>;
|
|
22
|
+
|
|
23
|
+
/** A meaning, or a meaning and a function that gives the argument of the message. */
|
|
24
|
+
export type Meaning = string | readonly [meaning: string, argOf: (origin: Origin, e: Event) => unknown];
|
|
25
|
+
|
|
26
|
+
/** The attributes of an element of a template. */
|
|
27
|
+
export interface Attrs<Item> {
|
|
28
|
+
/** The namespace of the element and of the elements below it. Never a hole. */
|
|
29
|
+
xmlns?: string;
|
|
30
|
+
/** An event type to its meaning. */
|
|
31
|
+
on?: Readonly<Record<string, Meaning>>;
|
|
32
|
+
/** A property name to its hole. */
|
|
33
|
+
props?: Holes<Item>;
|
|
34
|
+
[attr: string]: AttrValue | AttrHole<Item> | Readonly<Record<string, unknown>>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A tag, optional attributes, and children: templates, text, numbers, or one hole as the only child. */
|
|
38
|
+
export type Template<Item> =
|
|
39
|
+
readonly [tag: string, ...rest: (Attrs<Item> | Template<Item> | string | number | Hole<Item>)[]];
|
|
40
|
+
|
|
41
|
+
/** The attributes of a fixed template: no hole, no `on` and no `props`. */
|
|
42
|
+
export interface FixedAttrs {
|
|
43
|
+
on?: never;
|
|
44
|
+
props?: never;
|
|
45
|
+
[attr: string]: AttrValue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A template with no hole and no `on` or `props` entry. */
|
|
49
|
+
export type FixedTemplate = readonly [tag: string, ...rest: (FixedAttrs | FixedTemplate | string | number)[]];
|
|
50
|
+
|
|
51
|
+
// ── Parts ───────────────────────────────────────────────────────────────────
|
|
52
|
+
|
|
53
|
+
/** The write of one part. */
|
|
54
|
+
export interface Write {
|
|
55
|
+
text?: unknown;
|
|
56
|
+
attrs?: Readonly<Record<string, AttrValue>>;
|
|
57
|
+
props?: Readonly<Record<string, unknown>>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Writes by part name. */
|
|
61
|
+
export type Writes = Readonly<Record<string, Write>>;
|
|
62
|
+
|
|
63
|
+
/** Nodes by part name. */
|
|
64
|
+
export type Parts = Readonly<Record<string, Element>>;
|
|
65
|
+
|
|
66
|
+
/** The hole entry of one part. */
|
|
67
|
+
export interface HoleEntry<Item> {
|
|
68
|
+
readonly part: string;
|
|
69
|
+
readonly attrs?: AttrHoles<Item>;
|
|
70
|
+
readonly text?: Hole<Item>;
|
|
71
|
+
readonly props?: Holes<Item>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** An event type and a part name, with a meaning. */
|
|
75
|
+
export type EventEntry = readonly [readonly [eventType: string, part: string], Meaning];
|
|
76
|
+
|
|
77
|
+
/** What `splitTemplate` returns. Frozen. A copy of it is not a split template. */
|
|
78
|
+
export declare class SplitTemplate<Item> {
|
|
79
|
+
private constructor();
|
|
80
|
+
/** Ties the split template to the type of its item. */
|
|
81
|
+
private readonly item: Item;
|
|
82
|
+
readonly fixed: FixedTemplate;
|
|
83
|
+
readonly holes: readonly HoleEntry<Item>[];
|
|
84
|
+
readonly events: readonly EventEntry[];
|
|
85
|
+
/** The writes of `item`, by part name. */
|
|
86
|
+
writes(item: Item): Writes;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** A hole of a split template that a component may also write. */
|
|
90
|
+
export interface SharedHole {
|
|
91
|
+
readonly part: string;
|
|
92
|
+
readonly tag: string;
|
|
93
|
+
readonly attr: string;
|
|
94
|
+
readonly writer: string;
|
|
95
|
+
readonly target: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function splitTemplate<Item>(name: string, template: Template<Item>): SplitTemplate<Item>;
|
|
99
|
+
export function sharedHoles<Item>(
|
|
100
|
+
split: SplitTemplate<Item>,
|
|
101
|
+
foreignWrites: Readonly<Record<string, readonly ForeignWrite[]>>,
|
|
102
|
+
): SharedHole[];
|
|
103
|
+
export function makeNode(fixed: FixedTemplate): Element;
|
|
104
|
+
export function nodeMaker(fixed: FixedTemplate): (...ignored: unknown[]) => Element;
|
|
105
|
+
export function readParts(node: Element): Parts;
|
|
106
|
+
export function writeParts(parts: Parts, writes: Writes): void;
|
|
107
|
+
export function writeItem<Item>(node: Element, split: SplitTemplate<Item>, item: Item): void;
|
|
108
|
+
export function setAttrs(el: Element, attrs: Readonly<Record<string, AttrValue>>): void;
|
|
109
|
+
export function setText(el: Element, text: unknown): void;
|
|
110
|
+
export function withOneRender<E extends Element>(el: E, work: (el: E) => unknown): void;
|
|
111
|
+
|
|
112
|
+
// ── Places ──────────────────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
/** A parent with an optional anchor, the key of a node with an optional part, or a part alone. */
|
|
115
|
+
export type Container =
|
|
116
|
+
| { readonly parent: Element; readonly before?: Node | null }
|
|
117
|
+
| { readonly key: string; readonly part?: string }
|
|
118
|
+
| { readonly part: string };
|
|
119
|
+
|
|
120
|
+
/** Containers by name. */
|
|
121
|
+
export type Containers = Readonly<Record<string, Container>>;
|
|
122
|
+
|
|
123
|
+
/** The keys of each container, in order. */
|
|
124
|
+
export type Places = Readonly<Record<string, readonly string[]>>;
|
|
125
|
+
|
|
126
|
+
/** Nodes by key. */
|
|
127
|
+
export type Nodes = Readonly<Record<string, Element>>;
|
|
128
|
+
|
|
129
|
+
/** What `readPlaces` returns. Frozen. */
|
|
130
|
+
export interface Reading {
|
|
131
|
+
readonly containers: Containers;
|
|
132
|
+
readonly places: Places;
|
|
133
|
+
readonly nodes: Nodes;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** One placement of a plan: a key, its container, and the key it goes before, or null. */
|
|
137
|
+
export interface Placement {
|
|
138
|
+
readonly key: string;
|
|
139
|
+
readonly in: string;
|
|
140
|
+
readonly before: string | null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** What `plan` returns. Frozen. */
|
|
144
|
+
export interface Plan {
|
|
145
|
+
readonly remove: readonly string[];
|
|
146
|
+
readonly place: readonly Placement[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Makes the node of a new key. */
|
|
150
|
+
export type Make = (key: string) => Element;
|
|
151
|
+
|
|
152
|
+
export function plan(current: Places, wanted: Places): Plan;
|
|
153
|
+
export function readPlaces(containers: Containers): Reading;
|
|
154
|
+
export function perform(reading: Reading, plan: Plan, make: Make): Nodes;
|
|
155
|
+
export function syncPlaces(containers: Containers, wanted: Places, make: Make): Nodes;
|
|
156
|
+
export function release(node: Element): void;
|
|
157
|
+
|
|
158
|
+
// ── Events ──────────────────────────────────────────────────────────────────
|
|
159
|
+
|
|
160
|
+
/** The keys on the path of an event, outermost first, and its nearest part. */
|
|
161
|
+
export interface Origin {
|
|
162
|
+
readonly keyPath: readonly string[];
|
|
163
|
+
readonly part: string | null;
|
|
164
|
+
readonly node: Element | null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** What the application receives: a meaning and an optional argument. */
|
|
168
|
+
export type Message = readonly [meaning: string, arg?: unknown];
|
|
169
|
+
|
|
170
|
+
export interface ListenOptions {
|
|
171
|
+
dispatch: (message: Message) => unknown;
|
|
172
|
+
events: readonly EventEntry[];
|
|
173
|
+
requestedValues?: typeof import("./requests").requestedValues;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** The state holder of `dispatcher`. */
|
|
177
|
+
export interface Store<State> {
|
|
178
|
+
value: State;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function readOrigin(e: Event): Origin;
|
|
182
|
+
/** Returns a function that removes the listeners. */
|
|
183
|
+
export function listen(root: Node, options: ListenOptions): () => void;
|
|
184
|
+
export function dispatcher<State, View>(
|
|
185
|
+
store: Store<State>,
|
|
186
|
+
step: (state: State, message: Message) => State,
|
|
187
|
+
view: (state: State) => View,
|
|
188
|
+
render: (view: View) => unknown,
|
|
189
|
+
): (message: Message) => State;
|
|
190
|
+
|
|
191
|
+
// ── Elements ────────────────────────────────────────────────────────────────
|
|
192
|
+
|
|
193
|
+
export interface ElementOptions<A extends string> {
|
|
194
|
+
/** The attributes the element shows. A hole gets them as an item, `null` when absent. */
|
|
195
|
+
attrs: readonly A[];
|
|
196
|
+
template: Template<Readonly<Record<A, string | null>>>;
|
|
197
|
+
css?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function defineElement<A extends string>(tag: string, options: ElementOptions<A>): void;
|