typenative 0.0.9 → 0.0.11
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/LICENSE +1 -1
- package/README.md +48 -9
- package/bin/index.js +14 -6
- package/bin/transpiler.js +137 -28
- package/package.json +14 -8
- package/types/typenative.d.ts +38 -3
- package/bin/tcc/doc/tcc-doc.html +0 -2418
- package/bin/tcc/doc/tcc-win32.txt +0 -156
- package/bin/tcc/examples/dll.c +0 -12
- package/bin/tcc/examples/fib.c +0 -23
- package/bin/tcc/examples/hello_dll.c +0 -19
- package/bin/tcc/examples/hello_win.c +0 -163
- package/bin/tcc/examples/libtcc_test.c +0 -76
- package/bin/tcc/include/_mingw.h +0 -139
- package/bin/tcc/include/assert.h +0 -54
- package/bin/tcc/include/conio.h +0 -409
- package/bin/tcc/include/ctype.h +0 -281
- package/bin/tcc/include/dir.h +0 -31
- package/bin/tcc/include/direct.h +0 -68
- package/bin/tcc/include/dirent.h +0 -135
- package/bin/tcc/include/dos.h +0 -55
- package/bin/tcc/include/errno.h +0 -75
- package/bin/tcc/include/excpt.h +0 -123
- package/bin/tcc/include/fcntl.h +0 -52
- package/bin/tcc/include/fenv.h +0 -108
- package/bin/tcc/include/float.h +0 -57
- package/bin/tcc/include/inttypes.h +0 -297
- package/bin/tcc/include/io.h +0 -418
- package/bin/tcc/include/limits.h +0 -111
- package/bin/tcc/include/locale.h +0 -91
- package/bin/tcc/include/malloc.h +0 -175
- package/bin/tcc/include/math.h +0 -777
- package/bin/tcc/include/mem.h +0 -13
- package/bin/tcc/include/memory.h +0 -40
- package/bin/tcc/include/process.h +0 -176
- package/bin/tcc/include/sec_api/conio_s.h +0 -42
- package/bin/tcc/include/sec_api/crtdbg_s.h +0 -19
- package/bin/tcc/include/sec_api/io_s.h +0 -33
- package/bin/tcc/include/sec_api/mbstring_s.h +0 -52
- package/bin/tcc/include/sec_api/search_s.h +0 -25
- package/bin/tcc/include/sec_api/stdio_s.h +0 -145
- package/bin/tcc/include/sec_api/stdlib_s.h +0 -67
- package/bin/tcc/include/sec_api/stralign_s.h +0 -30
- package/bin/tcc/include/sec_api/string_s.h +0 -41
- package/bin/tcc/include/sec_api/sys/timeb_s.h +0 -34
- package/bin/tcc/include/sec_api/tchar_s.h +0 -266
- package/bin/tcc/include/sec_api/time_s.h +0 -61
- package/bin/tcc/include/sec_api/wchar_s.h +0 -128
- package/bin/tcc/include/setjmp.h +0 -160
- package/bin/tcc/include/share.h +0 -28
- package/bin/tcc/include/signal.h +0 -63
- package/bin/tcc/include/stdarg.h +0 -41
- package/bin/tcc/include/stdbool.h +0 -10
- package/bin/tcc/include/stddef.h +0 -28
- package/bin/tcc/include/stdint.h +0 -209
- package/bin/tcc/include/stdio.h +0 -429
- package/bin/tcc/include/stdlib.h +0 -580
- package/bin/tcc/include/string.h +0 -164
- package/bin/tcc/include/sys/fcntl.h +0 -13
- package/bin/tcc/include/sys/file.h +0 -14
- package/bin/tcc/include/sys/locking.h +0 -30
- package/bin/tcc/include/sys/stat.h +0 -290
- package/bin/tcc/include/sys/time.h +0 -69
- package/bin/tcc/include/sys/timeb.h +0 -133
- package/bin/tcc/include/sys/types.h +0 -118
- package/bin/tcc/include/sys/unistd.h +0 -14
- package/bin/tcc/include/sys/utime.h +0 -146
- package/bin/tcc/include/tcclib.h +0 -78
- package/bin/tcc/include/tchar.h +0 -1102
- package/bin/tcc/include/time.h +0 -287
- package/bin/tcc/include/vadefs.h +0 -11
- package/bin/tcc/include/values.h +0 -4
- package/bin/tcc/include/varargs.h +0 -12
- package/bin/tcc/include/wchar.h +0 -871
- package/bin/tcc/include/wctype.h +0 -172
- package/bin/tcc/include/winapi/basetsd.h +0 -149
- package/bin/tcc/include/winapi/basetyps.h +0 -85
- package/bin/tcc/include/winapi/guiddef.h +0 -151
- package/bin/tcc/include/winapi/intrin.h +0 -11
- package/bin/tcc/include/winapi/poppack.h +0 -8
- package/bin/tcc/include/winapi/pshpack1.h +0 -8
- package/bin/tcc/include/winapi/pshpack2.h +0 -8
- package/bin/tcc/include/winapi/pshpack4.h +0 -8
- package/bin/tcc/include/winapi/pshpack8.h +0 -8
- package/bin/tcc/include/winapi/reason.h +0 -80
- package/bin/tcc/include/winapi/specstrings.h +0 -7
- package/bin/tcc/include/winapi/stralign.h +0 -154
- package/bin/tcc/include/winapi/tvout.h +0 -79
- package/bin/tcc/include/winapi/winbase.h +0 -2951
- package/bin/tcc/include/winapi/wincon.h +0 -301
- package/bin/tcc/include/winapi/windef.h +0 -293
- package/bin/tcc/include/winapi/windows.h +0 -123
- package/bin/tcc/include/winapi/winerror.h +0 -3166
- package/bin/tcc/include/winapi/wingdi.h +0 -4080
- package/bin/tcc/include/winapi/winnetwk.h +0 -476
- package/bin/tcc/include/winapi/winnls.h +0 -765
- package/bin/tcc/include/winapi/winnt.h +0 -5770
- package/bin/tcc/include/winapi/winreg.h +0 -272
- package/bin/tcc/include/winapi/winuser.h +0 -5651
- package/bin/tcc/include/winapi/winver.h +0 -160
- package/bin/tcc/lib/gdi32.def +0 -337
- package/bin/tcc/lib/kernel32.def +0 -765
- package/bin/tcc/lib/libtcc1.a +0 -0
- package/bin/tcc/lib/msvcrt.def +0 -1399
- package/bin/tcc/lib/user32.def +0 -654
- package/bin/tcc/libtcc/libtcc.def +0 -38
- package/bin/tcc/libtcc/libtcc.h +0 -100
- package/bin/tcc/libtcc.dll +0 -0
- package/bin/tcc/tcc.exe +0 -0
- package/bin/tcc/tiny_impdef.exe +0 -0
- package/bin/tcc/tiny_libmaker.exe +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,18 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
Build native applications using Typescript.
|
|
4
4
|
|
|
5
|
+
## PreRequisites
|
|
6
|
+
|
|
7
|
+
- Go 1.21 or newer.
|
|
8
|
+
|
|
5
9
|
## Get Started
|
|
6
10
|
|
|
7
11
|
- Write a file `test.ts` with content `console.log('Hello World!');` or any other message
|
|
8
|
-
- Run `npx typenative --source test.ts`
|
|
9
|
-
-
|
|
12
|
+
- Run `npx typenative --source test.ts --script`
|
|
13
|
+
- See your message in the terminal
|
|
14
|
+
|
|
15
|
+
## Typescript Syntax Support
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
TypeNative currently supports a subset of TypeScript syntax elements that are transpiled to Go code:
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
| Feature | Supported | Notes |
|
|
20
|
+
|---------|:---------:|-------|
|
|
21
|
+
| **Basic Types** | | |
|
|
22
|
+
| number | ✅ | Transpiled to `float64` |
|
|
23
|
+
| boolean | ✅ | Transpiled to `bool` |
|
|
24
|
+
| string | ✅ | |
|
|
25
|
+
| null | ✅ | |
|
|
26
|
+
| any | ✅ | Used for type inference |
|
|
27
|
+
| **Variables** | | |
|
|
28
|
+
| Variable declarations | ✅ | `let` and `const` |
|
|
29
|
+
| **Operators** | | |
|
|
30
|
+
| Arithmetic operators | ✅ | `+`, `-`, etc. |
|
|
31
|
+
| Comparison operators | ✅ | `==`, `!=`, etc. |
|
|
32
|
+
| Logical operators | ✅ | `&&`, `\|\|` |
|
|
33
|
+
| Increment/Decrement | ✅ | `++`, `--` |
|
|
34
|
+
| **Control Flow** | | |
|
|
35
|
+
| For loops | ✅ | Standard `for` loops |
|
|
36
|
+
| For...of loops | ✅ | Iteration over arrays |
|
|
37
|
+
| While loops | ✅ | Transpiled to Go's `for` loops |
|
|
38
|
+
| Do...while loops | ✅ | Implemented with conditional break |
|
|
39
|
+
| If/Else statements | ✅ | Fully supported |
|
|
40
|
+
| Switch statements | ✅ | Case and default statements |
|
|
41
|
+
| **Data Structures** | | |
|
|
42
|
+
| Arrays | ✅ | Basic array operations |
|
|
43
|
+
| Array methods | ✅ | `push` supported |
|
|
44
|
+
| **Functions** | | |
|
|
45
|
+
| console.log | ✅ | Mapped to `fmt.Println` |
|
|
46
|
+
| console.time/timeEnd | ✅ | Performance measurement |
|
|
47
|
+
| Math.random | ✅ | Mapped to Go's `rand.Float64()` |
|
|
48
|
+
| Math.floor | ✅ | Mapped to Go's `math.Floor()` |
|
|
49
|
+
| **Unsupported Features** | | |
|
|
50
|
+
| Classes | ❌ | Not implemented |
|
|
51
|
+
| Interfaces | ❌ | Not implemented |
|
|
52
|
+
| Functions | ❌ | Custom function definitions not supported |
|
|
53
|
+
| Arrow Functions | ❌ | Not implemented |
|
|
54
|
+
| Async/Await | ❌ | Not implemented |
|
|
55
|
+
| Modules/Imports | ❌ | Not implemented |
|
|
56
|
+
| Generics | ❌ | Not implemented |
|
|
15
57
|
|
|
16
|
-
|
|
17
|
-
- Database (using sqlite)
|
|
18
|
-
- Web Server (using libmicrohttpd)
|
|
19
|
-
- UI App (using webview)
|
|
58
|
+
TypeNative is currently in early development and new features are being added regularly.
|
package/bin/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import inquirer from 'inquirer';
|
|
3
|
-
import shell from 'shelljs';
|
|
4
3
|
import fs from 'fs-extra';
|
|
5
4
|
import path from 'path';
|
|
6
|
-
import {
|
|
5
|
+
import { execa } from 'execa';
|
|
6
|
+
import { transpileToNative } from './transpiler.js';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
@@ -34,14 +34,22 @@ const __dirname = path.dirname(__filename);
|
|
|
34
34
|
const tsCode = answers.tsCode
|
|
35
35
|
? answers.tsCode
|
|
36
36
|
: await fs.readFile(target ?? answers.path, { encoding: 'utf-8' });
|
|
37
|
-
const
|
|
37
|
+
const nativeCode = transpileToNative(tsCode);
|
|
38
38
|
await fs.ensureDir('dist');
|
|
39
|
-
await fs.writeFile('dist/code.
|
|
40
|
-
|
|
39
|
+
await fs.writeFile('dist/code.go', nativeCode, { encoding: 'utf-8' });
|
|
40
|
+
await execa('go build -o dist/native.exe dist/code.go');
|
|
41
|
+
// await fs.remove('dist/code.go');
|
|
41
42
|
if (answers.output) {
|
|
42
43
|
await fs.copy('dist/native.exe', answers.output, { overwrite: true });
|
|
44
|
+
await fs.remove('dist/native.exe');
|
|
43
45
|
}
|
|
44
|
-
if (
|
|
46
|
+
if (scriptMode) {
|
|
47
|
+
await execa('dist/native.exe', {
|
|
48
|
+
stdio: 'inherit'
|
|
49
|
+
});
|
|
50
|
+
await fs.remove('dist/native.exe');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
45
53
|
console.log('DONE');
|
|
46
54
|
}
|
|
47
55
|
})();
|
package/bin/transpiler.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
let TypeCheker;
|
|
3
|
-
|
|
3
|
+
let importedPackages = new Set();
|
|
4
|
+
export function transpileToNative(code) {
|
|
4
5
|
const sourceFile = ts.createSourceFile('main.ts', code, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS);
|
|
5
6
|
TypeCheker = ts.createProgram(['main.ts'], {}).getTypeChecker();
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
importedPackages.clear();
|
|
8
|
+
const transpiledCode = visit(sourceFile);
|
|
9
|
+
return `package main
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
${[...importedPackages].map((pkg) => `import "${pkg}"`).join('\n')}
|
|
12
|
+
|
|
13
|
+
func main() {
|
|
14
|
+
${transpiledCode.trim()}
|
|
15
|
+
}`;
|
|
13
16
|
}
|
|
14
|
-
export function visit(node) {
|
|
17
|
+
export function visit(node, inline = false, extraBlockContent = '') {
|
|
15
18
|
let code = '';
|
|
16
19
|
if (ts.isIdentifier(node)) {
|
|
17
20
|
return node.text;
|
|
@@ -20,26 +23,44 @@ export function visit(node) {
|
|
|
20
23
|
return `"${node.text}"`;
|
|
21
24
|
}
|
|
22
25
|
else if (ts.isNumericLiteral(node)) {
|
|
23
|
-
return
|
|
26
|
+
return `float64(${node.text})`;
|
|
24
27
|
}
|
|
25
28
|
else if (ts.isToken(node) && node.kind === ts.SyntaxKind.TrueKeyword) {
|
|
26
|
-
return `
|
|
29
|
+
return `true`;
|
|
27
30
|
}
|
|
28
31
|
else if (ts.isToken(node) && node.kind === ts.SyntaxKind.FalseKeyword) {
|
|
29
|
-
return `
|
|
32
|
+
return `false`;
|
|
33
|
+
}
|
|
34
|
+
else if (ts.isArrayLiteralExpression(node)) {
|
|
35
|
+
const type = ts.isVariableDeclaration(node.parent) ? getType(node.parent.type, true) : '';
|
|
36
|
+
return `[]${type} {${node.elements.map((e) => visit(e)).join(', ')}}`;
|
|
37
|
+
}
|
|
38
|
+
else if (ts.isBlock(node)) {
|
|
39
|
+
return `{\n\t\t${node.statements.map((n) => visit(n)).join('\t')}${extraBlockContent}}${inline ? '' : '\n\t'}`;
|
|
40
|
+
}
|
|
41
|
+
else if (ts.isElementAccessExpression(node)) {
|
|
42
|
+
return `${visit(node.expression)}[int(${visit(node.argumentExpression)})]`;
|
|
30
43
|
}
|
|
31
44
|
else if (ts.isPropertyAccessExpression(node)) {
|
|
32
|
-
|
|
45
|
+
const leftSide = visit(node.expression);
|
|
46
|
+
const rightSide = visit(node.name);
|
|
47
|
+
return getAcessString(leftSide, rightSide);
|
|
33
48
|
}
|
|
34
49
|
else if (ts.isVariableDeclaration(node)) {
|
|
35
|
-
const type =
|
|
36
|
-
const initializer = node.initializer ?
|
|
37
|
-
return `${type
|
|
50
|
+
const type = getType(node.type);
|
|
51
|
+
const initializer = node.initializer ? `= ${visit(node.initializer)}` : '';
|
|
52
|
+
return `${type === ':' ? '' : 'var '}${visit(node.name)} ${type}${type === ':' ? '' : ' '}${initializer}`;
|
|
38
53
|
}
|
|
39
54
|
else if (ts.isCallExpression(node)) {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
return
|
|
55
|
+
const caller = visit(node.expression);
|
|
56
|
+
const args = node.arguments.map((a) => visit(a));
|
|
57
|
+
return getCallString(caller, args);
|
|
58
|
+
}
|
|
59
|
+
else if (ts.isPrefixUnaryExpression(node)) {
|
|
60
|
+
return `${getOperatorText(node.operator)}${visit(node.operand)}`;
|
|
61
|
+
}
|
|
62
|
+
else if (ts.isPostfixUnaryExpression(node)) {
|
|
63
|
+
return `${visit(node.operand, true)}${getOperatorText(node.operator)}`;
|
|
43
64
|
}
|
|
44
65
|
else if (ts.isBinaryExpression(node)) {
|
|
45
66
|
return `${visit(node.left)} ${node.operatorToken.getText()} ${visit(node.right)}`;
|
|
@@ -48,29 +69,117 @@ export function visit(node) {
|
|
|
48
69
|
return `(${visit(node.expression)})`;
|
|
49
70
|
}
|
|
50
71
|
else if (ts.isVariableDeclarationList(node)) {
|
|
51
|
-
return node.declarations.map((n) => visit(n)).join(';\n\t') + ';\n\t';
|
|
72
|
+
return (node.declarations.map((n) => visit(n)).join(inline ? ';' : ';\n\t') + (inline ? '' : ';\n\t'));
|
|
52
73
|
}
|
|
53
74
|
else if (ts.isExpressionStatement(node)) {
|
|
54
|
-
return visit(node.expression) + ';\n\t';
|
|
75
|
+
return visit(node.expression) + (inline ? '' : ';\n\t');
|
|
76
|
+
}
|
|
77
|
+
else if (ts.isForStatement(node)) {
|
|
78
|
+
return `for ${visit(node.initializer, true)}; ${visit(node.condition, true)}; ${visit(node.incrementor, true)}${visit(node.statement)}`;
|
|
79
|
+
}
|
|
80
|
+
else if (ts.isForOfStatement(node)) {
|
|
81
|
+
return `for _,${visit(node.initializer, true)}= range ${visit(node.expression, true)}${visit(node.statement)}`;
|
|
82
|
+
}
|
|
83
|
+
else if (ts.isWhileStatement(node)) {
|
|
84
|
+
return `for ${visit(node.expression, true)}${visit(node.statement)}`;
|
|
85
|
+
}
|
|
86
|
+
else if (ts.isDoStatement(node)) {
|
|
87
|
+
const condition = `\tif !(${visit(node.expression, true)}) {\n\t\t\tbreak \n\t\t}\n\t`;
|
|
88
|
+
return `for ${visit(node.statement, false, condition)}`;
|
|
89
|
+
}
|
|
90
|
+
else if (ts.isIfStatement(node)) {
|
|
91
|
+
const condition = `if ${visit(node.expression, true)} ${visit(node.thenStatement, true)}`;
|
|
92
|
+
if (node.elseStatement) {
|
|
93
|
+
return `${condition} else ${visit(node.elseStatement)}`;
|
|
94
|
+
}
|
|
95
|
+
return condition;
|
|
96
|
+
}
|
|
97
|
+
const syntaxKind = ts.SyntaxKind[node.kind];
|
|
98
|
+
if (!['SourceFile', 'FirstStatement', 'EndOfFileToken'].includes(syntaxKind)) {
|
|
99
|
+
console.log(ts.SyntaxKind[node.kind], node.getText());
|
|
55
100
|
}
|
|
56
|
-
console.log(ts.SyntaxKind[node.kind], node.getText());
|
|
57
101
|
ts.forEachChild(node, (subNode) => {
|
|
58
102
|
code += visit(subNode);
|
|
59
103
|
return null;
|
|
60
104
|
});
|
|
61
105
|
return code;
|
|
62
106
|
}
|
|
63
|
-
function
|
|
107
|
+
function getType(typeNode, getArrayType = false) {
|
|
64
108
|
const type = TypeCheker.getTypeFromTypeNode(typeNode);
|
|
65
|
-
|
|
109
|
+
let typeName = TypeCheker.typeToString(type);
|
|
110
|
+
const isArray = typeNode?.kind & ts.SyntaxKind.ArrayType;
|
|
111
|
+
if (isArray) {
|
|
112
|
+
if (getArrayType) {
|
|
113
|
+
typeName = typeName.replace('[]', '');
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
return ':';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
66
119
|
switch (typeName) {
|
|
67
|
-
case 'string':
|
|
68
|
-
return { typeStr: 'char', arrayStr: '[]' };
|
|
69
120
|
case 'number':
|
|
70
|
-
return
|
|
121
|
+
return 'float64';
|
|
71
122
|
case 'boolean':
|
|
72
|
-
return
|
|
123
|
+
return 'bool';
|
|
124
|
+
case 'any':
|
|
125
|
+
return ':';
|
|
73
126
|
default:
|
|
74
|
-
return
|
|
127
|
+
return typeName;
|
|
75
128
|
}
|
|
76
129
|
}
|
|
130
|
+
function getAcessString(leftSide, rightSide) {
|
|
131
|
+
if (rightSide === 'length') {
|
|
132
|
+
return 'float64(len(arr))';
|
|
133
|
+
}
|
|
134
|
+
return `${leftSide}.${rightSide}`;
|
|
135
|
+
}
|
|
136
|
+
function getCallString(caller, args) {
|
|
137
|
+
if (caller === 'console.log') {
|
|
138
|
+
importedPackages.add('fmt');
|
|
139
|
+
return `fmt.Println(${args.join(', ')})`;
|
|
140
|
+
}
|
|
141
|
+
else if (caller === 'console.time') {
|
|
142
|
+
importedPackages.add('time');
|
|
143
|
+
return `${getTimerName(args[0])} := time.Now()`;
|
|
144
|
+
}
|
|
145
|
+
else if (caller === 'console.timeEnd') {
|
|
146
|
+
importedPackages.add('time');
|
|
147
|
+
importedPackages.add('fmt');
|
|
148
|
+
return `fmt.Println("Elapsed time:", time.Since(${getTimerName(args[0])}))`;
|
|
149
|
+
}
|
|
150
|
+
else if (caller === 'Math.random') {
|
|
151
|
+
importedPackages.add('math/rand');
|
|
152
|
+
return 'rand.Float64()';
|
|
153
|
+
}
|
|
154
|
+
else if (caller === 'Math.floor') {
|
|
155
|
+
importedPackages.add('math');
|
|
156
|
+
return `math.Floor(${args.join(', ')})`;
|
|
157
|
+
}
|
|
158
|
+
else if (caller.endsWith('.push')) {
|
|
159
|
+
const arrayName = caller.substring(0, caller.length - '.push'.length);
|
|
160
|
+
return `${arrayName} = append(${arrayName},${args.join(', ')})`;
|
|
161
|
+
}
|
|
162
|
+
return `${caller}(${args.join(', ')})`;
|
|
163
|
+
}
|
|
164
|
+
function getOperatorText(operator) {
|
|
165
|
+
switch (operator) {
|
|
166
|
+
case ts.SyntaxKind.PlusToken:
|
|
167
|
+
return '+';
|
|
168
|
+
case ts.SyntaxKind.MinusToken:
|
|
169
|
+
return '-';
|
|
170
|
+
case ts.SyntaxKind.TildeToken:
|
|
171
|
+
return '~';
|
|
172
|
+
case ts.SyntaxKind.ExclamationToken:
|
|
173
|
+
return '!';
|
|
174
|
+
case ts.SyntaxKind.PlusPlusToken:
|
|
175
|
+
return '++';
|
|
176
|
+
case ts.SyntaxKind.MinusMinusToken:
|
|
177
|
+
return '--';
|
|
178
|
+
default:
|
|
179
|
+
console.error('Did not find operator', operator);
|
|
180
|
+
return '';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function getTimerName(name) {
|
|
184
|
+
return `__timer_${name.replaceAll(' ', '_').replaceAll('"', '')}__`;
|
|
185
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typenative",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Build native applications using Typescript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
"start:compiler": "node ./bin/index",
|
|
13
13
|
"start:script": "node ./bin/index --script",
|
|
14
14
|
"test": "node ./bin/index --source test/test.ts --script",
|
|
15
|
+
"test2": "node ./bin/index --source test/test2.ts --script",
|
|
16
|
+
"test3": "node ./bin/index --source test/test3.ts --script",
|
|
17
|
+
"test3_node": "tsc test/test3.ts && node test/test3.js && rimraf test/test3.js",
|
|
18
|
+
"test4": "node ./bin/index --source test/test4.ts --script",
|
|
19
|
+
"test5": "node ./bin/index --source test/test5.ts --script",
|
|
20
|
+
"test6": "node ./bin/index --source test/test6.ts --script",
|
|
15
21
|
"release": "npm publish"
|
|
16
22
|
},
|
|
17
23
|
"repository": {
|
|
@@ -26,14 +32,14 @@
|
|
|
26
32
|
"homepage": "https://github.com/danisss9/typenative#readme",
|
|
27
33
|
"devDependencies": {
|
|
28
34
|
"@types/fs-extra": "^11.0.4",
|
|
29
|
-
"@types/inquirer": "^9.0.
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"
|
|
35
|
+
"@types/inquirer": "^9.0.8",
|
|
36
|
+
"@types/node": "^22.15.21",
|
|
37
|
+
"rimraf": "^6.0.1"
|
|
32
38
|
},
|
|
33
39
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"typescript": "^5.
|
|
40
|
+
"execa": "^9.5.3",
|
|
41
|
+
"fs-extra": "^11.3.0",
|
|
42
|
+
"inquirer": "^12.6.1",
|
|
43
|
+
"typescript": "^5.8.3"
|
|
38
44
|
}
|
|
39
45
|
}
|
package/types/typenative.d.ts
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface SymbolConstructor {
|
|
2
|
+
readonly iterator: unique symbol;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
declare var Symbol: SymbolConstructor;
|
|
6
|
+
|
|
7
|
+
interface IteratorYieldResult<TYield> {
|
|
8
|
+
done?: false;
|
|
9
|
+
value: TYield;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface IteratorReturnResult<TReturn> {
|
|
13
|
+
done: true;
|
|
14
|
+
value: TReturn;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
|
|
18
|
+
|
|
19
|
+
interface Iterator<T, TReturn = any, TNext = any> {
|
|
20
|
+
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
|
21
|
+
next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
|
|
22
|
+
return?(value?: TReturn): IteratorResult<T, TReturn>;
|
|
23
|
+
throw?(e?: any): IteratorResult<T, TReturn>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface IterableIterator<T, TReturn = any, TNext = any> extends Iterator<T, TReturn, TNext> {
|
|
27
|
+
[Symbol.iterator](): IterableIterator<T, TReturn, TNext>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Array<T> extends IterableIterator<T> {
|
|
2
31
|
/**
|
|
3
32
|
* Gets or sets the length of the array. This is a number one higher than the highest index in the array.
|
|
4
33
|
*/
|
|
@@ -6,14 +35,20 @@ interface Array<T> {
|
|
|
6
35
|
/**
|
|
7
36
|
* Returns a string representation of an array.
|
|
8
37
|
*/
|
|
9
|
-
|
|
38
|
+
push(element: T): void;
|
|
10
39
|
|
|
11
40
|
[n: number]: T;
|
|
12
41
|
}
|
|
13
42
|
|
|
14
43
|
interface Console {
|
|
15
44
|
log(...data: any[]): void;
|
|
45
|
+
time(label?: string): void;
|
|
46
|
+
timeEnd(label?: string): void;
|
|
16
47
|
}
|
|
17
48
|
declare var console: Console;
|
|
18
49
|
|
|
19
|
-
|
|
50
|
+
interface Math {
|
|
51
|
+
random(): number;
|
|
52
|
+
floor(x: number): number;
|
|
53
|
+
}
|
|
54
|
+
declare var Math: Math;
|