Skip to content

Commit ce0d27f

Browse files
committed
chore: refactor exports
1 parent b0882f7 commit ce0d27f

10 files changed

Lines changed: 81 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [2.0.0-beta.3] – 2025-08-25
4+
5+
- Make export friendly use in web
6+
37
## [2.0.0-beta.2] – 2025-08-25
48

59
- Make friendly for use in web

index.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

jest.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

jest.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Config } from 'jest';
2+
3+
const config: Config = {
4+
verbose: true,
5+
testEnvironment: 'node',
6+
testMatch: ['**/*.spec.ts'],
7+
preset: 'ts-jest',
8+
};
9+
10+
export default config;

package.json

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,60 @@
11
{
22
"name": "@ton-community/tlb-codegen",
3-
"version": "2.0.0-beta.2",
4-
"description": "",
5-
"main": "build/index.js",
3+
"version": "2.0.0-beta.3",
4+
"description": "TLB code generator",
5+
"files": [
6+
"./build/*",
7+
"LICENSE",
8+
"README.md"
9+
],
10+
"main": "./build/index.js",
11+
"module": "./build/index.js",
12+
"types": "./build/index.d.ts",
13+
"exports": {
14+
".": {
15+
"types": "./build/index.d.ts",
16+
"import": "./build/index.js",
17+
"require": "./build/index.js",
18+
"default": "./index.js"
19+
},
20+
"./node": {
21+
"types": "./build/node.d.ts",
22+
"import": "./build/node.js",
23+
"require": "./build/node.js",
24+
"default": "./build/node.js"
25+
}
26+
},
27+
"typesVersions": {
28+
"*": {
29+
"*": ["*"]
30+
}
31+
},
32+
"bin": {
33+
"tlb": "./build/cli.js"
34+
},
35+
"publishConfig": {
36+
"access": "public"
37+
},
638
"prettier": "@ton/toolchain/prettier",
739
"scripts": {
840
"lint": "eslint . --max-warnings 0",
941
"lint:fix": "eslint . --max-warnings 0 --fix",
42+
"test:gen": "ts-node test/generate.ts",
1043
"test": "jest",
1144
"build": "npm run compile",
45+
"prepublishOnly": "npm run build",
1246
"compile": "tsc"
1347
},
14-
"bin": {
15-
"tlb": "build/main.js"
16-
},
17-
"keywords": [],
18-
"author": "",
19-
"license": "ISC",
48+
"keywords": [
49+
"ton",
50+
"tlb",
51+
"tl-b",
52+
"codegen",
53+
"react-native",
54+
"browser"
55+
],
56+
"author": "TON Tech",
57+
"license": "MIT",
2058
"devDependencies": {
2159
"@jest/globals": "^29.7.0",
2260
"@ton/toolchain": "github:the-ton-tech/toolchain#v1.4.0",

main.ts renamed to src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
import meow from 'meow';
33

4-
import { generateCode } from './src/node';
4+
import { generateCode } from './node';
55

66
const cli = meow(
77
`

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export * from './ast';
2+
export { getTLBCodeByAST, generateCodeByAST, generateCodeFromData } from './main';
3+
export { generateCode, getTLBCode, generateCodeWithGenerator } from './node';
4+
export { isBigInt, isBigIntExpr } from './generators/typescript/utils';
5+
export type { CodeGenerator } from './generators/generator';
6+
export { TypescriptGenerator } from './generators/typescript/generator';

src/main.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ import { CodeBuilder } from './generators/CodeBuilder';
88
import { CodeGenerator, CommonGenDeclaration } from './generators/generator';
99
import { TypescriptGenerator } from './generators/typescript/generator';
1010

11-
export function getTLBCodeByAST(tree: Program, input: string) {
11+
export function getTLBCodeByAST(tree: Program, input: string): TLBCode {
1212
let oldTlbCode: TLBCodeBuild = { types: new Map<string, TLBTypeBuild>() };
1313
let splittedInput = input.split('\n');
1414
fillConstructors(tree.declarations, oldTlbCode, splittedInput);
15-
let tlbCode: TLBCode = convertCodeToReadonly(oldTlbCode);
16-
17-
return tlbCode;
15+
return convertCodeToReadonly(oldTlbCode);
1816
}
1917

2018
export function generateCodeByAST(tree: Program, input: string, getGenerator: (tlbCode: TLBCode) => CodeGenerator) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import path from 'path';
22

3-
import { generateCode } from './src/node';
3+
import { generateCode } from '../src/node';
44

55
function genCodeForTest(name: string) {
6-
const fixturesDir = path.resolve(__dirname, 'test');
6+
const fixturesDir = path.resolve(__dirname, 'tlb');
77
generateCode(
8-
path.resolve(fixturesDir, 'tlb', name + '.tlb'),
8+
path.resolve(fixturesDir, name + '.tlb'),
99
'test/generated_files/generated_' + name + '.ts',
1010
'typescript',
1111
);

tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@
77
"strict": true, /* Enable all strict type-checking options. */
88
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
99
"outDir": "build",
10-
}
10+
"declaration": true,
11+
"allowSyntheticDefaultImports": true,
12+
"moduleResolution": "node",
13+
"isolatedModules": false
14+
},
15+
"include": [
16+
"src/**/*"
17+
]
1118
}

0 commit comments

Comments
 (0)