@tsonic/js 10.0.37 → 10.0.38
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/README.md +36 -68
- package/package.json +1 -1
- package/tsonic.bindings.json +6 -0
package/README.md
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
# @tsonic/js
|
|
2
2
|
|
|
3
|
-
JavaScript
|
|
3
|
+
JavaScript runtime bindings for **Tsonic**.
|
|
4
4
|
|
|
5
5
|
This package is part of Tsonic: https://tsonic.org.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`@tsonic/js` provides JS runtime APIs (`JSON`, `console`, `Map`, `Set`, `Date`, timers, etc.) for Tsonic projects.
|
|
8
8
|
|
|
9
9
|
## Prerequisites
|
|
10
10
|
|
|
11
|
-
- Install the .NET 10 SDK
|
|
11
|
+
- Install the .NET 10 SDK: https://dotnet.microsoft.com/download
|
|
12
12
|
- Verify: `dotnet --version`
|
|
13
13
|
|
|
14
|
-
## Quick Start
|
|
14
|
+
## Quick Start (surface-first, no `@tsonic/js` imports required)
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
mkdir my-app && cd my-app
|
|
18
|
-
npx --yes tsonic@latest init
|
|
18
|
+
npx --yes tsonic@latest init --surface js
|
|
19
19
|
npx --yes tsonic@latest add npm @tsonic/js
|
|
20
|
+
```
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
cat > packages/my-app/src/App.ts <<'EOF'
|
|
23
|
-
import { console, JSON } from "@tsonic/js/index.js";
|
|
24
|
-
|
|
22
|
+
```ts
|
|
25
23
|
export function main(): void {
|
|
26
24
|
const value = JSON.parse<{ x: number }>('{"x": 1}');
|
|
27
25
|
console.log(JSON.stringify(value));
|
|
28
26
|
}
|
|
29
|
-
|
|
27
|
+
```
|
|
30
28
|
|
|
29
|
+
Build/run:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
31
32
|
npm run dev
|
|
32
33
|
```
|
|
33
34
|
|
|
@@ -37,81 +38,48 @@ npm run dev
|
|
|
37
38
|
npx --yes tsonic@latest add npm @tsonic/js
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
This repo is versioned by runtime major:
|
|
43
|
-
|
|
44
|
-
- `10` → `versions/10/` → npm: `@tsonic/js@10.x`
|
|
45
|
-
|
|
46
|
-
When publishing, run: `npm publish versions/10 --access public`
|
|
41
|
+
If the workspace is not already JS surface, set:
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- `console` (JS-style console)
|
|
51
|
-
- `JSON` (`parse` / `stringify`)
|
|
52
|
-
- `Map`, `Set`, `WeakMap`, `WeakSet`
|
|
53
|
-
- `Date`, `Math`, `RegExp`, `Number`, `String`
|
|
54
|
-
- Timers via `Timers.setTimeout` / `Timers.setInterval`
|
|
55
|
-
- JS-style `Array` via `JSArray<T>`
|
|
56
|
-
- Common globals (e.g. `parseInt`, `parseFloat`, `encodeURI`, …)
|
|
57
|
-
|
|
58
|
-
## Usage
|
|
59
|
-
|
|
60
|
-
### `console` + JSON
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
import { console, JSON } from "@tsonic/js/index.js";
|
|
64
|
-
|
|
65
|
-
export function main(): void {
|
|
66
|
-
const value = JSON.parse<{ x: number }>('{"x": 1}');
|
|
67
|
-
console.log(JSON.stringify(value));
|
|
68
|
-
}
|
|
43
|
+
```bash
|
|
44
|
+
npx --yes tsonic@latest init --surface js
|
|
69
45
|
```
|
|
70
46
|
|
|
71
|
-
|
|
47
|
+
## Optional direct imports
|
|
72
48
|
|
|
73
|
-
|
|
74
|
-
import { Timers, console } from "@tsonic/js/index.js";
|
|
49
|
+
Surface mode enables natural JS authoring, but direct package imports remain supported:
|
|
75
50
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
51
|
+
```ts
|
|
52
|
+
import { Timers, JSArray } from "@tsonic/js/index.js";
|
|
79
53
|
```
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
import { Map, Set } from "@tsonic/js/index.js";
|
|
85
|
-
|
|
86
|
-
const map = new Map<string, number>();
|
|
87
|
-
map.set("key", 42);
|
|
88
|
-
|
|
89
|
-
const set = new Set<string>();
|
|
90
|
-
set.add("value");
|
|
91
|
-
```
|
|
55
|
+
## Core APIs
|
|
92
56
|
|
|
93
|
-
|
|
57
|
+
- `console`
|
|
58
|
+
- `JSON`
|
|
59
|
+
- `Map`, `Set`, `WeakMap`, `WeakSet`
|
|
60
|
+
- `Date`, `Math`, `RegExp`, `Number`, `String`
|
|
61
|
+
- `Timers`
|
|
62
|
+
- `JSArray<T>`
|
|
63
|
+
- globals like `parseInt`, `parseFloat`, `encodeURI`
|
|
94
64
|
|
|
95
|
-
|
|
96
|
-
import { JSArray } from "@tsonic/js/index.js";
|
|
65
|
+
## Relationship to `@tsonic/nodejs`
|
|
97
66
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const mapped = arr.map((x) => x * 2);
|
|
101
|
-
void mapped;
|
|
102
|
-
```
|
|
67
|
+
- `@tsonic/js` = JS runtime surface
|
|
68
|
+
- `@tsonic/nodejs` = Node-style modules (`node:fs`, `node:path`, `node:crypto`, ...)
|
|
103
69
|
|
|
104
|
-
##
|
|
70
|
+
## Versioning
|
|
105
71
|
|
|
106
|
-
|
|
72
|
+
- `10` → `versions/10/` → npm: `@tsonic/js@10.x`
|
|
107
73
|
|
|
108
|
-
|
|
74
|
+
Publish:
|
|
109
75
|
|
|
110
|
-
|
|
76
|
+
```bash
|
|
77
|
+
npm publish versions/10 --access public
|
|
78
|
+
```
|
|
111
79
|
|
|
112
80
|
## Development
|
|
113
81
|
|
|
114
|
-
See `__build
|
|
82
|
+
See `__build/`.
|
|
115
83
|
|
|
116
84
|
## License
|
|
117
85
|
|
package/package.json
CHANGED
package/tsonic.bindings.json
CHANGED