@2byte/tgbot-framework 1.0.8 → 1.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2byte/tgbot-framework",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A TypeScript framework for creating Telegram bots with sections-based architecture (Bun optimized)",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/core/App.ts CHANGED
@@ -731,19 +731,23 @@ export class App {
731
731
  throw new Error(`Section ${sectionId} not found at path ${pathSectionModule}.ts`);
732
732
  }
733
733
 
734
- if (freshVersion) {
735
- pathSectionModule += "?update=" + Date.now();
736
- }
737
-
738
- // For bypassing cache in Node.js/Bun, we use file:// protocol with a query parameter
739
- let importPath = pathSectionModule;
740
- if (freshVersion) {
741
- // We convert the path to a file:// URL with a query parameter
742
- const fileUrl = new URL(`file:///${pathSectionModule.replace(/\\/g, "/")}`);
743
- fileUrl.searchParams.set("t", Date.now().toString());
744
- importPath = fileUrl.href;
734
+ // For bypassing cache in Bun, we need to clear the module cache
735
+ if (freshVersion && typeof Bun !== 'undefined') {
736
+ // Clear Bun's module cache for this specific module
737
+ const modulePath = pathSectionModule + ".ts";
738
+ this.debugLog('Clearing cache for fresh version of section:', modulePath);
739
+
740
+ // In Bun, we can use dynamic import with a unique query to bypass cache
741
+ // But we need to resolve the absolute path first
742
+ const absolutePath = path.resolve(modulePath);
743
+
744
+ // Try to delete from require cache if it exists
745
+ if (require.cache && require.cache[absolutePath]) {
746
+ delete require.cache[absolutePath];
747
+ }
745
748
  }
746
- const sectionClass = (await import(importPath)).default as typeof Section;
749
+
750
+ const sectionClass = (await import(pathSectionModule)).default as typeof Section;
747
751
  this.debugLog("Loaded section", sectionId);
748
752
 
749
753
  return sectionClass;
@@ -46,9 +46,9 @@ export class Artisan {
46
46
  * Возвращает шаблон для новой секции
47
47
  */
48
48
  private getSectionTemplate(name: string): string {
49
- return `import { Section } from "../../src/illumination/Section";
50
- import { SectionOptions } from "../../src/types";
51
- import { InlineKeyboard } from "../../src/illumination/InlineKeyboard";
49
+ return `import { Section } from "@2byte/tgbot-framework";
50
+ import { SectionOptions } from "@2byte/tgbot-framework";
51
+ import { InlineKeyboard } from "@2byte/tgbot-framework";
52
52
 
53
53
  export default class ${name}Section extends Section {
54
54
  static command = "${name.toLowerCase()}";
@@ -1,7 +1,8 @@
1
1
  import type { Database } from "bun:sqlite";
2
2
  import { MakeManualPaginateButtonsParams, ModelPaginateParams, PaginateResult } from "@2byte/tgbot-framework";
3
3
  import { Section } from "@2byte/tgbot-framework";
4
+ import { Model as BaseModel } from "@2byte/tgbot-framework";
4
5
 
5
- export abstract class Model {
6
+ export abstract class Model extends BaseModel {
6
7
 
7
8
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "{{kebabName}}",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "{{description}}",
5
5
  "main": "bot.ts",
6
6
  "scripts": {