On this page
Overview
Serializes OPFS sync-handle read/write requests from a MessagePort.
- Artifact
DBOPFSWorker.js· worker - Classification
internal worker - Availability
Dedicated worker - Normalization
Responses normalize to `{success,fileData?}` or `{error:{name,message}}`.
Import and lifecycle
const worker = new Worker('/arcane/modules/DBOPFSWorker.js');
A classic dedicated worker handles each MessagePort request independently, so concurrent requests can interleave. Each request opens app-scoped OPFS synchronous handles, reads or writes bytes, closes the handle and port, and transfers read buffers back.
Application-facing behavior: No ESM exports; accepts read and write port requests.
Protocol and host implementation
MessageChannel + OPFS sync access handle This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
This artifact has no ESM bindings. Its public load, global, asset, or worker contract is listed below.
Parameter meanings and results
postMessage data requires canonical applicationId, directoryName, and fileName. operation === "read" selects a read; a missing, falsy, or other truthy operation selects write, which also requires fileData:ArrayBuffer and accepts optional append. The response is {success:true, fileData?} or {error:{name, message}}.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
- worker message request
- MessagePort response
Direct coded failures
This artifact directly assigns no stable coded failure.
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- SecurityError for an invalid application scope
- NotSupportedError without synchronous access handles
- serialized OPFS, read, or write errors
Availability and capabilities
Dedicated worker. Responses normalize to `{success,fileData?}` or `{error:{name,message}}`.
Internal DBOPFS fallback only; never import it as ESM, and it has no Core dependency.
Worker protocol example
const worker=new Worker('/arcane/modules/DBOPFSWorker.js');
const channel=new MessageChannel();
const fileData=new Uint8Array([1,2,3]).buffer;
const result=new Promise((resolve,reject)=>{
channel.port1.onmessage=event=>event.data.error
?reject(Object.assign(new Error(event.data.error.message),{name:event.data.error.name}))
:resolve(event.data);
channel.port1.start();
});
worker.postMessage({
operation:'write',
applicationId:'notes-app',
directoryName:'files',
fileName:'sample.bin',
fileData,
append:false
},[fileData,channel.port2]);
console.log(await result);
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.