Skip to content

Commit

Permalink
[ts-sdk] Release TypeScript SDK v0.1.0 (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozyra95 authored Sep 26, 2024
1 parent 8ec071e commit 8e63da3
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion ts/@live-compositor/browser-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"wasm-pack": "^0.13.0"
},
"peerDependencies": {
"live-compositor": "0.1.0-rc.5"
"live-compositor": "^0.1.0"
},
"nx": {
"targets": {
Expand Down
4 changes: 2 additions & 2 deletions ts/@live-compositor/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@live-compositor/core",
"version": "0.1.0-rc.5",
"version": "0.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand All @@ -23,6 +23,6 @@
"react-reconciler": "0.29.2"
},
"peerDependencies": {
"live-compositor": "0.1.0-rc.5"
"live-compositor": "^0.1.0"
}
}
4 changes: 2 additions & 2 deletions ts/@live-compositor/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@live-compositor/node",
"version": "0.1.0-rc.5",
"version": "0.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand All @@ -24,7 +24,7 @@
"@types/ws": "^8.5.12"
},
"dependencies": {
"@live-compositor/core": "0.1.0-rc.5",
"@live-compositor/core": "^0.1.0",
"fs-extra": "^11.2.0",
"node-fetch": "^2.6.7",
"tar": "^7.4.3",
Expand Down
20 changes: 13 additions & 7 deletions ts/@live-compositor/node/src/manager/locallySpawnedInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ManagedInstanceOptions = {
port: number;
workingdir?: string;
executablePath?: string;
enableWebRenderer?: boolean;
};

/**
Expand All @@ -27,11 +28,13 @@ class LocallySpawnedInstance implements CompositorManager {
private workingdir: string;
private executablePath?: string;
private wsConnection: WebSocketConnection;
private enableWebRenderer?: boolean;

constructor(opts: ManagedInstanceOptions) {
this.port = opts.port;
this.workingdir = opts.workingdir ?? path.join(os.tmpdir(), `live-compositor-${uuidv4()}`);
this.executablePath = opts.executablePath;
this.enableWebRenderer = opts.enableWebRenderer;
this.wsConnection = new WebSocketConnection(`ws://127.0.0.1:${this.port}/ws`);
}

Expand All @@ -46,13 +49,14 @@ class LocallySpawnedInstance implements CompositorManager {
}

public async setupInstance(): Promise<void> {
const executablePath = this.executablePath ?? (await prepareExecutable());
const executablePath = this.executablePath ?? (await prepareExecutable(this.enableWebRenderer));

spawn(executablePath, [], {
env: {
...process.env,
LIVE_COMPOSITOR_DOWNLOAD_DIR: path.join(this.workingdir, 'download'),
LIVE_COMPOSITOR_API_PORT: this.port.toString(),
LIVE_COMPOSITOR_WEB_RENDERER_ENABLE: this.enableWebRenderer ? 'true' : 'false',
// silence scene updates logging
LIVE_COMPOSITOR_LOGGER_LEVEL:
'info,wgpu_hal=warn,wgpu_core=warn,compositor_pipeline::pipeline=warn',
Expand Down Expand Up @@ -81,10 +85,10 @@ class LocallySpawnedInstance implements CompositorManager {
}
}

async function prepareExecutable(): Promise<string> {
const downloadDir = path.join(os.homedir(), '.live_compositor', VERSION, architecture());
async function prepareExecutable(enableWebRenderer?: boolean): Promise<string> {
const version = enableWebRenderer ? `${VERSION}-web` : VERSION;
const downloadDir = path.join(os.homedir(), '.live_compositor', version, architecture());
const readyFilePath = path.join(downloadDir, '.ready');
// TODO: make sure it works on all platforms and variants
const executablePath = path.join(downloadDir, 'live_compositor/live_compositor');

if (await fs.pathExists(readyFilePath)) {
Expand All @@ -96,7 +100,7 @@ async function prepareExecutable(): Promise<string> {
if (await fs.pathExists(tarGzPath)) {
await fs.remove(tarGzPath);
}
await download(compositorTarGzUrl(), tarGzPath);
await download(compositorTarGzUrl(enableWebRenderer), tarGzPath);

await tar.x({
file: tarGzPath,
Expand All @@ -122,8 +126,10 @@ function architecture(): 'linux_aarch64' | 'linux_x86_64' | 'darwin_x86_64' | 'd
}
}

function compositorTarGzUrl(): string {
return `https://github.com/software-mansion/live-compositor/releases/download/${VERSION}/live_compositor_${architecture()}.tar.gz`;
function compositorTarGzUrl(withWebRenderer?: boolean): string {
const archiveNameSuffix = withWebRenderer ? '_with_web_renderer' : '';
const archiveName = `live_compositor${archiveNameSuffix}_${architecture()}.tar.gz`;
return `https://github.com/software-mansion/live-compositor/releases/download/${VERSION}/${archiveName}`;
}

export default LocallySpawnedInstance;
2 changes: 1 addition & 1 deletion ts/create-live-compositor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-live-compositor",
"version": "0.1.0-rc.6",
"version": "0.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"build": "tsc"
},
"dependencies": {
"@live-compositor/node": "0.1.0-rc.5",
"@live-compositor/node": "^0.1.0",
"@reduxjs/toolkit": "^2.2.7",
"express": "^4.21.0",
"live-compositor": "0.1.0-rc.5",
"live-compositor": "^0.1.0",
"react": "^18.3.1",
"react-redux": "^9.1.2"
},
Expand Down
4 changes: 2 additions & 2 deletions ts/create-live-compositor/templates/node-minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"build": "tsc"
},
"dependencies": {
"@live-compositor/node": "0.1.0-rc.5",
"live-compositor": "0.1.0-rc.5",
"@live-compositor/node": "^0.1.0",
"live-compositor": "^0.1.0",
"react": "^18.3.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions ts/examples/node-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"author": "",
"license": "MIT",
"dependencies": {
"@live-compositor/node": "0.1.0-rc.5",
"@live-compositor/node": "^0.1.0",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.14.10",
"fs-extra": "^11.2.0",
"live-compositor": "0.1.0-rc.5",
"live-compositor": "^0.1.0",
"node-fetch": "^2.6.7",
"ts-node": "^10.9.2"
}
Expand Down
2 changes: 1 addition & 1 deletion ts/examples/vite-browser-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"preview": "vite preview"
},
"dependencies": {
"@live-compositor/browser-render": "0.1.0-rc.4",
"@live-compositor/browser-render": "^0.1.0-rc.4",
"mp4box": "^0.5.2",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
2 changes: 1 addition & 1 deletion ts/live-compositor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "live-compositor",
"version": "0.1.0-rc.5",
"version": "0.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
30 changes: 15 additions & 15 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8e63da3

Please sign in to comment.