Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [2.0.0-beta.3] – 2025-08-25

- Make export friendly use in web

## [2.0.0-beta.2] – 2025-08-25

- Make friendly for use in web
Expand Down
6 changes: 0 additions & 6 deletions index.ts

This file was deleted.

6 changes: 0 additions & 6 deletions jest.config.js

This file was deleted.

10 changes: 10 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Config } from 'jest';

const config: Config = {
verbose: true,
testEnvironment: 'node',
testMatch: ['**/*.spec.ts'],
preset: 'ts-jest',
};

export default config;
56 changes: 47 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,60 @@
{
"name": "@ton-community/tlb-codegen",
"version": "2.0.0-beta.2",
"description": "",
"main": "build/index.js",
"version": "2.0.0-beta.3",
"description": "TLB code generator",
"files": [
"./build/*",
"LICENSE",
"README.md"
],
"main": "./build/index.js",
"module": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"import": "./build/index.js",
"require": "./build/index.js",
"default": "./index.js"
},
"./node": {
"types": "./build/node.d.ts",
"import": "./build/node.js",
"require": "./build/node.js",
"default": "./build/node.js"
}
},
"typesVersions": {
"*": {
"*": ["*"]
}
},
"bin": {
"tlb": "./build/cli.js"
},
"publishConfig": {
"access": "public"
},
"prettier": "@ton/toolchain/prettier",
"scripts": {
"lint": "eslint . --max-warnings 0",
"lint:fix": "eslint . --max-warnings 0 --fix",
"test:gen": "ts-node test/generate.ts",
"test": "jest",
"build": "npm run compile",
"prepublishOnly": "npm run build",
"compile": "tsc"
},
"bin": {
"tlb": "build/main.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"keywords": [
"ton",
"tlb",
"tl-b",
"codegen",
"react-native",
"browser"
],
"author": "TON Tech",
"license": "MIT",
"devDependencies": {
"@jest/globals": "^29.7.0",
"@ton/toolchain": "github:the-ton-tech/toolchain#v1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion main.ts → src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import meow from 'meow';

import { generateCode } from './src/node';
import { generateCode } from './node';

const cli = meow(
`
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './ast';
export { getTLBCodeByAST, generateCodeByAST, generateCodeFromData } from './main';
export { generateCode, getTLBCode, generateCodeWithGenerator } from './node';
export { isBigInt, isBigIntExpr } from './generators/typescript/utils';
export type { CodeGenerator } from './generators/generator';
export { TypescriptGenerator } from './generators/typescript/generator';
6 changes: 2 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import { CodeBuilder } from './generators/CodeBuilder';
import { CodeGenerator, CommonGenDeclaration } from './generators/generator';
import { TypescriptGenerator } from './generators/typescript/generator';

export function getTLBCodeByAST(tree: Program, input: string) {
export function getTLBCodeByAST(tree: Program, input: string): TLBCode {
let oldTlbCode: TLBCodeBuild = { types: new Map<string, TLBTypeBuild>() };
let splittedInput = input.split('\n');
fillConstructors(tree.declarations, oldTlbCode, splittedInput);
let tlbCode: TLBCode = convertCodeToReadonly(oldTlbCode);

return tlbCode;
return convertCodeToReadonly(oldTlbCode);
}

export function generateCodeByAST(tree: Program, input: string, getGenerator: (tlbCode: TLBCode) => CodeGenerator) {
Expand Down
6 changes: 3 additions & 3 deletions generate_tests.ts → test/generate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'path';

import { generateCode } from './src/node';
import { generateCode } from '../src/node';

function genCodeForTest(name: string) {
const fixturesDir = path.resolve(__dirname, 'test');
const fixturesDir = path.resolve(__dirname, 'tlb');
generateCode(
path.resolve(fixturesDir, 'tlb', name + '.tlb'),
path.resolve(fixturesDir, name + '.tlb'),
'test/generated_files/generated_' + name + '.ts',
'typescript',
);
Expand Down
9 changes: 8 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"outDir": "build",
}
"declaration": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"isolatedModules": false
},
"include": [
"src/**/*"
]
}
Loading