@micro-cms/core 1.0.16 → 1.0.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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +11 -1
- package/dist/index.mjs +11 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsModule } from '@micro-cms/types';
|
|
1
|
+
import { CmsModule, SubscriptionOptions } from '@micro-cms/types';
|
|
2
2
|
|
|
3
3
|
declare class RouteRegistry {
|
|
4
4
|
private routes;
|
|
@@ -17,6 +17,10 @@ declare class App {
|
|
|
17
17
|
get: (k: string) => any;
|
|
18
18
|
subscribe: (k: string, c: Function) => void;
|
|
19
19
|
};
|
|
20
|
+
get events(): {
|
|
21
|
+
emit: (e: string, p: any) => Promise<void>;
|
|
22
|
+
subscribe: (e: string, c: Function, o?: SubscriptionOptions) => () => void;
|
|
23
|
+
};
|
|
20
24
|
get runtime(): {
|
|
21
25
|
getCapability: <T = any>(cap: string) => T | undefined;
|
|
22
26
|
getRoutes: () => any[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsModule } from '@micro-cms/types';
|
|
1
|
+
import { CmsModule, SubscriptionOptions } from '@micro-cms/types';
|
|
2
2
|
|
|
3
3
|
declare class RouteRegistry {
|
|
4
4
|
private routes;
|
|
@@ -17,6 +17,10 @@ declare class App {
|
|
|
17
17
|
get: (k: string) => any;
|
|
18
18
|
subscribe: (k: string, c: Function) => void;
|
|
19
19
|
};
|
|
20
|
+
get events(): {
|
|
21
|
+
emit: (e: string, p: any) => Promise<void>;
|
|
22
|
+
subscribe: (e: string, c: Function, o?: SubscriptionOptions) => () => void;
|
|
23
|
+
};
|
|
20
24
|
get runtime(): {
|
|
21
25
|
getCapability: <T = any>(cap: string) => T | undefined;
|
|
22
26
|
getRoutes: () => any[];
|
package/dist/index.js
CHANGED
|
@@ -41,8 +41,12 @@ var EventBus = class {
|
|
|
41
41
|
default: []
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
const handler = { callback, priority, parallel };
|
|
45
|
+
this.listeners[event][stage].push(handler);
|
|
45
46
|
this.listeners[event][stage].sort((a, b) => b.priority - a.priority);
|
|
47
|
+
return () => {
|
|
48
|
+
this.listeners[event][stage] = this.listeners[event][stage].filter((h) => h !== handler);
|
|
49
|
+
};
|
|
46
50
|
}
|
|
47
51
|
async emit(event, payload) {
|
|
48
52
|
if (!this.listeners[event]) return;
|
|
@@ -110,6 +114,12 @@ var App = class {
|
|
|
110
114
|
subscribe: (k, c) => this.stateManager.subscribe(k, c)
|
|
111
115
|
};
|
|
112
116
|
}
|
|
117
|
+
get events() {
|
|
118
|
+
return {
|
|
119
|
+
emit: (e, p) => this.eventBus.emit(e, p),
|
|
120
|
+
subscribe: (e, c, o) => this.eventBus.subscribe(e, c, o)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
113
123
|
get runtime() {
|
|
114
124
|
return {
|
|
115
125
|
getCapability: (cap) => this.capabilities[cap],
|
package/dist/index.mjs
CHANGED
|
@@ -15,8 +15,12 @@ var EventBus = class {
|
|
|
15
15
|
default: []
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const handler = { callback, priority, parallel };
|
|
19
|
+
this.listeners[event][stage].push(handler);
|
|
19
20
|
this.listeners[event][stage].sort((a, b) => b.priority - a.priority);
|
|
21
|
+
return () => {
|
|
22
|
+
this.listeners[event][stage] = this.listeners[event][stage].filter((h) => h !== handler);
|
|
23
|
+
};
|
|
20
24
|
}
|
|
21
25
|
async emit(event, payload) {
|
|
22
26
|
if (!this.listeners[event]) return;
|
|
@@ -84,6 +88,12 @@ var App = class {
|
|
|
84
88
|
subscribe: (k, c) => this.stateManager.subscribe(k, c)
|
|
85
89
|
};
|
|
86
90
|
}
|
|
91
|
+
get events() {
|
|
92
|
+
return {
|
|
93
|
+
emit: (e, p) => this.eventBus.emit(e, p),
|
|
94
|
+
subscribe: (e, c, o) => this.eventBus.subscribe(e, c, o)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
87
97
|
get runtime() {
|
|
88
98
|
return {
|
|
89
99
|
getCapability: (cap) => this.capabilities[cap],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-cms/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@micro-cms/types": "^1.0.
|
|
19
|
+
"@micro-cms/types": "^1.0.17"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|