reactor-effect-native 0.2.0 → 0.3.0-rc.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 +4 -2
- package/README.md +90 -15
- package/dist/_internal/bridge.d.ts +70 -14
- package/dist/_internal/bridge.d.ts.map +1 -1
- package/dist/_internal/bridge.js +290 -145
- package/dist/_internal/bridge.js.map +1 -1
- package/dist/_internal/isolated/child.d.ts +2 -0
- package/dist/_internal/isolated/child.d.ts.map +1 -0
- package/dist/_internal/isolated/child.js +176 -0
- package/dist/_internal/isolated/child.js.map +1 -0
- package/dist/_internal/isolated/host.d.ts +147 -0
- package/dist/_internal/isolated/host.d.ts.map +1 -0
- package/dist/_internal/isolated/host.js +645 -0
- package/dist/_internal/isolated/host.js.map +1 -0
- package/dist/_internal/isolated/protocol.d.ts +399 -0
- package/dist/_internal/isolated/protocol.d.ts.map +1 -0
- package/dist/_internal/isolated/protocol.js +250 -0
- package/dist/_internal/isolated/protocol.js.map +1 -0
- package/dist/_internal/peer.d.ts +68 -13
- package/dist/_internal/peer.d.ts.map +1 -1
- package/dist/_internal/peer.js +233 -157
- package/dist/_internal/peer.js.map +1 -1
- package/dist/index.d.ts +19 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -33
- package/dist/index.js.map +1 -1
- package/dist/isolated.d.ts +25 -0
- package/dist/isolated.d.ts.map +1 -0
- package/dist/isolated.js +39 -0
- package/dist/isolated.js.map +1 -0
- package/lib/darwin-arm64/libreactor_effect_native.dylib +0 -0
- package/lib/darwin-arm64/native-identity.json +4 -3
- package/lib/linux-x64/libreactor_effect_native.so +0 -0
- package/lib/linux-x64/native-identity.json +4 -3
- package/package.json +7 -3
- package/rust/Cargo.toml +108 -2
- package/rust/build.rs +253 -114
- package/rust/clippy.toml +7 -0
- package/rust/include/reactor_effect_native.h +101 -42
- package/rust/src/abi.rs +258 -0
- package/rust/src/error.rs +149 -0
- package/rust/src/ffi/memory.rs +256 -0
- package/rust/src/ffi/tests.rs +719 -0
- package/rust/src/ffi.rs +474 -0
- package/rust/src/lib.rs +36 -2341
- package/rust/src/peer/callbacks.rs +145 -0
- package/rust/src/peer/media.rs +221 -0
- package/rust/src/peer/owner/tests.rs +188 -0
- package/rust/src/peer/owner.rs +353 -0
- package/rust/src/peer/shared.rs +323 -0
- package/rust/src/peer/tests.rs +513 -0
- package/rust/src/peer.rs +189 -0
- package/rust/src/protocol/event.rs +238 -0
- package/rust/src/protocol/request.rs +347 -0
- package/rust/src/protocol/stats.rs +356 -0
- package/rust/src/protocol.rs +71 -0
- package/rust/src/sync/gate.rs +159 -0
- package/rust/src/sync/notifier.rs +136 -0
- package/rust/src/sync/queue.rs +384 -0
- package/rust/src/sync.rs +20 -0
- package/rust/src/test_support.rs +99 -0
- package/rust-toolchain.toml +7 -0
- package/scripts/stage.mjs +41 -1
package/scripts/stage.mjs
CHANGED
|
@@ -49,6 +49,45 @@ const targets = /** @type {const} */ ({
|
|
|
49
49
|
"win32-arm64": ["aarch64-pc-windows-msvc", "reactor_effect_native.dll"],
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
/** The shipped SBOM of each platform's Reactor libwebrtc prebuilt. */
|
|
53
|
+
const sboms = /** @type {Record<string, string>} */ ({
|
|
54
|
+
"darwin-arm64": "reactor-webrtc-mac-arm64-release.sbom.json",
|
|
55
|
+
"linux-x64": "reactor-webrtc-linux-x64-release.sbom.json",
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The prebuilt the library links must be the one its notices describe: the
|
|
60
|
+
* NOTICE's tag exactly, and the platform SBOM's WebRTC milestone and commit.
|
|
61
|
+
* @param {unknown} linked @param {string} platform
|
|
62
|
+
*/
|
|
63
|
+
const checkPrebuilt = (linked, platform) => {
|
|
64
|
+
const notices = join(root, "notices");
|
|
65
|
+
const notice = readFileSync(join(notices, "reactor-webrtc-NOTICE.md"), "utf8");
|
|
66
|
+
const declared = /Reactor prebuilt tag: `([^`]+)`/.exec(notice)?.[1];
|
|
67
|
+
const pinned = /Pinned WebRTC commit: `([0-9a-f]{40})`/.exec(notice)?.[1];
|
|
68
|
+
const tag = typeof linked === "string" ? /^webrtc-(\d+)-([0-9a-f]{8})-p\d+$/.exec(linked) : null;
|
|
69
|
+
if (tag === null || linked !== declared)
|
|
70
|
+
throw new Error(
|
|
71
|
+
`native library links WebRTC prebuilt ${JSON.stringify(linked)}, but its NOTICE declares ${JSON.stringify(declared)}; rebuild without a libwebrtc override or update the notices`,
|
|
72
|
+
);
|
|
73
|
+
const sbom = sboms[platform];
|
|
74
|
+
if (sbom === undefined) throw new Error(`no WebRTC SBOM ships for ${platform}`);
|
|
75
|
+
const component = JSON.parse(readFileSync(join(notices, "reactor-webrtc", sbom), "utf8"))
|
|
76
|
+
?.metadata?.component;
|
|
77
|
+
const [, milestone = "", commit = ""] = tag;
|
|
78
|
+
const [, sbomMilestone, sbomCommit = ""] =
|
|
79
|
+
/^branch-heads\/(\d+)\+([0-9a-f]{8,40})$/.exec(String(component?.version)) ?? [];
|
|
80
|
+
if (
|
|
81
|
+
sbomMilestone !== milestone ||
|
|
82
|
+
!sbomCommit.startsWith(commit) ||
|
|
83
|
+
pinned === undefined ||
|
|
84
|
+
!pinned.startsWith(sbomCommit)
|
|
85
|
+
)
|
|
86
|
+
throw new Error(
|
|
87
|
+
`${sbom} describes WebRTC ${JSON.stringify(component?.version)}, not the linked ${tag[0]} at ${String(pinned)}`,
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
52
91
|
const [input, platform] = process.argv.slice(2);
|
|
53
92
|
if (input === "--source-hash" && platform === undefined) {
|
|
54
93
|
// CI keys its staged-artifact cache on this identity; a cached library whose
|
|
@@ -72,7 +111,7 @@ if (start < 0 || end < 0 || bytes.indexOf(prefix, end + suffix.length) !== -1) {
|
|
|
72
111
|
const build = JSON.parse(bytes.subarray(start + prefix.length, end).toString("utf8"));
|
|
73
112
|
if (
|
|
74
113
|
build.schemaVersion !== 1 ||
|
|
75
|
-
build.abiVersion !==
|
|
114
|
+
build.abiVersion !== 4 ||
|
|
76
115
|
build.profile !== "release" ||
|
|
77
116
|
build.target !== target
|
|
78
117
|
) {
|
|
@@ -86,6 +125,7 @@ if (build.sourceSha256 !== expected) {
|
|
|
86
125
|
`native source identity mismatch: artifact ${build.sourceSha256}; current sources ${expected}; rebuild before staging`,
|
|
87
126
|
);
|
|
88
127
|
}
|
|
128
|
+
checkPrebuilt(build.webrtcPrebuilt, platform);
|
|
89
129
|
const manifest = { schemaVersion: 1, platform, library, sha256: sha256(bytes), build };
|
|
90
130
|
const destination = join(root, "lib", platform, library);
|
|
91
131
|
mkdirSync(dirname(destination), { recursive: true });
|