From 7bc2b9f6f4e1f436577b3343dc508101d364b38c Mon Sep 17 00:00:00 2001 From: Alec Thilenius Date: Mon, 3 Apr 2023 18:52:47 -0700 Subject: [PATCH] Add an example React client that points to buf Eliza service --- .vscode/settings.json | 11 +- axum-connect-examples/client/.gitignore | 123 ++ axum-connect-examples/client/.npmrc | 1 + .../client/.vscode/settings.json | 3 + axum-connect-examples/client/buf.gen.yaml | 8 + axum-connect-examples/client/index.html | 27 + .../client/package-lock.json | 1174 +++++++++++++++++ axum-connect-examples/client/package.json | 34 + axum-connect-examples/client/src/app.tsx | 71 + axum-connect-examples/client/src/main.tsx | 9 + axum-connect-examples/client/tsconfig.json | 36 + axum-connect-examples/client/vite.config.ts | 13 + buf.yaml | 8 + 13 files changed, 1517 insertions(+), 1 deletion(-) create mode 100644 axum-connect-examples/client/.gitignore create mode 100644 axum-connect-examples/client/.npmrc create mode 100644 axum-connect-examples/client/.vscode/settings.json create mode 100644 axum-connect-examples/client/buf.gen.yaml create mode 100644 axum-connect-examples/client/index.html create mode 100644 axum-connect-examples/client/package-lock.json create mode 100644 axum-connect-examples/client/package.json create mode 100644 axum-connect-examples/client/src/app.tsx create mode 100644 axum-connect-examples/client/src/main.tsx create mode 100644 axum-connect-examples/client/tsconfig.json create mode 100644 axum-connect-examples/client/vite.config.ts create mode 100644 buf.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json index 6578159..a126254 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,12 @@ { - "cSpell.words": ["codegen", "proto", "protobuf", "serde", "typecheck"] + "cSpell.words": [ + "bufbuild", + "codegen", + "proto", + "protobuf", + "protoc", + "serde", + "Thilenius", + "typecheck" + ] } diff --git a/axum-connect-examples/client/.gitignore b/axum-connect-examples/client/.gitignore new file mode 100644 index 0000000..fe58a93 --- /dev/null +++ b/axum-connect-examples/client/.gitignore @@ -0,0 +1,123 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +firebase-debug.log* + +# Firebase cache +.firebase/ + +# 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 + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# Build and dist directories +build +dist +dist_tmp + +# Parcel caches +.cache + +# Rust Stuff +target + +# OSX Crap +.DS_Store + +.parcel-cache +.next + +# Test coverage output +/coverage/ + +# Docusaurus +.docusaurus +.cache-loader +/web/build + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Yarn 2+ +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions diff --git a/axum-connect-examples/client/.npmrc b/axum-connect-examples/client/.npmrc new file mode 100644 index 0000000..8dd477a --- /dev/null +++ b/axum-connect-examples/client/.npmrc @@ -0,0 +1 @@ +@buf:registry=https://buf.build/gen/npm/v1 diff --git a/axum-connect-examples/client/.vscode/settings.json b/axum-connect-examples/client/.vscode/settings.json new file mode 100644 index 0000000..25fa621 --- /dev/null +++ b/axum-connect-examples/client/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/axum-connect-examples/client/buf.gen.yaml b/axum-connect-examples/client/buf.gen.yaml new file mode 100644 index 0000000..2d64589 --- /dev/null +++ b/axum-connect-examples/client/buf.gen.yaml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - plugin: es + out: gen + opt: target=ts + - plugin: connect-es + out: gen + opt: target=ts diff --git a/axum-connect-examples/client/index.html b/axum-connect-examples/client/index.html new file mode 100644 index 0000000..3317621 --- /dev/null +++ b/axum-connect-examples/client/index.html @@ -0,0 +1,27 @@ + + + + + + + + Axum Connect Example Client + + + + + +
Loading
+
+ + + diff --git a/axum-connect-examples/client/package-lock.json b/axum-connect-examples/client/package-lock.json new file mode 100644 index 0000000..4d6f318 --- /dev/null +++ b/axum-connect-examples/client/package-lock.json @@ -0,0 +1,1174 @@ +{ + "name": "axum-connect-examples-client", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "axum-connect-examples-client", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@buf/bufbuild_eliza.bufbuild_connect-es": "^0.8.4-20221224180530-f3801d450ef9.1", + "@bufbuild/connect": "^0.8.4", + "@bufbuild/connect-web": "^0.8.4", + "@bufbuild/protobuf": "^1.2.0", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@bufbuild/buf": "^1.15.0-1", + "@bufbuild/protoc-gen-connect-es": "^0.8.4", + "@bufbuild/protoc-gen-es": "^1.2.0", + "@types/react": "^18.0.33", + "@types/react-dom": "^18.0.11", + "@vitejs/plugin-react": "^3.1.0", + "prettier": "^2.8.7", + "tslib": "^2.5.0", + "typescript": "^5.0.2", + "vite": "^4.2.1" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/highlight": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.4", + "@babel/helper-compilation-targets": "^7.21.4", + "@babel/helper-module-transforms": "^7.21.2", + "@babel/helpers": "^7.21.0", + "@babel/parser": "^7.21.4", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.4", + "@babel/types": "^7.21.4", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.2", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.21.4", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.21.4", + "@babel/helper-validator-option": "^7.21.0", + "browserslist": "^4.21.3", + "lru-cache": "^5.1.1", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.18.9", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.21.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.20.7", + "@babel/types": "^7.21.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.18.6", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.21.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.21.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-simple-access": "^7.20.2", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/helper-validator-identifier": "^7.19.1", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.2", + "@babel/types": "^7.21.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.20.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.20.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.20.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.18.6", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.19.4", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.19.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.21.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.21.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.21.0", + "@babel/types": "^7.21.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.18.6", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.18.6", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.21.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.20.2" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.19.6", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.19.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.20.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.18.6", + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.4", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.21.0", + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/parser": "^7.21.4", + "@babel/types": "^7.21.4", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.21.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.19.4", + "@babel/helper-validator-identifier": "^7.19.1", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@buf/bufbuild_eliza.bufbuild_connect-es": { + "version": "0.8.4-20221224180530-f3801d450ef9.1", + "resolved": "https://buf.build/gen/npm/v1/@buf/bufbuild_eliza.bufbuild_connect-es/-/bufbuild_eliza.bufbuild_connect-es-0.8.4-20221224180530-f3801d450ef9.1.tgz", + "dependencies": { + "@buf/bufbuild_eliza.bufbuild_es": "1.1.1-20221224180530-f3801d450ef9.1" + }, + "peerDependencies": { + "@bufbuild/connect": "^0.8.4" + } + }, + "node_modules/@buf/bufbuild_eliza.bufbuild_es": { + "version": "1.1.1-20221224180530-f3801d450ef9.1", + "resolved": "https://buf.build/gen/npm/v1/@buf/bufbuild_eliza.bufbuild_es/-/bufbuild_eliza.bufbuild_es-1.1.1-20221224180530-f3801d450ef9.1.tgz", + "peerDependencies": { + "@bufbuild/protobuf": "^1.1.1" + } + }, + "node_modules/@bufbuild/buf": { + "version": "1.15.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "buf": "bin/buf", + "protoc-gen-buf-breaking": "bin/protoc-gen-buf-breaking", + "protoc-gen-buf-lint": "bin/protoc-gen-buf-lint" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@bufbuild/buf-darwin-arm64": "1.15.0", + "@bufbuild/buf-darwin-x64": "1.15.0", + "@bufbuild/buf-linux-aarch64": "1.15.0", + "@bufbuild/buf-linux-x64": "1.15.0", + "@bufbuild/buf-win32-arm64": "1.15.0", + "@bufbuild/buf-win32-x64": "1.15.0" + } + }, + "node_modules/@bufbuild/buf-linux-x64": { + "version": "1.15.0", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@bufbuild/connect": { + "version": "0.8.4", + "license": "Apache-2.0", + "peerDependencies": { + "@bufbuild/protobuf": "^1.0.0" + } + }, + "node_modules/@bufbuild/connect-web": { + "version": "0.8.4", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/connect": "0.8.4" + }, + "peerDependencies": { + "@bufbuild/protobuf": "^1.0.0" + } + }, + "node_modules/@bufbuild/protobuf": { + "version": "1.2.0", + "license": "(Apache-2.0 AND BSD-3-Clause)" + }, + "node_modules/@bufbuild/protoc-gen-connect-es": { + "version": "0.8.4", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.0.0", + "@bufbuild/protoplugin": "^1.0.0" + }, + "bin": { + "protoc-gen-connect-es": "bin/protoc-gen-connect-es" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@bufbuild/connect": "0.8.4", + "@bufbuild/protoc-gen-es": "^1.0.0" + }, + "peerDependenciesMeta": { + "@bufbuild/connect": { + "optional": true + }, + "@bufbuild/protoc-gen-es": { + "optional": true + } + } + }, + "node_modules/@bufbuild/protoc-gen-es": { + "version": "1.2.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protoplugin": "1.2.0" + }, + "bin": { + "protoc-gen-es": "bin/protoc-gen-es" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@bufbuild/protobuf": "1.2.0" + }, + "peerDependenciesMeta": { + "@bufbuild/protobuf": { + "optional": true + } + } + }, + "node_modules/@bufbuild/protoplugin": { + "version": "1.2.0", + "dev": true, + "license": "(Apache-2.0 AND BSD-3-Clause)", + "dependencies": { + "@bufbuild/protobuf": "1.2.0", + "@typescript/vfs": "^1.4.0", + "typescript": "4.5.2" + } + }, + "node_modules/@bufbuild/protoplugin/node_modules/typescript": { + "version": "4.5.2", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.15", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.17", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "node_modules/@types/prop-types": { + "version": "15.7.5", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "18.0.33", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/@types/react-dom": { + "version": "18.0.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/react": "*" + } + }, + "node_modules/@types/scheduler": { + "version": "0.16.3", + "dev": true, + "license": "MIT" + }, + "node_modules/@typescript/vfs": { + "version": "1.4.0", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.20.12", + "@babel/plugin-transform-react-jsx-self": "^7.18.6", + "@babel/plugin-transform-react-jsx-source": "^7.19.6", + "magic-string": "^0.27.0", + "react-refresh": "^0.14.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.1.0-beta.0" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/browserslist": { + "version": "4.21.5", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "license": "MIT", + "dependencies": { + "caniuse-lite": "^1.0.30001449", + "electron-to-chromium": "^1.4.284", + "node-releases": "^2.0.8", + "update-browserslist-db": "^1.0.10" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001473", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chalk": { + "version": "2.4.2", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "dev": true, + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.1.2", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.3.4", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.349", + "dev": true, + "license": "ISC" + }, + "node_modules/esbuild": { + "version": "0.17.15", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.15", + "@esbuild/android-arm64": "0.17.15", + "@esbuild/android-x64": "0.17.15", + "@esbuild/darwin-arm64": "0.17.15", + "@esbuild/darwin-x64": "0.17.15", + "@esbuild/freebsd-arm64": "0.17.15", + "@esbuild/freebsd-x64": "0.17.15", + "@esbuild/linux-arm": "0.17.15", + "@esbuild/linux-arm64": "0.17.15", + "@esbuild/linux-ia32": "0.17.15", + "@esbuild/linux-loong64": "0.17.15", + "@esbuild/linux-mips64el": "0.17.15", + "@esbuild/linux-ppc64": "0.17.15", + "@esbuild/linux-riscv64": "0.17.15", + "@esbuild/linux-s390x": "0.17.15", + "@esbuild/linux-x64": "0.17.15", + "@esbuild/netbsd-x64": "0.17.15", + "@esbuild/openbsd-x64": "0.17.15", + "@esbuild/sunos-x64": "0.17.15", + "@esbuild/win32-arm64": "0.17.15", + "@esbuild/win32-ia32": "0.17.15", + "@esbuild/win32-x64": "0.17.15" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "dev": true, + "license": "MIT" + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/has": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/is-core-module": { + "version": "2.11.0", + "dev": true, + "license": "MIT", + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "2.5.2", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/magic-string": { + "version": "0.27.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.6", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-releases": { + "version": "2.0.10", + "dev": true, + "license": "MIT" + }, + "node_modules/path-parse": { + "version": "1.0.7", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.0.0", + "dev": true, + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.4.21", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.4", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prettier": { + "version": "2.8.7", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/react": { + "version": "18.2.0", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.2.0", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/react-refresh": { + "version": "0.14.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.1", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/rollup": { + "version": "3.20.2", + "dev": true, + "license": "MIT", + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/scheduler": { + "version": "0.23.0", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, + "node_modules/semver": { + "version": "6.3.0", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/tslib": { + "version": "2.5.0", + "dev": true, + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "5.0.3", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.10", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "browserslist-lint": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/vite": { + "version": "4.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.21", + "resolve": "^1.22.1", + "rollup": "^3.18.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "dev": true, + "license": "ISC" + } + } +} diff --git a/axum-connect-examples/client/package.json b/axum-connect-examples/client/package.json new file mode 100644 index 0000000..2fd50e7 --- /dev/null +++ b/axum-connect-examples/client/package.json @@ -0,0 +1,34 @@ +{ + "name": "axum-connect-examples-client", + "version": "1.0.0", + "description": "An example React client to demo end-to-end RPC calls", + "main": "index.js", + "repository": "https://github.com/AThilenius/axum-connect", + "author": "Alec Thilenius", + "license": "MIT", + "scripts": { + "dev": "vite", + "build": "tsc --noEmit && yarn vite build", + "preview": "vite preview" + }, + "dependencies": { + "@buf/bufbuild_eliza.bufbuild_connect-es": "^0.8.4-20221224180530-f3801d450ef9.1", + "@bufbuild/connect": "^0.8.4", + "@bufbuild/connect-web": "^0.8.4", + "@bufbuild/protobuf": "^1.2.0", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@bufbuild/buf": "^1.15.0-1", + "@bufbuild/protoc-gen-connect-es": "^0.8.4", + "@bufbuild/protoc-gen-es": "^1.2.0", + "@types/react": "^18.0.33", + "@types/react-dom": "^18.0.11", + "@vitejs/plugin-react": "^3.1.0", + "prettier": "^2.8.7", + "tslib": "^2.5.0", + "typescript": "^5.0.2", + "vite": "^4.2.1" + } +} diff --git a/axum-connect-examples/client/src/app.tsx b/axum-connect-examples/client/src/app.tsx new file mode 100644 index 0000000..817a605 --- /dev/null +++ b/axum-connect-examples/client/src/app.tsx @@ -0,0 +1,71 @@ +import React, { useEffect, useState } from "react"; +import { createPromiseClient } from "@bufbuild/connect"; +import { createConnectTransport } from "@bufbuild/connect-web"; +import { ElizaService } from "@buf/bufbuild_eliza.bufbuild_connect-es/buf/connect/demo/eliza/v1/eliza_connect"; + +const transport = createConnectTransport({ + baseUrl: "https://demo.connect.build", +}); + +const client = createPromiseClient(ElizaService, transport); + +export const App: React.FC = () => { + useEffect(() => { + (async () => { + for await (const message of client.introduce({})) { + console.log(message); + } + })(); + }, []); + + const [inputValue, setInputValue] = useState(""); + const [messages, setMessages] = useState< + { + fromMe: boolean; + message: string; + }[] + >([]); + return ( + <> +
    + {messages.map((msg, index) => ( +
  1. + {`${msg.fromMe ? "ME:" : "ELIZA:"} ${msg.message}`} +
  2. + ))} +
+
{ + e.preventDefault(); + // Clear inputValue since the user has submitted. + setInputValue(""); + // Store the inputValue in the chain of messages and + // mark this message as coming from "me" + setMessages((prev) => [ + ...prev, + { + fromMe: true, + message: inputValue, + }, + ]); + const response = await client.say({ + sentence: inputValue, + }); + setMessages((prev) => [ + ...prev, + { + fromMe: false, + message: response.sentence, + }, + ]); + }} + > + setInputValue(e.target.value)} + /> + +
+ + ); +}; diff --git a/axum-connect-examples/client/src/main.tsx b/axum-connect-examples/client/src/main.tsx new file mode 100644 index 0000000..a5c5323 --- /dev/null +++ b/axum-connect-examples/client/src/main.tsx @@ -0,0 +1,9 @@ +import { createRoot } from "react-dom/client"; +import { App } from "~/app"; + +async function main() { + const root = createRoot(document.getElementById("root")!); + root.render(); +} + +main(); diff --git a/axum-connect-examples/client/tsconfig.json b/axum-connect-examples/client/tsconfig.json new file mode 100644 index 0000000..0e5f69c --- /dev/null +++ b/axum-connect-examples/client/tsconfig.json @@ -0,0 +1,36 @@ +{ + "compilerOptions": { + "allowJs": true, + "allowSyntheticDefaultImports": true, + "alwaysStrict": true, + "baseUrl": ".", + "declaration": true, + "downlevelIteration": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "forceConsistentCasingInFileNames": true, + "importHelpers": true, + "isolatedModules": true, + "jsx": "react-jsx", + "lib": ["dom", "dom.iterable", "esnext", "webworker"], + "module": "esnext", + "moduleResolution": "node", + "noEmit": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "paths": { "~/*": ["src/*"] }, + "removeComments": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "target": "es6", + "useDefineForClassFields": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules/**/*"] +} diff --git a/axum-connect-examples/client/vite.config.ts b/axum-connect-examples/client/vite.config.ts new file mode 100644 index 0000000..331da1b --- /dev/null +++ b/axum-connect-examples/client/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from "vite"; +import { resolve } from "path"; +import react from "@vitejs/plugin-react"; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], + resolve: { + alias: { + "~": resolve(__dirname, "./src"), + }, + }, +}); diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..b4e2cb1 --- /dev/null +++ b/buf.yaml @@ -0,0 +1,8 @@ +version: v1 +name: buf.build/woodriver-energy/blink +breaking: + use: + - FILE +lint: + use: + - DEFAULT