@lipsjs/lips 0.3.0 → 0.4.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.
Files changed (46) hide show
  1. package/README.md +123 -9
  2. package/dist/lips.js +915 -669
  3. package/dist/lips.js.map +15 -12
  4. package/dist/lips.min.js +12 -12
  5. package/dist/lips.min.js.map +15 -12
  6. package/dist/lynx-background.min.js +3 -0
  7. package/dist/lynx-background.min.js.map +13 -0
  8. package/dist/lynx-main.min.js +3 -0
  9. package/dist/lynx-main.min.js.map +11 -0
  10. package/dist/lynx-plugin.mjs +1487 -0
  11. package/dist/lynx.min.js +51 -0
  12. package/dist/lynx.min.js.map +18 -0
  13. package/dist/mf2.min.js.map +1 -1
  14. package/dist/parts.min.js +19 -0
  15. package/dist/parts.min.js.map +11 -0
  16. package/dist/precompile.min.js +15 -15
  17. package/dist/precompile.min.js.map +8 -7
  18. package/dist/runtime.min.js +4 -4
  19. package/dist/runtime.min.js.map +11 -9
  20. package/dist/stylis.min.js.map +1 -1
  21. package/dist/types/component.d.ts +32 -0
  22. package/dist/types/ir/compiler.d.ts +2 -4
  23. package/dist/types/ir/facade.d.ts +63 -12
  24. package/dist/types/ir/host.d.ts +9 -1
  25. package/dist/types/ir/initial.d.ts +16 -0
  26. package/dist/types/ir/router.d.ts +2 -0
  27. package/dist/types/ir/tags.d.ts +16 -0
  28. package/dist/types/lips.d.ts +7 -7
  29. package/dist/types/lynx/a11y.d.ts +1 -0
  30. package/dist/types/lynx/background.d.ts +52 -3
  31. package/dist/types/lynx/main.d.ts +9 -5
  32. package/dist/types/lynx/plugin.d.ts +8 -0
  33. package/dist/types/lynx/protocol.d.ts +55 -4
  34. package/dist/types/lynx/style.d.ts +7 -0
  35. package/dist/types/lynx/template.d.ts +6 -0
  36. package/dist/types/lynx.d.ts +22 -0
  37. package/dist/types/parts/menu.d.ts +44 -0
  38. package/dist/types/parts/popover.d.ts +83 -0
  39. package/dist/types/parts.d.ts +16 -0
  40. package/dist/types/precompile.d.ts +8 -11
  41. package/dist/types/runtime.d.ts +1 -0
  42. package/dist/types/types.d.ts +181 -57
  43. package/dist/untrusted.min.js +4 -4
  44. package/dist/untrusted.min.js.map +7 -7
  45. package/package.json +29 -3
  46. package/dist/types/i18n/formatters.d.ts +0 -3
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Menu: a popover's panel of actions (RFC-008 §5; WAI-ARIA's menu button).
3
+ *
4
+ * lips.use( menu ) // and the popover it is built on
5
+ *
6
+ * <popover open=state.open on-change( setOpen )>
7
+ * <popover-trigger haspopup="menu"><span>Actions</span></popover-trigger>
8
+ * <popover-menu items=state.actions class="menu" item="menu-item" on-select( run )/>
9
+ * </popover>
10
+ *
11
+ * Named `popover-menu`: `menu` is an HTML element, which the compiler
12
+ * reads as one.
13
+ *
14
+ * Its items are data, `{ id, label, disabled? }`, each drawn as its label
15
+ * or by the slot, which gets `item` and `active`:
16
+ * `<popover-menu … [item, active]><span>{item.label}</span></popover-menu>`.
17
+ *
18
+ * Its list is the popup (`popup="content"`): mounted each time the menu
19
+ * opens, it starts on the item the trigger asked for, takes focus, and
20
+ * names the active item with `aria-activedescendant`. Arrows move it, Home
21
+ * and End go to the first and last, a letter to the next item it starts,
22
+ * all past disabled items. Enter or Space selects it; a tap selects the
23
+ * item tapped. Selecting emits `select` with the item and closes the menu,
24
+ * giving focus back to the trigger. Tab closes it and lets focus move on.
25
+ * On Lynx, which has no menu role, each item is a button.
26
+ *
27
+ * The active item has the class `is-active`; a disabled one,
28
+ * `aria-disabled` and `is-disabled`.
29
+ */
30
+ import type { Plugin } from '../types';
31
+ export interface MenuItem {
32
+ readonly id: string;
33
+ readonly label: string;
34
+ readonly disabled?: boolean;
35
+ }
36
+ /**
37
+ * The next item to make active from `from`, by `step` (±1), wrapping and
38
+ * skipping disabled ones; -1 when none can be. `from` -1 starts before the
39
+ * first item, `items.length` after the last.
40
+ */
41
+ export declare function move(items: readonly MenuItem[], from: number, step: 1 | -1): number;
42
+ /** The next enabled item after `from` whose label starts with `letter`, wrapping; -1 when none */
43
+ export declare function typed(items: readonly MenuItem[], from: number, letter: string): number;
44
+ export declare const menu: Plugin;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Popover: a trigger and the panel it opens, over the page (RFC-008 §5).
3
+ *
4
+ * lips.use( popover )
5
+ *
6
+ * <popover open=state.open on-change( setOpen )>
7
+ * <popover-trigger class="btn"><span>Actions</span></popover-trigger>
8
+ * <popover-content class="panel">…</popover-content>
9
+ * </popover>
10
+ *
11
+ * It is controlled: `open` is the app's, and a change comes back as
12
+ * `change`. `popover` provides what its pieces share as `context.popover`
13
+ * (`PopoverApi`), which reaches them where its slot places them (RFC-005
14
+ * §4.4). A piece given `of` uses that instead, so a piece can be driven by
15
+ * any controller of the same shape.
16
+ *
17
+ * `popover-content` renders, while open, a layer over the whole page, a
18
+ * backdrop in it and the panel. The layer is one fixed element on both
19
+ * hosts: on Lynx `fixed` places it as a child of the page's root, which is
20
+ * what Lynx asks of a page that is all Lynx (its `overlay` is for Lynx
21
+ * inside a native page). Each time it opens, the panel is drawn invisible,
22
+ * then the trigger, the layer and the panel are measured and the panel is
23
+ * placed (`place`, or the app's own as `place=`), and focus goes to it.
24
+ *
25
+ * Closing: Escape, a tap on the backdrop, and whatever the content asks
26
+ * (`p.set( false )`); focus goes back to the trigger. The backdrop takes a
27
+ * tap outside whole, so it closes the panel and reaches nothing beneath,
28
+ * as a menu on a phone does. `.outside` would not do: it listens in the
29
+ * capture phase on both hosts, before the trigger's own tap, which would
30
+ * close the panel and open it again.
31
+ *
32
+ * `popup` says which element is the popup a screen reader is told of:
33
+ * `"panel"` (the default) gives the panel the popover's id, its `role`,
34
+ * the trigger as its label, and focus; `"content"` leaves all of that to
35
+ * the content, as a menu's list takes it (`./menu`).
36
+ *
37
+ * Its mechanics (the layer over the page, where the panel sits) are
38
+ * inline styles: Lynx cannot add a sheet at run time, so a part's own
39
+ * sheet would have to reach the app's build, and nothing here needs what
40
+ * only a sheet reaches (`:hover`, `@keyframes`, `@media`). Its look is the
41
+ * app's, through the classes it is given.
42
+ */
43
+ import type { Plugin } from '../types';
44
+ /** What a popover's pieces share: `context.popover`, or a piece's `of` */
45
+ export interface PopoverApi {
46
+ /** The popup's id; the trigger's is this with `-trigger` */
47
+ readonly id: string;
48
+ /** The app's `open`, read live */
49
+ readonly open: boolean;
50
+ /** The popup's id while it is open: what `aria-controls` names */
51
+ readonly controls: string | null;
52
+ /** The trigger's element, set by the trigger */
53
+ trigger?: {
54
+ focus(): void;
55
+ getBoundingClientRect(): unknown;
56
+ };
57
+ /** Where content with items starts when it opens, as the trigger's key asked */
58
+ start: 'first' | 'last';
59
+ /** Ask for `open`; closed, focus goes back to the trigger unless `back` is false */
60
+ set(open: boolean, back?: boolean): void;
61
+ toggle(): void;
62
+ }
63
+ /** A box as the DOM and Lips's Lynx refs both give it */
64
+ export interface Box {
65
+ top: number;
66
+ left: number;
67
+ right: number;
68
+ bottom: number;
69
+ width: number;
70
+ height: number;
71
+ }
72
+ /** Where a panel goes in its layer, from the three boxes measured */
73
+ export type Placement = (trigger: Box, layer: Box, panel: Box, rtl?: boolean) => {
74
+ top: number;
75
+ left: number;
76
+ };
77
+ /**
78
+ * Below the trigger, or above it where it does not fit below and does
79
+ * above; its start edge on the trigger's, or its end edge in right-to-left;
80
+ * kept inside the layer.
81
+ */
82
+ export declare const place: Placement;
83
+ export declare const popover: Plugin;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `@lipsjs/lips/parts`: headless components (RFC-008).
3
+ *
4
+ * Each part is a plugin: `lips.use()` installs its components and what it
5
+ * is built on, once.
6
+ *
7
+ * import { menu } from '@lipsjs/lips/parts'
8
+ * lips.use( menu ) // and the popover it is built on
9
+ *
10
+ * A part's templates are source. An app that runs in interpreted mode
11
+ * under a content security policy precompiles them in its build with
12
+ * `precompile()` (`@lipsjs/lips/precompile`), as it does its own; on Lynx,
13
+ * with `compileLynxTemplate()`.
14
+ */
15
+ export { popover, place, type PopoverApi, type Placement, type Box } from './parts/popover';
16
+ export { menu, move, typed, type MenuItem } from './parts/menu';
@@ -16,15 +16,12 @@
16
16
  import type { TemplateIR, CompileOptions } from './ir/compiler';
17
17
  import type { StyleIR, StylePreprocessor } from './ir/style';
18
18
  import type { TemplateDiagnostic } from './ir/parser';
19
- export interface PrecompiledTemplate {
19
+ import type { Component, TypedComponent, Shape } from './types';
20
+ /** What `precompile()` returns: the template it was given, with `ir` (and `style`) for its sources */
21
+ /** A component with its markup and stylesheet compiled: no source ships */
22
+ export type PrecompiledComponent<S extends Shape = Shape> = Omit<TypedComponent<S>, 'default' | 'macros' | 'stylesheet'> & {
20
23
  ir: TemplateIR;
21
- /** Compiled stylesheet — replaces `stylesheet` source (RFC-004) */
22
- style?: StyleIR;
23
- state?: Record<string, any>;
24
- _static?: Record<string, any>;
25
- context?: string[];
26
- handler?: Record<string, (...args: any[]) => any>;
27
- }
24
+ };
28
25
  export interface PrecompileOptions {
29
26
  /**
30
27
  * Scope name for the stylesheet — baked into the StyleIR, so it must
@@ -41,8 +38,8 @@ export interface PrecompileOptions {
41
38
  /** The kind of host the IR is for — see `CompileOptions.target` */
42
39
  target?: CompileOptions['target'];
43
40
  }
44
- export interface PrecompileResult {
45
- template: PrecompiledTemplate;
41
+ export interface PrecompileResult<S extends Shape = Shape> {
42
+ template: PrecompiledComponent<S>;
46
43
  diagnostics: TemplateDiagnostic[];
47
44
  }
48
45
  /**
@@ -51,7 +48,7 @@ export interface PrecompileResult {
51
48
  * is compiled to StyleIR, so the `./runtime` build needs no CSS
52
49
  * preprocessor either (RFC-004 §1).
53
50
  */
54
- export declare function precompile(template: Record<string, any>, options?: PrecompileOptions): PrecompileResult;
51
+ export declare function precompile<S extends Shape = Shape>(template: Component<S>, options?: PrecompileOptions): PrecompileResult<S>;
55
52
  /** Serialize an IR for embedding in generated source */
56
53
  export declare const serializeIR: (ir: TemplateIR) => string;
57
54
  export declare const serializeStyleIR: (ir: StyleIR) => string;
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { IRLips } from './ir/facade';
12
12
  export * from './types';
13
+ export { component } from './component';
13
14
  export { renderIR } from './ir/runtime';
14
15
  export { signal, effect, untrack, reactive } from './ir/signal';
15
16
  export type { TemplateIR, IRInstance, RuntimeOptions, RenderSetup, SwapReport, Host } from './ir';
@@ -1,45 +1,115 @@
1
1
  /**
2
2
  * Public types.
3
3
  *
4
- * Component authoring shape — the same plain object the framework has
5
- * always taken, and the serializable artifact a generator can emit:
4
+ * A component is a plain object — the same one the framework has always
5
+ * taken, and the serializable artifact a generator can emit:
6
6
  *
7
- * { default, state, handler, _static, context, macros, stylesheet }
7
+ * { name, default, state, static, handler, watchContext, macros, stylesheet }
8
8
  *
9
- * These are the types `register`/`render`/`root` actually accept: the
10
- * facade is generic over `Metavars`, so `Template<MT>` here and the
11
- * argument the engine takes are the same type, not parallel ones.
9
+ * `component()` writes one with its types inferred: `state` and `static`
10
+ * from their values, the handlers from themselves, `this` in each of them
11
+ * from all three. What no value can show, the `input` a parent hands it,
12
+ * it is told by name:
13
+ *
14
+ * const counter = component<{ input: { initial?: number } }>()({
15
+ * state: { count: 0 },
16
+ * handler: {
17
+ * onInput(){ this.state.count = this.input.initial ?? 0 },
18
+ * step( by: number ){ this.state.count += by }
19
+ * },
20
+ * default: `<button on-click(step, 1)>{state.count}</button>`
21
+ * })
22
+ *
23
+ * lips.render('counter', counter, { initial: 2 }).state.count // number
24
+ *
25
+ * The context is the app's, so it is typed once for every component, by
26
+ * augmenting `SharedContext`. What the template strings read is not
27
+ * checked: their expressions are not TypeScript.
12
28
  */
13
29
  import type { MessageFormat, Model } from 'messageformat';
14
30
  import type { MessageFunction } from 'messageformat/functions';
15
31
  import type { TemplateIR } from './ir/compiler';
16
32
  import type { StyleIR } from './ir/style';
17
33
  import type { Untrusted } from './ir/policy';
34
+ import type { IRLips, RESERVED } from './ir/facade';
18
35
  /**
19
- * The four typed surfaces of a component. Defaults are permissive on
20
- * purpose: an untyped `lips.render('x', { state: { n: 0 } })` still
21
- * gets `c.state.n` without annotation, and a component that declares
22
- * its metavars gets exact types. Tightening these to `{}` would turn
23
- * every unannotated read into a compile error.
36
+ * What every component of an app reads as `context`. Empty here, so an
37
+ * app types it once, for every component and for `new Lips()`:
38
+ *
39
+ * declare module '@lipsjs/lips' {
40
+ * interface SharedContext { theme: 'dark' | 'light' }
41
+ * }
42
+ *
43
+ * Left empty, `context` reads as `Record<string, any>`.
24
44
  */
25
- export interface Metavars<Input extends Object = Record<string, any>, State extends Object = Record<string, any>, Static extends Object = Record<string, any>, Context extends Object = Record<string, any>> {
26
- Input: Input;
27
- State: State;
28
- Static: Static;
29
- Context: Context;
45
+ export interface SharedContext {
30
46
  }
31
- export type LifeCycleEventTypes = 'onCreate' | 'onInput' | 'onMount' | 'onRender' | 'onUpdate' | 'onAttach' | 'onDetach' | 'onContext' | 'onError' | 'onDestroy';
47
+ type Shared = keyof SharedContext extends never ? Record<string, any> : SharedContext;
48
+ /** The parts a component names; any it leaves out */
49
+ export type Parts = {
50
+ input?: object;
51
+ state?: object;
52
+ static?: object;
53
+ context?: object;
54
+ };
55
+ /** A part `P` names, or `Else` */
56
+ type Part<P, K extends keyof Parts, Else> = P extends {
57
+ [k in K]: infer X extends object;
58
+ } ? X : Else;
32
59
  /**
33
- * `this` inside a handler: reactive stores plus the component's
34
- * own API (emit/on/off, setContext).
60
+ * The four typed parts of a component, by name: what a parent hands it
61
+ * (`input`), what it changes (`state`), what never re-renders (`static`)
62
+ * and what the app shares (`context`).
63
+ *
64
+ * Shape<{ input: { tone: string }, state: { count: number } }>
65
+ *
66
+ * A part it names is exact, a part it leaves out is empty, and `context`
67
+ * is the app's `SharedContext` unless named. Bare, `Shape` reads every
68
+ * part as `any`: the shape of a component nothing typed, and one every
69
+ * typed component is assignable to.
35
70
  */
36
- export interface ComponentSelf<MT extends Metavars = Metavars> {
37
- state: MT['State'];
38
- input: MT['Input'];
39
- context: MT['Context'];
40
- static: MT['Static'];
71
+ export type Shape<P extends Parts = {
72
+ input: any;
73
+ state: any;
74
+ static: any;
75
+ context: any;
76
+ }> = {
77
+ input: Part<P, 'input', {}>;
78
+ state: Part<P, 'state', {}>;
79
+ static: Part<P, 'static', {}>;
80
+ context: Part<P, 'context', Shared>;
81
+ };
82
+ /** The lifecycle, in the order it runs (`onError` and `onContext` when they occur) */
83
+ export interface Hooks {
84
+ onCreate(): void;
85
+ onInput(): void;
86
+ onMount(): void;
87
+ onRender(): void;
88
+ onUpdate(): void;
89
+ onAttach(): void;
90
+ onDetach(): void;
91
+ onContext(): void;
92
+ onError(error: Error): void;
93
+ onDestroy(): void;
94
+ }
95
+ export type HookName = keyof Hooks;
96
+ /** Names a handler cannot take: the component's own members */
97
+ export type ReservedName = typeof RESERVED[number];
98
+ /** The component's own members, in `this` beside its handlers */
99
+ export interface Members<S extends Shape = Shape> {
100
+ state: S['state'];
101
+ input: S['input'];
102
+ context: S['context'];
103
+ static: S['static'];
41
104
  /** Live root elements of this component */
42
105
  readonly node: Element[];
106
+ /**
107
+ * The elements its template names with `@ref="name"`, while they live:
108
+ * `this.refs.search.focus()`. On the DOM each is the element; on Lynx a
109
+ * node that answers `focus`, `blur`, `scrollTo`, `scrollIntoView` and
110
+ * `animate` as the element would.
111
+ */
112
+ readonly refs: Record<string, any>;
43
113
  /**
44
114
  * Active language, read reactively — a bind that reads it re-renders
45
115
  * on `setLanguage()`. Component-grained: a component under
@@ -55,62 +125,115 @@ export interface ComponentSelf<MT extends Metavars = Metavars> {
55
125
  * Also the inbound channel: a listener registered here receives
56
126
  * `component.emit(…)` calls made by whoever holds the handle.
57
127
  */
58
- on(event: string, fn: (...args: any[]) => void): ComponentSelf<MT>;
59
- once(event: string, fn: (...args: any[]) => void): ComponentSelf<MT>;
60
- off(event: string, fn?: (...args: any[]) => void): ComponentSelf<MT>;
128
+ on(event: string, fn: (...args: any[]) => void): this;
129
+ once(event: string, fn: (...args: any[]) => void): this;
130
+ off(event: string, fn?: (...args: any[]) => void): this;
61
131
  setContext(arg: string | Record<string, any>, value?: any): void;
62
- /** Sibling handlers, reachable as `this.otherMethod()` */
63
- [key: string]: any;
64
132
  }
65
- export interface LifecycleEvents<MT extends Metavars> {
66
- onCreate(this: ComponentSelf<MT>): void;
67
- onInput(this: ComponentSelf<MT>): void;
68
- onMount(this: ComponentSelf<MT>): void;
69
- onRender(this: ComponentSelf<MT>): void;
70
- onUpdate(this: ComponentSelf<MT>): void;
71
- onAttach(this: ComponentSelf<MT>): void;
72
- onDetach(this: ComponentSelf<MT>): void;
73
- onContext(this: ComponentSelf<MT>): void;
74
- onError(this: ComponentSelf<MT>, error: Error): void;
75
- onDestroy(this: ComponentSelf<MT>): void;
76
- }
77
- export type Handler<MT extends Metavars> = Partial<LifecycleEvents<MT>> & {
78
- [K in string as K extends keyof LifecycleEvents<MT> ? never : K]?: (this: ComponentSelf<MT>, ...args: any[]) => any;
133
+ /**
134
+ * `this` in a handler: the component's members and its other handlers.
135
+ * `Methods` are the handlers `component()` saw, so a sibling it does not
136
+ * have is an error; left out, any name reads as `any`.
137
+ */
138
+ export type Self<S extends Shape = Shape, Methods = Record<string, any>> = Members<S> & Methods;
139
+ /**
140
+ * A component's `handler` object, typed by hand: for a component written
141
+ * as module exports (`export const handler: Handlers<S> = { … }`), which
142
+ * `component()` cannot see whole. Its `this` reads siblings as `any`.
143
+ */
144
+ export type Handlers<S extends Shape = Shape> = {
145
+ [K in HookName]?: (this: Self<S>, ...args: Parameters<Hooks[K]>) => void;
146
+ } & {
147
+ [K in string as K extends HookName | ReservedName ? never : K]?: (this: Self<S>, ...args: any[]) => any;
79
148
  };
80
- export type Template<MT extends Metavars = Metavars> = {
149
+ /** What `register`, `render`, `root` and a route take */
150
+ export type Component<S extends Shape = Shape> = {
151
+ /**
152
+ * The scope of a component placed by value — a route page, or
153
+ * `<{state.view}/>` — that no `register()` names: its stylesheet's
154
+ * `rel`. Left out, each such object gets one of its own.
155
+ */
156
+ name?: string;
81
157
  /** Template source — the component's markup */
82
158
  default?: string;
83
159
  /** Precompiled template IR — used instead of `default` (see `precompile`) */
84
160
  ir?: TemplateIR;
85
- state?: MT['State'];
161
+ state?: S['state'];
86
162
  /**
87
- * Constants — read as `this.static` in a handler and `static.x` in a
88
- * template. `_static` is the same field: a NAMED MODULE EXPORT cannot
89
- * be called `static` (it is reserved in strict mode, and ES modules
90
- * are always strict), so the underscore exists for that form only.
91
- * Object literals should use `static`.
163
+ * Variables that never re-render — read and written as `this.static` in
164
+ * a handler, read as `static.x` in a template, which subscribes to none
165
+ * of them. Each instance has its own copy, as it has of `state`: what
166
+ * the component declares is where each starts. `_static` is the same
167
+ * field: a NAMED MODULE EXPORT cannot be called `static` (it is reserved
168
+ * in strict mode, and ES modules are always strict), so the underscore
169
+ * exists for that form only. Object literals use `static`.
92
170
  */
93
- static?: MT['Static'];
94
- _static?: MT['Static'];
171
+ static?: S['static'];
172
+ _static?: S['static'];
95
173
  /**
96
174
  * Context fields whose change fires this component's `onContext`.
97
175
  *
98
176
  * It does NOT declare what the component reads: bindings that read
99
177
  * `context.x` are tracked individually and update whether or not `x`
100
- * is listed here. The old spelling for this was `context`, which read
101
- * as "the context this component uses" and misled accordingly.
178
+ * is listed here.
102
179
  */
103
180
  watchContext?: string[];
104
- /** @deprecated Renamed to `watchContext` — same meaning (RFC-005 §4.3) */
105
- context?: string[];
106
181
  /** `<macro [argv] name="X">…</macro>` definitions, inlined at compile time */
107
182
  macros?: string;
108
- handler?: Handler<MT>;
183
+ handler?: Handlers<S>;
109
184
  /** Scoped CSS — declaration values may be `{expr}` (RFC-004) */
110
185
  stylesheet?: string;
111
186
  /** Precompiled StyleIR — used instead of `stylesheet` (see `precompile`) */
112
187
  style?: StyleIR;
113
188
  };
189
+ /** Marks a component that carries its shape; type-only, never set */
190
+ declare const SHAPE: unique symbol;
191
+ /**
192
+ * A component whose shape is known, so `render()` reads it back: what
193
+ * `component()` and `precompile()` return.
194
+ */
195
+ export type TypedComponent<S extends Shape = Shape> = Component<S> & {
196
+ readonly [SHAPE]: S;
197
+ };
198
+ /**
199
+ * A component being written, its state, static and handlers inferred:
200
+ * what `component()` takes, and what `register`, `render` and `root` take
201
+ * written in the call. Each handler's `this` is the component's members
202
+ * and every handler beside it. A `TypedComponent` is not one: its shape is
203
+ * already known.
204
+ */
205
+ export type Definition<S extends Shape, Methods> = Omit<Component<S>, 'handler'> & {
206
+ readonly [SHAPE]?: never;
207
+ handler?: Methods & Partial<Hooks> & {
208
+ [K in ReservedName]?: never;
209
+ } & ThisType<Self<S, Methods>>;
210
+ };
211
+ /**
212
+ * The shape a `Definition` gives: what `P` names, else what was inferred.
213
+ * Written in a `register`, `render` or `root` call, nothing names `input`,
214
+ * so it reads as `Record<string, any>` there (or as what `render()` is
215
+ * handed).
216
+ */
217
+ export type Inferred<P extends Parts, State, Static> = {
218
+ input: Part<P, 'input', {}>;
219
+ state: Part<P, 'state', State>;
220
+ static: Part<P, 'static', Static>;
221
+ context: Part<P, 'context', Shared>;
222
+ };
223
+ /**
224
+ * What `lips.use()` installs: a library of components (`@lipsjs/lips/parts`
225
+ * is one), what it needs installed before it, and its own setup.
226
+ */
227
+ export interface Plugin<Options = unknown> {
228
+ /** Installed once per Lips, however many times it is used or required */
229
+ readonly name: string;
230
+ /** Installed before it, each once */
231
+ readonly requires?: readonly Plugin<any>[];
232
+ /** Registered by name; a name something else holds is refused */
233
+ readonly components?: Readonly<Record<string, Component<any>>>;
234
+ /** Anything else it sets up, with what `use()` was given */
235
+ install?(lips: IRLips<any>, options?: Options): void;
236
+ }
114
237
  export type LipsConfig<Context extends Object = {}> = {
115
238
  debug?: boolean;
116
239
  context?: Context;
@@ -200,3 +323,4 @@ export type MessageFormatEngine = {
200
323
  };
201
324
  /** One language's messages, by stable key or by source text. */
202
325
  export type Dictionary = Record<string, Message>;
326
+ export {};