@twinkle-lang/twinkle 0.1.0 → 0.2.0

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # @twinkle-lang/twinkle
2
2
 
3
- Twinkle is a statically typed language targeting WebAssembly GC. This package
4
- ships both the `twk` command-line compiler and an embeddable JS library for
5
- compiling and running Twinkle programs from Node.js.
3
+ Twinkle is a statically typed, value-oriented language targeting Wasm GC. This
4
+ package ships both the `twk` command-line compiler and an embeddable JS library
5
+ for compiling and running Twinkle programs from Node.js.
6
6
 
7
7
  ## Install
8
8
 
package/boot.wasm CHANGED
Binary file
package/node.mjs CHANGED
@@ -58,6 +58,23 @@ function loadBootWasm() {
58
58
  }
59
59
  }
60
60
 
61
+ function loadPackageVersion() {
62
+ if (process.env.TWK_VERSION) return process.env.TWK_VERSION;
63
+ try {
64
+ const pkg = JSON.parse(readFileSync(`${here}/package.json`, "utf8"));
65
+ if (typeof pkg.version === "string") return pkg.version;
66
+ } catch (_) {
67
+ // Not running from the packaged npm layout.
68
+ }
69
+ try {
70
+ const pkg = JSON.parse(readFileSync(`${here}/../npm/package.json`, "utf8"));
71
+ if (typeof pkg.version === "string") return pkg.version;
72
+ } catch (_) {
73
+ // Development fallback failed; let the compiler report "dev".
74
+ }
75
+ return undefined;
76
+ }
77
+
61
78
  function loadBridgeWasm() {
62
79
  const override = process.env.BRIDGE_WASM;
63
80
  if (override) return readFileSync(resolve(override));
@@ -75,11 +92,15 @@ function loadBridgeWasm() {
75
92
 
76
93
  async function main() {
77
94
  const bootOverride = process.env.BOOT_WASM;
95
+ const env = { ...process.env };
96
+ const version = loadPackageVersion();
97
+ if (version !== undefined) env.TWK_VERSION = version;
98
+
78
99
  const exitCode = await runWasmBytesAsync(loadBootWasm(), {
79
100
  programPath: bootOverride ? resolve(bootOverride) : "twk.wasm",
80
101
  guestArgs: process.argv.slice(2),
81
102
  cwd: process.cwd(),
82
- env: process.env,
103
+ env,
83
104
  stdout: nodeStream(1),
84
105
  stderr: nodeStream(2),
85
106
  bridgeBytes: loadBridgeWasm(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinkle-lang/twinkle",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Twinkle — a statically typed language targeting WebAssembly GC. CLI (twk) plus an embeddable compile/run library.",
5
5
  "type": "module",
6
6
  "bin": { "twk": "node.mjs" },