3.3 KiB
3.3 KiB
name, description
| name | description |
|---|---|
| sp-storage-uri-plugin-bundle | Bundle URI plugin for @suaveplan/storage-uri — serves packed asset bundles over HTTP with range support, LRU cache, safe fetch shim, and OTel metrics. |
sp-storage-uri-plugin-bundle
| Symbol | Kind | Responsibility |
|---|---|---|
bundleUriPlugin |
Function | Creates bundle:// URI plugin |
validateOptions |
Function | Validates bundle plugin options |
BundleStorageShim |
Class | Shim adapting bundle storage to URI plugin interface |
safeFetch |
Function | Safe fetch with error handling |
performExists |
Function | Checks if bundle entry exists |
performGetMetadata |
Function | Reads bundle entry metadata |
performRangeRead |
Function | Reads byte range from bundle |
buildRangeHeader |
Function | Builds HTTP Range header |
sliceForRange |
Function | Slices buffer for byte range |
validateRange |
Function | Validates range request |
parse |
Function | Parses bundle:// URI |
build |
Function | Builds bundle:// URI |
UriLruCache |
Class | LRU cache for bundle responses |
toReadableStream |
Function | Converts response to readable stream |
ensureNotAborted |
Function | Throws if operation aborted |
recordCacheHit |
Function | OTel counter for cache hits |
recordCacheMiss |
Function | OTel counter for cache misses |
recordRangeFallback |
Function | OTel counter for range fallbacks |
BUNDLE_URI_CODES |
Constant | Error codes via defineCodes |
BundleUriError |
Class | Typed error with bundle URI codes |
BundleUriPluginOptionsSchema |
Schema | Zod schema for plugin options |
File Structure: packages/persistence/storage/storage-uri-plugin-bundle/src/{factory,storage-shim,parse,range,cache,streaming,abort,otel,error-codes,types}/
Sibling packages:
@suaveplan/storage-uri— URI resolver framework@suaveplan/packer-browser— asset bundling
Patterns:
Quick Start:
import { bundleUriPlugin } from "@suaveplan/storage-uri-plugin-bundle";
const plugin = bundleUriPlugin({ baseUrl: "https://cdn.example.com/bundles" });
Shim:
import { BundleStorageShim } from "@suaveplan/storage-uri-plugin-bundle";
const shim = new BundleStorageShim({ baseUrl });
Range read:
import { performRangeRead } from "@suaveplan/storage-uri-plugin-bundle";
const data = await performRangeRead({ url, range: { start: 0, end: 1024 } });
Constraints:
- Implements
UriPluginfrom@suaveplan/storage-uri bundle://URIs reference packed asset bundlesBundleStorageShimfetches bundles over HTTP with retry- Range requests supported for partial asset loading
UriLruCachecaches bundle metadata and small responsessafeFetchhandles network errors with typedBundleUriError- OTel instruments: cache hit/miss, range fallback, operations
- Error codes use
defineCodesfrom@suaveplan/error
Checklist:
bundleUriPluginimplementsUriPlugininterfacebundle://URIs resolved to bundle assetsBundleStorageShimfetches over HTTP- Range requests return correct partial content
UriLruCachecaches metadata and responsessafeFetchhandles errors gracefully- OTel metrics track cache effectiveness
- Error codes use
defineCodesfrom@suaveplan/error