Files
hyperframes/packages/sdk/package.json
T
Vance Ingalls c19898e799 feat(sdk): stage 7 step 1 — http persist adapter (#1441)
## What

Adds `createHttpAdapter` — a browser-native `PersistAdapter` that reads and writes composition files through the Studio dev-server's `/api/projects/:id/files/...` endpoints using the Fetch API. Exported as a subpath: `@hyperframes/sdk/adapters/http`.

## Why

The SDK's `PersistAdapter` interface previously had filesystem (`fs`) and in-memory (`memory`) implementations, both Node-only. Studio runs in the browser and needs to persist compositions back to the dev server. This adapter is the browser-compatible plug that lets `openComposition` work in a Studio context without Node I/O.

## How

- `HttpAdapter` implements `PersistAdapter`: `read` → GET, `write` → PUT with per-path queue to serialize concurrent writes to the same file (at-most-once in-flight per path)
- `flush()` waits for all in-flight queues to drain
- `listVersions` / `loadFrom` proxy the server's version history endpoints
- `on('persist:error')` fires on network/non-2xx failures without throwing; callers can surface errors non-fatally
- Retry is caller's responsibility; the adapter does not retry

## Test plan

- `http.test.ts`: read/write round-trip with MSW, concurrent write serialization, persist:error event on 503, flush drains queue
- Contract suite (`persistAdapter.contract.test.ts`) passes for the http adapter against a mock server
2026-06-15 13:52:20 -07:00

82 lines
2.0 KiB
JSON

{
"name": "@hyperframes/sdk",
"version": "0.6.99",
"description": "Headless, framework-neutral HyperFrames composition editing engine",
"repository": {
"type": "git",
"url": "https://github.com/heygen-com/hyperframes",
"directory": "packages/sdk"
},
"files": [
"dist",
"README.md"
],
"type": "module",
"sideEffects": false,
"exports": {
".": {
"import": "./src/index.ts",
"types": "./src/index.ts"
},
"./adapters/memory": {
"import": "./src/adapters/memory.ts",
"types": "./src/adapters/memory.ts"
},
"./adapters/fs": {
"import": "./src/adapters/fs.ts",
"types": "./src/adapters/fs.ts"
},
"./adapters/headless": {
"import": "./src/adapters/headless.ts",
"types": "./src/adapters/headless.ts"
},
"./adapters/http": {
"import": "./src/adapters/http.ts",
"types": "./src/adapters/http.ts"
}
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./adapters/memory": {
"import": "./dist/adapters/memory.js",
"types": "./dist/adapters/memory.d.ts"
},
"./adapters/fs": {
"import": "./dist/adapters/fs.js",
"types": "./dist/adapters/fs.d.ts"
},
"./adapters/headless": {
"import": "./dist/adapters/headless.js",
"types": "./dist/adapters/headless.d.ts"
},
"./adapters/http": {
"import": "./dist/adapters/http.js",
"types": "./dist/adapters/http.d.ts"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"scripts": {
"build": "tsc",
"test": "vitest run",
"test:watch": "vitest",
"typecheck": "tsc --noEmit",
"typecheck:examples": "tsc --noEmit -p tsconfig.check.json"
},
"dependencies": {
"@hyperframes/core": "workspace:*",
"linkedom": "^0.18.12"
},
"devDependencies": {
"@types/node": "^25.0.10",
"typescript": "^5.0.0",
"vitest": "^3.2.4"
}
}