Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/webui/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test/integration.test.js
!bin/
2 changes: 2 additions & 0 deletions packages/webui/bin/webui
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo "webui: binary not installed. Run 'pnpm build' or reinstall." >&2; exit 1
46 changes: 23 additions & 23 deletions packages/webui/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
{
"name": "@microsoft/webui",
"description": "WebUI — high-performance server-side rendering framework. Build-time protocol compiler and streaming renderer.",
"license": "MIT",
"version": "0.0.7",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/webui.git"
},
"bin": {
"webui": "bin/webui"
},
"description": "WebUI — high-performance server-side rendering framework. Build-time protocol compiler and streaming renderer.",
"devDependencies": {
"@types/node": "catalog:",
"esbuild": "catalog:",
"typescript": "catalog:"
"files": [
"bin/",
"dist/",
"wasm/"
],
"scripts": {
"build": "tsc",
"postbuild": "node dist/install.js",
"postinstall": "node --input-type=module -e \"try{await import('./dist/install.js')}catch{}\"",
"test": "tsc --project tsconfig.test.json && node --test dist/test/integration.test.js"
},
"engines": {
"node": ">=18"
Expand All @@ -19,13 +33,6 @@
}
}
},
"files": [
"bin/",
"dist/",
"wasm/"
],
"license": "MIT",
"name": "@microsoft/webui",
"optionalDependencies": {
"@microsoft/webui-darwin-arm64": "workspace:*",
"@microsoft/webui-darwin-x64": "workspace:*",
Expand All @@ -34,15 +41,8 @@
"@microsoft/webui-win32-arm64": "workspace:*",
"@microsoft/webui-win32-x64": "workspace:*"
},
"repository": {
"type": "git",
"url": "https://github.com/microsoft/webui.git"
},
"scripts": {
"build": "esbuild src/index.ts src/platform.ts src/install.ts --outdir=dist --format=esm --platform=node && tsc --emitDeclarationOnly",
"postinstall": "node --input-type=module -e \"try{await import('./dist/install.js')}catch{}\"",
"test": "esbuild test/integration.test.ts --outfile=test/integration.test.js --format=esm --platform=node && node --test test/integration.test.js"
},
"type": "module",
"version": "0.0.7"
"devDependencies": {
"@types/node": "catalog:",
"typescript": "catalog:"
}
}
18 changes: 14 additions & 4 deletions packages/webui/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
// Licensed under the MIT license.

import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { resolve, platformKey, packageName } from "./platform.js";

// Validate that the platform binary exists after install.
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const binDir = path.resolve(__dirname, "..", "bin");
const binName = process.platform === "win32" ? "webui.exe" : "webui";
const binDest = path.join(binDir, binName);

// Locate the platform binary and copy it into bin/ so the package.json
// "bin" entry points at a real native executable.
try {
const binPath = resolve("bin");
if (binPath && fs.existsSync(binPath)) {
// Success — binary is available.
const srcBin = resolve("bin");
if (srcBin && fs.existsSync(srcBin)) {
fs.mkdirSync(binDir, { recursive: true });
fs.copyFileSync(srcBin, binDest);
fs.chmodSync(binDest, 0o755);
process.exit(0);
}
} catch {
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { describe, test, before, after } from 'node:test';
import { strict as assert } from 'node:assert';
import { build, render, renderStream, inspect } from '../dist/index.js';
import { build, render, renderStream, inspect } from '@microsoft/webui';
import { writeFileSync, mkdtempSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
Expand Down
11 changes: 11 additions & 0 deletions packages/webui/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "test",
"outDir": "dist/test",
"declaration": false,
"declarationMap": false,
"sourceMap": false
},
"include": ["test"]
}
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

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

Loading