@geektech/tsone 0.0.1
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/LICENSE +21 -0
- package/README.md +176 -0
- package/dist/core/app.d.ts +92 -0
- package/dist/core/component/base.d.ts +53 -0
- package/dist/core/component/index.d.ts +4 -0
- package/dist/core/component.d.ts +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/reactive/types.d.ts +19 -0
- package/dist/core/reactive.d.ts +31 -0
- package/dist/core/renderer/props.d.ts +9 -0
- package/dist/core/renderer/types.d.ts +31 -0
- package/dist/core/renderer.d.ts +57 -0
- package/dist/core/template.d.ts +50 -0
- package/dist/core/vnode.d.ts +64 -0
- package/dist/index-3j2jsdpc.js +1498 -0
- package/dist/index-3j2jsdpc.js.map +20 -0
- package/dist/index-dgv88dz4.js +59 -0
- package/dist/index-dgv88dz4.js.map +10 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +248 -0
- package/dist/index.js.map +11 -0
- package/dist/router/history.d.ts +5 -0
- package/dist/router/index.d.ts +88 -0
- package/dist/router/index.js +16 -0
- package/dist/router/index.js.map +9 -0
- package/dist/router/instance.d.ts +26 -0
- package/dist/router/matcher.d.ts +7 -0
- package/dist/style/StyleManager.d.ts +16 -0
- package/dist/style/class-style.d.ts +0 -0
- package/dist/style/id-style.d.ts +0 -0
- package/dist/style/index.d.ts +1 -0
- package/dist/style/index.js +9 -0
- package/dist/style/index.js.map +9 -0
- package/dist/style/style.d.ts +0 -0
- package/package.json +66 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AnyComponentConstructor, Component } from '../core/component';
|
|
2
|
+
import { OneApp } from '../core/app';
|
|
3
|
+
import type { VNode } from '../core/vnode';
|
|
4
|
+
export type RouteMeta = Record<string, unknown>;
|
|
5
|
+
export interface RouteRecord {
|
|
6
|
+
path: string;
|
|
7
|
+
component: AnyComponentConstructor;
|
|
8
|
+
name?: string;
|
|
9
|
+
meta?: RouteMeta;
|
|
10
|
+
}
|
|
11
|
+
export interface RouterOptions {
|
|
12
|
+
routes: RouteRecord[];
|
|
13
|
+
mode?: 'history' | 'hash';
|
|
14
|
+
base?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RouteLocation {
|
|
17
|
+
path: string;
|
|
18
|
+
query: Record<string, string>;
|
|
19
|
+
params: Record<string, string>;
|
|
20
|
+
fullPath: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
meta?: RouteMeta;
|
|
23
|
+
}
|
|
24
|
+
export type RouteChangeListener = (to: RouteLocation, from: RouteLocation | null) => void;
|
|
25
|
+
export declare class Router {
|
|
26
|
+
protected currentRoute: RouteRecord | null;
|
|
27
|
+
protected currentLocation: RouteLocation | null;
|
|
28
|
+
private readonly routes;
|
|
29
|
+
private app;
|
|
30
|
+
private readonly mode;
|
|
31
|
+
private readonly base;
|
|
32
|
+
private readonly routeChangeListeners;
|
|
33
|
+
private removeWindowListener?;
|
|
34
|
+
constructor(options: RouterOptions | RouteRecord[]);
|
|
35
|
+
install(app: OneApp): void;
|
|
36
|
+
push(path: string): void;
|
|
37
|
+
replace(path: string): void;
|
|
38
|
+
forward(): void;
|
|
39
|
+
back(): void;
|
|
40
|
+
go(delta: number): void;
|
|
41
|
+
getCurrentRoute(): RouteLocation | null;
|
|
42
|
+
getCurrentRouteRecord(): RouteRecord | null;
|
|
43
|
+
onRouteChange(listener: RouteChangeListener): () => void;
|
|
44
|
+
getRoutes(): RouteRecord[];
|
|
45
|
+
addRoute(route: RouteRecord): void;
|
|
46
|
+
createHref(path: string): string;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
private navigate;
|
|
49
|
+
private validateRoutes;
|
|
50
|
+
private initEvents;
|
|
51
|
+
private handleRouteChange;
|
|
52
|
+
private resolveCurrentRoute;
|
|
53
|
+
private getCurrentLocation;
|
|
54
|
+
private isSameLocation;
|
|
55
|
+
private triggerRouteChangeListeners;
|
|
56
|
+
}
|
|
57
|
+
export interface RouterLinkProps {
|
|
58
|
+
to: string;
|
|
59
|
+
replace?: boolean;
|
|
60
|
+
className?: string;
|
|
61
|
+
activeClass?: string;
|
|
62
|
+
children?: Array<VNode | string>;
|
|
63
|
+
}
|
|
64
|
+
interface RouterLinkState {
|
|
65
|
+
currentPath: string;
|
|
66
|
+
}
|
|
67
|
+
export declare class RouterLink extends Component<RouterLinkProps, RouterLinkState> {
|
|
68
|
+
private unsubscribe?;
|
|
69
|
+
protected initState(): RouterLinkState;
|
|
70
|
+
protected initStyles(): void;
|
|
71
|
+
protected onMounted(): void;
|
|
72
|
+
protected onUnmounted(): void;
|
|
73
|
+
protected render(): VNode;
|
|
74
|
+
}
|
|
75
|
+
interface RouterViewState {
|
|
76
|
+
route: RouteLocation | null;
|
|
77
|
+
record: RouteRecord | null;
|
|
78
|
+
}
|
|
79
|
+
export declare class RouterView extends Component<object, RouterViewState> {
|
|
80
|
+
private unsubscribe?;
|
|
81
|
+
protected initState(): RouterViewState;
|
|
82
|
+
protected initStyles(): void;
|
|
83
|
+
protected onMounted(): void;
|
|
84
|
+
protected onUnmounted(): void;
|
|
85
|
+
protected render(): VNode;
|
|
86
|
+
}
|
|
87
|
+
export declare function createRouter(options: RouterOptions | RouteRecord[]): Router;
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Router,
|
|
3
|
+
RouterLink,
|
|
4
|
+
RouterView,
|
|
5
|
+
createRouter
|
|
6
|
+
} from "../index-3j2jsdpc.js";
|
|
7
|
+
import"../index-dgv88dz4.js";
|
|
8
|
+
export {
|
|
9
|
+
createRouter,
|
|
10
|
+
RouterView,
|
|
11
|
+
RouterLink,
|
|
12
|
+
Router
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# debugId=8B42F5F6D588EAD464756E2164756E21
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Router } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* 设置全局路由实例
|
|
4
|
+
* @param r 路由实例
|
|
5
|
+
*/
|
|
6
|
+
export declare function setRouter(r: Router): void;
|
|
7
|
+
/**
|
|
8
|
+
* 获取路由实例
|
|
9
|
+
* @returns 路由实例
|
|
10
|
+
* @throws 当路由未初始化时抛出错误
|
|
11
|
+
*/
|
|
12
|
+
export declare function useRouter(): Router;
|
|
13
|
+
/**
|
|
14
|
+
* 安全地获取路由实例,如果未初始化则返回null
|
|
15
|
+
* @returns 路由实例或null
|
|
16
|
+
*/
|
|
17
|
+
export declare function getRouter(): Router | null;
|
|
18
|
+
/**
|
|
19
|
+
* 检查路由是否已初始化
|
|
20
|
+
* @returns 是否已初始化
|
|
21
|
+
*/
|
|
22
|
+
export declare function hasRouter(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 重置路由实例(主要用于测试)
|
|
25
|
+
*/
|
|
26
|
+
export declare function resetRouter(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RouteRecord } from './index';
|
|
2
|
+
export interface RouteMatch {
|
|
3
|
+
route: RouteRecord;
|
|
4
|
+
params: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function normalizePath(path: string): string;
|
|
7
|
+
export declare function matchRoute(routes: RouteRecord[], path: string): RouteMatch | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface StyleOptions {
|
|
2
|
+
selector: string;
|
|
3
|
+
properties: Record<string, string | number>;
|
|
4
|
+
hover?: Record<string, string | number>;
|
|
5
|
+
media?: Record<string, Record<string, string | number>>;
|
|
6
|
+
}
|
|
7
|
+
export declare class StyleManager {
|
|
8
|
+
styleElement: HTMLStyleElement;
|
|
9
|
+
styles: Map<string, StyleOptions>;
|
|
10
|
+
constructor();
|
|
11
|
+
addStyle(name: string, options: StyleOptions): void;
|
|
12
|
+
removeStyle(name: string): void;
|
|
13
|
+
clearStyles(): void;
|
|
14
|
+
private convertToCSS;
|
|
15
|
+
private updateStyles;
|
|
16
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StyleManager';
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geektech/tsone",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "TSone 是轻量级纯 TypeScript 前端框架,提供响应式系统、类组件、策略化渲染和路由功能",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./router": {
|
|
15
|
+
"import": "./dist/router/index.js",
|
|
16
|
+
"types": "./dist/router/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./style": {
|
|
19
|
+
"import": "./dist/style/index.js",
|
|
20
|
+
"types": "./dist/style/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"dev": "bun scripts/dev.ts",
|
|
25
|
+
"docs": "bun scripts/docs.ts",
|
|
26
|
+
"build": "bun scripts/build.ts",
|
|
27
|
+
"build:types": "bunx tsc --project tsconfig.build.json",
|
|
28
|
+
"lint": "eslint . --ext .ts",
|
|
29
|
+
"format": "prettier --write *.ts",
|
|
30
|
+
"test": "bun test",
|
|
31
|
+
"preview": "bun scripts/docs.ts"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"typescript",
|
|
35
|
+
"frontend",
|
|
36
|
+
"framework",
|
|
37
|
+
"reactive",
|
|
38
|
+
"component",
|
|
39
|
+
"router"
|
|
40
|
+
],
|
|
41
|
+
"author": "Jimmie Max(Qianyu)",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/bun": "^1.3.14",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
46
|
+
"@typescript-eslint/parser": "^6.14.0",
|
|
47
|
+
"eslint": "^8.55.0",
|
|
48
|
+
"eslint-config-prettier": "^10.1.8",
|
|
49
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
50
|
+
"happy-dom": "^20.9.0",
|
|
51
|
+
"prettier": "^3.1.1",
|
|
52
|
+
"typescript": "^5.3.3"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"bun": ">=1.3.0"
|
|
56
|
+
},
|
|
57
|
+
"files": [
|
|
58
|
+
"dist",
|
|
59
|
+
"README.md",
|
|
60
|
+
"LICENSE"
|
|
61
|
+
],
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public",
|
|
64
|
+
"registry": "https://registry.npmjs.org/"
|
|
65
|
+
}
|
|
66
|
+
}
|