typenative 0.1.0 → 0.1.2

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": "typenative",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Build native applications using Typescript.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,61 +11,10 @@
11
11
  "build": "tsc",
12
12
  "watch": "tsc --watch",
13
13
  "build:native": "node scripts/build-native.mjs",
14
- "test": "node ./test/test-runner test",
15
- "features": "node scripts/features.mjs",
16
- "release": "npm publish",
17
- "test1": "node ./bin/cli.js --source test/test1.spec.ts --script",
18
- "test2": "node ./bin/cli.js --source test/test2.spec.ts --script",
19
- "test3": "node ./bin/cli.js --source test/test3.spec.ts --script",
20
- "test3_node": "tsc test/test3.spec.ts && node test/test3.spec.js && rimraf test/test3.spec.js",
21
- "test4": "node ./bin/cli.js --source test/test4.spec.ts --script",
22
- "test5": "node ./bin/cli.js --source test/test5.spec.ts --script",
23
- "test6": "node ./bin/cli.js --source test/test6.spec.ts --script",
24
- "test7": "node ./bin/cli.js --source test/test7.spec.ts --script",
25
- "test8": "node ./bin/cli.js --source test/test8.spec.ts --script",
26
- "test9": "node ./bin/cli.js --source test/test9.spec.ts --script",
27
- "test10": "node ./bin/cli.js --source test/test10.spec.ts --script",
28
- "test11": "node ./bin/cli.js --source test/test11.spec.ts --script",
29
- "test12": "node ./bin/cli.js --source test/test12.spec.ts --script",
30
- "test13": "node ./bin/cli.js --source test/test13.spec.ts --script",
31
- "test14": "node ./bin/cli.js --source test/test14.spec.ts --script",
32
- "test15": "node ./bin/cli.js --source test/test15.spec.ts --script",
33
- "test16": "node ./bin/cli.js --source test/test16.spec.ts --script",
34
- "test17": "node ./bin/cli.js --source test/test17.spec.ts --script",
35
- "test18": "node ./bin/cli.js --source test/test18.spec.ts --script",
36
- "test19": "node ./bin/cli.js --source test/test19.spec.ts --script",
37
- "test20": "node ./bin/cli.js --source test/test20.spec.ts --script",
38
- "test21": "node ./bin/cli.js --source test/test21.spec.ts --script",
39
- "test22": "node ./bin/cli.js --source test/test22.spec.ts --script",
40
- "test23": "node ./bin/cli.js --source test/test23.spec.ts --script",
41
- "test24": "node ./bin/cli.js --source test/test24.spec.ts --script",
42
- "test25": "node ./bin/cli.js --source test/test25.spec.ts --script",
43
- "test25_export": "node ./bin/cli.js --source test/test25-export.spec.ts --script",
44
- "test26": "node ./bin/cli.js --source test/test26.spec.ts --script",
45
- "test27": "node ./bin/cli.js --source test/test27.spec.ts --script",
46
- "test28": "node ./bin/cli.js --source test/test28.spec.ts --script",
47
- "test29": "node ./bin/cli.js --source test/test29.spec.ts --script",
48
- "test30": "node ./bin/cli.js --source test/test30.spec.ts --script",
49
- "test31": "node ./bin/cli.js --source test/test31.spec.ts --script",
50
- "test32": "node ./bin/cli.js --source test/test32.spec.ts --script",
51
- "test33": "node ./bin/cli.js --source test/test33.spec.ts --script",
52
- "test34": "node ./bin/cli.js --source test/test34.spec.ts --script",
53
- "test35": "node ./bin/cli.js --source test/test35.spec.ts --script",
54
- "test36": "node ./bin/cli.js --source test/test36.spec.ts --script",
55
- "test37": "node ./bin/cli.js --source test/test37.spec.ts --script",
56
- "test38": "node ./bin/cli.js --source test/test38.spec.ts --script",
57
- "test39": "node ./bin/cli.js --source test/test39.spec.ts --script",
58
- "test40": "node ./bin/cli.js --source test/test40.spec.ts --script",
59
- "test41": "node ./bin/cli.js --source test/test41.spec.ts --script",
60
- "test42": "node ./bin/cli.js --source test/test42.spec.ts --script",
61
- "test43": "node ./bin/cli.js --source test/test43.spec.ts --script",
62
- "test44": "node ./bin/cli.js --source test/test44.spec.ts --script",
63
- "test45": "node ./bin/cli.js --source test/test45.spec.ts --script",
64
- "test46": "node ./bin/cli.js --source test/test46.spec.ts --script",
65
- "test47": "node ./bin/cli.js --source test/test47.spec.ts --script",
66
- "test48": "node ./bin/cli.js --source test/test48.spec.ts --script",
67
- "test49": "node ./bin/cli.js --source test/test49.spec.ts --script",
68
- "test50": "node ./bin/cli.js --source test/test50.spec.ts --script"
14
+ "conformance": "node scripts/conformance.mjs",
15
+ "conformance:parallel": "node scripts/conformance-parallel.mjs",
16
+ "test": "npm run conformance",
17
+ "release": "npm publish"
69
18
  },
70
19
  "repository": {
71
20
  "type": "git",
@@ -78,13 +27,12 @@
78
27
  },
79
28
  "homepage": "https://github.com/danisss9/typenative#readme",
80
29
  "devDependencies": {
81
- "@types/inquirer": "^9.0.9",
82
- "@types/node": "^25.3.5",
83
- "execa": "^9.6.1",
30
+ "@types/inquirer": "^9.0.10",
31
+ "@types/node": "^24.19.2",
84
32
  "rimraf": "^6.1.3"
85
33
  },
86
34
  "dependencies": {
87
- "inquirer": "^13.3.0",
88
- "typescript": "^5.9.3"
35
+ "inquirer": "^14.2.3",
36
+ "typescript": "^6.0.3"
89
37
  }
90
38
  }
package/tsparser/main.go CHANGED
@@ -19,14 +19,19 @@ import (
19
19
  "github.com/buke/typescript-go-internal/pkg/ast"
20
20
  "github.com/buke/typescript-go-internal/pkg/core"
21
21
  "github.com/buke/typescript-go-internal/pkg/parser"
22
+ "github.com/buke/typescript-go-internal/pkg/scanner"
22
23
  )
23
24
 
25
+ // The parsed source, for template raw text
26
+ var sourceText string
27
+
24
28
  func main() {
25
29
  sourceBytes, err := io.ReadAll(os.Stdin)
26
30
  if err != nil {
27
31
  fmt.Fprintln(os.Stderr, "read stdin:", err)
28
32
  os.Exit(1)
29
33
  }
34
+ sourceText = string(sourceBytes)
30
35
  sourceFile := parser.ParseSourceFile(
31
36
  ast.SourceFileParseOptions{FileName: "/main.ts"},
32
37
  string(sourceBytes),
@@ -128,7 +133,6 @@ func serializeNode(n *ast.Node) any {
128
133
  ast.KindTemplateTail, ast.KindJsxText:
129
134
  obj["text"] = n.Text()
130
135
  }
131
-
132
136
  // Binding-pattern holes (`[a, , b]`): ts-go parses them as an empty
133
137
  // BindingElement; the TypeScript API exposes them as OmittedExpression
134
138
  if n.Kind == ast.KindBindingElement {
@@ -141,6 +145,18 @@ func serializeNode(n *ast.Node) any {
141
145
  if data.IsValid() {
142
146
  collectFields(data, obj)
143
147
  }
148
+ // Template pieces: rawText is the source between their delimiters
149
+ // (`…`, `…${, }…${, }…`), with line endings normalized like JS
150
+ switch n.Kind {
151
+ case ast.KindNoSubstitutionTemplateLiteral, ast.KindTemplateHead, ast.KindTemplateMiddle, ast.KindTemplateTail:
152
+ start, end := scanner.SkipTrivia(sourceText, n.Pos())+1, n.End()-1
153
+ if n.Kind == ast.KindTemplateHead || n.Kind == ast.KindTemplateMiddle {
154
+ end--
155
+ }
156
+ if start <= end && end <= len(sourceText) {
157
+ obj["rawText"] = strings.ReplaceAll(sourceText[start:end], "\r\n", "\n")
158
+ }
159
+ }
144
160
  return obj
145
161
  }
146
162
 
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/tsparser/tsparser.exe
3
- size: 37234176 bytes
4
- sha256: ce98ee3136dc50c07e1d3c12ace366c7f7180982c7cc14615ac614ab34fc63ae
3
+ size: 37232640 bytes
4
+ sha256: 52a159d7760b1b54c809ccdf9f9c2913aacde6acbd3793f9aa877562cf86d3ff
package/TODO.md DELETED
@@ -1,38 +0,0 @@
1
- # Self-Hosting Roadmap
2
-
3
- Goal: TypeNative transpiles itself into a native Go binary (1.0 milestone).
4
-
5
- ## Done
6
- - [x] node:fs mappings (read/write/append/exists/mkdir/readdir/copy/rm) via Go helpers
7
- - [x] node:url (fileURLToPath/pathToFileURL), node:os (platform/homedir/tmpdir)
8
- - [x] node:child_process (spawnSync-shaped sync API, stdio-inherit runs)
9
- - [x] node:readline sync `question` (stdin prompts in native binaries)
10
- - [x] Go helper-function registry emitted into the main output file
11
- - [x] Per-file import scoping (imports registered after function-body visits)
12
- - [x] Unbraced if/else-if/else statements, `%`/`%=` → math.Mod
13
- - [x] nanoid/fs-extra/execa removed from src; inquirer isolated in Node-only cli.ts
14
- - [x] Transpilable core: src/index.ts (run/createProject), src/prompt.ts, src/main.ts (self-host entry)
15
-
16
- ## Done (phase 3a/3b)
17
- - [x] tsparser/ Go tool: parses TS via buke/typescript-go-internal (no JS runtime),
18
- emits normalized JSON AST (kind + TS-spec field names)
19
- - [x] src/parse-node.ts: Node adapter (typescript npm pkg → same JSON shape)
20
- - [x] Verified byte-identical AST signatures across all 32 test specs AND all
21
- compiler sources (incl. transpiler.ts, 521k-char signature)
22
-
23
- - [x] ts shim converted to plain isX() functions + string kind literals
24
- (object-literal shim was itself untranspilable)
25
- - [x] Phase 3c: transpiler.ts no longer imports `typescript` — consumes the JSON AST
26
- via an injected parse function (ts shim keeps predicate call sites); operator
27
- tokens, process.env, stdin-exec mappings added; verified identical Go output
28
- via npm parser and Go-parser paths on all 33 test specs
29
- - [x] Phase 4: src/main.ts (incl. transpiler.ts) compiles to a native binary;
30
- `any` values use a small Go runtime (TnGet/TnSet/TnAs/...) instead of guessed types
31
- - [x] Phase 5: stage-1/stage-2 bootstrap — the native compiler passes all test specs
32
- and reproduces its own Go source identically (fixpoint)
33
-
34
- ## Next
35
- - [ ] CI self-hosting job (stage 1 → stage 2 → compare); README/CHANGELOG updates
36
- - [ ] Stateful RegExp /g (`lastIndex`, `while ((m = re.exec(s)))` loops)
37
- - [ ] import.meta.url lowering
38
- - [ ] Gradually type the AST in transpiler.ts (fewer dynamic lookups, faster binary)