Skip to content

Commit

Permalink
Disable debugging, publish to npm
Browse files Browse the repository at this point in the history
  • Loading branch information
theseyan committed Dec 27, 2022
1 parent 49755e2 commit 7b1fbc6
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ deps.zig
gyro.lock
*/zig-cache
dev.sh
test.js
test.js
build
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
zig-out
zig-cache
.vscode
.zigmod
deps.zig
.gyro
gyro.lock
*/zig-cache
dev.sh
test.js
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ git submodule update --init --recursive
# Build
zig build -Drelease-fast

# Move to build/ folder. Your binary name will differ based on OS/CPU.
mkdir build && mv zig-out/bin/bunview-x86_64-linux ./build/bunview-x86_64-linux

# Run example (must have Bun installed)
bun examples/main.js
```
11 changes: 10 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("bunview", "src/main.zig");
const os = target.getOs().tag;
const arch = target.getCpuArch();

var name: []const u8 = undefined;
if(os == .linux and arch == .x86_64) { name = "bunview-x86_64-linux"; }
else if(os == .linux and arch == .aarch64) { name = "bunview-aarch64-linux"; }
else if(os == .macos and arch == .x86_64) { name = "bunview-x86_64-macos"; }
else if(os == .macos and arch == .aarch64) { name = "bunview-aarch64-macos"; }

const exe = b.addExecutable(name, "src/main.zig");

// Link libc and libc++
//exe.linkLibC();
Expand Down
13 changes: 11 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import EventEmitter from 'events';
import { spawn } from "bun";

// Toggle debug logging
const DEBUG = true;
const DEBUG = false;

export const SizeHint = {
// Width and height are default size
Expand All @@ -19,8 +19,17 @@ export const SizeHint = {
FIXED: 3,
};

var TARGET_TRIPLE;
switch(process.arch + "-" + process.platform) {
case 'x64-linux': { TARGET_TRIPLE = "x86_64-linux"; break; }
case 'arm64-linux': { TARGET_TRIPLE = "aarch64-linux"; break; }
case 'x64-darwin': { TARGET_TRIPLE = "x86_64-macos"; break; }
case 'arm64-darwin': { TARGET_TRIPLE = "aarch64-macos"; break; }
default: throw new Error("Unsupported CPU/OS");
}

// Path to bunview server
const EXE_PATH = __dirname + '/../zig-out/bin/bunview';
const EXE_PATH = __dirname + `/../build/bunview-${TARGET_TRIPLE}`;

/**
* Window Class
Expand Down
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "bunview",
"version": "0.0.2",
"description": "Complete webview bindings for Bun",
"main": "lib/index.js",
"directories": {
"example": "examples",
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/theseyan/bunview.git"
},
"files": [
"build",
"lib"
],
"keywords": [
"webview",
"bun",
"gui",
"desktop-application"
],
"author": "Sayan J. Das",
"license": "MIT",
"bugs": {
"url": "https://github.com/theseyan/bunview/issues"
},
"homepage": "https://github.com/theseyan/bunview#readme"
}

0 comments on commit 7b1fbc6

Please sign in to comment.