@gasm-compiler/core 0.3.1 → 0.4.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/LICENSE +17 -0
- package/README.md +69 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +7 -7
- package/dist/chunk-NQJKL2KQ.js +9 -0
- package/dist/chunk-R6SXLNEJ.js +5 -0
- package/dist/compiler.js +1 -1
- package/dist/{error_codes-D6RsiZ33.d.ts → error_codes-Cdy_3FNo.d.ts} +27 -13
- package/dist/gasm_core_rs.wasm +0 -0
- package/dist/mod.d.ts +89 -3
- package/dist/mod.js +1 -1
- package/package.json +11 -12
- package/dist/chunk-PS4NV6ZB.js +0 -5
- package/dist/chunk-VSCQDCQR.js +0 -9
|
@@ -24,6 +24,7 @@ interface ImportedGlobal {
|
|
|
24
24
|
module: string;
|
|
25
25
|
name: string;
|
|
26
26
|
type: ValueType;
|
|
27
|
+
mutable: boolean;
|
|
27
28
|
}
|
|
28
29
|
interface DefinedGlobal {
|
|
29
30
|
kind: "definition";
|
|
@@ -40,10 +41,16 @@ interface WasmMemory {
|
|
|
40
41
|
max?: number;
|
|
41
42
|
}
|
|
42
43
|
interface WasmDataSegment {
|
|
44
|
+
mode: "active" | "passive";
|
|
43
45
|
memoryIndex: number;
|
|
44
46
|
offset: Instruction[];
|
|
45
47
|
data: Uint8Array;
|
|
46
48
|
}
|
|
49
|
+
interface AtomicRegionDescriptor {
|
|
50
|
+
memoryIndex: number;
|
|
51
|
+
offset: number;
|
|
52
|
+
length: number;
|
|
53
|
+
}
|
|
47
54
|
interface WasmExport {
|
|
48
55
|
name: string;
|
|
49
56
|
kind: "func" | "table" | "mem" | "global";
|
|
@@ -54,6 +61,10 @@ interface WasmImport {
|
|
|
54
61
|
name: string;
|
|
55
62
|
kind: "func" | "table" | "mem" | "global";
|
|
56
63
|
typeIndex?: number;
|
|
64
|
+
memoryMin?: number;
|
|
65
|
+
memoryMax?: number;
|
|
66
|
+
globalType?: ValueType;
|
|
67
|
+
globalMutable?: boolean;
|
|
57
68
|
}
|
|
58
69
|
interface WasmType {
|
|
59
70
|
params: ValueType[];
|
|
@@ -70,6 +81,11 @@ interface WasmModule {
|
|
|
70
81
|
startFunctionIndex?: number;
|
|
71
82
|
/** Custom sections from the WebAssembly module (for graphics extension metadata) */
|
|
72
83
|
customSections?: CustomSection[];
|
|
84
|
+
extensions?: string[];
|
|
85
|
+
workgroupSizes?: Map<number, [number, number, number]>;
|
|
86
|
+
atomicRegion?: AtomicRegionDescriptor;
|
|
87
|
+
hasTableSection?: boolean;
|
|
88
|
+
hasElementSection?: boolean;
|
|
73
89
|
}
|
|
74
90
|
interface CompileError extends Error {
|
|
75
91
|
functionName?: string;
|
|
@@ -218,10 +234,12 @@ declare function extractDebugInfo(wasmBytes: Uint8Array): DebugInfo;
|
|
|
218
234
|
* WGSL mappings, vector dimensions, and validation specs.
|
|
219
235
|
*
|
|
220
236
|
* Functions are imported from the "gasm" module with names like:
|
|
221
|
-
* - "
|
|
237
|
+
* - "sin_f32" (scalar f32 -> f32)
|
|
222
238
|
* - "sin_v2f32" (vector vec2<f32> -> vec2<f32>)
|
|
223
239
|
* - "sin_v3f32" (vector vec3<f32> -> vec3<f32>)
|
|
224
|
-
* - "sin_v4f32" (vector vec4<f32> -> vec4<f32
|
|
240
|
+
* - "sin_v4f32" (vector vec4<f32> -> vec4<f32>)
|
|
241
|
+
*
|
|
242
|
+
* Unsuffixed scalar names remain accepted as legacy aliases.
|
|
225
243
|
*/
|
|
226
244
|
|
|
227
245
|
/**
|
|
@@ -306,14 +324,13 @@ interface DemotionPolicy {
|
|
|
306
324
|
/**
|
|
307
325
|
* Supported Gasm specification versions.
|
|
308
326
|
*
|
|
309
|
-
* - "0.1":
|
|
310
|
-
* - "0.2":
|
|
311
|
-
* conformance suite is complete, v0.2 mode is opt-in and existing
|
|
312
|
-
* compile() defaults preserve v0.1 behavior.
|
|
327
|
+
* - "0.1": Compatibility mode for the archived TypeScript-era behavior.
|
|
328
|
+
* - "0.2": Default Rust/Wasm compiler behavior. See spec/gasm-v0.2.md.
|
|
313
329
|
*/
|
|
314
330
|
type SpecVersion = "0.1" | "0.2";
|
|
315
331
|
declare const SPEC_VERSION_V01: SpecVersion;
|
|
316
332
|
declare const SPEC_VERSION_V02: SpecVersion;
|
|
333
|
+
declare const DEFAULT_SPEC_VERSION: SpecVersion;
|
|
317
334
|
declare function resolveSpecVersion(options?: CompileOptions): SpecVersion;
|
|
318
335
|
declare function isV02Mode(options?: CompileOptions): boolean;
|
|
319
336
|
interface CompileOptions {
|
|
@@ -377,13 +394,10 @@ interface CompileOptions {
|
|
|
377
394
|
/**
|
|
378
395
|
* Target Gasm specification version.
|
|
379
396
|
*
|
|
380
|
-
* - "0.1"
|
|
381
|
-
* - "0.2":
|
|
382
|
-
* conformance suite is complete, this mode is intentionally opt-in.
|
|
397
|
+
* - "0.1": Explicit compatibility mode for existing v0.1 callers.
|
|
398
|
+
* - "0.2" (default): Strict v0.2 validation and Rust/Wasm lowering.
|
|
383
399
|
*
|
|
384
|
-
* Setting this to "0.
|
|
385
|
-
* additional v0.2-only rules added in subsequent PRs. The default WGSL
|
|
386
|
-
* header is NOT changed by this flag in PR-0.
|
|
400
|
+
* Setting this to "0.1" preserves the compatibility escape hatch.
|
|
387
401
|
*/
|
|
388
402
|
specVersion?: SpecVersion;
|
|
389
403
|
}
|
|
@@ -464,4 +478,4 @@ declare const ErrorCodes: {
|
|
|
464
478
|
};
|
|
465
479
|
type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
466
480
|
|
|
467
|
-
export { type
|
|
481
|
+
export { type CompileOptions as C, type DispatchInfo as D, ErrorCodes as E, type MathIntrinsicSpec as M, type SpecVersion as S, type VectorDimension as V, type WasmModule as W, type CompileDiagnostics as a, type CompileError as b, DEFAULT_SPEC_VERSION as c, SPEC_VERSION_V01 as d, SPEC_VERSION_V02 as e, isCompileError$1 as f, compile as g, isCompileError as h, isV02Mode as i, type ErrorCode as j, type MathLevel as k, getIntrinsicsAtLevel as l, getMathSpec as m, getVectorDimension as n, getWgslMapping as o, isMathIntrinsic as p, MATH_INTRINSICS as q, resolveSpecVersion as r, type DebugInfo as s, type SourceLanguage as t, type SourceMappingLevel as u, detectSourceLanguage as v, extractDebugInfo as w, parseNamesSection as x, parseProducersSection as y };
|
package/dist/gasm_core_rs.wasm
CHANGED
|
Binary file
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,10 +1,85 @@
|
|
|
1
|
-
import { W as WasmModule, C as
|
|
2
|
-
export { b as CompileError,
|
|
1
|
+
import { W as WasmModule, C as CompileOptions, D as DispatchInfo, a as CompileDiagnostics } from './error_codes-Cdy_3FNo.js';
|
|
2
|
+
export { b as CompileError, c as DEFAULT_SPEC_VERSION, s as DebugInfo, j as ErrorCode, E as ErrorCodes, q as MATH_INTRINSICS, M as MathIntrinsicSpec, k as MathLevel, d as SPEC_VERSION_V01, e as SPEC_VERSION_V02, t as SourceLanguage, u as SourceMappingLevel, S as SpecVersion, V as VectorDimension, v as detectSourceLanguage, w as extractDebugInfo, l as getIntrinsicsAtLevel, m as getMathSpec, n as getVectorDimension, o as getWgslMapping, f as isCompileError, p as isMathIntrinsic, h as isParseError, i as isV02Mode, x as parseNamesSection, y as parseProducersSection, g as parseWasmModule, r as resolveSpecVersion } from './error_codes-Cdy_3FNo.js';
|
|
3
3
|
import { IGPUExecutor, ExecutorConfig, BufferData, ExecuteOptions } from './executor.js';
|
|
4
4
|
export { ExecutionError, OutputBufferSpec, isExecutionError } from './executor.js';
|
|
5
5
|
export { BrowserGPUExecutor } from './browser-executor.js';
|
|
6
6
|
export { CompileOptions as NodeCompilerOptions, compileAssemblyScriptToWGSL, compileWasmToWGSL } from './compiler.js';
|
|
7
7
|
|
|
8
|
+
type GasmBindingRole = "memory" | "atomic_region" | "imported_global" | "mutable_globals" | "workgroup_memory" | "extension_resource";
|
|
9
|
+
interface GasmBinding {
|
|
10
|
+
group: number;
|
|
11
|
+
binding: number;
|
|
12
|
+
kind: "storage" | "uniform" | "texture" | "sampler";
|
|
13
|
+
rw?: "read" | "read_write" | "write";
|
|
14
|
+
role: GasmBindingRole;
|
|
15
|
+
wasmName?: string;
|
|
16
|
+
wgslName?: string;
|
|
17
|
+
type?: "i32" | "i64" | "f32" | "f64" | "u32" | "vec4<u32>" | "external";
|
|
18
|
+
atomic?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare function buildBindingTable(module: WasmModule): GasmBinding[];
|
|
21
|
+
|
|
22
|
+
interface GasmMetadata {
|
|
23
|
+
specVersion: "0.2";
|
|
24
|
+
extensions: string[];
|
|
25
|
+
memory: {
|
|
26
|
+
sizeBytes: number;
|
|
27
|
+
atomicRegion?: {
|
|
28
|
+
offset: number;
|
|
29
|
+
length: number;
|
|
30
|
+
binding: {
|
|
31
|
+
group: number;
|
|
32
|
+
binding: number;
|
|
33
|
+
};
|
|
34
|
+
} | null;
|
|
35
|
+
workgroupMemoryBytes?: number;
|
|
36
|
+
};
|
|
37
|
+
entryPoints: GasmMetadataEntryPoint[];
|
|
38
|
+
bindings: GasmBinding[];
|
|
39
|
+
dataSegments: GasmMetadataDataSegment[];
|
|
40
|
+
atomicDataSegments?: GasmMetadataDataSegment[];
|
|
41
|
+
passiveDataSegments?: GasmMetadataPassiveDataSegment[];
|
|
42
|
+
mutableGlobals?: Array<{
|
|
43
|
+
index: number;
|
|
44
|
+
name?: string;
|
|
45
|
+
type: "i32" | "i64" | "f32" | "f64";
|
|
46
|
+
offset: number;
|
|
47
|
+
byteLength: number;
|
|
48
|
+
initialValue?: string;
|
|
49
|
+
}>;
|
|
50
|
+
extras?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
interface GasmMetadataEntryPoint {
|
|
53
|
+
name: string;
|
|
54
|
+
wgslName: string;
|
|
55
|
+
workgroupSize: [number, number, number];
|
|
56
|
+
}
|
|
57
|
+
interface GasmMetadataDataSegment {
|
|
58
|
+
memory: number;
|
|
59
|
+
offset: number;
|
|
60
|
+
byteLength: number;
|
|
61
|
+
dataB64: string;
|
|
62
|
+
}
|
|
63
|
+
interface GasmMetadataPassiveDataSegment {
|
|
64
|
+
index: number;
|
|
65
|
+
byteLength: number;
|
|
66
|
+
dataB64: string;
|
|
67
|
+
dropped: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface MetadataBuildContext {
|
|
70
|
+
options?: CompileOptions;
|
|
71
|
+
dispatchInfo?: DispatchInfo;
|
|
72
|
+
}
|
|
73
|
+
declare function buildGasmMetadata(module: WasmModule, context?: MetadataBuildContext): GasmMetadata;
|
|
74
|
+
declare function validateGasmMetadataSchema(metadata: unknown): {
|
|
75
|
+
valid: true;
|
|
76
|
+
} | {
|
|
77
|
+
valid: false;
|
|
78
|
+
errors: string[];
|
|
79
|
+
};
|
|
80
|
+
declare function assertCustomSectionsAndMetadataAgree(module: WasmModule, metadata: GasmMetadata): void;
|
|
81
|
+
declare function entryWrapperName(exportName: string): string;
|
|
82
|
+
|
|
8
83
|
/**
|
|
9
84
|
* WAT Disassembler
|
|
10
85
|
*
|
|
@@ -85,10 +160,21 @@ type CompileWithDiagnosticsResult = {
|
|
|
85
160
|
ok: false;
|
|
86
161
|
diagnostics: CompileDiagnostics;
|
|
87
162
|
};
|
|
163
|
+
type CompileArtifactResult = {
|
|
164
|
+
ok: true;
|
|
165
|
+
wgsl: string;
|
|
166
|
+
metadata: GasmMetadata;
|
|
167
|
+
diagnostics: CompileDiagnostics;
|
|
168
|
+
dispatchInfo: DispatchInfo;
|
|
169
|
+
} | {
|
|
170
|
+
ok: false;
|
|
171
|
+
diagnostics: CompileDiagnostics;
|
|
172
|
+
};
|
|
88
173
|
declare function compileWithDiagnostics(wasmBytes: Uint8Array, options?: CompileOptions): CompileWithDiagnosticsResult;
|
|
174
|
+
declare function compileToArtifact(wasmBytes: Uint8Array, options?: CompileOptions): CompileArtifactResult;
|
|
89
175
|
declare function preloadCompiler(): Promise<void>;
|
|
90
176
|
declare function compileWithDiagnosticsAsync(wasmBytes: Uint8Array, options?: CompileOptions): Promise<CompileWithDiagnosticsResult>;
|
|
91
177
|
declare function compile(wasmBytes: Uint8Array, options?: CompileOptions): string;
|
|
92
178
|
declare function compileAsync(wasmBytes: Uint8Array, options?: CompileOptions): Promise<string>;
|
|
93
179
|
|
|
94
|
-
export { BufferData, CompileDiagnostics, CompileOptions, type CompileWithDiagnosticsResult, DenoGPUExecutor, DispatchInfo, ExecuteOptions, ExecutorConfig, IGPUExecutor, compile, compileAsync, compileWithDiagnostics, compileWithDiagnosticsAsync, disassembleToWAT, preloadCompiler };
|
|
180
|
+
export { BufferData, type CompileArtifactResult, CompileDiagnostics, CompileOptions, type CompileWithDiagnosticsResult, DenoGPUExecutor, DispatchInfo, ExecuteOptions, ExecutorConfig, type GasmBinding, type GasmMetadata, type GasmMetadataEntryPoint, IGPUExecutor, assertCustomSectionsAndMetadataAgree, buildBindingTable, buildGasmMetadata, compile, compileAsync, compileToArtifact, compileWithDiagnostics, compileWithDiagnosticsAsync, disassembleToWAT, entryWrapperName, preloadCompiler, validateGasmMetadataSchema };
|
package/dist/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as t,b as u,c as v,d as w,e as x,f as y,g as C,h as D,i as E,j as F,k as G,l as H,m as I,n as J,o as K}from"./chunk-NQJKL2KQ.js";import{D as o,E as p,F as q,G as r,H as s,b as a,d as b,e as c,f as d,i as e,j as f,k as g,l as h,m as i,o as j,u as k,v as l,w as m,x as n}from"./chunk-R6SXLNEJ.js";import{a as B}from"./chunk-IZGS3OS2.js";import{a as z,b as A}from"./chunk-STDXBN5E.js";export{B as BrowserGPUExecutor,q as DEFAULT_SPEC_VERSION,C as DenoGPUExecutor,b as ErrorCodes,z as ExecutionError,e as MATH_INTRINSICS,o as SPEC_VERSION_V01,p as SPEC_VERSION_V02,w as assertCustomSectionsAndMetadataAgree,t as buildBindingTable,u as buildGasmMetadata,J as compile,D as compileAssemblyScriptToWGSL,K as compileAsync,G as compileToArtifact,E as compileWasmToWGSL,F as compileWithDiagnostics,I as compileWithDiagnosticsAsync,m as detectSourceLanguage,y as disassembleToWAT,x as entryWrapperName,n as extractDebugInfo,j as getIntrinsicsAtLevel,g as getMathSpec,i as getVectorDimension,h as getWgslMapping,a as isCompileError,A as isExecutionError,f as isMathIntrinsic,d as isParseError,s as isV02Mode,k as parseNamesSection,l as parseProducersSection,c as parseWasmModule,H as preloadCompiler,r as resolveSpecVersion,v as validateGasmMetadataSchema};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasm-compiler/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Gasm Compiler — compile WebAssembly to WGSL (WebGPU Shading Language)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/mod.js",
|
|
@@ -43,16 +43,6 @@
|
|
|
43
43
|
"LICENSE",
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "pnpm --dir ../.. core-rs:build:wasm:release && deno run --allow-read --allow-write ../../scripts/generate_core_rs_wasm_embed.ts --release && tsup && deno run --allow-read --allow-write ../../scripts/fix_node_builtin_imports.ts && deno run --allow-read --allow-write --allow-run --allow-env ../../scripts/copy_core_rs_wasm.ts --release",
|
|
48
|
-
"test": "pnpm --dir ../.. core-rs:build:wasm && GASM_CORE_BACKEND=rust deno test --allow-all",
|
|
49
|
-
"test:e2e": "deno test --allow-all --unstable-webgpu --no-check tests/e2e_execution_test.ts",
|
|
50
|
-
"test:e2e:gpu": "ENABLE_GPU_TESTS=1 deno test --allow-all --unstable-webgpu --no-check tests/e2e_execution_test.ts",
|
|
51
|
-
"lint": "biome lint .",
|
|
52
|
-
"prepublishOnly": "pnpm run build",
|
|
53
|
-
"size": "pnpm --dir ../.. core-rs:size",
|
|
54
|
-
"pack:smoke": "pnpm --dir ../.. core-rs:pack-smoke"
|
|
55
|
-
},
|
|
56
46
|
"license": "SEE LICENSE IN LICENSE",
|
|
57
47
|
"publishConfig": {
|
|
58
48
|
"access": "public"
|
|
@@ -75,5 +65,14 @@
|
|
|
75
65
|
"devDependencies": {
|
|
76
66
|
"tsup": "^8.5.1",
|
|
77
67
|
"typescript": "^5.9.3"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "pnpm --dir ../.. core-rs:build:wasm:release && deno run --allow-read --allow-write ../../scripts/generate_core_rs_wasm_embed.ts --release && tsup && deno run --allow-read --allow-write ../../scripts/fix_node_builtin_imports.ts && deno run --allow-read --allow-write --allow-run --allow-env ../../scripts/copy_core_rs_wasm.ts --release",
|
|
71
|
+
"test": "pnpm --dir ../.. core-rs:build:wasm && GASM_CORE_BACKEND=rust deno test --allow-all",
|
|
72
|
+
"test:e2e": "deno test --allow-all --unstable-webgpu --no-check tests/e2e_execution_test.ts",
|
|
73
|
+
"test:e2e:gpu": "ENABLE_GPU_TESTS=1 deno test --allow-all --unstable-webgpu --no-check tests/e2e_execution_test.ts",
|
|
74
|
+
"lint": "biome lint .",
|
|
75
|
+
"size": "pnpm --dir ../.. core-rs:size",
|
|
76
|
+
"pack:smoke": "pnpm --dir ../.. core-rs:pack-smoke"
|
|
78
77
|
}
|
|
79
|
-
}
|
|
78
|
+
}
|