@composy/store-core 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/CHANGELOG.md +5 -0
- package/README.md +172 -0
- package/dist/index.js +1852 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1082 -0
- package/dist/index.min.js.map +1 -0
- package/es/core/async-action.d.ts +95 -0
- package/es/core/async-action.d.ts.map +1 -0
- package/es/core/async-action.js +116 -0
- package/es/core/async-action.js.map +1 -0
- package/es/core/base-store.d.ts +85 -0
- package/es/core/base-store.d.ts.map +1 -0
- package/es/core/base-store.js +185 -0
- package/es/core/base-store.js.map +1 -0
- package/es/core/batch-manager.d.ts +46 -0
- package/es/core/batch-manager.d.ts.map +1 -0
- package/es/core/batch-manager.js +64 -0
- package/es/core/batch-manager.js.map +1 -0
- package/es/core/create-store.d.ts +66 -0
- package/es/core/create-store.d.ts.map +1 -0
- package/es/core/create-store.js +29 -0
- package/es/core/create-store.js.map +1 -0
- package/es/core/event-bus.d.ts +34 -0
- package/es/core/event-bus.d.ts.map +1 -0
- package/es/core/event-bus.js +71 -0
- package/es/core/event-bus.js.map +1 -0
- package/es/core/index.d.ts +14 -0
- package/es/core/index.d.ts.map +1 -0
- package/es/core/index.js +17 -0
- package/es/core/pub-sub.d.ts +41 -0
- package/es/core/pub-sub.d.ts.map +1 -0
- package/es/core/pub-sub.js +71 -0
- package/es/core/pub-sub.js.map +1 -0
- package/es/engine/index.d.ts +10 -0
- package/es/engine/index.d.ts.map +1 -0
- package/es/engine/index.js +12 -0
- package/es/engine/plugin.d.ts +20 -0
- package/es/engine/plugin.d.ts.map +1 -0
- package/es/engine/plugin.js +153 -0
- package/es/engine/plugin.js.map +1 -0
- package/es/engine/types.d.ts +81 -0
- package/es/engine/types.d.ts.map +1 -0
- package/es/engine/types.js +10 -0
- package/es/errors/index.d.ts +208 -0
- package/es/errors/index.d.ts.map +1 -0
- package/es/errors/index.js +217 -0
- package/es/errors/index.js.map +1 -0
- package/es/index.d.ts +27 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +34 -0
- package/es/index.js.map +1 -0
- package/es/middleware/index.d.ts +13 -0
- package/es/middleware/index.d.ts.map +1 -0
- package/es/middleware/index.js +16 -0
- package/es/middleware/logger.d.ts +67 -0
- package/es/middleware/logger.d.ts.map +1 -0
- package/es/middleware/logger.js +136 -0
- package/es/middleware/logger.js.map +1 -0
- package/es/middleware/middleware-manager.d.ts +40 -0
- package/es/middleware/middleware-manager.d.ts.map +1 -0
- package/es/middleware/middleware-manager.js +79 -0
- package/es/middleware/middleware-manager.js.map +1 -0
- package/es/middleware/persist.d.ts +34 -0
- package/es/middleware/persist.d.ts.map +1 -0
- package/es/middleware/persist.js +102 -0
- package/es/middleware/persist.js.map +1 -0
- package/es/middleware/time-travel.d.ts +30 -0
- package/es/middleware/time-travel.d.ts.map +1 -0
- package/es/middleware/time-travel.js +151 -0
- package/es/middleware/time-travel.js.map +1 -0
- package/es/middleware/validation.d.ts +100 -0
- package/es/middleware/validation.d.ts.map +1 -0
- package/es/middleware/validation.js +74 -0
- package/es/middleware/validation.js.map +1 -0
- package/es/plugins/define-plugin.d.ts +74 -0
- package/es/plugins/define-plugin.d.ts.map +1 -0
- package/es/plugins/define-plugin.js +52 -0
- package/es/plugins/define-plugin.js.map +1 -0
- package/es/plugins/index.d.ts +8 -0
- package/es/plugins/index.d.ts.map +1 -0
- package/es/plugins/index.js +13 -0
- package/es/plugins/plugin-manager.d.ts +35 -0
- package/es/plugins/plugin-manager.d.ts.map +1 -0
- package/es/plugins/plugin-manager.js +77 -0
- package/es/plugins/plugin-manager.js.map +1 -0
- package/es/types/index.d.ts +12 -0
- package/es/types/index.d.ts.map +1 -0
- package/es/types/index.js +10 -0
- package/es/types/middleware.d.ts +172 -0
- package/es/types/middleware.d.ts.map +1 -0
- package/es/types/middleware.js +10 -0
- package/es/types/plugin.d.ts +136 -0
- package/es/types/plugin.d.ts.map +1 -0
- package/es/types/plugin.js +10 -0
- package/es/types/store.d.ts +198 -0
- package/es/types/store.d.ts.map +1 -0
- package/es/types/store.js +10 -0
- package/es/types/subscription.d.ts +158 -0
- package/es/types/subscription.d.ts.map +1 -0
- package/es/types/subscription.js +10 -0
- package/es/types/utility.d.ts +312 -0
- package/es/types/utility.d.ts.map +1 -0
- package/es/types/utility.js +10 -0
- package/es/utils/debounce-throttle.d.ts +86 -0
- package/es/utils/debounce-throttle.d.ts.map +1 -0
- package/es/utils/debounce-throttle.js +86 -0
- package/es/utils/debounce-throttle.js.map +1 -0
- package/es/utils/deep-clone.d.ts +143 -0
- package/es/utils/deep-clone.d.ts.map +1 -0
- package/es/utils/deep-clone.js +193 -0
- package/es/utils/deep-clone.js.map +1 -0
- package/es/utils/index.d.ts +13 -0
- package/es/utils/index.d.ts.map +1 -0
- package/es/utils/index.js +14 -0
- package/es/utils/selector.d.ts +213 -0
- package/es/utils/selector.d.ts.map +1 -0
- package/es/utils/selector.js +151 -0
- package/es/utils/selector.js.map +1 -0
- package/esm/core/async-action.d.ts +95 -0
- package/esm/core/async-action.js +116 -0
- package/esm/core/async-action.js.map +1 -0
- package/esm/core/base-store.d.ts +85 -0
- package/esm/core/base-store.js +185 -0
- package/esm/core/base-store.js.map +1 -0
- package/esm/core/batch-manager.d.ts +46 -0
- package/esm/core/batch-manager.js +64 -0
- package/esm/core/batch-manager.js.map +1 -0
- package/esm/core/create-store.d.ts +66 -0
- package/esm/core/create-store.js +29 -0
- package/esm/core/create-store.js.map +1 -0
- package/esm/core/event-bus.d.ts +34 -0
- package/esm/core/event-bus.js +71 -0
- package/esm/core/event-bus.js.map +1 -0
- package/esm/core/index.d.ts +14 -0
- package/esm/core/index.js +17 -0
- package/esm/core/pub-sub.d.ts +41 -0
- package/esm/core/pub-sub.js +71 -0
- package/esm/core/pub-sub.js.map +1 -0
- package/esm/engine/index.d.ts +10 -0
- package/esm/engine/index.js +12 -0
- package/esm/engine/plugin.d.ts +20 -0
- package/esm/engine/plugin.js +153 -0
- package/esm/engine/plugin.js.map +1 -0
- package/esm/engine/types.d.ts +81 -0
- package/esm/errors/index.d.ts +208 -0
- package/esm/errors/index.js +217 -0
- package/esm/errors/index.js.map +1 -0
- package/esm/index.d.ts +27 -0
- package/esm/index.js +36 -0
- package/esm/index.js.map +1 -0
- package/esm/middleware/index.d.ts +13 -0
- package/esm/middleware/logger.d.ts +67 -0
- package/esm/middleware/logger.js +119 -0
- package/esm/middleware/logger.js.map +1 -0
- package/esm/middleware/middleware-manager.d.ts +40 -0
- package/esm/middleware/middleware-manager.js +79 -0
- package/esm/middleware/middleware-manager.js.map +1 -0
- package/esm/middleware/persist.d.ts +34 -0
- package/esm/middleware/persist.js +102 -0
- package/esm/middleware/persist.js.map +1 -0
- package/esm/middleware/time-travel.d.ts +30 -0
- package/esm/middleware/time-travel.js +151 -0
- package/esm/middleware/time-travel.js.map +1 -0
- package/esm/middleware/validation.d.ts +100 -0
- package/esm/middleware/validation.js +74 -0
- package/esm/middleware/validation.js.map +1 -0
- package/esm/plugins/define-plugin.d.ts +74 -0
- package/esm/plugins/define-plugin.js +52 -0
- package/esm/plugins/define-plugin.js.map +1 -0
- package/esm/plugins/index.d.ts +8 -0
- package/esm/plugins/plugin-manager.d.ts +35 -0
- package/esm/plugins/plugin-manager.js +77 -0
- package/esm/plugins/plugin-manager.js.map +1 -0
- package/esm/types/index.d.ts +12 -0
- package/esm/types/middleware.d.ts +172 -0
- package/esm/types/plugin.d.ts +136 -0
- package/esm/types/store.d.ts +198 -0
- package/esm/types/subscription.d.ts +158 -0
- package/esm/types/utility.d.ts +312 -0
- package/esm/utils/debounce-throttle.d.ts +86 -0
- package/esm/utils/debounce-throttle.js +86 -0
- package/esm/utils/debounce-throttle.js.map +1 -0
- package/esm/utils/deep-clone.d.ts +143 -0
- package/esm/utils/deep-clone.js +193 -0
- package/esm/utils/deep-clone.js.map +1 -0
- package/esm/utils/index.d.ts +13 -0
- package/esm/utils/selector.d.ts +213 -0
- package/esm/utils/selector.js +151 -0
- package/esm/utils/selector.js.map +1 -0
- package/lib/core/async-action.cjs +118 -0
- package/lib/core/async-action.cjs.map +1 -0
- package/lib/core/async-action.d.ts +95 -0
- package/lib/core/base-store.cjs +187 -0
- package/lib/core/base-store.cjs.map +1 -0
- package/lib/core/base-store.d.ts +85 -0
- package/lib/core/batch-manager.cjs +69 -0
- package/lib/core/batch-manager.cjs.map +1 -0
- package/lib/core/batch-manager.d.ts +46 -0
- package/lib/core/create-store.cjs +31 -0
- package/lib/core/create-store.cjs.map +1 -0
- package/lib/core/create-store.d.ts +66 -0
- package/lib/core/event-bus.cjs +74 -0
- package/lib/core/event-bus.cjs.map +1 -0
- package/lib/core/event-bus.d.ts +34 -0
- package/lib/core/index.cjs +29 -0
- package/lib/core/index.d.ts +14 -0
- package/lib/core/pub-sub.cjs +74 -0
- package/lib/core/pub-sub.cjs.map +1 -0
- package/lib/core/pub-sub.d.ts +41 -0
- package/lib/engine/index.cjs +16 -0
- package/lib/engine/index.d.ts +10 -0
- package/lib/engine/plugin.cjs +157 -0
- package/lib/engine/plugin.cjs.map +1 -0
- package/lib/engine/plugin.d.ts +20 -0
- package/lib/engine/types.cjs +12 -0
- package/lib/engine/types.d.ts +81 -0
- package/lib/errors/index.cjs +233 -0
- package/lib/errors/index.cjs.map +1 -0
- package/lib/errors/index.d.ts +208 -0
- package/lib/index.cjs +101 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/middleware/index.cjs +28 -0
- package/lib/middleware/index.d.ts +13 -0
- package/lib/middleware/logger.cjs +140 -0
- package/lib/middleware/logger.cjs.map +1 -0
- package/lib/middleware/logger.d.ts +67 -0
- package/lib/middleware/middleware-manager.cjs +83 -0
- package/lib/middleware/middleware-manager.cjs.map +1 -0
- package/lib/middleware/middleware-manager.d.ts +40 -0
- package/lib/middleware/persist.cjs +105 -0
- package/lib/middleware/persist.cjs.map +1 -0
- package/lib/middleware/persist.d.ts +34 -0
- package/lib/middleware/time-travel.cjs +154 -0
- package/lib/middleware/time-travel.cjs.map +1 -0
- package/lib/middleware/time-travel.d.ts +30 -0
- package/lib/middleware/validation.cjs +76 -0
- package/lib/middleware/validation.cjs.map +1 -0
- package/lib/middleware/validation.d.ts +100 -0
- package/lib/package.json +3 -0
- package/lib/plugins/define-plugin.cjs +56 -0
- package/lib/plugins/define-plugin.cjs.map +1 -0
- package/lib/plugins/define-plugin.d.ts +74 -0
- package/lib/plugins/index.cjs +20 -0
- package/lib/plugins/index.d.ts +8 -0
- package/lib/plugins/plugin-manager.cjs +81 -0
- package/lib/plugins/plugin-manager.cjs.map +1 -0
- package/lib/plugins/plugin-manager.d.ts +35 -0
- package/lib/types/index.cjs +12 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/middleware.cjs +12 -0
- package/lib/types/middleware.d.ts +172 -0
- package/lib/types/plugin.cjs +12 -0
- package/lib/types/plugin.d.ts +136 -0
- package/lib/types/store.cjs +12 -0
- package/lib/types/store.d.ts +198 -0
- package/lib/types/subscription.cjs +12 -0
- package/lib/types/subscription.d.ts +158 -0
- package/lib/types/utility.cjs +12 -0
- package/lib/types/utility.d.ts +312 -0
- package/lib/utils/debounce-throttle.cjs +89 -0
- package/lib/utils/debounce-throttle.cjs.map +1 -0
- package/lib/utils/debounce-throttle.d.ts +86 -0
- package/lib/utils/deep-clone.cjs +202 -0
- package/lib/utils/deep-clone.cjs.map +1 -0
- package/lib/utils/deep-clone.d.ts +143 -0
- package/lib/utils/index.cjs +34 -0
- package/lib/utils/index.d.ts +13 -0
- package/lib/utils/selector.cjs +161 -0
- package/lib/utils/selector.cjs.map +1 -0
- package/lib/utils/selector.d.ts +213 -0
- package/package.json +155 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-store.cjs","names":[],"sources":["../../src/core/create-store.ts"],"sourcesContent":["/**\n * @module store/core/create-store\n *\n * Store 工厂函数,用于创建单例 Store 的惰性初始化函数。\n * 基于 BaseStore 实现,返回的工厂函数在首次调用时创建 Store 实例,\n * 后续调用返回同一实例,直到调用 $dispose() 后重置。\n */\n\nimport type {\n ActionSubscriber,\n StateMutation,\n StateSubscriber,\n StateTree,\n StoreId,\n Unsubscribe,\n} from '../types'\nimport { BaseStore } from './base-store'\n\n/**\n * Store 定义描述接口\n *\n * @typeParam Id - Store 唯一标识符类型\n * @typeParam S - 状态树类型\n * @typeParam G - 计算属性定义类型\n * @typeParam A - Action 定义类型\n */\nexport interface CreateStoreDefinition<\n Id extends StoreId,\n S extends StateTree,\n G extends Record<string, (state: S) => unknown>,\n A extends Record<string, (this: StoreAPI<Id, S, G, A>, ...args: unknown[]) => unknown>,\n> {\n id: Id\n state: () => S\n getters?: G\n actions?: A\n}\n\n/**\n * Store 实例的公共 API 接口\n *\n * 提供状态读取、订阅、补丁、重置、Action 监听和生命周期管理等能力。\n *\n * @typeParam Id - Store 唯一标识符类型\n * @typeParam S - 状态树类型\n * @typeParam G - 计算属性定义类型\n * @typeParam A - Action 定义类型\n */\nexport interface StoreAPI<\n Id extends StoreId = StoreId,\n S extends StateTree = StateTree,\n G extends Record<string, (state: S) => unknown> = Record<string, never>,\n A extends Record<string, (...args: unknown[]) => unknown> = Record<string, never>,\n> {\n readonly $id: Id\n readonly $state: S\n $reset: () => void\n $patch: (partial: Partial<S> | ((state: S) => void)) => void\n $subscribe: (callback: StateSubscriber<S>, options?: { immediate?: boolean }) => Unsubscribe\n $onAction: (callback: ActionSubscriber<A>) => Unsubscribe\n $dispose: () => void\n readonly getters: { [K in keyof G]: ReturnType<G[K]> }\n readonly actions: { [K in keyof A]: A[K] }\n}\n\n/**\n * 创建 Store 的工厂函数\n *\n * 返回一个惰性初始化的工厂函数。首次调用时基于定义创建 Store 实例,\n * 后续调用返回缓存的单例,直到 $dispose() 被调用后重置。\n *\n * @typeParam Id - Store 唯一标识符类型\n * @typeParam S - 状态树类型\n * @typeParam G - 计算属性定义类型\n * @typeParam A - Action 定义类型\n * @param definition - Store 定义,包含 id、state 工厂、getters 和 actions\n * @returns 惰性初始化的 Store 工厂函数,调用后返回 StoreAPI 实例\n */\nexport function createStore<\n Id extends StoreId,\n S extends StateTree,\n G extends Record<string, (state: S) => unknown> = Record<string, never>,\n A extends Record<string, (this: StoreAPI<Id, S, G, A>, ...args: unknown[]) => unknown> = Record<string, never>,\n>(\n definition: CreateStoreDefinition<Id, S, G, A>,\n): () => StoreAPI<Id, S, G, A> {\n let instance: StoreAPI<Id, S, G, A> | null = null\n\n return (): StoreAPI<Id, S, G, A> => {\n if (instance) {\n return instance\n }\n\n const store = new BaseStore<Id, S, G, A>(definition)\n const originalDispose = store.$dispose.bind(store)\n store.$dispose = (): void => {\n originalDispose()\n instance = null\n }\n\n instance = store as unknown as StoreAPI<Id, S, G, A>\n\n return store\n }\n}\n\n/** 状态变更类型,支持部分更新或通过函数直接修改状态 */\nexport type { StateMutation }\n"],"mappings":";;;;;;;;;;;;;AA8EO,SAAS,YAMd,YAC6B;CAC7B,IAAI,WAAyC;CAE7C,aAAoC;EAClC,IAAI,UACF,OAAO;EAGT,MAAM,QAAQ,IAAI,mBAAA,UAAuB,UAAU;EACnD,MAAM,kBAAkB,MAAM,SAAS,KAAK,KAAK;EACjD,MAAM,iBAAuB;GAC3B,gBAAgB;GAChB,WAAW;EACb;EAEA,WAAW;EAEX,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module store/core/create-store
|
|
3
|
+
*
|
|
4
|
+
* Store 工厂函数,用于创建单例 Store 的惰性初始化函数。
|
|
5
|
+
* 基于 BaseStore 实现,返回的工厂函数在首次调用时创建 Store 实例,
|
|
6
|
+
* 后续调用返回同一实例,直到调用 $dispose() 后重置。
|
|
7
|
+
*/
|
|
8
|
+
import type { ActionSubscriber, StateMutation, StateSubscriber, StateTree, StoreId, Unsubscribe } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Store 定义描述接口
|
|
11
|
+
*
|
|
12
|
+
* @typeParam Id - Store 唯一标识符类型
|
|
13
|
+
* @typeParam S - 状态树类型
|
|
14
|
+
* @typeParam G - 计算属性定义类型
|
|
15
|
+
* @typeParam A - Action 定义类型
|
|
16
|
+
*/
|
|
17
|
+
export interface CreateStoreDefinition<Id extends StoreId, S extends StateTree, G extends Record<string, (state: S) => unknown>, A extends Record<string, (this: StoreAPI<Id, S, G, A>, ...args: unknown[]) => unknown>> {
|
|
18
|
+
id: Id;
|
|
19
|
+
state: () => S;
|
|
20
|
+
getters?: G;
|
|
21
|
+
actions?: A;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Store 实例的公共 API 接口
|
|
25
|
+
*
|
|
26
|
+
* 提供状态读取、订阅、补丁、重置、Action 监听和生命周期管理等能力。
|
|
27
|
+
*
|
|
28
|
+
* @typeParam Id - Store 唯一标识符类型
|
|
29
|
+
* @typeParam S - 状态树类型
|
|
30
|
+
* @typeParam G - 计算属性定义类型
|
|
31
|
+
* @typeParam A - Action 定义类型
|
|
32
|
+
*/
|
|
33
|
+
export interface StoreAPI<Id extends StoreId = StoreId, S extends StateTree = StateTree, G extends Record<string, (state: S) => unknown> = Record<string, never>, A extends Record<string, (...args: unknown[]) => unknown> = Record<string, never>> {
|
|
34
|
+
readonly $id: Id;
|
|
35
|
+
readonly $state: S;
|
|
36
|
+
$reset: () => void;
|
|
37
|
+
$patch: (partial: Partial<S> | ((state: S) => void)) => void;
|
|
38
|
+
$subscribe: (callback: StateSubscriber<S>, options?: {
|
|
39
|
+
immediate?: boolean;
|
|
40
|
+
}) => Unsubscribe;
|
|
41
|
+
$onAction: (callback: ActionSubscriber<A>) => Unsubscribe;
|
|
42
|
+
$dispose: () => void;
|
|
43
|
+
readonly getters: {
|
|
44
|
+
[K in keyof G]: ReturnType<G[K]>;
|
|
45
|
+
};
|
|
46
|
+
readonly actions: {
|
|
47
|
+
[K in keyof A]: A[K];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 创建 Store 的工厂函数
|
|
52
|
+
*
|
|
53
|
+
* 返回一个惰性初始化的工厂函数。首次调用时基于定义创建 Store 实例,
|
|
54
|
+
* 后续调用返回缓存的单例,直到 $dispose() 被调用后重置。
|
|
55
|
+
*
|
|
56
|
+
* @typeParam Id - Store 唯一标识符类型
|
|
57
|
+
* @typeParam S - 状态树类型
|
|
58
|
+
* @typeParam G - 计算属性定义类型
|
|
59
|
+
* @typeParam A - Action 定义类型
|
|
60
|
+
* @param definition - Store 定义,包含 id、state 工厂、getters 和 actions
|
|
61
|
+
* @returns 惰性初始化的 Store 工厂函数,调用后返回 StoreAPI 实例
|
|
62
|
+
*/
|
|
63
|
+
export declare function createStore<Id extends StoreId, S extends StateTree, G extends Record<string, (state: S) => unknown> = Record<string, never>, A extends Record<string, (this: StoreAPI<Id, S, G, A>, ...args: unknown[]) => unknown> = Record<string, never>>(definition: CreateStoreDefinition<Id, S, G, A>): () => StoreAPI<Id, S, G, A>;
|
|
64
|
+
/** 状态变更类型,支持部分更新或通过函数直接修改状态 */
|
|
65
|
+
export type { StateMutation };
|
|
66
|
+
//# sourceMappingURL=create-store.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/store-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:27:33 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
//#region src/core/event-bus.ts
|
|
13
|
+
function createEventBus() {
|
|
14
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
15
|
+
const getListeners = (type) => {
|
|
16
|
+
let set = listeners.get(type);
|
|
17
|
+
if (!set) {
|
|
18
|
+
set = /* @__PURE__ */ new Set();
|
|
19
|
+
listeners.set(type, set);
|
|
20
|
+
}
|
|
21
|
+
return set;
|
|
22
|
+
};
|
|
23
|
+
const on = (type, listener) => {
|
|
24
|
+
const set = getListeners(type);
|
|
25
|
+
set.add(listener);
|
|
26
|
+
return () => {
|
|
27
|
+
set.delete(listener);
|
|
28
|
+
if (set.size === 0) listeners.delete(type);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const off = (type, listener) => {
|
|
32
|
+
if (listener) {
|
|
33
|
+
const set = listeners.get(type);
|
|
34
|
+
if (set) {
|
|
35
|
+
set.delete(listener);
|
|
36
|
+
if (set.size === 0) listeners.delete(type);
|
|
37
|
+
}
|
|
38
|
+
} else listeners.delete(type);
|
|
39
|
+
};
|
|
40
|
+
const once = (type, listener) => {
|
|
41
|
+
const wrappedListener = (data) => {
|
|
42
|
+
listener(data);
|
|
43
|
+
off(type, wrappedListener);
|
|
44
|
+
};
|
|
45
|
+
return on(type, wrappedListener);
|
|
46
|
+
};
|
|
47
|
+
const emit = (type, payload) => {
|
|
48
|
+
const data = {
|
|
49
|
+
type,
|
|
50
|
+
payload,
|
|
51
|
+
timestamp: Date.now()
|
|
52
|
+
};
|
|
53
|
+
const typeListeners = listeners.get(type);
|
|
54
|
+
if (typeListeners) typeListeners.forEach((listener) => listener(data));
|
|
55
|
+
const wildcardListeners = listeners.get("*");
|
|
56
|
+
if (wildcardListeners) wildcardListeners.forEach((listener) => listener(data));
|
|
57
|
+
};
|
|
58
|
+
const clear = () => {
|
|
59
|
+
listeners.clear();
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
on,
|
|
63
|
+
once,
|
|
64
|
+
off,
|
|
65
|
+
emit,
|
|
66
|
+
clear
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const globalEventBus = createEventBus();
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.createEventBus = createEventBus;
|
|
72
|
+
exports.globalEventBus = globalEventBus;
|
|
73
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|
|
74
|
+
//# sourceMappingURL=event-bus.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.cjs","names":[],"sources":["../../src/core/event-bus.ts"],"sourcesContent":["/**\n * 事件总线实现\n *\n * 提供事件的发布/订阅功能\n * @module core/event-bus\n */\n\nimport type { EventBus, EventData, EventListener, EventType, Unsubscribe } from '../types'\n\n/**\n * 创建事件总线\n *\n * @returns 事件总线实例\n *\n * @example\n * ```typescript\n * const bus = createEventBus()\n *\n * // 监听事件\n * const unsubscribe = bus.on('state:changed', (data) => {\n * console.log('状态变化:', data)\n * })\n *\n * // 发送事件\n * bus.emit('state:changed', { storeId: 'counter', newValue: 1 })\n *\n * // 取消监听\n * unsubscribe()\n * ```\n */\nexport function createEventBus(): EventBus {\n /** 事件监听器映射 */\n const listeners = new Map<EventType | '*', Set<EventListener>>()\n\n /**\n * 获取或创建监听器集合\n */\n const getListeners = (type: EventType | '*'): Set<EventListener> => {\n let set = listeners.get(type)\n if (!set) {\n set = new Set()\n listeners.set(type, set)\n }\n return set\n }\n\n /**\n * 监听事件\n */\n const on = (type: EventType | '*', listener: EventListener): Unsubscribe => {\n const set = getListeners(type)\n set.add(listener)\n\n return () => {\n set.delete(listener)\n if (set.size === 0) {\n listeners.delete(type)\n }\n }\n }\n\n /**\n * 取消监听\n */\n const off = (type: EventType | '*', listener?: EventListener): void => {\n if (listener) {\n const set = listeners.get(type)\n if (set) {\n set.delete(listener)\n if (set.size === 0) {\n listeners.delete(type)\n }\n }\n }\n else {\n listeners.delete(type)\n }\n }\n\n /**\n * 监听一次\n */\n const once = (type: EventType, listener: EventListener): Unsubscribe => {\n const wrappedListener: EventListener = (data) => {\n listener(data)\n off(type, wrappedListener)\n }\n return on(type, wrappedListener)\n }\n\n /**\n * 发送事件\n */\n const emit = (type: EventType, payload?: unknown): void => {\n const data: EventData = {\n type,\n payload,\n timestamp: Date.now(),\n }\n\n // 触发特定类型的监听器\n const typeListeners = listeners.get(type)\n if (typeListeners) {\n typeListeners.forEach(listener => listener(data))\n }\n\n // 触发通配符监听器\n const wildcardListeners = listeners.get('*')\n if (wildcardListeners) {\n wildcardListeners.forEach(listener => listener(data))\n }\n }\n\n /**\n * 清空所有监听器\n */\n const clear = (): void => {\n listeners.clear()\n }\n\n return {\n on,\n once,\n off,\n emit,\n clear,\n }\n}\n\n/**\n * 全局事件总线实例\n */\nexport const globalEventBus = createEventBus()\n\n"],"mappings":";;;;;;;;;;;;AA8BO,SAAS,iBAA2B;CAEzC,MAAM,4BAAY,IAAI,IAAyC;CAK/D,MAAM,gBAAgB,SAA8C;EAClE,IAAI,MAAM,UAAU,IAAI,IAAI;EAC5B,IAAI,CAAC,KAAK;GACR,sBAAM,IAAI,IAAI;GACd,UAAU,IAAI,MAAM,GAAG;EACzB;EACA,OAAO;CACT;CAKA,MAAM,MAAM,MAAuB,aAAyC;EAC1E,MAAM,MAAM,aAAa,IAAI;EAC7B,IAAI,IAAI,QAAQ;EAEhB,aAAa;GACX,IAAI,OAAO,QAAQ;GACnB,IAAI,IAAI,SAAS,GACf,UAAU,OAAO,IAAI;EAEzB;CACF;CAKA,MAAM,OAAO,MAAuB,aAAmC;EACrE,IAAI,UAAU;GACZ,MAAM,MAAM,UAAU,IAAI,IAAI;GAC9B,IAAI,KAAK;IACP,IAAI,OAAO,QAAQ;IACnB,IAAI,IAAI,SAAS,GACf,UAAU,OAAO,IAAI;GAEzB;EACF,OAEE,UAAU,OAAO,IAAI;CAEzB;CAKA,MAAM,QAAQ,MAAiB,aAAyC;EACtE,MAAM,mBAAkC,SAAS;GAC/C,SAAS,IAAI;GACb,IAAI,MAAM,eAAe;EAC3B;EACA,OAAO,GAAG,MAAM,eAAe;CACjC;CAKA,MAAM,QAAQ,MAAiB,YAA4B;EACzD,MAAM,OAAkB;GACtB;GACA;GACA,WAAW,KAAK,IAAI;EACtB;EAGA,MAAM,gBAAgB,UAAU,IAAI,IAAI;EACxC,IAAI,eACF,cAAc,SAAQ,aAAY,SAAS,IAAI,CAAC;EAIlD,MAAM,oBAAoB,UAAU,IAAI,GAAG;EAC3C,IAAI,mBACF,kBAAkB,SAAQ,aAAY,SAAS,IAAI,CAAC;CAExD;CAKA,MAAM,cAAoB;EACxB,UAAU,MAAM;CAClB;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;CACF;AACF;AAKO,MAAM,iBAAiB,eAAe"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事件总线实现
|
|
3
|
+
*
|
|
4
|
+
* 提供事件的发布/订阅功能
|
|
5
|
+
* @module core/event-bus
|
|
6
|
+
*/
|
|
7
|
+
import type { EventBus } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* 创建事件总线
|
|
10
|
+
*
|
|
11
|
+
* @returns 事件总线实例
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const bus = createEventBus()
|
|
16
|
+
*
|
|
17
|
+
* // 监听事件
|
|
18
|
+
* const unsubscribe = bus.on('state:changed', (data) => {
|
|
19
|
+
* console.log('状态变化:', data)
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* // 发送事件
|
|
23
|
+
* bus.emit('state:changed', { storeId: 'counter', newValue: 1 })
|
|
24
|
+
*
|
|
25
|
+
* // 取消监听
|
|
26
|
+
* unsubscribe()
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createEventBus(): EventBus;
|
|
30
|
+
/**
|
|
31
|
+
* 全局事件总线实例
|
|
32
|
+
*/
|
|
33
|
+
export declare const globalEventBus: EventBus;
|
|
34
|
+
//# sourceMappingURL=event-bus.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/store-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:27:33 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
const require_pub_sub = require("./pub-sub.cjs");
|
|
13
|
+
const require_async_action = require("./async-action.cjs");
|
|
14
|
+
const require_event_bus = require("./event-bus.cjs");
|
|
15
|
+
const require_base_store = require("./base-store.cjs");
|
|
16
|
+
const require_batch_manager = require("./batch-manager.cjs");
|
|
17
|
+
const require_create_store = require("./create-store.cjs");
|
|
18
|
+
exports.BaseStore = require_base_store.BaseStore;
|
|
19
|
+
exports.batch = require_batch_manager.batch;
|
|
20
|
+
exports.createAsyncAction = require_async_action.createAsyncAction;
|
|
21
|
+
exports.createBatchManager = require_batch_manager.createBatchManager;
|
|
22
|
+
exports.createEventBus = require_event_bus.createEventBus;
|
|
23
|
+
exports.createPubSub = require_pub_sub.createPubSub;
|
|
24
|
+
exports.createPubSubWithValue = require_pub_sub.createPubSubWithValue;
|
|
25
|
+
exports.createStore = require_create_store.createStore;
|
|
26
|
+
exports.getGlobalBatchManager = require_batch_manager.getGlobalBatchManager;
|
|
27
|
+
exports.globalEventBus = require_event_bus.globalEventBus;
|
|
28
|
+
exports.setGlobalBatchManager = require_batch_manager.setGlobalBatchManager;
|
|
29
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 核心模块导出
|
|
3
|
+
*
|
|
4
|
+
* @module core
|
|
5
|
+
*/
|
|
6
|
+
export { createAsyncAction } from './async-action';
|
|
7
|
+
export type { AsyncAction, AsyncActionOptions, AsyncActionState } from './async-action';
|
|
8
|
+
export { BaseStore } from './base-store';
|
|
9
|
+
export { batch, createBatchManager, getGlobalBatchManager, setGlobalBatchManager, } from './batch-manager';
|
|
10
|
+
export { createStore } from './create-store';
|
|
11
|
+
export type { CreateStoreDefinition, StoreAPI } from './create-store';
|
|
12
|
+
export { createEventBus, globalEventBus } from './event-bus';
|
|
13
|
+
export { createPubSub, createPubSubWithValue } from './pub-sub';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/store-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:27:33 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
//#region src/core/pub-sub.ts
|
|
13
|
+
function createPubSub() {
|
|
14
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
15
|
+
const subscribe = (callback, options = {}) => {
|
|
16
|
+
const info = {
|
|
17
|
+
callback,
|
|
18
|
+
options
|
|
19
|
+
};
|
|
20
|
+
subscribers.add(info);
|
|
21
|
+
return () => {
|
|
22
|
+
subscribers.delete(info);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const publish = (value, oldValue) => {
|
|
26
|
+
subscribers.forEach((info) => {
|
|
27
|
+
try {
|
|
28
|
+
info.callback(value, oldValue);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error("[PubSub] 订阅回调执行出错:", error);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const clear = () => {
|
|
35
|
+
subscribers.clear();
|
|
36
|
+
};
|
|
37
|
+
const size = () => {
|
|
38
|
+
return subscribers.size;
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
subscribe,
|
|
42
|
+
publish,
|
|
43
|
+
clear,
|
|
44
|
+
size
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function createPubSubWithValue(initialValue) {
|
|
48
|
+
let currentValue = initialValue;
|
|
49
|
+
const pubsub = createPubSub();
|
|
50
|
+
const getValue = () => currentValue;
|
|
51
|
+
const setValue = (value) => {
|
|
52
|
+
const oldValue = currentValue;
|
|
53
|
+
currentValue = value;
|
|
54
|
+
pubsub.publish(value, oldValue);
|
|
55
|
+
};
|
|
56
|
+
const subscribe = (callback, options = {}) => {
|
|
57
|
+
const unsubscribe = pubsub.subscribe(callback, options);
|
|
58
|
+
if (options.immediate) callback(currentValue);
|
|
59
|
+
return unsubscribe;
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
subscribe,
|
|
63
|
+
publish: pubsub.publish,
|
|
64
|
+
clear: pubsub.clear,
|
|
65
|
+
size: pubsub.size,
|
|
66
|
+
getValue,
|
|
67
|
+
setValue
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.createPubSub = createPubSub;
|
|
72
|
+
exports.createPubSubWithValue = createPubSubWithValue;
|
|
73
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|
|
74
|
+
//# sourceMappingURL=pub-sub.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pub-sub.cjs","names":[],"sources":["../../src/core/pub-sub.ts"],"sourcesContent":["/**\n * 发布订阅模式实现\n *\n * @module core/pub-sub\n */\n\nimport type { PubSub, Subscriber, SubscriptionOptions, Unsubscribe } from '../types'\n\n/**\n * 订阅者信息\n */\ninterface SubscriberInfo<T> {\n /** 回调函数 */\n callback: Subscriber<T>\n /** 订阅选项 */\n options: SubscriptionOptions\n}\n\n/**\n * 创建发布订阅管理器\n *\n * @template T - 数据类型\n * @returns 发布订阅管理器实例\n *\n * @example\n * ```typescript\n * const pubsub = createPubSub<number>()\n *\n * // 订阅\n * const unsubscribe = pubsub.subscribe((value, oldValue) => {\n * console.log(`值从 ${oldValue} 变为 ${value}`)\n * })\n *\n * // 发布\n * pubsub.publish(1, 0)\n *\n * // 取消订阅\n * unsubscribe()\n * ```\n */\nexport function createPubSub<T = unknown>(): PubSub<T> {\n /** 订阅者列表 */\n const subscribers = new Set<SubscriberInfo<T>>()\n\n /**\n * 订阅\n */\n const subscribe = (\n callback: Subscriber<T>,\n options: SubscriptionOptions = {},\n ): Unsubscribe => {\n const info: SubscriberInfo<T> = {\n callback,\n options,\n }\n subscribers.add(info)\n\n return () => {\n subscribers.delete(info)\n }\n }\n\n /**\n * 发布\n */\n const publish = (value: T, oldValue?: T): void => {\n subscribers.forEach((info) => {\n try {\n info.callback(value, oldValue)\n }\n catch (error) {\n console.error('[PubSub] 订阅回调执行出错:', error)\n }\n })\n }\n\n /**\n * 清空所有订阅\n */\n const clear = (): void => {\n subscribers.clear()\n }\n\n /**\n * 获取订阅者数量\n */\n const size = (): number => {\n return subscribers.size\n }\n\n return {\n subscribe,\n publish,\n clear,\n size,\n }\n}\n\n/**\n * 创建带立即执行的发布订阅管理器\n *\n * @template T - 数据类型\n * @param initialValue - 初始值\n * @returns 发布订阅管理器实例\n */\nexport function createPubSubWithValue<T>(initialValue: T): PubSub<T> & {\n getValue: () => T\n setValue: (value: T) => void\n} {\n let currentValue = initialValue\n const pubsub = createPubSub<T>()\n\n const getValue = (): T => currentValue\n\n const setValue = (value: T): void => {\n const oldValue = currentValue\n currentValue = value\n pubsub.publish(value, oldValue)\n }\n\n const subscribe = (\n callback: Subscriber<T>,\n options: SubscriptionOptions = {},\n ): Unsubscribe => {\n const unsubscribe = pubsub.subscribe(callback, options)\n\n // 立即执行\n if (options.immediate) {\n callback(currentValue)\n }\n\n return unsubscribe\n }\n\n return {\n subscribe,\n publish: pubsub.publish,\n clear: pubsub.clear,\n size: pubsub.size,\n getValue,\n setValue,\n }\n}\n\n"],"mappings":";;;;;;;;;;;;AAwCO,SAAS,eAAuC;CAErD,MAAM,8BAAc,IAAI,IAAuB;CAK/C,MAAM,aACJ,UACA,UAA+B,CAAC,MAChB;EAChB,MAAM,OAA0B;GAC9B;GACA;EACF;EACA,YAAY,IAAI,IAAI;EAEpB,aAAa;GACX,YAAY,OAAO,IAAI;EACzB;CACF;CAKA,MAAM,WAAW,OAAU,aAAuB;EAChD,YAAY,SAAS,SAAS;GAC5B,IAAI;IACF,KAAK,SAAS,OAAO,QAAQ;GAC/B,SACO,OAAO;IACZ,QAAQ,MAAM,sBAAsB,KAAK;GAC3C;EACF,CAAC;CACH;CAKA,MAAM,cAAoB;EACxB,YAAY,MAAM;CACpB;CAKA,MAAM,aAAqB;EACzB,OAAO,YAAY;CACrB;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;AASO,SAAS,sBAAyB,cAGvC;CACA,IAAI,eAAe;CACnB,MAAM,SAAS,aAAgB;CAE/B,MAAM,iBAAoB;CAE1B,MAAM,YAAY,UAAmB;EACnC,MAAM,WAAW;EACjB,eAAe;EACf,OAAO,QAAQ,OAAO,QAAQ;CAChC;CAEA,MAAM,aACJ,UACA,UAA+B,CAAC,MAChB;EAChB,MAAM,cAAc,OAAO,UAAU,UAAU,OAAO;EAGtD,IAAI,QAAQ,WACV,SAAS,YAAY;EAGvB,OAAO;CACT;CAEA,OAAO;EACL;EACA,SAAS,OAAO;EAChB,OAAO,OAAO;EACd,MAAM,OAAO;EACb;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 发布订阅模式实现
|
|
3
|
+
*
|
|
4
|
+
* @module core/pub-sub
|
|
5
|
+
*/
|
|
6
|
+
import type { PubSub } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* 创建发布订阅管理器
|
|
9
|
+
*
|
|
10
|
+
* @template T - 数据类型
|
|
11
|
+
* @returns 发布订阅管理器实例
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const pubsub = createPubSub<number>()
|
|
16
|
+
*
|
|
17
|
+
* // 订阅
|
|
18
|
+
* const unsubscribe = pubsub.subscribe((value, oldValue) => {
|
|
19
|
+
* console.log(`值从 ${oldValue} 变为 ${value}`)
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* // 发布
|
|
23
|
+
* pubsub.publish(1, 0)
|
|
24
|
+
*
|
|
25
|
+
* // 取消订阅
|
|
26
|
+
* unsubscribe()
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createPubSub<T = unknown>(): PubSub<T>;
|
|
30
|
+
/**
|
|
31
|
+
* 创建带立即执行的发布订阅管理器
|
|
32
|
+
*
|
|
33
|
+
* @template T - 数据类型
|
|
34
|
+
* @param initialValue - 初始值
|
|
35
|
+
* @returns 发布订阅管理器实例
|
|
36
|
+
*/
|
|
37
|
+
export declare function createPubSubWithValue<T>(initialValue: T): PubSub<T> & {
|
|
38
|
+
getValue: () => T;
|
|
39
|
+
setValue: (value: T) => void;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=pub-sub.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/store-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:27:33 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
const require_plugin = require("./plugin.cjs");
|
|
13
|
+
exports.createStoreEngineBridge = require_plugin.createStoreEngineBridge;
|
|
14
|
+
exports.storeEventKeys = require_plugin.storeEventKeys;
|
|
15
|
+
exports.storeStateKeys = require_plugin.storeStateKeys;
|
|
16
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module store/engine
|
|
3
|
+
*
|
|
4
|
+
* Store 引擎桥接层的统一导出,提供将 Store 能力集成到 LDesign Engine 的工厂函数、
|
|
5
|
+
* 事件键和状态键。包含引擎 API、容器、事件总线等兼容接口类型,
|
|
6
|
+
* 供 Vue/React 等适配层复用。
|
|
7
|
+
*/
|
|
8
|
+
export { createStoreEngineBridge, storeEventKeys, storeStateKeys, } from './plugin';
|
|
9
|
+
export type { StoreEngineApi, StoreEngineApiLike, StoreEngineBridge, StoreEngineBridgeOptions, StoreEngineContainerLike, StoreEngineEventsLike, StoreEngineLike, StoreEngineLoggerLike, StoreEnginePluginContextLike, StoreEnginePluginOptions, StoreEngineRegisteredApi, StoreEngineStateLike, StoreRuntimeLike, } from './types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/store-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:27:33 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
const require_event_bus = require("../core/event-bus.cjs");
|
|
13
|
+
//#region src/engine/plugin.ts
|
|
14
|
+
const storeStateKeys = {
|
|
15
|
+
BUS: "store:bus",
|
|
16
|
+
PINIA: "store:pinia",
|
|
17
|
+
API: "store:api",
|
|
18
|
+
REGISTRY: "store:registry",
|
|
19
|
+
RUNTIME: "store:runtime"
|
|
20
|
+
};
|
|
21
|
+
const storeEventKeys = {
|
|
22
|
+
INSTALLED: "store:installed",
|
|
23
|
+
UNINSTALLED: "store:uninstalled"
|
|
24
|
+
};
|
|
25
|
+
function resolveEngine(context) {
|
|
26
|
+
const value = context;
|
|
27
|
+
if (value && typeof value === "object" && "engine" in value) return value.engine ?? {};
|
|
28
|
+
return value ?? {};
|
|
29
|
+
}
|
|
30
|
+
function resolvePluginContext(context) {
|
|
31
|
+
return context && typeof context === "object" ? context : void 0;
|
|
32
|
+
}
|
|
33
|
+
function resolveDefaultApp(engine, context, payload) {
|
|
34
|
+
const payloadObject = payload;
|
|
35
|
+
return payloadObject?.app ?? payloadObject?.framework?.app ?? engine.getApp?.() ?? context?.framework?.app;
|
|
36
|
+
}
|
|
37
|
+
function createRegisteredApi(name, version, runtime) {
|
|
38
|
+
return {
|
|
39
|
+
name,
|
|
40
|
+
version,
|
|
41
|
+
pinia: runtime.pinia,
|
|
42
|
+
getStore: runtime.storeAPI.getStore,
|
|
43
|
+
hasStore: runtime.storeAPI.hasStore,
|
|
44
|
+
getStoreIds: runtime.storeAPI.getStoreIds,
|
|
45
|
+
resetAll: runtime.storeAPI.resetAll
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function registerEngineApi(engine, name, version, runtime) {
|
|
49
|
+
if (!engine.api?.register) return;
|
|
50
|
+
const api = createRegisteredApi(name, version, runtime);
|
|
51
|
+
engine.api.unregister?.(name);
|
|
52
|
+
if (engine.api.register.length >= 2) {
|
|
53
|
+
engine.api.register(name, api);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
engine.api.register(api);
|
|
57
|
+
}
|
|
58
|
+
function syncEngineState(engine, name, options, runtime) {
|
|
59
|
+
engine.state?.set?.(storeStateKeys.RUNTIME, runtime);
|
|
60
|
+
engine.state?.set?.(storeStateKeys.PINIA, runtime.pinia);
|
|
61
|
+
engine.state?.set?.(storeStateKeys.API, runtime.storeAPI);
|
|
62
|
+
engine.state?.set?.(storeStateKeys.REGISTRY, runtime.registry);
|
|
63
|
+
engine.state?.set?.(storeStateKeys.BUS, require_event_bus.globalEventBus);
|
|
64
|
+
engine.state?.set?.(`plugins.${name}`, runtime.storeAPI);
|
|
65
|
+
engine.state?.set?.(`plugins.${name}.config`, options);
|
|
66
|
+
}
|
|
67
|
+
function clearEngineState(engine, name) {
|
|
68
|
+
engine.state?.delete?.(storeStateKeys.RUNTIME);
|
|
69
|
+
engine.state?.delete?.(storeStateKeys.PINIA);
|
|
70
|
+
engine.state?.delete?.(storeStateKeys.API);
|
|
71
|
+
engine.state?.delete?.(storeStateKeys.REGISTRY);
|
|
72
|
+
engine.state?.delete?.(storeStateKeys.BUS);
|
|
73
|
+
engine.state?.delete?.(`plugins.${name}`);
|
|
74
|
+
engine.state?.delete?.(`plugins.${name}.config`);
|
|
75
|
+
}
|
|
76
|
+
function registerContainerServices(context, runtime) {
|
|
77
|
+
if (!context?.container?.singleton) return;
|
|
78
|
+
try {
|
|
79
|
+
context.container.singleton("pinia", runtime.pinia);
|
|
80
|
+
context.container.singleton("storeAPI", runtime.storeAPI);
|
|
81
|
+
context.container.singleton("storeRegistry", runtime.registry);
|
|
82
|
+
context.container.singleton("storeRuntime", runtime);
|
|
83
|
+
} catch {}
|
|
84
|
+
}
|
|
85
|
+
function createStoreEngineBridge(options) {
|
|
86
|
+
const { createRuntime, debug = false, name = "store", onRuntimeChange, version = "1.0.0" } = options;
|
|
87
|
+
let activeEngine = {};
|
|
88
|
+
let activeContext;
|
|
89
|
+
let runtime = null;
|
|
90
|
+
let runtimeOwner = null;
|
|
91
|
+
const bindRuntime = (nextRuntime, owner) => {
|
|
92
|
+
const previousRuntime = runtime;
|
|
93
|
+
const previousOwner = runtimeOwner;
|
|
94
|
+
runtime = nextRuntime;
|
|
95
|
+
runtimeOwner = owner;
|
|
96
|
+
onRuntimeChange?.(nextRuntime);
|
|
97
|
+
syncEngineState(activeEngine, name, options, nextRuntime);
|
|
98
|
+
registerEngineApi(activeEngine, name, version, nextRuntime);
|
|
99
|
+
registerContainerServices(activeContext, nextRuntime);
|
|
100
|
+
if (previousRuntime && previousRuntime !== nextRuntime && previousOwner === "engine") previousRuntime.dispose?.();
|
|
101
|
+
return nextRuntime;
|
|
102
|
+
};
|
|
103
|
+
const ensureRuntime = () => {
|
|
104
|
+
if (runtime && runtimeOwner === "engine") return runtime;
|
|
105
|
+
return createRuntime();
|
|
106
|
+
};
|
|
107
|
+
const attachToApp = (app) => {
|
|
108
|
+
const installedRuntime = options.getRuntimeFromApp?.(app);
|
|
109
|
+
if (installedRuntime) return bindRuntime(installedRuntime, "external");
|
|
110
|
+
const nextRuntime = ensureRuntime();
|
|
111
|
+
const mountedRuntime = options.attachToApp ? options.attachToApp(app, nextRuntime) : nextRuntime;
|
|
112
|
+
return bindRuntime(mountedRuntime, mountedRuntime === nextRuntime ? "engine" : "external");
|
|
113
|
+
};
|
|
114
|
+
const install = async (context) => {
|
|
115
|
+
activeEngine = resolveEngine(context);
|
|
116
|
+
activeContext = resolvePluginContext(context);
|
|
117
|
+
const app = options.resolveApp ? options.resolveApp(activeEngine, activeContext ?? {}, void 0) : resolveDefaultApp(activeEngine, activeContext);
|
|
118
|
+
if (app && (!options.isApp || options.isApp(app))) attachToApp(app);
|
|
119
|
+
else {
|
|
120
|
+
bindRuntime(ensureRuntime(), "engine");
|
|
121
|
+
activeEngine.events?.once?.("app:created", (payload) => {
|
|
122
|
+
const createdApp = options.resolveApp ? options.resolveApp(activeEngine, activeContext ?? {}, payload) : resolveDefaultApp(activeEngine, activeContext, payload);
|
|
123
|
+
if (createdApp && (!options.isApp || options.isApp(createdApp))) attachToApp(createdApp);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
await activeEngine.events?.emit?.(storeEventKeys.INSTALLED, {
|
|
127
|
+
name,
|
|
128
|
+
version,
|
|
129
|
+
pinia: runtime?.pinia,
|
|
130
|
+
storeAPI: runtime?.storeAPI
|
|
131
|
+
});
|
|
132
|
+
if (debug) activeEngine.logger?.info?.("[StoreEngineBridge] installed");
|
|
133
|
+
};
|
|
134
|
+
const uninstall = async (context) => {
|
|
135
|
+
const engine = context ? resolveEngine(context) : activeEngine;
|
|
136
|
+
engine.api?.unregister?.(name);
|
|
137
|
+
clearEngineState(engine, name);
|
|
138
|
+
await engine.events?.emit?.(storeEventKeys.UNINSTALLED, { name });
|
|
139
|
+
if (runtime && runtimeOwner === "engine") runtime.dispose?.();
|
|
140
|
+
runtime = null;
|
|
141
|
+
runtimeOwner = null;
|
|
142
|
+
onRuntimeChange?.(null);
|
|
143
|
+
if (debug) engine.logger?.info?.("[StoreEngineBridge] uninstalled");
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
attachToApp,
|
|
147
|
+
getRuntime: () => runtime,
|
|
148
|
+
install,
|
|
149
|
+
uninstall
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
exports.createStoreEngineBridge = createStoreEngineBridge;
|
|
154
|
+
exports.storeEventKeys = storeEventKeys;
|
|
155
|
+
exports.storeStateKeys = storeStateKeys;
|
|
156
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|
|
157
|
+
//# sourceMappingURL=plugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":[],"sources":["../../src/engine/plugin.ts"],"sourcesContent":["/**\n * @composy/store-core Engine 桥接能力\n *\n * Core 负责 engine 生命周期、state/API 同步和事件派发;框架适配层只提供 runtime 创建与 App 挂载。\n * @module engine/plugin\n */\n\nimport type {\n StoreEngineBridge,\n StoreEngineBridgeOptions,\n StoreEngineLike,\n StoreEnginePluginContextLike,\n StoreEngineRegisteredApi,\n StoreRuntimeLike,\n} from './types'\nimport { globalEventBus } from '../core/event-bus'\n\nexport const storeStateKeys = {\n BUS: 'store:bus' as const,\n PINIA: 'store:pinia' as const,\n API: 'store:api' as const,\n REGISTRY: 'store:registry' as const,\n RUNTIME: 'store:runtime' as const,\n} as const\n\nexport const storeEventKeys = {\n INSTALLED: 'store:installed' as const,\n UNINSTALLED: 'store:uninstalled' as const,\n} as const\n\ntype RuntimeOwner = 'engine' | 'external'\n\nfunction resolveEngine(context: unknown): StoreEngineLike {\n const value = context as StoreEnginePluginContextLike | StoreEngineLike | null | undefined\n if (value && typeof value === 'object' && 'engine' in value) {\n return value.engine ?? {}\n }\n\n return (value ?? {}) as StoreEngineLike\n}\n\nfunction resolvePluginContext(context: unknown): StoreEnginePluginContextLike | undefined {\n return context && typeof context === 'object'\n ? context as StoreEnginePluginContextLike\n : undefined\n}\n\nfunction resolveDefaultApp(\n engine: StoreEngineLike,\n context: StoreEnginePluginContextLike | undefined,\n payload?: unknown,\n): unknown {\n const payloadObject = payload as { app?: unknown; framework?: { app?: unknown } } | undefined\n return payloadObject?.app\n ?? payloadObject?.framework?.app\n ?? engine.getApp?.()\n ?? context?.framework?.app\n}\n\nfunction createRegisteredApi(\n name: string,\n version: string,\n runtime: StoreRuntimeLike,\n): StoreEngineRegisteredApi {\n return {\n name,\n version,\n pinia: runtime.pinia,\n getStore: runtime.storeAPI.getStore,\n hasStore: runtime.storeAPI.hasStore,\n getStoreIds: runtime.storeAPI.getStoreIds,\n resetAll: runtime.storeAPI.resetAll,\n }\n}\n\nfunction registerEngineApi(\n engine: StoreEngineLike,\n name: string,\n version: string,\n runtime: StoreRuntimeLike,\n): void {\n if (!engine.api?.register) {\n return\n }\n\n const api = createRegisteredApi(name, version, runtime)\n engine.api.unregister?.(name)\n\n if (engine.api.register.length >= 2) {\n ;(engine.api.register as (name: string, api: StoreEngineRegisteredApi) => void)(name, api)\n return\n }\n\n ;(engine.api.register as (api: StoreEngineRegisteredApi) => void)(api)\n}\n\nfunction syncEngineState<Runtime extends StoreRuntimeLike>(\n engine: StoreEngineLike,\n name: string,\n options: StoreEngineBridgeOptions<Runtime>,\n runtime: Runtime,\n): void {\n engine.state?.set?.(storeStateKeys.RUNTIME, runtime)\n engine.state?.set?.(storeStateKeys.PINIA, runtime.pinia)\n engine.state?.set?.(storeStateKeys.API, runtime.storeAPI)\n engine.state?.set?.(storeStateKeys.REGISTRY, runtime.registry)\n engine.state?.set?.(storeStateKeys.BUS, globalEventBus)\n engine.state?.set?.(`plugins.${name}`, runtime.storeAPI)\n engine.state?.set?.(`plugins.${name}.config`, options)\n}\n\nfunction clearEngineState(engine: StoreEngineLike, name: string): void {\n engine.state?.delete?.(storeStateKeys.RUNTIME)\n engine.state?.delete?.(storeStateKeys.PINIA)\n engine.state?.delete?.(storeStateKeys.API)\n engine.state?.delete?.(storeStateKeys.REGISTRY)\n engine.state?.delete?.(storeStateKeys.BUS)\n engine.state?.delete?.(`plugins.${name}`)\n engine.state?.delete?.(`plugins.${name}.config`)\n}\n\nfunction registerContainerServices(\n context: StoreEnginePluginContextLike | undefined,\n runtime: StoreRuntimeLike,\n): void {\n if (!context?.container?.singleton) {\n return\n }\n\n try {\n context.container.singleton('pinia', runtime.pinia)\n context.container.singleton('storeAPI', runtime.storeAPI)\n context.container.singleton('storeRegistry', runtime.registry)\n context.container.singleton('storeRuntime', runtime)\n }\n catch {\n // 同一个 engine 重复安装时可能已存在单例,保持幂等即可。\n }\n}\n\nexport function createStoreEngineBridge<Runtime extends StoreRuntimeLike>(\n options: StoreEngineBridgeOptions<Runtime>,\n): StoreEngineBridge {\n const {\n createRuntime,\n debug = false,\n name = 'store',\n onRuntimeChange,\n version = '1.0.0',\n } = options\n\n let activeEngine: StoreEngineLike = {}\n let activeContext: StoreEnginePluginContextLike | undefined\n let runtime: Runtime | null = null\n let runtimeOwner: RuntimeOwner | null = null\n\n const bindRuntime = (\n nextRuntime: Runtime,\n owner: RuntimeOwner,\n ): Runtime => {\n const previousRuntime = runtime\n const previousOwner = runtimeOwner\n\n runtime = nextRuntime\n runtimeOwner = owner\n onRuntimeChange?.(nextRuntime)\n\n syncEngineState(activeEngine, name, options, nextRuntime)\n registerEngineApi(activeEngine, name, version, nextRuntime)\n registerContainerServices(activeContext, nextRuntime)\n\n if (\n previousRuntime\n && previousRuntime !== nextRuntime\n && previousOwner === 'engine'\n ) {\n previousRuntime.dispose?.()\n }\n\n return nextRuntime\n }\n\n const ensureRuntime = (): Runtime => {\n if (runtime && runtimeOwner === 'engine') {\n return runtime\n }\n\n return createRuntime()\n }\n\n const attachToApp = (app: unknown): Runtime => {\n const installedRuntime = options.getRuntimeFromApp?.(app)\n if (installedRuntime) {\n return bindRuntime(installedRuntime, 'external')\n }\n\n const nextRuntime = ensureRuntime()\n const mountedRuntime = options.attachToApp\n ? options.attachToApp(app, nextRuntime)\n : nextRuntime\n const owner: RuntimeOwner = mountedRuntime === nextRuntime ? 'engine' : 'external'\n return bindRuntime(mountedRuntime, owner)\n }\n\n const install = async (context: unknown): Promise<void> => {\n activeEngine = resolveEngine(context)\n activeContext = resolvePluginContext(context)\n\n const app = options.resolveApp\n ? options.resolveApp(activeEngine, activeContext ?? {}, undefined)\n : resolveDefaultApp(activeEngine, activeContext)\n\n if (app && (!options.isApp || options.isApp(app))) {\n attachToApp(app)\n }\n else {\n bindRuntime(ensureRuntime(), 'engine')\n activeEngine.events?.once?.('app:created', (payload?: unknown) => {\n const createdApp = options.resolveApp\n ? options.resolveApp(activeEngine, activeContext ?? {}, payload)\n : resolveDefaultApp(activeEngine, activeContext, payload)\n if (createdApp && (!options.isApp || options.isApp(createdApp))) {\n attachToApp(createdApp)\n }\n })\n }\n\n await activeEngine.events?.emit?.(storeEventKeys.INSTALLED, {\n name,\n version,\n pinia: runtime?.pinia,\n storeAPI: runtime?.storeAPI,\n })\n\n if (debug) {\n activeEngine.logger?.info?.('[StoreEngineBridge] installed')\n }\n }\n\n const uninstall = async (context?: unknown): Promise<void> => {\n const engine = context ? resolveEngine(context) : activeEngine\n\n engine.api?.unregister?.(name)\n clearEngineState(engine, name)\n await engine.events?.emit?.(storeEventKeys.UNINSTALLED, { name })\n\n if (runtime && runtimeOwner === 'engine') {\n runtime.dispose?.()\n }\n\n runtime = null\n runtimeOwner = null\n onRuntimeChange?.(null)\n\n if (debug) {\n engine.logger?.info?.('[StoreEngineBridge] uninstalled')\n }\n }\n\n return {\n attachToApp,\n getRuntime: () => runtime,\n install,\n uninstall,\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @composy/store-core Engine 桥接能力
|
|
3
|
+
*
|
|
4
|
+
* Core 负责 engine 生命周期、state/API 同步和事件派发;框架适配层只提供 runtime 创建与 App 挂载。
|
|
5
|
+
* @module engine/plugin
|
|
6
|
+
*/
|
|
7
|
+
import type { StoreEngineBridge, StoreEngineBridgeOptions, StoreRuntimeLike } from './types';
|
|
8
|
+
export declare const storeStateKeys: {
|
|
9
|
+
readonly BUS: "store:bus";
|
|
10
|
+
readonly PINIA: "store:pinia";
|
|
11
|
+
readonly API: "store:api";
|
|
12
|
+
readonly REGISTRY: "store:registry";
|
|
13
|
+
readonly RUNTIME: "store:runtime";
|
|
14
|
+
};
|
|
15
|
+
export declare const storeEventKeys: {
|
|
16
|
+
readonly INSTALLED: "store:installed";
|
|
17
|
+
readonly UNINSTALLED: "store:uninstalled";
|
|
18
|
+
};
|
|
19
|
+
export declare function createStoreEngineBridge<Runtime extends StoreRuntimeLike>(options: StoreEngineBridgeOptions<Runtime>): StoreEngineBridge;
|
|
20
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/store-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:27:33 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|