scriptc 0.1.6 → 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/dist/usage.d.ts DELETED
@@ -1,78 +0,0 @@
1
- export declare const USAGE = "scriptc \u2014 TypeScript/JavaScript to native and WebAssembly executables (experimental)\n\nUsage:\n scriptc build <file.ts|.js> [options] compile to an executable or source artifact\n scriptc run <file.ts|.js> [options] compile and run\n scriptc coverage <file.ts|.js> how much compiles statically, and why not\n scriptc coverage <file.ts|.js> --dynamic what a --dynamic build compiles, and what still blocks it\n scriptc coverage <file.ts|.js> --external-types <specifier=file.d.ts>\n type-resolve an embedder-provided module for analysis\n scriptc build --lib --profile <p.json> library mode: compile the profile's entry\n module to a linkable static archive\n (<name>.lib.a) exporting the\n profile-declared C symbols; a profile\n with a sidecar section also gets the\n contract sidecar JSON beside the archive\n scriptc cache warm [runtime|tls|dynamic\u2026] prebuild expensive native cache families\n for the current compiler/SDK/target\n\nOptions:\n -o, --out <path> primary output path (default: .scriptc/<name><suffix>)\n --emit <kind> primary output: ir, c, llvm, asm, obj, or exe\n (default: exe). asm/obj use the matching platform helper\n --print <kind> print machine-readable metadata instead of the output path\n (native-link-info implies --emit=obj and never links)\n --backend <b> code generator. llvm is the default and the output that\n ships; c emits readable C for inspecting what the\n compiler produced, and program behavior is identical\n either way. On native targets, a program outside the LLVM tier still\n builds \u2014 the default lane emits C for it and a one-line\n stderr note names the construct \u2014 while an explicit\n --backend llvm fails with that construct named\n wasm32-wasi is LLVM-only unless --backend c is explicit;\n its C inspection lane accepts async-free programs only\n --optimization <release|dev>\n native optimization posture (default: release/-O2). dev\n uses -O0 and stable cached LLVM object shards for faster\n edits of large programs\n --strip remove symbol/debug payload from the linked executable\n for smaller builds (opt in; --emit=exe only)\n --windows-subsystem <console|gui>\n Windows executable subsystem (default: console). gui\n prevents Windows from opening a console window\n --from-c treat input as a C (or .ll) file (toolchain plumbing/debugging)\n --keep-c keep the generated program TU next to the executable\n (default; the .ll \u2014 or the .c under --backend=c or\n when the build fell back)\n --no-keep-c delete the generated program TU after compiling\n --emit-ir also write IR beside an executable or library archive;\n deprecated for executables: use --emit=ir for primary IR\n --sanitize build with ASan + runtime RC audit\n --dynamic embed the dynamic engine (adds ~620KB; static stays the default)\n --ffi <file> bind signature-only TypeScript declarations to native\n C symbols and link the manifest's archives/libraries\n --npm-static <pkg[,pkg\u2026]|auto>\n compile the named npm packages' shipped JS statically as\n program modules (repeatable; \"auto\" opts in every eligible\n direct import: own .d.ts, unminified JS, no build-transform\n markers). A package preflight refuses falls back to the\n island (--dynamic) with a coverage-report note \u2014 opt-in,\n experimental\n --provenance-sources\n EXPERIMENTAL: compile npm dependencies from their\n provenance-attested SOURCE (fetched at the attested\n commit) as static program modules; packages without a\n usable attestation keep the island path (a note, never\n a failure)\n --external-types <specifier=file.d.ts>\n coverage only: map an exact bare module specifier to a\n local declaration file. The declaration supplies types\n for analysis; the host module remains an explicit\n external-boundary blocker (repeatable)\n -h, --help show this help\n -v, --version print the version\n";
2
- export declare const CLI_OPTIONS: {
3
- readonly out: {
4
- readonly type: "string";
5
- readonly short: "o";
6
- };
7
- readonly emit: {
8
- readonly type: "string";
9
- };
10
- readonly print: {
11
- readonly type: "string";
12
- };
13
- readonly backend: {
14
- readonly type: "string";
15
- };
16
- readonly optimization: {
17
- readonly type: "string";
18
- };
19
- readonly strip: {
20
- readonly type: "boolean";
21
- readonly default: false;
22
- };
23
- readonly "windows-subsystem": {
24
- readonly type: "string";
25
- };
26
- readonly "from-c": {
27
- readonly type: "boolean";
28
- readonly default: false;
29
- };
30
- readonly "keep-c": {
31
- readonly type: "boolean";
32
- readonly default: true;
33
- };
34
- readonly "emit-ir": {
35
- readonly type: "boolean";
36
- readonly default: false;
37
- };
38
- readonly sanitize: {
39
- readonly type: "boolean";
40
- readonly default: false;
41
- };
42
- readonly dynamic: {
43
- readonly type: "boolean";
44
- readonly default: false;
45
- };
46
- readonly ffi: {
47
- readonly type: "string";
48
- };
49
- readonly "npm-static": {
50
- readonly type: "string";
51
- readonly multiple: true;
52
- };
53
- readonly "provenance-sources": {
54
- readonly type: "boolean";
55
- readonly default: false;
56
- };
57
- readonly "external-types": {
58
- readonly type: "string";
59
- readonly multiple: true;
60
- };
61
- readonly lib: {
62
- readonly type: "boolean";
63
- readonly default: false;
64
- };
65
- readonly profile: {
66
- readonly type: "string";
67
- };
68
- readonly help: {
69
- readonly type: "boolean";
70
- readonly short: "h";
71
- readonly default: false;
72
- };
73
- readonly version: {
74
- readonly type: "boolean";
75
- readonly short: "v";
76
- readonly default: false;
77
- };
78
- };
package/dist/usage.js DELETED
@@ -1,97 +0,0 @@
1
- export const USAGE = `scriptc — TypeScript/JavaScript to native and WebAssembly executables (experimental)
2
-
3
- Usage:
4
- scriptc build <file.ts|.js> [options] compile to an executable or source artifact
5
- scriptc run <file.ts|.js> [options] compile and run
6
- scriptc coverage <file.ts|.js> how much compiles statically, and why not
7
- scriptc coverage <file.ts|.js> --dynamic what a --dynamic build compiles, and what still blocks it
8
- scriptc coverage <file.ts|.js> --external-types <specifier=file.d.ts>
9
- type-resolve an embedder-provided module for analysis
10
- scriptc build --lib --profile <p.json> library mode: compile the profile's entry
11
- module to a linkable static archive
12
- (<name>.lib.a) exporting the
13
- profile-declared C symbols; a profile
14
- with a sidecar section also gets the
15
- contract sidecar JSON beside the archive
16
- scriptc cache warm [runtime|tls|dynamic…] prebuild expensive native cache families
17
- for the current compiler/SDK/target
18
-
19
- Options:
20
- -o, --out <path> primary output path (default: .scriptc/<name><suffix>)
21
- --emit <kind> primary output: ir, c, llvm, asm, obj, or exe
22
- (default: exe). asm/obj use the matching platform helper
23
- --print <kind> print machine-readable metadata instead of the output path
24
- (native-link-info implies --emit=obj and never links)
25
- --backend <b> code generator. llvm is the default and the output that
26
- ships; c emits readable C for inspecting what the
27
- compiler produced, and program behavior is identical
28
- either way. On native targets, a program outside the LLVM tier still
29
- builds — the default lane emits C for it and a one-line
30
- stderr note names the construct — while an explicit
31
- --backend llvm fails with that construct named
32
- wasm32-wasi is LLVM-only unless --backend c is explicit;
33
- its C inspection lane accepts async-free programs only
34
- --optimization <release|dev>
35
- native optimization posture (default: release/-O2). dev
36
- uses -O0 and stable cached LLVM object shards for faster
37
- edits of large programs
38
- --strip remove symbol/debug payload from the linked executable
39
- for smaller builds (opt in; --emit=exe only)
40
- --windows-subsystem <console|gui>
41
- Windows executable subsystem (default: console). gui
42
- prevents Windows from opening a console window
43
- --from-c treat input as a C (or .ll) file (toolchain plumbing/debugging)
44
- --keep-c keep the generated program TU next to the executable
45
- (default; the .ll — or the .c under --backend=c or
46
- when the build fell back)
47
- --no-keep-c delete the generated program TU after compiling
48
- --emit-ir also write IR beside an executable or library archive;
49
- deprecated for executables: use --emit=ir for primary IR
50
- --sanitize build with ASan + runtime RC audit
51
- --dynamic embed the dynamic engine (adds ~620KB; static stays the default)
52
- --ffi <file> bind signature-only TypeScript declarations to native
53
- C symbols and link the manifest's archives/libraries
54
- --npm-static <pkg[,pkg…]|auto>
55
- compile the named npm packages' shipped JS statically as
56
- program modules (repeatable; "auto" opts in every eligible
57
- direct import: own .d.ts, unminified JS, no build-transform
58
- markers). A package preflight refuses falls back to the
59
- island (--dynamic) with a coverage-report note — opt-in,
60
- experimental
61
- --provenance-sources
62
- EXPERIMENTAL: compile npm dependencies from their
63
- provenance-attested SOURCE (fetched at the attested
64
- commit) as static program modules; packages without a
65
- usable attestation keep the island path (a note, never
66
- a failure)
67
- --external-types <specifier=file.d.ts>
68
- coverage only: map an exact bare module specifier to a
69
- local declaration file. The declaration supplies types
70
- for analysis; the host module remains an explicit
71
- external-boundary blocker (repeatable)
72
- -h, --help show this help
73
- -v, --version print the version
74
- `;
75
- export const CLI_OPTIONS = {
76
- out: { type: "string", short: "o" },
77
- emit: { type: "string" },
78
- print: { type: "string" },
79
- backend: { type: "string" },
80
- optimization: { type: "string" },
81
- strip: { type: "boolean", default: false },
82
- "windows-subsystem": { type: "string" },
83
- "from-c": { type: "boolean", default: false },
84
- "keep-c": { type: "boolean", default: true },
85
- "emit-ir": { type: "boolean", default: false },
86
- sanitize: { type: "boolean", default: false },
87
- dynamic: { type: "boolean", default: false },
88
- ffi: { type: "string" },
89
- "npm-static": { type: "string", multiple: true },
90
- "provenance-sources": { type: "boolean", default: false },
91
- "external-types": { type: "string", multiple: true },
92
- lib: { type: "boolean", default: false },
93
- profile: { type: "string" },
94
- help: { type: "boolean", short: "h", default: false },
95
- version: { type: "boolean", short: "v", default: false },
96
- };
97
- //# sourceMappingURL=usage.js.map
package/dist/usage.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyEpB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;IACnC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACzB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC3B,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;IAC1C,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;IAC7C,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5C,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;IAC9C,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;IAC7C,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;IAC5C,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvB,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;IAChD,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;IACzD,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;IACpD,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;IACxC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE;IACrD,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE;CAChD,CAAC"}
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env node
2
- /* The subprocess host for `scriptc run` on wasm32-wasi. Keeping the WASI
3
- * instance outside the CLI process preserves native run's exit isolation:
4
- * process.exit(), traps, and signals cannot take the compiler process down.
5
- */
6
- import { readFile } from "node:fs/promises";
7
- import { tmpdir } from "node:os";
8
- import { WASI } from "node:wasi";
9
- import { wasiGuestPath } from "@scriptc/compiler";
10
- import { wasiEnvironment, wasiPreopens } from "./paths.js";
11
- const binary = process.argv[2];
12
- if (binary === undefined)
13
- throw new Error("scriptc WASI runner needs a module path");
14
- const cwd = process.cwd();
15
- const hostTmp = tmpdir();
16
- const wasi = new WASI({
17
- version: "preview1",
18
- args: [wasiGuestPath(binary, cwd, hostTmp) ?? binary],
19
- env: wasiEnvironment(process.env, cwd, hostTmp),
20
- // A native scriptc executable inherits access to the caller's filesystem.
21
- // WASI is capability-based, so expose the caller's working tree as `/`
22
- // and the platform's actual temporary directory as guest `/tmp`.
23
- preopens: wasiPreopens(cwd, hostTmp),
24
- returnOnExit: true,
25
- });
26
- const instantiated = await WebAssembly.instantiate(await readFile(binary), wasi.getImportObject());
27
- process.exitCode = wasi.start(instantiated.instance);
28
- //# sourceMappingURL=wasi-runner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wasi-runner.js","sourceRoot":"","sources":["../src/wasi-runner.ts"],"names":[],"mappings":";AACA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAU3D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/B,IAAI,MAAM,KAAK,SAAS;IAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AACrF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC1B,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAEzB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;IACpB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC;IACrD,GAAG,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;IAC/C,0EAA0E;IAC1E,uEAAuE;IACvE,iEAAiE;IACjE,QAAQ,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC;IACpC,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,WAAW,CAChD,MAAM,QAAQ,CAAC,MAAM,CAAC,EACtB,IAAI,CAAC,eAAe,EAAE,CACvB,CAAC;AACF,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- export function hostSupportsRuntimePack(
2
- platform?: NodeJS.Platform,
3
- architecture?: string,
4
- hostRelease?: string,
5
- ): boolean;
@@ -1,12 +0,0 @@
1
- import { release } from "node:os";
2
-
3
- export function hostSupportsRuntimePack(
4
- platform = process.platform,
5
- architecture = process.arch,
6
- hostRelease = release(),
7
- ) {
8
- const darwinMajor = Number.parseInt(hostRelease.split(".", 1)[0] ?? "", 10);
9
- return (platform === "darwin" && (architecture === "arm64" || architecture === "x64") && darwinMajor >= 24) ||
10
- (platform === "linux" && (architecture === "arm64" || architecture === "x64")) ||
11
- (platform === "win32" && architecture === "x64");
12
- }
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { existsSync } from "node:fs";
4
- import { dirname, join } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { hostSupportsRuntimePack } from "./runtime-pack-host.mjs";
7
-
8
- // Workspace installs should stay cheap and deterministic: repository test
9
- // images already manage cache warming explicitly. Published npm packages do
10
- // not contain src/, so only installed consumers take this best-effort path.
11
- const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
12
- if (
13
- !existsSync(join(packageRoot, "src")) &&
14
- process.env["SCRIPTC_NO_CACHE"] !== "1" &&
15
- // A supported platform install already carries immutable release/dev
16
- // runtime artifacts. Unsupported hosts retain the source-toolchain path.
17
- !hostSupportsRuntimePack()
18
- ) {
19
- try {
20
- const { warmNativeCaches } = await import("@scriptc/compiler");
21
- await warmNativeCaches();
22
- } catch (error) {
23
- // Installation must never depend on a native toolchain. A machine without
24
- // clang/ar (or with lifecycle scripts disabled) retains ordinary lazy
25
- // first-build behavior; explicit `scriptc cache warm` reports errors.
26
- if (process.env["SCRIPTC_CACHE_WARM_DEBUG"] === "1") {
27
- process.stderr.write(`scriptc: cache warm skipped: ${error instanceof Error ? error.message : String(error)}\n`);
28
- }
29
- }
30
- }