floating-live 0.16.0-alpha.15 → 0.16.0-alpha.17
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/dist/command/manager.js +5 -4
- package/dist/error/index.d.ts +4 -2
- package/dist/error/types.d.ts +1 -0
- package/dist/hook/manager.d.ts +0 -8
- package/dist/hook/manager.js +6 -14
- package/dist/live/room.d.ts +24 -10
- package/dist/live/room.js +23 -7
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +3 -0
- package/dist/plugin/manager.d.ts +0 -8
- package/dist/plugin/manager.js +20 -26
- package/dist/plugin/types.d.ts +1 -1
- package/dist/plugins/room/index.js +35 -12
- package/dist/value/manager.js +4 -1
- package/package.json +1 -1
package/dist/command/manager.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AppError } from "../error";
|
|
1
2
|
export class CommandManager {
|
|
2
3
|
constructor(app) {
|
|
3
4
|
/** 功能列表 */
|
|
@@ -23,10 +24,10 @@ export class CommandManager {
|
|
|
23
24
|
callWithOptions(name, options, ...args) {
|
|
24
25
|
const command = this.list.get(name);
|
|
25
26
|
if (!command) {
|
|
26
|
-
throw {
|
|
27
|
-
message:
|
|
28
|
-
|
|
29
|
-
};
|
|
27
|
+
throw new AppError("command:call_unexist", {
|
|
28
|
+
message: `命令不存在: ${name}`,
|
|
29
|
+
target: `command/${name}`,
|
|
30
|
+
});
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
33
|
return command.call({ source: options.source, client: options.client }, ...args);
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ErrorOptions } from "./types";
|
|
2
2
|
export * from "./types";
|
|
3
3
|
export declare class AppError extends Error {
|
|
4
|
-
/** 错误来源 */
|
|
5
|
-
source?: string;
|
|
6
4
|
/** 错误id */
|
|
7
5
|
id: string;
|
|
6
|
+
/** 错误来源 */
|
|
7
|
+
source?: string;
|
|
8
|
+
/** 错误目标 */
|
|
9
|
+
target?: string;
|
|
8
10
|
/** 错误原因 */
|
|
9
11
|
cause?: Error | string;
|
|
10
12
|
constructor(id: string, options: ErrorOptions);
|
package/dist/error/types.d.ts
CHANGED
package/dist/hook/manager.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { App } from "../app";
|
|
2
|
-
import { AppError, ErrorOptions } from "../error";
|
|
3
2
|
import { HookFunction, HookUseOptions } from "./types";
|
|
4
|
-
export interface HookErrorOptions extends ErrorOptions {
|
|
5
|
-
hookName: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class HookError extends AppError {
|
|
8
|
-
hookName: string;
|
|
9
|
-
constructor(id: string, options: HookErrorOptions);
|
|
10
|
-
}
|
|
11
3
|
export declare class HookManager {
|
|
12
4
|
private list;
|
|
13
5
|
private pluginMap;
|
package/dist/hook/manager.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { AppError } from "../error";
|
|
2
|
-
export class HookError extends AppError {
|
|
3
|
-
constructor(id, options) {
|
|
4
|
-
super(id, options);
|
|
5
|
-
this.hookName = options.hookName;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
2
|
export class HookManager {
|
|
9
3
|
constructor(app) {
|
|
10
4
|
this.list = new Map();
|
|
@@ -20,10 +14,10 @@ export class HookManager {
|
|
|
20
14
|
this.list.set(name, hooks);
|
|
21
15
|
}
|
|
22
16
|
else if (hooks.includes(call)) {
|
|
23
|
-
throw new
|
|
17
|
+
throw new AppError("hook:use_duplicate", {
|
|
24
18
|
message: `钩子函数挂载失败: ${name}`,
|
|
25
19
|
cause: "重复挂载同一函数",
|
|
26
|
-
|
|
20
|
+
target: `hook/${name}`,
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
23
|
hooks.push({ call, pluginName });
|
|
@@ -31,15 +25,13 @@ export class HookManager {
|
|
|
31
25
|
/** 取消挂载钩子函数 */
|
|
32
26
|
unuse(name, call) {
|
|
33
27
|
let hooks = this.list.get(name);
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const index = hooks?.findIndex((item) => item.call == call) ?? -1;
|
|
29
|
+
if (!hooks || index < 0)
|
|
30
|
+
throw new AppError("hook:unuse_unexist", {
|
|
36
31
|
message: `钩子函数卸载失败: ${name}`,
|
|
37
32
|
cause: "卸载不存在的钩子函数",
|
|
38
|
-
|
|
33
|
+
target: `hook/${name}`,
|
|
39
34
|
});
|
|
40
|
-
const index = hooks.findIndex((item) => item.call == call);
|
|
41
|
-
if (index < 0)
|
|
42
|
-
throw {};
|
|
43
35
|
hooks.splice(index, 1);
|
|
44
36
|
}
|
|
45
37
|
/** 调用钩子函数 */
|
package/dist/live/room.d.ts
CHANGED
|
@@ -21,12 +21,12 @@ export declare abstract class LiveRoom extends CustomEventEmitter implements Liv
|
|
|
21
21
|
timestamp: number;
|
|
22
22
|
/** 当前直播id */
|
|
23
23
|
liveId?: string;
|
|
24
|
-
/** 房间是否打开 */
|
|
25
|
-
opened: boolean;
|
|
26
24
|
/** 房间连接状态 */
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
25
|
+
connectionStatus: LiveConnectionStatus;
|
|
26
|
+
/** 房间开启状态 */
|
|
27
|
+
openStatus: LiveRoomOpenStatus;
|
|
28
|
+
get opened(): boolean;
|
|
29
|
+
get available(): boolean;
|
|
30
30
|
/** 打开连接 */
|
|
31
31
|
abstract open(): void;
|
|
32
32
|
/** 关闭连接 */
|
|
@@ -78,12 +78,14 @@ export interface LiveRoomData {
|
|
|
78
78
|
liveId?: string;
|
|
79
79
|
/** 直播状态 */
|
|
80
80
|
status: LiveRoomStatus;
|
|
81
|
-
/** 直播间是否可用 */
|
|
82
|
-
available: boolean;
|
|
83
|
-
/** 房间监听是否打开 */
|
|
84
|
-
opened: boolean;
|
|
85
81
|
/** 房间连接状态 */
|
|
86
|
-
|
|
82
|
+
connectionStatus: LiveConnectionStatus;
|
|
83
|
+
/** 房间监听状态 */
|
|
84
|
+
openStatus: LiveRoomOpenStatus;
|
|
85
|
+
/** 房间是否开启 */
|
|
86
|
+
opened: boolean;
|
|
87
|
+
/** 房间是否可用 */
|
|
88
|
+
available: boolean;
|
|
87
89
|
}
|
|
88
90
|
/** 房间展示信息 */
|
|
89
91
|
export interface LiveRoomDetailInfo {
|
|
@@ -133,6 +135,18 @@ export declare const LiveConnectionStatus: {
|
|
|
133
135
|
readonly disconnected: -1;
|
|
134
136
|
};
|
|
135
137
|
export type LiveConnectionStatus = EnumValue<typeof LiveConnectionStatus>;
|
|
138
|
+
/** 直播间开启状态 */
|
|
139
|
+
export declare const LiveRoomOpenStatus: {
|
|
140
|
+
/** 已关闭 */
|
|
141
|
+
readonly closed: 0;
|
|
142
|
+
/** 正在开启 */
|
|
143
|
+
readonly opening: 1;
|
|
144
|
+
/** 已开启 */
|
|
145
|
+
readonly opened: 2;
|
|
146
|
+
/** 不可用 */
|
|
147
|
+
readonly unavailable: -1;
|
|
148
|
+
};
|
|
149
|
+
export type LiveRoomOpenStatus = EnumValue<typeof LiveRoomOpenStatus>;
|
|
136
150
|
export interface LiveRoomEventMap {
|
|
137
151
|
/** */
|
|
138
152
|
status: {
|
package/dist/live/room.js
CHANGED
|
@@ -7,12 +7,16 @@ export class LiveRoom extends CustomEventEmitter {
|
|
|
7
7
|
this.status = LiveRoomStatus.off;
|
|
8
8
|
/** 时间戳 */
|
|
9
9
|
this.timestamp = 0;
|
|
10
|
-
/** 房间是否打开 */
|
|
11
|
-
this.opened = false;
|
|
12
10
|
/** 房间连接状态 */
|
|
13
|
-
this.
|
|
14
|
-
/**
|
|
15
|
-
this.
|
|
11
|
+
this.connectionStatus = LiveConnectionStatus.off;
|
|
12
|
+
/** 房间开启状态 */
|
|
13
|
+
this.openStatus = -1;
|
|
14
|
+
}
|
|
15
|
+
get opened() {
|
|
16
|
+
return this.openStatus == 2;
|
|
17
|
+
}
|
|
18
|
+
get available() {
|
|
19
|
+
return this.openStatus > -1;
|
|
16
20
|
}
|
|
17
21
|
/** 销毁 */
|
|
18
22
|
destroy() {
|
|
@@ -70,9 +74,10 @@ export class LiveRoom extends CustomEventEmitter {
|
|
|
70
74
|
timestamp: this.timestamp,
|
|
71
75
|
status: this.status,
|
|
72
76
|
liveId: this.liveId,
|
|
73
|
-
|
|
77
|
+
openStatus: this.openStatus,
|
|
74
78
|
opened: this.opened,
|
|
75
|
-
|
|
79
|
+
available: this.available,
|
|
80
|
+
connectionStatus: this.connectionStatus,
|
|
76
81
|
key: this.key,
|
|
77
82
|
};
|
|
78
83
|
}
|
|
@@ -106,3 +111,14 @@ export const LiveConnectionStatus = {
|
|
|
106
111
|
/** 连接失败或断开 */
|
|
107
112
|
disconnected: -1,
|
|
108
113
|
};
|
|
114
|
+
/** 直播间开启状态 */
|
|
115
|
+
export const LiveRoomOpenStatus = {
|
|
116
|
+
/** 已关闭 */
|
|
117
|
+
closed: 0,
|
|
118
|
+
/** 正在开启 */
|
|
119
|
+
opening: 1,
|
|
120
|
+
/** 已开启 */
|
|
121
|
+
opened: 2,
|
|
122
|
+
/** 不可用 */
|
|
123
|
+
unavailable: -1,
|
|
124
|
+
};
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { AppError } from "../error";
|
|
1
2
|
import type { PluginItem, PluginContext } from "./types";
|
|
2
3
|
export type * from "./types";
|
|
3
4
|
export declare class BasePlugin implements PluginItem {
|
|
4
5
|
static pluginName: string;
|
|
5
6
|
pluginName: string;
|
|
6
7
|
ctx: PluginContext;
|
|
8
|
+
readonly Error: typeof AppError;
|
|
9
|
+
readonly throw: (err?: Error) => void;
|
|
7
10
|
constructor(ctx: PluginContext, options?: any);
|
|
8
11
|
}
|
package/dist/plugin/index.js
CHANGED
package/dist/plugin/manager.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import type { App } from "../app";
|
|
2
|
-
import { AppError, ErrorOptions } from "../error";
|
|
3
2
|
import { PluginItem, PluginConstructor, PluginContext, PluginRegisterOptions } from "./types";
|
|
4
|
-
export interface PluginErrorOptions extends ErrorOptions {
|
|
5
|
-
pluginName: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class PluginError extends AppError {
|
|
8
|
-
pluginName: string;
|
|
9
|
-
constructor(id: string, options: PluginErrorOptions);
|
|
10
|
-
}
|
|
11
3
|
export interface PluginData<T> {
|
|
12
4
|
plugin: PluginItem;
|
|
13
5
|
context: PluginContext;
|
package/dist/plugin/manager.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { CommonPluginContext } from "./context/CommonPluginContext";
|
|
2
2
|
import { AppError } from "../error";
|
|
3
3
|
import { CorePluginContext } from "./context/CorePluginContext";
|
|
4
|
-
export class PluginError extends AppError {
|
|
5
|
-
constructor(id, options) {
|
|
6
|
-
super(id, options);
|
|
7
|
-
this.pluginName = options.pluginName;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
4
|
export class PluginManager {
|
|
11
5
|
constructor(app) {
|
|
12
6
|
/** 插件列表 */
|
|
@@ -16,17 +10,17 @@ export class PluginManager {
|
|
|
16
10
|
registerSync(pluginConstructor, options = {}, { context, core } = {}) {
|
|
17
11
|
const pluginName = pluginConstructor.pluginName;
|
|
18
12
|
if (!pluginName) {
|
|
19
|
-
throw new
|
|
13
|
+
throw new AppError("plugin:register_id_missing", {
|
|
20
14
|
message: "插件注册失败",
|
|
21
15
|
cause: "插件缺少pluginName字段",
|
|
22
|
-
|
|
16
|
+
target: "plugin/#unnamed",
|
|
23
17
|
});
|
|
24
18
|
}
|
|
25
19
|
if (this.list.has(pluginName)) {
|
|
26
|
-
throw new
|
|
20
|
+
throw new AppError("plugin:register_id_duplicate", {
|
|
27
21
|
message: `插件注册失败: ${pluginName}`,
|
|
28
22
|
cause: "已存在相同id的插件",
|
|
29
|
-
pluginName
|
|
23
|
+
target: `plugin/${pluginName}`,
|
|
30
24
|
});
|
|
31
25
|
}
|
|
32
26
|
const registerCtx = { pluginName, options };
|
|
@@ -34,10 +28,10 @@ export class PluginManager {
|
|
|
34
28
|
try {
|
|
35
29
|
const ctx = this.app.callHookSync("plugin.register", registerCtx);
|
|
36
30
|
if (ctx.defaultPrevented)
|
|
37
|
-
throw new
|
|
31
|
+
throw new AppError("plugin:register_hook_prevented", {
|
|
38
32
|
message: `插件注册失败: ${pluginName}`,
|
|
39
33
|
cause: "插件注册被钩子函数阻止",
|
|
40
|
-
pluginName
|
|
34
|
+
target: `plugin/${pluginName}`,
|
|
41
35
|
});
|
|
42
36
|
// 执行插件函数
|
|
43
37
|
const plugin = new pluginConstructor(pluginCtx, registerCtx.options || {});
|
|
@@ -55,10 +49,10 @@ export class PluginManager {
|
|
|
55
49
|
return plugin;
|
|
56
50
|
}
|
|
57
51
|
catch (err) {
|
|
58
|
-
throw new
|
|
52
|
+
throw new AppError("plugin:register_fail", {
|
|
59
53
|
message: `插件注册失败: ${pluginName}`,
|
|
60
54
|
cause: err,
|
|
61
|
-
pluginName
|
|
55
|
+
target: `plugin/${pluginName}`,
|
|
62
56
|
});
|
|
63
57
|
}
|
|
64
58
|
}
|
|
@@ -66,17 +60,17 @@ export class PluginManager {
|
|
|
66
60
|
async register(pluginConstructor, options = {}, { context, core } = {}) {
|
|
67
61
|
const pluginName = pluginConstructor.pluginName;
|
|
68
62
|
if (!pluginName) {
|
|
69
|
-
throw new
|
|
63
|
+
throw new AppError("plugin:register_id_missing", {
|
|
70
64
|
message: "插件注册失败",
|
|
71
65
|
cause: "插件缺少pluginName字段",
|
|
72
|
-
|
|
66
|
+
target: "plugin/#unnamed",
|
|
73
67
|
});
|
|
74
68
|
}
|
|
75
69
|
if (this.list.has(pluginName)) {
|
|
76
|
-
throw new
|
|
70
|
+
throw new AppError("plugin:register_id_duplicate", {
|
|
77
71
|
message: `插件注册失败: ${pluginName}`,
|
|
78
72
|
cause: "已存在相同id的插件",
|
|
79
|
-
pluginName
|
|
73
|
+
target: `plugin/${pluginName}`,
|
|
80
74
|
});
|
|
81
75
|
}
|
|
82
76
|
const registerCtx = { pluginName, options };
|
|
@@ -85,10 +79,10 @@ export class PluginManager {
|
|
|
85
79
|
.callHook("plugin.register", registerCtx)
|
|
86
80
|
.then(async (ctx) => {
|
|
87
81
|
if (ctx.defaultPrevented)
|
|
88
|
-
throw new
|
|
82
|
+
throw new AppError("plugin:register_hook_prevented", {
|
|
89
83
|
message: `插件注册失败: ${pluginName}`,
|
|
90
84
|
cause: "插件注册被钩子函数阻止",
|
|
91
|
-
pluginName
|
|
85
|
+
target: `plugin/${pluginName}`,
|
|
92
86
|
});
|
|
93
87
|
// 执行插件函数
|
|
94
88
|
const plugin = new pluginConstructor(pluginCtx, registerCtx.options || {});
|
|
@@ -106,10 +100,10 @@ export class PluginManager {
|
|
|
106
100
|
return plugin;
|
|
107
101
|
})
|
|
108
102
|
.catch((err) => {
|
|
109
|
-
throw new
|
|
103
|
+
throw new AppError("plugin:register_fail", {
|
|
110
104
|
message: `插件注册失败: ${pluginName}`,
|
|
111
105
|
cause: err,
|
|
112
|
-
pluginName
|
|
106
|
+
target: `plugin/${pluginName}`,
|
|
113
107
|
});
|
|
114
108
|
});
|
|
115
109
|
}
|
|
@@ -118,19 +112,19 @@ export class PluginManager {
|
|
|
118
112
|
const pluginData = this.list.get(pluginName);
|
|
119
113
|
// 检测插件是否存在
|
|
120
114
|
if (!pluginData) {
|
|
121
|
-
throw new
|
|
115
|
+
throw new AppError("plugin:unregister_unexist", {
|
|
122
116
|
message: `插件移除失败: ${pluginName}`,
|
|
123
117
|
cause: "插件不存在",
|
|
124
|
-
pluginName
|
|
118
|
+
target: `plugin/${pluginName}`,
|
|
125
119
|
});
|
|
126
120
|
}
|
|
127
121
|
else {
|
|
128
122
|
const { plugin, context, core } = pluginData;
|
|
129
123
|
if (core) {
|
|
130
|
-
throw new
|
|
124
|
+
throw new AppError("plugin:unregister_core", {
|
|
131
125
|
message: `插件移除失败: ${pluginName}`,
|
|
132
126
|
cause: "无法移除核心插件",
|
|
133
|
-
pluginName
|
|
127
|
+
target: `plugin/${pluginName}`,
|
|
134
128
|
});
|
|
135
129
|
}
|
|
136
130
|
// 调用插件和上下文的destroy钩子
|
package/dist/plugin/types.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface PluginContext {
|
|
|
45
45
|
emit<K extends keyof AppEventDetailMap>(type: K, detail: AppEventDetailMap[K], options?: AppEventEmitOptions & EventInit): void;
|
|
46
46
|
/** 抛出错误 */
|
|
47
47
|
throw(err?: Error): void;
|
|
48
|
-
/** 生成错误 */
|
|
48
|
+
/** 生成错误 @deprecated */
|
|
49
49
|
error(id: string, options: ErrorOptions): AppError;
|
|
50
50
|
/** 注册插件 */
|
|
51
51
|
register<P extends PluginItem>(plugin: PluginConstructor<P>, options?: PluginInitOptions): Promise<P>;
|
|
@@ -32,7 +32,7 @@ export class Room extends BasePlugin {
|
|
|
32
32
|
attach(room, open) {
|
|
33
33
|
let key = room.key;
|
|
34
34
|
if (this.map.has(key)) {
|
|
35
|
-
this.
|
|
35
|
+
this.throw(new AppError("room:add_exist", {
|
|
36
36
|
message: "房间已存在",
|
|
37
37
|
}));
|
|
38
38
|
return;
|
|
@@ -108,25 +108,32 @@ export class Room extends BasePlugin {
|
|
|
108
108
|
const ctx = { platform, id, options: opt };
|
|
109
109
|
const res = await this.ctx.callHook("room.add", ctx);
|
|
110
110
|
if (res.defaultPrevented) {
|
|
111
|
-
this.
|
|
111
|
+
this.throw(new this.Error("room:add_hook_prevented", {
|
|
112
112
|
message: "无法添加房间",
|
|
113
113
|
cause: "房间添加被钩子函数阻止",
|
|
114
|
+
target: `room/${platform}:${id}`,
|
|
114
115
|
}));
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.ctx.
|
|
117
|
+
let room;
|
|
118
|
+
try {
|
|
119
|
+
room = await this.ctx.call(`${platform}.room.create`, id, opt);
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
-
this.
|
|
121
|
+
catch (e) {
|
|
122
|
+
this.throw(new this.Error("room:create_fail", {
|
|
123
|
+
message: "无法创建房间",
|
|
124
|
+
cause: e,
|
|
125
|
+
target: `room/${platform}:${id}`,
|
|
126
|
+
}));
|
|
122
127
|
}
|
|
128
|
+
this.attach(room);
|
|
123
129
|
}
|
|
124
130
|
/** 移除房间 */
|
|
125
131
|
remove(key) {
|
|
126
132
|
let room = this.map.get(key);
|
|
127
133
|
if (!room) {
|
|
128
|
-
this.
|
|
134
|
+
this.throw(new this.Error("room:remove_unexist", {
|
|
129
135
|
message: "房间不存在",
|
|
136
|
+
target: `room/${key}`,
|
|
130
137
|
}));
|
|
131
138
|
}
|
|
132
139
|
this.map.delete(key); // 从表中删除房间
|
|
@@ -161,19 +168,35 @@ export class Room extends BasePlugin {
|
|
|
161
168
|
/** 打开房间连接 */
|
|
162
169
|
open(key) {
|
|
163
170
|
let room = this.map.get(key);
|
|
164
|
-
|
|
171
|
+
if (!room) {
|
|
172
|
+
this.throw(new this.Error("room:open_unexist", {
|
|
173
|
+
message: "打开的房间不存在",
|
|
174
|
+
target: `room/${key}`,
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
room.open();
|
|
165
178
|
}
|
|
166
179
|
/** 关闭房间连接 */
|
|
167
180
|
close(key) {
|
|
168
181
|
let room = this.map.get(key);
|
|
169
|
-
|
|
182
|
+
if (!room) {
|
|
183
|
+
this.throw(new this.Error("room:close_unexist", {
|
|
184
|
+
message: "关闭的房间不存在",
|
|
185
|
+
target: `room/${key}`,
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
room.close();
|
|
170
189
|
}
|
|
171
190
|
/** 更改某个房间的顺序 */
|
|
172
191
|
move(key, position) {
|
|
173
192
|
const arr = [...this.map];
|
|
174
193
|
const index = arr.findIndex(([k]) => k == key);
|
|
175
|
-
if (index == -1)
|
|
176
|
-
|
|
194
|
+
if (index == -1) {
|
|
195
|
+
this.throw(new this.Error("room:move_unexist", {
|
|
196
|
+
message: "要移动的房间不存在",
|
|
197
|
+
target: `room/${key}`,
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
177
200
|
const [item] = arr.splice(index, 1);
|
|
178
201
|
arr.splice(position, 0, item);
|
|
179
202
|
this.map = new Map(arr);
|
package/dist/value/manager.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AppError } from "../error";
|
|
1
2
|
import { bindCommand } from "../utils";
|
|
2
3
|
export class ValueManager {
|
|
3
4
|
constructor(app) {
|
|
@@ -25,7 +26,9 @@ export class ValueManager {
|
|
|
25
26
|
get(name, options) {
|
|
26
27
|
const item = this.list.get(name);
|
|
27
28
|
if (!item)
|
|
28
|
-
throw {
|
|
29
|
+
throw new AppError("value:get_unexist", {
|
|
30
|
+
message: "无法获取未注册的值",
|
|
31
|
+
});
|
|
29
32
|
return item.get(options);
|
|
30
33
|
}
|
|
31
34
|
/** 获取值(不存在则返回undefined) */
|