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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@science-corporation/synapse",
"version": "2.3.1",
"version": "2.3.2",
"description": "Client library and CLI for the Synapse API",
"license": "Apache-2.0",
"main": "dist/index.js",
Expand Down
10 changes: 10 additions & 0 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ PROTOS=$(find ${PROTO_DIR} -name '*.proto' | sed "s|${PROTO_DIR}/||")

mkdir -p ${PROTO_OUT_DIR}

# Mirror synapse-api/VERSION into src/api_version.ts so the protocol
# version is available as a constant in both node and browser builds.
if [ -f "${PROTO_DIR}/VERSION" ]; then
SYNAPSE_API_VERSION=$(tr -d '[:space:]' < ${PROTO_DIR}/VERSION)
cat > ./src/api_version.ts <<EOF
// Generated from synapse-api/VERSION by scripts/generate.sh. Do not edit.
export const SYNAPSE_API_VERSION = "${SYNAPSE_API_VERSION}";
EOF
fi

pbjs \
-t json \
-w es6 \
Expand Down
2 changes: 2 additions & 0 deletions src/api_version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Generated from synapse-api/VERSION by scripts/generate.sh. Do not edit.
export const SYNAPSE_API_VERSION = "2.4.0";
2 changes: 2 additions & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Browser-safe exports (types and enums only)
export type { CallOptions } from "./utils/client";
export { IStatus, Status, StatusCode } from "./utils/status";
export { SYNAPSE_API_VERSION } from "./api_version";
export { decodeSynapseVersion } from "./utils/version";
export * from "./api/api";
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export { default as Config } from "./config";
export { default as Device } from "./device";
export * from "./nodes";
export { IStatus, Status, StatusCode } from "./utils/status";
export { SYNAPSE_API_VERSION } from "./api_version";
export { decodeSynapseVersion } from "./utils/version";

export type { CallOptions } from "./utils/client";
export * from "./api/api";
12 changes: 12 additions & 0 deletions src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Decode a Synapse API version uint32 into a "major.minor.patch" string.
//
// Encoding (see synapse-api device.proto, DeviceInfo.synapse_version):
// bits [31:24] major (0-255)
// bits [23:16] minor (0-255)
// bits [15:0] patch (0-65535)
export function decodeSynapseVersion(v: number): string {
const major = (v >>> 24) & 0xff;
const minor = (v >>> 16) & 0xff;
const patch = v & 0xffff;
return `${major}.${minor}.${patch}`;
}
2 changes: 1 addition & 1 deletion synapse-api
Submodule synapse-api updated 2 files
+1 −1 README.md
+1 −0 VERSION
Loading