@sigil-dev/types 0.9.20 → 0.9.22
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 +9 -9
- package/index.d.ts +167 -167
- package/package.json +1 -1
- package/sigil-node.d.ts +9 -9
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# @sigil-dev/types
|
|
2
|
-
|
|
3
|
-
TypeScript types for [Sigil](https://sigil.cane1712.dev): the JSX namespace and the compile-time macros `$state`, `$derived` and `$effect`, plus the `Component` type. Projects made with `sigil create` already have it; install it yourself only when setting up a project by hand.
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
bun add -d @sigil-dev/types
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
**Docs:** [sigil.cane1712.dev/docs/reference/macros](https://sigil.cane1712.dev/docs/reference/macros)
|
|
1
|
+
# @sigil-dev/types
|
|
2
|
+
|
|
3
|
+
TypeScript types for [Sigil](https://sigil.cane1712.dev): the JSX namespace and the compile-time macros `$state`, `$derived` and `$effect`, plus the `Component` type. Projects made with `sigil create` already have it; install it yourself only when setting up a project by hand.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
bun add -d @sigil-dev/types
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
**Docs:** [sigil.cane1712.dev/docs/reference/macros](https://sigil.cane1712.dev/docs/reference/macros)
|
package/index.d.ts
CHANGED
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/// <reference path="sigil-node.d.ts" />
|
|
3
|
-
/**
|
|
4
|
-
* Declare reactive state
|
|
5
|
-
*/
|
|
6
|
-
declare function $state<T>(initial: T): T;
|
|
7
|
-
|
|
8
|
-
declare namespace $state {
|
|
9
|
-
/**
|
|
10
|
-
* Create state without Proxy wrapping for objects/arrays
|
|
11
|
-
*/
|
|
12
|
-
export function raw<T>(initial: T): T;
|
|
13
|
-
/**
|
|
14
|
-
* Un-proxy a signal value to get a plain snapshot
|
|
15
|
-
*/
|
|
16
|
-
export function snapshot<T>(value: T): T;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Declare reactive state meant to be exported and shared between modules
|
|
21
|
-
*/
|
|
22
|
-
declare function $store<T>(initial: T): T;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Declare derived state
|
|
26
|
-
*/
|
|
27
|
-
declare function $derived<T>(expression: T): T;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Declare a side effect
|
|
31
|
-
*/
|
|
32
|
-
declare function $effect(fn: () => undefined | (() => void)): void;
|
|
33
|
-
|
|
34
|
-
declare namespace $effect {
|
|
35
|
-
/**
|
|
36
|
-
* Check if inside a reactive tracking context
|
|
37
|
-
*/
|
|
38
|
-
export function tracking(): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Effect that flushes before DOM update
|
|
41
|
-
*/
|
|
42
|
-
export function pre(fn: () => undefined | (() => void)): void;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Dev-only reactive inspect
|
|
47
|
-
*/
|
|
48
|
-
declare function $inspect(...vals: unknown[]): void;
|
|
49
|
-
|
|
50
|
-
/** `use={fn}`: called with the element when it is created; may return a cleanup. */
|
|
51
|
-
type SigilDirective = (element: any, ...args: any[]) => unknown;
|
|
52
|
-
|
|
53
|
-
interface SigilBaseProps {
|
|
54
|
-
class?: string;
|
|
55
|
-
style?: React.CSSProperties | string;
|
|
56
|
-
/** Anything renderable: nodes, text, numbers, arrays, nothing. */
|
|
57
|
-
children?: unknown;
|
|
58
|
-
/** Identifies an item in a list, so it is moved rather than rebuilt. */
|
|
59
|
-
key?: string | number;
|
|
60
|
-
/** `use={fn}`, `use={[fn, options]}`, or several: `use={[a, [b, options]]}`. */
|
|
61
|
-
use?: SigilDirective | readonly unknown[];
|
|
62
|
-
/** The element itself, assigned to a `$state`. */
|
|
63
|
-
"bind:this"?: unknown;
|
|
64
|
-
bindThis?: unknown;
|
|
65
|
-
/** An animation played when the element appears and disappears. */
|
|
66
|
-
[transition: `transition:${string}`]: unknown;
|
|
67
|
-
[enter: `in:${string}`]: unknown;
|
|
68
|
-
[leave: `out:${string}`]: unknown;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface SigilBindProps {
|
|
72
|
-
"bind:value"?: unknown;
|
|
73
|
-
"bind:checked"?: unknown;
|
|
74
|
-
"bind:group"?: unknown;
|
|
75
|
-
bindValue?: string | number;
|
|
76
|
-
bindChecked?: boolean;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Sigil hands a handler the browser's own event, not a React synthetic one:
|
|
81
|
-
* `onClick={(e: MouseEvent) => …}`, with `currentTarget` typed as the element.
|
|
82
|
-
*/
|
|
83
|
-
type NativeHandler<H> = H extends ((event: infer E) => unknown) | undefined
|
|
84
|
-
? E extends React.SyntheticEvent<infer Target, infer Native>
|
|
85
|
-
? ((event: Native & { currentTarget: Target }) => unknown) | undefined
|
|
86
|
-
: H
|
|
87
|
-
: H;
|
|
88
|
-
|
|
89
|
-
type NativeHandlers<T> = {
|
|
90
|
-
[K in keyof T]: K extends `on${string}` ? NativeHandler<T[K]> : T[K];
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* HTML's own spelling of every camelCase prop: `onclick`, `spellcheck`,
|
|
95
|
-
* `autocomplete`, `tabindex`, `readonly`. Sigil passes attributes through as
|
|
96
|
-
* written, and the browser reads them case-insensitively.
|
|
97
|
-
*/
|
|
98
|
-
type LowercaseHandlers<T> = {
|
|
99
|
-
[K in keyof T as K extends string
|
|
100
|
-
? Lowercase<K> extends K
|
|
101
|
-
? never
|
|
102
|
-
: Lowercase<K>
|
|
103
|
-
: never]?: K extends `on${string}` ? NativeHandler<T[K]> : T[K];
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
type SigilIntrinsicElements = {
|
|
107
|
-
[K in keyof React.JSX.IntrinsicElements]: Omit<
|
|
108
|
-
NativeHandlers<React.JSX.IntrinsicElements[K]>,
|
|
109
|
-
"style" | "children"
|
|
110
|
-
> &
|
|
111
|
-
SigilBaseProps &
|
|
112
|
-
LowercaseHandlers<React.JSX.IntrinsicElements[K]>;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The hydration state the server embeds in the document, and the shape a
|
|
118
|
-
* streamed value takes in it.
|
|
119
|
-
*
|
|
120
|
-
* Declared here because every app that reads a streamed value has been
|
|
121
|
-
* re-declaring this by hand — the same three fields, with the `nodeType`
|
|
122
|
-
* guard that the runtime really needs and nobody remembers to write.
|
|
123
|
-
*/
|
|
124
|
-
interface GrimoireState {
|
|
125
|
-
/** The route pattern this document was rendered for. */
|
|
126
|
-
pattern: string;
|
|
127
|
-
/** Rendered load data. A value still in flight is absent until it settles. */
|
|
128
|
-
data?: Record<string, unknown>;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
interface Window {
|
|
132
|
-
/**
|
|
133
|
-
* Mirrors `__grimoire_state__`. The element carries the authoritative
|
|
134
|
-
* copy, but a late patch script can arrive before the element is parsed,
|
|
135
|
-
* so the runtime falls back to this object. `nodeType` is how the
|
|
136
|
-
* difference is told apart: the element has one, the plain object does
|
|
137
|
-
* not.
|
|
138
|
-
*/
|
|
139
|
-
__grimoire_state__?: GrimoireState | HTMLElement;
|
|
140
|
-
/** Public environment values, as the server saw them. */
|
|
141
|
-
__grimoire_env__?: Record<string, string>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
declare namespace JSX {
|
|
145
|
-
type Element = React.JSX.Element;
|
|
146
|
-
/**
|
|
147
|
-
* What may be used as a component. A Sigil component returns DOM nodes,
|
|
148
|
-
* text or nothing rather than a React element, so any function counts.
|
|
149
|
-
*/
|
|
150
|
-
type ElementType =
|
|
151
|
-
| keyof IntrinsicElements
|
|
152
|
-
| ((props: any) => unknown)
|
|
153
|
-
| (new (props: any) => unknown);
|
|
154
|
-
interface ElementClass extends React.JSX.ElementClass {}
|
|
155
|
-
interface ElementAttributesProperty
|
|
156
|
-
extends React.JSX.ElementAttributesProperty {}
|
|
157
|
-
interface ElementChildrenAttribute {
|
|
158
|
-
children: {};
|
|
159
|
-
}
|
|
160
|
-
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
|
|
161
|
-
|
|
162
|
-
interface IntrinsicElements extends SigilIntrinsicElements {
|
|
163
|
-
input: SigilIntrinsicElements["input"] & SigilBindProps;
|
|
164
|
-
textarea: SigilIntrinsicElements["textarea"] & SigilBindProps;
|
|
165
|
-
select: SigilIntrinsicElements["select"] & SigilBindProps;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference path="sigil-node.d.ts" />
|
|
3
|
+
/**
|
|
4
|
+
* Declare reactive state
|
|
5
|
+
*/
|
|
6
|
+
declare function $state<T>(initial: T): T;
|
|
7
|
+
|
|
8
|
+
declare namespace $state {
|
|
9
|
+
/**
|
|
10
|
+
* Create state without Proxy wrapping for objects/arrays
|
|
11
|
+
*/
|
|
12
|
+
export function raw<T>(initial: T): T;
|
|
13
|
+
/**
|
|
14
|
+
* Un-proxy a signal value to get a plain snapshot
|
|
15
|
+
*/
|
|
16
|
+
export function snapshot<T>(value: T): T;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Declare reactive state meant to be exported and shared between modules
|
|
21
|
+
*/
|
|
22
|
+
declare function $store<T>(initial: T): T;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Declare derived state
|
|
26
|
+
*/
|
|
27
|
+
declare function $derived<T>(expression: T): T;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Declare a side effect
|
|
31
|
+
*/
|
|
32
|
+
declare function $effect(fn: () => undefined | (() => void)): void;
|
|
33
|
+
|
|
34
|
+
declare namespace $effect {
|
|
35
|
+
/**
|
|
36
|
+
* Check if inside a reactive tracking context
|
|
37
|
+
*/
|
|
38
|
+
export function tracking(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Effect that flushes before DOM update
|
|
41
|
+
*/
|
|
42
|
+
export function pre(fn: () => undefined | (() => void)): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Dev-only reactive inspect
|
|
47
|
+
*/
|
|
48
|
+
declare function $inspect(...vals: unknown[]): void;
|
|
49
|
+
|
|
50
|
+
/** `use={fn}`: called with the element when it is created; may return a cleanup. */
|
|
51
|
+
type SigilDirective = (element: any, ...args: any[]) => unknown;
|
|
52
|
+
|
|
53
|
+
interface SigilBaseProps {
|
|
54
|
+
class?: string;
|
|
55
|
+
style?: React.CSSProperties | string;
|
|
56
|
+
/** Anything renderable: nodes, text, numbers, arrays, nothing. */
|
|
57
|
+
children?: unknown;
|
|
58
|
+
/** Identifies an item in a list, so it is moved rather than rebuilt. */
|
|
59
|
+
key?: string | number;
|
|
60
|
+
/** `use={fn}`, `use={[fn, options]}`, or several: `use={[a, [b, options]]}`. */
|
|
61
|
+
use?: SigilDirective | readonly unknown[];
|
|
62
|
+
/** The element itself, assigned to a `$state`. */
|
|
63
|
+
"bind:this"?: unknown;
|
|
64
|
+
bindThis?: unknown;
|
|
65
|
+
/** An animation played when the element appears and disappears. */
|
|
66
|
+
[transition: `transition:${string}`]: unknown;
|
|
67
|
+
[enter: `in:${string}`]: unknown;
|
|
68
|
+
[leave: `out:${string}`]: unknown;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface SigilBindProps {
|
|
72
|
+
"bind:value"?: unknown;
|
|
73
|
+
"bind:checked"?: unknown;
|
|
74
|
+
"bind:group"?: unknown;
|
|
75
|
+
bindValue?: string | number;
|
|
76
|
+
bindChecked?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Sigil hands a handler the browser's own event, not a React synthetic one:
|
|
81
|
+
* `onClick={(e: MouseEvent) => …}`, with `currentTarget` typed as the element.
|
|
82
|
+
*/
|
|
83
|
+
type NativeHandler<H> = H extends ((event: infer E) => unknown) | undefined
|
|
84
|
+
? E extends React.SyntheticEvent<infer Target, infer Native>
|
|
85
|
+
? ((event: Native & { currentTarget: Target }) => unknown) | undefined
|
|
86
|
+
: H
|
|
87
|
+
: H;
|
|
88
|
+
|
|
89
|
+
type NativeHandlers<T> = {
|
|
90
|
+
[K in keyof T]: K extends `on${string}` ? NativeHandler<T[K]> : T[K];
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* HTML's own spelling of every camelCase prop: `onclick`, `spellcheck`,
|
|
95
|
+
* `autocomplete`, `tabindex`, `readonly`. Sigil passes attributes through as
|
|
96
|
+
* written, and the browser reads them case-insensitively.
|
|
97
|
+
*/
|
|
98
|
+
type LowercaseHandlers<T> = {
|
|
99
|
+
[K in keyof T as K extends string
|
|
100
|
+
? Lowercase<K> extends K
|
|
101
|
+
? never
|
|
102
|
+
: Lowercase<K>
|
|
103
|
+
: never]?: K extends `on${string}` ? NativeHandler<T[K]> : T[K];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type SigilIntrinsicElements = {
|
|
107
|
+
[K in keyof React.JSX.IntrinsicElements]: Omit<
|
|
108
|
+
NativeHandlers<React.JSX.IntrinsicElements[K]>,
|
|
109
|
+
"style" | "children"
|
|
110
|
+
> &
|
|
111
|
+
SigilBaseProps &
|
|
112
|
+
LowercaseHandlers<React.JSX.IntrinsicElements[K]>;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The hydration state the server embeds in the document, and the shape a
|
|
118
|
+
* streamed value takes in it.
|
|
119
|
+
*
|
|
120
|
+
* Declared here because every app that reads a streamed value has been
|
|
121
|
+
* re-declaring this by hand — the same three fields, with the `nodeType`
|
|
122
|
+
* guard that the runtime really needs and nobody remembers to write.
|
|
123
|
+
*/
|
|
124
|
+
interface GrimoireState {
|
|
125
|
+
/** The route pattern this document was rendered for. */
|
|
126
|
+
pattern: string;
|
|
127
|
+
/** Rendered load data. A value still in flight is absent until it settles. */
|
|
128
|
+
data?: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface Window {
|
|
132
|
+
/**
|
|
133
|
+
* Mirrors `__grimoire_state__`. The element carries the authoritative
|
|
134
|
+
* copy, but a late patch script can arrive before the element is parsed,
|
|
135
|
+
* so the runtime falls back to this object. `nodeType` is how the
|
|
136
|
+
* difference is told apart: the element has one, the plain object does
|
|
137
|
+
* not.
|
|
138
|
+
*/
|
|
139
|
+
__grimoire_state__?: GrimoireState | HTMLElement;
|
|
140
|
+
/** Public environment values, as the server saw them. */
|
|
141
|
+
__grimoire_env__?: Record<string, string>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare namespace JSX {
|
|
145
|
+
type Element = React.JSX.Element;
|
|
146
|
+
/**
|
|
147
|
+
* What may be used as a component. A Sigil component returns DOM nodes,
|
|
148
|
+
* text or nothing rather than a React element, so any function counts.
|
|
149
|
+
*/
|
|
150
|
+
type ElementType =
|
|
151
|
+
| keyof IntrinsicElements
|
|
152
|
+
| ((props: any) => unknown)
|
|
153
|
+
| (new (props: any) => unknown);
|
|
154
|
+
interface ElementClass extends React.JSX.ElementClass {}
|
|
155
|
+
interface ElementAttributesProperty
|
|
156
|
+
extends React.JSX.ElementAttributesProperty {}
|
|
157
|
+
interface ElementChildrenAttribute {
|
|
158
|
+
children: {};
|
|
159
|
+
}
|
|
160
|
+
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
|
|
161
|
+
|
|
162
|
+
interface IntrinsicElements extends SigilIntrinsicElements {
|
|
163
|
+
input: SigilIntrinsicElements["input"] & SigilBindProps;
|
|
164
|
+
textarea: SigilIntrinsicElements["textarea"] & SigilBindProps;
|
|
165
|
+
select: SigilIntrinsicElements["select"] & SigilBindProps;
|
|
166
|
+
}
|
|
167
|
+
}
|
package/package.json
CHANGED
package/sigil-node.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// packages/types/src/sigil-node.d.ts
|
|
2
|
-
type SigilNode =
|
|
3
|
-
| string
|
|
4
|
-
| number
|
|
5
|
-
| boolean
|
|
6
|
-
| null
|
|
7
|
-
| undefined
|
|
8
|
-
| SigilNode[]
|
|
9
|
-
| JSX.Element;
|
|
1
|
+
// packages/types/src/sigil-node.d.ts
|
|
2
|
+
type SigilNode =
|
|
3
|
+
| string
|
|
4
|
+
| number
|
|
5
|
+
| boolean
|
|
6
|
+
| null
|
|
7
|
+
| undefined
|
|
8
|
+
| SigilNode[]
|
|
9
|
+
| JSX.Element;
|