Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @mcap/support, @mcap/nodejs, and @mcap/browser libraries #868

Merged
merged 32 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
38e9c9d
[TypeScript] @mcap/support (#838)
jhurliman Feb 28, 2023
9730d35
Merge remote-tracking branch 'origin/main' into jacob/support-lib
jtbandes Mar 28, 2023
6f49dfa
WIP
jtbandes Mar 28, 2023
9c3fb14
Merge remote-tracking branch 'origin/main' into jacob/support-lib
jtbandes Mar 28, 2023
73cf644
Merge remote-tracking branch 'origin/main' into jacob/support-lib
jtbandes Jun 29, 2023
3dacc7b
update src from studio/packages/mcap-support
jtbandes Jun 30, 2023
9c09f13
wheeeee
jtbandes Jun 30, 2023
40f8d27
typedoc updates
jtbandes Jul 1, 2023
4ee79d3
fix cspell
jtbandes Jul 1, 2023
16a2a9f
fixes
jtbandes Jul 1, 2023
695bab9
release instructions cleanup
jtbandes Jul 1, 2023
4d12176
cleanup, update validate script to use parseChannel
jtbandes Jul 1, 2023
5589b01
cleanup & fixes
jtbandes Jul 1, 2023
145d6d4
fix conformance-lint
jtbandes Jul 1, 2023
7dcef38
remove links which are broken in typedoc rendered output
jtbandes Jul 1, 2023
5651518
Use @foxglove/protobufjs fork
jtbandes Sep 2, 2023
6912dee
Merge remote-tracking branch 'origin/main' into jacob/support-lib
jtbandes Sep 12, 2023
69c8b72
update from latest studio code
jtbandes Sep 12, 2023
7a583ca
add @mcap/browser package with BlobReadable
jtbandes Sep 13, 2023
5d89e9c
Extra protobuf time/duration modifications so they can live in studio…
jtbandes Sep 13, 2023
811f45e
exports & comments
jtbandes Sep 13, 2023
80b98d6
readme update
jtbandes Sep 13, 2023
350e423
update comment to remove RosDatatypes reference
jtbandes Sep 13, 2023
c95de40
update (disabled) publish workflow
jtbandes Sep 13, 2023
d6b5b39
more CI & package.json updates
jtbandes Sep 13, 2023
11c2385
Merge remote-tracking branch 'origin/main' into jacob/platform-libs
jtbandes Nov 18, 2023
fb90670
remove parseChannel stuff
jtbandes Nov 18, 2023
8fdfa66
lint & yarn fixes
jtbandes Nov 18, 2023
7f4f110
update readmes
jtbandes Nov 18, 2023
2d602c1
cleanup
jtbandes Nov 18, 2023
718bfd5
prepare for publishing
jtbandes Nov 18, 2023
b3467d1
yarn dedupe
jtbandes Nov 18, 2023
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ python/mcap-ros1-support/mcap_ros1/vendor/** linguist-vendored=true
tests/conformance/data/** linguist-generated=true
typescript/examples/flatbuffer/output/** linguist-generated=true
go/ros/testdata/markers.bz2.bag filter=lfs diff=lfs merge=lfs -text
typescript/support/src/fixtures/byte-vector.ts linguist-generated=true
37 changes: 32 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
cache: yarn
- run: corepack enable && yarn install --immutable
- run: yarn workspace @foxglove/mcap-conformance lint:ci
- run: yarn workspace @foxglove/mcap-conformance typecheck
- run: yarn workspace @foxglove/mcap-conformance build

conformance-cpp:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -199,6 +199,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions/setup-node@v3
with:
node-version: 16.x
Expand All @@ -208,15 +210,40 @@ jobs:
- run: yarn dedupe --check
- run: yarn prettier:check
- run: yarn workspace @mcap/core lint:ci
- run: yarn workspace @mcap/core typecheck
- run: yarn workspace @mcap/core test

- name: Publish to NPM
- run: yarn workspace @mcap/core build
- run: yarn workspace @mcap/support lint:ci
- run: yarn workspace @mcap/support build
- run: yarn workspace @mcap/nodejs lint:ci
- run: yarn workspace @mcap/nodejs build
- run: yarn workspace @mcap/browser lint:ci
- run: yarn workspace @mcap/browser build
- run: yarn typescript:test

- name: Publish @mcap/core to NPM
if: ${{ startsWith(github.ref, 'refs/tags/releases/typescript/core/v') }}
run: yarn workspace @mcap/core npm publish --access public
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

# To be enabled once API has settled
# - name: Publish @mcap/support to NPM
# if: ${{ startsWith(github.ref, 'refs/tags/releases/typescript/support/v') }}
# run: yarn workspace @mcap/support publish --access public
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

# - name: Publish @mcap/nodejs to NPM
# if: ${{ startsWith(github.ref, 'refs/tags/releases/typescript/nodejs/v') }}
# run: yarn workspace @mcap/nodejs publish --access public
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

# - name: Publish @mcap/browser to NPM
# if: ${{ startsWith(github.ref, 'refs/tags/releases/typescript/browser/v') }}
# run: yarn workspace @mcap/browser publish --access public
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

typescript-examples:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
"eslint.options": {
"reportUnusedDisableDirectives": "error"
},
"jest.jestCommandLine": "yarn workspace @mcap/core test",
"jest.jestCommandLine": "yarn typescript:test",

"cSpell.enabled": true,

"search.exclude": {
"**/node_modules": true,
"tests/conformance/data": true,
"python/**/build": true,
"python/docs/*-apidoc": true
"python/docs/*-apidoc": true,
".yarn/**": true,
"yarn.lock": true,
"**/dist": true
},

"python.formatting.provider": "black",
Expand Down
12 changes: 0 additions & 12 deletions RELEASE.md

This file was deleted.

3 changes: 3 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ignorePaths:
- bin
- dist
- yarn-error.log
- "*.bfbs"
- "*.csv"
- "*.Dockerfile"
- Dockerfile
Expand Down Expand Up @@ -88,6 +89,7 @@ words:
- rostime
- schemaless
- serde
- sfixed
- srgb
- stoull
- struct
Expand All @@ -101,6 +103,7 @@ words:
- velodyne
- waabi
- webp
- xcdr
- zstandard
- zstd
- zustand
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,32 @@
"typescript/benchmarks",
"typescript/core",
"typescript/examples/*",
"typescript/support",
"typescript/nodejs",
"typescript/browser",
"website"
]
},
"scripts": {
"prettier": "prettier --write .",
"prettier:check": "prettier --check .",
"docs:swift:start": "swift package --disable-sandbox preview-documentation --target MCAP",
"typedoc": "typedoc --out __docs__/typescript typescript/core/src/index.ts --tsconfig typescript/core/tsconfig.json",
"typedoc": "yarn typescript:build && typedoc --out __docs__/typescript --options typescript/typedoc.json",
"start": "yarn workspace website start",
"spellcheck": "cspell --relative '**'",
"typescript:test": "yarn jest --config typescript/jest.config.json",
"typescript:build": "yarn workspace @mcap/core build && yarn workspace @mcap/support build && yarn workspace @mcap/nodejs build && yarn workspace @mcap/browser build",
"typescript:clean": "yarn workspace @mcap/core build --clean && yarn workspace @mcap/support build --clean && yarn workspace @mcap/nodejs build --clean && yarn workspace @mcap/browser build --clean",
"test:conformance:generate-inputs": "yarn workspace @foxglove/mcap-conformance generate-inputs --data-dir \"$(pwd)/tests/conformance/data\"",
"test:conformance": "yarn workspace @foxglove/mcap-conformance run-tests --data-dir \"$(pwd)/tests/conformance/data\""
},
"packageManager": "[email protected]",
"devDependencies": {
"cspell": "^6.26.3",
"jest": "29.4.3",
"prettier": "^2.8.4",
"ts-jest": "29.0.5",
"ts-node": "10.9.1",
"typedoc": "^0.23.25"
}
}
2 changes: 1 addition & 1 deletion python/mcap-protobuf-support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ pipenv run python point_cloud_example.py output.mcap

## Stay in touch

Join our [Slack channel](https://foxglove.dev/join-slack) to ask questions, share feedback, and stay up to date on what our team is working on.
Join our [Slack channel](https://foxglove.dev/slack) to ask questions, share feedback, and stay up to date on what our team is working on.
2 changes: 1 addition & 1 deletion python/mcap-ros1-support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ ros_writer.finish()

## Stay in touch

Join our [Slack channel](https://foxglove.dev/join-slack) to ask questions,
Join our [Slack channel](https://foxglove.dev/slack) to ask questions,
share feedback, and stay up to date on what our team is working on.
2 changes: 1 addition & 1 deletion python/mcap-ros2-support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ for msg in read_ros2_messages("my_data.mcap"):

## Stay in touch

Join our [Slack channel](https://foxglove.dev/join-slack) to ask questions,
Join our [Slack channel](https://foxglove.dev/slack) to ask questions,
share feedback, and stay up to date on what our team is working on.
5 changes: 4 additions & 1 deletion tests/conformance/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ module.exports = {
files: ["*.ts", "*.tsx"],
extends: ["plugin:@foxglove/typescript"],
parserOptions: {
project: "tsconfig.json",
project: ["tsconfig.json", "../../typescript/*/tsconfig.json"],
tsconfigRootDir: __dirname,
// Enable typescript-eslint to use `src` files for type information across project references
// <https://github.com/typescript-eslint/typescript-eslint/issues/2094>
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
},
},
],
Expand Down
7 changes: 4 additions & 3 deletions tests/conformance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
"version": "0.0.0",
"private": true,
"scripts": {
"typecheck": "tsc -p tsconfig.json --noEmit",
"build": "tsc -b tsconfig.json tsconfig.cjs.json",
"lint:ci": "eslint --report-unused-disable-directives .",
"lint": "eslint --report-unused-disable-directives --fix .",
"generate-inputs": "ts-node --files --project tsconfig.cjs.json scripts/generate-inputs",
"run-tests": "ts-node --files --project tsconfig.cjs.json scripts/run-tests"
"run-tests": "tsc -b tsconfig.json tsconfig.cjs.json && ts-node --files --project tsconfig.cjs.json scripts/run-tests"
},
"devDependencies": {
"@foxglove/crc": "^0.0.3",
"@foxglove/eslint-plugin": "0.21.0",
"@foxglove/tsconfig": "1.1.0",
"@mcap/core": "*",
"@mcap/core": "workspace:*",
"@mcap/support": "workspace:*",
"@types/diff": "^5.0.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "18.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { McapIndexedReader } from "@mcap/core";
import { FileHandleReadable } from "@mcap/nodejs";
import fs from "fs/promises";
import { TestFeatures, TestVariant } from "variants/types";

Expand Down Expand Up @@ -41,28 +42,7 @@ export default class TypescriptIndexedReaderTestRunner extends IndexedReadTestRu
}

private async _run(fileHandle: fs.FileHandle): Promise<IndexedReadTestResult> {
let buffer = new ArrayBuffer(4096);
const readable = {
size: async () => BigInt((await fileHandle.stat()).size),
read: async (offset: bigint, length: bigint) => {
if (offset > Number.MAX_SAFE_INTEGER || length > Number.MAX_SAFE_INTEGER) {
throw new Error(`Read too large: offset ${offset}, length ${length}`);
}
if (length > buffer.byteLength) {
buffer = new ArrayBuffer(Number(length * 2n));
}
const result = await fileHandle.read({
buffer: new DataView(buffer, 0, Number(length)),
position: Number(offset),
});
if (result.bytesRead !== Number(length)) {
throw new Error(
`Read only ${result.bytesRead} bytes from offset ${offset}, expected ${length}`,
);
}
return new Uint8Array(result.buffer.buffer, result.buffer.byteOffset, result.bytesRead);
},
};
const readable = new FileHandleReadable(fileHandle);

const reader = await McapIndexedReader.Initialize({ readable });
if (reader.chunkIndexes.length === 0) {
Expand Down
6 changes: 5 additions & 1 deletion tests/conformance/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"compilerOptions": {
"outDir": "./dist/cjs",
"module": "commonjs"
}
},
"references": [
{ "path": "../../typescript/core/tsconfig.cjs.json" },
{ "path": "../../typescript/support/tsconfig.cjs.json" }
]
}
9 changes: 8 additions & 1 deletion tests/conformance/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
"noEmit": true,
"lib": ["es2020", "dom"],
"paths": {
"@mcap/core": ["../../typescript/core/src"]
"@mcap/core": ["../../typescript/core/src"],
"@mcap/nodejs": ["../../typescript/nodejs/src"],
"@mcap/support": ["../../typescript/support/src"]
},

// required for tsconfig-paths https://github.com/dividab/tsconfig-paths/issues/143
"baseUrl": "."
},
"references": [
{ "path": "../../typescript/core" },
{ "path": "../../typescript/nodejs" },
{ "path": "../../typescript/support" }
],
"ts-node": {
"require": ["tsconfig-paths/register"]
}
Expand Down
42 changes: 42 additions & 0 deletions typescript/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Development guide

Install dependencies:

```
corepack enable
yarn install
```

Run lint/tests:

```
yarn workspace @mcap/core lint
yarn workspace @mcap/core test
```

Read and validate an MCAP file:

```
yarn workspace @foxglove/mcap-example-validate validate file.mcap
```

Run benchmarks:

```
yarn workspace @foxglove/mcap-benchmarks bench
```

Run benchmarks with Chrome debugger attached to use profiling tools:

```
yarn workspace @foxglove/mcap-benchmarks bench:debug
```

## Releasing to NPM

- Check out the version of the code you want to release
- Update package.json in `typescript/{pkg}/package.json` with the new version.
- Make a PR with your changes to package.json
- Wait for the PR to pass CI and merge
- Checkout main and tag the merged commit with `releases/typescript/{pkg}/v#.#.#` (replace #.#.# with the version you used in package.json)
- Push the new tag to the repo with `git push origin releases/typescript/{pkg}/v#.#.#`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't tag references have to be preceded by refs/tags/?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can for disambiguation, but it's not required

35 changes: 6 additions & 29 deletions typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
# TypeScript libraries for MCAP

Install dependencies:
[MCAP](https://mcap.dev/) is a modular container format and logging library for pub/sub messages with arbitrary message serialization. It is primarily intended for use in robotics applications, and works well under various workloads, resource constraints, and durability requirements.

```
corepack enable
yarn install
```
The following NPM packages are provided for use with JavaScript and TypeScript:

Run lint/tests:

```
yarn workspace @mcap/core lint
yarn workspace @mcap/core test
```

Read and validate an MCAP file:

```
yarn workspace @foxglove/mcap-example-validate validate file.mcap
```

Run benchmarks:

```
yarn workspace @foxglove/mcap-benchmarks bench
```

Run benchmarks with Chrome debugger attached to use profiling tools:

```
yarn workspace @foxglove/mcap-benchmarks bench:debug
```
- **@mcap/core** – low-level readers and writers
- **@mcap/support** – support for well-known compression formats and encodings
- **@mcap/nodejs** – support for Node.js environment
- **@mcap/browser** – support for browser environment
28 changes: 28 additions & 0 deletions typescript/browser/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-env node */
module.exports = {
env: { es2020: true },
ignorePatterns: ["dist"],
extends: ["plugin:@foxglove/base", "plugin:@foxglove/jest", "plugin:import/recommended"],
overrides: [
{
files: ["*.ts", "*.tsx"],
extends: ["plugin:@foxglove/typescript"],
parserOptions: {
project: "../*/tsconfig.json",
tsconfigRootDir: __dirname,
// Enable typescript-eslint to use `src` files for type information across project references
// <https://github.com/typescript-eslint/typescript-eslint/issues/2094>
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
},
},
],
rules: {
"no-warning-comments": ["error", { terms: ["fixme"], location: "anywhere" }],
},
settings: {
"import/resolver": {
typescript: true,
node: true,
},
},
};
Loading