@wocker/core 1.0.29-beta.1 → 1.0.30-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/env.d.ts +1 -1
- package/lib/env.js +1 -1
- package/lib/services/EventService.d.ts +4 -4
- package/lib/services/EventService.js +13 -1
- package/package.json +1 -1
package/lib/env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const WOCKER_VERSION = "1.0.
|
|
1
|
+
export declare const WOCKER_VERSION = "1.0.30";
|
|
2
2
|
export declare const WOCKER_VERSION_KEY = "__WOCKER_VERSION__";
|
|
3
3
|
export declare const WOCKER_DATA_DIR: string;
|
|
4
4
|
export declare const WOCKER_DATA_DIR_KEY = "__WOCKER_DATA_DIR__";
|
package/lib/env.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.MODULE_METADATA = exports.PLUGIN_NAME_METADATA = exports.INJECT_TOKEN_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.ALIAS_METADATA = exports.ARGS_OLD_METADATA = exports.ARGS_METADATA = exports.LISTENER_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_METADATA = exports.DESCRIPTION_METADATA = exports.INJECTABLE_WATERMARK = exports.IS_MODULE_METADATA = exports.IS_GLOBAL_METADATA = exports.IS_CONTROLLER_METADATA = exports.PLUGIN_DIR_KEY = exports.FILE_SYSTEM_DRIVER_KEY = exports.WOCKER_DATA_DIR_KEY = exports.WOCKER_DATA_DIR = exports.WOCKER_VERSION_KEY = exports.WOCKER_VERSION = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
exports.WOCKER_VERSION = "1.0.
|
|
9
|
+
exports.WOCKER_VERSION = "1.0.30";
|
|
10
10
|
exports.WOCKER_VERSION_KEY = "__WOCKER_VERSION__";
|
|
11
11
|
exports.WOCKER_DATA_DIR = process.env.WS_DIR || path_1.default.join(os_1.default.homedir(), ".workspace");
|
|
12
12
|
exports.WOCKER_DATA_DIR_KEY = "__WOCKER_DATA_DIR__";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Container } from "../core/Container";
|
|
2
2
|
export type EventHandle = (...args: any[]) => Promise<void> | void;
|
|
3
|
+
export type EventOff = () => void;
|
|
3
4
|
export declare class EventService {
|
|
4
5
|
protected readonly container: Container;
|
|
5
6
|
protected scanned: boolean;
|
|
6
|
-
protected handles:
|
|
7
|
-
[event: string]: Set<EventHandle>;
|
|
8
|
-
};
|
|
7
|
+
protected handles: Record<string, Set<EventHandle>>;
|
|
9
8
|
constructor(container: Container);
|
|
10
9
|
protected scanListeners(): void;
|
|
11
|
-
on(event: string, handle: EventHandle):
|
|
10
|
+
on(event: string, handle: EventHandle): EventOff;
|
|
11
|
+
protected preOn(event: string, handle: EventHandle): EventOff;
|
|
12
12
|
off(event: string, handle: EventHandle): void;
|
|
13
13
|
emit(event: string, ...args: any[]): Promise<void>;
|
|
14
14
|
}
|
|
@@ -44,7 +44,7 @@ let EventService = class EventService {
|
|
|
44
44
|
const eventNames = Reflect.getMetadata(env_1.LISTENER_METADATA, prototype[methodName]);
|
|
45
45
|
if (eventNames) {
|
|
46
46
|
for (const eventName of eventNames) {
|
|
47
|
-
this.
|
|
47
|
+
this.preOn(eventName, instance[methodName].bind(instance));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -61,6 +61,18 @@ let EventService = class EventService {
|
|
|
61
61
|
this.off(event, handle);
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
preOn(event, handle) {
|
|
65
|
+
if (!this.handles[event]) {
|
|
66
|
+
this.handles[event] = new Set();
|
|
67
|
+
}
|
|
68
|
+
this.handles[event] = new Set([
|
|
69
|
+
handle,
|
|
70
|
+
...Array.from(this.handles[event])
|
|
71
|
+
]);
|
|
72
|
+
return () => {
|
|
73
|
+
this.off(event, handle);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
64
76
|
off(event, handle) {
|
|
65
77
|
if (!this.handles[event]) {
|
|
66
78
|
return;
|