@mpxjs/store 2.10.18 → 2.10.21

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.
Files changed (3) hide show
  1. package/AGENTS.md +28 -0
  2. package/CLAUDE.md +1 -0
  3. package/package.json +3 -3
package/AGENTS.md ADDED
@@ -0,0 +1,28 @@
1
+ # @mpxjs/store
2
+
3
+ Mpx 内置的 Vuex 风格 store(在 [@mpxjs/core](../core/AGENTS.md) 中被 re-export),跑在 Mpx 自有响应式上。新项目推荐使用 [@mpxjs/pinia](../pinia/AGENTS.md),本包用于历史项目兼容。
4
+
5
+ ## 入口文件
6
+
7
+ - [src/index.js](src/index.js):核心实现,导出 `createStore` / `createStoreWithThis`、辅助函数与 `Store` 类。
8
+ - [src/mapStore.js](src/mapStore.js):`mapState` / `mapGetters` / `mapMutations` / `mapActions` 帮助函数。
9
+ - [@types/index.d.ts](@types/index.d.ts):对外类型。
10
+
11
+ ## 核心模块
12
+
13
+ - [src/index.js](src/index.js) 内主要分两部分:
14
+ - `transformGetters`:把用户传入的 getters 包装成对当前 module/state 的代理函数,注入响应式(`reactive` + `computed`)。
15
+ - `Store` 类:`commit` / `dispatch` / `getters` / `state` / `subscribe`,支持 module 嵌套与 `withThis` 风格。
16
+ - [src/mapStore.js](src/mapStore.js):四个 map 帮助函数把 store 字段映射到组件 computed/methods。
17
+
18
+ ## 典型调用链
19
+
20
+ 1. **创建**:用户 `createStore({ state, mutations, actions, getters, modules })` → 内部基于 `@mpxjs/core` 的 `reactive` / `computed` / `effectScope` 构造 `Store` 实例。
21
+ 2. **挂载**:通过 `mpx.use(store)` 或 `createApp({ store })` 注入,组件实例上可通过 `this.$store` 访问。
22
+ 3. **读取/变更**:`store.state.x` / `store.getters.y`(响应式追踪) → `commit('mutation')` 同步变更 → `dispatch('action')` 异步流程 → 通过 `subscribe` 派发订阅。
23
+
24
+ ## 注意
25
+
26
+ - 新项目优先用 [@mpxjs/pinia](../pinia/AGENTS.md),本包仅做兼容维护。
27
+ - 响应式 API 全部从 `@mpxjs/core` 引入,不要直接依赖 Vue。
28
+ - 与 `@mpxjs/utils` 的 `proxy` / `getByPath` / `warn` 配合做路径访问与告警。
package/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ 参考 [AGENTS.md](AGENTS.md)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/store",
3
- "version": "2.10.18",
3
+ "version": "2.10.21",
4
4
  "description": "A store for mpx framework",
5
5
  "main": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -26,10 +26,10 @@
26
26
  },
27
27
  "homepage": "https://github.com/didi/mpx#readme",
28
28
  "dependencies": {
29
- "@mpxjs/utils": "^2.10.18"
29
+ "@mpxjs/utils": "^2.10.21"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@mpxjs/core": "^2.9.0"
33
33
  },
34
- "gitHead": "8ce11a81959cb4b807d683b14c2d0b72c3991da3"
34
+ "gitHead": "a2cbdad9f8dcc376f2098d217485525953b64cd9"
35
35
  }