@hzab/data-model 2.0.3-alpha.1 → 2.1.0-alpha.0

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 CHANGED
@@ -1,62 +1,76 @@
1
1
  {
2
2
  "name": "@hzab/data-model",
3
- "version": "2.0.3-alpha.1",
4
- "description": "data model",
5
- "main": "src",
6
- "scripts": {
7
- "dev": "npm run prepare && webpack serve -c ./config/webpack.config.js --env local",
8
- "build": "webpack -c ./config/webpack.config.js --env production",
9
- "version:alpha": "npm version prerelease --preid=alpha",
10
- "publish:alpha": "npm publish --tag alpha",
11
- "version:beta": "npm version prerelease --preid=beta",
12
- "publish:beta": "npm publish --tag beta",
13
- "version:patch": "npm version patch",
14
- "version:minior": "npm version minor",
15
- "version:major": "npm version major",
16
- "publish:stable": "npm publish --access public",
17
- "prepare": "husky install",
18
- "docs": "typedoc"
3
+ "version": "2.1.0-alpha.0",
4
+ "private": false,
5
+ "description": "数据模型 2.1:再导出 core + useDataModel;后继 API 与旧写法双轨",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "CaiYansong",
9
+ "publishConfig": {
10
+ "access": "public"
19
11
  },
20
12
  "files": [
13
+ "dist",
21
14
  "src",
15
+ "README.md",
16
+ "LICENSE",
22
17
  "CHANGELOG.md"
23
18
  ],
24
- "keywords": [],
25
- "author": "CaiYansong",
26
- "license": "ISC",
27
- "devDependencies": {
28
- "@hzab/permissions": "^0.1.1",
29
- "@hzab/webpack-config": "^0.7.1",
30
- "@types/react": "^17.0.62",
31
- "@types/react-dom": "^17.0.20",
32
- "antd": "4.24.16",
33
- "axios": "1.13.6",
34
- "eslint": "^8.30.0",
35
- "js-cookie": "^3.0.5",
36
- "less": "^4.1.3",
37
- "lodash-es": "^4.18.1",
38
- "mobx": "^6.7.0",
39
- "mobx-react": "^7.6.0",
40
- "react": "^17.0.2",
41
- "react-dom": "^17.0.2",
42
- "react-router-dom": "^6.14.1",
43
- "typedoc": "^0.24.8",
44
- "typescript": "^4.9.4"
19
+ "main": "./dist/index.cjs",
20
+ "module": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js",
26
+ "require": "./dist/index.cjs"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "sideEffects": [
31
+ "./dist/index.js",
32
+ "./dist/index.cjs"
33
+ ],
34
+ "dependencies": {
35
+ "axios": "^1.18.1",
36
+ "nanoid": "^3.3.15"
37
+ },
38
+ "engines": {
39
+ "node": ">=24"
45
40
  },
46
41
  "peerDependencies": {
47
- "axios": ">=1.6.2",
48
- "js-cookie": ">=3.0.5"
42
+ "js-cookie": "^3.0.5",
43
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0"
49
44
  },
50
- "dependencies": {
51
- "dayjs": "^1.11.7",
52
- "nanoid": "^3.3.7"
45
+ "peerDependenciesMeta": {
46
+ "js-cookie": {
47
+ "optional": true
48
+ }
53
49
  },
54
- "directories": {
55
- "lib": "lib"
50
+ "devDependencies": {
51
+ "@testing-library/react": "^16.3.3",
52
+ "@types/lodash-es": "^4.17.12",
53
+ "@types/node": "^24.0.0",
54
+ "@types/react": "^19.0.0",
55
+ "happy-dom": "^20.11.12",
56
+ "lodash-es": "^4.18.1",
57
+ "prettier": "^3.0.0",
58
+ "react": "^19.0.0",
59
+ "react-dom": "^19.2.8",
60
+ "tsup": "^8.5.1",
61
+ "typescript": "^5.9.3",
62
+ "vite": "^8.0.0",
63
+ "vitest": "^4.1.10",
64
+ "@hzab/data-model-core": "^2.1.0-alpha.0",
65
+ "@hzab/eslint-config": "^0.0.0",
66
+ "@hzab/vite-config": "^0.0.2-alpha.0",
67
+ "@hzab/typescript-config": "^0.0.0"
56
68
  },
57
- "lint-staged": {
58
- "**.{js,jsx,ts,tsx,css,scss,less,json,html}": [
59
- "prettier --write"
60
- ]
69
+ "scripts": {
70
+ "build": "tsup",
71
+ "typecheck": "tsc --noEmit -p tsconfig.json --rootDir .",
72
+ "test": "vitest run",
73
+ "lint": "eslint src --max-warnings=0",
74
+ "format:check": "prettier --check src"
61
75
  }
62
- }
76
+ }
package/src/hooks.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { useMemo, useRef } from "react";
2
2
  import { merge } from "lodash-es";
3
- import DataModel, { DataModelOptions } from "./data-model";
3
+ import DataModel from "@hzab/data-model-core";
4
+ import type { DataModelOptions } from "@hzab/data-model-core";
4
5
 
5
6
  /**
6
7
  * useDataModel 选项接口
@@ -23,8 +24,11 @@ export interface UseDataModelOptions<T = any> {
23
24
  * @param {Object} opt.effectQuery 动态的 query 数据
24
25
  * @returns DataModel 实例
25
26
  */
26
- export const useDataModel = function <T = any>(initParams: DataModelOptions<T> = {}, opt: UseDataModelOptions<T> = {}) {
27
- const model = useRef<DataModel<T>>(new DataModel(initParams));
27
+ export const useDataModel = function <T = any>(
28
+ initParams: DataModelOptions<T> = {},
29
+ opt: UseDataModelOptions<T> = {},
30
+ ) {
31
+ const model = useRef<DataModel<T>>(new DataModel<T>(initParams));
28
32
  return useMemo(() => {
29
33
  const { effectParams, effectQuery } = opt || {};
30
34
  if (effectParams) {
package/src/index.ts CHANGED
@@ -1,11 +1,14 @@
1
- import axios from "./axios";
2
- import DataModel from "./data-model";
3
-
4
- export * from "./axios";
5
- export * from "./data-model";
6
- export * from "./hooks";
7
- export * from "./type";
8
-
9
- export { axios, DataModel };
10
-
11
- export default DataModel;
1
+ /**
2
+ * 数据模型 2.1:再导出 `@hzab/data-model-core`(打进 dist,不单独发布),
3
+ * 并提供 `useDataModel`。后继 API 与旧写法双轨。
4
+ *
5
+ * 老页面 `import { useDataModel, DataModel, axios } from "@hzab/data-model"` 仍可用。
6
+ * 不要安装 `@hzab/data-model-core`(private,已被打进本包 dist)。
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+
11
+ export * from "@hzab/data-model-core";
12
+ export { useDataModel } from "./hooks";
13
+ export type { UseDataModelOptions } from "./hooks";
14
+ export { default } from "@hzab/data-model-core";