@grammyjs/commands 0.8.0 → 0.8.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/out/commands.d.ts +2 -2
- package/out/commands.js +8 -8
- package/package.json +2 -1
package/out/commands.d.ts
CHANGED
|
@@ -33,11 +33,11 @@ export declare class Commands<C extends Context> {
|
|
|
33
33
|
private _languages;
|
|
34
34
|
private _scopes;
|
|
35
35
|
private _commands;
|
|
36
|
-
private
|
|
36
|
+
private _cachedComposer;
|
|
37
|
+
private _cachedComposerInvalidated;
|
|
37
38
|
private _commandOptions;
|
|
38
39
|
constructor(options?: Partial<CommandOptions>);
|
|
39
40
|
private _addCommandToScope;
|
|
40
|
-
private _populateComposer;
|
|
41
41
|
private _populateMetadata;
|
|
42
42
|
/**
|
|
43
43
|
* Registers a new command with a default handler.
|
package/out/commands.js
CHANGED
|
@@ -35,7 +35,8 @@ class Commands {
|
|
|
35
35
|
this._languages = new Set();
|
|
36
36
|
this._scopes = new Map();
|
|
37
37
|
this._commands = [];
|
|
38
|
-
this.
|
|
38
|
+
this._cachedComposer = new deps_node_js_1.Composer();
|
|
39
|
+
this._cachedComposerInvalidated = false;
|
|
39
40
|
this._commandOptions = {};
|
|
40
41
|
this._commandOptions = options;
|
|
41
42
|
}
|
|
@@ -44,11 +45,6 @@ class Commands {
|
|
|
44
45
|
const commands = (_a = this._scopes.get(JSON.stringify(scope))) !== null && _a !== void 0 ? _a : [];
|
|
45
46
|
this._scopes.set(JSON.stringify(scope), commands.concat([command]));
|
|
46
47
|
}
|
|
47
|
-
_populateComposer() {
|
|
48
|
-
for (const command of this._commands) {
|
|
49
|
-
this._composer.use(command.middleware());
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
48
|
_populateMetadata() {
|
|
53
49
|
this._languages.clear();
|
|
54
50
|
this._scopes.clear();
|
|
@@ -73,6 +69,7 @@ class Commands {
|
|
|
73
69
|
if (handler)
|
|
74
70
|
command.addToScope({ type: "default" }, handler);
|
|
75
71
|
this._commands.push(command);
|
|
72
|
+
this._cachedComposerInvalidated = true;
|
|
76
73
|
return command;
|
|
77
74
|
}
|
|
78
75
|
/**
|
|
@@ -176,8 +173,11 @@ class Commands {
|
|
|
176
173
|
return JSON.stringify(this);
|
|
177
174
|
}
|
|
178
175
|
middleware() {
|
|
179
|
-
this.
|
|
180
|
-
|
|
176
|
+
if (this._cachedComposerInvalidated) {
|
|
177
|
+
this._cachedComposer = new deps_node_js_1.Composer(...this._commands);
|
|
178
|
+
this._cachedComposerInvalidated = false;
|
|
179
|
+
}
|
|
180
|
+
return this._cachedComposer.middleware();
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* Replaces the `toString` method on node.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grammyjs/commands",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "grammY Commands Plugin",
|
|
5
5
|
"main": "out/mod.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"ts-pattern": "^5.0.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"deno-bin": "^1.45.2",
|
|
24
25
|
"typescript": "^5.1.6"
|
|
25
26
|
},
|
|
26
27
|
"files": [
|