reactor-effect-native 0.0.0-reserved.0 → 0.2.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/Dockerfile +38 -0
- package/LICENSE +201 -0
- package/NOTICE +28 -0
- package/README.md +106 -2
- package/dist/_internal/bridge.d.ts +49 -0
- package/dist/_internal/bridge.d.ts.map +1 -0
- package/dist/_internal/bridge.js +452 -0
- package/dist/_internal/bridge.js.map +1 -0
- package/dist/_internal/peer.d.ts +57 -0
- package/dist/_internal/peer.d.ts.map +1 -0
- package/dist/_internal/peer.js +479 -0
- package/dist/_internal/peer.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/lib/darwin-arm64/libreactor_effect_native.dylib +0 -0
- package/lib/darwin-arm64/native-identity.json +18 -0
- package/lib/linux-x64/libreactor_effect_native.so +0 -0
- package/lib/linux-x64/native-identity.json +20 -0
- package/notices/effect-LICENSE +21 -0
- package/notices/native-rust/NOTICE.md +27 -0
- package/notices/native-rust/bytes-1.12.1-LICENSE +25 -0
- package/notices/native-rust/itoa-1.0.18-LICENSE-APACHE +176 -0
- package/notices/native-rust/memchr-2.8.3-LICENSE-MIT +21 -0
- package/notices/native-rust/prost-0.13.5-LICENSE +201 -0
- package/notices/native-rust/serde-1.0.229-LICENSE-APACHE +176 -0
- package/notices/native-rust/serde_json-1.0.151-LICENSE-APACHE +176 -0
- package/notices/native-rust/zmij-1.0.23-LICENSE-MIT +23 -0
- package/notices/reactor-webrtc/WebRTC-LICENSE +29 -0
- package/notices/reactor-webrtc/WebRTC-PATENTS +24 -0
- package/notices/reactor-webrtc/reactor-webrtc-linux-x64-release.sbom.json +660 -0
- package/notices/reactor-webrtc/reactor-webrtc-mac-arm64-release.sbom.json +631 -0
- package/notices/reactor-webrtc/third-party/README.md +58 -0
- package/notices/reactor-webrtc/third-party/abseil-cpp/LICENSE +203 -0
- package/notices/reactor-webrtc/third-party/abseil-cpp/README.chromium +55 -0
- package/notices/reactor-webrtc/third-party/boringssl/LICENSE +238 -0
- package/notices/reactor-webrtc/third-party/boringssl/README.chromium +15 -0
- package/notices/reactor-webrtc/third-party/compiler-rt/LICENSE.TXT +311 -0
- package/notices/reactor-webrtc/third-party/compiler-rt/README.chromium +15 -0
- package/notices/reactor-webrtc/third-party/cpuinfo/LICENSE +27 -0
- package/notices/reactor-webrtc/third-party/cpuinfo/README.chromium +15 -0
- package/notices/reactor-webrtc/third-party/dav1d/LICENSE +23 -0
- package/notices/reactor-webrtc/third-party/dav1d/README.chromium +40 -0
- package/notices/reactor-webrtc/third-party/farmhash/LICENSE +19 -0
- package/notices/reactor-webrtc/third-party/farmhash/README.chromium +21 -0
- package/notices/reactor-webrtc/third-party/fft2d/LICENSE +3 -0
- package/notices/reactor-webrtc/third-party/fft2d/README.chromium +24 -0
- package/notices/reactor-webrtc/third-party/flatbuffers/LICENSE +202 -0
- package/notices/reactor-webrtc/third-party/flatbuffers/README.chromium +18 -0
- package/notices/reactor-webrtc/third-party/fp16/LICENSE +12 -0
- package/notices/reactor-webrtc/third-party/fp16/README.chromium +16 -0
- package/notices/reactor-webrtc/third-party/fxdiv/LICENSE +10 -0
- package/notices/reactor-webrtc/third-party/fxdiv/README.chromium +16 -0
- package/notices/reactor-webrtc/third-party/gemmlowp/LICENSE +202 -0
- package/notices/reactor-webrtc/third-party/gemmlowp/README.chromium +14 -0
- package/notices/reactor-webrtc/third-party/grpc/LICENSE +610 -0
- package/notices/reactor-webrtc/third-party/grpc/README.chromium +30 -0
- package/notices/reactor-webrtc/third-party/jsoncpp/LICENSE +55 -0
- package/notices/reactor-webrtc/third-party/jsoncpp/README.chromium +20 -0
- package/notices/reactor-webrtc/third-party/libaom/LICENSE +27 -0
- package/notices/reactor-webrtc/third-party/libaom/PATENTS +108 -0
- package/notices/reactor-webrtc/third-party/libaom/README.chromium +61 -0
- package/notices/reactor-webrtc/third-party/libgav1/LICENSE +202 -0
- package/notices/reactor-webrtc/third-party/libgav1/README.chromium +33 -0
- package/notices/reactor-webrtc/third-party/libjpeg_turbo/LICENSE.md.chromium +236 -0
- package/notices/reactor-webrtc/third-party/libjpeg_turbo/README.chromium +66 -0
- package/notices/reactor-webrtc/third-party/libsrtp/LICENSE +35 -0
- package/notices/reactor-webrtc/third-party/libsrtp/README.chromium +17 -0
- package/notices/reactor-webrtc/third-party/libvpx/LICENSE +31 -0
- package/notices/reactor-webrtc/third-party/libvpx/PATENTS +23 -0
- package/notices/reactor-webrtc/third-party/libvpx/README.chromium +73 -0
- package/notices/reactor-webrtc/third-party/libyuv/LICENSE +29 -0
- package/notices/reactor-webrtc/third-party/libyuv/README.chromium +13 -0
- package/notices/reactor-webrtc/third-party/neon_2_sse/LICENSE +29 -0
- package/notices/reactor-webrtc/third-party/neon_2_sse/README.chromium +21 -0
- package/notices/reactor-webrtc/third-party/opus/COPYING +44 -0
- package/notices/reactor-webrtc/third-party/opus/README.chromium +41 -0
- package/notices/reactor-webrtc/third-party/perfetto/LICENSE +285 -0
- package/notices/reactor-webrtc/third-party/perfetto/README.chromium +12 -0
- package/notices/reactor-webrtc/third-party/pffft/LICENSE +45 -0
- package/notices/reactor-webrtc/third-party/pffft/README.chromium +43 -0
- package/notices/reactor-webrtc/third-party/protobuf/LICENSE +32 -0
- package/notices/reactor-webrtc/third-party/protobuf/README.chromium +325 -0
- package/notices/reactor-webrtc/third-party/pthreadpool/LICENSE +26 -0
- package/notices/reactor-webrtc/third-party/pthreadpool/README.chromium +19 -0
- package/notices/reactor-webrtc/third-party/re2/LICENSE +27 -0
- package/notices/reactor-webrtc/third-party/re2/README.chromium +15 -0
- package/notices/reactor-webrtc/third-party/rnnoise/COPYING +31 -0
- package/notices/reactor-webrtc/third-party/rnnoise/README.chromium +30 -0
- package/notices/reactor-webrtc/third-party/ruy/LICENSE +202 -0
- package/notices/reactor-webrtc/third-party/ruy/README.chromium +20 -0
- package/notices/reactor-webrtc/third-party/tflite/LICENSE +203 -0
- package/notices/reactor-webrtc/third-party/tflite/README.chromium +22 -0
- package/notices/reactor-webrtc/third-party/xnnpack/LICENSE +31 -0
- package/notices/reactor-webrtc/third-party/xnnpack/README.chromium +18 -0
- package/notices/reactor-webrtc/third-party/zlib/LICENSE +22 -0
- package/notices/reactor-webrtc/third-party/zlib/README.chromium +38 -0
- package/notices/reactor-webrtc-LICENSE +201 -0
- package/notices/reactor-webrtc-NOTICE.md +32 -0
- package/package.json +54 -4
- package/rust/.cargo/config.toml +5 -0
- package/rust/Cargo.lock +208 -0
- package/rust/Cargo.toml +19 -0
- package/rust/build.rs +159 -0
- package/rust/include/reactor_effect_native.h +118 -0
- package/rust/src/lib.rs +2343 -0
- package/scripts/build.sh +35 -0
- package/scripts/install-linux-toolchain.sh +47 -0
- package/scripts/stage.mjs +107 -0
- package/scripts/stage.sh +31 -0
package/scripts/build.sh
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
5
|
+
cd "$root"
|
|
6
|
+
|
|
7
|
+
if [ "$(uname -s)" = Linux ]; then
|
|
8
|
+
cc=${CC:-clang-21}
|
|
9
|
+
cxx=${CXX:-clang++-21}
|
|
10
|
+
command -v "$cc" >/dev/null 2>&1 || {
|
|
11
|
+
echo "native-linux-toolchain-missing: C compiler '$cc' not found; set CC/CXX explicitly or opt in to scripts/install-linux-toolchain.sh in a supported Docker/CI environment" >&2
|
|
12
|
+
exit 2
|
|
13
|
+
}
|
|
14
|
+
command -v "$cxx" >/dev/null 2>&1 || {
|
|
15
|
+
echo "native-linux-toolchain-missing: C++ compiler '$cxx' not found; set CC/CXX explicitly or opt in to scripts/install-linux-toolchain.sh in a supported Docker/CI environment" >&2
|
|
16
|
+
exit 2
|
|
17
|
+
}
|
|
18
|
+
"$cc" --version >/dev/null 2>&1 || { echo "native-linux-toolchain-invalid: CC '$cc' cannot execute" >&2; exit 2; }
|
|
19
|
+
"$cxx" --version >/dev/null 2>&1 || { echo "native-linux-toolchain-invalid: CXX '$cxx' cannot execute" >&2; exit 2; }
|
|
20
|
+
export CC="$cc" CXX="$cxx"
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Cargo discovers configuration from its working directory, not --manifest-path.
|
|
24
|
+
cargo build --config "$root/rust/.cargo/config.toml" --locked --manifest-path "$root/rust/Cargo.toml" --release
|
|
25
|
+
|
|
26
|
+
case "$(uname -s)-$(uname -m)" in
|
|
27
|
+
Darwin-arm64) platform=darwin-arm64; library=libreactor_effect_native.dylib ;;
|
|
28
|
+
Darwin-x86_64) platform=darwin-x64; library=libreactor_effect_native.dylib ;;
|
|
29
|
+
Linux-x86_64) platform=linux-x64; library=libreactor_effect_native.so ;;
|
|
30
|
+
Linux-aarch64|Linux-arm64) platform=linux-arm64; library=libreactor_effect_native.so ;;
|
|
31
|
+
*) echo "unsupported native build host: $(uname -s)-$(uname -m)" >&2; exit 2 ;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
target=${CARGO_TARGET_DIR:-$root/rust/target}
|
|
35
|
+
"$root/scripts/stage.sh" "$target/release/$library" "$platform"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
expected_fingerprint=6084F3CF814B57C1CF12EFD515CF4D18AF4F7421
|
|
5
|
+
key_url=https://apt.llvm.org/llvm-snapshot.gpg.key
|
|
6
|
+
keyring=/usr/share/keyrings/apt.llvm.org.gpg
|
|
7
|
+
source_list=/etc/apt/sources.list.d/apt.llvm.org.list
|
|
8
|
+
|
|
9
|
+
die() {
|
|
10
|
+
echo "reactor-native-linux-toolchain: $*" >&2
|
|
11
|
+
exit 2
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[ "$(id -u)" -eq 0 ] || die "must run as root; this installer is opt-in for Docker/CI and never invokes sudo itself"
|
|
15
|
+
[ -r /etc/os-release ] || die "cannot identify Linux distribution: /etc/os-release is unavailable"
|
|
16
|
+
|
|
17
|
+
# shellcheck disable=SC1091
|
|
18
|
+
. /etc/os-release
|
|
19
|
+
case "${ID:-}:${VERSION_CODENAME:-}" in
|
|
20
|
+
debian:bookworm) suite=bookworm ;;
|
|
21
|
+
ubuntu:noble) suite=noble ;;
|
|
22
|
+
*) die "unsupported distribution ${ID:-unknown}:${VERSION_CODENAME:-unknown}; supported: Debian 12 bookworm, Ubuntu 24.04 noble" ;;
|
|
23
|
+
esac
|
|
24
|
+
|
|
25
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
26
|
+
apt-get update
|
|
27
|
+
apt-get install -y --no-install-recommends ca-certificates curl gnupg
|
|
28
|
+
|
|
29
|
+
tmp=$(mktemp -d)
|
|
30
|
+
trap 'rm -rf "$tmp"' EXIT HUP INT TERM
|
|
31
|
+
curl --fail --silent --show-error --location "$key_url" --output "$tmp/llvm-snapshot.gpg.key"
|
|
32
|
+
|
|
33
|
+
actual_fingerprint=$(gpg --batch --with-colons --show-keys --fingerprint "$tmp/llvm-snapshot.gpg.key" \
|
|
34
|
+
| awk -F: '$1 == "fpr" { print toupper($10); exit }')
|
|
35
|
+
[ "$actual_fingerprint" = "$expected_fingerprint" ] \
|
|
36
|
+
|| die "apt.llvm.org signing-key fingerprint mismatch: expected $expected_fingerprint, got ${actual_fingerprint:-missing}"
|
|
37
|
+
|
|
38
|
+
mkdir -p "$(dirname "$keyring")" "$(dirname "$source_list")"
|
|
39
|
+
gpg --batch --yes --dearmor --output "$keyring" "$tmp/llvm-snapshot.gpg.key"
|
|
40
|
+
chmod 0644 "$keyring"
|
|
41
|
+
printf 'deb [signed-by=%s] https://apt.llvm.org/%s/ llvm-toolchain-%s-21 main\n' "$keyring" "$suite" "$suite" > "$source_list"
|
|
42
|
+
|
|
43
|
+
apt-get update
|
|
44
|
+
apt-get install -y --no-install-recommends clang-21
|
|
45
|
+
|
|
46
|
+
clang-21 --version
|
|
47
|
+
clang++-21 --version
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
7
|
+
const prefix = "reactor-effect-native:build-identity:";
|
|
8
|
+
const suffix = ":end\0";
|
|
9
|
+
/** @param {Uint8Array} bytes */
|
|
10
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
11
|
+
|
|
12
|
+
/** @param {string} directory @param {string} [prefix] @returns {string[]} */
|
|
13
|
+
const sources = (directory, prefix = "") =>
|
|
14
|
+
readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
15
|
+
const relative = `${prefix}${entry.name}`;
|
|
16
|
+
return entry.isDirectory()
|
|
17
|
+
? sources(join(directory, entry.name), `${relative}/`)
|
|
18
|
+
: entry.isFile()
|
|
19
|
+
? [relative]
|
|
20
|
+
: [];
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const sourceHash = () => {
|
|
24
|
+
const native = join(root, "rust");
|
|
25
|
+
const files = [
|
|
26
|
+
"Cargo.toml",
|
|
27
|
+
"Cargo.lock",
|
|
28
|
+
"build.rs",
|
|
29
|
+
".cargo/config.toml",
|
|
30
|
+
"include/reactor_effect_native.h",
|
|
31
|
+
...sources(join(native, "src"), "src/"),
|
|
32
|
+
].sort();
|
|
33
|
+
const hash = createHash("sha256");
|
|
34
|
+
for (const file of files)
|
|
35
|
+
hash
|
|
36
|
+
.update(file)
|
|
37
|
+
.update("\0")
|
|
38
|
+
.update(readFileSync(join(native, file)))
|
|
39
|
+
.update("\0");
|
|
40
|
+
return hash.digest("hex");
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const targets = /** @type {const} */ ({
|
|
44
|
+
"darwin-arm64": ["aarch64-apple-darwin", "libreactor_effect_native.dylib"],
|
|
45
|
+
"darwin-x64": ["x86_64-apple-darwin", "libreactor_effect_native.dylib"],
|
|
46
|
+
"linux-x64": ["x86_64-unknown-linux-gnu", "libreactor_effect_native.so"],
|
|
47
|
+
"linux-arm64": ["aarch64-unknown-linux-gnu", "libreactor_effect_native.so"],
|
|
48
|
+
"win32-x64": ["x86_64-pc-windows-msvc", "reactor_effect_native.dll"],
|
|
49
|
+
"win32-arm64": ["aarch64-pc-windows-msvc", "reactor_effect_native.dll"],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const [input, platform] = process.argv.slice(2);
|
|
53
|
+
if (input === "--source-hash" && platform === undefined) {
|
|
54
|
+
// CI keys its staged-artifact cache on this identity; a cached library whose
|
|
55
|
+
// embedded identity differs is rejected by the staging check below.
|
|
56
|
+
console.log(sourceHash());
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
if (input === undefined || platform === undefined || !(platform in targets)) {
|
|
60
|
+
throw new Error("usage: scripts/stage.mjs <shared-library> <supported-platform-arch>");
|
|
61
|
+
}
|
|
62
|
+
const [target, library] = targets[/** @type {keyof typeof targets} */ (platform)];
|
|
63
|
+
const source = isAbsolute(input) ? input : resolve(root, input);
|
|
64
|
+
const bytes = readFileSync(source);
|
|
65
|
+
const start = bytes.indexOf(prefix);
|
|
66
|
+
const end = start < 0 ? -1 : bytes.indexOf(suffix, start + prefix.length);
|
|
67
|
+
if (start < 0 || end < 0 || bytes.indexOf(prefix, end + suffix.length) !== -1) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
"native staging requires exactly one embedded source/build identity; rebuild the native library",
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const build = JSON.parse(bytes.subarray(start + prefix.length, end).toString("utf8"));
|
|
73
|
+
if (
|
|
74
|
+
build.schemaVersion !== 1 ||
|
|
75
|
+
build.abiVersion !== 2 ||
|
|
76
|
+
build.profile !== "release" ||
|
|
77
|
+
build.target !== target
|
|
78
|
+
) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"native artifact ABI, release profile or target does not match the requested package platform",
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const expected = sourceHash();
|
|
84
|
+
if (build.sourceSha256 !== expected) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`native source identity mismatch: artifact ${build.sourceSha256}; current sources ${expected}; rebuild before staging`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const manifest = { schemaVersion: 1, platform, library, sha256: sha256(bytes), build };
|
|
90
|
+
const destination = join(root, "lib", platform, library);
|
|
91
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
92
|
+
// Readers verify both files, so an interrupted staging operation fails closed.
|
|
93
|
+
// Rename each complete file rather than exposing a partially copied library.
|
|
94
|
+
const temporary = `${destination}.${process.pid}.stage`;
|
|
95
|
+
writeFileSync(temporary, bytes);
|
|
96
|
+
renameSync(temporary, destination);
|
|
97
|
+
const identity = join(dirname(destination), "native-identity.json");
|
|
98
|
+
writeFileSync(`${identity}.${process.pid}.stage`, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
99
|
+
renameSync(`${identity}.${process.pid}.stage`, identity);
|
|
100
|
+
console.log(
|
|
101
|
+
JSON.stringify({
|
|
102
|
+
artifact: destination,
|
|
103
|
+
identity,
|
|
104
|
+
sha256: manifest.sha256,
|
|
105
|
+
sourceSha256: expected,
|
|
106
|
+
}),
|
|
107
|
+
);
|
package/scripts/stage.sh
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
5
|
+
source_path=${1:-}
|
|
6
|
+
platform=${2:-}
|
|
7
|
+
|
|
8
|
+
if [ -z "$source_path" ] || [ -z "$platform" ]; then
|
|
9
|
+
echo "usage: scripts/stage.sh <shared-library> <platform-arch>" >&2
|
|
10
|
+
echo "example: scripts/stage.sh rust/target/release/libreactor_effect_native.dylib darwin-arm64" >&2
|
|
11
|
+
exit 2
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
case "$platform" in
|
|
15
|
+
darwin-*) library=libreactor_effect_native.dylib ;;
|
|
16
|
+
linux-*) library=libreactor_effect_native.so ;;
|
|
17
|
+
win32-*) library=reactor_effect_native.dll ;;
|
|
18
|
+
*) echo "unsupported package platform: $platform" >&2; exit 2 ;;
|
|
19
|
+
esac
|
|
20
|
+
|
|
21
|
+
case "$source_path" in
|
|
22
|
+
/*) source=$source_path ;;
|
|
23
|
+
*) source=$root/$source_path ;;
|
|
24
|
+
esac
|
|
25
|
+
|
|
26
|
+
if [ ! -f "$source" ]; then
|
|
27
|
+
echo "native library not found: $source" >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
exec "${NODE_BINARY:-node}" "$root/scripts/stage.mjs" "$source" "$platform"
|