Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c897f445
Commit
c897f445
authored
Apr 03, 2026
by
Luke Sandberg
Committed by
Luke Sandberg
Apr 09, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more snaps
parent
fb4332ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
26 deletions
+34
-26
generated-native.d.ts
packages/next/src/build/swc/generated-native.d.ts
+24
-24
wasm-manager.ts
packages/next/src/build/swc/wasm-manager.ts
+1
-0
wasm-worker.ts
packages/next/src/build/swc/wasm-worker.ts
+9
-2
No files found.
packages/next/src/build/swc/generated-native.d.ts
View file @
c897f445
...
...
@@ -39,6 +39,30 @@ export declare class ExternalObject<T> {
[
K
:
symbol
]:
T
}
}
export
declare
function
registerWorkerScheduler
(
creator
:
(
arg
:
NapiWorkerCreation
)
=>
any
,
terminator
:
(
arg
:
NapiWorkerTermination
)
=>
any
):
void
export
declare
function
workerCreated
(
workerId
:
number
):
void
export
interface
NapiWorkerCreation
{
options
:
NapiWorkerOptions
}
export
interface
NapiWorkerOptions
{
filename
:
RcStr
cwd
:
RcStr
}
export
interface
NapiWorkerTermination
{
options
:
NapiWorkerOptions
workerId
:
number
}
export
interface
NapiTaskMessage
{
taskId
:
number
data
:
Buffer
}
export
declare
function
recvTaskMessageInWorker
(
workerId
:
number
):
Promise
<
NapiTaskMessage
>
export
declare
function
sendTaskMessage
(
message
:
NapiTaskMessage
):
Promise
<
void
>
/**
* Called by worker after WASM instantiation to register a dispatch callback.
*
...
...
@@ -76,30 +100,6 @@ export declare function wasmWorkerDispatchHostFn(
args
:
Array
<
number
>
,
memoryAccessor
:
object
):
unknown
export
declare
function
registerWorkerScheduler
(
creator
:
(
arg
:
NapiWorkerCreation
)
=>
any
,
terminator
:
(
arg
:
NapiWorkerTermination
)
=>
any
):
void
export
declare
function
workerCreated
(
workerId
:
number
):
void
export
interface
NapiWorkerCreation
{
options
:
NapiWorkerOptions
}
export
interface
NapiWorkerOptions
{
filename
:
RcStr
cwd
:
RcStr
}
export
interface
NapiWorkerTermination
{
options
:
NapiWorkerOptions
workerId
:
number
}
export
interface
NapiTaskMessage
{
taskId
:
number
data
:
Buffer
}
export
declare
function
recvTaskMessageInWorker
(
workerId
:
number
):
Promise
<
NapiTaskMessage
>
export
declare
function
sendTaskMessage
(
message
:
NapiTaskMessage
):
Promise
<
void
>
export
interface
NapiLocation
{
line
:
number
column
?:
number
...
...
packages/next/src/build/swc/wasm-manager.ts
View file @
c897f445
...
...
@@ -206,6 +206,7 @@ export const wasmManager = {
instanceId
,
module
,
hostFnDescriptors
,
runtimeId
,
}).
then
(
()
=>
callback
(
instanceId
),
(
err
)
=>
callback
(
String
(
err
))
...
...
packages/next/src/build/swc/wasm-worker.ts
View file @
c897f445
...
...
@@ -23,7 +23,8 @@ if (!parentPort) {
// Load native addon directly in the worker thread.
// This gives us direct NAPI access for host function callbacks.
const
bindings
=
require
(
workerData
.
nativeBindingsPath
)
const
runtimeId
:
number
=
workerData
.
runtimeId
// runtimeId may be 0 at worker creation time; it gets updated per-instantiate message.
let
runtimeId
:
number
=
workerData
.
runtimeId
// ---------------------------------------------------------------------------
// Instance storage — the ops object closes over the WASM instance/memory,
...
...
@@ -91,6 +92,11 @@ parentPort.on('message', (req: any) => {
switch
(
req
.
type
)
{
case
'instantiate'
:
{
const
instanceId
=
req
.
instanceId
as
number
// Update runtimeId from the message (may differ from workerData if
// workers were created before runtime registration).
if
(
req
.
runtimeId
!=
null
)
{
runtimeId
=
req
.
runtimeId
as
number
}
// Build env imports that call Rust host functions directly via NAPI
const
envImports
:
Record
<
string
,
Function
>
=
{}
...
...
@@ -100,13 +106,14 @@ parentPort.on('message', (req: any) => {
,
index
,
]
of
req
.
hostFnDescriptors
as
HostFnDescriptor
[])
{
const
capturedRuntimeID
=
runtimeId
envImports
[
name
]
=
(...
args
:
number
[])
=>
{
const
ops
=
instances
.
get
(
instanceId
)
if
(
!
ops
)
{
throw
new
Error
(
`Instance
${
instanceId
}
not found for host fn`
)
}
return
bindings
.
wasmWorkerDispatchHostFn
(
runtimeId
,
capturedRuntimeID
,
instanceId
,
index
,
args
.
slice
(
0
,
paramCount
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment