Install
createLogoSoup Engine
The core engine is what every framework adapter wraps. You can use it directly for vanilla JS apps, Web Components, or any framework that doesn’t have a dedicated adapter.Engine API
createLogoSoup()
Creates a new engine instance. Each instance has its own image cache and state.
engine.process(options)
Triggers a processing run. Cancels any in-flight work from a previous process() call. Accepts all shared options.
process() again with new options re-uses cached measurements for logos that haven’t changed. Only new logos trigger image loading.
engine.subscribe(listener)
Subscribes to state changes. Returns an unsubscribe function.
getSnapshot() inside the listener to read the current state. This design matches the pattern expected by React.useSyncExternalStore, Vue’s shallowRef, Svelte’s createSubscriber, and Solid’s from().
engine.getSnapshot()
Returns the current immutable state snapshot. Returns the same reference (===) when state hasn’t changed, which is critical for frameworks that use referential equality to avoid unnecessary re-renders.
If some images fail but others succeed, the engine still transitions to
"ready" with the successful logos. "error" only occurs when all images fail.engine.destroy()
Cleans up the engine: revokes blob URLs, cancels in-flight work, clears the image cache, and removes all subscribers.
destroy() when you’re done with the engine to avoid memory leaks from blob URLs.
Lifecycle
A typical lifecycle looks like:process() while a previous run is still loading cancels the in-flight work. Only the latest process() call’s results are emitted.
Re-processing on Option Changes
Callprocess() again whenever options change. The engine caches image measurements, so re-processing with the same logos but different baseSize or scaleFactor is synchronous (no network requests):
contrastThreshold, densityAware, or backgroundColor change, since these affect the measurement itself.
Web Components Example
Integrating with Other Frameworks
Thesubscribe/getSnapshot shape is designed to plug into any reactivity system. If your framework isn’t directly supported, the pattern is:
- Create an engine with
createLogoSoup() - Subscribe to changes and push snapshots into your framework’s reactive primitive
- Call
process()when options change - Call
destroy()on teardown