@skathi-native/cli 0.1.0-beta.2 → 0.1.0-beta.4

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.
Files changed (50) hide show
  1. package/aot/host-globals.json +105 -0
  2. package/aot/native.ts +142 -0
  3. package/aot/pin.ts +67 -0
  4. package/aot/toolchain.lock.json +17 -0
  5. package/aot/transform.ts +69 -0
  6. package/check/codes.ts +19 -0
  7. package/check/command.ts +5 -3
  8. package/check/index.ts +44 -1
  9. package/cli/aot-build.ts +192 -0
  10. package/cli/build-app.ts +102 -31
  11. package/cli/config.ts +45 -102
  12. package/cli/create.ts +12 -54
  13. package/cli/dev.ts +109 -19
  14. package/cli/effects.ts +162 -0
  15. package/cli/elf.ts +3 -2
  16. package/cli/help.ts +56 -148
  17. package/cli/host-fetch.ts +116 -54
  18. package/cli/host.ts +59 -39
  19. package/cli/sk.ts +440 -246
  20. package/cli/skpk.ts +6 -0
  21. package/cli/stamp.ts +2 -2
  22. package/cli/term.ts +169 -38
  23. package/cli/workload-cache.ts +258 -0
  24. package/effects/compile.ts +952 -0
  25. package/effects/redslangc.json +23 -0
  26. package/effects/redslangc.ts +220 -0
  27. package/effects/sk.slang +558 -0
  28. package/package.json +6 -2
  29. package/templates/icon.png +0 -0
  30. package/templates/minimal/.vscode/settings.json +3 -0
  31. package/templates/minimal/src/App.vue +2 -2
  32. package/templates/showcase/.vscode/settings.json +3 -0
  33. package/templates/showcase/shaders/sheen.slang +23 -0
  34. package/templates/showcase/src/components/Titlebar.vue +7 -3
  35. package/templates/showcase/src/engine.ts +3 -26
  36. package/templates/showcase/src/pages/AudioPage.vue +6 -9
  37. package/templates/showcase/src/pages/FilesPage.vue +11 -15
  38. package/templates/showcase/src/pages/FormsPage.vue +2 -3
  39. package/templates/showcase/src/pages/GraphicsPage.vue +13 -15
  40. package/templates/showcase/src/pages/HomePage.vue +1 -2
  41. package/templates/showcase/src/pages/LocalePage.vue +2 -2
  42. package/templates/showcase/src/pages/MediaPage.vue +1 -1
  43. package/templates/showcase/src/pages/MotionPage.vue +1 -1
  44. package/templates/showcase/src/pages/NetworkPage.vue +6 -5
  45. package/templates/showcase/src/pages/PermissionsPage.vue +2 -2
  46. package/templates/showcase/src/pages/StoragePage.vue +23 -36
  47. package/templates/showcase/src/pages/StylesPage.vue +9 -1
  48. package/templates/showcase/src/pages/SystemPage.vue +3 -3
  49. package/templates/showcase/src/styles.css +2 -2
  50. package/templates/showcase/src/components/Missing.vue +0 -26
@@ -0,0 +1,105 @@
1
+ {
2
+ "table": "4750b3540882158b35c1f7cc946edc1acb18561345bc70f9151fb913e59268b8",
3
+ "names": [
4
+ "$vm",
5
+ "AbortController",
6
+ "AbortSignal",
7
+ "Blob",
8
+ "BroadcastChannel",
9
+ "Buffer",
10
+ "BuildError",
11
+ "BuildMessage",
12
+ "Bun",
13
+ "ByteLengthQueuingStrategy",
14
+ "CloseEvent",
15
+ "CompressionStream",
16
+ "CountQueuingStrategy",
17
+ "Crypto",
18
+ "CryptoKey",
19
+ "CustomEvent",
20
+ "DOMException",
21
+ "DecompressionStream",
22
+ "ErrorEvent",
23
+ "Event",
24
+ "EventTarget",
25
+ "File",
26
+ "FormData",
27
+ "HTMLRewriter",
28
+ "Headers",
29
+ "Loader",
30
+ "MessageChannel",
31
+ "MessageEvent",
32
+ "MessagePort",
33
+ "Performance",
34
+ "PerformanceEntry",
35
+ "PerformanceMark",
36
+ "PerformanceMeasure",
37
+ "PerformanceObserver",
38
+ "PerformanceObserverEntryList",
39
+ "PerformanceResourceTiming",
40
+ "PerformanceServerTiming",
41
+ "PerformanceTiming",
42
+ "ReadableByteStreamController",
43
+ "ReadableStream",
44
+ "ReadableStreamBYOBReader",
45
+ "ReadableStreamBYOBRequest",
46
+ "ReadableStreamDefaultController",
47
+ "ReadableStreamDefaultReader",
48
+ "Request",
49
+ "ResolveError",
50
+ "ResolveMessage",
51
+ "Response",
52
+ "SubtleCrypto",
53
+ "TextDecoder",
54
+ "TextDecoderStream",
55
+ "TextEncoder",
56
+ "TextEncoderStream",
57
+ "TransformStream",
58
+ "TransformStreamDefaultController",
59
+ "URL",
60
+ "URLPattern",
61
+ "URLSearchParams",
62
+ "WebSocket",
63
+ "Worker",
64
+ "WritableStream",
65
+ "WritableStreamDefaultController",
66
+ "WritableStreamDefaultWriter",
67
+ "__disableSamplingProfiler",
68
+ "__disableSuperSampler",
69
+ "__dumpAndClearSamplingProfilerSamples",
70
+ "__enableSamplingProfiler",
71
+ "__enableSuperSampler",
72
+ "__signpostStart",
73
+ "__signpostStop",
74
+ "__tracePointStart",
75
+ "__tracePointStop",
76
+ "addEventListener",
77
+ "alert",
78
+ "atob",
79
+ "btoa",
80
+ "clearImmediate",
81
+ "clearInterval",
82
+ "clearTimeout",
83
+ "confirm",
84
+ "crypto",
85
+ "dispatchEvent",
86
+ "fetch",
87
+ "gc",
88
+ "global",
89
+ "navigator",
90
+ "onerror",
91
+ "onmessage",
92
+ "performance",
93
+ "postMessage",
94
+ "process",
95
+ "prompt",
96
+ "queueMicrotask",
97
+ "removeEventListener",
98
+ "reportError",
99
+ "self",
100
+ "setImmediate",
101
+ "setInterval",
102
+ "setTimeout",
103
+ "structuredClone"
104
+ ]
105
+ }
package/aot/native.ts ADDED
@@ -0,0 +1,142 @@
1
+ // One production bundle -> one native image: the opaque-host transform, then `sk-aot compile`
2
+ // (bundle -> IR -> machine code). Shared by `sk build --aot` and the inspector's release build, so
3
+ // both produce manifests the host validates the same way.
4
+ import { createHash } from "node:crypto";
5
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { COMPILER_FIELDS, type CompilerInfo } from "./pin";
8
+ import { opaqueHost, TRANSFORM } from "./transform";
9
+
10
+ export class AotError extends Error {}
11
+
12
+ const sha256 = (bytes: string | Uint8Array) => createHash("sha256").update(bytes).digest("hex");
13
+
14
+ interface Ran {
15
+ code: number;
16
+ stdout: string;
17
+ stderr: string;
18
+ }
19
+
20
+ /** Async, so a spinner keeps turning while sk-aot works. */
21
+ async function run(command: string[], cwd?: string): Promise<Ran> {
22
+ const child = Bun.spawn(command, { ...(cwd ? { cwd } : {}), stdout: "pipe", stderr: "pipe", stdin: "ignore" });
23
+ const [stdout, stderr, code] = await Promise.all([
24
+ new Response(child.stdout).text(),
25
+ new Response(child.stderr).text(),
26
+ child.exited,
27
+ ]);
28
+ return { code, stdout, stderr };
29
+ }
30
+
31
+ /** Where `cargo build --release` in a checkout's tools/sk-aot puts sk-aot. */
32
+ export const repoSkAot = (root: string) =>
33
+ join(root, "tools", "sk-aot", "target", "x86_64-pc-windows-msvc", "release", "sk-aot.exe");
34
+
35
+ const tail = (text: string, lines = 40) => text.trim().split(/\r?\n/).slice(-lines).join("\n");
36
+
37
+ export async function compilerInfo(compiler: string): Promise<CompilerInfo> {
38
+ if (!existsSync(compiler)) throw new AotError(`the native image compiler ${compiler} does not exist`);
39
+ const ran = await run([compiler, "info"]);
40
+ let info: Record<string, unknown> = {};
41
+ try {
42
+ info = JSON.parse(ran.stdout.trim()) as Record<string, unknown>;
43
+ } catch {}
44
+ const fields = COMPILER_FIELDS.map((name) => [name, info[name]] as const);
45
+ if (ran.code !== 0 || fields.some(([, value]) => typeof value !== "string")) {
46
+ throw new AotError(
47
+ `${compiler} is not a working sk-aot (\`info\` exited ${ran.code})\n${tail(ran.stdout + ran.stderr, 5)}`,
48
+ );
49
+ }
50
+ return Object.fromEntries(fields) as unknown as CompilerInfo;
51
+ }
52
+
53
+ /** The first field where `actual` and `expected` disagree, or null. */
54
+ export function compilerMismatch(actual: CompilerInfo, expected: CompilerInfo): string | null {
55
+ for (const name of COMPILER_FIELDS)
56
+ if (actual[name] !== expected[name]) return `${name} ${actual[name]} (the host needs ${expected[name]})`;
57
+ return null;
58
+ }
59
+
60
+ export interface NativeImage {
61
+ image: Uint8Array;
62
+ entry: number;
63
+ identity: string;
64
+ imageSha256: string;
65
+ sourceBundleSha256: string;
66
+ nativeInputSha256: string;
67
+ irSha256: string;
68
+ diagnostics: string;
69
+ }
70
+
71
+ export interface CompileOptions {
72
+ /** sk-aot. */
73
+ compiler: string;
74
+ source: string;
75
+ /** Holds the transformed input, the IR and the image. */
76
+ work: string;
77
+ }
78
+
79
+ export async function compileNative(options: CompileOptions): Promise<NativeImage> {
80
+ const { compiler, source, work } = options;
81
+ mkdirSync(work, { recursive: true });
82
+ const input = join(work, "native-input.js");
83
+ const ir = join(work, "app.ir");
84
+ const image = join(work, "app.image");
85
+ for (const stale of [ir, image, `${image}.entries`, `${image}.identity`]) rmSync(stale, { force: true });
86
+ const wrapped = opaqueHost(source);
87
+ writeFileSync(input, wrapped);
88
+
89
+ const compiled = await run([compiler, "compile", input, ir, image], work);
90
+ if (compiled.code !== 0 || !existsSync(ir) || !existsSync(image)) {
91
+ throw new AotError(
92
+ `sk-aot could not compile the app bundle (exit ${compiled.code}); its input is ${input}\n` +
93
+ tail(compiled.stderr + compiled.stdout),
94
+ );
95
+ }
96
+ const entries = readFileSync(`${image}.entries`, "utf8").trim().split(/\s+/).map(Number);
97
+ const entry = entries[0];
98
+ if (entries.length !== 1 || entry === undefined || !Number.isSafeInteger(entry) || entry < 1)
99
+ throw new AotError(`sk-aot reported entries ${JSON.stringify(entries)}, expected one`);
100
+ const identity = readFileSync(`${image}.identity`);
101
+ if (identity.length !== 16) throw new AotError("sk-aot wrote an invalid image identity");
102
+ const bytes = new Uint8Array(readFileSync(image));
103
+ return {
104
+ image: bytes,
105
+ entry,
106
+ identity: identity.toString("hex"),
107
+ imageSha256: sha256(bytes),
108
+ sourceBundleSha256: sha256(source),
109
+ nativeInputSha256: sha256(wrapped),
110
+ irSha256: sha256(readFileSync(ir)),
111
+ diagnostics: compiled.stdout.trim(),
112
+ };
113
+ }
114
+
115
+ export type NativeKind = "inspector" | "application";
116
+
117
+ /** The manifest the host checks before it loads `image` (crates/sk-app/src/native_aot.rs). */
118
+ export function nativeManifest(
119
+ kind: NativeKind,
120
+ info: CompilerInfo,
121
+ native: NativeImage,
122
+ options: { image: string; preludeSha256: string },
123
+ ): Record<string, unknown> {
124
+ return {
125
+ schema: "skathi.native-aot",
126
+ version: 1,
127
+ stage: "native-image",
128
+ kind,
129
+ ...info,
130
+ image: options.image,
131
+ imageSha256: native.imageSha256,
132
+ imageBytes: native.image.length,
133
+ entry: native.entry,
134
+ identity: native.identity,
135
+ transform: TRANSFORM,
136
+ sourceBundleSha256: native.sourceBundleSha256,
137
+ preludeSha256: options.preludeSha256,
138
+ nativeInputSha256: native.nativeInputSha256,
139
+ irSha256: native.irSha256,
140
+ sourceStage: "production-javascript",
141
+ };
142
+ }
package/aot/pin.ts ADDED
@@ -0,0 +1,67 @@
1
+ // The reviewed native-AOT toolchain: the Bun revision sk-aot's frontend is built from, the engine
2
+ // revision and the builtin table id that sk-aot must report. Reading it runs nothing.
3
+ import { createHash } from "node:crypto";
4
+ import { createReadStream, readFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+
7
+ export const PIN_PATH = join(import.meta.dir, "toolchain.lock.json");
8
+
9
+ export interface ToolchainPin {
10
+ schema: string;
11
+ version: number;
12
+ target: string;
13
+ frontend: { revision: string; sourceRepository: string };
14
+ engine: { revision: string; archiveSha256: string };
15
+ table: { id: string; dumpSha256: string };
16
+ }
17
+
18
+ /** What `sk-aot info` prints, and what a host's `--sk-host-info` `aot` names. */
19
+ export interface CompilerInfo {
20
+ target: string;
21
+ frontend: string;
22
+ engine: string;
23
+ tableId: string;
24
+ compileOptions: string;
25
+ }
26
+
27
+ export const COMPILER_FIELDS = ["target", "frontend", "engine", "tableId", "compileOptions"] as const;
28
+
29
+ export function loadPin(path: string = PIN_PATH): ToolchainPin {
30
+ const pin = JSON.parse(readFileSync(path, "utf8").replace(/^/, "")) as ToolchainPin;
31
+ if (pin.schema !== "skathi.native-aot-toolchain" || pin.version !== 1 || pin.target !== "x86_64-windows")
32
+ throw Error("Unsupported native AOT toolchain pin");
33
+ for (const revision of [pin.frontend?.revision, pin.engine?.revision])
34
+ if (!/^[a-f0-9]{40}$/.test(revision || "")) throw Error("Invalid native AOT revision");
35
+ for (const digest of [pin.engine?.archiveSha256, pin.table?.id, pin.table?.dumpSha256])
36
+ if (!/^[a-f0-9]{64}$/.test(digest || "")) throw Error("Invalid native AOT digest");
37
+ if (pin.frontend.sourceRepository !== "https://github.com/oven-sh/bun.git")
38
+ throw Error("The AOT frontend must be built from the official Bun repository");
39
+ return pin;
40
+ }
41
+
42
+ export function pinnedCompilerInfo(pin: ToolchainPin): CompilerInfo {
43
+ return {
44
+ target: pin.target,
45
+ frontend: pin.frontend.revision,
46
+ engine: pin.engine.revision,
47
+ tableId: pin.table.id,
48
+ compileOptions: `x86_64;references=narrow;image=pic;threads=1;admit=FilesRunByHost;default-options@${pin.engine.revision}`,
49
+ };
50
+ }
51
+
52
+ export async function fileDigest(path: string): Promise<string> {
53
+ const hash = createHash("sha256");
54
+ for await (const chunk of createReadStream(path, { highWaterMark: 64 * 1024 })) hash.update(chunk);
55
+ return hash.digest("hex");
56
+ }
57
+
58
+ export async function verifyFile(path: string, expected: string): Promise<void> {
59
+ const actual = await fileDigest(path);
60
+ if (actual !== expected)
61
+ throw Error(`Native AOT input digest mismatch: ${path}; expected ${expected}, got ${actual}`);
62
+ }
63
+
64
+ export function verifyCompilerInfo(info: Record<string, unknown>, pin: ToolchainPin): void {
65
+ for (const [name, value] of Object.entries(pinnedCompilerInfo(pin)))
66
+ if (info[name] !== value) throw Error(`Native AOT compiler ${name} differs from the reviewed toolchain`);
67
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "schema": "skathi.native-aot-toolchain",
3
+ "version": 1,
4
+ "target": "x86_64-windows",
5
+ "frontend": {
6
+ "revision": "7ca0042d3ba23ed60fd9cd8af1a1ce6ec3f8d074",
7
+ "sourceRepository": "https://github.com/oven-sh/bun.git"
8
+ },
9
+ "engine": {
10
+ "revision": "4d45755fed4aeef19e95beb90d3d0c884a2812bd",
11
+ "archiveSha256": "fd79937b7f8becd5c0961646cd7f8af4409122e9cf710ffd766dc0c89df1f619"
12
+ },
13
+ "table": {
14
+ "id": "4750b3540882158b35c1f7cc946edc1acb18561345bc70f9151fb913e59268b8",
15
+ "dumpSha256": "afac4f15bc41518c037d80965fed1c53edd36b96837602cab40660b3a0f5beb2"
16
+ }
17
+ }
@@ -0,0 +1,69 @@
1
+ // opaque-host-v1: the production bundle, wrapped so the host's globals are opaque inputs to the
2
+ // native frontend. It must not assume that this host's URL, fetch, WebSocket or Blob have Bun's
3
+ // layouts or helpers; the host binds `__SK_AOT_HOST__` to the realm's globalThis before the entry runs.
4
+ import HOST_TABLE from "./host-globals.json";
5
+
6
+ export const TRANSFORM = "opaque-host-v1";
7
+
8
+ export interface BuiltinEntry {
9
+ holder: string;
10
+ origin: string;
11
+ isSymbolName: boolean;
12
+ name: string;
13
+ }
14
+
15
+ /** The host-implemented globals of a builtin table dump: what host-globals.json records. */
16
+ export function hostGlobalsFromTable(entries: BuiltinEntry[]): string[] {
17
+ return [
18
+ ...new Set(
19
+ entries
20
+ .filter(
21
+ (entry) =>
22
+ entry.holder === "GlobalThis" &&
23
+ entry.origin === "Host" &&
24
+ !entry.isSymbolName &&
25
+ /^[A-Za-z_$][\w$]*$/.test(entry.name),
26
+ )
27
+ .map((entry) => entry.name),
28
+ ),
29
+ ].sort();
30
+ }
31
+
32
+ /** Browser globals this host provides that the table does not describe as host APIs. */
33
+ const BROWSER_GLOBALS = [
34
+ "Object",
35
+ "console",
36
+ "window",
37
+ "self",
38
+ "document",
39
+ "navigator",
40
+ "location",
41
+ "performance",
42
+ "requestAnimationFrame",
43
+ "cancelAnimationFrame",
44
+ "ResizeObserver",
45
+ "MutationObserver",
46
+ "IntersectionObserver",
47
+ "Image",
48
+ "Audio",
49
+ "AudioContext",
50
+ "OffscreenCanvas",
51
+ "Path2D",
52
+ "ImageData",
53
+ "createImageBitmap",
54
+ "localStorage",
55
+ "sessionStorage",
56
+ "indexedDB",
57
+ "matchMedia",
58
+ "getComputedStyle",
59
+ ];
60
+
61
+ export const TABLE_ID: string = HOST_TABLE.table;
62
+
63
+ export function opaqueGlobals(tableGlobals: readonly string[] = HOST_TABLE.names): string[] {
64
+ return [...new Set([...tableGlobals, ...BROWSER_GLOBALS])].sort();
65
+ }
66
+
67
+ export function opaqueHost(source: string, names: readonly string[] = opaqueGlobals()): string {
68
+ return `// ${TRANSFORM}: stable host API references are opaque inputs.\n(function(__sk_host) {\nconst globalThis = __sk_host;\nconst {${names.join(",")}} = __sk_host;\n${source}\n})(__SK_AOT_HOST__);\n`;
69
+ }
package/check/codes.ts CHANGED
@@ -57,6 +57,25 @@ const CODES: CodeInfo[] = [
57
57
  fix: "Fix the build error (sk build shows the same one), then run sk check again.",
58
58
  fatal: true,
59
59
  },
60
+ {
61
+ code: "SK0005",
62
+ severity: "error",
63
+ title: "an effect shader does not compile",
64
+ explanation:
65
+ "The app's shaders/*.slang are its own `--shading` effects, compiled into the app for every OS by sk build. One of them does not compile, or breaks a rule of the effect schema (an attribute, a parameter type, a name), so sk build refuses the app.",
66
+ example:
67
+ '[SkEffect("ripple")]\nstruct Ripple : IEffect\n{\n int rings; // parameters are float, float2, float3 or float4\n float4 shade(EffectInput input) { return float4(0, 0, 0, 0); }\n};',
68
+ fix: "Fix the shader at the reported line; the rules are in the comments of the `sk` prelude (`import sk;`).",
69
+ },
70
+ {
71
+ code: "SK0006",
72
+ severity: "warning",
73
+ title: "the effect shaders could not be checked",
74
+ explanation:
75
+ "The app has shaders/*.slang, but the shader compiler (redslangc) could not be found or downloaded, so they were not compiled. sk build needs it too.",
76
+ example: "SK_HOST_OFFLINE=1 with no cached redslangc",
77
+ fix: "Allow the download once, or set SK_REDSLANGC to a redslangc binary.",
78
+ },
60
79
  {
61
80
  code: "SK1001",
62
81
  severity: "error",
package/check/command.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { colorEnabled, colorFlag, paint, quietProgress, spinner, type Progress } from "../cli/term";
1
+ import { colorEnabled, colorFlag, interactive, paint, quietProgress, spinner, type Progress } from "../cli/term";
2
2
  import { highlighter, type Highlight } from "./highlight";
3
3
  import { exitCode, explain, formatPretty, listCodes, loadTypeScript, runCheck } from "./index";
4
4
 
@@ -25,7 +25,9 @@ export const defaultIo = (flags: Pick<CheckFlags, "color" | "no-color"> = {}): I
25
25
  err: (text) => process.stderr.write(`${text}\n`),
26
26
  color,
27
27
  progress: () =>
28
- process.stderr.isTTY ? spinner(process.stderr, colorEnabled(process.stderr, colorFlag(flags))) : quietProgress,
28
+ interactive(process.stderr)
29
+ ? spinner(process.stderr, colorEnabled(process.stderr, colorFlag(flags)))
30
+ : quietProgress,
29
31
  };
30
32
  };
31
33
 
@@ -73,7 +75,7 @@ export async function checkCommand(
73
75
  }
74
76
  return exitCode(report, flags["deny-warnings"] === true);
75
77
  } catch (e) {
76
- progress.end();
78
+ progress.fail();
77
79
  fail(e instanceof Error ? e.message : String(e));
78
80
  return 2;
79
81
  }
package/check/index.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { createRequire } from "node:module";
3
- import { join, relative, resolve, sep } from "node:path";
3
+ import { isAbsolute, join, relative, resolve, sep } from "node:path";
4
4
  import { loadAppConfig } from "../cli/config";
5
+ import { appShadersDir, compileAppEffects, EffectsError, hasAppEffects } from "../effects/compile";
6
+ import { resolveCompiler } from "../effects/redslangc";
5
7
  import { quietProgress, type Progress } from "../cli/term";
6
8
  import { Builtins } from "./builtins";
7
9
  import { codeInfo, REGISTRY } from "./codes";
@@ -91,6 +93,7 @@ export async function runCheck(options: CheckOptions): Promise<CheckReport> {
91
93
  const typescript = loadTypeScript(config.appRoot);
92
94
  const base = { typescript, root: config.appRoot, entry: config.entry, toolVersion: options.toolVersion, progress };
93
95
  if (findings.length) return analyze({ ...base, modules: [], findings });
96
+ findings.push(...(await effectFindings(config.appRoot, progress)));
94
97
 
95
98
  progress.step("module graph");
96
99
  let graph: ModuleGraph;
@@ -137,9 +140,49 @@ export async function runCheck(options: CheckOptions): Promise<CheckReport> {
137
140
  declarations: graph.declarations,
138
141
  allow: checkConfig.allow,
139
142
  deps: options.deps ?? true,
143
+ findings,
140
144
  });
141
145
  }
142
146
 
147
+ /** The app's shaders/*.slang, compiled as sk build would: one SK0005 per error, at the author's line. */
148
+ export async function effectFindings(appRoot: string, progress: Progress = quietProgress): Promise<Finding[]> {
149
+ if (!hasAppEffects(appRoot)) return [];
150
+ const dir = appShadersDir(appRoot);
151
+ progress.step("effect shaders");
152
+ let compiler: string;
153
+ try {
154
+ compiler = (
155
+ await resolveCompiler({
156
+ log: (line) => progress.info(line),
157
+ onBytes: (done, total) => progress.bytes(done, total),
158
+ })
159
+ ).path;
160
+ } catch (e) {
161
+ const message = `the effect shaders were not compiled: ${e instanceof Error ? e.message : String(e)}`;
162
+ return [{ code: "SK0006", message, file: dir, range: ZERO_RANGE, related: [] }];
163
+ }
164
+ try {
165
+ await compileAppEffects(appRoot, compiler);
166
+ return [];
167
+ } catch (e) {
168
+ if (!(e instanceof EffectsError)) throw e;
169
+ return e.problems
170
+ .filter((p) => p.severity === "error")
171
+ .map((p): Finding => {
172
+ const own = isAbsolute(p.file);
173
+ const line = own ? Math.max(0, p.line - 1) : 0;
174
+ const character = own ? Math.max(0, p.column - 1) : 0;
175
+ return {
176
+ code: "SK0005",
177
+ message: own ? p.message : `${p.file}${p.line ? `:${p.line}` : ""}: ${p.message}`,
178
+ file: own ? p.file : dir,
179
+ range: { start: { line, character }, end: { line, character } },
180
+ related: [],
181
+ };
182
+ });
183
+ }
184
+ }
185
+
143
186
  export function analyze(input: AnalyzeInput): CheckReport {
144
187
  const { typescript } = input;
145
188
  const progress = input.progress ?? quietProgress;