gramio 0.0.44 → 0.0.46
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/README.md +1 -1
- package/dist/bot.d.ts +8 -1
- package/dist/bot.js +14 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/plugin.d.ts +8 -1
- package/dist/plugin.js +8 -2
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[](https://core.telegram.org/bots/api)
|
|
6
6
|
[](https://www.npmjs.org/package/@gramio/core)
|
|
7
7
|
[](https://jsr.io/@gramio/core)
|
|
8
8
|
[](https://jsr.io/@gramio/core)
|
package/dist/bot.d.ts
CHANGED
|
@@ -139,8 +139,15 @@ export declare class Bot<Errors extends ErrorDefinitions = {}, Derives extends D
|
|
|
139
139
|
derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<typeof this, Update>>>(updateName: MaybeArray<Update>, handler: Handler): Bot<Errors, Derives & {
|
|
140
140
|
[K in Update]: Awaited<ReturnType<Handler>>;
|
|
141
141
|
}>;
|
|
142
|
+
decorate<Value extends Record<string, any>>(value: Value): Bot<Errors, Derives & {
|
|
143
|
+
global: {
|
|
144
|
+
[K in keyof Value]: Value[K];
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
142
147
|
decorate<Name extends string, Value>(name: Name, value: Value): Bot<Errors, Derives & {
|
|
143
|
-
global: {
|
|
148
|
+
global: {
|
|
149
|
+
[K in Name]: Value;
|
|
150
|
+
};
|
|
144
151
|
}>;
|
|
145
152
|
/**
|
|
146
153
|
* This hook called when the bot is `started`.
|
package/dist/bot.js
CHANGED
|
@@ -297,12 +297,20 @@ let Bot = (() => {
|
|
|
297
297
|
this.updates.composer.derive(updateNameOrHandler, handler);
|
|
298
298
|
return this;
|
|
299
299
|
}
|
|
300
|
-
decorate(
|
|
300
|
+
decorate(nameOrRecordValue, value) {
|
|
301
301
|
for (const contextName of Object.keys(contexts_1.contextsMappings)) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
302
|
+
if (typeof nameOrRecordValue === "string")
|
|
303
|
+
// @ts-expect-error
|
|
304
|
+
Object.defineProperty(contexts_1.contextsMappings[contextName].prototype, name, {
|
|
305
|
+
value,
|
|
306
|
+
});
|
|
307
|
+
else
|
|
308
|
+
Object.defineProperties(
|
|
309
|
+
// @ts-expect-error
|
|
310
|
+
contexts_1.contextsMappings[contextName].prototype, Object.keys(nameOrRecordValue).reduce((acc, key) => {
|
|
311
|
+
acc[key] = { value: nameOrRecordValue[key] };
|
|
312
|
+
return acc;
|
|
313
|
+
}, {}));
|
|
306
314
|
}
|
|
307
315
|
return this;
|
|
308
316
|
}
|
|
@@ -472,9 +480,7 @@ let Bot = (() => {
|
|
|
472
480
|
if (plugin._.composer.length) {
|
|
473
481
|
this.use(plugin._.composer.composed);
|
|
474
482
|
}
|
|
475
|
-
|
|
476
|
-
this.decorate(key, value);
|
|
477
|
-
}
|
|
483
|
+
this.decorate(plugin._.decorators);
|
|
478
484
|
for (const [key, value] of Object.entries(plugin._.errorsDefinitions)) {
|
|
479
485
|
if (this.errorsDefinitions[key])
|
|
480
486
|
this.errorsDefinitions[key] = value;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export * from "./webhook/index";
|
|
|
11
11
|
export * from "@gramio/contexts";
|
|
12
12
|
export * from "@gramio/files";
|
|
13
13
|
export * from "@gramio/keyboards";
|
|
14
|
-
export * from "@gramio/types";
|
|
14
|
+
export type * from "@gramio/types";
|
|
15
15
|
export * from "@gramio/format";
|
|
16
16
|
export * from "@gramio/callback-data";
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,5 @@ __exportStar(require("./webhook/index"), exports);
|
|
|
29
29
|
__exportStar(require("@gramio/contexts"), exports);
|
|
30
30
|
__exportStar(require("@gramio/files"), exports);
|
|
31
31
|
__exportStar(require("@gramio/keyboards"), exports);
|
|
32
|
-
__exportStar(require("@gramio/types"), exports);
|
|
33
32
|
__exportStar(require("@gramio/format"), exports);
|
|
34
33
|
__exportStar(require("@gramio/callback-data"), exports);
|
package/dist/plugin.d.ts
CHANGED
|
@@ -112,8 +112,15 @@ export declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extend
|
|
|
112
112
|
derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<AnyBot, Update>>>(updateName: MaybeArray<Update>, handler: Handler): Plugin<Errors, Derives & {
|
|
113
113
|
[K in Update]: Awaited<ReturnType<Handler>>;
|
|
114
114
|
}>;
|
|
115
|
+
decorate<Value extends Record<string, any>>(value: Value): Plugin<Errors, Derives & {
|
|
116
|
+
global: {
|
|
117
|
+
[K in keyof Value]: Value[K];
|
|
118
|
+
};
|
|
119
|
+
}>;
|
|
115
120
|
decorate<Name extends string, Value>(name: Name, value: Value): Plugin<Errors, Derives & {
|
|
116
|
-
global: {
|
|
121
|
+
global: {
|
|
122
|
+
[K in Name]: Value;
|
|
123
|
+
};
|
|
117
124
|
}>;
|
|
118
125
|
/** Register handler to one or many Updates */
|
|
119
126
|
on<T extends UpdateName>(updateName: MaybeArray<T>, handler: Handler<ContextType<AnyBot, T> & Derives["global"] & Derives[T]>): this;
|
package/dist/plugin.js
CHANGED
|
@@ -155,8 +155,14 @@ let Plugin = (() => {
|
|
|
155
155
|
this._.composer.derive(updateNameOrHandler, handler);
|
|
156
156
|
return this;
|
|
157
157
|
}
|
|
158
|
-
decorate(
|
|
159
|
-
|
|
158
|
+
decorate(nameOrValue, value) {
|
|
159
|
+
if (typeof nameOrValue === "string")
|
|
160
|
+
this._.decorators[nameOrValue] = value;
|
|
161
|
+
else {
|
|
162
|
+
for (const [name, value] of Object.entries(nameOrValue)) {
|
|
163
|
+
this._.decorators[name] = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
160
166
|
return this;
|
|
161
167
|
}
|
|
162
168
|
/** Register handler to one or many Updates */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gramio",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.46",
|
|
5
5
|
"description": "Powerful Telegram Bot API framework",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -28,23 +28,27 @@
|
|
|
28
28
|
"license": "ISC",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@biomejs/biome": "1.7.3",
|
|
31
|
+
"@types/bun": "^1.1.6",
|
|
31
32
|
"@types/debug": "^4.1.12",
|
|
32
|
-
"@types/node": "^20.14.
|
|
33
|
+
"@types/node": "^20.14.10",
|
|
33
34
|
"typescript": "^5.5.3"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"@gramio/callback-data": "^0.0.3",
|
|
37
|
-
"@gramio/contexts": "^0.0.
|
|
38
|
-
"@gramio/files": "^0.0.
|
|
38
|
+
"@gramio/contexts": "^0.0.20",
|
|
39
|
+
"@gramio/files": "^0.0.11",
|
|
39
40
|
"@gramio/format": "^0.1.3",
|
|
40
41
|
"@gramio/keyboards": "^0.3.3",
|
|
41
|
-
"@gramio/types": "^7.
|
|
42
|
+
"@gramio/types": "^7.7.1",
|
|
42
43
|
"debug": "^4.3.5",
|
|
43
44
|
"inspectable": "^3.0.2",
|
|
44
45
|
"middleware-io": "^2.8.1",
|
|
45
46
|
"undici": "^6.19.2"
|
|
46
47
|
},
|
|
48
|
+
"overrides": {
|
|
49
|
+
"@gramio/types": "^7.7.1"
|
|
50
|
+
},
|
|
47
51
|
"files": [
|
|
48
52
|
"dist"
|
|
49
53
|
]
|
|
50
|
-
}
|
|
54
|
+
}
|