Capability first · transport second

ScopedOPFSCache.js

Provides a narrow exact-key JSON cache inside one app-owned OPFS namespace.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Provides a narrow exact-key JSON cache inside one app-owned OPFS namespace.

  • Artifact
    ScopedOPFSCache.js · esm
  • Classification
    public first party
  • Availability
    Browser / native WebView
  • Normalization
    Filename-safe scope and key segments, complete JSON values, and malformed-cache cleanup are normalized; storage errors remain mixed.

Import and lifecycle

JavaScript
import scopedOpfsCache from '/arcane/modules/ScopedOPFSCache.js';

Construction validates scope/support only. The first operation lazily opens/creates the application data directory and namespace. set() writes one complete JSON file; get() parses the complete file and removes malformed JSON; delete() is exact-key and idempotent. There is no enumeration or clear-all.

Application-facing behavior: default ScopedOPFSCache; support check and get/set/delete APIs.

Protocol and host implementation

OPFS + AppDataScope This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
defaultdefault · classclass ScopedOPFSCache
MemberKindExact public declarationParameter syntax
ScopedOPFSCache.constructorconstructorconstructor({ applicationId=null, namespace, storage=globalThis.navigator?.storage, documentObject=globalThis.document, arcane=globalThis.Arcane }={}){ applicationId=null, namespace, storage=globalThis.navigator?.storage, documentObject=globalThis.document, arcane=globalThis.Arcane }={}
ScopedOPFSCache.supportedstatic methodstatic supported(storage=globalThis.navigator?.storage)storage=globalThis.navigator?.storage
ScopedOPFSCache.namespacegetget namespace()
ScopedOPFSCache.applicationIdgetget applicationId()
ScopedOPFSCache.getasync methodasync get(key)key
ScopedOPFSCache.setasync methodasync set(key,value)key,value
ScopedOPFSCache.deleteasync methodasync delete(key)key

Parameter meanings and results

new ScopedOPFSCache({applicationId?,namespace,storage?,documentObject?,arcane?}); static supported(storage?); getters namespace/applicationId; get(key) resolves the complete JSON value or undefined; set(key,JSONValue) resolves the same value; delete(key) resolves boolean.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

This artifact has no additional documented lifecycle event flow.

Direct coded failures

  • OPFS_UNAVAILABLE

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • OPFS_UNAVAILABLE
  • TypeError or RangeError for an unsafe segment or nonserializable value.
  • Malformed cached JSON is invalid, removed, and returned as undefined.
  • Underlying OPFS failures are preserved.

Availability and capabilities

Browser / native WebView. Filename-safe scope and key segments, complete JSON values, and malformed-cache cleanup are normalized; storage errors remain mixed.

OPFS needs no Core capability; omitted applicationId may use capability-free app.current to bind application ownership.

Contract example

JavaScript
import ScopedOPFSCache from '/arcane/modules/ScopedOPFSCache.js';

if (ScopedOPFSCache.supported()) {
    const cache = new ScopedOPFSCache({namespace:'example-cache'});
    await cache.set('welcome.json',{ready:true});
    console.log(await cache.get('welcome.json'));
}

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.