@silkui/core 0.0.0-stage → 0.1.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.
package/README.md CHANGED
@@ -1,3 +1,180 @@
1
- # Temporary Holding Version
1
+ # @silkui/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The node and event API of a [Silk UI](https://github.com/silk-lang/SilkUI) tree, for
4
+ JavaScript apps that run on the SilkJS engine embedded in a Silk UI program. Its nodes are
5
+ the tree's own (box, text, input, rich input, image, icon, canvas). Its methods and its
6
+ event flow are the DOM's: `appendChild`, `addEventListener`, capture and bubble,
7
+ `preventDefault`.
8
+
9
+ `@silkui/react` and `@silkui/foldkit` are built on it. Use it directly for a plain
10
+ JavaScript or TypeScript app, or to draw on nodes from inside a framework app.
11
+
12
+ ## Install
13
+
14
+ The quickest start is a template, which sets up the Silk host, Vite and this package:
15
+
16
+ ```sh
17
+ silk init my-app -t ui-js # plain TypeScript; ui-react and ui-foldkit use this package too
18
+ cd my-app
19
+ silk task dev
20
+ ```
21
+
22
+ See [Get started](https://silk-ui-docs.juliaortiz-js.workers.dev/start/). To add it to an
23
+ existing Silk UI web project:
24
+
25
+ ```sh
26
+ npm install @silkui/core
27
+ ```
28
+
29
+ The package runs inside a Silk UI host (the native window, or the web canvas), which provides
30
+ the native functions it calls. It does not run in Node or in a plain browser page by itself.
31
+
32
+ ## Usage
33
+
34
+ ```ts
35
+ import { createBox, createText, mount } from "@silkui/core";
36
+
37
+ const label = createText("Clicked 0 times");
38
+ const button = createBox(
39
+ { paddingTop: 12, paddingBottom: 12, paddingLeft: 20, paddingRight: 20, borderRadius: 10, backgroundColor: "rgb(37, 99, 235)", color: "white" },
40
+ label,
41
+ );
42
+ button.tabIndex = 0;
43
+ button.look("hover").set({ backgroundColor: "rgb(59, 130, 246)" });
44
+
45
+ let clicks = 0;
46
+ button.addEventListener("click", () => {
47
+ clicks += 1;
48
+ label.data = `Clicked ${clicks} times`;
49
+ });
50
+
51
+ mount(createBox({ position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center" }, button));
52
+ ```
53
+
54
+ ## API
55
+
56
+ ### Nodes
57
+
58
+ | Export | What it does |
59
+ | --- | --- |
60
+ | `createBox(style?, ...children)` | A box with `style` as its base look. Strings among the children become text nodes |
61
+ | `createText(data?)` | A text node. It takes its look from its parent |
62
+ | `createInput(style?)` | An editable text field. `value`, `selectionStart`, `selectionEnd` and `setSelectionRange` work as on an `<input>` |
63
+ | `createRichInput(style?)` | A text field with marks and inline atoms (see below) |
64
+ | `createIcon(svg, style?)` | SVG markup drawn at the node's size, with its `color` as `currentColor` |
65
+ | `createNode(kind)` | A node of any kind: `"box"`, `"text"`, `"input"`, `"richinput"`, `"image"`, `"icon"`, `"canvas"` |
66
+ | `mount(node)` / `root()` | Makes a node the root of the window's tree, or returns it |
67
+ | `nodeById(id)` | The node with a tree id, for hosts and tools |
68
+
69
+ A node has `append`, `appendChild`, `insertBefore`, `removeChild`, `remove`, `contains`,
70
+ `parentNode`, `childNodes`, `firstChild`, `lastChild` and the sibling getters, as in the DOM.
71
+ A removed node keeps its state and can be inserted again. `destroy()` frees a node and its
72
+ subtree for good. `focus()` and `scrollTo(x, y)` do what their names say.
73
+
74
+ ### Style and looks
75
+
76
+ ```ts
77
+ node.style.set({ width: 120, flexGrow: 1, fontFamily: "Noto Sans, sans-serif" });
78
+ node.style = { height: 40 }; // replaces the base look
79
+ node.look("hover").set({ opacity: 0.8 }); // also "active", "focus", "focusVisible"
80
+ node.look("starting").set({ opacity: 0 }); // what transitions start from, as @starting-style
81
+ ```
82
+
83
+ - Properties use their camel case names, typed from `csstype`. Numbers are CSS pixels,
84
+ except for unitless properties such as `opacity`, `flexGrow`, `zIndex` and `lineHeight`.
85
+ `null` takes a property out.
86
+ - Layout is CSS: flex, grid (`gridTemplateColumns: "auto 1fr"`, `repeat()`, `minmax()`,
87
+ named lines, `gridTemplateAreas`, `gridArea`, `gridColumn: "span 2"`) and positioning.
88
+ Grid properties apply from the base look only.
89
+ - `fontFamily` takes CSS `font-family` text, resolved in the host's fonts.
90
+ - `transition` and `animation` work as in CSS. `defineKeyframes(name, { from: {...}, "50%": {...}, to: {...} })`
91
+ defines `@keyframes` for them.
92
+
93
+ ### Events
94
+
95
+ ```ts
96
+ node.addEventListener("pointerdown", (event) => event.preventDefault(), { capture: true });
97
+ ```
98
+
99
+ An event runs the capture phase from the root down, the target, then bubbles, with
100
+ `stopPropagation`, `stopImmediatePropagation`, `preventDefault` and `composedPath`, as on the
101
+ web. Listeners run before the tree's default action, so `preventDefault()` on a
102
+ `pointerdown` keeps the focus where it is. `dispatchEvent(event)` runs an `Event` you made
103
+ through the tree.
104
+
105
+ | Events | Members |
106
+ | --- | --- |
107
+ | `pointerdown`, `pointerup`, `click` | `clientX`, `clientY`, `button`, `detail` (2 for a double click), modifier keys |
108
+ | `pointermove`, `pointerenter`, `pointerleave`, `pointercancel` | `clientX`, `clientY`, modifier keys |
109
+ | `wheel` | `deltaX`, `deltaY` |
110
+ | `keydown`, `keyup` | `key`, `code`, `repeat`, modifier keys |
111
+ | `focus`, `blur`, `load`, `error`, `gotpointercapture`, `lostpointercapture` | |
112
+ | `input` | `value`, `inputType`, and `document` on a rich input |
113
+ | `selectionchange` | `selectionStart`, `selectionEnd` |
114
+ | `scroll` | `scrollLeft`, `scrollTop` |
115
+ | `layout` | `bounds`: where layout put the node, in window pixels |
116
+ | `transitionrun`, `transitionstart`, `transitionend`, `transitioncancel` | `propertyName`, `elapsedTime` |
117
+ | `animationstart`, `animationiteration`, `animationend`, `animationcancel` | `animationName`, `elapsedTime` |
118
+
119
+ A listener that throws does not stop the dispatch. `setErrorHandler(handler)` receives the
120
+ exception; without one the host reports it.
121
+
122
+ ### Attributes and accessibility
123
+
124
+ `setAttribute(name, value)` sets the tree's attributes: `tabIndex`, `disabled`, `label`,
125
+ `testId`, `placeholder`, `multiline`, `readOnly`, `checked`, `selected`, `expanded`,
126
+ `focusTrap`, `inert`, `href`, `cursor` and `transition`, plus `id`. A name the tree does not
127
+ have throws a `TypeError`. `tabIndex` and `disabled` are also properties.
128
+
129
+ - `role` and the ARIA attributes work as in the DOM, spelled `aria-label` or `ariaLabel`.
130
+ `aria-labelledby`, `aria-describedby`, `aria-controls` and `aria-activedescendant` name
131
+ other nodes by their `id`.
132
+ - `announce(message, { politeness })` has screen readers say a message nothing on screen shows.
133
+ - `inert` puts a subtree out of reach of focus, pointers and screen readers, as in HTML.
134
+ - A node with an `href` is a link: a click on it that no listener prevented opens the address.
135
+
136
+ ### Rich inputs
137
+
138
+ A rich input edits a document of styled text and inline atoms (mentions, chips):
139
+
140
+ ```ts
141
+ import { createRichInput, OBJECT } from "@silkui/core";
142
+
143
+ const field = createRichInput({ width: 400 });
144
+ field.defineMark("bold", { fontWeight: 700 });
145
+ field.defineAtom("mention", { backgroundColor: "rgb(219, 234, 254)", borderRadius: 4 });
146
+ field.document = { text: `Hi ${OBJECT}`, marks: [], atoms: [{ kind: "mention", label: "@ada", data: "user-1" }] };
147
+ field.addEventListener("input", (event) => save(event.document));
148
+ ```
149
+
150
+ - An atom sits in `text` as one `OBJECT` character (U+FFFC), so the caret steps over it and
151
+ Backspace deletes it whole. Offsets are string indices.
152
+ - `format(name, on)` and `toggleMark(name)` mark the selection, or the text typed next at a
153
+ caret. `activeMarks` holds the marks typed text gets.
154
+ - `insertAtom(start, end, atom)` replaces a range with an atom, such as a `@` trigger
155
+ turning into a mention. Listen for `selectionchange` to open a picker.
156
+ - Undo, IME and copy work as in a plain input.
157
+
158
+ ### Markdown
159
+
160
+ `parseMarkdown(text, options?)` returns the syntax tree of Markdown text in the shape of
161
+ [mdast](https://github.com/syntax-tree/mdast), the tree remark gives, so renderers written
162
+ for remark work on it and the app needs no Markdown parser in its bundle. It is CommonMark
163
+ with GitHub's tables, strikethrough, task lists and autolinks (`gfm: false` turns them off,
164
+ or set `tables`, `strikethrough`, `taskLists` and `autolinkLiterals` one by one).
165
+ `footnotes`, `frontmatter` and `alerts` (`> [!NOTE]`) turn on more. Nodes have no
166
+ `position`.
167
+
168
+ ## TypeScript
169
+
170
+ The package ships its types. Every node class, event and style property is typed, and
171
+ `addEventListener` gives each listener the event of its type. `parseMarkdown` returns the
172
+ `mdast` `Root` type.
173
+
174
+ ## More
175
+
176
+ - [The ui-js reference](https://github.com/silk-lang/SilkUI/blob/main/modules/js/README.md):
177
+ every package, the host, and the web globals a realm has.
178
+ - [Templates](https://github.com/silk-lang/examples) and
179
+ [Get started](https://silk-ui-docs.juliaortiz-js.workers.dev/start/).
180
+ - [Source](https://github.com/silk-lang/SilkUI/tree/main/modules/js/packages/core). MIT license.
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@silkui/core",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "The node and event API of a Silk UI tree for JavaScript applications that run on the embedded SilkJS engine",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/silk-lang/SilkUI.git",
8
+ "directory": "modules/js/packages/core"
9
+ },
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./src/index.d.ts",
14
+ "default": "./src/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "src"
19
+ ],
20
+ "sideEffects": true,
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "@types/mdast": "^4.0.4",
24
+ "csstype": "^3.1.3"
25
+ }
26
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,319 @@
1
+ import type * as CSS from "csstype";
2
+
3
+ /** The node kinds of the tree. `richinput` is an `input` with marks and atoms. */
4
+ export type NodeKind = "box" | "text" | "input" | "richinput" | "image" | "icon" | "canvas";
5
+
6
+ /** The looks a state lays over the base look: `:hover`, `:active`, `:focus`, `:focus-visible`, `@starting-style`. */
7
+ export type LookState = "base" | "hover" | "active" | "focus" | "focusVisible" | "starting";
8
+
9
+ /**
10
+ * Style properties by their camel case names. Numbers are CSS pixels except for unitless
11
+ * properties (`opacity`, `flexGrow`, `zIndex`, `fontWeight`, `lineHeight` and the like).
12
+ * `null`, `undefined` and `""` take a property out.
13
+ */
14
+ export type Style = {
15
+ [K in keyof CSS.Properties<string | number>]?: CSS.Properties<string | number>[K] | null;
16
+ };
17
+
18
+ /** The declarations of one look of a node. */
19
+ export interface Look {
20
+ /** Sets properties over the ones the look has. */
21
+ set(properties: Style): void;
22
+ /** Replaces the whole look. */
23
+ replace(properties: Style): void;
24
+ /** A property as the tree got it, in CSS text (`"120px"`). */
25
+ get(name: keyof Style): string | undefined;
26
+ readonly cssText: string;
27
+ }
28
+
29
+ export type Listener<E extends Event = Event> = ((this: Node, event: E) => void) | { handleEvent(event: E): void };
30
+ export type ListenerOptions = boolean | { capture?: boolean; once?: boolean };
31
+
32
+ /** A node of the tree. Make one with `createBox`, `createText`, `createInput` or `createNode`. */
33
+ export class Node {
34
+ constructor(kind: NodeKind);
35
+ /** The tree's number for the node (not the DOM `id`: that is `setAttribute("id", ...)`). */
36
+ readonly id: number;
37
+ readonly kind: NodeKind;
38
+ readonly parentNode: Node | null;
39
+ readonly childNodes: readonly Node[];
40
+ readonly firstChild: Node | null;
41
+ readonly lastChild: Node | null;
42
+ readonly nextSibling: Node | null;
43
+ readonly previousSibling: Node | null;
44
+ /** Whether `other` is this node or inside it. */
45
+ contains(other: Node | null): boolean;
46
+ /** Inserts `child` before `before`, or last without it. A child already in the tree moves. */
47
+ insertBefore<T extends Node>(child: T, before?: Node | null): T;
48
+ appendChild<T extends Node>(child: T): T;
49
+ /** Appends nodes, and strings as text nodes. */
50
+ append(...children: (Node | string)[]): void;
51
+ /** Detaches `child` and its subtree. It keeps its state and can be inserted again. */
52
+ removeChild<T extends Node>(child: T): T;
53
+ remove(): void;
54
+ /** Detaches and frees this node and its subtree. They cannot be used again. */
55
+ destroy(): void;
56
+ /** The base look: `node.style.set({ width: 120 })` sets properties, `node.style = { ... }` replaces it. */
57
+ get style(): Look;
58
+ set style(properties: Style);
59
+ /** The look the tree lays over the base in `state`. */
60
+ look(state: LookState): Look;
61
+ /**
62
+ * Sets a tree attribute (`tabIndex`, `disabled`, `label`, `testId`, `placeholder`, `href`,
63
+ * `cursor`, `multiline`, `readOnly`, `inert`, `focusTrap`, `transition`), `id`, `role`, or
64
+ * an ARIA attribute spelled `aria-checked` or `ariaChecked`.
65
+ */
66
+ setAttribute(name: string, value: unknown): void;
67
+ set tabIndex(value: number);
68
+ set disabled(value: boolean);
69
+ focus(): void;
70
+ scrollTo(x: number, y: number): void;
71
+ addEventListener<K extends keyof EventMap>(type: K, listener: Listener<EventMap[K]>, options?: ListenerOptions): void;
72
+ removeEventListener<K extends keyof EventMap>(type: K, listener: Listener<EventMap[K]>, options?: ListenerOptions): void;
73
+ }
74
+
75
+ /** A text leaf. It takes its look from its parent. */
76
+ export class Text extends Node {
77
+ constructor(data?: string);
78
+ data: string;
79
+ textContent: string;
80
+ }
81
+
82
+ /** An editable text field. `value` follows what the user types. */
83
+ export class Input extends Node {
84
+ constructor();
85
+ value: string;
86
+ readonly selectionStart: number;
87
+ readonly selectionEnd: number;
88
+ /** Selects from `anchor` to `focus`, as UTF-8 byte offsets in the value. */
89
+ setSelectionRange(anchor: number, focus: number): void;
90
+ }
91
+
92
+ /** An inline atom of a rich input: a mention or a chip. */
93
+ export interface RichAtom {
94
+ kind: string;
95
+ label: string;
96
+ data: string;
97
+ }
98
+
99
+ /** A styled run of a rich input's text. */
100
+ export interface RichMarks {
101
+ start: number;
102
+ end: number;
103
+ marks: readonly string[];
104
+ }
105
+
106
+ /**
107
+ * A rich input's content. Each atom sits in `text` as one `OBJECT` character; `atoms` lists
108
+ * them in text order. Offsets are string indices.
109
+ */
110
+ export interface RichDocument {
111
+ text: string;
112
+ marks: readonly RichMarks[];
113
+ atoms: readonly RichAtom[];
114
+ }
115
+
116
+ /** Where an atom sits in a rich input's text: U+FFFC OBJECT REPLACEMENT CHARACTER. */
117
+ export const OBJECT: string;
118
+
119
+ /** A rich text field: marks and inline atoms over the text the user edits. */
120
+ export class RichInput extends Input {
121
+ /** The marks text typed at the caret gets, as of the last change. */
122
+ readonly activeMarks: readonly string[];
123
+ /** Replacing it moves the caret to the end and forgets the undo history. */
124
+ get document(): RichDocument;
125
+ set document(document: Partial<RichDocument>);
126
+ /** What text with mark `name` looks like. */
127
+ defineMark(name: string, style: Style): void;
128
+ /** What atoms of `kind` look like: the inline block holding the label. */
129
+ defineAtom(kind: string, style: Style): void;
130
+ /** Turns mark `name` on or off over the selection, or for the text typed next. */
131
+ format(name: string, on?: boolean): void;
132
+ toggleMark(name: string): void;
133
+ /** Replaces the text from `start` to `end` with `atom`. */
134
+ insertAtom(start: number, end: number, atom: RichAtom): void;
135
+ /** Selects from `anchor` to `focus`, as string indices. */
136
+ setSelectionRange(anchor: number, focus: number): void;
137
+ }
138
+
139
+ /** An icon: SVG markup drawn at the node's CSS size, with its `color` as `currentColor`. */
140
+ export class Icon extends Node {
141
+ constructor(svg?: string);
142
+ svg: string;
143
+ }
144
+
145
+ /** An event of the tree, with the members of the DOM event it corresponds to. */
146
+ export class Event {
147
+ constructor(type: keyof EventMap, target: Node);
148
+ readonly type: keyof EventMap;
149
+ readonly target: Node;
150
+ readonly currentTarget: Node | null;
151
+ /** 0 none, 1 capturing, 2 at the target, 3 bubbling. */
152
+ readonly eventPhase: 0 | 1 | 2 | 3;
153
+ readonly bubbles: boolean;
154
+ readonly cancelable: boolean;
155
+ readonly defaultPrevented: boolean;
156
+ preventDefault(): void;
157
+ stopPropagation(): void;
158
+ stopImmediatePropagation(): void;
159
+ /** The nodes the event passes, target first. */
160
+ composedPath(): Node[];
161
+ }
162
+
163
+ export interface ModifierEvent extends Event {
164
+ readonly shiftKey: boolean;
165
+ readonly ctrlKey: boolean;
166
+ readonly altKey: boolean;
167
+ readonly metaKey: boolean;
168
+ }
169
+
170
+ export interface PointerEvent extends ModifierEvent {
171
+ readonly clientX: number;
172
+ readonly clientY: number;
173
+ readonly x: number;
174
+ readonly y: number;
175
+ }
176
+
177
+ /** `pointerdown`, `pointerup` and `click`. */
178
+ export interface PointerButtonEvent extends PointerEvent {
179
+ readonly button: number;
180
+ /** The click count: 2 for a double click. */
181
+ readonly detail: number;
182
+ }
183
+
184
+ export interface WheelEvent extends PointerEvent {
185
+ readonly deltaX: number;
186
+ readonly deltaY: number;
187
+ }
188
+
189
+ export interface KeyboardEvent extends ModifierEvent {
190
+ readonly key: string;
191
+ readonly code: string;
192
+ readonly repeat: boolean;
193
+ }
194
+
195
+ /** An input or selection event's target: the field itself, or a field inside a node that listens. */
196
+ type FieldOf<T extends Node> = T extends Input ? T : Input;
197
+
198
+ export interface InputEvent<T extends Node = Input> extends Event {
199
+ readonly target: FieldOf<T>;
200
+ readonly value: string;
201
+ readonly inputType: string;
202
+ /** On a rich input: its document after the change. */
203
+ readonly document: FieldOf<T> extends RichInput ? RichDocument : RichDocument | undefined;
204
+ }
205
+
206
+ export interface SelectionEvent<T extends Node = Input> extends Event {
207
+ readonly target: FieldOf<T>;
208
+ readonly selectionStart: number;
209
+ readonly selectionEnd: number;
210
+ }
211
+
212
+ export interface ScrollEvent extends Event {
213
+ readonly scrollLeft: number;
214
+ readonly scrollTop: number;
215
+ }
216
+
217
+ /** Where layout put the node, in window pixels. */
218
+ export interface LayoutEvent extends Event {
219
+ readonly bounds: { x: number; y: number; width: number; height: number };
220
+ }
221
+
222
+ export interface TransitionEvent extends Event {
223
+ readonly propertyName: string;
224
+ readonly elapsedTime: number;
225
+ readonly pseudoElement: string;
226
+ }
227
+
228
+ export interface AnimationEvent extends Event {
229
+ readonly animationName: string;
230
+ readonly elapsedTime: number;
231
+ readonly pseudoElement: string;
232
+ }
233
+
234
+ /** The events of the tree by type. */
235
+ export interface EventMap {
236
+ pointerdown: PointerButtonEvent;
237
+ pointerup: PointerButtonEvent;
238
+ click: PointerButtonEvent;
239
+ pointermove: PointerEvent;
240
+ pointerenter: PointerEvent;
241
+ pointerleave: PointerEvent;
242
+ pointercancel: PointerEvent;
243
+ wheel: WheelEvent;
244
+ keydown: KeyboardEvent;
245
+ keyup: KeyboardEvent;
246
+ focus: Event;
247
+ blur: Event;
248
+ input: InputEvent;
249
+ selectionchange: SelectionEvent;
250
+ scroll: ScrollEvent;
251
+ layout: LayoutEvent;
252
+ gotpointercapture: Event;
253
+ lostpointercapture: Event;
254
+ load: Event;
255
+ error: Event;
256
+ transitionrun: TransitionEvent;
257
+ transitionstart: TransitionEvent;
258
+ transitionend: TransitionEvent;
259
+ transitioncancel: TransitionEvent;
260
+ animationstart: AnimationEvent;
261
+ animationiteration: AnimationEvent;
262
+ animationend: AnimationEvent;
263
+ animationcancel: AnimationEvent;
264
+ }
265
+
266
+ export function createNode(kind: "text"): Text;
267
+ export function createNode(kind: "input"): Input;
268
+ export function createNode(kind: "richinput"): RichInput;
269
+ export function createNode(kind: "icon"): Icon;
270
+ export function createNode(kind: NodeKind): Node;
271
+
272
+ /** A box with `style` as its base look and `children` appended. */
273
+ export function createBox(style?: Style | null, ...children: (Node | string)[]): Node;
274
+ export function createText(data?: string): Text;
275
+ export function createInput(style?: Style | null): Input;
276
+ export function createRichInput(style?: Style | null): RichInput;
277
+ /** An icon showing `svg` markup, with `style` as its base look. */
278
+ export function createIcon(svg: string, style?: Style | null): Icon;
279
+
280
+ /**
281
+ * Defines `@keyframes name`: `{ from: { opacity: 0 }, "50%": { ... }, to: { ... } }`.
282
+ * Defining a name again replaces its rule.
283
+ */
284
+ export function defineKeyframes(name: string, frames: Record<string, Style>): void;
285
+
286
+ /** Makes `node` the root of the window's tree. */
287
+ export function mount<T extends Node>(node: T): T;
288
+ export function root(): Node | null;
289
+
290
+ /** Has screen readers say `message` without showing it. */
291
+ export function announce(message: string, options?: { politeness?: "polite" | "assertive" }): void;
292
+
293
+ /** The node with tree id `id`, for hosts and tools. */
294
+ export function nodeById(id: number): Node | null;
295
+
296
+ /** Runs `event` through the tree as the DOM does. Returns false when a listener prevented the default. */
297
+ export function dispatchEvent(event: Event): boolean;
298
+
299
+ export interface MarkdownOptions {
300
+ /** GitHub's tables, strikethrough, task lists and autolinks. Default true. */
301
+ gfm?: boolean;
302
+ tables?: boolean;
303
+ strikethrough?: boolean;
304
+ taskLists?: boolean;
305
+ autolinkLiterals?: boolean;
306
+ footnotes?: boolean;
307
+ frontmatter?: boolean;
308
+ /** `> [!NOTE]` blocks, as nodes of type `alert` with a `kind`. */
309
+ alerts?: boolean;
310
+ }
311
+
312
+ /**
313
+ * The syntax tree of Markdown `text` in the shape of mdast, without positions. Install
314
+ * `@types/mdast` for its node types.
315
+ */
316
+ export function parseMarkdown(text: string, options?: MarkdownOptions): import("mdast").Root;
317
+
318
+ /** What happens to an exception a listener throws. Without a handler, the host reports it. */
319
+ export function setErrorHandler(handler: ((error: unknown) => void) | null): void;