@pawover/kit 1.3.0-alpha.0 → 1.4.0-alpha.2
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/package.json +11 -8
- package/skills/kit/SKILL.md +195 -0
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/pawover"
|
|
7
7
|
},
|
|
8
8
|
"description": "一个基于 TypeScript 的开发工具包",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.4.0-alpha.2",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=24.22.2"
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"pawover",
|
|
22
|
-
"pawover-kit"
|
|
22
|
+
"pawover-kit",
|
|
23
|
+
"tanstack-intent"
|
|
23
24
|
],
|
|
24
25
|
"homepage": "https://github.com/pawover/pawover-kit#readme",
|
|
25
26
|
"repository": {
|
|
@@ -31,7 +32,8 @@
|
|
|
31
32
|
"module": "./entry/index.js",
|
|
32
33
|
"types": "./entry/index.d.ts",
|
|
33
34
|
"files": [
|
|
34
|
-
"entry"
|
|
35
|
+
"entry",
|
|
36
|
+
"skills/kit"
|
|
35
37
|
],
|
|
36
38
|
"exports": {
|
|
37
39
|
".": {
|
|
@@ -167,11 +169,11 @@
|
|
|
167
169
|
"access": "public"
|
|
168
170
|
},
|
|
169
171
|
"dependencies": {
|
|
170
|
-
"@pawover/kit-eslint-rules": "0.2.0-alpha.
|
|
171
|
-
"@pawover/kit-hooks": "0.0.
|
|
172
|
-
"@pawover/kit-types": "0.
|
|
173
|
-
"@pawover/kit-utils": "1.0.
|
|
174
|
-
"@pawover/kit-zod": "0.0.
|
|
172
|
+
"@pawover/kit-eslint-rules": "0.2.0-alpha.2",
|
|
173
|
+
"@pawover/kit-hooks": "0.1.0-alpha.0",
|
|
174
|
+
"@pawover/kit-types": "0.2.0-alpha.0",
|
|
175
|
+
"@pawover/kit-utils": "1.1.0-alpha.0",
|
|
176
|
+
"@pawover/kit-zod": "0.1.0-alpha.0"
|
|
175
177
|
},
|
|
176
178
|
"devDependencies": {
|
|
177
179
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
@@ -180,6 +182,7 @@
|
|
|
180
182
|
"@commitlint/config-conventional": "^21.2.4",
|
|
181
183
|
"@fontsource/ibm-plex-mono": "^5.3.0",
|
|
182
184
|
"@pawover/kit-internal": "0.0.0",
|
|
185
|
+
"@tanstack/intent": "^0.5.6",
|
|
183
186
|
"@testing-library/react": "^16.3.3",
|
|
184
187
|
"@types/fs-extra": "^11.0.4",
|
|
185
188
|
"@types/node": "^26.6.6",
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kit
|
|
3
|
+
description: >-
|
|
4
|
+
Use when installing @pawover/kit or choosing between the root package, a
|
|
5
|
+
standalone subpackage, and a subpath such as @pawover/kit/utils,
|
|
6
|
+
@pawover/kit/hooks/react, @pawover/kit/types/global,
|
|
7
|
+
@pawover/kit/eslint-rules, or @pawover/kit/zod; also use when an import fails
|
|
8
|
+
because the root entry only re-exports @pawover/kit-utils, the hooks root
|
|
9
|
+
export is empty, or an optional peer dependency is missing.
|
|
10
|
+
metadata:
|
|
11
|
+
purpose: Choose the correct @pawover/kit package and subpath, install optional
|
|
12
|
+
peer dependencies, and avoid runtime import failures.
|
|
13
|
+
type: lifecycle
|
|
14
|
+
library: "@pawover/kit"
|
|
15
|
+
library_version: "1.3.0-alpha.1"
|
|
16
|
+
sources:
|
|
17
|
+
- package.json
|
|
18
|
+
- entry/index.d.ts
|
|
19
|
+
- entry/metadata.json
|
|
20
|
+
- site/guide/import-paths.md
|
|
21
|
+
- site/guide/installation.md
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Choose a `@pawover/kit` entry point
|
|
25
|
+
|
|
26
|
+
`@pawover/kit` is a thin re-export package. Its root `.` entry only re-exports
|
|
27
|
+
`@pawover/kit-utils`; types, hooks, the ESLint preset, and Zod schemas are
|
|
28
|
+
published through subpaths. The five standalone subpackages are also published
|
|
29
|
+
separately.
|
|
30
|
+
|
|
31
|
+
## Setup
|
|
32
|
+
|
|
33
|
+
Install the aggregate package when you want several capabilities:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
pnpm add @pawover/kit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Install only the subpackage you need when the project uses a single capability:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
pnpm add @pawover/kit-utils
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Optional peer dependencies are not installed for you. Install the peers for the
|
|
46
|
+
feature you use:
|
|
47
|
+
|
|
48
|
+
| Feature | Peer dependencies |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| React hooks | `react` |
|
|
51
|
+
| Alova hooks | `alova` + `react` |
|
|
52
|
+
| Math utilities (`MathUtil`, `CurrencyUtil.toRealValue`) | `mathjs` |
|
|
53
|
+
| Vite proxy utility (`ViteUtil.toProxy`) | `vite` |
|
|
54
|
+
| Zod schemas | `zod` |
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
pnpm add react alova mathjs vite zod
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Core patterns
|
|
61
|
+
|
|
62
|
+
### Use the subpath that owns the capability
|
|
63
|
+
|
|
64
|
+
| Import | Contents |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `@pawover/kit` | Only the core utility classes re-exported from `@pawover/kit-utils` |
|
|
67
|
+
| `@pawover/kit/utils` | Core static utility classes (`ArrayUtil`, `TypeUtil`, `TreeUtil`, …) |
|
|
68
|
+
| `@pawover/kit/utils/math` | `MathUtil` (alias: `@pawover/kit/math`) |
|
|
69
|
+
| `@pawover/kit/utils/vite` | `ViteUtil` (alias: `@pawover/kit/vite`) |
|
|
70
|
+
| `@pawover/kit/types` | Type utilities such as `AnyObject`, `PlainObject`, `TreeLike` |
|
|
71
|
+
| `@pawover/kit/types/react` | `Props`, `PropsWithChildren`, `PropsWithRef` |
|
|
72
|
+
| `@pawover/kit/types/global` | Type-only ambient entry; configure it in `tsconfig.types` |
|
|
73
|
+
| `@pawover/kit/types/react/global` | Type-only React ambient entry; configure it in `tsconfig.types` |
|
|
74
|
+
| `@pawover/kit/hooks/react` | React hooks |
|
|
75
|
+
| `@pawover/kit/hooks/alova` | Alova hooks |
|
|
76
|
+
| `@pawover/kit/eslint-rules` | ESLint flat config preset |
|
|
77
|
+
| `@pawover/kit/zod` | Prebuilt Zod v4 schemas |
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { TypeUtil, TreeUtil } from "@pawover/kit/utils";
|
|
81
|
+
import { useMount } from "@pawover/kit/hooks/react";
|
|
82
|
+
import { useAlovaRequest } from "@pawover/kit/hooks/alova";
|
|
83
|
+
import type { AnyObject } from "@pawover/kit/types";
|
|
84
|
+
import pawover from "@pawover/kit/eslint-rules";
|
|
85
|
+
import { id } from "@pawover/kit/zod";
|
|
86
|
+
|
|
87
|
+
const value: AnyObject = { enabled: true };
|
|
88
|
+
TypeUtil.isBoolean(value.enabled);
|
|
89
|
+
TreeUtil.rowsToTree([{ id: 1, parentId: null }]);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Prefer root subpaths in applications, subpackages in libraries
|
|
93
|
+
|
|
94
|
+
Applications that install `@pawover/kit` should use `@pawover/kit/*` for a
|
|
95
|
+
single, consistent dependency. Libraries that want to expose only one
|
|
96
|
+
capability should depend on and import the standalone package, for example
|
|
97
|
+
`@pawover/kit-utils`, so consumers do not install unrelated packages.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// Application
|
|
101
|
+
import { ArrayUtil as RootArrayUtil } from "@pawover/kit/utils";
|
|
102
|
+
|
|
103
|
+
// Standalone subpackage
|
|
104
|
+
import { ArrayUtil as PackageArrayUtil } from "@pawover/kit-utils";
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Global type entries are configured, not imported
|
|
108
|
+
|
|
109
|
+
`@pawover/kit/types/global` and `@pawover/kit/types/react/global` are type-only
|
|
110
|
+
entries. Add them to `compilerOptions.types`; do not write a runtime `import`.
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"compilerOptions": {
|
|
115
|
+
"types": ["@pawover/kit-types/global", "@pawover/kit-types/react/global"]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The React global entry requires `react` and `@types/react` in the consuming
|
|
121
|
+
project.
|
|
122
|
+
|
|
123
|
+
### ESM and CJS
|
|
124
|
+
|
|
125
|
+
Most packages publish both ESM and CJS. `@pawover/kit-eslint-rules` is ESM-only;
|
|
126
|
+
CommonJS consumers load it through Node's `require(esm)` support. Use `import`
|
|
127
|
+
in new code unless the surrounding tool requires `require`.
|
|
128
|
+
|
|
129
|
+
## Common mistakes
|
|
130
|
+
|
|
131
|
+
### Importing hooks from `@pawover/kit/hooks`
|
|
132
|
+
|
|
133
|
+
`@pawover/kit-hooks` has an empty root export. The following does not provide any
|
|
134
|
+
hook:
|
|
135
|
+
|
|
136
|
+
```ts no-check
|
|
137
|
+
import { useMount } from "@pawover/kit/hooks";
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Use the concrete subpaths instead:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { useMount } from "@pawover/kit/hooks/react";
|
|
144
|
+
import { useAlovaRequest } from "@pawover/kit/hooks/alova";
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Expecting the root `.` entry to export everything
|
|
148
|
+
|
|
149
|
+
The root entry only re-exports `@pawover/kit-utils`. `id`, `pawover`, `useMount`,
|
|
150
|
+
and `AnyObject` must come from their subpaths:
|
|
151
|
+
|
|
152
|
+
```ts no-check
|
|
153
|
+
import { id, pawover, useMount } from "@pawover/kit";
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Use:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
import { id } from "@pawover/kit/zod";
|
|
160
|
+
import pawover from "@pawover/kit/eslint-rules";
|
|
161
|
+
import { useMount } from "@pawover/kit/hooks/react";
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Importing `MathUtil` or `ViteUtil` from the core utils entry
|
|
165
|
+
|
|
166
|
+
`@pawover/kit/utils` and `@pawover/kit-utils` expose the core classes only.
|
|
167
|
+
`MathUtil` and `ViteUtil` live in their own entries because their peers are
|
|
168
|
+
optional:
|
|
169
|
+
|
|
170
|
+
```ts no-check
|
|
171
|
+
import { MathUtil } from "@pawover/kit/utils";
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Use:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { MathUtil } from "@pawover/kit/utils/math";
|
|
178
|
+
import { ViteUtil } from "@pawover/kit/utils/vite";
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Forgetting an optional peer
|
|
182
|
+
|
|
183
|
+
The package cannot resolve `alova`, `react`, `mathjs`, `vite`, or `zod` unless
|
|
184
|
+
the consuming project installs the peer for the feature it uses. A missing peer
|
|
185
|
+
fails when the corresponding module is loaded, not when `@pawover/kit` is
|
|
186
|
+
installed.
|
|
187
|
+
|
|
188
|
+
## Completion
|
|
189
|
+
|
|
190
|
+
- Every import uses a path that exists in the table above.
|
|
191
|
+
- The peers for each imported capability are installed.
|
|
192
|
+
- Global type entries, when used, appear in `compilerOptions.types` rather than
|
|
193
|
+
in an `import` statement.
|
|
194
|
+
- The application builds without resolving `@pawover/kit/hooks` or a missing
|
|
195
|
+
optional peer.
|