@pulse-compute/wasm-compiler 1.0.0-beta.4 → 1.0.0-beta.6
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 +14 -3
- package/bin/provider-proof-composition.js +29 -31
- package/bin/pulsewasm-extract.js +1 -1
- package/package.json +9 -11
- package/src/canonical-api-compiler.js +1 -9
- package/src/canonical-native-compiler.js +40 -62
- package/src/canonical-native-plan.js +513 -81
- package/src/canonical-project-compiler.js +52 -12
- package/src/execution-plan.js +1 -0
- package/src/extractor.js +36 -0
- package/src/javascript-application-plan.js +4 -1
- package/src/native-result-facts.js +50 -0
- package/src/project/router-module-linker.js +64 -0
- package/src/project-target-support.js +10 -2
- package/src/provider-toolchain.js +29 -5
- package/src/pure-helper-values.js +138 -0
- package/src/shared-stage-plan.js +239 -0
- package/src/source-helper-plan.js +482 -0
- package/src/spine/async-surface-normalizer.js +17 -1
- package/src/spine/bounded-pure-loop.js +210 -0
- package/src/spine/canonical-handler-ir.js +3 -1
- package/src/spine/guest-unit-stage.js +11 -2
- package/src/spine/handler-ir-emitter.js +20 -0
- package/src/spine/handler-ir.js +129 -26
- package/src/spine/handler-surface-authority.js +13 -0
- package/src/spine/incoming-body-source.js +48 -0
- package/src/spine/plain-handler-frontend.js +17 -4
- package/src/spine/pure-helper-source.js +123 -0
- package/src/spine/router-handler-frontend.js +39 -2
- package/src/spine/router-handler-ir.js +71 -3
- package/src/spine/router-topology-frontend.js +3 -1
- package/src/spine/terminal-package-native.js +37 -0
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
> **Stability:** Internal compiler interface; no application-author compatibility guarantee.<br>
|
|
9
9
|
> **npm:** [`@pulse-compute/wasm-compiler`](https://www.npmjs.com/package/@pulse-compute/wasm-compiler)<br>
|
|
10
10
|
> **Canonical replacement:** `@pulse-compute/cli`<br>
|
|
11
|
-
> **Canonical documentation:** [Package guide](https://pulsecompute.io/v1.0.0-beta.
|
|
11
|
+
> **Canonical documentation:** [Package guide](https://pulsecompute.io/v1.0.0-beta.6/packages/implementation-packages/)
|
|
12
12
|
>
|
|
13
|
-
> This release-status block is generated from the synchronized `Pulse 1.0.0-beta.
|
|
13
|
+
> This release-status block is generated from the synchronized `Pulse 1.0.0-beta.6` package policy.
|
|
14
14
|
<!-- pulse-package-status:end -->
|
|
15
15
|
|
|
16
16
|
Whole-project compiler implementation used by the `pulse` workflow. Application projects should use `@pulse-compute/cli`, not import this package directly.
|
|
@@ -38,6 +38,17 @@ The compiler orchestrates contracts but does not own:
|
|
|
38
38
|
|
|
39
39
|
Package-specific lowering belongs to the package owning the facade. Provider realization belongs to provider packages. Shared protocol vocabulary belongs to `@pulse-compute/wasm-contracts`.
|
|
40
40
|
|
|
41
|
+
Provider packages are not production dependencies of this compiler. Direct
|
|
42
|
+
compiler consumers supply the selected provider in their project context; the
|
|
43
|
+
product CLI owns its bundled Node/Fastly dependencies. Provider-neutral imports,
|
|
44
|
+
compilation and legacy executable help do not load providers. Legacy proof
|
|
45
|
+
commands load only their selected provider when invoked. Repository proof
|
|
46
|
+
scripts retain provider development dependencies.
|
|
47
|
+
|
|
48
|
+
The canonical API, Native-plan and Native-compiler facades use declared package
|
|
49
|
+
imports and surface missing or unexported dependencies without checkout-relative
|
|
50
|
+
recovery. Other historical loaders are outside this migration.
|
|
51
|
+
|
|
41
52
|
## Internal compiler spine
|
|
42
53
|
|
|
43
54
|
The compiler connects root extraction, surface recognition, normalization, classification, validation, canonical IR, native lowering, provider realization, and artifact verification through a fixed package-internal pipeline. The pipeline is not exported and is not a plugin framework. Compiler refactors must preserve checked-in metadata, diagnostics, native-plan, and generated-Wasm evidence unless an explicit contract migration authorizes a difference.
|
|
@@ -52,4 +63,4 @@ The package exports its root implementation plus focused compiler, CLI, extracto
|
|
|
52
63
|
|
|
53
64
|
Compiler changes should be covered by focused static/lowering tests, canonical project inspection, provider-plan parity, packed-package discovery where relevant, and the release documentation gates.
|
|
54
65
|
|
|
55
|
-
See the installed [implementation package guide](https://pulsecompute.io/v1.0.0-beta.
|
|
66
|
+
See the installed [implementation package guide](https://pulsecompute.io/v1.0.0-beta.6/packages/implementation-packages/) and [compilation concepts](https://pulsecompute.io/v1.0.0-beta.6/concepts/compilation-and-lowering/).
|
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
6
|
-
buildNodeLiveOriginRouteHandlerEffectProof
|
|
7
|
-
} = require('@pulse-compute/provider-node/compiler/route-handler-live-origin-proof');
|
|
8
|
-
const {
|
|
9
|
-
buildNodeCompiledRouteHandlerEffectBridge
|
|
10
|
-
} = require('@pulse-compute/provider-node/compiler/route-handler-compiled-wasm-bridge');
|
|
11
|
-
const {
|
|
12
|
-
buildNodeBackendJsonRequestBodyProof
|
|
13
|
-
} = require('@pulse-compute/provider-node/compiler/backend-json-request-body-proof');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const { createRequire } = require('node:module');
|
|
14
5
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
// Compatibility proof commands are optional and never loaded by plain compile,
|
|
7
|
+
// help or version. The caller supplies its project/CLI composition root.
|
|
8
|
+
function createProviderProofs(root = process.cwd()) {
|
|
9
|
+
const load = createRequire(path.join(path.resolve(root), 'package.json'));
|
|
10
|
+
return Object.freeze({
|
|
11
|
+
buildNodeAdapter: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeAdapter(...args),
|
|
12
|
+
buildNodeAssetsProviderProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeAssetsProviderProof(...args),
|
|
13
|
+
buildNodeCompiledWasmAssetsLifecycleProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeCompiledWasmAssetsLifecycleProof(...args),
|
|
14
|
+
buildNodeRouteHandlerEffectProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeRouteHandlerEffectProof(...args),
|
|
15
|
+
buildNodeRequestJsonBodyProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeRequestJsonBodyProof(...args),
|
|
16
|
+
buildNodeSchemaDecodeResultProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeSchemaDecodeResultProof(...args),
|
|
17
|
+
buildNodeSchemaResponseCodecProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeSchemaResponseCodecProof(...args),
|
|
18
|
+
buildFastlyReadiness: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyReadiness(...args),
|
|
19
|
+
buildFastlyHostcallBinding: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyHostcallBinding(...args),
|
|
20
|
+
buildFastlyStreamHeaderAdapter: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyStreamHeaderAdapter(...args),
|
|
21
|
+
buildFastlyCommandEntry: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyCommandEntry(...args),
|
|
22
|
+
buildFastlyAssetsProviderProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyAssetsProviderProof(...args),
|
|
23
|
+
buildFastlyAssetsPackageOutParityProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyAssetsPackageOutParityProof(...args),
|
|
24
|
+
buildFastlyRouteHandlerEffectProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyRouteHandlerEffectProof(...args),
|
|
25
|
+
buildFastlyLifecycleParityProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyLifecycleParityProof(...args),
|
|
26
|
+
buildNodeLiveOriginRouteHandlerEffectProof: (...args) => load('@pulse-compute/provider-node/compiler/route-handler-live-origin-proof').buildNodeLiveOriginRouteHandlerEffectProof(...args),
|
|
27
|
+
buildNodeCompiledRouteHandlerEffectBridge: (...args) => load('@pulse-compute/provider-node/compiler/route-handler-compiled-wasm-bridge').buildNodeCompiledRouteHandlerEffectBridge(...args),
|
|
28
|
+
buildNodeBackendJsonRequestBodyProof: (...args) => load('@pulse-compute/provider-node/compiler/backend-json-request-body-proof').buildNodeBackendJsonRequestBodyProof(...args),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { createProviderProofs };
|
package/bin/pulsewasm-extract.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const { runCli } = require('../src/cli.js');
|
|
5
5
|
const { getDefaultArtifactsDir } = require('@pulse-compute/wasm-build-support/artifacts-dir');
|
|
6
|
-
const providerProofs = require('./provider-proof-composition.js');
|
|
6
|
+
const providerProofs = require('./provider-proof-composition.js').createProviderProofs(process.cwd());
|
|
7
7
|
|
|
8
8
|
runCli(process.argv.slice(2), {
|
|
9
9
|
cwd: process.cwd(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulse-compute/wasm-compiler",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "PulseWasm compiler package inside the Pulse monorepo.",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -9,15 +9,13 @@
|
|
|
9
9
|
"pulsewasm": "./bin/pulsewasm-extract.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@pulse-compute/
|
|
13
|
-
"@pulse-compute/
|
|
14
|
-
"@pulse-compute/wasm-
|
|
15
|
-
"@pulse-compute/wasm-
|
|
16
|
-
"@pulse-compute/wasm-
|
|
17
|
-
"@pulse-compute/wasm-
|
|
18
|
-
"@pulse-compute/wasm-
|
|
19
|
-
"@pulse-compute/wasm-runtime-core-as": "1.0.0-beta.4",
|
|
20
|
-
"@pulse-compute/wasm-schema-json": "1.0.0-beta.4",
|
|
12
|
+
"@pulse-compute/wasm-build-support": "1.0.0-beta.6",
|
|
13
|
+
"@pulse-compute/wasm-contracts": "1.0.0-beta.6",
|
|
14
|
+
"@pulse-compute/wasm-guest-link": "1.0.0-beta.6",
|
|
15
|
+
"@pulse-compute/wasm-host-runtime": "1.0.0-beta.6",
|
|
16
|
+
"@pulse-compute/wasm-library-kit": "1.0.0-beta.6",
|
|
17
|
+
"@pulse-compute/wasm-runtime-core-as": "1.0.0-beta.6",
|
|
18
|
+
"@pulse-compute/wasm-schema-json": "1.0.0-beta.6",
|
|
21
19
|
"assemblyscript": "0.28.18",
|
|
22
20
|
"json-as": "1.5.0",
|
|
23
21
|
"typescript": "5.9.3"
|
|
@@ -58,7 +56,7 @@
|
|
|
58
56
|
"url": "git+https://github.com/pulse-compute/pulse.git",
|
|
59
57
|
"directory": "wasm/packages/compiler"
|
|
60
58
|
},
|
|
61
|
-
"homepage": "https://pulsecompute.io/v1.0.0-beta.
|
|
59
|
+
"homepage": "https://pulsecompute.io/v1.0.0-beta.6/packages/implementation-packages/",
|
|
62
60
|
"bugs": {
|
|
63
61
|
"url": "https://github.com/pulse-compute/pulse/issues"
|
|
64
62
|
},
|
|
@@ -22,15 +22,7 @@ const {
|
|
|
22
22
|
CanonicalCompileError
|
|
23
23
|
} = require('./spine/plain-handler-frontend.js');
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
try { return require('@pulse-compute/wasm-contracts/handler/canonical-runtime'); }
|
|
27
|
-
catch (error) {
|
|
28
|
-
if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../contracts/src/handler/canonical-runtime.js');
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const canonicalRuntimeContract = loadCanonicalRuntimeContract();
|
|
25
|
+
const canonicalRuntimeContract = require('@pulse-compute/wasm-contracts/handler/canonical-runtime');
|
|
34
26
|
|
|
35
27
|
const CANONICAL_API_COMPILER_VERSION = 'pulse.canonical-api-compiler.v7';
|
|
36
28
|
|
|
@@ -17,59 +17,12 @@ const {
|
|
|
17
17
|
PACKAGE_REALIZATION_ARTIFACT_SET_VERSION
|
|
18
18
|
} = require('@pulse-compute/wasm-contracts/package/package-contract');
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function loadRuntimeCore() {
|
|
29
|
-
try { return require('@pulse-compute/wasm-runtime-core-as/compiler/canonical-native'); }
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../runtime-core-as/src/compiler/canonical-native.js');
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function loadRuntimeContract() {
|
|
37
|
-
try { return require('@pulse-compute/wasm-contracts/handler/canonical-native-runtime'); }
|
|
38
|
-
catch (error) {
|
|
39
|
-
if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../contracts/src/handler/canonical-native-runtime.js');
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function loadEventContract() {
|
|
45
|
-
try { return require('@pulse-compute/wasm-contracts/events'); }
|
|
46
|
-
catch (error) {
|
|
47
|
-
if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../contracts/src/events/contracts.js');
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function loadBuildSupport() {
|
|
53
|
-
try { return require('@pulse-compute/wasm-build-support/assemblyscript-compile'); }
|
|
54
|
-
catch (error) {
|
|
55
|
-
if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../build-support/src/assemblyscript-compile.js');
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const nativePlanCompiler = loadNativePlanCompiler();
|
|
61
|
-
const runtimeCore = loadRuntimeCore();
|
|
62
|
-
const runtimeContract = loadRuntimeContract();
|
|
63
|
-
const eventContract = loadEventContract();
|
|
64
|
-
const { resolveAsc } = loadBuildSupport();
|
|
65
|
-
const { memoryAbi } = (() => {
|
|
66
|
-
try {
|
|
67
|
-
return require('@pulse-compute/wasm-guest-link');
|
|
68
|
-
} catch (error) {
|
|
69
|
-
if (error && error.code === 'MODULE_NOT_FOUND') return require('../../wasm-guest-link/src/index.js');
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
})();
|
|
20
|
+
const nativePlanCompiler = require('./canonical-native-plan.js');
|
|
21
|
+
const runtimeCore = require('@pulse-compute/wasm-runtime-core-as/compiler/canonical-native');
|
|
22
|
+
const runtimeContract = require('@pulse-compute/wasm-contracts/handler/canonical-native-runtime');
|
|
23
|
+
const eventContract = require('@pulse-compute/wasm-contracts/events');
|
|
24
|
+
const { resolveAsc } = require('@pulse-compute/wasm-build-support/assemblyscript-compile');
|
|
25
|
+
const { memoryAbi } = require('@pulse-compute/wasm-guest-link');
|
|
73
26
|
const {
|
|
74
27
|
appendAssemblyScriptOptimizationArgs,
|
|
75
28
|
resolveNativeOptimization
|
|
@@ -182,7 +135,13 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
|
|
|
182
135
|
const compilerPackageRoot = path.resolve(__dirname, '..');
|
|
183
136
|
const asc = resolveAsc(cwd) || resolveAsc(compilerPackageRoot);
|
|
184
137
|
if (!asc) throw new CanonicalNativeCompileError('AssemblyScript compiler dependency was not found.', { cwd, remediation: 'Install the lockfile-pinned AssemblyScript dependency before compiling native Wasm.' });
|
|
185
|
-
const
|
|
138
|
+
const application = plan.packages && plan.packages.application;
|
|
139
|
+
const source = application && application.source + `\nconst __pulse_application_plan_hash: string = ${JSON.stringify(plan.planHash)}\n`;
|
|
140
|
+
const generated = application ? Object.freeze({
|
|
141
|
+
source, sourceHash: sha256(source), manifest: Object.freeze({
|
|
142
|
+
...application.manifest, planVersion: plan.version, planHash: plan.planHash, sourceHash: sha256(source)
|
|
143
|
+
})
|
|
144
|
+
}) : runtimeCore.generateCanonicalNativeAssemblyScript(plan, options);
|
|
186
145
|
const schemaCodecsActive = generated.manifest.schemaCodecs && generated.manifest.schemaCodecs.active === true;
|
|
187
146
|
let jsonAs;
|
|
188
147
|
if (schemaCodecsActive) {
|
|
@@ -209,6 +168,8 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
|
|
|
209
168
|
}
|
|
210
169
|
jsonAs = Object.freeze({ transform, packageRoot, dependencyRoot, version: packageJson.version });
|
|
211
170
|
}
|
|
171
|
+
if (options.emitWat !== undefined && typeof options.emitWat !== 'boolean') throw new TypeError('emitWat must be a boolean.');
|
|
172
|
+
const emitWat = options.emitWat === true;
|
|
212
173
|
const stagingDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pulse-canonical-native-'));
|
|
213
174
|
const requestedOutDir = options.outDir ? path.resolve(options.outDir) : undefined;
|
|
214
175
|
const outputDir = requestedOutDir || stagingDir;
|
|
@@ -216,6 +177,7 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
|
|
|
216
177
|
const sourceFile = path.join(stagingDir, 'canonical-native.as.ts');
|
|
217
178
|
const wasmFile = path.join(outputDir, options.wasmFile || 'canonical-native.wasm');
|
|
218
179
|
const watFile = path.join(outputDir, options.watFile || 'canonical-native.wat');
|
|
180
|
+
if (!emitWat) fs.rmSync(watFile, { force: true });
|
|
219
181
|
try {
|
|
220
182
|
fs.writeFileSync(sourceFile, generated.source, 'utf8');
|
|
221
183
|
// Compile from a stable, relative entry name so AssemblyScript's name section and
|
|
@@ -224,14 +186,25 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
|
|
|
224
186
|
asc.script,
|
|
225
187
|
path.basename(sourceFile),
|
|
226
188
|
'--outFile', wasmFile,
|
|
227
|
-
'--textFile', watFile,
|
|
228
189
|
'--runtime', schemaCodecsActive ? 'incremental' : 'stub',
|
|
229
190
|
'--noAssert',
|
|
230
191
|
'--optimize'
|
|
231
192
|
];
|
|
232
|
-
|
|
193
|
+
if (emitWat) args.push('--textFile', watFile);
|
|
194
|
+
const optimization = appendAssemblyScriptOptimizationArgs(args, options.nativeOptimization, {
|
|
195
|
+
guestLinked: guestUnits.length > 0
|
|
196
|
+
});
|
|
197
|
+
// The text capacity profile bounds each Native module to 256 MiB.
|
|
198
|
+
// Linked guests retain their separately owned fixed-memory ABI.
|
|
199
|
+
if (guestUnits.length === 0 && (runtimeContract.hasBoundedReadLoop(plan) || plan.capabilities.includes('response.output') || plan.capabilities.includes('request.body.transform') || plan.effects.some(effect => effect.kind === 'crypto.digestText' || effect.kind.startsWith('s3.')))) {
|
|
200
|
+
args.push('--maximumMemory', String(runtimeContract.CANONICAL_NATIVE_READ_LOOP_MEMORY.maximumMemoryPages));
|
|
201
|
+
}
|
|
202
|
+
if (guestUnits.length > 0 && (plan.capabilities.includes('response.output') || plan.capabilities.includes('request.body.transform'))) throw new CanonicalNativeCompileError('Generated output with linked guests requires separate memory qualification.');
|
|
233
203
|
if (guestUnits.length > 0) {
|
|
234
204
|
args.push(
|
|
205
|
+
'--disable', 'bulk-memory',
|
|
206
|
+
'--disable', 'nontrapping-f2i',
|
|
207
|
+
'--disable', 'sign-extension',
|
|
235
208
|
'--importMemory',
|
|
236
209
|
'--noExportMemory',
|
|
237
210
|
'--initialMemory', String(memoryAbi.minimumPages),
|
|
@@ -276,12 +249,13 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
|
|
|
276
249
|
guestUnits,
|
|
277
250
|
generated,
|
|
278
251
|
wasm: fs.readFileSync(wasmFile),
|
|
279
|
-
wat:
|
|
252
|
+
wat: emitWat ? fs.readFileSync(watFile, 'utf8') : '',
|
|
253
|
+
textEmitted: emitWat,
|
|
280
254
|
assemblyScriptVersion: require(path.join(asc.packageRoot, 'package.json')).version,
|
|
281
255
|
jsonAsVersion: jsonAs && jsonAs.version,
|
|
282
256
|
optimization,
|
|
283
257
|
durationMs,
|
|
284
|
-
output: requestedOutDir ? Object.freeze({ outDir: outputDir, wasmFile, watFile }) : undefined
|
|
258
|
+
output: requestedOutDir ? Object.freeze({ outDir: outputDir, wasmFile, watFile: emitWat ? watFile : null }) : undefined
|
|
285
259
|
});
|
|
286
260
|
} finally {
|
|
287
261
|
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
@@ -311,7 +285,9 @@ function verifyCanonicalNativeRealization(realization) {
|
|
|
311
285
|
? Object.freeze({ package: 'json-as', version: realization.jsonAsVersion, transform: true, strict: true, mode: 'NAIVE', fastPath: false })
|
|
312
286
|
: null,
|
|
313
287
|
wasm: Object.freeze({ bytes: inspection.bytes, sha256: inspection.sha256, magic: inspection.magic }),
|
|
314
|
-
wat: Object.freeze(
|
|
288
|
+
wat: Object.freeze(realization.textEmitted
|
|
289
|
+
? { emitted: true, bytes: Buffer.byteLength(realization.wat), sha256: sha256(realization.wat) }
|
|
290
|
+
: { emitted: false, bytes: 0, sha256: null }),
|
|
315
291
|
importModules: inspection.importModules,
|
|
316
292
|
imports: inspection.imports,
|
|
317
293
|
exports: inspection.exports,
|
|
@@ -322,7 +298,7 @@ function verifyCanonicalNativeRealization(realization) {
|
|
|
322
298
|
finalWasmAudit: realization.guestLink.audit,
|
|
323
299
|
providerPackaging: realization.guestLink.providerPackaging
|
|
324
300
|
} : {}),
|
|
325
|
-
policy:
|
|
301
|
+
policy: realization.generated.manifest.policy
|
|
326
302
|
});
|
|
327
303
|
return Object.freeze({
|
|
328
304
|
version: runtimeContract.CANONICAL_NATIVE_WASM_VERSION,
|
|
@@ -376,7 +352,9 @@ function writeCanonicalNativeModule(compiled, outDir, options = {}) {
|
|
|
376
352
|
: undefined;
|
|
377
353
|
fs.writeFileSync(sourceFile, compiled.source, 'utf8');
|
|
378
354
|
fs.writeFileSync(wasmFile, compiled.wasm);
|
|
379
|
-
|
|
355
|
+
const emitWat = compiled.manifest.wat.emitted !== false;
|
|
356
|
+
if (emitWat) fs.writeFileSync(watFile, compiled.wat, 'utf8');
|
|
357
|
+
else fs.rmSync(watFile, { force: true });
|
|
380
358
|
fs.writeFileSync(planFile, `${nativePlanCompiler.stableStringify(compiled.plan, 2)}\n`, 'utf8');
|
|
381
359
|
fs.writeFileSync(manifestFile, `${stableStringify(compiled.manifest, 2)}\n`, 'utf8');
|
|
382
360
|
if (realizationArtifactsFile) {
|
|
@@ -389,7 +367,7 @@ function writeCanonicalNativeModule(compiled, outDir, options = {}) {
|
|
|
389
367
|
target,
|
|
390
368
|
sourceFile,
|
|
391
369
|
wasmFile,
|
|
392
|
-
watFile,
|
|
370
|
+
watFile: emitWat ? watFile : null,
|
|
393
371
|
planFile,
|
|
394
372
|
manifestFile,
|
|
395
373
|
realizationArtifactsFile,
|