├── .circleci └── config.yml ├── .editorconfig ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .node-version ├── .releaserc ├── BUILDING.md ├── CHANGELOG.md ├── CIRCLECI.md ├── CONTRIBUTING.md ├── CONVENTIONAL_COMMITS.md ├── LICENSE.md ├── README.md ├── RELEASING.md ├── VERSIONING.md ├── jest.config.js ├── monaco-rescript.js ├── openrpc.json ├── package-lock.json ├── package.json ├── public ├── CNAME └── index.html ├── src ├── App.css ├── components │ └── TransportDropdown.tsx ├── containers │ ├── App.tsx │ ├── Inspector.tsx │ ├── JSONRPCRequestEditor.tsx │ └── OptionsEditor.tsx ├── exports.tsx ├── helpers │ ├── openrpcDocumentToJSONRPCSchema.ts │ └── openrpcDocumentToJSONRPCSchemaResult.ts ├── hooks │ ├── useMonacoVimMode.ts │ ├── useOpenrpcDocument.ts │ ├── useQueryParams.ts │ ├── useTabs.ts │ └── useTransport.ts ├── index.tsx ├── react-app-env.d.ts ├── splitpane.css └── themes │ └── openrpcTheme.ts ├── tsconfig.json ├── tsfmt.json └── tslint.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | aliases: 4 | # ------------------------- 5 | # ALIASES: Caches 6 | # ------------------------- 7 | - &restore-deps-cache 8 | key: deps-cache-{{ checksum "package.json" }} 9 | 10 | - &save-deps-cache 11 | key: deps-cache-{{ checksum "package.json" }} 12 | paths: 13 | - ~/project/node_modules 14 | 15 | # ------------------------- 16 | # ALIASES: Branch Filters 17 | # ------------------------- 18 | - &filter-only-master 19 | branches: 20 | only: master 21 | - &filter-only-semantic-pr 22 | branches: 23 | only: /^(pull|fix|feat|dependabot)\/.*$/ 24 | 25 | defaults: &defaults 26 | working_directory: ~/project 27 | 28 | jobs: 29 | test: 30 | <<: *defaults 31 | docker: 32 | - image: cimg/node:18.20.4 33 | steps: 34 | - checkout 35 | - restore_cache: *restore-deps-cache 36 | - run: npm install 37 | - run: npm install codecov 38 | - run: npm test 39 | - run: ./node_modules/.bin/codecov 40 | - save_cache: *save-deps-cache 41 | 42 | build: 43 | <<: *defaults 44 | docker: 45 | - image: cimg/node:18.20.4 46 | steps: 47 | - checkout 48 | - restore_cache: *restore-deps-cache 49 | - run: npm install 50 | - run: npm run build 51 | - run: npm run build:package 52 | - save_cache: *save-deps-cache 53 | 54 | release: 55 | <<: *defaults 56 | docker: 57 | - image: cimg/node:18.20.4 58 | steps: 59 | - checkout 60 | - restore_cache: *restore-deps-cache 61 | - run: npm install 62 | - run: npm run build 63 | - run: npm run build:package 64 | - run: npm install semantic-release@16 @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/npm @semantic-release/commit-analyzer @semantic-release/release-notes-generator @qiwi/semantic-release-gh-pages-plugin 65 | - run: git checkout package.json package-lock.json 66 | - run: ./node_modules/.bin/semantic-release 67 | - save_cache: *save-deps-cache 68 | 69 | workflows: 70 | version: 2 71 | analysis: 72 | jobs: 73 | - test: 74 | filters: *filter-only-semantic-pr 75 | - build: 76 | filters: *filter-only-semantic-pr 77 | 78 | release: 79 | jobs: 80 | - test: 81 | filters: *filter-only-master 82 | - build: 83 | filters: *filter-only-master 84 | - hold: 85 | filters: *filter-only-master 86 | type: approval 87 | requires: 88 | - test 89 | - build 90 | - release: 91 | filters: *filter-only-master 92 | requires: 93 | - hold 94 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | indent_style = space 9 | indent_size = 2 10 | tab_width = 2 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | build 4 | docs 5 | .DS_Store 6 | dist 7 | /**/build 8 | package/ 9 | *.tgz 10 | -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | 14.17.5 2 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | { 2 | "tagFormat": "${version}", 3 | "branch": "master", 4 | "plugins": [ 5 | "@semantic-release/commit-analyzer", 6 | "@semantic-release/release-notes-generator", 7 | "@semantic-release/changelog", 8 | "@semantic-release/github", 9 | "@semantic-release/git", 10 | "@semantic-release/npm" 11 | ], 12 | "verifyConditions": [ 13 | "@semantic-release/changelog", 14 | "@semantic-release/git", 15 | "@semantic-release/github", 16 | "@qiwi/semantic-release-gh-pages-plugin", 17 | "@semantic-release/npm" 18 | ], 19 | "publish": [ 20 | "@semantic-release/github", 21 | { 22 | "path": "@qiwi/semantic-release-gh-pages-plugin", 23 | "msg": "github pages release", 24 | "src": "build/", 25 | "branch": "gh-pages" 26 | }, 27 | "@semantic-release/npm" 28 | ], 29 | "success": [ 30 | "@semantic-release/github" 31 | ], 32 | "fail": [ 33 | "@semantic-release/github" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /BUILDING.md: -------------------------------------------------------------------------------- 1 | # Building 2 | 3 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) [RFC2119](https://tools.ietf.org/html/rfc2119) [RFC8174](https://tools.ietf.org/html/rfc8174) when, and only when, they appear in all capitals, as shown here. 4 | 5 | This document is licensed under [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). 6 | 7 | ## Introduction 8 | 9 | This document is to describe the functionality a project MUST provide in terms of creating build artifacts. It also describes the structure in which project's MUST write build artifacts in. 10 | 11 | A project MUST provide: 12 | 13 | - a folder name convention for build artifacts 14 | - a folder structure for the above-mentioned build artifacts folder 15 | - a list of targets 16 | - a file called `bin/build.{target}.{ext}` to target each of the build targets 17 | - a build pipeline given the above pretext 18 | 19 | The purpose of having a uniform way of producing a build is that we may ALL produce builds for any of the projects, making the onramp for new developers less steep, while still maintaining an exceptionally high level of quality. 20 | 21 | The projects should follow the 'architecture as code' principle - and should require a very minimal set of dependencies. 22 | 23 | It is the responsibilty of the build tooling to write artifacts to the appropriate location as outlined in this specification. 24 | 25 | ## Build Folder Name 26 | 27 | The cannonical folder for builds SHALL be named `build` and be located at the root of the project repository. 28 | Each project MUST `git ignore` the `build` folder. 29 | 30 | ## Build Folder Structure 31 | 32 | Files and folder names MUST be lowercase. 33 | The result of the build process should create a folder structure as follows: 34 | 35 | ``` 36 | . 37 | └── build 38 | └── {target} 39 | └── {project-name}.{ext} 40 | ``` 41 | 42 | 43 | Below is an example: 44 | ``` 45 | . 46 | └── build 47 | └── windows 48 | └── my-build.exe 49 | ``` 50 | 51 | ## Build Targets 52 | 53 | Below is a list of suggested targets for a project 54 | 1. windows 55 | 2. linux 56 | 3. macos 57 | 58 | ## Build script 59 | 60 | Each release target MUST have a `bin/build.{target}.{ext}` file. 61 | 62 | The result of this is that every project MUST produce a build for each target when the following command is invoked: 63 | 64 | ``` 65 | bin/build.{target}.{ext} 66 | ``` 67 | 68 | The file MUST be placed in the project's `bin` directory. 69 | 70 | ## Build Pipeline 71 | 72 | ### Building targets 73 | 74 | `bin/build.{target}.{ext}` should create builds for each of the targets, and place the build artifacts in a folder structure outlined above. 75 | 76 | ### Windows 77 | 78 | ``` 79 | bin/build.windows.bat 80 | ``` 81 | 82 | ### Linux 83 | 84 | ``` 85 | bin/build.linux.sh 86 | ``` 87 | 88 | ### Macos 89 | 90 | ``` 91 | bin/build.macos.sh 92 | ``` 93 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.7.1](https://github.com/open-rpc/inspector/compare/1.7.0...1.7.1) (2022-09-29) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * bump logs-react to latest ([8561580](https://github.com/open-rpc/inspector/commit/8561580e8be4c7a1ea88de66db9af5ef88d0f315)) 7 | 8 | # [1.7.0](https://github.com/open-rpc/inspector/compare/1.6.3...1.7.0) (2022-09-09) 9 | 10 | 11 | ### Features 12 | 13 | * adds support for schemaUrl to inspector ([901cfc9](https://github.com/open-rpc/inspector/commit/901cfc97e8ec6d692c39b8d33525940ab5432f1c)) 14 | 15 | ## [1.6.3](https://github.com/open-rpc/inspector/compare/1.6.2...1.6.3) (2022-01-19) 16 | 17 | 18 | ### Bug Fixes 19 | 20 | * add customTransport api from query string ([c7f41b5](https://github.com/open-rpc/inspector/commit/c7f41b5c449023a0e9143ceeef9d211fc287c02c)) 21 | 22 | ## [1.6.2](https://github.com/open-rpc/inspector/compare/1.6.1...1.6.2) (2021-09-11) 23 | 24 | 25 | ### Bug Fixes 26 | 27 | * add support for out of band errors with no id ([0c4a63d](https://github.com/open-rpc/inspector/commit/0c4a63d0260ca4d8ad64ba6219294da42845e2a1)) 28 | * subscribe to errors/notifications after rpc.discover ([7f70ce4](https://github.com/open-rpc/inspector/commit/7f70ce4b6d9b3879b94e69f7e4668111b7f4802f)) 29 | 30 | ## [1.6.1](https://github.com/open-rpc/inspector/compare/1.6.0...1.6.1) (2021-09-03) 31 | 32 | 33 | ### Bug Fixes 34 | 35 | * multiple custom transport cleanup ([78651fa](https://github.com/open-rpc/inspector/commit/78651fac4dad3ea10bec9e332d8f7417557db52c)) 36 | * order of close for interTransport ([b059c5d](https://github.com/open-rpc/inspector/commit/b059c5d26968ad72833da134a9ff1c5224824ada)) 37 | 38 | # [1.6.0](https://github.com/open-rpc/inspector/compare/1.5.5...1.6.0) (2021-07-05) 39 | 40 | 41 | ### Features 42 | 43 | * keep custom transports in localstorage ([26e45af](https://github.com/open-rpc/inspector/commit/26e45afda442c213b6493b3cc57d186a89fbf974)) 44 | 45 | ## [1.5.5](https://github.com/open-rpc/inspector/compare/1.5.4...1.5.5) (2021-04-08) 46 | 47 | 48 | ### Bug Fixes 49 | 50 | * bump client-js ([26ba5a1](https://github.com/open-rpc/inspector/commit/26ba5a198e5303653776835149d446557d23ae43)) 51 | 52 | ## [1.5.4](https://github.com/open-rpc/inspector/compare/1.5.3...1.5.4) (2021-03-30) 53 | 54 | 55 | ### Bug Fixes 56 | 57 | * make clear button more visible ([61c7bb2](https://github.com/open-rpc/inspector/commit/61c7bb21d85429a2a0db9154bd51be44c9d052f4)) 58 | 59 | ## [1.5.3](https://github.com/open-rpc/inspector/compare/1.5.2...1.5.3) (2021-03-21) 60 | 61 | 62 | ### Bug Fixes 63 | 64 | * allow custom transport as option ([56685a0](https://github.com/open-rpc/inspector/commit/56685a0a66695ea7d2c0b34881ee444d16455c1b)) 65 | 66 | ## [1.5.2](https://github.com/open-rpc/inspector/compare/1.5.1...1.5.2) (2021-03-21) 67 | 68 | 69 | ### Bug Fixes 70 | 71 | * allows notifications to be passed through custom transports ([fe75d3f](https://github.com/open-rpc/inspector/commit/fe75d3fb6e9c73e0d49ff4c27985471aba9465c3)) 72 | 73 | ## [1.5.1](https://github.com/open-rpc/inspector/compare/1.5.0...1.5.1) (2021-03-15) 74 | 75 | 76 | ### Bug Fixes 77 | 78 | * allow play button press for transports with no url ([fcdac25](https://github.com/open-rpc/inspector/commit/fcdac2501becd897482e6754cf3034b71c26d29d)) 79 | 80 | # [1.5.0](https://github.com/open-rpc/inspector/compare/1.4.18...1.5.0) (2020-11-10) 81 | 82 | 83 | ### Bug Fixes 84 | 85 | * add discord link ([2722bec](https://github.com/open-rpc/inspector/commit/2722bec312a59148adef82b44223864553d093d4)) 86 | * update meta-schema ([6b4d47e](https://github.com/open-rpc/inspector/commit/6b4d47e788965957c69c1450cb3fde3a0a5cefdf)) 87 | * update meta-schema + dereffer ([fab0533](https://github.com/open-rpc/inspector/commit/fab05335e1f5f28a7b3525667a01a93e5b957b01)) 88 | 89 | 90 | ### Features 91 | 92 | * add http transport options configuration ([585ebe8](https://github.com/open-rpc/inspector/commit/585ebe82e087be1af8b68d8a5651bc439bcb85b0)) 93 | * notification wip ([8e759b1](https://github.com/open-rpc/inspector/commit/8e759b18462e79139cb54df3dbcfd3f7d182e664)) 94 | 95 | ## [1.4.18](https://github.com/open-rpc/inspector/compare/1.4.17...1.4.18) (2020-10-15) 96 | 97 | 98 | ### Bug Fixes 99 | 100 | * update logs react to get smaller card list sizing ([1ed9296](https://github.com/open-rpc/inspector/commit/1ed9296ca626c7af87d605d9916c090703c45c86)) 101 | 102 | ## [1.4.17](https://github.com/open-rpc/inspector/compare/1.4.16...1.4.17) (2020-10-15) 103 | 104 | 105 | ### Bug Fixes 106 | 107 | * monaco editor height 100% ([65b7fa2](https://github.com/open-rpc/inspector/commit/65b7fa2dde5892b7261a6c8771f03472ecc083ec)) 108 | 109 | ## [1.4.16](https://github.com/open-rpc/inspector/compare/1.4.15...1.4.16) (2020-10-15) 110 | 111 | 112 | ### Bug Fixes 113 | 114 | * logs-react scroll bottom ([516e440](https://github.com/open-rpc/inspector/commit/516e4409369669ea7e9fc61d6b98424090deda54)) 115 | 116 | ## [1.4.15](https://github.com/open-rpc/inspector/compare/1.4.14...1.4.15) (2020-10-15) 117 | 118 | 119 | ### Bug Fixes 120 | 121 | * linting ([8373306](https://github.com/open-rpc/inspector/commit/8373306646529e80a466aa6f157cf47bf801e46e)) 122 | * update logs-react to support openrpc document ([753a78d](https://github.com/open-rpc/inspector/commit/753a78daf2e1a2d2d52dc829e6ff742d0d289d1e)) 123 | 124 | ## [1.4.14](https://github.com/open-rpc/inspector/compare/1.4.13...1.4.14) (2020-10-15) 125 | 126 | 127 | ### Bug Fixes 128 | 129 | * update logs-react to 1.1.9 ([a8308da](https://github.com/open-rpc/inspector/commit/a8308da4afd36027592331a9959b7c4a5f1c5d91)) 130 | 131 | ## [1.4.13](https://github.com/open-rpc/inspector/compare/1.4.12...1.4.13) (2020-10-15) 132 | 133 | 134 | ### Bug Fixes 135 | 136 | * update logs-react and add empty message/tutorial back ([a52ce92](https://github.com/open-rpc/inspector/commit/a52ce92e136bfb886b201244d4d26d48496848b0)) 137 | 138 | ## [1.4.12](https://github.com/open-rpc/inspector/compare/1.4.11...1.4.12) (2020-10-14) 139 | 140 | 141 | ### Bug Fixes 142 | 143 | * update logs-react ([7d9c226](https://github.com/open-rpc/inspector/commit/7d9c226e1758de2d60ecdc622d07a13ef51477cc)) 144 | * update logs-react to remove scroll to bottom ([65c3b01](https://github.com/open-rpc/inspector/commit/65c3b01533e08dfec40e8deb884bf27322499b0a)) 145 | 146 | ## [1.4.11](https://github.com/open-rpc/inspector/compare/1.4.10...1.4.11) (2020-10-14) 147 | 148 | 149 | ### Bug Fixes 150 | 151 | * update logs-react ([60196e6](https://github.com/open-rpc/inspector/commit/60196e69f53ff9746b28f6bdc861911d4bf236dc)) 152 | 153 | ## [1.4.10](https://github.com/open-rpc/inspector/compare/1.4.9...1.4.10) (2020-10-14) 154 | 155 | 156 | ### Bug Fixes 157 | 158 | * default to empty if no tab logs ([5c5f4f7](https://github.com/open-rpc/inspector/commit/5c5f4f7914df6e2393e2c08a1599f6ace3982767)) 159 | * tab log empty ([48b7ffe](https://github.com/open-rpc/inspector/commit/48b7ffe5c00af4b94f0dcbd1463d1607ee8f973e)) 160 | 161 | ## [1.4.9](https://github.com/open-rpc/inspector/compare/1.4.8...1.4.9) (2020-10-14) 162 | 163 | 164 | ### Bug Fixes 165 | 166 | * **deps:** update material ui deps ([cb1905e](https://github.com/open-rpc/inspector/commit/cb1905e9ed41d4821e248665f862e73ba95ac73f)) 167 | * default logs to empty array when switching tabs ([ae7c23f](https://github.com/open-rpc/inspector/commit/ae7c23fa79704ebb80b149bac9a2fbc581782b59)) 168 | * lock material-ui versions ([d6693d7](https://github.com/open-rpc/inspector/commit/d6693d78da796e38680192c9198e8284e9d763df)) 169 | * material deps ([7ec066c](https://github.com/open-rpc/inspector/commit/7ec066cddefba21aa86f34c3a2e7b03ff07c1738)) 170 | * update logs-react ([60b8ad5](https://github.com/open-rpc/inspector/commit/60b8ad5f6fdb205e9a62316326c9aed548999c50)) 171 | 172 | ## [1.4.8](https://github.com/open-rpc/inspector/compare/1.4.7...1.4.8) (2020-08-13) 173 | 174 | 175 | ### Bug Fixes 176 | 177 | * **README:** add logs react to resources ([02a80be](https://github.com/open-rpc/inspector/commit/02a80bedc42d733ba76ac83075c48927f98c8b01)) 178 | 179 | ## [1.4.7](https://github.com/open-rpc/inspector/compare/1.4.6...1.4.7) (2020-07-22) 180 | 181 | 182 | ### Bug Fixes 183 | 184 | * add transport as prop and query string ([1f480b1](https://github.com/open-rpc/inspector/commit/1f480b1fc1a14700c41484495447ede874d1f962)) 185 | * **README:** add docs for transport query param ([c92155b](https://github.com/open-rpc/inspector/commit/c92155b6580b79f5fab4ab549c1c001e03d25cc5)) 186 | 187 | ## [1.4.6](https://github.com/open-rpc/inspector/compare/1.4.5...1.4.6) (2020-07-02) 188 | 189 | 190 | ### Bug Fixes 191 | 192 | * remove unused old postmessage transport ([274d19e](https://github.com/open-rpc/inspector/commit/274d19e60665615b8c51c0c7bf79e42f0ed67e83)) 193 | * update clientjs to support postmessage window and iframe ([4ad4139](https://github.com/open-rpc/inspector/commit/4ad413935b5508a304291f365f1e0c57cd10e23a)) 194 | 195 | ## [1.4.5](https://github.com/open-rpc/inspector/compare/1.4.4...1.4.5) (2020-05-06) 196 | 197 | 198 | ### Bug Fixes 199 | 200 | * update readme url to mock server ([646e6aa](https://github.com/open-rpc/inspector/commit/646e6aae6aa66e02ef9f3c7da99d658bdef6a873)) 201 | 202 | ## [1.4.4](https://github.com/open-rpc/inspector/compare/1.4.3...1.4.4) (2020-05-06) 203 | 204 | 205 | ### Bug Fixes 206 | 207 | * **README:** update url params example with id ([42dba2a](https://github.com/open-rpc/inspector/commit/42dba2aacb5cbd1608722f5107fdf918feab7627)) 208 | 209 | ## [1.4.3](https://github.com/open-rpc/inspector/compare/1.4.2...1.4.3) (2020-05-06) 210 | 211 | 212 | ### Bug Fixes 213 | 214 | * remove id variable ([d5cf345](https://github.com/open-rpc/inspector/commit/d5cf3455fb31cdafd72493ed0d4320a1826e1e25)) 215 | * simplify postmessage transport ([bdafb5a](https://github.com/open-rpc/inspector/commit/bdafb5a4e1fca2aa1262f2baf504d254a2d8a340)) 216 | * **postmessage transport:** remove guard from iframe ([fd6dc94](https://github.com/open-rpc/inspector/commit/fd6dc944dd36ef4c68144812e638f73454efaf55)) 217 | 218 | ## [1.4.2](https://github.com/open-rpc/inspector/compare/1.4.1...1.4.2) (2020-04-01) 219 | 220 | 221 | ### Bug Fixes 222 | 223 | * remove counter + fix issue with props.openrpcDoc ([a78ece9](https://github.com/open-rpc/inspector/commit/a78ece935a1e3f4d04078d5cae12be3f2e293223)) 224 | 225 | ## [1.4.1](https://github.com/open-rpc/inspector/compare/1.4.0...1.4.1) (2020-03-30) 226 | 227 | 228 | ### Bug Fixes 229 | 230 | * json schema validation ([4d49cc5](https://github.com/open-rpc/inspector/commit/4d49cc563c58493f8658e2636f18c18e25674536)) 231 | 232 | # [1.4.0](https://github.com/open-rpc/inspector/compare/1.3.8...1.4.0) (2020-03-27) 233 | 234 | 235 | ### Bug Fixes 236 | 237 | * change default transports ([479eaeb](https://github.com/open-rpc/inspector/commit/479eaeb6fcf69bd2b74ff3e9509c548c52312bca)) 238 | * linting ([2c5c871](https://github.com/open-rpc/inspector/commit/2c5c871015920706f53f09d297afabc274f94780)) 239 | 240 | 241 | ### Features 242 | 243 | * metamask ([2239b81](https://github.com/open-rpc/inspector/commit/2239b8108ad23bab667101d6ab924a18e82ef818)) 244 | * transport plugins ([a377a8e](https://github.com/open-rpc/inspector/commit/a377a8e1fd55362889926b2585b52be0559f192c)), closes [#121](https://github.com/open-rpc/inspector/issues/121) 245 | 246 | ## [1.3.8](https://github.com/open-rpc/inspector/compare/1.3.7...1.3.8) (2020-03-18) 247 | 248 | 249 | ### Bug Fixes 250 | 251 | * errors + ids + transports ([b69f42f](https://github.com/open-rpc/inspector/commit/b69f42f49d7170b92632ccbdf055c85f33e9e81c)) 252 | * update id with new tab ([034a4dd](https://github.com/open-rpc/inspector/commit/034a4dda5275782f76053fc48464a758e2ba9848)) 253 | 254 | ## [1.3.7](https://github.com/open-rpc/inspector/compare/1.3.6...1.3.7) (2020-03-17) 255 | 256 | 257 | ### Bug Fixes 258 | 259 | * keep existing url for new tabs ([f91ca01](https://github.com/open-rpc/inspector/commit/f91ca01bade696364c322dbe77203d3acb23e972)), closes [#135](https://github.com/open-rpc/inspector/issues/135) 260 | 261 | ## [1.3.6](https://github.com/open-rpc/inspector/compare/1.3.5...1.3.6) (2020-03-13) 262 | 263 | 264 | ### Bug Fixes 265 | 266 | * **openrpc jsonrpc schema:** guard against methods and params not existing ([ebe3ca5](https://github.com/open-rpc/inspector/commit/ebe3ca52bc0be915d5cdcb70080b096ae0aaf226)) 267 | 268 | ## [1.3.5](https://github.com/open-rpc/inspector/compare/1.3.4...1.3.5) (2020-03-12) 269 | 270 | 271 | ### Bug Fixes 272 | 273 | * add props updates ([9c85d55](https://github.com/open-rpc/inspector/commit/9c85d5590dbb5d80144a684d01e325352d8755df)) 274 | * linting ([5b8b058](https://github.com/open-rpc/inspector/commit/5b8b0581df396ed9df5b1e21de74a9a16891c61a)) 275 | 276 | ## [1.3.4](https://github.com/open-rpc/inspector/compare/1.3.3...1.3.4) (2020-03-09) 277 | 278 | 279 | ### Bug Fixes 280 | 281 | * add automaticLayout monaco option ([fb20fa3](https://github.com/open-rpc/inspector/commit/fb20fa3ecbf559f06774d149b49f649eb4041922)) 282 | * monaco widgets overflow and better json-rpc error handling ([5e0c4ed](https://github.com/open-rpc/inspector/commit/5e0c4edd92c36a2ea80a22c7af9286b076317f9b)) 283 | 284 | ## [1.3.3](https://github.com/open-rpc/inspector/compare/1.3.2...1.3.3) (2020-03-09) 285 | 286 | 287 | ### Bug Fixes 288 | 289 | * markdown descriptions + add vim mode + add text to show ctrl+space help ([4ea9456](https://github.com/open-rpc/inspector/commit/4ea9456fd14070b118d016bdad6ac627d4b0905c)), closes [#120](https://github.com/open-rpc/inspector/issues/120) 290 | * resize help ([5167c13](https://github.com/open-rpc/inspector/commit/5167c1382ad9e5ca0ff2857189a639ff149aef27)) 291 | * spacing + linting ([5bd70b2](https://github.com/open-rpc/inspector/commit/5bd70b242872c9d4265f157c31b4cbe721da01c4)) 292 | 293 | ## [1.3.2](https://github.com/open-rpc/inspector/compare/1.3.1...1.3.2) (2020-03-06) 294 | 295 | 296 | ### Bug Fixes 297 | 298 | * add history ([d13845c](https://github.com/open-rpc/inspector/commit/d13845c7b655b6ce38a2e1f0b435c7d41e69f296)) 299 | * remove dead code ([3443c44](https://github.com/open-rpc/inspector/commit/3443c44266845bb1eeb1d24d6d1a4af9933c5693)) 300 | * remove unused hook ([cfb7776](https://github.com/open-rpc/inspector/commit/cfb7776b83027ccb92e0bf500ad24258fed4708f)) 301 | * **README:** update demo gif ([9f34ad3](https://github.com/open-rpc/inspector/commit/9f34ad3c09ef03352c6fb66e66332e1ab6cc4ac3)) 302 | 303 | ## [1.3.1](https://github.com/open-rpc/inspector/compare/1.3.0...1.3.1) (2020-03-06) 304 | 305 | 306 | ### Bug Fixes 307 | 308 | * add helper text to press play button when no results ([170c34d](https://github.com/open-rpc/inspector/commit/170c34d0c7ecffd041e6c6b97c5756713a60e080)) 309 | * add openrpc check circle and tooltip ([3138fd0](https://github.com/open-rpc/inspector/commit/3138fd047fa348e62e79e95f96bdc71addc9b94c)) 310 | * add parseOpenRpcDocument ([6e67d51](https://github.com/open-rpc/inspector/commit/6e67d512e73b487989b74f3d2a942e5ddd4f7475)) 311 | * linting ([fe93536](https://github.com/open-rpc/inspector/commit/fe93536157226ec46e4cd74eb339829d160432e5)) 312 | * linting ++ ([4af6074](https://github.com/open-rpc/inspector/commit/4af60749077e0668bd101d8196e11f3fe17631a9)) 313 | * openrpcdoc validation issue on new tab ([774ab07](https://github.com/open-rpc/inspector/commit/774ab07d15a30d49134cf664a6df47f09a55ac25)) 314 | * remove commented code ([7e6b7b5](https://github.com/open-rpc/inspector/commit/7e6b7b5e63d7f100686c307181ec1fb5d4d71f50)) 315 | * request passed from url ([93848bb](https://github.com/open-rpc/inspector/commit/93848bb268c8709189b5f3abf870af0f1491f781)) 316 | 317 | # [1.3.0](https://github.com/open-rpc/inspector/compare/1.2.11...1.3.0) (2020-03-05) 318 | 319 | 320 | ### Bug Fixes 321 | 322 | * linting ([07a424a](https://github.com/open-rpc/inspector/commit/07a424ae1fc4220e1ee8f8f990e10b072d55c172)) 323 | * remove lodash from inspector.tsx ([e747550](https://github.com/open-rpc/inspector/commit/e747550e6dc5ae5189674a6294f57a9d24321c50)) 324 | * **README:** update gif ([afceac8](https://github.com/open-rpc/inspector/commit/afceac8783e67afd9461d47065b274338aa1321a)) 325 | 326 | 327 | ### Features 328 | 329 | * add tabs and openrpdocument autocomplete ([1f4aae4](https://github.com/open-rpc/inspector/commit/1f4aae40d8a4a5e4404fe49768a43619564bf80a)) 330 | 331 | ## [1.2.11](https://github.com/open-rpc/inspector/compare/1.2.10...1.2.11) (2020-03-03) 332 | 333 | 334 | ### Bug Fixes 335 | 336 | * remove minimap ([1340aa1](https://github.com/open-rpc/inspector/commit/1340aa1f3e1bf7f5623a69aa8e095a1cd15dea15)) 337 | 338 | ## [1.2.10](https://github.com/open-rpc/inspector/compare/1.2.9...1.2.10) (2020-02-28) 339 | 340 | 341 | ### Bug Fixes 342 | 343 | * add support for params by name ([9470402](https://github.com/open-rpc/inspector/commit/9470402eab1d6f94a9f8f3c410b671c0efc220ab)) 344 | * by-name schema ([8653704](https://github.com/open-rpc/inspector/commit/8653704040fb9d3c5991439b88975246db8d33ca)) 345 | 346 | ## [1.2.9](https://github.com/open-rpc/inspector/compare/1.2.8...1.2.9) (2020-02-06) 347 | 348 | 349 | ### Bug Fixes 350 | 351 | * brave embed ([0924b3c](https://github.com/open-rpc/inspector/commit/0924b3c62bd6e9fb927a35769ee93e48bd7f7522)) 352 | * **localstorage brave:** refactor into localStorageMock ([7a27921](https://github.com/open-rpc/inspector/commit/7a27921c013b0c76da1afe1eb7476e335e4496cd)) 353 | 354 | ## [1.2.8](https://github.com/open-rpc/inspector/compare/1.2.7...1.2.8) (2020-01-22) 355 | 356 | 357 | ### Bug Fixes 358 | 359 | * error message display ([97ed459](https://github.com/open-rpc/inspector/commit/97ed45925848e334cf5d37b0c3557401271f1aad)) 360 | * **CI:** disable cache ([c2bb921](https://github.com/open-rpc/inspector/commit/c2bb92129da8715b34e9aad6e94ea38501902206)) 361 | 362 | ## [1.2.7](https://github.com/open-rpc/inspector/compare/1.2.6...1.2.7) (2019-12-23) 363 | 364 | 365 | ### Bug Fixes 366 | 367 | * appbar should be static ([88305ee](https://github.com/open-rpc/inspector/commit/88305ee9d99b2e2fa62553c41ec1f9028d1d4f9f)) 368 | * remove packed file ([76c9a84](https://github.com/open-rpc/inspector/commit/76c9a842bde278a368fca5dbfcccddff732e9a4c)) 369 | 370 | ## [1.2.6](https://github.com/open-rpc/inspector/compare/1.2.5...1.2.6) (2019-12-16) 371 | 372 | 373 | ### Bug Fixes 374 | 375 | * clean up editors ([e742005](https://github.com/open-rpc/inspector/commit/e742005cbfc8bbae4557b8e44af090f249c528d4)) 376 | * remove console logs ([73d4e04](https://github.com/open-rpc/inspector/commit/73d4e04650aaf52c5604a24467317f2afa305e2c)) 377 | * unpack npm modules + rename JSONRequest to JSONRequestEditor ([b756454](https://github.com/open-rpc/inspector/commit/b7564548ce54a9b886022f62bb8de60a78ad5f42)) 378 | * update react to latest ([291ee08](https://github.com/open-rpc/inspector/commit/291ee08afb6036e6ce289a7c928213ae6a89a77b)) 379 | * update react-monaco-editor ([c247140](https://github.com/open-rpc/inspector/commit/c24714014db0192627718e285b2b41f37e0539ac)) 380 | * upgrade material-ui and monaco ([aef09f7](https://github.com/open-rpc/inspector/commit/aef09f7d3f8554c8a1490b7d9d4b8b839c4ea814)) 381 | * use @etclabscore/react-monaco-editor ([cb77295](https://github.com/open-rpc/inspector/commit/cb772950de73bd2826ba91e1a6b3ea4e8b6fc13b)) 382 | 383 | ## [1.2.5](https://github.com/open-rpc/inspector/compare/1.2.4...1.2.5) (2019-12-06) 384 | 385 | 386 | ### Bug Fixes 387 | 388 | * remove appbar color override ([cc82d55](https://github.com/open-rpc/inspector/commit/cc82d5567dd2ed647f8ea18e46ea5fa8d8325329)) 389 | * remove unneeded comments ([fb2f0cb](https://github.com/open-rpc/inspector/commit/fb2f0cbc4dbe5273894d08220fcc91d89566c53a)) 390 | 391 | ## [1.2.4](https://github.com/open-rpc/inspector/compare/1.2.3...1.2.4) (2019-12-06) 392 | 393 | 394 | ### Bug Fixes 395 | 396 | * ensure id is string and jsonrpc is 2.0 ([5d6841d](https://github.com/open-rpc/inspector/commit/5d6841d177c47d16f615dc4ac6fa461c4a782a46)) 397 | * inspector value update ([766b54d](https://github.com/open-rpc/inspector/commit/766b54d133d46659ac7ae973e8a006e781d01350)) 398 | 399 | ## [1.2.3](https://github.com/open-rpc/inspector/compare/1.2.2...1.2.3) (2019-12-05) 400 | 401 | 402 | ### Bug Fixes 403 | 404 | * remove extra divs ([49d29be](https://github.com/open-rpc/inspector/commit/49d29be082703ffead16804166439e8bd4bd4d5e)) 405 | 406 | ## [1.2.2](https://github.com/open-rpc/inspector/compare/1.2.1...1.2.2) (2019-12-05) 407 | 408 | 409 | ### Bug Fixes 410 | 411 | * update monaco add diagnostics ([e84af00](https://github.com/open-rpc/inspector/commit/e84af008f03b0ffe211b4e8ae2215c4e97c3e1f7)) 412 | * use monaco add diagnostics ([5aeabfd](https://github.com/open-rpc/inspector/commit/5aeabfddee568ea71fc7ac7b3aa13d5db0c63082)) 413 | 414 | ## [1.2.1](https://github.com/open-rpc/inspector/compare/1.2.0...1.2.1) (2019-12-04) 415 | 416 | 417 | ### Bug Fixes 418 | 419 | * move monaco init into editorDidMount + fix resize ([e789b3f](https://github.com/open-rpc/inspector/commit/e789b3fc5a8cd5926d43e32867ea3be6f1248ab9)) 420 | 421 | # [1.2.0](https://github.com/open-rpc/inspector/compare/1.1.0...1.2.0) (2019-11-28) 422 | 423 | 424 | ### Features 425 | 426 | * add openrpc method object support ([bd149fc](https://github.com/open-rpc/inspector/commit/bd149fc1535e1b3ce3cc783172728d96e3b5d2f5)) 427 | 428 | # [1.1.0](https://github.com/open-rpc/inspector/compare/1.0.7...1.1.0) (2019-11-23) 429 | 430 | 431 | ### Features 432 | 433 | * improve editor and result views ([8e2988d](https://github.com/open-rpc/inspector/commit/8e2988dc0eb4b154df04b41c44e13b83c1feb503)), closes [#1](https://github.com/open-rpc/inspector/issues/1) 434 | 435 | ## [1.0.7](https://github.com/open-rpc/inspector/compare/1.0.6...1.0.7) (2019-09-20) 436 | 437 | 438 | ### Bug Fixes 439 | 440 | * **client-js:** handle errors ([71b0fb0](https://github.com/open-rpc/inspector/commit/71b0fb0)), closes [#15](https://github.com/open-rpc/inspector/issues/15) 441 | 442 | ## [1.0.6](https://github.com/open-rpc/inspector/compare/1.0.5...1.0.6) (2019-08-19) 443 | 444 | 445 | ### Bug Fixes 446 | 447 | * **package:** add @types/qs to devDeps ([0948180](https://github.com/open-rpc/inspector/commit/0948180)) 448 | * **package:** npm export ([fbc40b7](https://github.com/open-rpc/inspector/commit/fbc40b7)) 449 | * **README:** typo with params ([e8f37c9](https://github.com/open-rpc/inspector/commit/e8f37c9)) 450 | 451 | ## [1.0.5](https://github.com/open-rpc/inspector/compare/1.0.4...1.0.5) (2019-08-19) 452 | 453 | 454 | ### Bug Fixes 455 | 456 | * add query string configuration ([95bc328](https://github.com/open-rpc/inspector/commit/95bc328)) 457 | * **App:** inspector element line length ([c8477c3](https://github.com/open-rpc/inspector/commit/c8477c3)) 458 | * **README:** add docs on url configuration ([c7d737d](https://github.com/open-rpc/inspector/commit/c7d737d)) 459 | 460 | ## [1.0.4](https://github.com/open-rpc/inspector/compare/1.0.3...1.0.4) (2019-08-19) 461 | 462 | 463 | ### Bug Fixes 464 | 465 | * update url when props.url changes ([2e5c58d](https://github.com/open-rpc/inspector/commit/2e5c58d)) 466 | 467 | ## [1.0.3](https://github.com/open-rpc/inspector/compare/1.0.2...1.0.3) (2019-08-19) 468 | 469 | 470 | ### Bug Fixes 471 | 472 | * refactor dark mode ([4c1e947](https://github.com/open-rpc/inspector/commit/4c1e947)) 473 | 474 | ## [1.0.2](https://github.com/open-rpc/inspector/compare/1.0.1...1.0.2) (2019-08-19) 475 | 476 | 477 | ### Bug Fixes 478 | 479 | * add App wrapper and hideToggleTheme ([4bd3b4a](https://github.com/open-rpc/inspector/commit/4bd3b4a)) 480 | 481 | ## [1.0.1](https://github.com/open-rpc/inspector/compare/1.0.0...1.0.1) (2019-08-18) 482 | 483 | 484 | ### Bug Fixes 485 | 486 | * publish access public ([dbcf09f](https://github.com/open-rpc/inspector/commit/dbcf09f)) 487 | 488 | # 1.0.0 (2019-08-18) 489 | 490 | 491 | ### Bug Fixes 492 | 493 | * add CNAME to public folder ([be3050a](https://github.com/open-rpc/inspector/commit/be3050a)) 494 | * **README:** add inspector readme ([6814619](https://github.com/open-rpc/inspector/commit/6814619)) 495 | 496 | 497 | ### Features 498 | 499 | * initial commit ([893136f](https://github.com/open-rpc/inspector/commit/893136f)) 500 | 501 | ## [1.0.2](https://github.com/etclabscore/pristine-typescript-react/compare/1.0.1...1.0.2) (2019-07-02) 502 | 503 | 504 | ### Bug Fixes 505 | 506 | * add homepage to fix gh-pages ([dcb2099](https://github.com/etclabscore/pristine-typescript-react/commit/dcb2099)) 507 | 508 | ## [1.0.1](https://github.com/etclabscore/pristine-typescript-react/compare/1.0.0...1.0.1) (2019-07-02) 509 | 510 | 511 | ### Bug Fixes 512 | 513 | * **.releaserc:** remove npm publish ([2ee1fce](https://github.com/etclabscore/pristine-typescript-react/commit/2ee1fce)) 514 | 515 | # 1.0.0 (2019-07-02) 516 | 517 | 518 | ### Bug Fixes 519 | 520 | * **jest:** use passWithNoTests ([f7fdd6c](https://github.com/etclabscore/pristine-typescript-react/commit/f7fdd6c)) 521 | 522 | 523 | ### Features 524 | 525 | * initial commit ([2cf2f38](https://github.com/etclabscore/pristine-typescript-react/commit/2cf2f38)) 526 | -------------------------------------------------------------------------------- /CIRCLECI.md: -------------------------------------------------------------------------------- 1 | # CircleCI 2 | 3 | ## Deploying 4 | 5 | Deploy by signing into [circleci.com](http://circleci.com/) with github. Add and set up your project. 6 | 7 | You can add your github token by clicking on a projects `settings` icon and going to `Environment Variables` and adding: 8 | 9 | ### `GH_TOKEN` 10 | ` 11 | [create a personal access token for a public github here](https://github.com/settings/tokens/new?scopes=public_repo). 12 | 13 | When creating the token, the minimum required scopes are: 14 | 15 | - repo for a private repository 16 | - public_repo for a public repository 17 | 18 | ## HOLD 19 | 20 | Once set up properly it will be building a `workflow` that puts your `release` job `ON HOLD` until manually approved. This lets you batch up fixes and features into 1 release and still have the convenience of a 1 button deploy. 21 | 22 | ## Github Releases 23 | On successfull release, it will create release notes and a new release and publish to github and github pages. 24 | 25 | ## Github Pages 26 | 27 | You can view your deployed react site at the `homepage` url required to be changed in the `package.json` mentioned in the [README.md](README.md) 28 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | > This document is inspired by [elasticsearch/CONTRIBUTING.md](https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md) 4 | 5 | Adding a `CONTRIBUTING.md` to a Github repository enables a link to that file in the pull request or create an issue page. This document should guide potential contributors toward making a successful and meaningful impact on the project, and can save maintainers time and hassle caused by improper pull requests and issues. You can learn more about the features that are enabled by Github when this file is present [here](https://help.github.com/articles/setting-guidelines-for-repository-contributors/). 6 | 7 | ## How to contribute 8 | 9 | There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, [submitting Github issues](https://help.github.com/articles/creating-an-issue/), bug reports, feature requests and writing code. 10 | 11 | ## License 12 | 13 | This repository uses the [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). 14 | 15 | ## Bug reports 16 | 17 | If you think you've found a bug in the software, first make sure you're testing against the *latest* version of the software -- your issue may have been fixed already. If it's not, please check out the issues list on Github and search for similar issues that have already been opened. If there are no issues then please [submit a Github issue](https://help.github.com/articles/creating-an-issue/). 18 | 19 | If you can provide a small test case it would greatly help the reproduction of a bug, as well as a a screenshot, and any other information you can provide. 20 | 21 | 22 | ## Feature Requests 23 | 24 | If there are features that do not exist yet, we are definitely open to feature requests and detailed proposals. [Open an issue](https://help.github.com/articles/creating-an-issue/) on our Github which describes the feature or proposal in detail, answer questions like why? how? 25 | 26 | ## Contributing Code and Documentation Changes 27 | 28 | Bug fixes, patches and new features are welcome. Please find or open an issue about it first. Talk about what exactly want to do, someone may already be working on it, or there might be some issues that you need to be aware of before implementing the fix. 29 | 30 | There are many ways to fix a problem and it is important to find the best approach before writing a ton of code. 31 | 32 | ##### Documentation Changes 33 | 34 | For small documentation changes and fixes, these can be done quickly following this video guide on [how to contribute to Open Source in 1 minute on Github](https://www.youtube.com/watch?v=kRYk1-yKwWs). 35 | 36 | ### Forking the repository 37 | 38 | [How to fork a repository](https://help.github.com/articles/fork-a-repo/). 39 | 40 | ### Submitting changes 41 | 42 | 1. Review & Test changes 43 | * If the code changed, then test it. If documentation changed, then preview the rendered Markdown. 44 | 2. Commiting 45 | * Follow the [Conventional Commits](CONVENTIONAL_COMMITS.md) guidelines to create a commit message. 46 | 3. Sign the CLA 47 | * Make sure you've signed the repository's Contributor License Agreement. We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once. 48 | 4. Submit a pull request 49 | * Push local changes to your forked repository and make a pull request. Follow the [Convention Commits](CONVENTIONAL_COMMITS.md) guidelines for naming Github pull requests and what to put in the body. 50 | 51 | 52 | ## Building 53 | 54 | Follow the build process is outlined in [BUILDING.md](BUILDING.md) to create a build. 55 | 56 | 57 | ## Releasing 58 | 59 | Follow the release process is outlined in [RELEASING.md](RELEASING.md) to create a release. 60 | 61 | 62 | -------------------------------------------------------------------------------- /CONVENTIONAL_COMMITS.md: -------------------------------------------------------------------------------- 1 | # Conventional Commits 1.0.0-beta.2 2 | 3 | > This spec is a direct copy from [http://conventionalcommits.org](http://conventionalcommits.org). It lives here as a reference document for new contributors. 4 | 5 | ## Summary 6 | 7 | The [Conventional Commits](http://conventionalcommits.org) specification is a lightweight convention on top of commit messages. 8 | It provides an easy set of rules for creating an explicit commit history; 9 | which makes it easier to write automated tools on top of. 10 | This convention dovetails with [SemVer](http://semver.org), 11 | by describing the features, fixes, and breaking changes made in commit messages. 12 | 13 | The commit message should be structured as follows: 14 | 15 | --- 16 | 17 | ``` 18 | [optional scope]: 19 | 20 | [optional body] 21 | 22 | [optional footer] 23 | ``` 24 | --- 25 | 26 |
27 | The commit contains the following structural elements, to communicate intent to the 28 | consumers of your library: 29 | 30 | 1. **fix:** a commit of the _type_ `fix` patches a bug in your codebase (this correlates with [`PATCH`](http://semver.org/#summary) in semantic versioning). 31 | 1. **feat:** a commit of the _type_ `feat` introduces a new feature to the codebase (this correlates with [`MINOR`](http://semver.org/#summary) in semantic versioning). 32 | 1. **BREAKING CHANGE:** a commit that has the text `BREAKING CHANGE:` at the beginning of its optional body or footer section introduces a breaking API change (correlating with [`MAJOR`](http://semver.org/#summary) in semantic versioning). 33 | A BREAKING CHANGE can be part of commits of any _type_. 34 | 1. Others: commit _types_ other than `fix:` and `feat:` are allowed, for example [commitlint-config-conventional](https://github.com/marionebl/commitlint/tree/master/%40commitlint/config-conventional) (based on the [the Angular convention](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines)) recommends `chore:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, and others. 35 | We also recommend `improvement` for commits that improve a current implementation without adding a new feature or fixing a bug. 36 | Notice these types are not mandated by the conventional commits specification, and have no implicit effect in semantic versioning (unless they include a BREAKING CHANGE). 37 |
38 | A scope may be provided to a commit's type, to provide additional contextual information and is contained within parenthesis, e.g., `feat(parser): add ability to parse arrays`. 39 | 40 | ## Examples 41 | 42 | ### Commit message with description and breaking change in body 43 | ``` 44 | feat: allow provided config object to extend other configs 45 | 46 | BREAKING CHANGE: `extends` key in config file is now used for extending other config files 47 | ``` 48 | 49 | ### Commit message with no body 50 | ``` 51 | docs: correct spelling of CHANGELOG 52 | ``` 53 | 54 | ### Commit message with scope 55 | ``` 56 | feat(lang): added polish language 57 | ``` 58 | 59 | ### Commit message for a fix using an (optional) issue number. 60 | ``` 61 | fix: minor typos in code 62 | 63 | see the issue for details on the typos fixed 64 | 65 | fixes issue #12 66 | ``` 67 | ## Specification 68 | 69 | The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). 70 | 71 | 1. Commits MUST be prefixed with a type, which consists of a noun, `feat`, `fix`, etc., followed by a colon and a space. 72 | 1. The type `feat` MUST be used when a commit adds a new feature to your application or library. 73 | 1. The type `fix` MUST be used when a commit represents a bug fix for your application. 74 | 1. An optional scope MAY be provided after a type. A scope is a phrase describing a section of the codebase enclosed in parenthesis, e.g., `fix(parser):` 75 | 1. A description MUST immediately follow the type/scope prefix. 76 | The description is a short description of the code changes, e.g., _fix: array parsing issue when multiple spaces were contained in string._ 77 | 1. A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description. 78 | 1. A footer MAY be provided one blank line after the body. 79 | The footer SHOULD contain additional issue references about the code changes (such as the issues it fixes, e.g.,`Fixes #13`). 80 | 1. Breaking changes MUST be indicated at the very beginning of the footer or body section of a commit. A breaking change MUST consist of the uppercase text `BREAKING CHANGE`, followed by a colon and a space. 81 | 1. A description MUST be provided after the `BREAKING CHANGE: `, describing what has changed about the API, e.g., _BREAKING CHANGE: environment variables now take precedence over config files._ 82 | 1. The footer MUST only contain `BREAKING CHANGE`, external links, issue references, and other meta-information. 83 | 1. Types other than `feat` and `fix` MAY be used in your commit messages. 84 | 85 | ## Why Use Conventional Commits 86 | 87 | * Automatically generating CHANGELOGs. 88 | * Automatically determining a semantic version bump (based on the types of commits landed). 89 | * Communicating the nature of changes to teammates, the public, and other stakeholders. 90 | * Triggering build and publish processes. 91 | * Making it easier for people to contribute to your projects, by allowing them to explore 92 | a more structured commit history. 93 | 94 | ## FAQ 95 | 96 | ### How should I deal with commit messages in the initial development phase? 97 | 98 | We recommend that you proceed as if you've an already released product. Typically *somebody*, even if its your fellow software developers, is using your software. They'll want to know what's fixed, what breaks etc. 99 | 100 | ### Are the types in the commit title uppercase or lowercase? 101 | 102 | Any casing may be used, but it's best to be consistent. 103 | 104 | ### What do I do if the commit conforms to more than one of the commit types? 105 | 106 | Go back and make multiple commits whenever possible. Part of the benefit of Conventional Commits is its ability to drive us to make more organized commits and PRs. 107 | 108 | ### Doesn’t this discourage rapid development and fast iteration? 109 | 110 | It discourages moving fast in a disorganized way. It helps you be able to move fast long term across multiple projects with varied contributors. 111 | 112 | ### Might Conventional Commits lead developers to limit the type of commits they make because they'll be thinking in the types provided? 113 | 114 | Conventional Commits encourages us to make more of certain types of commits such as fixes. Other than that, the flexibility of Conventional Commits allows your team to come up with their own types and change those types over time. 115 | 116 | ### How does this relate to SemVer? 117 | 118 | `fix` type commits should be translated to `PATCH` releases. `feat` type commits should be translated to `MINOR` releases. Commits with `BREAKING CHANGE` in the commits, regardless of type, should be translated to `MAJOR` releases. 119 | 120 | ### How should I version my extensions to the Conventional Commits Specification, e.g. `@jameswomack/conventional-commit-spec`? 121 | 122 | We recommend using SemVer to release your own extensions to this specification (and 123 | encourage you to make these extensions!) 124 | 125 | ### What do I do if I accidentally use the wrong commit type? 126 | 127 | #### When you used a type that's of the spec but not the correct type, e.g. `fix` instead of `feat` 128 | 129 | Prior to merging or releasing the mistake, we recommend using `git rebase -i` to edit the commit history. After release, the cleanup will be different according to what tools and processes you use. 130 | 131 | #### When you used a type *not* of the spec, e.g. `feet` instead of `feat` 132 | 133 | In a worst case scenario, it's not the end of the world if a commit lands that does not meet the conventional commit specification. It simply means that commit will be missed by tools that are based on the spec. 134 | 135 | ### Do all my contributors need to use the conventional commit specification? 136 | 137 | No! If you use a squash based workflow on Git lead maintainers can cleanup the commit messages as they're merged—adding no workload to casual committers. 138 | A common workflow for this is to have your git system automatically squash commits from a pull request and present a form for the lead maintainer to enter the proper git commit message for the merge. 139 | 140 | ## About 141 | 142 | The Conventional Commit specification is inspired by, and based heavily on, the [Angular Commit Guidelines](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines). 143 | 144 | The first draft of this specification has been written in collaboration with some of the folks contributing to: 145 | 146 | * [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog): a set of tools for parsing conventional commit messages from git histories. 147 | * [bumped](https://bumped.github.io): a tool for releasing software that makes it easy to perform actions before and after releasing a new version of your software. 148 | * [unleash](https://github.com/netflix/unleash): a tool for automating the software release and publishing lifecycle. 149 | * [lerna](https://github.com/lerna/lerna): a tool for managing monorepos, which grew out of the Babel project. 150 | 151 | ## Tooling for Conventional Commits 152 | 153 | * [conform](https://github.com/autonomy/conform): a tool that can be used to enforce policies on git repositories, including conventional commits. 154 | 155 | ## Projects Using Conventional Commits 156 | 157 | * [yargs](https://github.com/yargs/yargs): everyone's favorite pirate themed command line argument parser. 158 | * [istanbuljs](https://github.com/istanbuljs/istanbuljs): a collection of open-source tools and libraries for adding test coverage to your JavaScript tests. 159 | * [standard-version](https://github.com/conventional-changelog/standard-version): Automatic versioning and CHANGELOG management, using GitHub's new squash button and the recommended Conventional Commits workflow. 160 | * [uPortal-home](https://github.com/UW-Madison-DoIT/angularjs-portal) and [uPortal-application-framework](https://github.com/UW-Madison-DoIT/uw-frame): Optional supplemental user interface enhancing [Apereo uPortal](https://www.apereo.org/projects/uportal). 161 | * [massive.js](https://github.com/dmfay/massive-js): A data access library for Node and PostgreSQL. 162 | * [electron](https://github.com/electron/electron): Build cross-platform desktop apps with JavaScript, HTML, and CSS. 163 | * [scroll-utility](https://github.com/LeDDGroup/scroll-utility): A simple to use scroll utility package for centering elements, and smooth animations 164 | * [Blaze UI](https://github.com/BlazeUI/blaze): Framework-free open source modular toolkit. 165 | 166 | [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) 167 | 168 | _want your project on this list?_ [send a pull request](https://github.com/conventional-changelog/conventionalcommits.org/pulls). 169 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenRPC Inspector 2 | 3 | OpenRPC Inspector is a simple tool to create, modify and execute JSON-RPC requests. 4 | 5 | - Edit JSON-RPC request 6 | - Test JSON-RPC request against a given URL 7 | 8 | It can be used as a standalone tool or included in other projects. 9 | 10 | ![inspector_history](https://user-images.githubusercontent.com/364566/76125093-ef2fee00-5fb0-11ea-818e-04becc063bee.gif) 11 | 12 | https://inspector.open-rpc.org 13 | 14 | Need help or have a question? Join us on [Discord](https://discord.gg/gREUKuF)! 15 | 16 | ### Url configuration 17 | 18 | You can configure the default request, url and transport via url params: 19 | 20 | `?url=http://localhost:8545` 21 | 22 | `?request[jsonrpc]=2.0&request[method]=eth_chainId&request[id]=0` 23 | 24 | `?transport=websocket` 25 | 26 | here is a full example: 27 | 28 | https://inspector.open-rpc.org/?url=https://mock.open-rpc.org/petstore-1.0.0&?request[jsonrpc]=2.0&request[method]=list_pets&request[id]=0 29 | 30 | ### Contributing 31 | 32 | How to contribute, build and release are outlined in [CONTRIBUTING.md](CONTRIBUTING.md), [BUILDING.md](BUILDING.md) and [RELEASING.md](RELEASING.md) respectively. Commits in this repository follow the [CONVENTIONAL_COMMITS.md](CONVENTIONAL_COMMITS.md) specification. 33 | 34 | # Resources 35 | - [open-rpc/client-js](https://github.com/open-rpc/client-js) 36 | - [open-rpc/logs-react](https://github.com/open-rpc/logs-react) 37 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | # Releasing 2 | 3 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) [RFC2119](https://tools.ietf.org/html/rfc2119) [RFC8174](https://tools.ietf.org/html/rfc8174) when, and only when, they appear in all capitals, as shown here. 4 | 5 | This document is licensed under [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). 6 | 7 | When using the name 'version' we mean the versioning scheme described in [VERSIONING.md](VERSIONING.md) 8 | 9 | ## Introduction 10 | 11 | This document is to describe the release pipeline, which is taking the result of the artifacts created according to [BUILDING.md](BUILDING.md) and publish a release to the various release targets for the project. 12 | 13 | We propose: 14 | - a set of release targets that are allowable 15 | - a pipeline for handling the release folder's artifacts 16 | 17 | It is NOT the purpose of this document to describe how a project might create a build, NOR is it describing a strcture in which projects MUST write build artifacts to. It is describing the structure of the releases themselves. 18 | 19 | ## Release Pipeline 20 | 21 | Each Pristine project MUST provide a `bin/release.sh` script which will make a release to the various targets. 22 | 23 | Each target may be scripted directly into the `bin/release.sh` shell script, or it may be broken down into files following the pattern:`./bin/release.{target}.sh`. 24 | 25 | While the `.sh` extension is mandatory, the scripts may be written with one of the following headers: 26 | - `#!bin/sh` 27 | - `#!bin/node` 28 | - `#!/usr/bin/env node` 29 | 30 | ### Create a build from current branch 31 | 32 | Process is outlined in [BUILDING.md](BUILDING.md) 33 | 34 | 1. Clean the build directory 35 | 2. run: `bin/build.{target}.{ext}` 36 | 37 | ### Bump the version of the project 38 | 39 | Projects SHOULD automate the version bump following [CONVENTIONAL_COMMITS.md](CONVENTIONAL_COMMITS.md). 40 | 41 | ### Generate Changelog 42 | 43 | Projects SHOULD use generated changelogs from following [CONVENTIONAL_COMMITS.md](CONVENTIONAL_COMMITS.md). 44 | 45 | ### Commit the bump + changelog update 46 | 47 | A project MUST generate a commit with the changes. 48 | 49 | ### Tag the commit with the bumped version 50 | 51 | A project MUST be tagged with the semantic versioning scheme from [VERSIONING.md](VERSIONING.md). 52 | 53 | ### Sign the releases. 54 | 55 | - MUST be a pgp signature 56 | - MUST be the same pgp key as is registered with Github 57 | - MUST be a detached ascii-armored (.asc) signature 58 | - All files in the build folder MUST have an associated signature file 59 | 60 | ### Push changelog & version bump 61 | 62 | ### Run Release Targets 63 | 64 | For each of the desired release targets, prepare and push the release. 65 | 66 | #### Example Release Targets 67 | 68 | 1. Github 69 | 2. Docker Hub 70 | 71 | ## Resources 72 | 73 | - [semantic-release](https://github.com/semantic-release/semantic-release) 74 | - [Conventional Commits](https://conventionalcommits.org/) 75 | -------------------------------------------------------------------------------- /VERSIONING.md: -------------------------------------------------------------------------------- 1 | # Versioning 2 | 3 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) [RFC2119](https://tools.ietf.org/html/rfc2119) [RFC8174](https://tools.ietf.org/html/rfc8174) when, and only when, they appear in all capitals, as shown here. 4 | 5 | This document is licensed under [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). 6 | 7 | ## Introduction 8 | This document is to describe how a project is to version its releases 9 | 10 | It also describes standardized tooling around manipulating the version 11 | 12 | ## Semver 13 | A project MUST use Semantic Versioning [semver](https://semver.org). Build metadata MAY NOT be used in a project. Build metadata SHOULD be ignored. 14 | 15 | A Basic summary of Semantic Versioning taken from: [semver.org](https://semver.org) 16 | 17 | ### Summary: 18 | 19 | Given a version number MAJOR.MINOR.PATCH, increment the: 20 | 21 | MAJOR version when you make incompatible API changes, 22 | MINOR version when you add functionality in a backwards-compatible manner, and 23 | PATCH version when you make backwards-compatible bug fixes. 24 | Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format. 25 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | clearMocks: true, 3 | coverageDirectory: '../coverage', 4 | resetMocks: true, 5 | restoreMocks: true, 6 | rootDir: './src', 7 | testEnvironment: 'jsdom', 8 | preset: 'ts-jest' 9 | }; 10 | -------------------------------------------------------------------------------- /monaco-rescript.js: -------------------------------------------------------------------------------- 1 | const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); 2 | const { prependWebpackPlugin } = require("@rescripts/utilities"); 3 | 4 | module.exports = function override(config, env) { 5 | return prependWebpackPlugin(new MonacoWebpackPlugin({ 6 | // available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options 7 | languages: ["json"] 8 | }), config); 9 | } 10 | -------------------------------------------------------------------------------- /openrpc.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-rpc/inspector/f6fdf378cc962ed3655ea7b9dac70f36ecd5bbf5/openrpc.json -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@open-rpc/inspector", 3 | "version": "0.0.0-development", 4 | "description": "", 5 | "main": "package/index.js", 6 | "files": [ 7 | "package/" 8 | ], 9 | "publishConfig": { 10 | "access": "public" 11 | }, 12 | "scripts": { 13 | "start": "rescripts start", 14 | "build": "rescripts build", 15 | "lint": "tslint --fix -p .", 16 | "test": "npm run lint && rescripts test --coverage --passWithNoTests", 17 | "build:package": "tsc --noEmit false --outDir package --jsx react --declaration true --allowJs false --isolatedModules false --target es5 --module commonjs && mv package/exports.d.ts package/index.d.ts && mv package/exports.js package/index.js" 18 | }, 19 | "rescripts": [ 20 | "monaco-rescript" 21 | ], 22 | "author": "", 23 | "license": "Apache-2.0", 24 | "devDependencies": { 25 | "@rescripts/cli": "0.0.13", 26 | "@rescripts/utilities": "0.0.6", 27 | "@types/jest": "^24.0.13", 28 | "@types/qs": "^6.5.3", 29 | "@types/react-dom": "^16.8.4", 30 | "@types/use-persisted-state": "^0.3.0", 31 | "jest": "24.9.0", 32 | "monaco-editor-webpack-plugin": "^1.7.0", 33 | "react-scripts": "^3.3.0", 34 | "ts-jest": "^24.0.2", 35 | "tslint": "^5.17.0", 36 | "typescript": "^3.7.3" 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | }, 50 | "dependencies": { 51 | "@etclabscore/monaco-add-json-schema-diagnostics": "^1.0.3", 52 | "@etclabscore/react-monaco-editor": "^1.0.4", 53 | "@material-ui/core": "4.9.8", 54 | "@material-ui/icons": "3.0.2", 55 | "@material-ui/lab": "4.0.0-alpha.47", 56 | "@monaco-editor/react": "^2.3.0", 57 | "@open-rpc/client-js": "^1.6.3", 58 | "@open-rpc/logs-react": "^1.2.0", 59 | "@open-rpc/meta-schema": "^1.14.9", 60 | "@open-rpc/schema-utils-js": "^1.14.3", 61 | "@rehooks/window-size": "^1.0.2", 62 | "acorn-dynamic-import": "^4.0.0", 63 | "monaco-editor": "^0.18.1", 64 | "monaco-vim": "0.0.14", 65 | "qs": "^6.8.0", 66 | "react": "^16.12.0", 67 | "react-dom": "^16.12.0", 68 | "react-json-view": "^1.19.1", 69 | "react-split-pane": "^0.1.87", 70 | "semantic-release": "^15.13.21", 71 | "use-dark-mode": "^2.3.1", 72 | "use-debounce": "^3.3.0", 73 | "use-persisted-state": "^0.3.3" 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /public/CNAME: -------------------------------------------------------------------------------- 1 | inspector.open-rpc.org 2 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | height: 100%; 4 | overflow: hidden; 5 | } 6 | ::-webkit-scrollbar { 7 | width: 10px; 8 | } 9 | 10 | ::-webkit-scrollbar-track { 11 | background: #666; 12 | z-index: 1; 13 | } 14 | 15 | ::-webkit-scrollbar-thumb { 16 | background: #ddd; 17 | border-radius: 5px; 18 | } 19 | 20 | .Resizer { 21 | z-index: 1; 22 | } 23 | 24 | .react-json-view, .object-key-val, .object-container, .object-content { 25 | background: transparent !important; 26 | } 27 | -------------------------------------------------------------------------------- /src/components/TransportDropdown.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, ChangeEvent } from "react"; 2 | import { Button, Menu, MenuItem, Typography, Dialog, Container, Grid, InputBase } from "@material-ui/core"; 3 | import { CSSProperties } from "@material-ui/core/styles/withStyles"; 4 | import PlusIcon from "@material-ui/icons/Add"; 5 | import DropdownArrowIcon from "@material-ui/icons/ArrowDropDown"; 6 | import { ITransport } from "../hooks/useTransport"; 7 | 8 | interface IProps { 9 | transports: ITransport[]; 10 | selectedTransport: ITransport; 11 | onChange: (changedTransport: ITransport) => void; 12 | onAddTransport: (addedTransport: ITransport) => void; 13 | style?: CSSProperties; 14 | } 15 | 16 | const TransportDropdown: React.FC = ({ selectedTransport, transports, onChange, style, onAddTransport }) => { 17 | const handleClick = (event: React.MouseEvent) => { 18 | setAnchorEl(event.currentTarget); 19 | }; 20 | const handleClose = () => { 21 | setAnchorEl(null); 22 | }; 23 | const handleMenuItemClick = (transport: ITransport) => { 24 | setAnchorEl(null); 25 | // this forces language change for react + i18n react 26 | onChange(transport); 27 | }; 28 | 29 | const [anchorEl, setAnchorEl] = useState(null); 30 | const [dialogOpen, setDialogOpen] = useState(false); 31 | 32 | const [selectedCustomTransport, setSelectedCustomTransport] = useState(); 33 | const [customTransportName, setCustomTransportName] = useState(); 34 | const [customTransportUri, setCustomTransportUri] = useState(); 35 | 36 | const [dialogMenuAnchorEl, setDialogMenuAnchorEl] = useState(null); 37 | 38 | const handleDialogAnchorClose = () => { 39 | setDialogMenuAnchorEl(null); 40 | }; 41 | const handleDialogCustomTransportClick = (event: React.MouseEvent) => { 42 | setDialogMenuAnchorEl(event.currentTarget); 43 | }; 44 | 45 | const handleCustomTransportDialogMenuItemClick = (transport: ITransport) => { 46 | setDialogMenuAnchorEl(null); 47 | setSelectedCustomTransport(transport); 48 | }; 49 | 50 | const handleSubmitCustomTransport = () => { 51 | setDialogMenuAnchorEl(null); 52 | if (selectedCustomTransport && customTransportName && customTransportUri) { 53 | const t: ITransport = { 54 | type: "plugin", 55 | transport: selectedCustomTransport, 56 | name: customTransportName, 57 | uri: customTransportUri, 58 | }; 59 | onAddTransport(t); 60 | setDialogOpen(false); 61 | } 62 | }; 63 | return ( 64 |
65 | setDialogOpen(false)} aria-labelledby="simple-dialog-title" open={dialogOpen}> 66 | 67 | 72 | Custom Transport Plugin 73 | 74 | Transport plugins are created by implementing the "connect", 75 | "sendData", and "close" methods over JSON-RPC. 76 | 77 | 78 | 79 | ) => { 82 | setCustomTransportName(event.target.value); 83 | } 84 | } 85 | style={{ 86 | display: "block", 87 | background: "rgba(0,0,0,0.1)", 88 | borderRadius: "4px", 89 | padding: "0px 10px", 90 | marginRight: "5px", 91 | }} 92 | /> 93 | 94 | 95 | ) => { 98 | setCustomTransportUri(event.target.value); 99 | } 100 | } 101 | style={{ 102 | display: "block", 103 | background: "rgba(0,0,0,0.1)", 104 | borderRadius: "4px", 105 | padding: "0px 10px", 106 | marginRight: "5px", 107 | }} 108 | /> 109 | 110 | 111 | 116 | 117 | 118 | 125 | {transports.filter((value) => value.type !== "plugin").map((transport, i) => ( 126 | handleCustomTransportDialogMenuItemClick(transport)} 128 | >{transport.name} 129 | ))} 130 | 131 | 138 | 139 | 140 | 141 | 149 | 156 | {transports.map((transport, i) => ( 157 | handleMenuItemClick(transport)}>{transport.name} 158 | ))} 159 | setDialogOpen(true)}> 160 | Add Transport 161 | 162 | 163 |
164 | ); 165 | }; 166 | 167 | export default TransportDropdown; 168 | -------------------------------------------------------------------------------- /src/containers/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { CssBaseline } from "@material-ui/core"; 3 | import { MuiThemeProvider } from "@material-ui/core"; 4 | 5 | import { lightTheme, darkTheme } from "../themes/openrpcTheme"; 6 | import useDarkMode from "use-dark-mode"; 7 | import Inspector from "./Inspector"; 8 | import useQueryParams from "../hooks/useQueryParams"; 9 | import * as monaco from "monaco-editor"; 10 | import useOpenrpcDocument from "../hooks/useOpenrpcDocument"; 11 | 12 | const App: React.FC = () => { 13 | const darkMode = useDarkMode(); 14 | const [query] = useQueryParams(); 15 | const theme = darkMode.value ? darkTheme : lightTheme; 16 | const openrpcDocument = useOpenrpcDocument(query.openrpcDocument, query.schemaUrl); 17 | 18 | useEffect(() => { 19 | const t = darkMode.value ? "vs-dark" : "vs"; 20 | monaco.editor.setTheme(t); 21 | }, [darkMode.value]); 22 | 23 | return ( 24 | 25 | 26 | 27 | 36 | 37 | ); 38 | }; 39 | 40 | export default App; 41 | -------------------------------------------------------------------------------- /src/containers/Inspector.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, ChangeEvent, Dispatch } from "react"; 2 | import SplitPane from "react-split-pane"; 3 | import JSONRPCRequestEditor from "./JSONRPCRequestEditor"; 4 | import PlayCircle from "@material-ui/icons/PlayCircleFilled"; 5 | import CloseIcon from "@material-ui/icons/Close"; 6 | import FlashOn from "@material-ui/icons/FlashOn"; 7 | import FlashOff from "@material-ui/icons/FlashOff"; 8 | import History from "@material-ui/icons/History"; 9 | import Keyboard from "@material-ui/icons/Keyboard"; 10 | import MonacoEditor from "@etclabscore/react-monaco-editor"; 11 | import PlusIcon from "@material-ui/icons/Add"; 12 | import DocumentIcon from "@material-ui/icons/Description"; 13 | import { 14 | IconButton, 15 | AppBar, 16 | Toolbar, 17 | Typography, 18 | Button, 19 | InputBase, 20 | Tab, 21 | Tabs, 22 | Tooltip, 23 | Grid, 24 | Dialog, 25 | ListItem, 26 | List, 27 | ListItemText, 28 | Container, 29 | } from "@material-ui/core"; 30 | import createPersistedState from "use-persisted-state"; 31 | import Brightness3Icon from "@material-ui/icons/Brightness3"; 32 | import WbSunnyIcon from "@material-ui/icons/WbSunny"; 33 | import { JSONRPCError } from "@open-rpc/client-js/build/Error"; 34 | import { OpenrpcDocument, ExampleObject } from "@open-rpc/meta-schema"; 35 | import useTabs from "../hooks/useTabs"; 36 | import { useDebounce } from "use-debounce"; 37 | import { green } from "@material-ui/core/colors"; 38 | import { parseOpenRPCDocument } from "@open-rpc/schema-utils-js"; 39 | import TransportDropdown from "../components/TransportDropdown"; 40 | import useTransport, { ITransport, IWebTransport, TTransport } from "../hooks/useTransport"; 41 | import JSONRPCLogger, { JSONRPCLog } from "@open-rpc/logs-react"; 42 | import OptionsEditor from "./OptionsEditor"; 43 | 44 | const useCustomTransportList = createPersistedState("inspector-custom-transports"); 45 | 46 | const defaultTransports: ITransport[] = [ 47 | { 48 | type: "http", 49 | name: "HTTP", 50 | schema: { 51 | type: "object", 52 | properties: { 53 | headers: { 54 | patternProperties: { 55 | "": { 56 | type: "string", 57 | }, 58 | }, 59 | }, 60 | credentials: { 61 | type: "string", 62 | enum: [ 63 | "omit", 64 | "same-origin", 65 | "include", 66 | ], 67 | }, 68 | }, 69 | examples: [ 70 | { 71 | headers: { 72 | }, 73 | }, 74 | ], 75 | }, 76 | }, 77 | { 78 | type: "websocket", 79 | name: "WebSocket", 80 | }, 81 | { 82 | type: "postmessagewindow", 83 | name: "PostMessageWindow", 84 | }, 85 | { 86 | type: "postmessageiframe", 87 | name: "PostMessageIframe", 88 | }, 89 | ]; 90 | 91 | const errorToJSON = (error: JSONRPCError | any, id?: string | number | null): any => { 92 | const isError = error instanceof Error; 93 | if (!isError) { 94 | return; 95 | } 96 | if (!error) { 97 | return; 98 | } 99 | const emptyErrorResponse = { 100 | jsonrpc: "2.0", 101 | id, 102 | }; 103 | // this is an internal wrapped client-js error 104 | if (error.data instanceof Error) { 105 | return { 106 | ...emptyErrorResponse, 107 | error: { 108 | code: error.data.code, 109 | message: error.data.message, 110 | data: error.data.data, 111 | }, 112 | }; 113 | } 114 | return { 115 | ...emptyErrorResponse, 116 | error: { 117 | code: error.code, 118 | message: error.message, 119 | data: error.data, 120 | }, 121 | }; 122 | }; 123 | 124 | interface IProps { 125 | url?: string; 126 | request?: any; 127 | darkMode?: boolean; 128 | hideToggleTheme?: boolean; 129 | openrpcDocument?: OpenrpcDocument; 130 | transport?: TTransport; 131 | customTransport?: ITransport; 132 | onToggleDarkMode?: () => void; 133 | } 134 | 135 | const emptyJSONRPC = { 136 | jsonrpc: "2.0", 137 | method: "", 138 | params: [], 139 | id: 0, 140 | }; 141 | 142 | const Inspector: React.FC = (props) => { 143 | const { 144 | setTabContent, 145 | setTabEditing, 146 | setTabIndex, 147 | tabs, 148 | setTabs, 149 | handleClose, 150 | tabIndex, 151 | setTabOpenRPCDocument, 152 | setTabUrl, 153 | handleLabelChange, 154 | setTabLogs, 155 | } = useTabs( 156 | [ 157 | { 158 | name: props.request ? props.request.method : "New Tab", 159 | content: props.request || { ...emptyJSONRPC }, 160 | logs: [], 161 | url: props.url || "", 162 | openrpcDocument: props.openrpcDocument, 163 | }, 164 | ], 165 | ); 166 | const [openrpcDocument, setOpenRpcDocument] = useState(props.openrpcDocument); 167 | const [json, setJson] = useState(props.request || { 168 | jsonrpc: "2.0", 169 | method: "", 170 | params: [], 171 | id: 0, 172 | }); 173 | const [transportList, setTransportList] = useCustomTransportList(() => { 174 | if (props.customTransport) { 175 | return [...defaultTransports, props.customTransport]; 176 | } 177 | return defaultTransports; 178 | }); 179 | const [url, setUrl] = useState(props.url || ""); 180 | const [debouncedUrl] = useDebounce(url, 1000); 181 | const [selectedTransport, setSelectedTransport] = useState(props.customTransport || defaultTransports[0]); 182 | const [transportOptions, setTransportOptions] = useState(); 183 | const [debouncedtransportOptions] = useDebounce(transportOptions, 1000); 184 | const [transport, setTransport, , connected] = useTransport( 185 | transportList, 186 | debouncedUrl, 187 | props.customTransport || defaultTransports[0], 188 | debouncedtransportOptions, 189 | ); 190 | const [historyOpen, setHistoryOpen] = useState(false); 191 | const [requestHistory, setRequestHistory]: [any[], Dispatch] = useState([]); 192 | const [historySelectedIndex, setHistorySelectedIndex] = useState(0); 193 | const [logs, setLogs] = useState([]); 194 | useEffect(() => { 195 | setTabs([ 196 | ...tabs, 197 | { 198 | name: props.request ? props.request.method || "New Tab" : "New Tab", 199 | content: props.request, 200 | url: props.url, 201 | openrpcDocument, 202 | }, 203 | ]); 204 | setTabIndex(tabs.length); 205 | // eslint-disable-next-line react-hooks/exhaustive-deps 206 | }, [props.request]); 207 | 208 | useEffect(() => { 209 | if (selectedTransport !== undefined) { 210 | setTransport(selectedTransport); 211 | const s: IWebTransport = selectedTransport as IWebTransport; 212 | if (s.schema !== undefined && s.schema !== true && s.schema !== false) { 213 | setTransportOptions((s.schema.examples as ExampleObject[])[0]); 214 | } 215 | } 216 | // eslint-disable-next-line react-hooks/exhaustive-deps 217 | }, [selectedTransport]); 218 | 219 | useEffect(() => { 220 | if (json) { 221 | setTabContent(tabIndex, json); 222 | } 223 | // eslint-disable-next-line react-hooks/exhaustive-deps 224 | }, [json]); 225 | 226 | useEffect(() => { 227 | if (props.transport) { 228 | const t = transportList 229 | .find((tp: ITransport) => tp.name?.toLowerCase() === props.transport?.toLowerCase()); 230 | if (t) { 231 | setSelectedTransport(t); 232 | } 233 | } 234 | // eslint-disable-next-line react-hooks/exhaustive-deps 235 | }, [props.transport]); 236 | 237 | useEffect(() => { 238 | if (props.url) { 239 | setUrl(props.url); 240 | setTabUrl(tabIndex, props.url); 241 | } 242 | // eslint-disable-next-line react-hooks/exhaustive-deps 243 | }, [props.url]); 244 | 245 | const handlePlayButton = async () => { 246 | let requestTimestamp = new Date(); 247 | if (transport) { 248 | try { 249 | requestTimestamp = new Date(); 250 | const result = await transport.sendData({ 251 | internalID: json.id, 252 | request: json, 253 | }); 254 | const responseTimestamp = new Date(); 255 | const r = { jsonrpc: "2.0", result, id: json.id }; 256 | const reqObj: JSONRPCLog = { 257 | type: "request", 258 | method: json.method, 259 | timestamp: requestTimestamp, 260 | payload: json, 261 | }; 262 | const resObj: JSONRPCLog = { 263 | type: "response", 264 | method: json.method, 265 | timestamp: responseTimestamp, 266 | payload: r, 267 | }; 268 | const newHistory: any = [...requestHistory, { ...tabs[tabIndex] }]; 269 | setRequestHistory(newHistory); 270 | setLogs((prevLogs) => [...prevLogs, reqObj, resObj]); 271 | setTabLogs(tabIndex, [...(tabs[tabIndex].logs || []), reqObj, resObj]); 272 | } catch (e) { 273 | const responseTimestamp = new Date(); 274 | const convertedError = errorToJSON(e, json.id); 275 | const reqObj: JSONRPCLog = { 276 | type: "request", 277 | method: json.method, 278 | timestamp: requestTimestamp, 279 | payload: json, 280 | }; 281 | const resObj: JSONRPCLog = { 282 | type: "response", 283 | method: json.method, 284 | timestamp: responseTimestamp, 285 | payload: convertedError, 286 | }; 287 | const newHistory: any = [...requestHistory, { ...tabs[tabIndex] }]; 288 | setRequestHistory(newHistory); 289 | setLogs((prevLogs) => [...prevLogs, reqObj, resObj]); 290 | setTabLogs(tabIndex, [...(tabs[tabIndex].logs || []), reqObj, resObj]); 291 | } 292 | } 293 | }; 294 | 295 | const clear = () => { 296 | setLogs([]); 297 | setTabLogs(tabIndex, []); 298 | }; 299 | 300 | const handleClearButton = () => { 301 | clear(); 302 | }; 303 | 304 | const handleToggleDarkMode = () => { 305 | if (props.onToggleDarkMode) { 306 | props.onToggleDarkMode(); 307 | } 308 | }; 309 | const refreshOpenRpcDocument = async () => { 310 | try { 311 | const d = await transport?.sendData({ 312 | internalID: 999999, 313 | request: { 314 | jsonrpc: "2.0", 315 | params: [], 316 | id: 999999, 317 | method: "rpc.discover", 318 | }, 319 | }); 320 | const doc = await parseOpenRPCDocument(d); 321 | setOpenRpcDocument(doc); 322 | setTabOpenRPCDocument(tabIndex, doc); 323 | } catch (e) { 324 | if (!props.openrpcDocument) { 325 | setOpenRpcDocument(undefined); 326 | setTabOpenRPCDocument(tabIndex, undefined); 327 | } 328 | } 329 | if (transport) { 330 | transport.subscribe("notification", (notification: any) => { 331 | const responseTimestamp = new Date(); 332 | const notificationObj: JSONRPCLog = { 333 | type: "response", 334 | notification: true, 335 | method: notification.method, 336 | timestamp: responseTimestamp, 337 | payload: notification, 338 | }; 339 | setLogs((prevLogs) => [...prevLogs, notificationObj]); 340 | setTabLogs(tabIndex, [...(tabs[tabIndex].logs || []), notificationObj]); 341 | }); 342 | transport.subscribe("error", (error: any) => { 343 | const responseTimestamp = new Date(); 344 | const notificationObj: JSONRPCLog = { 345 | type: "response", 346 | method: "", 347 | timestamp: responseTimestamp, 348 | payload: errorToJSON(error, null), 349 | }; 350 | setLogs((prevLogs) => [...prevLogs, notificationObj]); 351 | setTabLogs(tabIndex, [...(tabs[tabIndex].logs || []), notificationObj]); 352 | }); 353 | } 354 | }; 355 | useEffect(() => { 356 | if (!props.openrpcDocument) { 357 | setOpenRpcDocument(undefined); 358 | } 359 | refreshOpenRpcDocument(); 360 | // eslint-disable-next-line react-hooks/exhaustive-deps 361 | }, [transport, tabIndex]); 362 | 363 | useEffect(() => { 364 | if (tabs[tabIndex]) { 365 | setJson(tabs[tabIndex].content); 366 | setUrl(tabs[tabIndex].url || ""); 367 | setLogs(tabs[tabIndex].logs || []); 368 | } 369 | // eslint-disable-next-line react-hooks/exhaustive-deps 370 | }, [tabIndex]); 371 | 372 | useEffect(() => { 373 | setOpenRpcDocument(props.openrpcDocument); 374 | setTabOpenRPCDocument(tabIndex, props.openrpcDocument); 375 | // eslint-disable-next-line react-hooks/exhaustive-deps 376 | }, [props.openrpcDocument]); 377 | 378 | useEffect(() => { 379 | if (!historyOpen) { 380 | handlePlayButton(); 381 | } 382 | // eslint-disable-next-line react-hooks/exhaustive-deps 383 | }, [historyOpen]); 384 | 385 | const handleTabIndexChange = (event: React.ChangeEvent<{}>, newValue: number) => { 386 | setTabIndex(newValue); 387 | }; 388 | 389 | const onHistoryPlayClick = () => { 390 | if (requestHistory[historySelectedIndex]) { 391 | setJson(requestHistory[historySelectedIndex].content); 392 | setUrl(requestHistory[historySelectedIndex].url); 393 | setOpenRpcDocument(requestHistory[historySelectedIndex].openrpcDocument); 394 | setHistoryOpen(false); 395 | } 396 | }; 397 | 398 | const handleTransportOptionsChange = (optionsString: string) => { 399 | try { 400 | setTransportOptions(JSON.parse(optionsString)); 401 | } catch (e) { 402 | // cannot parse transport options 403 | } 404 | }; 405 | 406 | return ( 407 | <> 408 | setHistoryOpen(false)} aria-labelledby="simple-dialog-title" open={historyOpen} > 409 | 410 | 415 | History 416 | { 417 | requestHistory.length === 0 418 | ? null 419 | : 420 | 421 | 422 | 423 | 424 | } 425 | 426 | { 427 | requestHistory.length === 0 428 | ? No History Yet. 429 | : 430 | 431 | {requestHistory.map((requestHistoryItem: any, historyIndex: number) => ( 432 | setHistorySelectedIndex(historyIndex)} 434 | selected={historyIndex === historySelectedIndex}> 435 | 439 | 440 | ))} 441 | 442 | { 452 | // noop 453 | }} 454 | /> 455 | 456 | } 457 | 458 | 459 | 460 |
461 | 468 | {tabs.map((tab, index) => ( 469 | setTabEditing(tab, true)} label={ 474 |
475 | {tab.editing 476 | ? handleLabelChange(ev, tab)} 479 | onBlur={() => setTabEditing(tab, false)} 480 | autoFocus 481 | style={{ maxWidth: "80px", marginRight: "25px" }} 482 | /> 483 | : {tab.name} 484 | } 485 | {tabIndex === index 486 | ? 487 | 488 | handleClose(ev, index) 490 | } style={{ position: "absolute", right: "10px", top: "25%" }} size="small"> 491 | 492 | 493 | 494 | : null 495 | } 496 |
497 | }>
498 | ))} 499 | 501 | setTabs([ 502 | ...tabs, 503 | { 504 | name: "New Tab", 505 | content: { ...emptyJSONRPC, id: 0 }, 506 | logs: [], 507 | openrpcDocument, 508 | url, 509 | }, 510 | ], 511 | )}> 512 | 513 | 514 | 515 | }> 516 | 517 |
518 |
519 | 520 | 521 | openrpc-logo 527 | Inspector 528 | { 531 | setTransportList([ 532 | ...transportList, 533 | addedTransport, 534 | ]); 535 | }} 536 | selectedTransport={selectedTransport} 537 | onChange={(changedTransport) => setSelectedTransport(changedTransport)} 538 | style={{ 539 | marginLeft: "10px", 540 | }} 541 | /> 542 | 543 | 544 | 545 | 546 | 547 | 550 | 551 | {connected 552 | ? 553 | : 554 | } 555 | 556 | { 557 | openrpcDocument 558 | ? 559 | 561 | OpenRPC Document Detected 562 | 563 | A JSON-RPC endpoint may respond to the rpc.discover method 564 | or a provide a static document. 565 | This adds features like auto completion to the inspector. 566 | 567 | 568 | } onClick={() => window.open("https://spec.open-rpc.org/#service-discovery-method")}> 569 | 570 | 571 | : null 572 | } 573 | 574 | } 575 | value={url} 576 | placeholder="Enter a JSON-RPC server URL" 577 | onChange={ 578 | (event: ChangeEvent) => { 579 | setUrl(event.target.value); 580 | setTabUrl(tabIndex, event.target.value); 581 | } 582 | } 583 | fullWidth 584 | style={{ background: "rgba(0,0,0,0.1)", borderRadius: "4px", padding: "0px 10px", marginRight: "5px" }} 585 | /> 586 | 587 | setHistoryOpen(true)}> 588 | 589 | 590 | 591 | { 592 | props.hideToggleTheme 593 | ? null 594 | : 595 | 596 | 597 | {props.darkMode ? : } 598 | 599 | 600 | } 601 | 602 | 603 | 610 | 617 | { 619 | let jsonResult; 620 | try { 621 | jsonResult = JSON.parse(val); 622 | } catch (e) { 623 | console.error(e); 624 | } 625 | if (jsonResult) { 626 | setJson(jsonResult); 627 | setTabContent(tabIndex, jsonResult); 628 | } 629 | }} 630 | openrpcDocument={openrpcDocument} 631 | value={JSON.stringify(json, null, 4)} 632 | /> 633 | {(selectedTransport as IWebTransport).schema && 637 | 638 | } 639 | 640 | <> 641 | {logs.length > 0 && 642 | 655 | } 656 | {logs.length === 0 && 657 | 658 | 659 | Press the Play button to see the results here. 660 | 661 | Use  662 | 671 | to auto-complete in the editor. 672 | 673 | 674 | 675 | } 676 | {logs.length !== 0 && 677 |
678 | 684 |
685 | } 686 | 687 |
688 | 689 | ); 690 | }; 691 | 692 | export default Inspector; 693 | -------------------------------------------------------------------------------- /src/containers/JSONRPCRequestEditor.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import MonacoEditor from "@etclabscore/react-monaco-editor"; 3 | import * as monaco from "monaco-editor"; 4 | import { MethodObject, OpenrpcDocument } from "@open-rpc/meta-schema"; 5 | import useWindowSize from "@rehooks/window-size"; 6 | import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics"; 7 | import openrpcDocumentToJSONRPCSchema from "../helpers/openrpcDocumentToJSONRPCSchema"; 8 | import useMonacoVimMode from "../hooks/useMonacoVimMode"; 9 | 10 | interface IProps { 11 | onChange?: (newValue: any) => void; 12 | openrpcMethodObject?: MethodObject; 13 | openrpcDocument?: OpenrpcDocument; 14 | value: any; 15 | } 16 | 17 | const JSONRPCRequestEditor: React.FC = (props) => { 18 | const [editor, setEditor] = useState(); 19 | useMonacoVimMode(editor); 20 | const windowSize = useWindowSize(); 21 | useEffect(() => { 22 | if (editor) { 23 | editor.layout(); 24 | } 25 | }, [windowSize, editor]); 26 | 27 | useEffect(() => { 28 | if (!editor) { 29 | return; 30 | } 31 | const modelName = (props.openrpcDocument && props.openrpcDocument.info) ? props.openrpcDocument.info.title : "inspector"; 32 | const modelUriString = `inmemory://${modelName}-${Math.random()}.json`; 33 | const modelUri = monaco.Uri.parse(modelUriString); 34 | const model = monaco.editor.createModel(props.value || "", "json", modelUri); 35 | editor.setModel(model); 36 | let schema: any = { 37 | type: "object", 38 | properties: { 39 | jsonrpc: { 40 | type: "string", 41 | const: "2.0", 42 | }, 43 | id: { 44 | oneOf: [ 45 | { 46 | type: "string", 47 | }, 48 | { 49 | type: "number", 50 | }, 51 | ], 52 | }, 53 | method: { 54 | type: "string", 55 | }, 56 | }, 57 | }; 58 | 59 | if (props.openrpcDocument) { 60 | schema = openrpcDocumentToJSONRPCSchema(props.openrpcDocument); 61 | } else { 62 | schema = { 63 | additionalProperties: false, 64 | properties: { 65 | ...schema.properties, 66 | params: { 67 | oneOf: [ 68 | { type: "array" }, 69 | { type: "object" }, 70 | ], 71 | }, 72 | }, 73 | }; 74 | } 75 | addDiagnostics(modelUri.toString(), schema, monaco); 76 | 77 | // eslint-disable-next-line react-hooks/exhaustive-deps 78 | }, [props.openrpcDocument, editor]); 79 | 80 | function handleEditorDidMount(_: any, ed: any) { 81 | setEditor(ed); 82 | } 83 | 84 | const handleChange = (ev: any, value: any) => { 85 | if (props.onChange) { 86 | props.onChange(value); 87 | } 88 | }; 89 | 90 | return ( 91 | 106 | ); 107 | }; 108 | 109 | export default JSONRPCRequestEditor; 110 | -------------------------------------------------------------------------------- /src/containers/OptionsEditor.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import MonacoEditor from "@etclabscore/react-monaco-editor"; 3 | import * as monaco from "monaco-editor"; 4 | import { JSONSchema, MethodObject } from "@open-rpc/meta-schema"; 5 | import useWindowSize from "@rehooks/window-size"; 6 | import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics"; 7 | import useMonacoVimMode from "../hooks/useMonacoVimMode"; 8 | 9 | interface IProps { 10 | onChange?: (newValue: any) => void; 11 | openrpcMethodObject?: MethodObject; 12 | schema?: JSONSchema; 13 | value: any; 14 | } 15 | 16 | const OptionsEditor: React.FC = (props) => { 17 | const [editor, setEditor] = useState(); 18 | useMonacoVimMode(editor); 19 | const windowSize = useWindowSize(); 20 | useEffect(() => { 21 | if (editor) { 22 | editor.layout(); 23 | } 24 | }, [windowSize, editor]); 25 | 26 | useEffect(() => { 27 | if (!editor) { 28 | return; 29 | } 30 | const modelName = "inspector-transport-options"; 31 | const modelUriString = `inmemory://${modelName}-${Math.random()}.json`; 32 | const modelUri = monaco.Uri.parse(modelUriString); 33 | const model = monaco.editor.createModel(props.value || "", "json", modelUri); 34 | editor.setModel(model); 35 | 36 | addDiagnostics(modelUri.toString(), props.schema, monaco); 37 | 38 | // eslint-disable-next-line react-hooks/exhaustive-deps 39 | }, [props.schema, editor]); 40 | 41 | function handleEditorDidMount(_: any, ed: any) { 42 | setEditor(ed); 43 | } 44 | 45 | const handleChange = (ev: any, value: any) => { 46 | if (props.onChange) { 47 | props.onChange(value); 48 | } 49 | }; 50 | 51 | return ( 52 | <> 53 |
54 | 72 | 73 | ); 74 | }; 75 | 76 | export default OptionsEditor; 77 | -------------------------------------------------------------------------------- /src/exports.tsx: -------------------------------------------------------------------------------- 1 | import {default as Inspector} from "./containers/Inspector"; 2 | export default Inspector; 3 | -------------------------------------------------------------------------------- /src/helpers/openrpcDocumentToJSONRPCSchema.ts: -------------------------------------------------------------------------------- 1 | import { MethodObject, ContentDescriptorObject, OpenrpcDocument, ExampleObject } from "@open-rpc/meta-schema"; 2 | 3 | const schema: any = { 4 | type: "object", 5 | properties: { 6 | jsonrpc: { 7 | type: "string", 8 | enum: ["2.0"], 9 | description: "JSON-RPC version string", 10 | }, 11 | id: { 12 | description: "unique identifier for the JSON-RPC request", 13 | oneOf: [ 14 | { 15 | type: "string", 16 | }, 17 | { 18 | type: "number", 19 | }, 20 | ], 21 | }, 22 | method: { 23 | type: "string", 24 | }, 25 | }, 26 | }; 27 | 28 | const openrpcDocumentToJSONRPCSchema = (openrpcDocument: OpenrpcDocument) => { 29 | return { 30 | type: "object", 31 | properties: { 32 | id: { 33 | ...schema.properties.id, 34 | }, 35 | jsonrpc: { 36 | ...schema.properties.jsonrpc, 37 | }, 38 | method: { 39 | type: "string", 40 | oneOf: openrpcDocument && openrpcDocument.methods && openrpcDocument.methods.map((method) => { 41 | const m = method as MethodObject; 42 | return { 43 | const: m.name, 44 | description: m.description || m.summary, 45 | markdownDescription: m.description || m.summary, 46 | }; 47 | }), 48 | }, 49 | }, 50 | allOf: openrpcDocument && openrpcDocument.methods && openrpcDocument.methods.map((method) => { 51 | const m = method as MethodObject; 52 | return { 53 | if: { 54 | properties: { 55 | method: { 56 | const: m.name, 57 | }, 58 | }, 59 | }, 60 | then: { 61 | properties: { 62 | params: { 63 | oneOf: [ 64 | { 65 | type: "array", 66 | minItems: m.params && m.params.filter((param: any) => param.required).length, 67 | maxItems: m.params && m.params.length, 68 | defaultSnippets: m.examples ? m.examples.map((example: any) => { 69 | return { 70 | label: example.name, 71 | description: example.description || example.summary, 72 | body: example.params && example.params.map((ex: ExampleObject) => ex.value), 73 | }; 74 | }) : [], 75 | items: m.params && m.params.map((param: any) => { 76 | return { 77 | ...param.schema, 78 | markdownDescription: param.description || param.summary, 79 | description: param.description || param.summary, 80 | additionalProperties: false, 81 | }; 82 | }), 83 | }, 84 | { 85 | type: "object", 86 | properties: m.params && (m.params as ContentDescriptorObject[]) 87 | .reduce((memo: any, param: ContentDescriptorObject) => { 88 | if (typeof param.schema === "object") { 89 | memo[param.name] = { 90 | ...param.schema, 91 | markdownDescription: param.description || param.summary, 92 | description: param.description || param.summary, 93 | additionalProperties: false, 94 | }; 95 | } else { 96 | memo[param.name] = param.schema; 97 | } 98 | return memo; 99 | }, {}), 100 | }, 101 | ], 102 | }, 103 | }, 104 | }, 105 | }; 106 | }), 107 | }; 108 | }; 109 | 110 | export default openrpcDocumentToJSONRPCSchema; 111 | -------------------------------------------------------------------------------- /src/helpers/openrpcDocumentToJSONRPCSchemaResult.ts: -------------------------------------------------------------------------------- 1 | import { 2 | MethodObject, 3 | ContentDescriptorObject, 4 | OpenrpcDocument, 5 | } from "@open-rpc/meta-schema"; 6 | 7 | const schema: any = { 8 | type: "object", 9 | properties: { 10 | jsonrpc: { 11 | type: "string", 12 | description: "JSON-RPC Version String", 13 | const: "2.0", 14 | }, 15 | id: { 16 | oneOf: [ 17 | { 18 | type: "string", 19 | }, 20 | { 21 | type: "number", 22 | }, 23 | ], 24 | }, 25 | }, 26 | }; 27 | 28 | const openrpcDocumentToJSONRPCSchemaResult = ( 29 | openrpcDocument: OpenrpcDocument, 30 | methodName: string 31 | ) => { 32 | const methodObject = openrpcDocument.methods.find( 33 | (method) => (method as MethodObject).name === methodName 34 | ) as MethodObject; 35 | let methodSchema: any; 36 | if (methodObject !== undefined && methodObject.result !== undefined) { 37 | methodSchema = (methodObject.result as ContentDescriptorObject).schema; 38 | } 39 | return { 40 | type: "object", 41 | properties: { 42 | id: { 43 | ...schema.properties.id, 44 | }, 45 | jsonrpc: { 46 | ...schema.properties.jsonrpc, 47 | }, 48 | result: { 49 | ...methodSchema, 50 | markdownDescription: methodObject?.description || methodObject?.summary, 51 | description: methodObject?.description || methodObject?.summary, 52 | }, 53 | }, 54 | }; 55 | }; 56 | 57 | export default openrpcDocumentToJSONRPCSchemaResult; 58 | -------------------------------------------------------------------------------- /src/hooks/useMonacoVimMode.ts: -------------------------------------------------------------------------------- 1 | import { useState, useEffect, Dispatch } from "react"; 2 | import * as monaco from "monaco-editor"; 3 | const { initVimMode } = require("monaco-vim"); //tslint:disable-line 4 | 5 | // Vim Mode: 6 | // Press Chord Ctrl-K, Ctrl-V => the action will run if it is enabled 7 | const useMonacoVimMode = (editor: monaco.editor.IStandaloneCodeEditor | undefined) => { 8 | const [vimMode, setVimMode]: [any, Dispatch] = useState(); 9 | 10 | useEffect(() => { 11 | if (!editor) { return; } 12 | 13 | editor.addAction({ 14 | id: "vim-mode", 15 | label: "Vim Mode", 16 | keybindings: [ 17 | monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_V), //tslint:disable-line 18 | ], 19 | contextMenuGroupId: "navigation", 20 | contextMenuOrder: 1.5, 21 | run: () => { 22 | if (vimMode) { 23 | vimMode.dispose(); 24 | } 25 | setVimMode(initVimMode(editor)); 26 | }, 27 | }); 28 | 29 | return () => { 30 | if (vimMode) { 31 | vimMode.dispose(); 32 | } 33 | }; 34 | // eslint-disable-next-line react-hooks/exhaustive-deps 35 | }, [editor]); 36 | 37 | return [editor, vimMode]; 38 | }; 39 | 40 | export default useMonacoVimMode; 41 | -------------------------------------------------------------------------------- /src/hooks/useOpenrpcDocument.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | 3 | const useOpenrpcDocument = (openrpcDocument?: string, schemaUrl?: string) => { 4 | 5 | const [openrpcDoc, setOpenrpcDoc] = useState(openrpcDocument); 6 | useEffect(() => { 7 | async function retrieveOpenrpcDocument() { 8 | try { 9 | if (!openrpcDocument && schemaUrl) { 10 | const response = await fetch(schemaUrl); 11 | const doc = await response.json(); 12 | setOpenrpcDoc(doc); 13 | } 14 | 15 | } catch (e) { 16 | setOpenrpcDoc(undefined); 17 | } 18 | } 19 | retrieveOpenrpcDocument(); 20 | }, [openrpcDocument, schemaUrl]); 21 | return openrpcDoc; 22 | }; 23 | 24 | export default useOpenrpcDocument; 25 | -------------------------------------------------------------------------------- /src/hooks/useQueryParams.ts: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import * as qs from "qs"; 3 | 4 | const useQueryParams = (depth?: number) => { 5 | const parse = () => { 6 | return qs.parse(window.location.search, { 7 | ignoreQueryPrefix: true, 8 | depth: depth || 100, 9 | decoder(str) { 10 | if (/^([+-]?[0-9]\d*|0)$/.test(str)) { 11 | return parseInt(str, 10); 12 | } 13 | if (str === "false") { 14 | return false; 15 | } 16 | if (str === "true") { 17 | return true; 18 | } 19 | return decodeURIComponent(str); 20 | }, 21 | }); 22 | }; 23 | const [query] = useState(parse()); 24 | return [query]; 25 | }; 26 | 27 | export default useQueryParams; 28 | -------------------------------------------------------------------------------- /src/hooks/useTabs.ts: -------------------------------------------------------------------------------- 1 | import { useState, Dispatch, useEffect } from "react"; 2 | import { OpenrpcDocument } from "@open-rpc/meta-schema"; 3 | import { JSONRPCLog } from "@open-rpc/logs-react"; 4 | 5 | interface ITab { 6 | name: string; 7 | content?: any; 8 | logs: JSONRPCLog[]; 9 | editing?: boolean; 10 | url?: string; 11 | openrpcDocument?: OpenrpcDocument; 12 | } 13 | 14 | const emptyJSONRPC = { 15 | jsonrpc: "2.0", 16 | method: "", 17 | params: [], 18 | id: 0, 19 | }; 20 | 21 | const useTabs = (defaultTabs?: ITab[]) => { 22 | const [tabIndex, setTabIndex] = useState(0); 23 | const [tabs, setTabs]: [ITab[], Dispatch] = useState( 24 | defaultTabs || [{ name: "New Tab", content: emptyJSONRPC, url: undefined, logs: [] }], 25 | ); 26 | 27 | const handleClose = (event: React.MouseEvent<{}>, index: number) => { 28 | if (tabs.length === 1) { 29 | return; 30 | } 31 | const t = tabs.filter((tab, i) => i !== index); 32 | setTabs(t); 33 | }; 34 | 35 | useEffect(() => { 36 | if (tabs.length === tabIndex) { 37 | setTabIndex(tabIndex - 1); 38 | } 39 | }, [tabs, tabIndex]); 40 | 41 | const setTabName = (tab: ITab, name: string) => { 42 | const newTabs = tabs.map((innerTab) => { 43 | if (innerTab === tab) { 44 | return { 45 | ...innerTab, 46 | name, 47 | }; 48 | } 49 | return innerTab; 50 | }); 51 | setTabs(newTabs); 52 | }; 53 | 54 | const setTabEditing = (tab: ITab, editing: boolean) => { 55 | const newTabs = tabs.map((innerTab) => { 56 | if (innerTab === tab) { 57 | return { 58 | ...innerTab, 59 | editing, 60 | }; 61 | } 62 | return innerTab; 63 | }); 64 | setTabs(newTabs); 65 | }; 66 | 67 | const setTabOpenRPCDocument = (ti: number, openrpcDocument: OpenrpcDocument | undefined) => { 68 | const newTabs = tabs.map((innerTab, i) => { 69 | if (i === ti) { 70 | if (!openrpcDocument) { 71 | return { 72 | name: innerTab.name, 73 | content: innerTab.content, 74 | logs: innerTab.logs, 75 | editing: innerTab.editing, 76 | url: innerTab.url, 77 | }; 78 | } 79 | return { 80 | ...innerTab, 81 | openrpcDocument, 82 | }; 83 | } 84 | return innerTab; 85 | }); 86 | setTabs(newTabs); 87 | }; 88 | 89 | const setTabUrl = (ti: number, url: string) => { 90 | const newTabs = tabs.map((innerTab, i) => { 91 | if (i === ti) { 92 | return { 93 | ...innerTab, 94 | url, 95 | }; 96 | } 97 | return innerTab; 98 | }); 99 | setTabs(newTabs); 100 | }; 101 | 102 | const setTabLogs = (ti: number, logs: JSONRPCLog[]) => { 103 | const newTabs = tabs.map((innerTab, i) => { 104 | if (i === ti) { 105 | return { 106 | ...innerTab, 107 | logs, 108 | }; 109 | } 110 | return innerTab; 111 | }); 112 | setTabs(newTabs); 113 | }; 114 | 115 | const setTabContent = (ti: number, content: any) => { 116 | const newTabs = tabs.map((innerTab, i) => { 117 | if (i === ti) { 118 | return { 119 | ...innerTab, 120 | content, 121 | }; 122 | } 123 | return innerTab; 124 | }); 125 | setTabs(newTabs); 126 | }; 127 | 128 | const handleLabelChange = (ev: any, tab: ITab) => { 129 | setTabName(tab, ev.target.value); 130 | }; 131 | return { 132 | setTabContent, 133 | setTabEditing, 134 | setTabIndex, 135 | setTabName, 136 | tabs, 137 | setTabs, 138 | handleClose, 139 | tabIndex, 140 | handleLabelChange, 141 | setTabUrl, 142 | setTabLogs, 143 | setTabOpenRPCDocument, 144 | }; 145 | }; 146 | 147 | export default useTabs; 148 | -------------------------------------------------------------------------------- /src/hooks/useTransport.ts: -------------------------------------------------------------------------------- 1 | 2 | import { JSONRPCError } from "@open-rpc/client-js/build/Error"; 3 | import { Dispatch, useEffect, useState } from "react"; 4 | import { HTTPTransport, WebSocketTransport, PostMessageWindowTransport, PostMessageIframeTransport } from "@open-rpc/client-js"; 5 | import { Transport } from "@open-rpc/client-js/build/transports/Transport"; 6 | import { IJSONRPCData, IJSONRPCNotificationResponse } from "@open-rpc/client-js/build/Request"; 7 | import { JSONSchema } from "@open-rpc/meta-schema"; 8 | 9 | export type TTransport = "http" | "websocket" | "postmessagewindow" | "postmessageiframe"; 10 | 11 | export interface IWebTransport { 12 | type: TTransport; 13 | name?: string; 14 | schema?: JSONSchema; 15 | } 16 | 17 | export interface IPluginTransport { 18 | type: "plugin"; 19 | uri: string; 20 | name: string; 21 | transport: ITransport; 22 | } 23 | const getTransportFromType = async ( 24 | uri: string, 25 | transports: ITransport[], 26 | transport: ITransport, 27 | transportOptions?: any, 28 | ): Promise => { 29 | let localTransport: any; 30 | const localTransportType = transports.find((value) => { 31 | return value.type === transport.type && value.name === transport.name; 32 | }); 33 | if (localTransportType?.type === "websocket") { 34 | localTransport = new WebSocketTransport(uri); 35 | } else if (localTransportType?.type === "http") { 36 | localTransport = new HTTPTransport(uri, transportOptions); 37 | } else if (localTransportType?.type === "postmessageiframe") { 38 | localTransport = new PostMessageIframeTransport(uri); 39 | } else if (localTransportType?.type === "postmessagewindow") { 40 | localTransport = new PostMessageWindowTransport(uri); 41 | } else if (localTransportType?.type === "plugin") { 42 | const intermediateTransport = await getTransportFromType( 43 | localTransportType.uri, 44 | transports, 45 | localTransportType.transport, 46 | ); 47 | class InterTransport extends Transport { 48 | public async connect() { 49 | await intermediateTransport.connect(); 50 | const results = await intermediateTransport.sendData({ 51 | internalID: 0, 52 | request: { 53 | jsonrpc: "2.0", 54 | method: "connect", 55 | params: [uri], 56 | id: 0, 57 | }, 58 | }); 59 | intermediateTransport.subscribe("notification", (data: IJSONRPCNotificationResponse) => { 60 | this.transportRequestManager.transportEventChannel.emit("notification", data); 61 | }); 62 | intermediateTransport.subscribe("error", (data: JSONRPCError) => { 63 | this.transportRequestManager.transportEventChannel.emit("error", data); 64 | }); 65 | return results; 66 | } 67 | public sendData(data: IJSONRPCData): Promise { 68 | return intermediateTransport.sendData({ 69 | internalID: 0, 70 | request: { 71 | jsonrpc: "2.0", 72 | method: "sendData", 73 | params: [data.request], 74 | id: 0, 75 | }, 76 | }); 77 | } 78 | public close() { 79 | intermediateTransport.unsubscribe(); 80 | intermediateTransport.sendData({ 81 | internalID: 0, 82 | request: { 83 | jsonrpc: "2.0", 84 | method: "close", 85 | params: [], 86 | id: 0, 87 | }, 88 | }); 89 | intermediateTransport.close(); 90 | } 91 | } 92 | localTransport = new InterTransport(); 93 | } 94 | 95 | return localTransport; 96 | }; 97 | 98 | export type ITransport = IWebTransport | IPluginTransport; 99 | 100 | type TUseTransport = ( 101 | transports: ITransport[], 102 | url: string, 103 | defaultTransportType: ITransport, 104 | transportOptions?: any, 105 | ) => [Transport | undefined, (t: ITransport) => void, JSONRPCError | undefined, boolean]; 106 | 107 | const useTransport: TUseTransport = (transports, url, defaultTransportType, transportOptions) => { 108 | const [transport, setTransport] = useState(); 109 | const [transportConnected, setTransportConnected] = useState(false); 110 | const [transportType, setTransportType]: 111 | [ITransport | undefined, Dispatch] = useState(defaultTransportType); 112 | const [error, setError]: [JSONRPCError | undefined, Dispatch] = useState(); 113 | useEffect(() => { 114 | if (!transportType) { 115 | return; 116 | } 117 | const doSetTransport = async () => { 118 | if (transport) { 119 | transport.unsubscribe(); 120 | transport.close(); 121 | } 122 | const localTransport = await getTransportFromType(url, transports, transportType, transportOptions); 123 | return localTransport.connect().then(() => { 124 | setTransportConnected(true); 125 | setTransport(localTransport); 126 | }).catch((e) => { 127 | localTransport.unsubscribe(); 128 | localTransport.close(); 129 | throw e; 130 | }); 131 | }; 132 | 133 | doSetTransport() 134 | .catch((e: JSONRPCError) => { 135 | setTransportConnected(false); 136 | setTransport(undefined); 137 | setError(e); 138 | }); 139 | // eslint-disable-next-line react-hooks/exhaustive-deps 140 | }, [transportType, url, transports, transportOptions]); 141 | const setSelectedTransportType = async (t: ITransport) => { 142 | setTransportConnected(false); 143 | setTransportType(t); 144 | }; 145 | return [transport, setSelectedTransportType, error, transportConnected]; 146 | }; 147 | 148 | export default useTransport; 149 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import ReactDOM from "react-dom"; 2 | import React from "react"; 3 | import App from "./containers/App"; 4 | import "./App.css"; 5 | import "./splitpane.css"; 6 | 7 | ReactDOM.render(, document.getElementById("root")); 8 | -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /src/splitpane.css: -------------------------------------------------------------------------------- 1 | .Resizer { 2 | background: #000; 3 | opacity: .2; 4 | z-index: 1; 5 | -moz-box-sizing: border-box; 6 | -webkit-box-sizing: border-box; 7 | box-sizing: border-box; 8 | -moz-background-clip: padding; 9 | -webkit-background-clip: padding; 10 | background-clip: padding-box; 11 | } 12 | 13 | .Resizer:hover { 14 | -webkit-transition: all 2s ease; 15 | transition: all 2s ease; 16 | } 17 | 18 | .Resizer.horizontal { 19 | height: 11px; 20 | margin: -5px 0; 21 | border-top: 5px solid rgba(255, 255, 255, 0); 22 | border-bottom: 5px solid rgba(255, 255, 255, 0); 23 | cursor: row-resize; 24 | width: 100%; 25 | } 26 | 27 | .Resizer.horizontal:hover { 28 | border-top: 5px solid rgba(0, 0, 0, 0.5); 29 | border-bottom: 5px solid rgba(0, 0, 0, 0.5); 30 | } 31 | 32 | .Resizer.vertical { 33 | width: 11px; 34 | margin: 0 -5px; 35 | border-left: 5px solid rgba(255, 255, 255, 0); 36 | border-right: 5px solid rgba(255, 255, 255, 0); 37 | cursor: col-resize; 38 | } 39 | 40 | .Resizer.vertical:hover { 41 | border-left: 5px solid rgba(0, 0, 0, 0.5); 42 | border-right: 5px solid rgba(0, 0, 0, 0.5); 43 | } 44 | .Resizer.disabled { 45 | cursor: not-allowed; 46 | } 47 | .Resizer.disabled:hover { 48 | border-color: transparent; 49 | } 50 | -------------------------------------------------------------------------------- /src/themes/openrpcTheme.ts: -------------------------------------------------------------------------------- 1 | import { createMuiTheme } from "@material-ui/core/styles"; 2 | import grey from "@material-ui/core/colors/grey"; 3 | 4 | export const lightTheme = createMuiTheme({ 5 | props: { 6 | MuiAppBar: { 7 | position: "sticky", 8 | }, 9 | MuiCard: { 10 | elevation: 0, 11 | }, 12 | }, 13 | overrides: { 14 | MuiAppBar: { 15 | root: { 16 | background: "#fff !important", 17 | }, 18 | }, 19 | }, 20 | palette: { 21 | background: { 22 | default: "#fff", 23 | }, 24 | }, 25 | }); 26 | 27 | export const darkTheme = createMuiTheme({ 28 | props: { 29 | MuiAppBar: { 30 | position: "sticky", 31 | }, 32 | MuiCard: { 33 | elevation: 0, 34 | }, 35 | }, 36 | palette: { 37 | type: "dark", 38 | background: { 39 | default: grey[900], 40 | paper: grey[800], 41 | }, 42 | }, 43 | overrides: { 44 | MuiAppBar: { 45 | root: { 46 | background: "transparent !important", 47 | }, 48 | }, 49 | MuiTable: { 50 | root: { 51 | background: "transparent !important", 52 | }, 53 | }, 54 | MuiTypography: { 55 | root: { 56 | color: grey[400], 57 | }, 58 | }, 59 | }, 60 | }); 61 | 62 | export default { 63 | darkTheme, 64 | lightTheme, 65 | }; 66 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "esnext", 5 | "lib": [ 6 | "es2015", 7 | "dom" 8 | ], 9 | "outDir": "build", 10 | "strict": true, 11 | "esModuleInterop": true, 12 | "skipLibCheck": true, 13 | "allowSyntheticDefaultImports": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "moduleResolution": "node", 16 | "resolveJsonModule": true, 17 | "isolatedModules": true, 18 | "jsx": "preserve", 19 | "allowJs": true, 20 | "noEmit": true 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /tsfmt.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "tslint:recommended" 4 | ], 5 | "rules": { 6 | "ordered-imports": false, 7 | "indent": [ 8 | true, 9 | "spaces", 10 | 2 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "tslint:recommended" 4 | ], 5 | "rules": { 6 | "ordered-imports": false, 7 | "object-literal-sort-keys": false, 8 | "no-console": [true, "log"], 9 | "indent": [true, "spaces", 2], 10 | "max-classes-per-file" : false 11 | } 12 | } 13 | --------------------------------------------------------------------------------