@aptre/bldr-saucer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +44 -0
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/index.js +106 -0
- package/install.js +95 -0
- package/package.json +48 -0
- package/src/fetch_proto.cpp +379 -0
- package/src/fetch_proto.h +70 -0
- package/src/main.cpp +90 -0
- package/src/pipe_client.cpp +228 -0
- package/src/pipe_client.h +67 -0
- package/src/pipe_connection.h +67 -0
- package/src/scheme_forwarder.cpp +173 -0
- package/src/scheme_forwarder.h +36 -0
package/CMakeLists.txt
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.16)
|
|
2
|
+
project(bldr_saucer LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 23)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
7
|
+
|
|
8
|
+
# Dependency source directories (default to go mod vendor paths).
|
|
9
|
+
if(NOT DEFINED SAUCER_SOURCE_DIR)
|
|
10
|
+
set(SAUCER_SOURCE_DIR "${CMAKE_SOURCE_DIR}/vendor/github.com/aperturerobotics/saucer")
|
|
11
|
+
endif()
|
|
12
|
+
if(NOT DEFINED YAMUX_SOURCE_DIR)
|
|
13
|
+
set(YAMUX_SOURCE_DIR "${CMAKE_SOURCE_DIR}/vendor/github.com/aperturerobotics/cpp-yamux")
|
|
14
|
+
endif()
|
|
15
|
+
|
|
16
|
+
# Saucer options.
|
|
17
|
+
set(saucer_static ON CACHE BOOL "" FORCE)
|
|
18
|
+
set(saucer_serializer "Glaze" CACHE STRING "" FORCE)
|
|
19
|
+
set(saucer_no_version_check ON CACHE BOOL "" FORCE)
|
|
20
|
+
set(saucer_examples OFF CACHE BOOL "" FORCE)
|
|
21
|
+
set(saucer_tests OFF CACHE BOOL "" FORCE)
|
|
22
|
+
|
|
23
|
+
# cpp-yamux options.
|
|
24
|
+
set(YAMUX_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
25
|
+
|
|
26
|
+
add_subdirectory(${SAUCER_SOURCE_DIR} ${CMAKE_BINARY_DIR}/_deps/saucer)
|
|
27
|
+
add_subdirectory(${YAMUX_SOURCE_DIR} ${CMAKE_BINARY_DIR}/_deps/yamux)
|
|
28
|
+
|
|
29
|
+
add_executable(bldr-saucer
|
|
30
|
+
src/main.cpp
|
|
31
|
+
src/pipe_client.cpp
|
|
32
|
+
src/fetch_proto.cpp
|
|
33
|
+
src/scheme_forwarder.cpp
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
target_link_libraries(bldr-saucer PRIVATE saucer::saucer yamux)
|
|
37
|
+
target_compile_features(bldr-saucer PRIVATE cxx_std_23)
|
|
38
|
+
|
|
39
|
+
# Platform-specific socket libraries.
|
|
40
|
+
if(WIN32)
|
|
41
|
+
target_link_libraries(bldr-saucer PRIVATE ws2_32)
|
|
42
|
+
endif()
|
|
43
|
+
|
|
44
|
+
install(TARGETS bldr-saucer RUNTIME DESTINATION bin)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aperture Robotics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# bldr-saucer
|
|
2
|
+
|
|
3
|
+
Native webview bridge for Bldr using [Saucer](https://github.com/saucer/saucer).
|
|
4
|
+
|
|
5
|
+
## Building from Source
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- CMake 3.16+
|
|
10
|
+
- Ninja (recommended)
|
|
11
|
+
- C++23 compatible compiler
|
|
12
|
+
- OpenSSL 3.x
|
|
13
|
+
- Platform-specific webview dependencies (see Saucer docs)
|
|
14
|
+
|
|
15
|
+
### macOS
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
brew install cmake ninja openssl@3
|
|
19
|
+
cmake -G Ninja -B build
|
|
20
|
+
cmake --build build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Linux
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
sudo apt-get install cmake ninja-build libssl-dev libgtk-3-dev libwebkit2gtk-4.1-dev
|
|
27
|
+
cmake -G Ninja -B build
|
|
28
|
+
cmake --build build
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Windows
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cmake -G Ninja -B build
|
|
35
|
+
cmake --build build
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## NPM Package
|
|
39
|
+
|
|
40
|
+
This project is distributed as an npm package with prebuilt binaries:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install @aptre/bldr-saucer
|
|
44
|
+
# or
|
|
45
|
+
bun add @aptre/bldr-saucer
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Repository
|
|
49
|
+
|
|
50
|
+
https://github.com/aperturerobotics/bldr-saucer
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const os = require("os");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the path to the bldr-saucer binary.
|
|
7
|
+
*
|
|
8
|
+
* Tries platform-specific npm package first, then falls back to
|
|
9
|
+
* source-built binary if BLDR_SAUCER_FROM_SOURCE is set or binary
|
|
10
|
+
* doesn't exist.
|
|
11
|
+
*
|
|
12
|
+
* @returns {string} Path to the bldr-saucer binary
|
|
13
|
+
* @throws {Error} If no binary is found
|
|
14
|
+
*/
|
|
15
|
+
function getBinaryPath() {
|
|
16
|
+
// Check for forced source build
|
|
17
|
+
if (process.env.BLDR_SAUCER_FROM_SOURCE === "true") {
|
|
18
|
+
return getSourceBinaryPath();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Try platform-specific package
|
|
22
|
+
const platformBinary = getPlatformBinaryPath();
|
|
23
|
+
if (platformBinary && fs.existsSync(platformBinary)) {
|
|
24
|
+
return platformBinary;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Fallback to source-built binary
|
|
28
|
+
const sourceBinary = getSourceBinaryPath();
|
|
29
|
+
if (sourceBinary && fs.existsSync(sourceBinary)) {
|
|
30
|
+
return sourceBinary;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
throw new Error(
|
|
34
|
+
`bldr-saucer binary not found for platform ${os.platform()}-${os.arch()}. ` +
|
|
35
|
+
`Try running with BLDR_SAUCER_FROM_SOURCE=true to build from source.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get the platform-specific package binary path.
|
|
41
|
+
* @returns {string|null}
|
|
42
|
+
*/
|
|
43
|
+
function getPlatformBinaryPath() {
|
|
44
|
+
const platform = os.platform();
|
|
45
|
+
const arch = os.arch();
|
|
46
|
+
|
|
47
|
+
let packageName;
|
|
48
|
+
switch (`${platform}-${arch}`) {
|
|
49
|
+
case "darwin-arm64":
|
|
50
|
+
packageName = "@aptre/bldr-saucer-darwin-arm64";
|
|
51
|
+
break;
|
|
52
|
+
case "darwin-x64":
|
|
53
|
+
packageName = "@aptre/bldr-saucer-darwin-x64";
|
|
54
|
+
break;
|
|
55
|
+
case "linux-x64":
|
|
56
|
+
packageName = "@aptre/bldr-saucer-linux-x64";
|
|
57
|
+
break;
|
|
58
|
+
case "linux-arm64":
|
|
59
|
+
packageName = "@aptre/bldr-saucer-linux-arm64";
|
|
60
|
+
break;
|
|
61
|
+
case "win32-x64":
|
|
62
|
+
packageName = "@aptre/bldr-saucer-win32-x64";
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const packagePath = require.resolve(`${packageName}/package.json`);
|
|
70
|
+
const binDir = path.join(path.dirname(packagePath), "bin");
|
|
71
|
+
const binaryName = platform === "win32" ? "bldr-saucer.exe" : "bldr-saucer";
|
|
72
|
+
return path.join(binDir, binaryName);
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get the source-built binary path.
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
function getSourceBinaryPath() {
|
|
83
|
+
const platform = os.platform();
|
|
84
|
+
const binaryName = platform === "win32" ? "bldr-saucer.exe" : "bldr-saucer";
|
|
85
|
+
return path.join(__dirname, "build", binaryName);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Check if the binary exists.
|
|
90
|
+
* @returns {boolean}
|
|
91
|
+
*/
|
|
92
|
+
function hasBinary() {
|
|
93
|
+
try {
|
|
94
|
+
getBinaryPath();
|
|
95
|
+
return true;
|
|
96
|
+
} catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = {
|
|
102
|
+
getBinaryPath,
|
|
103
|
+
getPlatformBinaryPath,
|
|
104
|
+
getSourceBinaryPath,
|
|
105
|
+
hasBinary,
|
|
106
|
+
};
|
package/install.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
|
|
8
|
+
// Skip if binary exists and we're not forcing source build
|
|
9
|
+
if (process.env.BLDR_SAUCER_SKIP_BINARY === "true") {
|
|
10
|
+
console.log("bldr-saucer: Skipping install (BLDR_SAUCER_SKIP_BINARY=true)");
|
|
11
|
+
process.exit(0);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Check if platform binary exists
|
|
15
|
+
const { getPlatformBinaryPath } = require("./index.js");
|
|
16
|
+
const platformBinary = getPlatformBinaryPath();
|
|
17
|
+
if (platformBinary && fs.existsSync(platformBinary)) {
|
|
18
|
+
console.log("bldr-saucer: Using prebuilt binary");
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Check for forced source build
|
|
23
|
+
if (process.env.BLDR_SAUCER_FROM_SOURCE !== "true") {
|
|
24
|
+
console.log(
|
|
25
|
+
"bldr-saucer: No prebuilt binary for this platform. " +
|
|
26
|
+
"Set BLDR_SAUCER_FROM_SOURCE=true to build from source."
|
|
27
|
+
);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log("bldr-saucer: Building from source...");
|
|
32
|
+
|
|
33
|
+
// Check for required tools
|
|
34
|
+
function hasCommand(cmd) {
|
|
35
|
+
try {
|
|
36
|
+
execFileSync("which", [cmd], { stdio: "ignore" });
|
|
37
|
+
return true;
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!hasCommand("cmake")) {
|
|
44
|
+
console.error("bldr-saucer: cmake is required but not found");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!hasCommand("ninja")) {
|
|
49
|
+
console.error("bldr-saucer: ninja is required but not found");
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const srcDir = __dirname;
|
|
54
|
+
const buildDir = path.join(srcDir, "build");
|
|
55
|
+
|
|
56
|
+
// Create build directory
|
|
57
|
+
if (!fs.existsSync(buildDir)) {
|
|
58
|
+
fs.mkdirSync(buildDir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Run CMake configure
|
|
62
|
+
console.log("bldr-saucer: Configuring...");
|
|
63
|
+
try {
|
|
64
|
+
execFileSync("cmake", ["-G", "Ninja", "-B", "build"], {
|
|
65
|
+
cwd: srcDir,
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
});
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error("bldr-saucer: CMake configure failed");
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Run CMake build
|
|
74
|
+
console.log("bldr-saucer: Building...");
|
|
75
|
+
try {
|
|
76
|
+
execFileSync("cmake", ["--build", "build"], {
|
|
77
|
+
cwd: srcDir,
|
|
78
|
+
stdio: "inherit",
|
|
79
|
+
});
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error("bldr-saucer: CMake build failed");
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Verify binary exists
|
|
86
|
+
const platform = os.platform();
|
|
87
|
+
const binaryName = platform === "win32" ? "bldr-saucer.exe" : "bldr-saucer";
|
|
88
|
+
const binaryPath = path.join(buildDir, binaryName);
|
|
89
|
+
|
|
90
|
+
if (!fs.existsSync(binaryPath)) {
|
|
91
|
+
console.error(`bldr-saucer: Binary not found at ${binaryPath}`);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log("bldr-saucer: Build successful!");
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aptre/bldr-saucer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Native webview bridge for Bldr using Saucer",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/aperturerobotics/bldr-saucer.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"webview",
|
|
12
|
+
"saucer",
|
|
13
|
+
"native",
|
|
14
|
+
"bldr"
|
|
15
|
+
],
|
|
16
|
+
"author": "Aptre",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/aperturerobotics/bldr-saucer/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/aperturerobotics/bldr-saucer#readme",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"postinstall": "node install.js",
|
|
24
|
+
"gen": "bun run go:aptre -- generate",
|
|
25
|
+
"gen:force": "bun run go:aptre -- generate --force",
|
|
26
|
+
"go:aptre": "go run -mod=mod github.com/aperturerobotics/common/cmd/aptre"
|
|
27
|
+
},
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"@aptre/bldr-saucer-darwin-arm64": "0.1.0",
|
|
30
|
+
"@aptre/bldr-saucer-darwin-x64": "0.1.0",
|
|
31
|
+
"@aptre/bldr-saucer-linux-x64": "0.1.0",
|
|
32
|
+
"@aptre/bldr-saucer-linux-arm64": "0.1.0",
|
|
33
|
+
"@aptre/bldr-saucer-win32-x64": "0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"index.js",
|
|
37
|
+
"install.js",
|
|
38
|
+
"src/**/*",
|
|
39
|
+
"cmake/**/*",
|
|
40
|
+
"CMakeLists.txt"
|
|
41
|
+
],
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@aptre/common": "^0.30.1"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@aptre/protobuf-es-lite": "^0.5.2"
|
|
47
|
+
}
|
|
48
|
+
}
|