Skip to content

Create asset exporter interface#330

Merged
waynemwashuma merged 10 commits into
wimaengine:devfrom
waynemwashuma:create-asset-exporter
May 31, 2026
Merged

Create asset exporter interface#330
waynemwashuma merged 10 commits into
wimaengine:devfrom
waynemwashuma:create-asset-exporter

Conversation

@waynemwashuma

@waynemwashuma waynemwashuma commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Objective

Introduce asset exporting support to the asset pipeline.This adds a first-class exporter abstraction to AssetServer, enabling assets to be serialized and saved back to storage in a format-aware manner. This establishes the foundation for editor workflows, asset authoring tools, and runtime asset persistence.

Solution

Previously, the asset system only supported importing assets through parsers. There was no corresponding mechanism for serializing runtime assets back into a file format, making asset editing and persistence impossible through the asset pipeline.

Changes made

Added Exporter abstraction

Introduced a new base class Exporter<T> mirroring the existing parser architecture and allows asset types to support one or more output formats.

Example:

class TextExporter extends Exporter {
  getExtensions() {
    return ['txt']
  }

  async serialize(asset) {
    return JSON.stringify(asset)
  }
}

Added exporter registration support

Introduced AssetServer.registerExporter(...) and AssetExporterPlugin which allows exporters to be registered through the plugin system in the same way parsers are registered today.

Example:

app.registerPlugin(new AssetExporterPlugin({
  asset: Text,
  exporter: new TextExporter()
}))

Added asset saving support

Introduced:

AssetServer.save(handle, path?)

which:

  1. resolves the target asset
  2. selects the appropriate exporter
  3. serializes the asset
  4. submits the serialized output to the destination

Example:

assetServer.save(handle, '/assets/text/sample.txt')

If no path is provided, the server attempts to reuse the asset's registered source path.

Added save failure reporting

Asset failures previously only represented loading operations. Introduced AssetLoadOperation and extended AssetLoadFail to include operation context. This allows tooling and diagnostics to distinguish between import and export failures.

Why this approach

The exporter system mirrors the existing parser architecture:

Import:
File -> Parser -> Asset

Export:
Asset -> Exporter -> File

This symmetry keeps the asset pipeline predictable and extensible.

It also provides a clean foundation for future features such as:

  • editor save operations
  • scene serialization
  • asset conversion pipelines
  • export tooling
  • runtime persistence
  • custom asset authoring workflows

Showcase

Save an asset:

const handle = assets.add(new Text('hello'))

assetServer.save(
  handle,
  '/assets/text/sample.txt'
)

The exporter serializes the asset and submits the result to the target path.

Migration guide

No migration required.

Checklist

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@waynemwashuma waynemwashuma self-assigned this May 31, 2026
@waynemwashuma waynemwashuma added the type:enhancement New feature or request label May 31, 2026
@waynemwashuma waynemwashuma force-pushed the create-asset-exporter branch from 597de44 to 321f482 Compare May 31, 2026 20:05
@waynemwashuma waynemwashuma merged commit c4df8c1 into wimaengine:dev May 31, 2026
7 checks passed
@waynemwashuma waynemwashuma deleted the create-asset-exporter branch May 31, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:asset type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant