@solidjs/html 2.0.0-rc.2 → 2.0.0-rc.3
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 +1 -1
- package/dist/html.cjs +520 -13
- package/dist/html.js +521 -14
- package/package.json +11 -11
- package/types/index.d.ts +1 -3
- package/types/parse.d.ts +67 -0
- package/types/tagged-jsx.d.ts +4 -12567
- package/types/tokenize.d.ts +43 -0
- package/types/types.d.ts +51 -0
- package/types-cjs/index.d.cts +1 -3
- package/types-cjs/parse.d.cts +67 -0
- package/types-cjs/tagged-jsx.d.cts +4 -12567
- package/types-cjs/tokenize.d.cts +43 -0
- package/types-cjs/types.d.cts +51 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const OPEN_TAG_TOKEN = 0;
|
|
2
|
+
export declare const CLOSE_TAG_TOKEN = 1;
|
|
3
|
+
export declare const SLASH_TOKEN = 2;
|
|
4
|
+
export declare const IDENTIFIER_TOKEN = 3;
|
|
5
|
+
export declare const EQUALS_TOKEN = 4;
|
|
6
|
+
export declare const STRING_TOKEN = 5;
|
|
7
|
+
export declare const TEXT_TOKEN = 6;
|
|
8
|
+
export declare const EXPRESSION_TOKEN = 7;
|
|
9
|
+
export declare const SPREAD_TOKEN = 8;
|
|
10
|
+
export interface OpenTagToken {
|
|
11
|
+
type: typeof OPEN_TAG_TOKEN;
|
|
12
|
+
}
|
|
13
|
+
export interface CloseTagToken {
|
|
14
|
+
type: typeof CLOSE_TAG_TOKEN;
|
|
15
|
+
}
|
|
16
|
+
export interface SlashToken {
|
|
17
|
+
type: typeof SLASH_TOKEN;
|
|
18
|
+
}
|
|
19
|
+
export interface IdentifierToken {
|
|
20
|
+
type: typeof IDENTIFIER_TOKEN;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
export interface EqualsToken {
|
|
24
|
+
type: typeof EQUALS_TOKEN;
|
|
25
|
+
}
|
|
26
|
+
export interface StringToken {
|
|
27
|
+
type: typeof STRING_TOKEN;
|
|
28
|
+
value: string;
|
|
29
|
+
quote: "'" | '"';
|
|
30
|
+
}
|
|
31
|
+
export interface TextToken {
|
|
32
|
+
type: typeof TEXT_TOKEN;
|
|
33
|
+
value: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SpreadToken {
|
|
36
|
+
type: typeof SPREAD_TOKEN;
|
|
37
|
+
}
|
|
38
|
+
export interface ExpressionToken {
|
|
39
|
+
type: typeof EXPRESSION_TOKEN;
|
|
40
|
+
value: number;
|
|
41
|
+
}
|
|
42
|
+
export type Token = OpenTagToken | CloseTagToken | SlashToken | IdentifierToken | EqualsToken | StringToken | TextToken | ExpressionToken | SpreadToken;
|
|
43
|
+
export declare const tokenize: (strings: TemplateStringsArray | string[], rawTextElements: Set<string>) => Token[];
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
export type FunctionComponent = (...args: any[]) => any;
|
|
3
|
+
/**
|
|
4
|
+
* Component registry type
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const components: ComponentRegistry = {
|
|
8
|
+
* MyComponent: (props) => <div>Hello {props.name}</div>
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export type ComponentRegistry = Record<string, FunctionComponent>;
|
|
13
|
+
/**
|
|
14
|
+
* Tagged JSX instance type
|
|
15
|
+
* @template T Component registry
|
|
16
|
+
*/
|
|
17
|
+
export type TaggedJSXInstance<T extends ComponentRegistry> = {
|
|
18
|
+
/**
|
|
19
|
+
* Tagged JSX template function
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const myTemplate = html`<div>Hello World</div>`
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
(strings: TemplateStringsArray, ...values: any[]): JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* Self reference to tagged JSX instance for tooling
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const MyComponent: FunctionComponent = (props) => {
|
|
31
|
+
* // Use html to create a template inside a component
|
|
32
|
+
* return myTaggedJSX.jsx`<div>Hello ${props.name}</div>`
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
jsx: TaggedJSXInstance<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new tagged JSX instance with additional components added to the registry
|
|
38
|
+
* @param components New components to add to the registry
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const MyComponent: FunctionComponent = (props) => <div>Hello {props.name}</div>
|
|
42
|
+
* const myTaggedJSX = html.define({MyComponent})
|
|
43
|
+
* const myTemplate = myTaggedJSX`<MyComponent name="World" />`
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
define<TNew extends ComponentRegistry>(components: TNew): TaggedJSXInstance<T & TNew>;
|
|
47
|
+
/**
|
|
48
|
+
* Component registry
|
|
49
|
+
*/
|
|
50
|
+
components: T;
|
|
51
|
+
};
|
package/types-cjs/index.d.cts
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Token } from "./tokenize.cjs";
|
|
2
|
+
export declare const ROOT_NODE = 0;
|
|
3
|
+
export declare const ELEMENT_NODE = 1;
|
|
4
|
+
export declare const COMPONENT_NODE = 2;
|
|
5
|
+
export declare const TEXT_NODE = 3;
|
|
6
|
+
export declare const EXPRESSION_NODE = 4;
|
|
7
|
+
export declare const BOOLEAN_PROP = 0;
|
|
8
|
+
export declare const STATIC_PROP = 1;
|
|
9
|
+
export declare const EXPRESSION_PROP = 2;
|
|
10
|
+
export declare const SPREAD_PROP = 3;
|
|
11
|
+
export type NodeType = typeof ROOT_NODE | typeof ELEMENT_NODE | typeof COMPONENT_NODE | typeof TEXT_NODE | typeof EXPRESSION_NODE;
|
|
12
|
+
export type PropType = typeof BOOLEAN_PROP | typeof STATIC_PROP | typeof EXPRESSION_PROP | typeof SPREAD_PROP;
|
|
13
|
+
export type ChildNode = ElementNode | TextNode | ExpressionNode | ComponentNode;
|
|
14
|
+
export interface RootNode {
|
|
15
|
+
type: typeof ROOT_NODE;
|
|
16
|
+
children: ChildNode[];
|
|
17
|
+
}
|
|
18
|
+
export interface ElementNode {
|
|
19
|
+
type: typeof ELEMENT_NODE;
|
|
20
|
+
name: string;
|
|
21
|
+
props: PropNode[];
|
|
22
|
+
children: ChildNode[];
|
|
23
|
+
template?: HTMLTemplateElement;
|
|
24
|
+
/**
|
|
25
|
+
* Element-claim contract target (`a[href]`, `form[action]`, or a spread
|
|
26
|
+
* that may carry those). Stamped at template build — before static props
|
|
27
|
+
* are filtered out — so clones can be claimed even when the attribute was
|
|
28
|
+
* baked into the template.
|
|
29
|
+
*/
|
|
30
|
+
claim?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface ComponentNode {
|
|
33
|
+
type: typeof COMPONENT_NODE;
|
|
34
|
+
name: string | number;
|
|
35
|
+
props: PropNode[];
|
|
36
|
+
children: ChildNode[];
|
|
37
|
+
}
|
|
38
|
+
export interface TextNode {
|
|
39
|
+
type: typeof TEXT_NODE;
|
|
40
|
+
value: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ExpressionNode {
|
|
43
|
+
type: typeof EXPRESSION_NODE;
|
|
44
|
+
value: number;
|
|
45
|
+
}
|
|
46
|
+
export interface BooleanProp {
|
|
47
|
+
name: string;
|
|
48
|
+
type: typeof BOOLEAN_PROP;
|
|
49
|
+
value: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface StringProp {
|
|
52
|
+
name: string;
|
|
53
|
+
type: typeof STATIC_PROP;
|
|
54
|
+
value: string;
|
|
55
|
+
quote?: "'" | '"';
|
|
56
|
+
}
|
|
57
|
+
export interface ExpressionProp {
|
|
58
|
+
name: string;
|
|
59
|
+
type: typeof EXPRESSION_PROP;
|
|
60
|
+
value: number;
|
|
61
|
+
}
|
|
62
|
+
export interface SpreadProp {
|
|
63
|
+
type: typeof SPREAD_PROP;
|
|
64
|
+
value: number;
|
|
65
|
+
}
|
|
66
|
+
export type PropNode = BooleanProp | StringProp | ExpressionProp | SpreadProp;
|
|
67
|
+
export declare const parse: (tokens: Token[], voidElements: Set<string>) => RootNode;
|