@taicode/common-web 3.8.0 → 4.0.0-beta.10
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/output/components/pagination/index.d.ts +1 -6
- package/output/components/pagination/index.d.ts.map +1 -1
- package/output/features/signin/service.d.ts +3 -0
- package/output/features/signin/service.d.ts.map +1 -1
- package/output/features/signin/service.js +8 -3
- package/output/layout/dashboard/index.d.ts +2 -40
- package/output/layout/dashboard/index.d.ts.map +1 -1
- package/output/layout/dashboard/index.js +1 -46
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface PaginationProps {
|
|
1
|
+
export interface PaginationProps {
|
|
2
2
|
/**
|
|
3
3
|
* 当前页码(从1开始)
|
|
4
4
|
*/
|
|
@@ -15,10 +15,6 @@ interface PaginationProps {
|
|
|
15
15
|
* 页码改变回调
|
|
16
16
|
*/
|
|
17
17
|
onPageChange: (page: number) => void;
|
|
18
|
-
/**
|
|
19
|
-
* 每页数量改变回调(可选)
|
|
20
|
-
*/
|
|
21
|
-
onPageSizeChange?: (pageSize: number) => void;
|
|
22
18
|
/**
|
|
23
19
|
* 文案(可选,用于 i18n 覆盖)
|
|
24
20
|
*/
|
|
@@ -30,5 +26,4 @@ interface PaginationProps {
|
|
|
30
26
|
};
|
|
31
27
|
}
|
|
32
28
|
export declare function Pagination(props: PaginationProps): import("react").JSX.Element | null;
|
|
33
|
-
export {};
|
|
34
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/pagination/index.tsx"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/pagination/index.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;QACtE,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;KACpD,CAAA;CACF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,sCAmIhD"}
|
|
@@ -86,6 +86,9 @@ export declare class SigninService extends Service {
|
|
|
86
86
|
private cleanup;
|
|
87
87
|
/**
|
|
88
88
|
* 销毁服务
|
|
89
|
+
*
|
|
90
|
+
* 顺序固定:先**同步** cleanup(清持久化状态 / 停轮询 / 复位 observable),再 flush disposer
|
|
91
|
+
* (释放 reaction)。反过来说:`cleanup` 不能进 `disposer` —— 那样它会晚一个微任务才跑。
|
|
89
92
|
*/
|
|
90
93
|
dispose(): void;
|
|
91
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../source/features/signin/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAsB,MAAM,sBAAsB,CAAA;AAElE,OAAO,KAAK,EAAE,SAAS,EAAwC,YAAY,EAAE,MAAM,YAAY,CAAA;AAE/F,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,CAAA;AAE/G;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,YAAY,CAAC,EAAE,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EpC;IAED;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACH,OAAO,CAAC,SAAS;IAgBjB;;OAEG;IACH,OAAO,CAAC,YAAY;IAuCpB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAehB;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;YACW,iBAAiB;IAyB/B;;OAEG;YACW,iBAAiB;IA4G/B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IAEG,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA+CrC;;OAEG;IAEG,WAAW;IASjB;;OAEG;IAEG,MAAM;IAqBZ;;OAEG;IAEU,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IA4BrC;;OAEG;IACH,OAAO,CAAC,OAAO;IAWf;;;;;OAKG;IACI,OAAO;CAIf"}
|
|
@@ -438,9 +438,11 @@ let SigninService = (() => {
|
|
|
438
438
|
* 初始化服务
|
|
439
439
|
*/
|
|
440
440
|
async init() {
|
|
441
|
-
|
|
441
|
+
// 清理不登记到 disposer:`Disposer.dispose()` 是异步的(逐项 await),
|
|
442
|
+
// 而 `dispose()` 必须**同步**把持久化状态清掉(调用方通常不 await `dispose()`)。
|
|
443
|
+
// 延迟清理会把 `dispose()` 之后写入的持久化状态一并抹掉。
|
|
442
444
|
// 监听状态变化并自动保存
|
|
443
|
-
this.disposer.
|
|
445
|
+
this.disposer.add(reaction(() => ({
|
|
444
446
|
ticket: this.ticket,
|
|
445
447
|
dialogStatus: this.dialogStatus,
|
|
446
448
|
errorMessage: this.errorMessage
|
|
@@ -472,10 +474,13 @@ let SigninService = (() => {
|
|
|
472
474
|
}
|
|
473
475
|
/**
|
|
474
476
|
* 销毁服务
|
|
477
|
+
*
|
|
478
|
+
* 顺序固定:先**同步** cleanup(清持久化状态 / 停轮询 / 复位 observable),再 flush disposer
|
|
479
|
+
* (释放 reaction)。反过来说:`cleanup` 不能进 `disposer` —— 那样它会晚一个微任务才跑。
|
|
475
480
|
*/
|
|
476
481
|
dispose() {
|
|
477
482
|
this.cleanup();
|
|
478
|
-
this.disposer.dispose();
|
|
483
|
+
void this.disposer.dispose();
|
|
479
484
|
}
|
|
480
485
|
},
|
|
481
486
|
_SigninService_inited_accessor_storage = new WeakMap(),
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
export { Pagination as DashboardPagination } from '../../components/pagination/index.js';
|
|
3
|
+
export type { PaginationProps as DashboardPaginationProps } from '../../components/pagination/index.js';
|
|
2
4
|
export interface DashboardLayoutProps {
|
|
3
5
|
sidebar?: ReactNode;
|
|
4
6
|
header?: ReactNode;
|
|
@@ -36,44 +38,4 @@ export interface DashboardContentProps {
|
|
|
36
38
|
}
|
|
37
39
|
export declare function DashboardMain(props: ComponentProps<'div'>): import("react").JSX.Element;
|
|
38
40
|
export declare function DashboardContent(props: DashboardContentProps): import("react").JSX.Element;
|
|
39
|
-
export interface DashboardBackButtonProps {
|
|
40
|
-
label?: string;
|
|
41
|
-
context?: string;
|
|
42
|
-
onClick: () => void;
|
|
43
|
-
}
|
|
44
|
-
export declare function DashboardBackButton(props: DashboardBackButtonProps): import("react").JSX.Element;
|
|
45
|
-
export interface DashboardRefreshButtonProps {
|
|
46
|
-
onClick: () => void;
|
|
47
|
-
loading?: boolean;
|
|
48
|
-
label?: string;
|
|
49
|
-
}
|
|
50
|
-
export declare function DashboardRefreshButton(props: DashboardRefreshButtonProps): import("react").JSX.Element;
|
|
51
|
-
export interface DashboardResetButtonProps {
|
|
52
|
-
onClick: () => void;
|
|
53
|
-
label?: string;
|
|
54
|
-
}
|
|
55
|
-
export declare function DashboardResetButton(props: DashboardResetButtonProps): import("react").JSX.Element;
|
|
56
|
-
export interface DashboardFilterActionsProps {
|
|
57
|
-
onApply: () => void;
|
|
58
|
-
onReset: () => void;
|
|
59
|
-
onRefresh?: () => void;
|
|
60
|
-
loading?: boolean;
|
|
61
|
-
applyLabel?: string;
|
|
62
|
-
resetLabel?: string;
|
|
63
|
-
refreshLabel?: string;
|
|
64
|
-
}
|
|
65
|
-
export declare function DashboardFilterActions(props: DashboardFilterActionsProps): import("react").JSX.Element;
|
|
66
|
-
export interface DashboardPaginationProps {
|
|
67
|
-
currentPage: number;
|
|
68
|
-
pageSize: number;
|
|
69
|
-
total: number;
|
|
70
|
-
onPageChange: (page: number) => void;
|
|
71
|
-
labels?: {
|
|
72
|
-
showingResults?: (start: number, end: number, total: number) => string;
|
|
73
|
-
previous?: string;
|
|
74
|
-
next?: string;
|
|
75
|
-
pageOf?: (current: number, total: number) => string;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
export declare function DashboardPagination(props: DashboardPaginationProps): import("react").JSX.Element | null;
|
|
79
41
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/layout/dashboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/layout/dashboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKrE,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AACxF,YAAY,EAAE,eAAe,IAAI,wBAAwB,EAAE,MAAM,sCAAsC,CAAA;AAEvG,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,+BAc1D;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,SAAS,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BAmBxD;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,SAAS,CAAA;IAChB,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,+BAIzD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,+BA8B5D"}
|
|
@@ -10,10 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { ArrowLeftIcon, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, RefreshCwIcon, RotateCcwIcon, SearchIcon } from 'lucide-react';
|
|
14
|
-
import { Button } from '../../components/button.js';
|
|
15
13
|
import { SidebarInset, SidebarProvider } from '../../components/sidebar.js';
|
|
16
14
|
import { mergeClassNames } from '../../utils/merge-class-names/index.js';
|
|
15
|
+
export { Pagination as DashboardPagination } from '../../components/pagination/index.js';
|
|
17
16
|
export function DashboardLayout(props) {
|
|
18
17
|
const { sidebar, header, children } = props;
|
|
19
18
|
return (_jsxs(_Fragment, { children: [sidebar, _jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [header, _jsx("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: _jsx("div", { className: "@container/main flex min-w-0 flex-1 flex-col gap-2", children: children }) })] })] }));
|
|
@@ -38,47 +37,3 @@ export function DashboardContent(props) {
|
|
|
38
37
|
const { title, description, back, toolbar, filters, children, antiAutoFill = false } = props;
|
|
39
38
|
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-4 pb-4 md:gap-5", children: [_jsxs("div", { className: "flex flex-col gap-2.5 border-b px-4 py-3 lg:px-6", children: [back, _jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("h1", { className: "truncate text-base font-semibold leading-6 tracking-tight", children: title }), description && (_jsx("p", { className: "mt-0.5 line-clamp-2 text-[13px] leading-5 text-muted-foreground", children: description }))] }), toolbar && _jsx("div", { className: "flex min-h-8 shrink-0 items-center justify-end gap-2", children: toolbar })] }), filters && _jsx("div", { className: "flex flex-col gap-2", children: filters })] }), _jsx(DashboardMain, { className: "space-y-4 md:space-y-5", children: children }), antiAutoFill && (_jsxs(_Fragment, { children: [_jsx("input", { type: "text", name: "fake-username", autoComplete: "off", tabIndex: -1, style: { position: 'absolute', top: -1000, left: -1000 } }), _jsx("input", { type: "password", name: "fake-password", autoComplete: "new-password", tabIndex: -1, style: { position: 'absolute', top: -1000, left: -1000 } })] }))] }));
|
|
40
39
|
}
|
|
41
|
-
export function DashboardBackButton(props) {
|
|
42
|
-
const { label = 'Back', context, onClick } = props;
|
|
43
|
-
return (_jsxs("div", { className: "flex min-h-9 min-w-0 items-center gap-2", children: [_jsxs(Button, { variant: "ghost", size: "sm", onClick: onClick, className: "-ml-2 shrink-0 gap-1.5 px-2", children: [_jsx(ArrowLeftIcon, { className: "size-4" }), _jsx("span", { children: label })] }), context && _jsx("span", { className: "truncate text-sm text-muted-foreground", children: context })] }));
|
|
44
|
-
}
|
|
45
|
-
export function DashboardRefreshButton(props) {
|
|
46
|
-
const { onClick, loading = false, label = 'Refresh' } = props;
|
|
47
|
-
return _jsx(Button, { variant: "outline", size: "icon", className: "size-9", onClick: onClick, disabled: loading, "aria-label": label, title: label, children: _jsx(RefreshCwIcon, { className: loading ? 'size-4 animate-spin' : 'size-4' }) });
|
|
48
|
-
}
|
|
49
|
-
export function DashboardResetButton(props) {
|
|
50
|
-
const { onClick, label = 'Reset' } = props;
|
|
51
|
-
return _jsx(Button, { onClick: onClick, variant: "outline", size: "icon", className: "size-9", "aria-label": label, title: label, children: _jsx(RotateCcwIcon, { className: "size-4" }) });
|
|
52
|
-
}
|
|
53
|
-
export function DashboardFilterActions(props) {
|
|
54
|
-
const { onApply, onReset, onRefresh, loading = false, applyLabel = 'Filter', resetLabel = 'Reset', refreshLabel = 'Refresh' } = props;
|
|
55
|
-
return _jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [_jsxs(Button, { onClick: onApply, className: "h-9", children: [_jsx(SearchIcon, { className: "size-4" }), applyLabel] }), _jsx(DashboardResetButton, { onClick: onReset, label: resetLabel }), onRefresh && _jsx(DashboardRefreshButton, { onClick: onRefresh, loading: loading, label: refreshLabel })] });
|
|
56
|
-
}
|
|
57
|
-
export function DashboardPagination(props) {
|
|
58
|
-
var _a, _b, _c, _d, _e, _f;
|
|
59
|
-
const { currentPage, pageSize, total, onPageChange, labels } = props;
|
|
60
|
-
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
61
|
-
const pages = [];
|
|
62
|
-
if (totalPages <= 7) {
|
|
63
|
-
for (let page = 1; page <= totalPages; page++)
|
|
64
|
-
pages.push(page);
|
|
65
|
-
}
|
|
66
|
-
else if (currentPage <= 4) {
|
|
67
|
-
pages.push(1, 2, 3, 4, 5, '...', totalPages);
|
|
68
|
-
}
|
|
69
|
-
else if (currentPage >= totalPages - 3) {
|
|
70
|
-
pages.push(1, '...');
|
|
71
|
-
for (let page = totalPages - 4; page <= totalPages; page++)
|
|
72
|
-
pages.push(page);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
pages.push(1, '...', currentPage - 1, currentPage, currentPage + 1, '...', totalPages);
|
|
76
|
-
}
|
|
77
|
-
if (total === 0)
|
|
78
|
-
return null;
|
|
79
|
-
const start = (currentPage - 1) * pageSize + 1;
|
|
80
|
-
const end = Math.min(currentPage * pageSize, total);
|
|
81
|
-
const previous = (_a = labels === null || labels === void 0 ? void 0 : labels.previous) !== null && _a !== void 0 ? _a : 'Previous';
|
|
82
|
-
const next = (_b = labels === null || labels === void 0 ? void 0 : labels.next) !== null && _b !== void 0 ? _b : 'Next';
|
|
83
|
-
return (_jsxs("div", { className: "flex items-center justify-between px-4", children: [_jsx("div", { className: "hidden flex-1 text-sm text-muted-foreground lg:flex", children: (_d = (_c = labels === null || labels === void 0 ? void 0 : labels.showingResults) === null || _c === void 0 ? void 0 : _c.call(labels, start, end, total)) !== null && _d !== void 0 ? _d : `Showing ${start} to ${end} of ${total} results` }), _jsxs("div", { className: "flex w-full items-center justify-between gap-1 lg:hidden", children: [_jsxs(Button, { variant: "outline", size: "sm", className: "shrink-0 px-2", onClick: () => onPageChange(currentPage - 1), disabled: currentPage === 1, children: [_jsx(ChevronLeft, { className: "size-4" }), previous] }), _jsx("div", { className: "min-w-0 truncate px-1 text-center text-xs font-medium", children: (_f = (_e = labels === null || labels === void 0 ? void 0 : labels.pageOf) === null || _e === void 0 ? void 0 : _e.call(labels, currentPage, totalPages)) !== null && _f !== void 0 ? _f : `Page ${currentPage} of ${totalPages}` }), _jsxs(Button, { variant: "outline", size: "sm", className: "shrink-0 px-2", onClick: () => onPageChange(currentPage + 1), disabled: currentPage === totalPages, children: [next, _jsx(ChevronRight, { className: "size-4" })] })] }), _jsxs("div", { className: "hidden w-full items-center gap-2 lg:flex lg:w-fit", children: [_jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(1), disabled: currentPage === 1, children: [_jsx("span", { className: "sr-only", children: "Go to first page" }), _jsx(ChevronsLeft, { className: "size-4" })] }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(currentPage - 1), disabled: currentPage === 1, children: [_jsx("span", { className: "sr-only", children: "Go to previous page" }), _jsx(ChevronLeft, { className: "size-4" })] }), _jsx("div", { className: "flex items-center gap-1", children: pages.map((page, index) => typeof page === 'number' ? _jsx(Button, { variant: page === currentPage ? 'default' : 'outline', className: "size-8 p-0", onClick: () => onPageChange(page), children: page }, `page-${page}`) : _jsx("span", { className: "flex size-8 items-center justify-center text-muted-foreground", children: page }, `ellipsis-${index}`)) }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(currentPage + 1), disabled: currentPage === totalPages, children: [_jsx("span", { className: "sr-only", children: "Go to next page" }), _jsx(ChevronRight, { className: "size-4" })] }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(totalPages), disabled: currentPage === totalPages, children: [_jsx("span", { className: "sr-only", children: "Go to last page" }), _jsx(ChevronsRight, { className: "size-4" })] })] })] }));
|
|
84
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taicode/common-web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"author": "Alain",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"mobx": ">=6",
|
|
55
55
|
"mobx-react-lite": "^4.1.1",
|
|
56
56
|
"react": ">=18",
|
|
57
|
-
"@taicode/common-base": "^
|
|
57
|
+
"@taicode/common-base": "^4.0.0-beta.10"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@headlessui/react": "^2.2.9",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"vite-plugin-svgr": "^4.5.0",
|
|
108
108
|
"vite-tsconfig-paths": "^5.1.4",
|
|
109
109
|
"vitest": "^4.1.9",
|
|
110
|
-
"@taicode/common-base": "^
|
|
110
|
+
"@taicode/common-base": "^4.0.0-beta.10"
|
|
111
111
|
},
|
|
112
112
|
"scripts": {
|
|
113
113
|
"test": "vitest",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"test:ci": "vitest run",
|
|
117
117
|
"lint": "eslint .",
|
|
118
118
|
"typecheck": "tsc --noEmit",
|
|
119
|
-
"build": "tsc -p tsconfig.json",
|
|
119
|
+
"build": "rm -rf output && tsc -p tsconfig.json",
|
|
120
120
|
"dev": "tsc -p tsconfig.json --watch",
|
|
121
121
|
"pack:local": "pnpm build && mkdir -p ../../.local-packages && pnpm pack --pack-destination ../../.local-packages"
|
|
122
122
|
}
|