Skip to content

Commit

Permalink
feat(studio): Add studio RPC typescript client lib
Browse files Browse the repository at this point in the history
* Implement message framing.
* Transports over Web Bluetooth/Serial.
* Message types for serialize/deserialize generated with protoc.
  • Loading branch information
petejohanson committed Jun 17, 2024
1 parent 5def565 commit fdb36fb
Show file tree
Hide file tree
Showing 32 changed files with 25,085 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Local env vars for debugging
TS_NODE_IGNORE="false"
TS_NODE_FILES="true"
1 change: 1 addition & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/types/global.d.ts
32 changes: 32 additions & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'node', 'prettier'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'warn',
'node/no-missing-import': 'off',
'node/no-empty-function': 'off',
'node/no-unsupported-features/es-syntax': 'off',
'node/no-missing-require': 'off',
'node/shebang': 'off',
'@typescript-eslint/no-use-before-define': 'off',
quotes: ['warn', 'single', { avoidEscape: true }],
'node/no-unpublished-import': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
2 changes: 2 additions & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set the repository to show as TypeScript rather than JS in GitHub
*.js linguist-detectable=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: '🐛 Bug Report'
about: Report a reproducible bug or regression.
title: ''
labels: bug
assignees: ''
---

## Current Behavior

<!-- Describe how the issue manifests. -->

## Expected Behavior

<!-- Describe what the desired behavior would be. -->

## Steps to Reproduce the Problem

1.
1.
1.

## Environment

- Version: <!-- Version set in package.json -->
- Platform: <!-- Win/Mac/Linux -->
- Node.js Version: <!-- Output of running `node -v` -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: 🌈 Feature request
about: Suggest an amazing new idea for this project
title: ''
labels: enhancement
assignees: ''
---

## Feature Request

**Is your feature request related to a problem? Please describe.**

<!-- A clear and concise description of what the problem is. Ex. I have an issue when [...] -->

**Describe the solution you'd like**

<!-- A clear and concise description of what you want to happen. Add any considered drawbacks. -->

**Describe alternatives you've considered**

<!-- A clear and concise description of any alternative solutions or features you've considered. -->

## Are you willing to resolve this issue by submitting a Pull Request?

<!--
Remember that first-time contributors are welcome! 🙌
-->

- [ ] Yes, I have the time, and I know how to start.
- [ ] Yes, I have the time, but I don't know how to start. I would need guidance.
- [ ] No, I don't have the time, although I believe I could do it if I had the time...
- [ ] No, I don't have the time and I wouldn't even know how to start.

<!--
👋 Have a great day and thank you for the feature request!
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
😀 Wonderful! Thank you for opening a pull request.
Please fill in the information below to expedite the review
and (hopefully) merge of your change.
-->

### Description of change

<!--
Please be clear and concise what the change is intended to do,
why this change is needed, and how you've verified that it
corrects what you intended.
In some cases it may be helpful to include the current behavior
and the new behavior.
If the change is related to an open issue, you can link it here.
If you include `Fixes #0000` (replacing `0000` with the issue number)
when this is merged it will automatically mark the issue as fixed and
close it.
-->

### Pull-Request Checklist

<!--
Please make sure to review and check all of the following.
If an item is not applicable, you can add "N/A" to the end.
-->

- [ ] Code is up-to-date with the `main` branch
- [ ] `npm run lint` passes with this change
- [ ] `npm run test` passes with this change
- [ ] This pull request links relevant issues as `Fixes #0000`
- [ ] There are new or updated unit tests validating the change
- [ ] Documentation has been updated to reflect this change
- [ ] The new commits follow conventions outlined in the [conventional commit spec](https://www.conventionalcommits.org/en/v1.0.0/)

<!--
🎉 Thank you for contributing!
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Reusable workflow for code analysis; to eject, you can replace this file with
# https://github.com/ryansonshine/ryansonshine/blob/main/.github/workflows/codeql-analysis.yml
name: 'CodeQL'

permissions:
security-events: write
actions: read
contents: read

on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '36 7 * * 6'

jobs:
analyze:
uses: ryansonshine/ryansonshine/.github/workflows/codeql-analysis.yml@main
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Reusable workflow for PRs; to eject, you can replace this file with
# https://github.com/ryansonshine/ryansonshine/blob/main/.github/workflows/pr.yml
name: Pull Request

on: [pull_request]

jobs:
build:
uses: ryansonshine/ryansonshine/.github/workflows/pr.yml@main
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Reusable workflow for releases; to eject, you can replace this file with
# https://github.com/ryansonshine/ryansonshine/blob/main/.github/workflows/release.yml
name: Release
on:
push:
branches:
- main
jobs:
release:
permissions:
contents: write
issues: write
pull-requests: write
uses: ryansonshine/ryansonshine/.github/workflows/release.yml@main
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
119 changes: 119 additions & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env.test
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Compiled code
lib/
1 change: 1 addition & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

exec </dev/tty && node_modules/.bin/cz --hook || true
6 changes: 6 additions & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "avoid",
"printWidth": 80
}
52 changes: 52 additions & 0 deletions rpc-clients/typescript/ts-zmk-rpc-core/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Current TS File",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"args": ["${relativeFile}"],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
"envFile": "${workspaceFolder}/.env",
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart",
"skipFiles": ["<node_internals>/**", "node_modules/**"]
},
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand"
],
"envFile": "${workspaceFolder}/.env",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229,
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
},
{
"name": "Debug Jest Current File",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["${relativeFile}", "--config", "jest.config.js"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229,
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}
]
}
Loading

0 comments on commit fdb36fb

Please sign in to comment.