@solidjs/html 2.0.0-rc.1 → 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[];
|
|
@@ -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/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2016-2025 Ryan Carniato
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|