@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,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Engine 集成类型
|
|
3
|
+
*
|
|
4
|
+
* 这里仅描述框架无关的 engine 契约;Vue/React 等适配层负责提供真实 runtime。
|
|
5
|
+
* @module engine/types
|
|
6
|
+
*/
|
|
7
|
+
import type { EventBus, StoreId } from '../types';
|
|
8
|
+
export interface StoreRuntimeLike {
|
|
9
|
+
pinia?: unknown;
|
|
10
|
+
registry?: unknown;
|
|
11
|
+
storeAPI: StoreEngineApi;
|
|
12
|
+
dispose?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface StoreEngineApi {
|
|
15
|
+
pinia?: unknown;
|
|
16
|
+
getStore: <T = unknown>(id: StoreId) => T | undefined;
|
|
17
|
+
hasStore: (id: StoreId) => boolean;
|
|
18
|
+
getStoreIds: () => StoreId[];
|
|
19
|
+
resetAll: () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface StoreEngineApiLike {
|
|
22
|
+
register?: ((api: StoreEngineRegisteredApi) => void) | ((name: string, api: StoreEngineRegisteredApi) => void);
|
|
23
|
+
unregister?: (name: string) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface StoreEngineEventsLike {
|
|
26
|
+
emit?: (event: string, payload: unknown) => void | Promise<void>;
|
|
27
|
+
once?: (event: string, listener: (payload?: unknown) => void | Promise<void>) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface StoreEngineStateLike {
|
|
30
|
+
delete?: (key: string) => void;
|
|
31
|
+
set?: (key: string, value: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface StoreEngineLoggerLike {
|
|
34
|
+
info?: (...args: unknown[]) => void;
|
|
35
|
+
}
|
|
36
|
+
export interface StoreEngineContainerLike {
|
|
37
|
+
has?: (identifier: string | symbol) => boolean;
|
|
38
|
+
resolve?: <T = unknown>(identifier: string | symbol) => T;
|
|
39
|
+
singleton?: (identifier: string | symbol, implementation: unknown) => void;
|
|
40
|
+
}
|
|
41
|
+
export interface StoreEngineLike {
|
|
42
|
+
api?: StoreEngineApiLike;
|
|
43
|
+
container?: StoreEngineContainerLike;
|
|
44
|
+
events?: StoreEngineEventsLike;
|
|
45
|
+
getApp?: () => unknown;
|
|
46
|
+
logger?: StoreEngineLoggerLike;
|
|
47
|
+
state?: StoreEngineStateLike;
|
|
48
|
+
}
|
|
49
|
+
export interface StoreEnginePluginContextLike {
|
|
50
|
+
container?: StoreEngineContainerLike;
|
|
51
|
+
engine?: StoreEngineLike;
|
|
52
|
+
framework?: {
|
|
53
|
+
app?: unknown;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface StoreEngineRegisteredApi extends StoreEngineApi {
|
|
57
|
+
name: string;
|
|
58
|
+
version: string;
|
|
59
|
+
}
|
|
60
|
+
export interface StoreEnginePluginOptions {
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
dependencies?: string[];
|
|
63
|
+
name?: string;
|
|
64
|
+
version?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface StoreEngineBridgeOptions<Runtime extends StoreRuntimeLike = StoreRuntimeLike> extends StoreEnginePluginOptions {
|
|
67
|
+
createRuntime: () => Runtime;
|
|
68
|
+
attachToApp?: (app: unknown, runtime: Runtime) => Runtime;
|
|
69
|
+
getRuntimeFromApp?: (app: unknown) => Runtime | null | undefined;
|
|
70
|
+
isApp?: (value: unknown) => boolean;
|
|
71
|
+
onRuntimeChange?: (runtime: Runtime | null) => void;
|
|
72
|
+
resolveApp?: (engine: StoreEngineLike, context: StoreEnginePluginContextLike, payload?: unknown) => unknown;
|
|
73
|
+
}
|
|
74
|
+
export interface StoreEngineBridge {
|
|
75
|
+
attachToApp: (app: unknown) => StoreRuntimeLike;
|
|
76
|
+
getRuntime: () => StoreRuntimeLike | null;
|
|
77
|
+
install: (context: unknown) => Promise<void>;
|
|
78
|
+
uninstall: (context?: unknown) => Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
export type { EventBus };
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,233 @@
|
|
|
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/errors/index.ts
|
|
13
|
+
var StoreErrorCode = /* @__PURE__ */ ((StoreErrorCode2) => {
|
|
14
|
+
StoreErrorCode2["STORE_DISPOSED"] = "STORE_DISPOSED";
|
|
15
|
+
StoreErrorCode2["STORE_NOT_FOUND"] = "STORE_NOT_FOUND";
|
|
16
|
+
StoreErrorCode2["STORE_ALREADY_EXISTS"] = "STORE_ALREADY_EXISTS";
|
|
17
|
+
StoreErrorCode2["INVALID_STATE"] = "INVALID_STATE";
|
|
18
|
+
StoreErrorCode2["INVALID_ACTION"] = "INVALID_ACTION";
|
|
19
|
+
StoreErrorCode2["SERIALIZATION_ERROR"] = "SERIALIZATION_ERROR";
|
|
20
|
+
StoreErrorCode2["DESERIALIZATION_ERROR"] = "DESERIALIZATION_ERROR";
|
|
21
|
+
StoreErrorCode2["STORAGE_ERROR"] = "STORAGE_ERROR";
|
|
22
|
+
StoreErrorCode2["PLUGIN_ERROR"] = "PLUGIN_ERROR";
|
|
23
|
+
StoreErrorCode2["MIDDLEWARE_ERROR"] = "MIDDLEWARE_ERROR";
|
|
24
|
+
StoreErrorCode2["SUBSCRIPTION_ERROR"] = "SUBSCRIPTION_ERROR";
|
|
25
|
+
StoreErrorCode2["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
|
|
26
|
+
StoreErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
27
|
+
return StoreErrorCode2;
|
|
28
|
+
})(StoreErrorCode || {});
|
|
29
|
+
var ErrorSeverity = /* @__PURE__ */ ((ErrorSeverity2) => {
|
|
30
|
+
ErrorSeverity2["WARNING"] = "warning";
|
|
31
|
+
ErrorSeverity2["ERROR"] = "error";
|
|
32
|
+
ErrorSeverity2["FATAL"] = "fatal";
|
|
33
|
+
return ErrorSeverity2;
|
|
34
|
+
})(ErrorSeverity || {});
|
|
35
|
+
var StoreError = class StoreError extends Error {
|
|
36
|
+
/**
|
|
37
|
+
* 创建 Store 错误
|
|
38
|
+
*
|
|
39
|
+
* @param message - 错误消息
|
|
40
|
+
* @param code - 错误代码
|
|
41
|
+
* @param context - 错误上下文
|
|
42
|
+
* @param severity - 错误严重级别
|
|
43
|
+
* @param cause - 原始错误
|
|
44
|
+
*/
|
|
45
|
+
constructor(message, code = "UNKNOWN_ERROR", context = {}, severity = "error", cause) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.name = "StoreError";
|
|
48
|
+
this.code = code;
|
|
49
|
+
this.context = {
|
|
50
|
+
...context,
|
|
51
|
+
timestamp: context.timestamp ?? Date.now()
|
|
52
|
+
};
|
|
53
|
+
this.severity = severity;
|
|
54
|
+
this.cause = cause;
|
|
55
|
+
Object.setPrototypeOf(this, StoreError.prototype);
|
|
56
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, StoreError);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 转换为 JSON
|
|
60
|
+
*/
|
|
61
|
+
toJSON() {
|
|
62
|
+
return {
|
|
63
|
+
name: this.name,
|
|
64
|
+
message: this.message,
|
|
65
|
+
code: this.code,
|
|
66
|
+
context: this.context,
|
|
67
|
+
severity: this.severity,
|
|
68
|
+
stack: this.stack
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 格式化错误信息
|
|
73
|
+
*/
|
|
74
|
+
format() {
|
|
75
|
+
const parts = [`[${this.code}] ${this.message}`];
|
|
76
|
+
if (this.context.storeId) parts.push(`Store: ${this.context.storeId}`);
|
|
77
|
+
if (this.context.action) parts.push(`Action: ${this.context.action}`);
|
|
78
|
+
return parts.join(" | ");
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var StoreDisposedError = class StoreDisposedError extends StoreError {
|
|
82
|
+
constructor(storeId, action) {
|
|
83
|
+
super(`Store "${storeId}" \u5DF2\u88AB\u9500\u6BC1\uFF0C\u65E0\u6CD5\u6267\u884C\u64CD\u4F5C${action ? `: ${action}` : ""}`, "STORE_DISPOSED", {
|
|
84
|
+
storeId,
|
|
85
|
+
action
|
|
86
|
+
}, "error");
|
|
87
|
+
this.name = "StoreDisposedError";
|
|
88
|
+
Object.setPrototypeOf(this, StoreDisposedError.prototype);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var StoreNotFoundError = class StoreNotFoundError extends StoreError {
|
|
92
|
+
constructor(storeId) {
|
|
93
|
+
super(`Store "${storeId}" \u4E0D\u5B58\u5728`, "STORE_NOT_FOUND", { storeId }, "error");
|
|
94
|
+
this.name = "StoreNotFoundError";
|
|
95
|
+
Object.setPrototypeOf(this, StoreNotFoundError.prototype);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var StoreAlreadyExistsError = class StoreAlreadyExistsError extends StoreError {
|
|
99
|
+
constructor(storeId) {
|
|
100
|
+
super(`Store "${storeId}" \u5DF2\u5B58\u5728`, "STORE_ALREADY_EXISTS", { storeId }, "warning");
|
|
101
|
+
this.name = "StoreAlreadyExistsError";
|
|
102
|
+
Object.setPrototypeOf(this, StoreAlreadyExistsError.prototype);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var InvalidStateError = class InvalidStateError extends StoreError {
|
|
106
|
+
constructor(message, storeId, data) {
|
|
107
|
+
super(message, "INVALID_STATE", {
|
|
108
|
+
storeId,
|
|
109
|
+
data
|
|
110
|
+
}, "error");
|
|
111
|
+
this.name = "InvalidStateError";
|
|
112
|
+
Object.setPrototypeOf(this, InvalidStateError.prototype);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var SerializationError = class SerializationError extends StoreError {
|
|
116
|
+
constructor(message, cause, storeId) {
|
|
117
|
+
super(message, "SERIALIZATION_ERROR", { storeId }, "error", cause);
|
|
118
|
+
this.name = "SerializationError";
|
|
119
|
+
Object.setPrototypeOf(this, SerializationError.prototype);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var DeserializationError = class DeserializationError extends StoreError {
|
|
123
|
+
constructor(message, cause, storeId) {
|
|
124
|
+
super(message, "DESERIALIZATION_ERROR", { storeId }, "error", cause);
|
|
125
|
+
this.name = "DeserializationError";
|
|
126
|
+
Object.setPrototypeOf(this, DeserializationError.prototype);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var StorageError = class StorageError extends StoreError {
|
|
130
|
+
constructor(message, cause, storeId) {
|
|
131
|
+
super(message, "STORAGE_ERROR", { storeId }, "error", cause);
|
|
132
|
+
this.name = "StorageError";
|
|
133
|
+
Object.setPrototypeOf(this, StorageError.prototype);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var PluginError = class PluginError extends StoreError {
|
|
137
|
+
constructor(message, pluginName, cause) {
|
|
138
|
+
super(message, "PLUGIN_ERROR", { plugin: pluginName }, "error", cause);
|
|
139
|
+
this.name = "PluginError";
|
|
140
|
+
Object.setPrototypeOf(this, PluginError.prototype);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
var MiddlewareError = class MiddlewareError extends StoreError {
|
|
144
|
+
constructor(message, middlewareName, cause) {
|
|
145
|
+
super(message, "MIDDLEWARE_ERROR", { middleware: middlewareName }, "error", cause);
|
|
146
|
+
this.name = "MiddlewareError";
|
|
147
|
+
Object.setPrototypeOf(this, MiddlewareError.prototype);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var SubscriptionError = class SubscriptionError extends StoreError {
|
|
151
|
+
constructor(message, cause, storeId) {
|
|
152
|
+
super(message, "SUBSCRIPTION_ERROR", { storeId }, "warning", cause);
|
|
153
|
+
this.name = "SubscriptionError";
|
|
154
|
+
Object.setPrototypeOf(this, SubscriptionError.prototype);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var TimeoutError = class TimeoutError extends StoreError {
|
|
158
|
+
constructor(message, storeId, action) {
|
|
159
|
+
super(message, "TIMEOUT_ERROR", {
|
|
160
|
+
storeId,
|
|
161
|
+
action
|
|
162
|
+
}, "error");
|
|
163
|
+
this.name = "TimeoutError";
|
|
164
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const errorUtils = {
|
|
168
|
+
/**
|
|
169
|
+
* 判断是否为 Store 错误
|
|
170
|
+
*/
|
|
171
|
+
isStoreError(error) {
|
|
172
|
+
return error instanceof StoreError;
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* 判断是否为特定类型的错误
|
|
176
|
+
*/
|
|
177
|
+
isErrorCode(error, code) {
|
|
178
|
+
return error instanceof StoreError && error.code === code;
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* 包装错误为 Store 错误
|
|
182
|
+
*/
|
|
183
|
+
wrap(error, code = "UNKNOWN_ERROR", context = {}) {
|
|
184
|
+
if (error instanceof StoreError) return error;
|
|
185
|
+
return new StoreError(error instanceof Error ? error.message : String(error), code, context, "error", error instanceof Error ? error : void 0);
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* 安全执行函数,捕获并包装错误
|
|
189
|
+
*/
|
|
190
|
+
async tryCatch(fn, code = "UNKNOWN_ERROR", context = {}) {
|
|
191
|
+
try {
|
|
192
|
+
return await fn();
|
|
193
|
+
} catch (error) {
|
|
194
|
+
throw errorUtils.wrap(error, code, context);
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
/**
|
|
198
|
+
* 创建错误日志记录器
|
|
199
|
+
*/
|
|
200
|
+
createLogger(prefix) {
|
|
201
|
+
return {
|
|
202
|
+
error(error) {
|
|
203
|
+
console.error(`[${prefix}]`, error.format());
|
|
204
|
+
if (error.cause) console.error(`[${prefix}] Caused by:`, error.cause);
|
|
205
|
+
},
|
|
206
|
+
warn(error) {
|
|
207
|
+
console.warn(`[${prefix}]`, error.format());
|
|
208
|
+
},
|
|
209
|
+
log(error) {
|
|
210
|
+
if (error.severity === "fatal" || error.severity === "error") this.error(error);
|
|
211
|
+
else this.warn(error);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
//#endregion
|
|
217
|
+
exports.DeserializationError = DeserializationError;
|
|
218
|
+
exports.ErrorSeverity = ErrorSeverity;
|
|
219
|
+
exports.InvalidStateError = InvalidStateError;
|
|
220
|
+
exports.MiddlewareError = MiddlewareError;
|
|
221
|
+
exports.PluginError = PluginError;
|
|
222
|
+
exports.SerializationError = SerializationError;
|
|
223
|
+
exports.StorageError = StorageError;
|
|
224
|
+
exports.StoreAlreadyExistsError = StoreAlreadyExistsError;
|
|
225
|
+
exports.StoreDisposedError = StoreDisposedError;
|
|
226
|
+
exports.StoreError = StoreError;
|
|
227
|
+
exports.StoreErrorCode = StoreErrorCode;
|
|
228
|
+
exports.StoreNotFoundError = StoreNotFoundError;
|
|
229
|
+
exports.SubscriptionError = SubscriptionError;
|
|
230
|
+
exports.TimeoutError = TimeoutError;
|
|
231
|
+
exports.errorUtils = errorUtils;
|
|
232
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|
|
233
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["StoreErrorCode","ErrorSeverity"],"sources":["../../src/errors/index.ts"],"sourcesContent":["/**\n * 自定义错误类\n *\n * 提供统一的错误处理模式\n * @module errors\n */\n\n/**\n * Store 错误代码\n */\nexport enum StoreErrorCode {\n /** Store 已销毁 */\n STORE_DISPOSED = 'STORE_DISPOSED',\n /** Store 不存在 */\n STORE_NOT_FOUND = 'STORE_NOT_FOUND',\n /** Store 已存在 */\n STORE_ALREADY_EXISTS = 'STORE_ALREADY_EXISTS',\n /** 无效的状态 */\n INVALID_STATE = 'INVALID_STATE',\n /** 无效的 Action */\n INVALID_ACTION = 'INVALID_ACTION',\n /** 序列化错误 */\n SERIALIZATION_ERROR = 'SERIALIZATION_ERROR',\n /** 反序列化错误 */\n DESERIALIZATION_ERROR = 'DESERIALIZATION_ERROR',\n /** 存储错误 */\n STORAGE_ERROR = 'STORAGE_ERROR',\n /** 插件错误 */\n PLUGIN_ERROR = 'PLUGIN_ERROR',\n /** 中间件错误 */\n MIDDLEWARE_ERROR = 'MIDDLEWARE_ERROR',\n /** 订阅错误 */\n SUBSCRIPTION_ERROR = 'SUBSCRIPTION_ERROR',\n /** 超时错误 */\n TIMEOUT_ERROR = 'TIMEOUT_ERROR',\n /** 未知错误 */\n UNKNOWN_ERROR = 'UNKNOWN_ERROR',\n}\n\n/**\n * 错误严重级别\n */\nexport enum ErrorSeverity {\n /** 警告 - 不影响功能,但需要注意 */\n WARNING = 'warning',\n /** 错误 - 影响部分功能 */\n ERROR = 'error',\n /** 致命 - 导致系统无法正常运行 */\n FATAL = 'fatal',\n}\n\n/**\n * Store 错误上下文\n */\nexport interface StoreErrorContext {\n /** Store ID */\n storeId?: string\n /** Action 名称 */\n action?: string\n /** 插件名称 */\n plugin?: string\n /** 中间件名称 */\n middleware?: string\n /** 额外数据 */\n data?: unknown\n /** 时间戳 */\n timestamp?: number\n}\n\n/**\n * Store 基础错误类\n *\n * 所有 Store 相关错误的基类\n *\n * @example\n * ```typescript\n * try {\n * store.someAction()\n * } catch (error) {\n * if (error instanceof StoreError) {\n * console.log('Store error:', error.code, error.message)\n * console.log('Context:', error.context)\n * }\n * }\n * ```\n */\nexport class StoreError extends Error {\n /** 错误代码 */\n readonly code: StoreErrorCode\n\n /** 错误上下文 */\n readonly context: StoreErrorContext\n\n /** 错误严重级别 */\n readonly severity: ErrorSeverity\n\n /** 原始错误 */\n readonly cause?: Error\n\n /**\n * 创建 Store 错误\n *\n * @param message - 错误消息\n * @param code - 错误代码\n * @param context - 错误上下文\n * @param severity - 错误严重级别\n * @param cause - 原始错误\n */\n constructor(\n message: string,\n code: StoreErrorCode = StoreErrorCode.UNKNOWN_ERROR,\n context: StoreErrorContext = {},\n severity: ErrorSeverity = ErrorSeverity.ERROR,\n cause?: Error,\n ) {\n super(message)\n this.name = 'StoreError'\n this.code = code\n this.context = {\n ...context,\n timestamp: context.timestamp ?? Date.now(),\n }\n this.severity = severity\n this.cause = cause\n\n // 保持正确的原型链\n Object.setPrototypeOf(this, StoreError.prototype)\n\n // 捕获堆栈跟踪\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, StoreError)\n }\n }\n\n /**\n * 转换为 JSON\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n context: this.context,\n severity: this.severity,\n stack: this.stack,\n }\n }\n\n /**\n * 格式化错误信息\n */\n format(): string {\n const parts = [`[${this.code}] ${this.message}`]\n\n if (this.context.storeId) {\n parts.push(`Store: ${this.context.storeId}`)\n }\n\n if (this.context.action) {\n parts.push(`Action: ${this.context.action}`)\n }\n\n return parts.join(' | ')\n }\n}\n\n/**\n * Store 销毁错误\n *\n * 当尝试操作已销毁的 Store 时抛出\n */\nexport class StoreDisposedError extends StoreError {\n constructor(storeId: string, action?: string) {\n super(\n `Store \"${storeId}\" 已被销毁,无法执行操作${action ? `: ${action}` : ''}`,\n StoreErrorCode.STORE_DISPOSED,\n { storeId, action },\n ErrorSeverity.ERROR,\n )\n this.name = 'StoreDisposedError'\n Object.setPrototypeOf(this, StoreDisposedError.prototype)\n }\n}\n\n/**\n * Store 不存在错误\n */\nexport class StoreNotFoundError extends StoreError {\n constructor(storeId: string) {\n super(\n `Store \"${storeId}\" 不存在`,\n StoreErrorCode.STORE_NOT_FOUND,\n { storeId },\n ErrorSeverity.ERROR,\n )\n this.name = 'StoreNotFoundError'\n Object.setPrototypeOf(this, StoreNotFoundError.prototype)\n }\n}\n\n/**\n * Store 已存在错误\n */\nexport class StoreAlreadyExistsError extends StoreError {\n constructor(storeId: string) {\n super(\n `Store \"${storeId}\" 已存在`,\n StoreErrorCode.STORE_ALREADY_EXISTS,\n { storeId },\n ErrorSeverity.WARNING,\n )\n this.name = 'StoreAlreadyExistsError'\n Object.setPrototypeOf(this, StoreAlreadyExistsError.prototype)\n }\n}\n\n/**\n * 无效状态错误\n */\nexport class InvalidStateError extends StoreError {\n constructor(message: string, storeId?: string, data?: unknown) {\n super(\n message,\n StoreErrorCode.INVALID_STATE,\n { storeId, data },\n ErrorSeverity.ERROR,\n )\n this.name = 'InvalidStateError'\n Object.setPrototypeOf(this, InvalidStateError.prototype)\n }\n}\n\n/**\n * 序列化错误\n */\nexport class SerializationError extends StoreError {\n constructor(message: string, cause?: Error, storeId?: string) {\n super(\n message,\n StoreErrorCode.SERIALIZATION_ERROR,\n { storeId },\n ErrorSeverity.ERROR,\n cause,\n )\n this.name = 'SerializationError'\n Object.setPrototypeOf(this, SerializationError.prototype)\n }\n}\n\n/**\n * 反序列化错误\n */\nexport class DeserializationError extends StoreError {\n constructor(message: string, cause?: Error, storeId?: string) {\n super(\n message,\n StoreErrorCode.DESERIALIZATION_ERROR,\n { storeId },\n ErrorSeverity.ERROR,\n cause,\n )\n this.name = 'DeserializationError'\n Object.setPrototypeOf(this, DeserializationError.prototype)\n }\n}\n\n/**\n * 存储错误\n */\nexport class StorageError extends StoreError {\n constructor(message: string, cause?: Error, storeId?: string) {\n super(\n message,\n StoreErrorCode.STORAGE_ERROR,\n { storeId },\n ErrorSeverity.ERROR,\n cause,\n )\n this.name = 'StorageError'\n Object.setPrototypeOf(this, StorageError.prototype)\n }\n}\n\n/**\n * 插件错误\n */\nexport class PluginError extends StoreError {\n constructor(message: string, pluginName: string, cause?: Error) {\n super(\n message,\n StoreErrorCode.PLUGIN_ERROR,\n { plugin: pluginName },\n ErrorSeverity.ERROR,\n cause,\n )\n this.name = 'PluginError'\n Object.setPrototypeOf(this, PluginError.prototype)\n }\n}\n\n/**\n * 中间件错误\n */\nexport class MiddlewareError extends StoreError {\n constructor(message: string, middlewareName: string, cause?: Error) {\n super(\n message,\n StoreErrorCode.MIDDLEWARE_ERROR,\n { middleware: middlewareName },\n ErrorSeverity.ERROR,\n cause,\n )\n this.name = 'MiddlewareError'\n Object.setPrototypeOf(this, MiddlewareError.prototype)\n }\n}\n\n/**\n * 订阅错误\n */\nexport class SubscriptionError extends StoreError {\n constructor(message: string, cause?: Error, storeId?: string) {\n super(\n message,\n StoreErrorCode.SUBSCRIPTION_ERROR,\n { storeId },\n ErrorSeverity.WARNING,\n cause,\n )\n this.name = 'SubscriptionError'\n Object.setPrototypeOf(this, SubscriptionError.prototype)\n }\n}\n\n/**\n * 超时错误\n */\nexport class TimeoutError extends StoreError {\n constructor(message: string, storeId?: string, action?: string) {\n super(\n message,\n StoreErrorCode.TIMEOUT_ERROR,\n { storeId, action },\n ErrorSeverity.ERROR,\n )\n this.name = 'TimeoutError'\n Object.setPrototypeOf(this, TimeoutError.prototype)\n }\n}\n\n/**\n * 错误处理工具\n */\nexport const errorUtils = {\n /**\n * 判断是否为 Store 错误\n */\n isStoreError(error: unknown): error is StoreError {\n return error instanceof StoreError\n },\n\n /**\n * 判断是否为特定类型的错误\n */\n isErrorCode(error: unknown, code: StoreErrorCode): boolean {\n return error instanceof StoreError && error.code === code\n },\n\n /**\n * 包装错误为 Store 错误\n */\n wrap(error: unknown, code: StoreErrorCode = StoreErrorCode.UNKNOWN_ERROR, context: StoreErrorContext = {}): StoreError {\n if (error instanceof StoreError) {\n return error\n }\n\n const message = error instanceof Error ? error.message : String(error)\n const cause = error instanceof Error ? error : undefined\n\n return new StoreError(message, code, context, ErrorSeverity.ERROR, cause)\n },\n\n /**\n * 安全执行函数,捕获并包装错误\n */\n async tryCatch<T>(\n fn: () => T | Promise<T>,\n code: StoreErrorCode = StoreErrorCode.UNKNOWN_ERROR,\n context: StoreErrorContext = {},\n ): Promise<T> {\n try {\n return await fn()\n }\n catch (error) {\n throw errorUtils.wrap(error, code, context)\n }\n },\n\n /**\n * 创建错误日志记录器\n */\n createLogger(prefix: string) {\n return {\n error(error: StoreError): void {\n console.error(`[${prefix}]`, error.format())\n if (error.cause) {\n console.error(`[${prefix}] Caused by:`, error.cause)\n }\n },\n\n warn(error: StoreError): void {\n console.warn(`[${prefix}]`, error.format())\n },\n\n log(error: StoreError): void {\n if (error.severity === ErrorSeverity.FATAL || error.severity === ErrorSeverity.ERROR) {\n this.error(error)\n }\n else {\n this.warn(error)\n }\n },\n }\n },\n}\n\n"],"mappings":"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"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 自定义错误类
|
|
3
|
+
*
|
|
4
|
+
* 提供统一的错误处理模式
|
|
5
|
+
* @module errors
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Store 错误代码
|
|
9
|
+
*/
|
|
10
|
+
export declare enum StoreErrorCode {
|
|
11
|
+
/** Store 已销毁 */
|
|
12
|
+
STORE_DISPOSED = "STORE_DISPOSED",
|
|
13
|
+
/** Store 不存在 */
|
|
14
|
+
STORE_NOT_FOUND = "STORE_NOT_FOUND",
|
|
15
|
+
/** Store 已存在 */
|
|
16
|
+
STORE_ALREADY_EXISTS = "STORE_ALREADY_EXISTS",
|
|
17
|
+
/** 无效的状态 */
|
|
18
|
+
INVALID_STATE = "INVALID_STATE",
|
|
19
|
+
/** 无效的 Action */
|
|
20
|
+
INVALID_ACTION = "INVALID_ACTION",
|
|
21
|
+
/** 序列化错误 */
|
|
22
|
+
SERIALIZATION_ERROR = "SERIALIZATION_ERROR",
|
|
23
|
+
/** 反序列化错误 */
|
|
24
|
+
DESERIALIZATION_ERROR = "DESERIALIZATION_ERROR",
|
|
25
|
+
/** 存储错误 */
|
|
26
|
+
STORAGE_ERROR = "STORAGE_ERROR",
|
|
27
|
+
/** 插件错误 */
|
|
28
|
+
PLUGIN_ERROR = "PLUGIN_ERROR",
|
|
29
|
+
/** 中间件错误 */
|
|
30
|
+
MIDDLEWARE_ERROR = "MIDDLEWARE_ERROR",
|
|
31
|
+
/** 订阅错误 */
|
|
32
|
+
SUBSCRIPTION_ERROR = "SUBSCRIPTION_ERROR",
|
|
33
|
+
/** 超时错误 */
|
|
34
|
+
TIMEOUT_ERROR = "TIMEOUT_ERROR",
|
|
35
|
+
/** 未知错误 */
|
|
36
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 错误严重级别
|
|
40
|
+
*/
|
|
41
|
+
export declare enum ErrorSeverity {
|
|
42
|
+
/** 警告 - 不影响功能,但需要注意 */
|
|
43
|
+
WARNING = "warning",
|
|
44
|
+
/** 错误 - 影响部分功能 */
|
|
45
|
+
ERROR = "error",
|
|
46
|
+
/** 致命 - 导致系统无法正常运行 */
|
|
47
|
+
FATAL = "fatal"
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Store 错误上下文
|
|
51
|
+
*/
|
|
52
|
+
export interface StoreErrorContext {
|
|
53
|
+
/** Store ID */
|
|
54
|
+
storeId?: string;
|
|
55
|
+
/** Action 名称 */
|
|
56
|
+
action?: string;
|
|
57
|
+
/** 插件名称 */
|
|
58
|
+
plugin?: string;
|
|
59
|
+
/** 中间件名称 */
|
|
60
|
+
middleware?: string;
|
|
61
|
+
/** 额外数据 */
|
|
62
|
+
data?: unknown;
|
|
63
|
+
/** 时间戳 */
|
|
64
|
+
timestamp?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Store 基础错误类
|
|
68
|
+
*
|
|
69
|
+
* 所有 Store 相关错误的基类
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* try {
|
|
74
|
+
* store.someAction()
|
|
75
|
+
* } catch (error) {
|
|
76
|
+
* if (error instanceof StoreError) {
|
|
77
|
+
* console.log('Store error:', error.code, error.message)
|
|
78
|
+
* console.log('Context:', error.context)
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare class StoreError extends Error {
|
|
84
|
+
/** 错误代码 */
|
|
85
|
+
readonly code: StoreErrorCode;
|
|
86
|
+
/** 错误上下文 */
|
|
87
|
+
readonly context: StoreErrorContext;
|
|
88
|
+
/** 错误严重级别 */
|
|
89
|
+
readonly severity: ErrorSeverity;
|
|
90
|
+
/** 原始错误 */
|
|
91
|
+
readonly cause?: Error;
|
|
92
|
+
/**
|
|
93
|
+
* 创建 Store 错误
|
|
94
|
+
*
|
|
95
|
+
* @param message - 错误消息
|
|
96
|
+
* @param code - 错误代码
|
|
97
|
+
* @param context - 错误上下文
|
|
98
|
+
* @param severity - 错误严重级别
|
|
99
|
+
* @param cause - 原始错误
|
|
100
|
+
*/
|
|
101
|
+
constructor(message: string, code?: StoreErrorCode, context?: StoreErrorContext, severity?: ErrorSeverity, cause?: Error);
|
|
102
|
+
/**
|
|
103
|
+
* 转换为 JSON
|
|
104
|
+
*/
|
|
105
|
+
toJSON(): Record<string, unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* 格式化错误信息
|
|
108
|
+
*/
|
|
109
|
+
format(): string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Store 销毁错误
|
|
113
|
+
*
|
|
114
|
+
* 当尝试操作已销毁的 Store 时抛出
|
|
115
|
+
*/
|
|
116
|
+
export declare class StoreDisposedError extends StoreError {
|
|
117
|
+
constructor(storeId: string, action?: string);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Store 不存在错误
|
|
121
|
+
*/
|
|
122
|
+
export declare class StoreNotFoundError extends StoreError {
|
|
123
|
+
constructor(storeId: string);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Store 已存在错误
|
|
127
|
+
*/
|
|
128
|
+
export declare class StoreAlreadyExistsError extends StoreError {
|
|
129
|
+
constructor(storeId: string);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 无效状态错误
|
|
133
|
+
*/
|
|
134
|
+
export declare class InvalidStateError extends StoreError {
|
|
135
|
+
constructor(message: string, storeId?: string, data?: unknown);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 序列化错误
|
|
139
|
+
*/
|
|
140
|
+
export declare class SerializationError extends StoreError {
|
|
141
|
+
constructor(message: string, cause?: Error, storeId?: string);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 反序列化错误
|
|
145
|
+
*/
|
|
146
|
+
export declare class DeserializationError extends StoreError {
|
|
147
|
+
constructor(message: string, cause?: Error, storeId?: string);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 存储错误
|
|
151
|
+
*/
|
|
152
|
+
export declare class StorageError extends StoreError {
|
|
153
|
+
constructor(message: string, cause?: Error, storeId?: string);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 插件错误
|
|
157
|
+
*/
|
|
158
|
+
export declare class PluginError extends StoreError {
|
|
159
|
+
constructor(message: string, pluginName: string, cause?: Error);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 中间件错误
|
|
163
|
+
*/
|
|
164
|
+
export declare class MiddlewareError extends StoreError {
|
|
165
|
+
constructor(message: string, middlewareName: string, cause?: Error);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* 订阅错误
|
|
169
|
+
*/
|
|
170
|
+
export declare class SubscriptionError extends StoreError {
|
|
171
|
+
constructor(message: string, cause?: Error, storeId?: string);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 超时错误
|
|
175
|
+
*/
|
|
176
|
+
export declare class TimeoutError extends StoreError {
|
|
177
|
+
constructor(message: string, storeId?: string, action?: string);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 错误处理工具
|
|
181
|
+
*/
|
|
182
|
+
export declare const errorUtils: {
|
|
183
|
+
/**
|
|
184
|
+
* 判断是否为 Store 错误
|
|
185
|
+
*/
|
|
186
|
+
isStoreError(error: unknown): error is StoreError;
|
|
187
|
+
/**
|
|
188
|
+
* 判断是否为特定类型的错误
|
|
189
|
+
*/
|
|
190
|
+
isErrorCode(error: unknown, code: StoreErrorCode): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* 包装错误为 Store 错误
|
|
193
|
+
*/
|
|
194
|
+
wrap(error: unknown, code?: StoreErrorCode, context?: StoreErrorContext): StoreError;
|
|
195
|
+
/**
|
|
196
|
+
* 安全执行函数,捕获并包装错误
|
|
197
|
+
*/
|
|
198
|
+
tryCatch<T>(fn: () => T | Promise<T>, code?: StoreErrorCode, context?: StoreErrorContext): Promise<T>;
|
|
199
|
+
/**
|
|
200
|
+
* 创建错误日志记录器
|
|
201
|
+
*/
|
|
202
|
+
createLogger(prefix: string): {
|
|
203
|
+
error(error: StoreError): void;
|
|
204
|
+
warn(error: StoreError): void;
|
|
205
|
+
log(error: StoreError): void;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
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("./core/pub-sub.cjs");
|
|
13
|
+
const require_async_action = require("./core/async-action.cjs");
|
|
14
|
+
const require_event_bus = require("./core/event-bus.cjs");
|
|
15
|
+
const require_base_store = require("./core/base-store.cjs");
|
|
16
|
+
const require_batch_manager = require("./core/batch-manager.cjs");
|
|
17
|
+
const require_create_store = require("./core/create-store.cjs");
|
|
18
|
+
const require_plugin = require("./engine/plugin.cjs");
|
|
19
|
+
const require_index = require("./errors/index.cjs");
|
|
20
|
+
const require_debounce_throttle = require("./utils/debounce-throttle.cjs");
|
|
21
|
+
const require_deep_clone = require("./utils/deep-clone.cjs");
|
|
22
|
+
const require_selector = require("./utils/selector.cjs");
|
|
23
|
+
const require_logger = require("./middleware/logger.cjs");
|
|
24
|
+
const require_middleware_manager = require("./middleware/middleware-manager.cjs");
|
|
25
|
+
const require_persist = require("./middleware/persist.cjs");
|
|
26
|
+
const require_time_travel = require("./middleware/time-travel.cjs");
|
|
27
|
+
const require_validation = require("./middleware/validation.cjs");
|
|
28
|
+
const require_define_plugin = require("./plugins/define-plugin.cjs");
|
|
29
|
+
const require_plugin_manager = require("./plugins/plugin-manager.cjs");
|
|
30
|
+
//#region src/index.ts
|
|
31
|
+
const version = "1.0.0";
|
|
32
|
+
const name = "@composy/store-core";
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.BaseStore = require_base_store.BaseStore;
|
|
35
|
+
exports.DeserializationError = require_index.DeserializationError;
|
|
36
|
+
exports.ErrorSeverity = require_index.ErrorSeverity;
|
|
37
|
+
exports.InvalidStateError = require_index.InvalidStateError;
|
|
38
|
+
exports.MiddlewareError = require_index.MiddlewareError;
|
|
39
|
+
exports.PluginError = require_index.PluginError;
|
|
40
|
+
exports.SerializationError = require_index.SerializationError;
|
|
41
|
+
exports.StorageError = require_index.StorageError;
|
|
42
|
+
exports.StoreAlreadyExistsError = require_index.StoreAlreadyExistsError;
|
|
43
|
+
exports.StoreDisposedError = require_index.StoreDisposedError;
|
|
44
|
+
exports.StoreError = require_index.StoreError;
|
|
45
|
+
exports.StoreErrorCode = require_index.StoreErrorCode;
|
|
46
|
+
exports.StoreNotFoundError = require_index.StoreNotFoundError;
|
|
47
|
+
exports.SubscriptionError = require_index.SubscriptionError;
|
|
48
|
+
exports.TimeoutError = require_index.TimeoutError;
|
|
49
|
+
exports.batch = require_batch_manager.batch;
|
|
50
|
+
exports.combineSelectors = require_selector.combineSelectors;
|
|
51
|
+
exports.composePlugins = require_define_plugin.composePlugins;
|
|
52
|
+
exports.createAsyncAction = require_async_action.createAsyncAction;
|
|
53
|
+
exports.createBatchManager = require_batch_manager.createBatchManager;
|
|
54
|
+
exports.createCachedSelector = require_selector.createCachedSelector;
|
|
55
|
+
exports.createEventBus = require_event_bus.createEventBus;
|
|
56
|
+
exports.createLoggerMiddleware = require_logger.createLoggerMiddleware;
|
|
57
|
+
exports.createMemoizedSelector = require_selector.createMemoizedSelector;
|
|
58
|
+
exports.createMiddlewareManager = require_middleware_manager.createMiddlewareManager;
|
|
59
|
+
exports.createPersistMiddleware = require_persist.createPersistMiddleware;
|
|
60
|
+
exports.createPluginFactory = require_define_plugin.createPluginFactory;
|
|
61
|
+
exports.createPluginManager = require_plugin_manager.createPluginManager;
|
|
62
|
+
exports.createPubSub = require_pub_sub.createPubSub;
|
|
63
|
+
exports.createPubSubWithValue = require_pub_sub.createPubSubWithValue;
|
|
64
|
+
exports.createSelector = require_selector.createSelector;
|
|
65
|
+
exports.createSelectorWithDeps = require_selector.createSelectorWithDeps;
|
|
66
|
+
exports.createSimpleLoggerMiddleware = require_logger.createSimpleLoggerMiddleware;
|
|
67
|
+
exports.createStore = require_create_store.createStore;
|
|
68
|
+
exports.createStoreEngineBridge = require_plugin.createStoreEngineBridge;
|
|
69
|
+
exports.createTimeTravelMiddleware = require_time_travel.createTimeTravelMiddleware;
|
|
70
|
+
exports.createValidationMiddleware = require_validation.createValidationMiddleware;
|
|
71
|
+
exports.debounce = require_debounce_throttle.debounce;
|
|
72
|
+
exports.deepClone = require_deep_clone.deepClone;
|
|
73
|
+
exports.deepEqual = require_deep_clone.deepEqual;
|
|
74
|
+
exports.deepFreeze = require_deep_clone.deepFreeze;
|
|
75
|
+
exports.deepMerge = require_deep_clone.deepMerge;
|
|
76
|
+
exports.deepMergeWithOptions = require_deep_clone.deepMergeWithOptions;
|
|
77
|
+
exports.defineStorePlugin = require_define_plugin.defineStorePlugin;
|
|
78
|
+
exports.deleteByPath = require_selector.deleteByPath;
|
|
79
|
+
exports.errorUtils = require_index.errorUtils;
|
|
80
|
+
exports.getByPath = require_selector.getByPath;
|
|
81
|
+
exports.getGlobalBatchManager = require_batch_manager.getGlobalBatchManager;
|
|
82
|
+
exports.getGlobalMiddlewareManager = require_middleware_manager.getGlobalMiddlewareManager;
|
|
83
|
+
exports.getGlobalPluginManager = require_plugin_manager.getGlobalPluginManager;
|
|
84
|
+
exports.globalEventBus = require_event_bus.globalEventBus;
|
|
85
|
+
exports.hasPath = require_selector.hasPath;
|
|
86
|
+
exports.isObject = require_deep_clone.isObject;
|
|
87
|
+
exports.isPlainObject = require_deep_clone.isPlainObject;
|
|
88
|
+
exports.name = name;
|
|
89
|
+
exports.restoreState = require_persist.restoreState;
|
|
90
|
+
exports.setByPath = require_selector.setByPath;
|
|
91
|
+
exports.setGlobalBatchManager = require_batch_manager.setGlobalBatchManager;
|
|
92
|
+
exports.setGlobalMiddlewareManager = require_middleware_manager.setGlobalMiddlewareManager;
|
|
93
|
+
exports.setGlobalPluginManager = require_plugin_manager.setGlobalPluginManager;
|
|
94
|
+
exports.setRestoreCallback = require_time_travel.setRestoreCallback;
|
|
95
|
+
exports.shallowClone = require_deep_clone.shallowClone;
|
|
96
|
+
exports.storeEventKeys = require_plugin.storeEventKeys;
|
|
97
|
+
exports.storeStateKeys = require_plugin.storeStateKeys;
|
|
98
|
+
exports.throttle = require_debounce_throttle.throttle;
|
|
99
|
+
exports.version = version;
|
|
100
|
+
/*! End of @composy/store-core | Powered by @composy/builder */
|
|
101
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @composy/store-core - 框架无关的状态管理核心库\n *\n * 主要功能模块:\n * - 核心抽象:Store、State、Action、Getter 等核心概念\n * - 插件系统:可扩展的插件机制\n * - 中间件:日志、持久化、时间旅行等\n * - 订阅发布:状态变化订阅、事件总线\n * - 批量更新:性能优化的批量状态更新\n * - 工具函数:深拷贝、选择器等\n *\n * @module @composy/store-core\n */\n\n// === 核心模块 ===\nexport {\n BaseStore,\n batch,\n createAsyncAction,\n createBatchManager,\n createEventBus,\n createPubSub,\n createPubSubWithValue,\n createStore,\n getGlobalBatchManager,\n globalEventBus,\n setGlobalBatchManager,\n} from './core'\n\nexport type {\n AsyncAction,\n AsyncActionOptions,\n AsyncActionState,\n CreateStoreDefinition,\n StoreAPI,\n} from './core'\n\n// Engine 插件\nexport * from './engine'\n\n// === 错误处理 ===\nexport {\n DeserializationError,\n ErrorSeverity,\n errorUtils,\n InvalidStateError,\n MiddlewareError,\n PluginError,\n SerializationError,\n StorageError,\n StoreAlreadyExistsError,\n StoreDisposedError,\n StoreError,\n StoreErrorCode,\n StoreNotFoundError,\n SubscriptionError,\n TimeoutError,\n} from './errors'\n\nexport type {\n StoreErrorContext,\n} from './errors'\n\n// === 中间件模块 ===\nexport {\n createLoggerMiddleware,\n createMiddlewareManager,\n createPersistMiddleware,\n createSimpleLoggerMiddleware,\n createTimeTravelMiddleware,\n createValidationMiddleware,\n getGlobalMiddlewareManager,\n restoreState,\n setGlobalMiddlewareManager,\n setRestoreCallback,\n} from './middleware'\n\nexport type {\n StoreValidationRules,\n ValidationError,\n ValidationMiddlewareOptions,\n ValidationResult,\n ValidationRule,\n} from './middleware'\n\n// === 插件模块 ===\nexport {\n composePlugins,\n createPluginFactory,\n createPluginManager,\n defineStorePlugin,\n getGlobalPluginManager,\n setGlobalPluginManager,\n} from './plugins'\n\n// === 类型定义 ===\nexport type {\n // Store 类型\n ActionContext,\n ActionSubscriber,\n // 订阅类型\n BatchContext,\n BatchManager,\n // 插件类型\n DefinePluginOptions,\n EventBus,\n EventData,\n EventListener,\n EventType,\n // 中间件类型\n LoggerMiddlewareOptions,\n Middleware,\n MiddlewareActionType,\n MiddlewareContext,\n MiddlewareFunction,\n MiddlewareManager,\n PersistMiddlewareOptions,\n PersistOptions,\n PluginContext,\n PluginFactory,\n PluginManager,\n PubSub,\n Selector,\n SelectorOptions,\n StateMutation,\n StateSnapshot,\n StateSubscriber,\n StateTree,\n StorageAdapter,\n StoreAction,\n StoreActions,\n StoreDefinition,\n StoreGetter,\n StoreGetters,\n StoreId,\n StoreInstance,\n StoreManagerLike,\n StoreOptions,\n StorePlugin,\n SubscribeOptions,\n Subscriber,\n SubscriptionOptions,\n TimeTravelController,\n TimeTravelMiddlewareOptions,\n Unsubscribe,\n} from './types'\n\n// === 工具函数 ===\nexport {\n combineSelectors,\n createCachedSelector,\n createMemoizedSelector,\n createSelector,\n createSelectorWithDeps,\n debounce,\n deepClone,\n deepEqual,\n deepFreeze,\n deepMerge,\n deepMergeWithOptions,\n deleteByPath,\n getByPath,\n hasPath,\n isObject,\n isPlainObject,\n setByPath,\n shallowClone,\n throttle,\n} from './utils'\n\n// === 版本信息 ===\nexport const version = '1.0.0'\nexport const name = '@composy/store-core'\n\nexport type {\n DebouncedFunction,\n DeepCloneOptions,\n DeepMergeOptions,\n MemoizedSelectorOptions,\n SelectorEqualityFn,\n ThrottledFunction,\n} from './utils'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2KO,MAAM,UAAU;AAChB,MAAM,OAAO"}
|