@gasm-compiler/core 0.4.0 → 0.5.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 +38 -0
- package/dist/browser.d.ts +27 -3
- package/dist/browser.js +8 -8
- package/dist/chunk-MBWDLAL5.js +5 -0
- package/dist/chunk-TICBJF7F.js +9 -0
- package/dist/compiler.js +1 -1
- package/dist/{error_codes-Cdy_3FNo.d.ts → error_codes-5zCZDwFZ.d.ts} +108 -2
- package/dist/gasm_core_rs.wasm +0 -0
- package/dist/mod.d.ts +16 -78
- package/dist/mod.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-NQJKL2KQ.js +0 -9
- package/dist/chunk-R6SXLNEJ.js +0 -5
package/README.md
CHANGED
|
@@ -113,6 +113,44 @@ Required extensions are declared by the module's `gasm.extensions` custom
|
|
|
113
113
|
section. The CLI does not inject extensions, so validation reflects the exact
|
|
114
114
|
module that will be distributed.
|
|
115
115
|
|
|
116
|
+
### Integrator Workflow
|
|
117
|
+
|
|
118
|
+
Playgrounds, compiler backends, and other embedders can prepare transient Wasm
|
|
119
|
+
without modifying their producer toolchain:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import {
|
|
123
|
+
compileWithRuntimeInfo,
|
|
124
|
+
prepareModule,
|
|
125
|
+
} from "@gasm-compiler/core/browser";
|
|
126
|
+
|
|
127
|
+
const prepared = prepareModule(wasmBytes, {
|
|
128
|
+
demotionPolicy: { f64: "allow", i64: "allow-lossy" },
|
|
129
|
+
});
|
|
130
|
+
if (prepared.errors.length > 0) {
|
|
131
|
+
throw new Error(prepared.errors[0].message);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const result = compileWithRuntimeInfo(prepared.wasmBytes, {
|
|
135
|
+
...prepared.compileOptions,
|
|
136
|
+
mode: "strict",
|
|
137
|
+
});
|
|
138
|
+
if (!result.ok) throw new Error(result.diagnostics.errors[0].message);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`prepareModule()` defaults to integrator mode. It infers required extensions,
|
|
142
|
+
merges a stable `gasm.extensions` section, and returns binding and mutable-global
|
|
143
|
+
initialization data. Modules with undeclared mutable defined globals use the
|
|
144
|
+
v0.1 private-global compatibility path to avoid shared-storage races.
|
|
145
|
+
|
|
146
|
+
Use `{ mode: "strict" }` to analyze a distribution artifact without changing
|
|
147
|
+
its bytes. Strict compilation through `compile()` and
|
|
148
|
+
`compileWithDiagnostics()` remains unchanged and never injects extensions.
|
|
149
|
+
|
|
150
|
+
`compileWithRuntimeInfo()` is also available from the main and browser entry
|
|
151
|
+
points. It combines preparation, compilation, binding metadata, dispatch
|
|
152
|
+
information, and mutable-global initialization into one result.
|
|
153
|
+
|
|
116
154
|
### Basic Compilation
|
|
117
155
|
|
|
118
156
|
```typescript
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { C as CompileDiagnostics, D as DispatchInfo$1, G as GasmMetadata, a as GasmBinding, P as PreparedModule, b as CompileOptions, c as PrepareModuleOptions } from './error_codes-5zCZDwFZ.js';
|
|
2
|
+
export { d as CompileError, h as DEFAULT_SPEC_VERSION, e as DemotionPolicy, f as Diagnostic, g as DiagnosticRecovery, o as ErrorCode, E as ErrorCodes, u as GasmMetadataEntryPoint, M as MutableGlobalsInit, x as PrepareMode, j as SPEC_VERSION_V01, k as SPEC_VERSION_V02, S as SpecVersion, w as buildBindingTable, s as buildGasmMetadata, l as isCompileError, n as isParseError, i as isV02Mode, m as parseWasmModule, p as prepareModule, r as resolveSpecVersion, v as validateGasmMetadataSchema } from './error_codes-5zCZDwFZ.js';
|
|
3
3
|
export { BrowserGPUExecutor } from './browser-executor.js';
|
|
4
4
|
export { BufferData, ExecuteOptions, ExecutionError, ExecutorConfig, IGPUExecutor, OutputBufferSpec, isExecutionError } from './executor.js';
|
|
5
5
|
|
|
@@ -67,6 +67,28 @@ type CompileWithDiagnosticsResult = {
|
|
|
67
67
|
ok: false;
|
|
68
68
|
diagnostics: CompileDiagnostics;
|
|
69
69
|
};
|
|
70
|
+
type CompileArtifactResult = {
|
|
71
|
+
ok: true;
|
|
72
|
+
wgsl: string;
|
|
73
|
+
metadata: GasmMetadata;
|
|
74
|
+
diagnostics: CompileDiagnostics;
|
|
75
|
+
dispatchInfo: DispatchInfo;
|
|
76
|
+
} | {
|
|
77
|
+
ok: false;
|
|
78
|
+
diagnostics: CompileDiagnostics;
|
|
79
|
+
};
|
|
80
|
+
type CompileWithRuntimeInfoResult = {
|
|
81
|
+
ok: true;
|
|
82
|
+
wgsl: string;
|
|
83
|
+
diagnostics: CompileDiagnostics;
|
|
84
|
+
dispatchInfo: DispatchInfo;
|
|
85
|
+
bindings: GasmBinding[];
|
|
86
|
+
metadata: GasmMetadata;
|
|
87
|
+
mutableGlobalsInit?: PreparedModule["mutableGlobalsInit"];
|
|
88
|
+
} | {
|
|
89
|
+
ok: false;
|
|
90
|
+
diagnostics: CompileDiagnostics;
|
|
91
|
+
};
|
|
70
92
|
interface BackendMismatchDetails {
|
|
71
93
|
kind: "wgsl" | "ok_mismatch" | "rust_error" | "diagnostics";
|
|
72
94
|
message: string;
|
|
@@ -88,6 +110,8 @@ interface BackendComparisonResult {
|
|
|
88
110
|
}
|
|
89
111
|
|
|
90
112
|
declare function compileWithDiagnostics(wasmBytes: Uint8Array, options?: CompileOptions): CompileWithDiagnosticsResult;
|
|
113
|
+
declare function compileToArtifact(wasmBytes: Uint8Array, options?: CompileOptions): CompileArtifactResult;
|
|
114
|
+
declare function compileWithRuntimeInfo(wasmBytes: Uint8Array, options?: PrepareModuleOptions): CompileWithRuntimeInfoResult;
|
|
91
115
|
declare function compileWithDiagnosticsAsync(wasmBytes: Uint8Array, options?: CompileOptions, initOptions?: InitRustCompilerOptions): Promise<CompileWithDiagnosticsResult>;
|
|
92
116
|
declare function compileWithBackendComparison(wasmBytes: Uint8Array, options?: CompileOptions, compareOptions?: {
|
|
93
117
|
funcName?: string;
|
|
@@ -98,4 +122,4 @@ declare function compileWithBackendComparisonAsync(wasmBytes: Uint8Array, option
|
|
|
98
122
|
declare function compile(wasmBytes: Uint8Array, options?: CompileOptions): string;
|
|
99
123
|
declare function compileAsync(wasmBytes: Uint8Array, options?: CompileOptions, initOptions?: InitRustCompilerOptions): Promise<string>;
|
|
100
124
|
|
|
101
|
-
export { type BackendComparisonResult, type BackendMismatchDetails, type BrowserCompilerBackend, CompileDiagnostics, CompileOptions, type CompileWithDiagnosticsResult, type DispatchInfo, type InitRustCompilerOptions, type WgslComparisonSummary, type WgslDiffOptions, compile, compileAsync, compileWithBackendComparison, compileWithBackendComparisonAsync, compileWithDiagnostics, compileWithDiagnosticsAsync, disassembleToWAT, exportWgslFunctionSnippet, formatUnifiedDiff, getBrowserCompilerBackend, initRustCompiler, isRustCompilerInitialized, normalizeWgslForComparison, preloadCompiler, setBrowserCompilerBackend, summarizeWgslComparison, waitForRustCompilerInit };
|
|
125
|
+
export { type BackendComparisonResult, type BackendMismatchDetails, type BrowserCompilerBackend, type CompileArtifactResult, CompileDiagnostics, CompileOptions, type CompileWithDiagnosticsResult, type CompileWithRuntimeInfoResult, type DispatchInfo, GasmBinding, GasmMetadata, type InitRustCompilerOptions, PrepareModuleOptions, PreparedModule, type WgslComparisonSummary, type WgslDiffOptions, compile, compileAsync, compileToArtifact, compileWithBackendComparison, compileWithBackendComparisonAsync, compileWithDiagnostics, compileWithDiagnosticsAsync, compileWithRuntimeInfo, disassembleToWAT, exportWgslFunctionSnippet, formatUnifiedDiff, getBrowserCompilerBackend, initRustCompiler, isRustCompilerInitialized, normalizeWgslForComparison, preloadCompiler, setBrowserCompilerBackend, summarizeWgslComparison, waitForRustCompilerInit };
|