chore: add package info

This commit is contained in:
Dmitriy Pleshevskiy 2022-03-16 22:45:15 +03:00
parent c26a095fef
commit 71b81704e6
10 changed files with 75 additions and 2 deletions

3
lib/index.d.mts Normal file
View File

@ -0,0 +1,3 @@
export * from "./str.mjs";
export * from "./nodes.mjs";
export * from "./types.mjs";

3
lib/index.mjs Normal file
View File

@ -0,0 +1,3 @@
export * from "./str.mjs";
export * from "./nodes.mjs";
export * from "./types.mjs";

5
lib/lang.d.mts Normal file
View 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
View 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
View 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
View File

@ -0,0 +1,4 @@
import { Elem } from "./nodes.mjs";
export interface Renderer<T> {
render(node: Elem | Promise<Elem>): Promise<T>;
}

View File

@ -6,4 +6,4 @@ ts-w:
npx tsc-watch
clean:
rm -rf target
rm -rf lib

View File

@ -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": {
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.14.0",
@ -9,5 +18,15 @@
"prettier": "^2.5.1",
"tsc-watch": "^4.6.0",
"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
View File

@ -0,0 +1,3 @@
export * from "./str.mjs";
export * from "./nodes.mjs";
export * from "./types.mjs";

View File

@ -5,6 +5,7 @@
"module": "ESNext",
"lib": ["dom", "esNext"],
"moduleResolution": "node",
"declaration": true,
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"suppressImplicitAnyIndexErrors": true,