chore: add package info
This commit is contained in:
parent
c26a095fef
commit
71b81704e6
10 changed files with 75 additions and 2 deletions
3
lib/index.d.mts
Normal file
3
lib/index.d.mts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export * from "./str.mjs";
|
||||||
|
export * from "./nodes.mjs";
|
||||||
|
export * from "./types.mjs";
|
3
lib/index.mjs
Normal file
3
lib/index.mjs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export * from "./str.mjs";
|
||||||
|
export * from "./nodes.mjs";
|
||||||
|
export * from "./types.mjs";
|
5
lib/lang.d.mts
Normal file
5
lib/lang.d.mts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export declare function isNil<T>(v: Nilable<T>): v is Nil;
|
||||||
|
export declare type Nullable<T> = T | null;
|
||||||
|
export declare type Nilable<T> = T | Nil;
|
||||||
|
export declare type Nil = null | undefined;
|
||||||
|
export declare function isBool(v: unknown): v is boolean;
|
30
lib/nodes.d.mts
Normal file
30
lib/nodes.d.mts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import { Nilable } from "./lang.mjs";
|
||||||
|
export declare type AnyNode = AnySyncNode | AnyAsyncNode;
|
||||||
|
export declare type AnyAsyncNode = Promise<AnySyncNode>;
|
||||||
|
export declare type AnySyncNode = TextNode | Elem | Frag;
|
||||||
|
export declare class TextNode extends String {
|
||||||
|
}
|
||||||
|
export declare function F(children: AnyNode[]): Frag;
|
||||||
|
export declare class Frag {
|
||||||
|
#private;
|
||||||
|
constructor();
|
||||||
|
get children(): Nilable<AnyNode[]>;
|
||||||
|
withText(text: string): this;
|
||||||
|
addText(text: string): void;
|
||||||
|
maybeWithChildren(nodes?: Nilable<AnyNode[]>): this;
|
||||||
|
withChildren(nodes: AnyNode[]): this;
|
||||||
|
withChild(node: AnyNode): this;
|
||||||
|
addChild(node: AnyNode): void;
|
||||||
|
}
|
||||||
|
export declare function E(tagName: string, attrs: ElemAttrs, children?: Nilable<AnyNode[]>): Elem;
|
||||||
|
export declare type ElemAttrs = Record<string, unknown>;
|
||||||
|
export declare class Elem extends Frag {
|
||||||
|
#private;
|
||||||
|
constructor(tagName: string);
|
||||||
|
get tagName(): string;
|
||||||
|
get attrs(): Record<string, unknown>;
|
||||||
|
withAttrs(attrs: Record<string, unknown>): Elem;
|
||||||
|
withAttr(name: string, value: unknown): Elem;
|
||||||
|
addAttr(name: string, value: unknown): void;
|
||||||
|
addChild(node: AnySyncNode): void;
|
||||||
|
}
|
5
lib/str.d.mts
Normal file
5
lib/str.d.mts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { Renderer } from "./types.mjs";
|
||||||
|
import { Elem } from "./nodes.mjs";
|
||||||
|
export declare class StrRenderer implements Renderer<string> {
|
||||||
|
render(node: Elem | Promise<Elem>): Promise<string>;
|
||||||
|
}
|
4
lib/types.d.mts
Normal file
4
lib/types.d.mts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import { Elem } from "./nodes.mjs";
|
||||||
|
export interface Renderer<T> {
|
||||||
|
render(node: Elem | Promise<Elem>): Promise<T>;
|
||||||
|
}
|
2
makefile
2
makefile
|
@ -6,4 +6,4 @@ ts-w:
|
||||||
npx tsc-watch
|
npx tsc-watch
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf target
|
rm -rf lib
|
||||||
|
|
21
package.json
21
package.json
|
@ -1,4 +1,13 @@
|
||||||
{
|
{
|
||||||
|
"name": "ren",
|
||||||
|
"description": "",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"main": "lib/index.mjs",
|
||||||
|
"types": "lib/index.d.mts",
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib",
|
||||||
|
"src": "src"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^17.0.21",
|
"@types/node": "^17.0.21",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
||||||
|
@ -9,5 +18,15 @@
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"tsc-watch": "^4.6.0",
|
"tsc-watch": "^4.6.0",
|
||||||
"typescript": "^4.6.2"
|
"typescript": "^4.6.2"
|
||||||
}
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/pleshevskiy/ren.git"
|
||||||
|
},
|
||||||
|
"author": "Dmitriy Pleshevskiy <dmitriy@ideascup.me>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/pleshevskiy/ren/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/pleshevskiy/ren#readme"
|
||||||
}
|
}
|
||||||
|
|
3
src/index.mts
Normal file
3
src/index.mts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export * from "./str.mjs";
|
||||||
|
export * from "./nodes.mjs";
|
||||||
|
export * from "./types.mjs";
|
|
@ -5,6 +5,7 @@
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"lib": ["dom", "esNext"],
|
"lib": ["dom", "esNext"],
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
|
"declaration": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"suppressImplicitAnyIndexErrors": true,
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
|
Reference in a new issue