├── .github └── workflows │ ├── rust-tag.yml │ └── rust.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── configure_github_release_script ├── examples ├── data-table │ └── index.html ├── discover-types │ ├── .gitignore │ ├── README.md │ ├── build.js │ ├── build.sh │ ├── img │ │ └── screenshot.png │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── run_me │ ├── src │ │ ├── App.css │ │ ├── App.tsx │ │ ├── Types.ts │ │ ├── error-handler.js │ │ ├── index.css │ │ ├── index.tsx │ │ ├── lib.ts │ │ ├── logo.svg │ │ ├── react-app-env.d.ts │ │ ├── reducer.test.ts │ │ ├── reducer.ts │ │ ├── serviceWorker.ts │ │ └── setupTests.ts │ ├── tsconfig.json │ └── types.csv ├── display-messages │ ├── display-messages.html │ └── img │ │ └── screenshot.png ├── for-main-readme.ts └── test-data │ └── burger-shop.csv ├── js-lib ├── .gitignore ├── README.md ├── dist │ ├── browser.js │ ├── main.d.ts │ ├── main.js │ ├── wv-linewise-buffer.d.ts │ ├── wv-linewise-buffer.js │ ├── wv-linewise-fetch.d.ts │ ├── wv-linewise-fetch.js │ ├── wv-linewise.d.ts │ └── wv-linewise.js ├── docs │ ├── .nojekyll │ ├── README.md │ ├── classes │ │ ├── wv_linewise.RawWvLinewise.md │ │ ├── wv_linewise.RawWvLinewiseMock.md │ │ ├── wv_linewise.WvLinewise.md │ │ ├── wv_linewise_buffer.WvLinewiseBuffer.md │ │ └── wv_linewise_fetch.WvLinewiseResponse.md │ ├── enums │ │ ├── wv_linewise.OUT_REQUEST_DESCRIPTOR.md │ │ ├── wv_linewise.REQUEST_TYPE.md │ │ └── wv_linewise.RESPONSE_TYPE.md │ ├── interfaces │ │ ├── wv_linewise.DetailsResponse.md │ │ ├── wv_linewise.ErrorResponse.md │ │ ├── wv_linewise.ExitRequest.md │ │ ├── wv_linewise.FinishedResponse.md │ │ ├── wv_linewise.LineResponse.md │ │ ├── wv_linewise.MessageErrorResponse.md │ │ ├── wv_linewise.OutRequest.md │ │ ├── wv_linewise.Param.md │ │ ├── wv_linewise.ParamsRequest.md │ │ ├── wv_linewise.ParamsResponse.md │ │ ├── wv_linewise.PausedResponse.md │ │ ├── wv_linewise.ResponseDispatcher.md │ │ ├── wv_linewise.StreamContinueRequest.md │ │ ├── wv_linewise.StreamListRequest.md │ │ ├── wv_linewise.StreamListResponse.md │ │ ├── wv_linewise.StreamStartRequest.md │ │ ├── wv_linewise_fetch.WvLinewiseFetchCurrent.md │ │ └── wv_linewise_fetch.WvLinewiseRequest.md │ ├── modules.md │ └── modules │ │ ├── main.md │ │ ├── wv_linewise.md │ │ ├── wv_linewise_buffer.md │ │ └── wv_linewise_fetch.md ├── package-lock.json ├── package.json ├── rollup.config.js ├── src │ ├── main.ts │ ├── wv-linewise-buffer.ts │ ├── wv-linewise-fetch.ts │ └── wv-linewise.ts ├── test │ ├── wv-linewise-buffer.ts │ └── wv-linewise-fetch.ts ├── tsconfig.json └── tslint.json └── src └── main.rs /.github/workflows/rust-tag.yml: -------------------------------------------------------------------------------- 1 | name: Rust Tag 2 | on: 3 | push: 4 | tags: 5 | - v* 6 | env: 7 | CARGO_TERM_COLOR: always 8 | jobs: 9 | unix_like: 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | matrix: 13 | os: [ubuntu-20.04, macos-latest, windows-latest] 14 | include: 15 | - os: ubuntu-20.04 16 | build_name: wv_linewise 17 | upload_name: wv_linewise 18 | os_name: Ubuntu 20.04 19 | - os: macos-latest 20 | build_name: wv_linewise 21 | upload_name: wv_linewise 22 | os_name: MacOS 23 | - os: windows-latest 24 | build_name: wv_linewise.exe 25 | upload_name: wv_linewise.exe 26 | os_name: Windows 27 | steps: 28 | - uses: actions/checkout@v2 29 | - name: Libs 30 | if: (matrix.os == 'ubuntu-20.04') || (matrix.os == 'macos-latest') 31 | run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.0-37 || true 32 | - name: Build 33 | run: cargo build --verbose --release 34 | - name: Release 35 | id: release 36 | uses: actions/create-release@v1 37 | env: 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 39 | with: 40 | tag_name: ${{ github.ref }}-${{ matrix.os }} 41 | release_name: "Release ${{ github.ref }}: ${{ matrix.os_name }}" 42 | draft: false 43 | - name: Upload Release Asset 44 | uses: actions/upload-release-asset@v1 45 | env: 46 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 47 | with: 48 | upload_url: ${{ steps.release.outputs.upload_url }} 49 | asset_path: target/release/${{ matrix.build_name }} 50 | asset_name: ${{ matrix.upload_name }} 51 | asset_content_type: application/x-executable 52 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust Master 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | unix_like: 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | os: [ubuntu-20.04, macos-latest, windows-latest] 19 | include: 20 | - os: ubuntu-20.04 21 | build_name: wv_linewise 22 | upload_name: wv_linewise 23 | os_name: Ubuntu 20.04 24 | - os: macos-latest 25 | build_name: wv_linewise 26 | upload_name: wv_linewise 27 | os_name: MacOS 28 | - os: windows-latest 29 | build_name: wv_linewise.exe 30 | upload_name: wv_linewise.exe 31 | os_name: Windows 32 | steps: 33 | - uses: actions/checkout@v2 34 | - name: Libs 35 | if: (matrix.os == 'ubuntu-20.04') || (matrix.os == 'macos-latest') 36 | run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.0-37 || true 37 | - name: Build 38 | run: cargo build --verbose --release 39 | - name: Release 40 | id: release 41 | uses: actions/create-release@v1 42 | env: 43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 44 | with: 45 | tag_name: ${{ github.ref }}-${{ matrix.os }} 46 | release_name: "Release ${{ github.ref }}: ${{ matrix.os_name }}" 47 | draft: true 48 | - name: Upload Release Asset 49 | uses: actions/upload-release-asset@v1 50 | env: 51 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 52 | with: 53 | upload_url: ${{ steps.release.outputs.upload_url }} 54 | asset_path: target/release/${{ matrix.build_name }} 55 | asset_name: ${{ matrix.upload_name }} 56 | asset_content_type: application/x-executable 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | /lookups.csv 4 | /lookups.tsv 5 | /stdin.csv 6 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wv_linewise" 3 | version = "0.3.0" 4 | authors = ["Matthew Forrester "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | web-view = { version = "0.7.3", features=["edge"] } 9 | # web-view = { version = "0.6.2", features = ["edge"] } 10 | serde_json = { version = "1.0", default-features = false, features = ["alloc"] } 11 | serde_derive = "1.0.105" 12 | serde = { version = "1.0", features = ["derive"] } 13 | clap = "2.33.0" 14 | 15 | [profile.release] 16 | debug = true 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Matt Forrester 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WV Linewise 2 | 3 | ![Rust](https://github.com/forbesmyester/wv-linewise/workflows/Rust/badge.svg) 4 | 5 | ## The Potential User 6 | 7 | You have some experience of the command line or writing small pieces of software. You may also be a professional software developer, but you may not be. 8 | 9 | You have learnt a little bit about the command line. You can do a `cat somefile.csv | grep 'Something Interesting' | sort > result.csv` and can see how sometimes, it's better to to do this than write code. 10 | 11 | Sometimes you write code you're really proud of. But sometimes it's only about getting data from A to B, maybe a one off or something that has to work but doesn't have to be pretty. You wonder if `cat BLAH BLAH | SOMETHING | X | Y | Z` might have worked, it certainly would have been faster and easier if only you could add some interactivity to `X`. 12 | 13 | You can write some HTML/CSS/JS and can make something interactive relatively easily, but your data which was previously happy stored in a CSV (for example) is no longer very easy to access. It seems that once you do HTML/CSS/JS you need to think about databases, port numbers, CORS and getting data out of your CSV is longer simple... HTML/CSS/JS is an all or nothing thing, you have to jump all in, sometimes it's just not worth it. 14 | 15 | You need one foot in both worlds... how... 16 | 17 | ## What it does 18 | 19 | [Boscop's Web-View](https://github.com/Boscop/web-view) has provided us with a lightweight library for showing HTML/CSS/JS within a window, using the OS's standard browser. If you know HTML/CSS/JS but shudder at the weight of Electron, this may be your thing. As a bonus, it's written in Rust too! 20 | 21 | This project provides some Rust functions for streaming STDIN or files into Boscop's Web-View and a higher level TypeScript / JavaScript API to pull them in as a stream of lines. You can also write to STDOUT using this API enabling you to put something like a web page, right in the middle of a UNIX pipeline. I find this quite exciting. 22 | 23 | Can you think of any things which you would like to do using UNIX pipes which you think you may want to add some interactivity or graphics to? I can think of many... 24 | 25 | ## Example 26 | 27 | This program could be invoked like the following: 28 | 29 | 30 | # Prepare lookups.csv 31 | echo '"First Name","Telephone Number"' > lookups.csv 32 | echo 'Alice,"01922 123 456"' >> lookups.csv 33 | echo 'Ben,"0800 100 232"' >> lookups.csv 34 | echo 'Jack,"01882 556216"' >> lookups.csv 35 | 36 | # write a file that we will pipe to stdin 37 | echo 'Name,Age' > stdin.csv 38 | echo 'Ben,21' >> stdin.csv 39 | echo 'Alice,31' >> stdin.csv 40 | echo 'Jane,27' >> stdin.csv 41 | 42 | cat stdin.csv | wv_linewise \ 43 | --code ./examples/bad-join.html \ 44 | --stream this_is_stdin=- \ 45 | --stream lookups=lookups.csv \ 46 | --param this_is_stdin='["Name"]' \ 47 | --param lookups='["First Name"]' \ 48 | --param request_count=2 49 | 50 | 51 | The data input above would cause the following messages to be sent between WV Linewise and the embedded web page. 52 | 53 | < { "msg": "params" } 54 | > { "type": "params", "params": [{ "name": "this_is_stdin", value: "[\"Name\"]"}, {"name": "lookups": "value": "[\"First Name\"]"}] } 55 | < {"msg":"streamList"} 56 | > {"streams":["this_is_stdin","lookups"],"type":"streamList"} 57 | < { "msg": "out", "descriptor": 1, "data": "Line Number,Name,Age,Telephone Number" } 58 | < { "msg": "streamStart", "name": "this_is_stdin", "count": 2 } 59 | < { "msg": "streamStart", "name": "lookups", "count": 2 } 60 | > { "type": "details", "name": "this_is_stdin", "details": { "rewindable": false } 61 | > { "type": "details", "name": "lookups", "details": { "rewindable": false } 62 | > { "type": "line", "name": "this_is_stdin", "data": "Name,Age" } 63 | > { "type": "line", "name": "this_is_stdin", "data": "Ben,21" } 64 | > { "type": "paused", "name": "this_is_stdin" } 65 | > { "type": "line", "name": "lookups", "data": "\"First Name\",\"Telephone Number\"" } 66 | < { "msg": "streamContinue", "name": "this_is_stdin" } 67 | > { "type": "line", "name": "lookups", "data": "Alice,\"01922 123 456\"" } 68 | > { "type": "paused", "name": "lookups" } 69 | > { "type": "line", "name": "this_is_stdin", "data": "Alice,31" } 70 | < { "msg": "out", "descriptor": 1, "data": "2,Alice,31,\"01922 123 456\"" } 71 | > { "type": "line", "name": "this_is_stdin", "data": "Jane,27" } 72 | > { "type": "finished", "name": "this_is_stdin" } 73 | < { "msg": "streamContinue", "name": "lookups" } 74 | > { "type": "line", "name": "lookups", "data": "Ben,\"0800 100 232\"" } 75 | < { "msg": "out", "descriptor": 1, "data": "1,Ben,21,\"0800 100 232"" } 76 | > { "type": "line", "name": "lookups", "data": "Jack,\"01882 556216\"" } 77 | > { "type": "finished", "name": "lookups" } 78 | < { "msg": "exit", "status": 0 } 79 | 80 | NOTE: `<` are messages from TypeScript / JavaScript to WV Linewise, `>` are the responses. 81 | 82 | WV Linewise will then exit with a status code of 0 and the following data will have already been written to STDOUT: 83 | 84 | Line Number,Name,Age,Telephone Number 85 | 2,Alice,31,"01922 123 456" 86 | 1,Ben,21,"0800 100 232" 87 | 88 | 89 | ## APIs 90 | 91 | There are two TypeScript / JavaScript APIs I created to control the sending / receiving of messages. These are listed below: 92 | 93 | ### The original Light Wrapper API 94 | 95 | If for whatever reason you don't want to use the Buffer API, the original API is a light weight message / event based API. In writing it I was merely trying to add some type safety over the raw messages. See the example below 96 | 97 | ```typescript 98 | import { RawWvLinewise, WvLinewise, RESPONSE_TYPE, MessageErrorResponse, ErrorResponse, ParamsResponse, LineResponse, PausedResponse } from "wv-linewise-js-lib"; 99 | 100 | async function processLightWeight() { 101 | 102 | let lineCount = 0; 103 | const wvl: WvLinewise = new WvLinewise(new RawWvLinewise(external as any)); 104 | 105 | // Upon error, just raise it so it's caught by the global error handler. 106 | wvl.on(RESPONSE_TYPE.MESSAGE_ERROR, (msg: MessageErrorResponse) => { 107 | throw new Error(`MSG ERROR: ${JSON.stringify(msg)}`) 108 | }); 109 | 110 | // Upon error, just raise it so it's caught by the global error handler. 111 | wvl.on(RESPONSE_TYPE.ERROR, (msg: ErrorResponse) => { 112 | throw new Error(`MSG ERROR: ${JSON.stringify(msg)}`) 113 | }); 114 | 115 | // Request the parameters the user passed in on the command line 116 | function getParams(wvl: WvLinewise): Promise { 117 | return new Promise((resolve) => { 118 | let f = (resp: ParamsResponse) => { 119 | resolve(resp); 120 | }; 121 | wvl.once(RESPONSE_TYPE.PARAMS, f); 122 | wvl.requestParams(); 123 | }); 124 | } 125 | 126 | function getRequestQuantity(paramsResponse: ParamsResponse): number { 127 | for (let p of paramsResponse.params) { 128 | if (p.name == "quantity") { 129 | return parseInt(p.value, 10); 130 | } 131 | } 132 | return 1000; 133 | } 134 | 135 | // Because all of our code is blocking (we're not waiting for animations etc) 136 | // we're going to have processed the data immediately, so when WV Linewise 137 | // pauses we can just start it right up again. 138 | wvl.on(RESPONSE_TYPE.PAUSED, (resp: PausedResponse) => { 139 | if (resp.name == "in") { 140 | wvl.streamContinue("in"); 141 | } 142 | }); 143 | 144 | // This function will get fired on every line, with the line that came from 145 | // the "in" stream, which could be STDIN or a file. 146 | wvl.on(RESPONSE_TYPE.LINE, (resp: LineResponse) => { 147 | if (resp.name == "in") { 148 | lineCount = lineCount + 1; 149 | } 150 | document.body.innerText = `The file has ${lineCount} lines` 151 | }); 152 | 153 | 154 | // Start WV Linewise processing lines 155 | wvl.streamStart("in", getRequestQuantity(await getParams(wvl))); 156 | 157 | } 158 | 159 | processLightWeight(); 160 | ``` 161 | 162 | ### The buffer API 163 | 164 | The WvLinewiseBuffer will allow you to disregard the messages for the purposes of reading the streams. It uses a low watermark and a quantity to request (3rd and 4th parameters) to try and make sure there's always lines available. Because it's built upon Promises it can handle situations where the buffer is empty and not fail. 165 | 166 | ```typescript 167 | async function processBuffer(wvl: WvLinewise) { 168 | 169 | let buffer = new WvLinewiseBuffer(wvl, "in", 100, 200); 170 | let line: string|null = ""; 171 | let lineCount = 0; 172 | 173 | while (line !== null) { 174 | line = await buffer.shift(); 175 | if (line === null) { 176 | continue; 177 | } 178 | document.body.innerText = `The file has ${lineCount} lines and the last line was ${line}`; 179 | } 180 | } 181 | 182 | const wvl: WvLinewise = new WvLinewise(new RawWvLinewise(external as any)); 183 | processBuffer(wvl); 184 | ``` 185 | 186 | ## Installation 187 | 188 | ### Binaries 189 | 190 | Binaries are available in [Releases](https://github.com/forbesmyester/wv-linewise/releases) for Windows, MacOS (I have no Mac to test) and Ubuntu x86 (which will run on at least some other x86 Linux). 191 | 192 | They should be big self contained binaries that run without dependencies. 193 | 194 | ### Compilation 195 | 196 | Installation is possible and easy with Rust v1.42.0 and later. 197 | 198 | [RustUp](https://rustup.rs/) is how I installed Rust. 199 | 200 | In Linux Boscop/Web-view [introduces a dependency on Webkit2gtk](https://github.com/Boscop/web-view#prerequisites). At least on Ubuntu this is easy to meet via `sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.0-37`. 201 | 202 | Once Rust is fully installed using `cargo install --path .` will compile and install the actual binary as wv_linewise. 203 | 204 | ## Example Applications 205 | 206 | ### [Discover Types](./examples/discover-types) 207 | 208 | #### About 209 | DiscoverTypes is an application for identifying the types of fields within a CSV file. It does this by comparing every cell against every regular expression the user has supplied. Because the CSV file could be HUGE it does not load the whole thing into memory but inspects it line by line as it passes through. 210 | 211 | #### Screenshot 212 | 213 | ![What it looks like](./examples/discover-types/img/screenshot.png) 214 | 215 | ### [Display Messages](./examples/display-messages) 216 | 217 | #### About 218 | 219 | This is a pure vanilla JS application I used to see develop WV Linewise, it's super basic and only: 220 | 221 | * Outputs messages sent and received into the Web View. 222 | * Lines that are are received by the Web View are assumed to be CSV data, converted to JSON with the stream name and line number added then sent to STDOUT. 223 | 224 | If you want to see how the interact with the original lightweight API this is probably the best place to start. 225 | 226 | #### Screenshot 227 | 228 | ![What it looks like](./examples/display-messages/img/screenshot.png) 229 | 230 | 231 | ## Releases 232 | 233 | * v0.1.3 - Move Windows builds to Edge (yes the old non Chrome version) and fix in CI/CD so I don't have any manual intervention when releasing via a Git Tag 234 | * v0.1.2 - Fix Ubuntu 20.04, fix `--version` command line flag and add ability to specify window title 235 | * v0.1.1 - Fix branding and examples/discover-types not outputting to STDOUT on continuous-and-exit 236 | * v0.1.0 - Initial Release 237 | -------------------------------------------------------------------------------- /configure_github_release_script: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | RELEASE_INDEX="$(cat .github/workflows/rust.yml | yq '.jobs.unix_like.steps[] | select(.name == "Release") | path | .[-1]')" 6 | 7 | cat .github/workflows/rust.yml | yq '.jobs.unix_like.steps['"${RELEASE_INDEX}"'].with.draft = false' | yq '.on = { "push": { "tags": ["v*"] } } ' | yq '.name = "Rust Tag"' > .github/workflows/rust-tag.yml 8 | -------------------------------------------------------------------------------- /examples/discover-types/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/discover-types/README.md: -------------------------------------------------------------------------------- 1 | # Discover Types 2 | 3 | ## About 4 | 5 | DiscoverTypes is an application for identifying the types of fields within a CSV file. It does this by comparing every cell against every regular expression the user has supplied. Because the CSV file could be HUGE it does not load the whole thing into memory but inspects it line by line as it passes through. 6 | 7 | ## Screenshot 8 | 9 | ![What it looks like](./img/screenshot.png) 10 | 11 | ## The Output 12 | 13 | The following is an example of the CSV output: 14 | 15 | | Column | Types | Count | Total Record Count | 16 | | ------------|-------------------------------------------|---------|-----------------------| 17 | | salesPerson | ["String"]" | 13 | 13 | 18 | | date | ["String","Full US Date","Full UK Date"]" | 8 | 13 | 19 | | date | ["NULL"]" | 1 | 13 | 20 | | date | ["String","Full UK Date"]" | 4 | 13 | 21 | | orderId | ["Integer","String"]" | 13 | 13 | 22 | | item | ["String"]" | 13 | 13 | 23 | | cost | ["String"]" | 13 | 13 | 24 | | price | ["Integer","String"]" | 10 | 13 | 25 | | price | ["String"]" | 3 | 13 | 26 | | profit | ["String"]" | 13 | 13 | 27 | 28 | Every cell within a CSV could be interpreted as 0 or more different types. Generally speaking I would use the regular expression `^$` (meaning a zero length string) to be `NULL` and `.` (at least one character in length) to be a String. This means that the integer `4` might be an integer (`^\-[0-9]+`) but could also a string. This is completely correct as you might have user input of a string type, which users tend to write integers in, an example of this may be local phone numbers, which are often just numbers, but sometimes include other characters, so are forced to be strings. 29 | 30 | ### Why we don't prefer one type over another 31 | 32 | Imagine you had 14 million lines and one column was full of dates and we preferred US dates format over the UK dates. The software would tell us we had 14 million (minus one) US dates and 1 UK date and you may conclude that the column is US dates with one error... but if all the dates were before the 12th of the month except __that__ one, you'd probably be wrong. 33 | 34 | This situation is actually shown in a much more simple form above. You can see that the date column must be one of the following: 35 | 36 | * A "Full US Date" and therefore has 5 records in error. 37 | * A "String" and therefore has 1 record in error. 38 | * A "Full UK Date" and therefore has 1 record in error. 39 | * **A "String" with null allowed and therefore has 0 record in error.** 40 | * **A "Full UK Date" with null allowed and therefore has 0 record in error.** 41 | 42 | Given the output above it should be relatively trivial to write software, to figure out that the date column is actually a UK Date which allows nulls. But the caveat is that software needs to know to prefer "Full UK Date" over "String" which this software does not. 43 | 44 | I may well add code and columns to: 45 | 46 | * List out what the zero error candidates are. This would get you down to just "String" and "Full UK Date" in the above example. 47 | * Add at least one example for each row in the table above. 48 | 49 | ## Usage 50 | 51 | ```shell 52 | cat test-data/burger-shop.csv | wv-linewise --code index.html \ 53 | --stream in=- \ 54 | --stream types=types.csv \ 55 | --param 'Full US Date'='^0*[0-9][0-2]?/[0-9]+/[0-9]{4}$' \ 56 | --param 'Full UK Date'='^[0-9]+/0*[0-9][0-2]?/[0-9]{4}$' \ 57 | --param mode='continuous' 58 | ``` 59 | 60 | Because DiscoverTypes is built upon WV Linewise it's command line interface is the interface from WV Linewise... well I could wrap the program in a BASH/BAT file to make it more slick, but DiscoverTypes is actually only an example application for WV Linewise so I will not. 61 | 62 | ### The "in" stream ( required ) 63 | 64 | The "in" stream is where the actual CSV you want to inspect comes from. It could be huge... 65 | 66 | If you use the special value `-` WV Linewise will read STDIN, otherwise this will be taken to be a filename and that file will be read. 67 | 68 | ### The "types" stream (optional) 69 | 70 | The "type" stream is a CSV with the following structure. 71 | 72 | | name | regexp | 73 | |---------|-----------| 74 | | Integer | ^-?[0-9]+ | 75 | | String | . | 76 | | NULL | ^$ | 77 | 78 | The `name` is a types name and `regexp` is a JavaScript regular expression without the enclosing forward slashes. 79 | 80 | ### The "type" parameters (optional) 81 | 82 | The type parameters are added to the "types" stream above with the `name` and the `regexp` taking the same form. Because WV Linewise has a singular `--param` command line argument written in the form `--param 'name=value`, which is moderately too verbose but at least quite specific. 83 | 84 | The name must not conflict with any other parameter names otherwise it will need to can be specified in full, for example such as `--param 'type=Full UK Date=^[0-9]+/0*[0-9][0-2]?/[0-9]{4}$'`. Type parameters names also cannot include the `=` symbol. 85 | 86 | ### The "mode" parameter (optional) 87 | 88 | I think the ease of adding interactive elements within UNIX pipelines is one of the nicest parts of WV Linewise, but equally I would find it mildly annoying to page through over a million rows. 89 | 90 | To deal with this I have introduced a "mode" to Discover Types which can take one of three values: 91 | 92 | * `manual` The default mode is "manual" and in this mode you will have to press "More" on the user interface to page through the data. 93 | * `continuous` This mode will page automatically and will stop at the end, waiting for you to press the "Exit" button, 94 | * `continuous-and-exit` This is same as `continuous` except that it exits automatically at the end. 95 | -------------------------------------------------------------------------------- /examples/discover-types/build.js: -------------------------------------------------------------------------------- 1 | var fs = require("fs") 2 | var inlineAssets = require("inline-assets") 3 | var content = fs.readFileSync("build/index.html", "utf8") 4 | content = inlineAssets("index.html", "build/index.html", content, { 5 | verbose: false, 6 | htmlmin: false, 7 | cssmin: false, 8 | jsmin: false, 9 | pattern: [ ".+" ], 10 | purge: false 11 | }) 12 | fs.writeFileSync("index.html", content, "utf8") 13 | -------------------------------------------------------------------------------- /examples/discover-types/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | rm -rf build 6 | npm run-script build && sed -i 'sJ="/J="Jg' build/index.html && node build.js 7 | 8 | -------------------------------------------------------------------------------- /examples/discover-types/img/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forbesmyester/wv-linewise/b16282da6e560b83d8906e9660bf74774c3a3362/examples/discover-types/img/screenshot.png -------------------------------------------------------------------------------- /examples/discover-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discover-types", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "@types/csvrow": "^0.1.0", 10 | "@types/jest": "^24.9.1", 11 | "@types/node": "^12.12.43", 12 | "@types/react": "^16.9.35", 13 | "@types/react-dom": "^16.9.8", 14 | "@types/react-redux": "^7.1.9", 15 | "@types/react-router-dom": "^5.1.5", 16 | "@types/styled-components": "^5.1.0", 17 | "csvrow": "^0.1.0", 18 | "immutable": "^4.0.0-rc.12", 19 | "inline-assets": "^1.4.5", 20 | "react": "^16.13.1", 21 | "react-dom": "^16.13.1", 22 | "react-redux": "^7.2.0", 23 | "react-router-dom": "^5.2.0", 24 | "react-router-native": "^5.2.0", 25 | "react-scripts": "3.4.1", 26 | "styled-components": "^5.1.1", 27 | "typescript": "^3.7.5", 28 | "wv-linewise-js-lib": "0.0.0" 29 | }, 30 | "scripts": { 31 | "start": "react-scripts start", 32 | "build": "react-scripts build", 33 | "test": "react-scripts test", 34 | "eject": "react-scripts eject" 35 | }, 36 | "eslintConfig": { 37 | "extends": "react-app" 38 | }, 39 | "browserslist": { 40 | "production": [ 41 | ">0.2%", 42 | "not dead", 43 | "not op_mini all" 44 | ], 45 | "development": [ 46 | "last 1 chrome version", 47 | "last 1 firefox version", 48 | "last 1 safari version" 49 | ] 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/discover-types/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forbesmyester/wv-linewise/b16282da6e560b83d8906e9660bf74774c3a3362/examples/discover-types/public/favicon.ico -------------------------------------------------------------------------------- /examples/discover-types/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 18 | 19 | 28 | React App 29 | 30 | 31 |
32 | 42 |
43 |
44 |
No JavaScript
45 |
You need to enable JavaScript to run this app
46 |
47 |
48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /examples/discover-types/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forbesmyester/wv-linewise/b16282da6e560b83d8906e9660bf74774c3a3362/examples/discover-types/public/logo192.png -------------------------------------------------------------------------------- /examples/discover-types/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forbesmyester/wv-linewise/b16282da6e560b83d8906e9660bf74774c3a3362/examples/discover-types/public/logo512.png -------------------------------------------------------------------------------- /examples/discover-types/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "view-and-schema", 3 | "name": "view-and-schema", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/discover-types/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/discover-types/run_me: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./build.sh && cat ../test-data/burger-shop.csv | cargo run -- --stream in=- --code index.html --stream types=types.csv --param 'Full US Date'='^0*[0-9][0-2]?/[0-9]+/[0-9]{4}$' --param 'Full UK Date'='^[0-9]+/0*[0-9][0-2]?/[0-9]{4}$' 4 | -------------------------------------------------------------------------------- /examples/discover-types/src/App.css: -------------------------------------------------------------------------------- 1 | td { 2 | /* height: 6em; */ 3 | } 4 | 5 | .stats-detail tr.stats-detail-row-data td { 6 | border: 0 7 | } 8 | 9 | .stats-detail tr.stats-detail-row-graph td { 10 | padding: 0 11 | } 12 | 13 | .bottom-bar-control { 14 | display:inline-block; 15 | margin-left: 1em; 16 | padding-bottom: 0; 17 | } 18 | 19 | .bottom-bar-control:first-child { 20 | margin-left: 0em; 21 | } 22 | 23 | .as-inline-block { display: inline-block !important; } 24 | #footer { padding: 0.5em 1em; background-color: #DDD; } 25 | 26 | #footer button { min-width: 8em; } 27 | 28 | .modal-overlay { padding: 1em; text-align: right; text-decoration: none } 29 | .modal-overlay:hover { padding: 1em; text-align: right; text-decoration: none } 30 | 31 | th.field { cursor: pointer; } 32 | 33 | html, body { height: 100%; } 34 | #react-mount { height: 100% } 35 | #react-root { height: 100% } 36 | 37 | #footer { position: fixed; left: 0; right: 0; bottom: 0; } 38 | 39 | table { width: 100% } 40 | 41 | 42 | #error-display-holder { 43 | position: absolute; 44 | top: 5em; 45 | width: 100%; 46 | display: none; 47 | } 48 | #error-display-holder.visible { display: block; } 49 | 50 | #error-display { 51 | background-color: lightgrey; 52 | padding: 0.5em 1em; 53 | margin: 0 auto; 54 | border: solid 1px darkgrey; 55 | width: 90%; 56 | max-width: 40em; 57 | } 58 | 59 | #error-display-holder.warning #error-display { 60 | background-color: orange; 61 | } 62 | 63 | #error-display-holder.error #error-display { 64 | background-color: red; 65 | color: white; 66 | } 67 | 68 | #error-display-header { margin-bottom: 1em; } 69 | #error-display-header .title { display: inline-block; width: 85%; font-weight: bold } 70 | #error-display-header .closer { display: inline-block; width: 15%; text-align: right; cursor: pointer; } 71 | -------------------------------------------------------------------------------- /examples/discover-types/src/Types.ts: -------------------------------------------------------------------------------- 1 | import Im from "immutable"; 2 | import { ChangeEvent } from "react"; 3 | 4 | export interface TypeMatcherSpec { 5 | name: TypeName, 6 | regexp: RegExp 7 | } 8 | 9 | export type TypeMatches = number; 10 | export type TypeName = string; 11 | 12 | export type FieldStats = Im.Map; 13 | 14 | export interface Field { 15 | name: string, 16 | stats: FieldStats, 17 | } 18 | 19 | export interface FieldValue { 20 | value: string, 21 | } 22 | 23 | export interface Record { 24 | key: number; 25 | values: FieldValue[]; 26 | } 27 | 28 | export enum MODE { 29 | MANUAL = "M", 30 | CONTINUOUS = "C", 31 | CONTINUOUS_AND_EXIT= "CE", 32 | } 33 | 34 | export type AppProps = { 35 | showingHelp: boolean; 36 | continuousMode: MODE; 37 | loading: boolean; 38 | finished: boolean; 39 | showingFieldDetails: string | false; 40 | events: { 41 | toggleContinuousMode: (evt: ChangeEvent) => void; 42 | scroll: () => void; 43 | exit: () => void; 44 | onClickTableHeading: (name: Field["name"] | false) => void; 45 | help: (b: boolean) => () => void; 46 | } 47 | deps: { 48 | typeMatchesToTypeNameBound: (typeMatches: TypeMatches) => TypeName[]; 49 | colorScale: (i: number) => string; 50 | }, 51 | totalRecordCount: number; 52 | oldRecordCount: number; 53 | header: Field[]; 54 | records: Record[]; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /examples/discover-types/src/error-handler.js: -------------------------------------------------------------------------------- 1 | export function getErrorHandler() { 2 | 3 | const ERROR_LEVEL_DEBUG=1; 4 | const ERROR_LEVEL_INFO=2; 5 | const ERROR_LEVEL_WARN=3; 6 | const ERROR_LEVEL_ERROR=4; 7 | const ERROR_LEVEL_FATAL=5; 8 | 9 | let errors = []; 10 | let showing = false; 11 | 12 | let holder = document.getElementById("error-display-holder"); 13 | let closer = document.getElementById("error-display-closer"); 14 | let title = document.getElementById("error-display-title"); 15 | let body = document.getElementById("error-display-body"); 16 | 17 | function showError() { 18 | 19 | showing = true; 20 | if (!errors.length) { 21 | holder.classList.remove("visible"); 22 | showing = false; 23 | return; 24 | } 25 | holder.classList.add("visible"); 26 | holder.classList.remove("warning"); 27 | holder.classList.remove("error"); 28 | 29 | let errorObj = errors.shift(); 30 | 31 | title.innerText = "Message"; 32 | body.innerText = errorObj.error.message; 33 | 34 | switch (errorObj.level) { 35 | case ERROR_LEVEL_DEBUG: 36 | title.innerText = "Debug"; 37 | break; 38 | case ERROR_LEVEL_INFO: 39 | title.innerText = "Information"; 40 | break; 41 | case ERROR_LEVEL_WARN: 42 | title.innerText = "Warning"; 43 | holder.classList.add("warning"); 44 | break; 45 | case ERROR_LEVEL_ERROR: 46 | title.innerText = "Error"; 47 | holder.classList.add("error"); 48 | break; 49 | case ERROR_LEVEL_FATAL: 50 | default: 51 | title.innerText = "Fatal Error"; 52 | if (closer) { 53 | closer.style.display = "none"; 54 | } 55 | holder.classList.add("error"); 56 | break; 57 | } 58 | 59 | holder.display = "block"; 60 | } 61 | 62 | function handleError(e, level=5) { 63 | errors = errors.filter( 64 | (eo, index) => (index <= 9) || (eo.level > level) 65 | ) 66 | if (errors.length <= 9) { 67 | errors.push({ error: e, level }); 68 | } 69 | if (!showing) { 70 | showError(); 71 | } 72 | } 73 | 74 | if (closer) { 75 | closer.onclick = showError; 76 | } 77 | 78 | handleError.ERROR_LEVEL_DEBUG = ERROR_LEVEL_DEBUG; 79 | handleError.ERROR_LEVEL_INFO = ERROR_LEVEL_INFO; 80 | handleError.ERROR_LEVEL_WARN = ERROR_LEVEL_WARN; 81 | handleError.ERROR_LEVEL_ERROR = ERROR_LEVEL_ERROR; 82 | handleError.ERROR_LEVEL_FATAL = ERROR_LEVEL_FATAL; 83 | 84 | return handleError; 85 | 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /examples/discover-types/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /examples/discover-types/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React, {ChangeEvent} from 'react'; 2 | import { getErrorHandler } from './error-handler'; 3 | import { parse } from "csvrow"; 4 | import ReactDOM from 'react-dom'; 5 | import './index.css'; 6 | import App from './App'; 7 | import { AppProps, Field, MODE, TypeMatcherSpec } from "./Types"; 8 | import { getReducer, getTypeMatcher, NEW_BUFFER_LINE, MyReducer, MARK_RECORDS_OLD, SHIFT, MARK_FINISHED, STATS_FOR_FIELD, START_LOADING, FINISH_LOADING, TOGGLE_CONTINUOUS_MODE, isContinuous, getInitialState, SET_HELP_SHOWING } from "./reducer"; 9 | import { RawWvLinewise, RawWvLinewiseMock, WvLinewise, runningInWvLinewise, WvLinewiseBuffer, RESPONSE_TYPE, MessageErrorResponse, ErrorResponse, ParamsResponse, StreamListResponse } from "wv-linewise-js-lib"; 10 | import {typeMatchesToTypeName} from './lib'; 11 | 12 | function redraw(state: AppProps) { 13 | ReactDOM.render( 14 | 15 | 16 | , 17 | document.getElementById('react-mount') 18 | ); 19 | } 20 | 21 | function needToDisplayMore(): boolean { 22 | 23 | const els = Array.from(document.querySelectorAll("#data-table tbody tr")); 24 | const rects = els.map( 25 | (tr) => tr.getBoundingClientRect() 26 | ); 27 | 28 | if (rects.length < 3) { return true; } 29 | 30 | const startAcc = { 31 | prevBottom: rects[0].bottom, 32 | count: 0, 33 | total: 0, 34 | max: 0, 35 | } 36 | 37 | const stats = rects.slice(1).reduce( 38 | (acc: typeof startAcc, rect) => { 39 | return { 40 | max: (rect.bottom - acc.prevBottom) > acc.max ? 41 | (rect.bottom - acc.prevBottom) : 42 | acc.max, 43 | count: acc.count + 1, 44 | total: acc.total + (rect.bottom - acc.prevBottom), 45 | prevBottom: rect.bottom, 46 | } 47 | }, 48 | startAcc 49 | ); 50 | 51 | function getHeight(id: string) { 52 | let el = document.getElementById(id); 53 | if (el === null) { 54 | return 0; 55 | } 56 | return el.getBoundingClientRect().height 57 | } 58 | 59 | let bottom = window.innerHeight - (getHeight("footer") * 1.2) 60 | 61 | if (rects[rects.length - 1].bottom + stats.max <= bottom) { 62 | return true; 63 | } 64 | 65 | return false; 66 | } 67 | 68 | function tooBig(): boolean { 69 | const els = Array.from(document.querySelectorAll("#data-table tbody tr:last-child")); 70 | if (els.length === 0) { 71 | return false; 72 | } 73 | return els[els.length - 1].getBoundingClientRect().bottom > window.innerHeight; 74 | } 75 | 76 | async function scroll(state: AppProps, reducer: MyReducer, buffer: WvLinewiseBuffer): Promise { 77 | 78 | state = reducer(state, { type: MARK_RECORDS_OLD }); 79 | state = reducer(state, { type: START_LOADING }); 80 | let line: string | null = ""; 81 | 82 | redraw(state); 83 | while ((line !== null)) { 84 | 85 | line = await buffer.shift(); 86 | if (line === null) { 87 | state = reducer(state, { type: MARK_FINISHED }); 88 | redraw(state); 89 | break; 90 | } 91 | 92 | while ((state.oldRecordCount) && (tooBig())) { 93 | state = reducer(state, { type: SHIFT }); 94 | } 95 | 96 | if ((state.oldRecordCount) && (state.records.length > 2)) { 97 | state = reducer(state, { type: SHIFT }); 98 | } 99 | 100 | state = reducer(state, { type: NEW_BUFFER_LINE, line }); 101 | 102 | redraw(state); 103 | 104 | if (needToDisplayMore()) { 105 | continue; 106 | } 107 | 108 | if (state.oldRecordCount) { 109 | continue; 110 | } 111 | 112 | break; 113 | } 114 | 115 | state = reducer(state, { type: FINISH_LOADING }); 116 | redraw(state); 117 | return state 118 | } 119 | 120 | function getCsvData(typeMatcherSpec: Array, state: AppProps): Array[] { 121 | 122 | const headings: (string|number)[][] = [["Column", "Types", "Count", "Total Record Count"]]; 123 | 124 | return state.header.reduce( 125 | (acc: (string|number)[][], head: Field) => { 126 | const toAdd = head.stats.toArray().map(([th, count]) => { 127 | return [ 128 | head.name, 129 | JSON.stringify(typeMatchesToTypeName(typeMatcherSpec, th)), 130 | count, 131 | state.totalRecordCount, 132 | ]; 133 | }); 134 | return acc.concat(toAdd); 135 | }, 136 | headings 137 | ); 138 | 139 | } 140 | 141 | function csvEncode(v: string|number) { 142 | if (typeof v == "string") { 143 | return '"' + v.replace(/"/g, "\"\"") + '"'; 144 | } 145 | return v; 146 | } 147 | 148 | interface Settings { 149 | types: TypeMatcherSpec[]; 150 | mode: MODE; 151 | } 152 | 153 | async function loadTypes(wvLinewise: WvLinewise): Promise { 154 | if ((await listStreams(wvLinewise)).streams.indexOf("types") === -1) { 155 | return []; 156 | } 157 | let buffer = new WvLinewiseBuffer(wvLinewise, "types", 2, 4); 158 | let line: string|null = ""; 159 | let headers: Map = new Map([["name", -1], ["regexp", -1]]); 160 | let lineNumber = 1; 161 | let r: TypeMatcherSpec[] = []; 162 | while (line !== null) { 163 | line = await buffer.shift(); 164 | if (line === null) { 165 | continue; 166 | } 167 | if (lineNumber++ === 1) { 168 | const headerLine = parse(line); 169 | if ((headerLine.indexOf("regexp") === -1) || (headerLine.indexOf("name") === -1)) { 170 | wvLinewise.out('ERROR: types CSV must include both a "name" and "regexp" column'); 171 | return []; 172 | } 173 | headers.set("regexp", headerLine.indexOf("regexp")); 174 | headers.set("name", headerLine.indexOf("name")); 175 | continue; 176 | } 177 | let parsed = []; 178 | try { 179 | parsed = parse(line); 180 | r = r.concat(getSpec( 181 | parsed[headers.get("name") as number], 182 | parsed[headers.get("regexp") as number] 183 | )); 184 | } catch (e) { 185 | throw new Error(`The types CSV has an invalid line ${line}`); 186 | } 187 | } 188 | return r; 189 | } 190 | 191 | interface Spec { name: string; regexp: RegExp; } 192 | 193 | function getSpec(name: string, re: string): Spec[] { 194 | let spec = { name: "", regexp: new RegExp(".") }; 195 | try { 196 | spec = { name, regexp: new RegExp(re) }; 197 | } catch (e) { 198 | throw new Error(`The regular expression for type "${name} is ${re}, which is invalid`); 199 | } 200 | if (spec.name && spec.name.length > 0) { 201 | return [spec]; 202 | } 203 | return []; 204 | } 205 | 206 | function getParams(wvl: WvLinewise): Promise { 207 | return new Promise((resolve) => { 208 | let f = (resp: ParamsResponse) => { 209 | resolve(resp); 210 | }; 211 | wvl.once(RESPONSE_TYPE.PARAMS, f); 212 | wvl.requestParams(); 213 | }); 214 | } 215 | 216 | function listStreams(wvl: WvLinewise): Promise { 217 | return new Promise((resolve) => { 218 | let f = (resp: StreamListResponse) => { 219 | resolve(resp); 220 | }; 221 | wvl.once(RESPONSE_TYPE.STREAM_LIST, f); 222 | wvl.requestStreamList(); 223 | }); 224 | } 225 | 226 | async function getSettings(wvLinewise: WvLinewise): Promise { 227 | 228 | const paramsResponse = await getParams(wvLinewise); 229 | const typesRe = /^([^=]+)=(.*)/; 230 | 231 | return paramsResponse.params.reduce( 232 | (acc: Settings, param) => { 233 | switch (param.name) { 234 | case "mode": 235 | const converter: {[k: string]: MODE} = { 236 | "manual": MODE.MANUAL, 237 | "continuous": MODE.CONTINUOUS, 238 | "continuous-and-exit": MODE.CONTINUOUS_AND_EXIT, 239 | }; 240 | if (converter.hasOwnProperty(param.value)) { 241 | return {...acc, mode: converter[param.value]}; 242 | } 243 | break; 244 | case "type": 245 | const m = param.value.match(typesRe); 246 | if (m) { 247 | return {...acc, types: acc.types.concat(getSpec(m[1], m[2])) }; 248 | } 249 | break; 250 | default: 251 | return {...acc, types: acc.types.concat(getSpec(param.name, param.value)) }; 252 | } 253 | return acc; 254 | }, 255 | { types: await loadTypes(wvLinewise), mode: MODE.MANUAL } as Settings 256 | ); 257 | 258 | } 259 | 260 | async function run(wvLinewise: WvLinewise) { 261 | 262 | wvLinewise.on(RESPONSE_TYPE.MESSAGE_ERROR, (msg: MessageErrorResponse) => { 263 | handleError(new Error(`MESSAGE ERROR: ${JSON.stringify(msg)}`), 4); 264 | }); 265 | 266 | wvLinewise.on(RESPONSE_TYPE.ERROR, (msg: ErrorResponse) => { 267 | handleError(new Error(`Error "${msg.error}" reading stream "${msg.name}"`), 4); 268 | }); 269 | 270 | const settings = await getSettings(wvLinewise); 271 | 272 | let buffer = new WvLinewiseBuffer(wvLinewise, "in", 128, 256); 273 | let reducer = getReducer(getTypeMatcher(settings.types)); 274 | 275 | let more = async () => { 276 | let cont = true; 277 | while (cont) { 278 | state = await scroll(state, reducer, buffer); 279 | cont = isContinuous(state.continuousMode) && (!state.finished); 280 | } 281 | if ((state.continuousMode === MODE.CONTINUOUS_AND_EXIT) && (state.finished)) { 282 | state.events.exit(); 283 | } 284 | }; 285 | 286 | let state: AppProps = getInitialState( 287 | settings.types, 288 | settings.mode, 289 | (evt: ChangeEvent) => { 290 | let m: MODE = MODE.MANUAL; 291 | if (evt.target.value === MODE.CONTINUOUS) { m = MODE.CONTINUOUS; } 292 | if (evt.target.value === MODE.CONTINUOUS_AND_EXIT) { m = MODE.CONTINUOUS_AND_EXIT; } 293 | state = reducer(state, { type: TOGGLE_CONTINUOUS_MODE, mode: m }); 294 | if (state.continuousMode !== MODE.MANUAL) { 295 | more(); 296 | } 297 | }, 298 | more, 299 | () => { 300 | const csvData = getCsvData(settings.types, state); 301 | const csvLines = csvData.map((line) => line.map(csvEncode).join(",")); 302 | csvLines.forEach((line) => { 303 | wvLinewise.out(line); 304 | }); 305 | wvLinewise.exit(0) 306 | }, 307 | (name: Field["name"] | false) => { 308 | state = reducer(state, { type: STATS_FOR_FIELD, name }); 309 | redraw(state); 310 | }, 311 | (showing: boolean) => { 312 | return () => { 313 | state = reducer(state, { type: SET_HELP_SHOWING, showing }); 314 | redraw(state); 315 | }; 316 | } 317 | ); 318 | 319 | more(); 320 | } 321 | 322 | function configureRawWvLinewise(runningInWvLinewise: boolean) { 323 | 324 | if (runningInWvLinewise) { 325 | // eslint-disable-next-line no-restricted-globals 326 | return new RawWvLinewise(external as any); 327 | } 328 | 329 | let mock = new RawWvLinewiseMock(); 330 | 331 | const dataIn = [ 332 | "salesPerson,date,orderId,item,cost,price,profit", 333 | "Jack,8/6/2020,3,Burger,2.99,3,0.01", 334 | "Jack,8/6/2020,3,Chips,0.99,2,1.01", 335 | "Jim,9/6/2020,4,Cake,1.49,2,0.51", 336 | "Alice,,5,Fish,1.19,2,0.81", 337 | "Alice,11/6/2020,5,Chips,0.99,2,1.01", 338 | "Alice,11/6/2020,5,Mushy Peas,0.19,0.5,0.31", 339 | "Kate,11/6/2020,6,Cake,1.49,2,0.51", 340 | "\"Sam \"\"The Dude\"\" Smith\",8/6/2020,7,Ice Cream,0.79,1.5,0.71", 341 | "\"Sam \"\"The Dude\"\" Smith\",8/6/2020,8,Cake,1.49,2,0.51", 342 | "Kate,13/6/2020,9,Chocolate,0.3,0.6,0.3", 343 | "Kate,14/6/2020,9,Chips,0.49,2,1.51", 344 | "Kate,15/6/2020,9,Chips,0.39,2,1.61", 345 | "Kate,15/6/2020,10,Drink,0.1,1,0.9", 346 | ]; 347 | const dataTypes = [ 348 | "name,regexp", 349 | "Integer,^-?[0-9]+$", 350 | "NULL,^$", 351 | "String,.", 352 | ] 353 | mock.addStreamData("in", dataIn) 354 | mock.addStreamData("types", dataTypes) 355 | mock.addParam("Full US Date", "^0*[0-9][0-2]?/[0-9]+/[0-9]{4}$"); 356 | mock.addParam("type", "Full UK Date=^[0-9]+/0*[0-9][0-2]?/[0-9]{4}$"); 357 | mock.addParam("mode", "manual"); 358 | return mock; 359 | } 360 | 361 | const handleError = getErrorHandler(); 362 | window.onerror = (e: Event|string) => { 363 | handleError(e, 4); 364 | } 365 | 366 | run(new WvLinewise(configureRawWvLinewise(runningInWvLinewise()))) 367 | .catch((e: Error) => { 368 | handleError(e, 4); 369 | }); 370 | 371 | // Deliberate commented out - problems with webview 372 | // serviceWorker.unregister(); 373 | -------------------------------------------------------------------------------- /examples/discover-types/src/lib.ts: -------------------------------------------------------------------------------- 1 | import {TypeMatcherSpec, TypeMatches, TypeName} from "./Types"; 2 | 3 | export function colorScale(i: number): string { 4 | const colors = [ '#0b5077', '#e9a380', '#e8c794', '#2eb855', '#e9675c', '#052ab3', '#0205e4', '#50cd4a', '#eb2d4b', '#167f72', '#0f6773']; 5 | return colors[i % colors.length]; 6 | } 7 | 8 | export function typeMatchesToTypeName(spec: TypeMatcherSpec[], typeMatches: TypeMatches): TypeName[] { 9 | let r: TypeName[] = []; 10 | let index = 0; 11 | while (typeMatches > 0) { 12 | if (typeMatches & 1) { 13 | r.push(spec[index].name); 14 | } 15 | typeMatches = typeMatches >> 1; 16 | index++; 17 | } 18 | return r; 19 | } 20 | -------------------------------------------------------------------------------- /examples/discover-types/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/discover-types/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/discover-types/src/reducer.test.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {getTypeMatcher, updateFieldStats, typeMatchesToTypeName} from './reducer'; 3 | import {Field} from './Types'; 4 | import Im from "immutable"; 5 | 6 | test('TypeMatcher returns the types that match', () => { 7 | expect(1).toBe(1); 8 | const tm = getTypeMatcher([ 9 | { name: "null", regexp: /^$/ }, 10 | { name: "int", regexp: /^-?[0-9]+$/ }, 11 | { name: "string", regexp: /./} 12 | ]); 13 | expect(tm("2")).toBe(6); 14 | expect(tm("")).toBe(1); 15 | expect(tm("hello")).toBe(4); 16 | }); 17 | 18 | function forMapComparison(m: Map): Array<[A, B]> { 19 | let r: Array<[A, B]> = []; 20 | for (const [a, b] of m) { 21 | r.push([a, b]); 22 | } 23 | return r; 24 | } 25 | 26 | test('updateFieldStats', () => { 27 | const header: Field[] = [ 28 | { name: "Id", stats: Im.Map([[6,2],[4,1]]) }, 29 | { name: "Name", stats: Im.Map([[4,3]]) }, 30 | ]; 31 | expect( 32 | updateFieldStats(header, [6, 1]).map(({stats}) => forMapComparison(stats)) 33 | ).toEqual( 34 | [ 35 | [[6, 3], [4, 1]], 36 | [[4, 3], [1, 1]] 37 | ] 38 | ); 39 | }); 40 | 41 | test('typeMatchesToTypeName', () => { 42 | const tm = [ 43 | { name: "null", regexp: /^$/ }, 44 | { name: "int", regexp: /^-?[0-9]+$/ }, 45 | { name: "string", regexp: /./} 46 | ]; 47 | expect(typeMatchesToTypeName(tm, 6)).toEqual(["int", "string"]); 48 | }); 49 | -------------------------------------------------------------------------------- /examples/discover-types/src/reducer.ts: -------------------------------------------------------------------------------- 1 | import { AppProps, TypeMatches, TypeMatcherSpec, Field, TypeName, MODE } from "./Types"; 2 | import { parse } from "csvrow"; 3 | import Im from "immutable"; 4 | import { colorScale, typeMatchesToTypeName } from "./lib"; 5 | import {Reducer} from "react"; 6 | 7 | export const NEW_BUFFER_LINE = 'NEW_BUFFER_LINE'; 8 | interface ReducerActionNewBufferLine { 9 | type: typeof NEW_BUFFER_LINE; 10 | line: string; 11 | } 12 | 13 | export const SHIFT = 'SHIFT'; 14 | interface ReducerActionShift { 15 | type: typeof SHIFT; 16 | } 17 | 18 | export const MARK_FINISHED = 'MARK_FINISHED'; 19 | interface ReducerActionMarkFinished { 20 | type: typeof MARK_FINISHED; 21 | } 22 | 23 | export const START_LOADING = 'START_LOADING'; 24 | interface ReducerActionStartLoading { 25 | type: typeof START_LOADING; 26 | } 27 | 28 | export const FINISH_LOADING = 'FINISH_LOADING'; 29 | interface ReducerActionFinishLoading { 30 | type: typeof FINISH_LOADING; 31 | } 32 | 33 | export const MARK_RECORDS_OLD = 'MARK_RECORDS_OLD'; 34 | interface ReducerActionMarkRecordsOld { 35 | type: typeof MARK_RECORDS_OLD; 36 | } 37 | 38 | export const STATS_FOR_FIELD = 'STATS_FOR_FIELD'; 39 | interface ReducerActionStatsForField { 40 | type: typeof STATS_FOR_FIELD; 41 | name: string | false; 42 | } 43 | 44 | export const TOGGLE_CONTINUOUS_MODE = 'TOGGLE_CONTINUOUS_MODE'; 45 | interface ReducerActionToggleContinuousMode { 46 | type: typeof TOGGLE_CONTINUOUS_MODE; 47 | mode: MODE; 48 | } 49 | 50 | export const SET_HELP_SHOWING = 'SET_HELP_SHOWING'; 51 | interface ReducerActionSetHelpShowing { 52 | type: typeof SET_HELP_SHOWING; 53 | showing: boolean; 54 | } 55 | 56 | type ReducerAction = ReducerActionNewBufferLine | ReducerActionMarkRecordsOld | ReducerActionShift | ReducerActionMarkFinished | ReducerActionStatsForField | ReducerActionStartLoading | ReducerActionFinishLoading | ReducerActionToggleContinuousMode | ReducerActionSetHelpShowing; 57 | 58 | interface TypeMatcher { 59 | (s: TypeName): TypeMatches 60 | } 61 | 62 | export function getTypeMatcher(typeMatchers: TypeMatcherSpec[]): TypeMatcher { 63 | return function typeMatcher(s: string) { 64 | return typeMatchers.reduce( 65 | (acc: TypeMatches, tm: TypeMatcherSpec, index) => { 66 | if (s.match(tm.regexp)) { 67 | const bitwise = Math.pow(2, index); 68 | return acc | bitwise; 69 | } 70 | return acc; 71 | }, 72 | 0 as TypeMatches 73 | ) as TypeMatches; 74 | } 75 | } 76 | 77 | export function updateFieldStats(header: Field[], typeMatches: TypeMatches[]): Field[] { 78 | return header.map((head, index) => { 79 | return {...head, 80 | stats: head.stats.set( 81 | typeMatches[index], 82 | (head.stats.get(typeMatches[index]) || 0) + 1 83 | ) 84 | }; 85 | }) 86 | } 87 | 88 | export function isContinuous(mode: MODE): boolean { 89 | return mode !== MODE.MANUAL; 90 | } 91 | 92 | export type MyReducer = Reducer; 93 | 94 | export function getInitialState(tm: TypeMatcherSpec[], continuousMode: MODE, toggleContinuousMode: AppProps["events"]["toggleContinuousMode"], scroll: AppProps["events"]["scroll"], exit: AppProps["events"]["exit"], onClickTableHeading: AppProps["events"]["onClickTableHeading"], help: AppProps["events"]["help"]): AppProps { 95 | return { 96 | continuousMode: continuousMode, 97 | loading: false, 98 | showingFieldDetails: false, 99 | finished: false, 100 | header: [], 101 | events: { 102 | help, 103 | toggleContinuousMode, 104 | scroll, 105 | exit, 106 | onClickTableHeading, 107 | }, 108 | deps: { 109 | colorScale, 110 | typeMatchesToTypeNameBound: typeMatchesToTypeName.bind(null, tm), 111 | }, 112 | totalRecordCount: 0, 113 | oldRecordCount: 0, 114 | records: [], 115 | showingHelp: false, 116 | }; 117 | } 118 | 119 | export function getReducer(typeMatcher: TypeMatcher): MyReducer { 120 | return function reducer(state: AppProps, action: ReducerAction): AppProps { 121 | switch (action.type) { 122 | case SET_HELP_SHOWING: 123 | return {...state, showingHelp: action.showing }; 124 | case TOGGLE_CONTINUOUS_MODE: 125 | return {...state, continuousMode: action.mode }; 126 | case START_LOADING: 127 | return {...state, loading: true }; 128 | case FINISH_LOADING: 129 | return {...state, loading: false }; 130 | case MARK_FINISHED: 131 | return {...state, finished: true }; 132 | case SHIFT: 133 | return {...state, 134 | records: state.records.slice(1), 135 | oldRecordCount: state.oldRecordCount - 1, 136 | }; 137 | case MARK_RECORDS_OLD: 138 | return {...state, 139 | oldRecordCount: state.records.length, 140 | }; 141 | case NEW_BUFFER_LINE: 142 | let parsed: string[] = parse(action.line); 143 | if (state.header.length === 0) { 144 | return {...state, 145 | header: parsed.map((name) => { 146 | return { 147 | name, 148 | stats: Im.Map() as Im.Map, 149 | }; 150 | }), 151 | }; 152 | } 153 | return {...state, 154 | records: state.records.concat([ 155 | { key: state.totalRecordCount + 1, values: parsed.map((value) => ({ value })), } 156 | ]), 157 | totalRecordCount: state.totalRecordCount + 1, 158 | header: updateFieldStats( 159 | state.header, 160 | parsed.map((fv) => typeMatcher(fv)) 161 | ) 162 | }; 163 | case STATS_FOR_FIELD: 164 | return {...state, showingFieldDetails: action.name }; 165 | } 166 | } 167 | } 168 | 169 | -------------------------------------------------------------------------------- /examples/discover-types/src/serviceWorker.ts: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | type Config = { 24 | onSuccess?: (registration: ServiceWorkerRegistration) => void; 25 | onUpdate?: (registration: ServiceWorkerRegistration) => void; 26 | }; 27 | 28 | export function register(config?: Config) { 29 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 30 | // The URL constructor is available in all browsers that support SW. 31 | const publicUrl = new URL( 32 | process.env.PUBLIC_URL, 33 | window.location.href 34 | ); 35 | if (publicUrl.origin !== window.location.origin) { 36 | // Our service worker won't work if PUBLIC_URL is on a different origin 37 | // from what our page is served on. This might happen if a CDN is used to 38 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 39 | return; 40 | } 41 | 42 | window.addEventListener('load', () => { 43 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 44 | 45 | if (isLocalhost) { 46 | // This is running on localhost. Let's check if a service worker still exists or not. 47 | checkValidServiceWorker(swUrl, config); 48 | 49 | // Add some additional logging to localhost, pointing developers to the 50 | // service worker/PWA documentation. 51 | navigator.serviceWorker.ready.then(() => { 52 | console.log( 53 | 'This web app is being served cache-first by a service ' + 54 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 55 | ); 56 | }); 57 | } else { 58 | // Is not localhost. Just register service worker 59 | registerValidSW(swUrl, config); 60 | } 61 | }); 62 | } 63 | } 64 | 65 | function registerValidSW(swUrl: string, config?: Config) { 66 | navigator.serviceWorker 67 | .register(swUrl) 68 | .then(registration => { 69 | registration.onupdatefound = () => { 70 | const installingWorker = registration.installing; 71 | if (installingWorker == null) { 72 | return; 73 | } 74 | installingWorker.onstatechange = () => { 75 | if (installingWorker.state === 'installed') { 76 | if (navigator.serviceWorker.controller) { 77 | // At this point, the updated precached content has been fetched, 78 | // but the previous service worker will still serve the older 79 | // content until all client tabs are closed. 80 | console.log( 81 | 'New content is available and will be used when all ' + 82 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 83 | ); 84 | 85 | // Execute callback 86 | if (config && config.onUpdate) { 87 | config.onUpdate(registration); 88 | } 89 | } else { 90 | // At this point, everything has been precached. 91 | // It's the perfect time to display a 92 | // "Content is cached for offline use." message. 93 | console.log('Content is cached for offline use.'); 94 | 95 | // Execute callback 96 | if (config && config.onSuccess) { 97 | config.onSuccess(registration); 98 | } 99 | } 100 | } 101 | }; 102 | }; 103 | }) 104 | .catch(error => { 105 | console.error('Error during service worker registration:', error); 106 | }); 107 | } 108 | 109 | function checkValidServiceWorker(swUrl: string, config?: Config) { 110 | // Check if the service worker can be found. If it can't reload the page. 111 | fetch(swUrl, { 112 | headers: { 'Service-Worker': 'script' } 113 | }) 114 | .then(response => { 115 | // Ensure service worker exists, and that we really are getting a JS file. 116 | const contentType = response.headers.get('content-type'); 117 | if ( 118 | response.status === 404 || 119 | (contentType != null && contentType.indexOf('javascript') === -1) 120 | ) { 121 | // No service worker found. Probably a different app. Reload the page. 122 | navigator.serviceWorker.ready.then(registration => { 123 | registration.unregister().then(() => { 124 | window.location.reload(); 125 | }); 126 | }); 127 | } else { 128 | // Service worker found. Proceed as normal. 129 | registerValidSW(swUrl, config); 130 | } 131 | }) 132 | .catch(() => { 133 | console.log( 134 | 'No internet connection found. App is running in offline mode.' 135 | ); 136 | }); 137 | } 138 | 139 | export function unregister() { 140 | if ('serviceWorker' in navigator) { 141 | navigator.serviceWorker.ready 142 | .then(registration => { 143 | registration.unregister(); 144 | }) 145 | .catch(error => { 146 | console.error(error.message); 147 | }); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /examples/discover-types/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /examples/discover-types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "downlevelIteration": true, 10 | "allowJs": true, 11 | "skipLibCheck": true, 12 | "esModuleInterop": true, 13 | "allowSyntheticDefaultImports": true, 14 | "strict": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /examples/discover-types/types.csv: -------------------------------------------------------------------------------- 1 | name,regexp 2 | Integer,^-?[0-9]+$ 3 | NULL,^$ 4 | String,. 5 | 6 | -------------------------------------------------------------------------------- /examples/display-messages/display-messages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Hello, World!

5 | 6 | 7 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /examples/display-messages/img/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/forbesmyester/wv-linewise/b16282da6e560b83d8906e9660bf74774c3a3362/examples/display-messages/img/screenshot.png -------------------------------------------------------------------------------- /examples/for-main-readme.ts: -------------------------------------------------------------------------------- 1 | import { RawWvLinewise, WvLinewise, WvLinewiseBuffer, RESPONSE_TYPE, MessageErrorResponse, ErrorResponse, ParamsResponse, LineResponse, PausedResponse } from "wv-linewise-js-lib"; 2 | 3 | async function processLightWeight() { 4 | 5 | let lineCount = 0; 6 | const wvl: WvLinewise = new WvLinewise(new RawWvLinewise(external as any)); 7 | 8 | // Upon error, just raise it so it's caught by the global error handler. 9 | wvl.on(RESPONSE_TYPE.MESSAGE_ERROR, (msg: MessageErrorResponse) => { 10 | throw new Error(`MSG ERROR: ${JSON.stringify(msg)}`) 11 | }); 12 | 13 | // Upon error, just raise it so it's caught by the global error handler. 14 | wvl.on(RESPONSE_TYPE.ERROR, (msg: ErrorResponse) => { 15 | throw new Error(`MSG ERROR: ${JSON.stringify(msg)}`) 16 | }); 17 | 18 | // Request the parameters the user passed in on the command line 19 | function getParams(wvl: WvLinewise): Promise { 20 | return new Promise((resolve) => { 21 | let f = (resp: ParamsResponse) => { 22 | resolve(resp); 23 | }; 24 | wvl.once(RESPONSE_TYPE.PARAMS, f); 25 | wvl.requestParams(); 26 | }); 27 | } 28 | 29 | function getRequestQuantity(paramsResponse: ParamsResponse): number { 30 | for (let p of paramsResponse.params) { 31 | if (p.name == "quantity") { 32 | return parseInt(p.value, 10); 33 | } 34 | } 35 | return 1000; 36 | } 37 | 38 | // Because all of our code is blocking (we're not waiting for animations etc) 39 | // we're going to have processed the data immediately, so when WV Linewise 40 | // pauses we can just start it right up again. 41 | wvl.on(RESPONSE_TYPE.PAUSED, (resp: PausedResponse) => { 42 | if (resp.name == "in") { 43 | wvl.streamContinue("in"); 44 | } 45 | }); 46 | 47 | // This function will get fired on every line, with the line that came from 48 | // the "in" stream, which could be STDIN or a file. 49 | wvl.on(RESPONSE_TYPE.LINE, (resp: LineResponse) => { 50 | if (resp.name == "in") { 51 | lineCount = lineCount + 1; 52 | } 53 | document.body.innerText = `The file has ${lineCount} lines and the last line was ${line}`; 54 | }); 55 | 56 | 57 | // Start WV Linewise processing lines 58 | wvl.streamStart("in", getRequestQuantity(await getParams(wvl))); 59 | 60 | } 61 | 62 | processLightWeight(); 63 | 64 | 65 | async function processBuffer(wvl: WvLinewise) { 66 | 67 | let buffer = new WvLinewiseBuffer(wvl, "in", 100, 200); 68 | let line: string|null = ""; 69 | let lineCount = 0; 70 | 71 | while (line !== null) { 72 | line = await buffer.shift(); 73 | if (line === null) { 74 | continue; 75 | } 76 | document.body.innerText = `The file has ${lineCount} lines and the last line was ${line}`; 77 | } 78 | } 79 | 80 | processBuffer(); 81 | -------------------------------------------------------------------------------- /examples/test-data/burger-shop.csv: -------------------------------------------------------------------------------- 1 | salesPerson,date,orderId,item,cost,price,profit 2 | Jack,8/6/2020,3,Burger,2.99,3,0.01 3 | Jack,8/6/2020,3,Chips,0.99,2,1.01 4 | Jim,,4,Cake,1.49,2,0.51 5 | Alice,12/6/2020,5,Fish,1.19,2,0.81 6 | Alice,12/6/2020,5,Chips,0.99,2,1.01 7 | Alice,13/6/2020,5,Mushy Peas,0.19,0.5,0.31 8 | Kate,13/6/2020,6,Cake,1.49,2,0.51 9 | "Sam ""The Dude"" Smith",14/6/2020,7,Ice Cream,0.79,1.5,0.71 10 | "Sam ""The Dude"" Smith",14/6/2020,8,Cake,1.49,2,0.51 11 | Kate,15/6/2020,9,Chocolate,0.3,0.6,0.3 12 | Kate,15/6/2020,9,Chips,0.49,2,1.51 13 | Kate,15/6/2020,9,Chips,0.39,2,1.61 14 | Kate,15/6/2020,10,Drink,0.1,1,0.9 15 | -------------------------------------------------------------------------------- /js-lib/.gitignore: -------------------------------------------------------------------------------- 1 | d3.html 2 | node_modules 3 | -------------------------------------------------------------------------------- /js-lib/README.md: -------------------------------------------------------------------------------- 1 | # wv-linewise-js-lib 2 | 3 | There are API docs available in the [docs](https://github.com/forbesmyester/wv-linewise/blob/master/js-lib/docs/README.md) directory. 4 | 5 | Overall usage documentation can be found in the [WV Linewise repository](https://github.com/forbesmyester/wv-linewise/README.md) 6 | -------------------------------------------------------------------------------- /js-lib/dist/main.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./wv-linewise"; 2 | export * from "./wv-linewise-buffer"; 3 | export * from "./wv-linewise-fetch"; 4 | -------------------------------------------------------------------------------- /js-lib/dist/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 5 | }) : (function(o, m, k, k2) { 6 | if (k2 === undefined) k2 = k; 7 | o[k2] = m[k]; 8 | })); 9 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 10 | for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); 11 | }; 12 | Object.defineProperty(exports, "__esModule", { value: true }); 13 | __exportStar(require("./wv-linewise"), exports); 14 | __exportStar(require("./wv-linewise-buffer"), exports); 15 | __exportStar(require("./wv-linewise-fetch"), exports); 16 | -------------------------------------------------------------------------------- /js-lib/dist/wv-linewise-buffer.d.ts: -------------------------------------------------------------------------------- 1 | import { WvLinewise } from "./wv-linewise"; 2 | export declare class WvLinewiseBuffer { 3 | private wvl; 4 | private streamName; 5 | private lowWaterMark; 6 | private countToRequest; 7 | private buffer; 8 | private state; 9 | protected noSleep: boolean; 10 | constructor(wvl: WvLinewise, streamName: string, lowWaterMark: number, countToRequest: number); 11 | notify(): Promise; 12 | request(): void; 13 | shift(): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /js-lib/dist/wv-linewise-buffer.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.WvLinewiseBuffer = void 0; 13 | const wv_linewise_1 = require("./wv-linewise"); 14 | function onlyOnce(f) { 15 | let called = false; 16 | return function onlyOnceImp(...args) { 17 | if (called) { 18 | return; 19 | } 20 | called = true; 21 | return f.apply(null, args); 22 | }; 23 | } 24 | var WvLinewiseBufferState; 25 | (function (WvLinewiseBufferState) { 26 | WvLinewiseBufferState[WvLinewiseBufferState["NotStarted"] = 0] = "NotStarted"; 27 | WvLinewiseBufferState[WvLinewiseBufferState["Running"] = 1] = "Running"; 28 | WvLinewiseBufferState[WvLinewiseBufferState["Requesting"] = 2] = "Requesting"; 29 | WvLinewiseBufferState[WvLinewiseBufferState["End"] = 3] = "End"; 30 | })(WvLinewiseBufferState || (WvLinewiseBufferState = {})); 31 | function sleep() { 32 | return new Promise((resolve) => { 33 | setTimeout(() => { 34 | resolve(null); 35 | }, 1); 36 | }); 37 | } 38 | class WvLinewiseBuffer { 39 | constructor(wvl, streamName, lowWaterMark, countToRequest) { 40 | this.wvl = wvl; 41 | this.streamName = streamName; 42 | this.lowWaterMark = lowWaterMark; 43 | this.countToRequest = countToRequest; 44 | this.buffer = []; 45 | this.state = WvLinewiseBufferState.NotStarted; 46 | this.noSleep = false; 47 | this.state = 0; // 1 = running, 2 = requesting, 3 = end 48 | if (countToRequest == 0) { 49 | throw new Error("WvLinewiseBuffer: countToRequest must be a positive number"); 50 | } 51 | this.wvl.on(wv_linewise_1.RESPONSE_TYPE.LINE, ({ name, data }) => { 52 | if (name == this.streamName) { 53 | this.buffer.push(data); 54 | } 55 | }); 56 | this.wvl.on(wv_linewise_1.RESPONSE_TYPE.FINISHED, () => { 57 | this.state = 3; 58 | }); 59 | this.wvl.on(wv_linewise_1.RESPONSE_TYPE.PAUSED, () => { 60 | this.state = 1; 61 | }); 62 | } 63 | notify() { 64 | return new Promise((resolve) => { 65 | let onlyOnceResolve = onlyOnce(resolve); 66 | let eventNotification = ({ name, type }) => __awaiter(this, void 0, void 0, function* () { 67 | if (name !== this.streamName) { 68 | return; 69 | } 70 | if (type == wv_linewise_1.RESPONSE_TYPE.FINISHED) { 71 | this.state = 3; 72 | } 73 | if (type == wv_linewise_1.RESPONSE_TYPE.PAUSED) { 74 | this.state = 1; 75 | if (!this.noSleep) { 76 | yield sleep(); 77 | } 78 | return this.request(); 79 | } 80 | this.wvl.off(wv_linewise_1.RESPONSE_TYPE.FINISHED, eventNotification); 81 | this.wvl.off(wv_linewise_1.RESPONSE_TYPE.LINE, eventNotification); 82 | this.wvl.off(wv_linewise_1.RESPONSE_TYPE.PAUSED, eventNotification); 83 | onlyOnceResolve(); 84 | }); 85 | this.wvl.on(wv_linewise_1.RESPONSE_TYPE.FINISHED, eventNotification); 86 | this.wvl.on(wv_linewise_1.RESPONSE_TYPE.LINE, eventNotification); 87 | this.wvl.on(wv_linewise_1.RESPONSE_TYPE.PAUSED, eventNotification); 88 | }); 89 | } 90 | request() { 91 | if (this.state >= 2) { 92 | return; 93 | } 94 | if (this.state == 0) { 95 | this.state = 2; 96 | this.wvl.streamStart(this.streamName, this.countToRequest); 97 | } 98 | else { 99 | this.state = 2; 100 | this.wvl.streamContinue(this.streamName); 101 | } 102 | } 103 | shift() { 104 | return __awaiter(this, void 0, void 0, function* () { 105 | let now = () => { 106 | let r = this.buffer.length ? this.buffer.shift() : null; 107 | if (r === undefined) { 108 | return null; 109 | } 110 | return r; 111 | }; 112 | if ((this.state < 2) && (this.buffer.length <= this.lowWaterMark)) { 113 | this.request(); 114 | } 115 | if (this.buffer.length == 0) { 116 | if (this.state == 2) { 117 | yield this.notify(); 118 | return now(); 119 | } 120 | return Promise.resolve(null); 121 | } 122 | return Promise.resolve(now()); 123 | }); 124 | } 125 | } 126 | exports.WvLinewiseBuffer = WvLinewiseBuffer; 127 | -------------------------------------------------------------------------------- /js-lib/dist/wv-linewise-fetch.d.ts: -------------------------------------------------------------------------------- 1 | import { WvLinewise } from "./wv-linewise"; 2 | export declare class WvLinewiseResponse implements Response { 3 | readonly url: string; 4 | private readonly resp_text; 5 | readonly status: number; 6 | readonly ok: boolean; 7 | headers: Headers; 8 | readonly redirected = false; 9 | readonly statusText: string; 10 | readonly trailer: Promise; 11 | readonly type: ResponseType; 12 | readonly body: ReadableStream | null; 13 | readonly bodyUsed: boolean; 14 | arrayBuffer(): Promise; 15 | blob(): Promise; 16 | formData(): Promise; 17 | constructor(url: string, resp_text: string, status: number, headers: { 18 | [k: string]: string; 19 | }); 20 | clone(): Response; 21 | json(): Promise; 22 | text(): Promise; 23 | private getStatusText; 24 | } 25 | export interface WvLinewiseRequest { 26 | opts: RequestInit; 27 | url: string; 28 | id: number; 29 | } 30 | export interface WvLinewiseFetchCurrent { 31 | id: number; 32 | status?: number; 33 | headers?: { 34 | [k: string]: string; 35 | }; 36 | body?: string[]; 37 | end?: boolean; 38 | } 39 | export declare function getWvLinewiseFetch(wvl: WvLinewise, responseStream: string): { 40 | (url: string, opts: RequestInit): Promise; 41 | request: (url: string, opts: RequestInit) => WvLinewiseRequest; 42 | serialize: (request: WvLinewiseRequest) => string; 43 | process: () => Promise; 44 | parse: (current: WvLinewiseFetchCurrent, command: string, lineStripped: string) => WvLinewiseFetchCurrent; 45 | pendingCount(): number; 46 | }; 47 | export declare function getWvLinewiseManagedFetch(wvl: WvLinewise, responseStream: string, getTimeout: (n: number) => number): { 48 | (url: string, opts: RequestInit): Promise; 49 | running(): boolean; 50 | }; 51 | -------------------------------------------------------------------------------- /js-lib/dist/wv-linewise-fetch.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.getWvLinewiseManagedFetch = exports.getWvLinewiseFetch = exports.WvLinewiseResponse = void 0; 13 | const wv_linewise_buffer_1 = require("./wv-linewise-buffer"); 14 | class WvHeaders { 15 | append(_name, _value) { throw new Error("Not Implemented"); } 16 | delete(_name) { throw new Error("Not Implemented"); } 17 | get(name) { 18 | if (this.hasOwnProperty(name)) { 19 | return this[name]; 20 | } 21 | return null; 22 | } 23 | has(name) { return this.hasOwnProperty(name); } 24 | set(_name, _value) { throw new Error("Not Implemented"); } 25 | forEach(callbackfn, thisArg) { 26 | let x = this; 27 | Object.getOwnPropertyNames(this).forEach((k) => { 28 | let v = x.get(k); 29 | if (typeof v === 'string') { 30 | callbackfn.call(thisArg || x, v, k, x); 31 | } 32 | }, {}); 33 | } 34 | constructor(kv) { 35 | Object.getOwnPropertyNames(kv).forEach((k) => { 36 | this[k] = kv[k]; 37 | }); 38 | } 39 | } 40 | class WvLinewiseResponse { 41 | constructor(url, resp_text, status, headers) { 42 | this.url = url; 43 | this.resp_text = resp_text; 44 | this.status = status; 45 | this.redirected = false; 46 | this.trailer = Promise.resolve(new WvHeaders({})); 47 | this.type = "basic"; 48 | this.body = null; 49 | this.bodyUsed = true; 50 | this.ok = (status >= 200) && (status < 300); 51 | this.statusText = this.getStatusText(status); 52 | this.headers = new WvHeaders(headers); 53 | } 54 | arrayBuffer() { throw new Error("WvLinewiseResponse: Unimplemented: arrayBuffer()"); } 55 | blob() { throw new Error("WvLinewiseResponse: Unimplemented: blob()"); } 56 | formData() { throw new Error("WvLinewiseResponse: Unimplemented: formData()"); } 57 | clone() { 58 | let headers = {}; 59 | Object.getOwnPropertyNames(this.headers).forEach((k) => { 60 | headers[k + ""] = headers[k] + ""; 61 | }); 62 | return new WvLinewiseResponse(this.url + "", this.resp_text + "", this.status, headers); 63 | } 64 | json() { return JSON.parse(this.resp_text); } 65 | text() { return Promise.resolve(this.resp_text); } 66 | getStatusText(n) { 67 | const statuses = { 68 | CONTINUE: 100, 69 | SWITCHING_PROTOCOLS: 101, 70 | OK: 200, 71 | CREATED: 201, 72 | ACCEPTED: 202, 73 | NON_AUTHORITATIVE_INFORMATION: 203, 74 | NO_CONTENT: 204, 75 | RESET_CONTENT: 205, 76 | PARTIAL_CONTENT: 206, 77 | MULTIPLE_CHOICES: 300, 78 | MOVED_PERMANENTLY: 301, 79 | FOUND: 302, 80 | SEE_OTHER: 303, 81 | NOT_MODIFIED: 304, 82 | USE_PROXY: 305, 83 | TEMPORARY_REDIRECT: 307, 84 | BAD_REQUEST: 400, 85 | UNAUTHORIZED: 401, 86 | PAYMENT_REQUIRED: 402, 87 | FORBIDDEN: 403, 88 | NOT_FOUND: 404, 89 | METHOD_NOT_ALLOWED: 405, 90 | NOT_ACCEPTABLE: 406, 91 | PROXY_AUTHENTICATION_REQUIRED: 407, 92 | REQUEST_TIMEOUT: 408, 93 | CONFLICT: 409, 94 | GONE: 410, 95 | LENGTH_REQUIRED: 411, 96 | PRECONDITION_FAILED: 412, 97 | REQUEST_ENTITY_TOO_LARGE: 413, 98 | REQUEST_URI_TOO_LONG: 414, 99 | UNSUPPORTED_MEDIA_TYPE: 415, 100 | REQUESTED_RANGE_NOT_SATISFIABLE: 416, 101 | EXPECTATION_FAILED: 417, 102 | UNPROCESSABLE_ENTITY: 422, 103 | TOO_MANY_REQUESTS: 429, 104 | INTERNAL_SERVER_ERROR: 500, 105 | NOT_IMPLEMENTED: 501, 106 | BAD_GATEWAY: 502, 107 | SERVICE_UNAVAILABLE: 503, 108 | GATEWAY_TIMEOUT: 504, 109 | HTTP_VERSION_NOT_SUPPORTED: 505, 110 | }; 111 | for (let [k, v] of Object.entries(statuses)) { 112 | if (v == n) { 113 | return k; 114 | } 115 | } 116 | throw new Error("Status code " + n + " not expected"); 117 | } 118 | } 119 | exports.WvLinewiseResponse = WvLinewiseResponse; 120 | function getWvLinewiseFetch(wvl, responseStream) { 121 | ; 122 | let id = 1; 123 | let wvlBuffer = new wv_linewise_buffer_1.WvLinewiseBuffer(wvl, responseStream, 16, 32); 124 | let requestOffset = 1; 125 | let promises = []; 126 | let currents = new Map(); 127 | const mainRegex = /^RESPONSE\: *([0-9]+)\: *([A-Z]{2,12})\:?/; 128 | function wvLinewiseFetch(url, opts) { 129 | wvl.out(wvLinewiseFetchSerialize(wvLinewiseFetchRequest(url, opts))); 130 | let r = new Promise((resolve, reject) => { 131 | promises.push({ resolve, reject, url }); 132 | }); 133 | return r; 134 | } 135 | function stripCommand(m, line) { 136 | line = line.substr(m[0].length); 137 | return line; 138 | } 139 | function stripPreWhitespace(line) { 140 | while ((line.length) && ((line[0] == ' ') || (line[0] == "\t"))) { 141 | line = line.substr(1); 142 | } 143 | return line; 144 | } 145 | function wvLinewiseFetchParseLine(current, command, lineStripped) { 146 | if (command == 'END') { 147 | return Object.assign(Object.assign({}, current), { end: true, body: current.body || [], headers: current.headers || {} }); 148 | } 149 | if (command == 'STATUS') { 150 | if (!current.hasOwnProperty('body')) { 151 | current.body = []; 152 | } 153 | lineStripped = stripPreWhitespace(lineStripped); 154 | let n = parseInt(lineStripped, 10); 155 | if (isNaN(n)) { 156 | throw new Error(`wvLinewiseFetchParseLine: Id ${lineStripped} is not an integer`); 157 | } 158 | return Object.assign(Object.assign({}, current), { status: n }); 159 | } 160 | if (command == 'BODY') { 161 | if (!current.hasOwnProperty('body')) { 162 | current.body = []; 163 | } 164 | return Object.assign(Object.assign({}, current), { body: [...current.body || []].concat([lineStripped]) }); 165 | } 166 | if (command == 'HEADERS') { 167 | let c = Object.assign({}, current); 168 | c.headers = c.headers || {}; 169 | let parsed = {}; 170 | try { 171 | parsed = JSON.parse(stripPreWhitespace(lineStripped)); 172 | } 173 | catch (e) { 174 | throw new Error(`wvLinewiseFetchParseLine: HEADERS supplied must be in JSON: '${lineStripped}'`); 175 | } 176 | for (let [k, v] of Object.entries(parsed)) { 177 | c.headers["" + k] = "" + v; 178 | } 179 | return c; 180 | } 181 | throw new Error(`wvLinewiseFetchParseLine: Line not recognized: '${lineStripped}' '${command}'`); 182 | } 183 | function extractFromLine(line) { 184 | const m = line.match(mainRegex); 185 | if (!m) { 186 | throw new Error("wvLinewiseFetchParseLine: Invalid line: " + line); 187 | } 188 | const n = parseInt(m[1], 10); 189 | if (isNaN(n)) { 190 | throw new Error(`wvLinewiseFetchParseLine: Id ${line} is not an integer`); 191 | } 192 | if ((n < requestOffset) || (n > requestOffset + promises.length)) { 193 | throw new Error(`wvLinewiseFetchParseLine: Id ${line} was not expected`); 194 | } 195 | return { n, command: stripPreWhitespace(m[2]), lineStripped: line.substr(m[0].length) }; 196 | } 197 | function initializeAndReturn(n) { 198 | const r = currents.get(n); 199 | if (r) { 200 | return r; 201 | } 202 | const current = { id: n }; 203 | currents.set(n, current); 204 | return current; 205 | } 206 | function wvLinewiseFetchProcess() { 207 | return __awaiter(this, void 0, void 0, function* () { 208 | let line = yield wvlBuffer.shift(); 209 | if (line === null) { 210 | return false; 211 | } 212 | const { n, command, lineStripped } = extractFromLine(line); 213 | let current = initializeAndReturn(n); 214 | current = wvLinewiseFetchParseLine(current, command, lineStripped); 215 | if (current.end) { 216 | let index = (current.id || 0) - requestOffset; 217 | let ps = promises[index]; 218 | if (ps === null) { 219 | throw new Error(`wvLinewiseFetchProcess: The promise at index ${index} seems to have been already used!`); 220 | } 221 | let resolve = ps.resolve; 222 | let url = ps.url; 223 | promises[index] = null; 224 | while (promises.length && (promises[0] === null)) { 225 | promises.shift(); 226 | requestOffset = requestOffset + 1; 227 | } 228 | let { body, status, headers } = current; 229 | resolve(new WvLinewiseResponse(url, (body || []).join("\n"), status || 200, headers || {})); 230 | currents.delete(current.id); 231 | } 232 | currents.set(current.id, current); 233 | return true; 234 | }); 235 | } 236 | function wvLinewiseFetchRequest(url, opts) { 237 | return { id: id++, url, opts }; 238 | } 239 | function wvLinewiseFetchSerialize(request) { 240 | let m = (request.opts.method || 'GET').toUpperCase(); 241 | return `REQUEST: ${request.id}: ${m}: ${request.url} ${request.opts.body || '{}'}`; 242 | } 243 | wvLinewiseFetch.request = wvLinewiseFetchRequest; 244 | wvLinewiseFetch.serialize = wvLinewiseFetchSerialize; 245 | wvLinewiseFetch.process = wvLinewiseFetchProcess; 246 | wvLinewiseFetch.parse = wvLinewiseFetchParseLine; 247 | wvLinewiseFetch.pendingCount = function wvLinewiseFetchPendingCount() { 248 | return promises.length; 249 | }; 250 | return wvLinewiseFetch; 251 | } 252 | exports.getWvLinewiseFetch = getWvLinewiseFetch; 253 | function getWvLinewiseManagedFetch(wvl, responseStream, getTimeout) { 254 | let wvLinewiseFetch = getWvLinewiseFetch(wvl, responseStream); 255 | let processing = false; 256 | let running = null; 257 | let backoffNumber = 0; 258 | function delay(n) { 259 | return new Promise((resolve) => { 260 | setTimeout(() => resolve(true), n); 261 | }); 262 | } 263 | function looper() { 264 | return __awaiter(this, void 0, void 0, function* () { 265 | backoffNumber = 0; 266 | if (processing) { 267 | return; 268 | } 269 | processing = true; 270 | if ((yield wvLinewiseFetch.process()) == true) { 271 | backoffNumber = 0; 272 | } 273 | yield delay(getTimeout(backoffNumber)); 274 | backoffNumber = backoffNumber + 1; 275 | processing = false; 276 | }); 277 | } 278 | function end() { 279 | if (wvLinewiseFetch.pendingCount() == 0) { 280 | running && clearInterval(running); 281 | running = null; 282 | } 283 | } 284 | function wvLinewiseManagedFetch(url, opts) { 285 | return __awaiter(this, void 0, void 0, function* () { 286 | if (!running) { 287 | let rp = wvLinewiseFetch(url, opts); 288 | running = setInterval(looper, 10); 289 | let r = yield rp; 290 | end(); 291 | return r; 292 | } 293 | backoffNumber = 0; 294 | let r = yield wvLinewiseFetch(url, opts); 295 | end(); 296 | return r; 297 | }); 298 | } 299 | wvLinewiseManagedFetch.running = function () { 300 | return running !== null; 301 | }; 302 | return wvLinewiseManagedFetch; 303 | } 304 | exports.getWvLinewiseManagedFetch = getWvLinewiseManagedFetch; 305 | -------------------------------------------------------------------------------- /js-lib/dist/wv-linewise.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Communication from the web-view to WV Linewise is sent via a Request and responeded to via a {@link Response} 3 | */ 4 | export declare type Request = StreamStartRequest | StreamContinueRequest | ParamsRequest | OutRequest | ExitRequest | StreamListRequest; 5 | /** 6 | * Every {@link Request} includes a `msg` which will from this enum. 7 | */ 8 | export declare enum REQUEST_TYPE { 9 | EXIT = "exit", 10 | STREAM_LIST = "streamList", 11 | STREAM_START = "streamStart", 12 | STREAM_CONTINUE = "streamContinue", 13 | PARAMS = "params", 14 | OUT = "out" 15 | } 16 | /** 17 | * {@link Request} to start a named stream. 18 | */ 19 | export interface StreamStartRequest { 20 | msg: REQUEST_TYPE.STREAM_START; 21 | /** The name of the stream to start */ 22 | name: string; 23 | /** How many lines to read before the stream is {@link PausedResponse} */ 24 | count: number; 25 | } 26 | /** 27 | * {@link Request} that the program exits (and the web view is closed). 28 | */ 29 | export interface ExitRequest { 30 | msg: REQUEST_TYPE.EXIT; 31 | /** This is the exit status returned to the software which started the webview, 0 is success */ 32 | status: number; 33 | } 34 | /** 35 | * {@link Request} To get a list of streams. 36 | */ 37 | export interface StreamListRequest { 38 | msg: REQUEST_TYPE.STREAM_LIST; 39 | } 40 | /** 41 | * Once a stream has been started, then {@link PausedResponse} because 42 | * {@link StreamStartRequest.count} lines had been read you can restart it with 43 | * this {@link Request} 44 | */ 45 | export interface StreamContinueRequest { 46 | msg: REQUEST_TYPE.STREAM_CONTINUE; 47 | name: string; 48 | } 49 | /** 50 | * {@link Request} the command line parameters passed in when starting the wv-linewise 51 | */ 52 | export interface ParamsRequest { 53 | msg: REQUEST_TYPE.PARAMS; 54 | } 55 | /** 56 | * Used by {@link OutRequest} to control which UNIX stream to write to. 57 | */ 58 | export declare enum OUT_REQUEST_DESCRIPTOR { 59 | STDOUT = 1, 60 | STDERR = 2, 61 | DESCRIPTOR_3 = 3, 62 | DESCRIPTOR_4 = 4, 63 | DESCRIPTOR_5 = 5, 64 | DESCRIPTOR_6 = 6, 65 | DESCRIPTOR_7 = 7, 66 | DESCRIPTOR_8 = 8, 67 | DESCRIPTOR_9 = 9 68 | } 69 | /** 70 | * {@link Request} that wv-linewise send {@link OutRequest.data} to 71 | * {@link OutRequest.descriptor} so it can be picked up by other programs 72 | * further down the pipeline. 73 | */ 74 | export interface OutRequest { 75 | msg: REQUEST_TYPE.OUT; 76 | descriptor: OUT_REQUEST_DESCRIPTOR; 77 | data: string; 78 | } 79 | /** 80 | * Communication from the WV Linewise to the webview, usually in response to a {@link Request} is sent via a Response. 81 | */ 82 | export declare type Response = ParamsResponse | PausedResponse | FinishedResponse | DetailsResponse | LineResponse | MessageErrorResponse | ErrorResponse | StreamListResponse; 83 | /** 84 | * Every {@link Response} includes a `type` which will from this enum. 85 | */ 86 | export declare enum RESPONSE_TYPE { 87 | PARAMS = "params", 88 | LINE = "line", 89 | STREAM_LIST = "streamList", 90 | DETAILS = "details", 91 | FINISHED = "finished", 92 | PAUSED = "paused", 93 | ERROR = "error", 94 | MESSAGE_ERROR = "messageError" 95 | } 96 | /** 97 | * This is a key/value pair which is embedded in a {@link ParamsResponse}. 98 | */ 99 | export interface Param { 100 | name: string; 101 | value: string; 102 | } 103 | /** 104 | * The parameters that were passed to WV Linewise, perhaps in BASH when it was started. 105 | */ 106 | export interface ParamsResponse { 107 | type: RESPONSE_TYPE.PARAMS; 108 | params: Param[]; 109 | } 110 | /** 111 | * A list of streams, in response to a {@link StreamListRequest} 112 | */ 113 | export interface StreamListResponse { 114 | type: RESPONSE_TYPE.STREAM_LIST; 115 | streams: string[]; 116 | } 117 | /** 118 | * After we have read {@link StreamStartRequest.count} lines we will 119 | * {@link PausedResponse}. 120 | * 121 | * To restart the stream use an {@link StreamContinueRequest}. 122 | */ 123 | export interface PausedResponse { 124 | type: RESPONSE_TYPE.PAUSED; 125 | name: string; 126 | } 127 | /** 128 | * The stream of data started via a {@link StreamStartRequest} may be infinate, 129 | * but it may also have an end. This marks the end. 130 | */ 131 | export interface FinishedResponse { 132 | type: RESPONSE_TYPE.FINISHED; 133 | name: string; 134 | } 135 | /** 136 | * Once a {@link StreamStartRequest} has been received, we will respond with 137 | * the details about that stream before sending {@link LineResponse}s. 138 | * 139 | * In future streams from files will likely be rewindable, but currently 140 | * {@link rewindable} is always false. 141 | */ 142 | export interface DetailsResponse { 143 | type: RESPONSE_TYPE.DETAILS; 144 | name: string; 145 | rewindable: boolean; 146 | } 147 | /** 148 | * Once a {@link StreamStartRequest} has been received this message will contain 149 | * the actual data from the file or STDIN. 150 | */ 151 | export interface LineResponse { 152 | type: RESPONSE_TYPE.LINE; 153 | name: string; 154 | data: string; 155 | } 156 | /** 157 | * This {@link Response} is sent after a {@link Request} is received that is 158 | * invalid. 159 | */ 160 | export interface MessageErrorResponse { 161 | type: RESPONSE_TYPE.MESSAGE_ERROR; 162 | error: string; 163 | } 164 | /** 165 | * This {@link Response} is sent in response to errors which can be pinned down 166 | * to a specific stream, or a request to a non-existing stream. 167 | */ 168 | export interface ErrorResponse { 169 | type: RESPONSE_TYPE.ERROR; 170 | error: string; 171 | name: string; 172 | } 173 | export interface ResponseDispatcher { 174 | (evt: Response): void; 175 | } 176 | export declare class RawWvLinewise { 177 | private external; 178 | private respFnsOnce; 179 | private respFns; 180 | constructor(external: { 181 | invoke: (e: string) => void; 182 | }); 183 | private getResponseDispatcher; 184 | protected fire(d: Response): void; 185 | request(j: Request): void; 186 | on(type: T["type"], f: ResponseDispatcher): void; 187 | once(type: T["type"], f: ResponseDispatcher): void; 188 | clear(type: T["type"]): void; 189 | off(type: T["type"], f: ResponseDispatcher): void; 190 | } 191 | export declare class RawWvLinewiseMock extends RawWvLinewise { 192 | private streamData; 193 | private params; 194 | private running; 195 | private started; 196 | private startedCounts; 197 | constructor(); 198 | addStreamData(streamName: LineResponse["name"], data: LineResponse["data"][]): void; 199 | addParam(name: Param["name"], value: Param["value"]): void; 200 | start(name: string, count: number): void; 201 | request(j: Request): Promise; 202 | } 203 | export declare class WvLinewise { 204 | raw: RawWvLinewise; 205 | constructor(raw: RawWvLinewise); 206 | streamStart(streamName: string, count: number): void; 207 | streamContinue(streamName: string): void; 208 | requestParams(): void; 209 | exit(status: number): void; 210 | requestStreamList(): void; 211 | out(text: string, descriptor?: OutRequest["descriptor"]): void; 212 | on(type: T["type"], f: ResponseDispatcher): void; 213 | once(type: T["type"], f: ResponseDispatcher): void; 214 | clear(type: T["type"]): void; 215 | off(type: T["type"], f: ResponseDispatcher): void; 216 | } 217 | export declare function runningInWvLinewise(): boolean; 218 | export declare function externalInvoke(e: any): any; 219 | -------------------------------------------------------------------------------- /js-lib/dist/wv-linewise.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.externalInvoke = exports.runningInWvLinewise = exports.WvLinewise = exports.RawWvLinewiseMock = exports.RawWvLinewise = exports.RESPONSE_TYPE = exports.OUT_REQUEST_DESCRIPTOR = exports.REQUEST_TYPE = void 0; 13 | /** 14 | * Every {@link Request} includes a `msg` which will from this enum. 15 | */ 16 | var REQUEST_TYPE; 17 | (function (REQUEST_TYPE) { 18 | REQUEST_TYPE["EXIT"] = "exit"; 19 | REQUEST_TYPE["STREAM_LIST"] = "streamList"; 20 | REQUEST_TYPE["STREAM_START"] = "streamStart"; 21 | REQUEST_TYPE["STREAM_CONTINUE"] = "streamContinue"; 22 | REQUEST_TYPE["PARAMS"] = "params"; 23 | REQUEST_TYPE["OUT"] = "out"; 24 | })(REQUEST_TYPE = exports.REQUEST_TYPE || (exports.REQUEST_TYPE = {})); 25 | /** 26 | * Used by {@link OutRequest} to control which UNIX stream to write to. 27 | */ 28 | var OUT_REQUEST_DESCRIPTOR; 29 | (function (OUT_REQUEST_DESCRIPTOR) { 30 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["STDOUT"] = 1] = "STDOUT"; 31 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["STDERR"] = 2] = "STDERR"; 32 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["DESCRIPTOR_3"] = 3] = "DESCRIPTOR_3"; 33 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["DESCRIPTOR_4"] = 4] = "DESCRIPTOR_4"; 34 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["DESCRIPTOR_5"] = 5] = "DESCRIPTOR_5"; 35 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["DESCRIPTOR_6"] = 6] = "DESCRIPTOR_6"; 36 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["DESCRIPTOR_7"] = 7] = "DESCRIPTOR_7"; 37 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["DESCRIPTOR_8"] = 8] = "DESCRIPTOR_8"; 38 | OUT_REQUEST_DESCRIPTOR[OUT_REQUEST_DESCRIPTOR["DESCRIPTOR_9"] = 9] = "DESCRIPTOR_9"; 39 | })(OUT_REQUEST_DESCRIPTOR = exports.OUT_REQUEST_DESCRIPTOR || (exports.OUT_REQUEST_DESCRIPTOR = {})); 40 | /** 41 | * Every {@link Response} includes a `type` which will from this enum. 42 | */ 43 | var RESPONSE_TYPE; 44 | (function (RESPONSE_TYPE) { 45 | RESPONSE_TYPE["PARAMS"] = "params"; 46 | RESPONSE_TYPE["LINE"] = "line"; 47 | RESPONSE_TYPE["STREAM_LIST"] = "streamList"; 48 | RESPONSE_TYPE["DETAILS"] = "details"; 49 | RESPONSE_TYPE["FINISHED"] = "finished"; 50 | RESPONSE_TYPE["PAUSED"] = "paused"; 51 | RESPONSE_TYPE["ERROR"] = "error"; 52 | RESPONSE_TYPE["MESSAGE_ERROR"] = "messageError"; 53 | })(RESPONSE_TYPE = exports.RESPONSE_TYPE || (exports.RESPONSE_TYPE = {})); 54 | class RawWvLinewise { 55 | constructor(external) { 56 | this.external = external; 57 | this.respFnsOnce = { 58 | error: [], 59 | messageError: [], 60 | params: [], 61 | streamList: [], 62 | paused: [], 63 | details: [], 64 | line: [], 65 | finished: [], 66 | }; 67 | this.respFns = { 68 | error: [], 69 | messageError: [], 70 | params: [], 71 | streamList: [], 72 | paused: [], 73 | details: [], 74 | line: [], 75 | finished: [], 76 | }; 77 | if (typeof window !== "undefined") { 78 | window._globalWvLinewise = (d) => this.fire(d); 79 | } 80 | } 81 | getResponseDispatcher(e) { 82 | let r = this.respFns[e]; 83 | while (this.respFnsOnce[e].length) { 84 | r = r.concat([this.respFnsOnce[e].shift()]); 85 | } 86 | return r; 87 | } 88 | fire(d) { 89 | let fires = this.getResponseDispatcher(d.type); 90 | if (!fires.length) { 91 | return; 92 | } 93 | for (let i = 0; i < fires.length; i++) { 94 | fires[i].call(null, d); 95 | } 96 | } 97 | request(j) { 98 | this.external.invoke(JSON.stringify(j)); 99 | } 100 | on(type, f) { 101 | this.respFns[type].push(f); 102 | } 103 | once(type, f) { 104 | this.respFnsOnce[type].push(f); 105 | } 106 | clear(type) { 107 | this.respFns[type] = []; 108 | this.respFnsOnce[type] = []; 109 | } 110 | off(type, f) { 111 | for (let i = this.respFns[type].length - 1; i >= 0; i--) { 112 | if (this.respFns[type][i] == f) { 113 | this.respFns[type].splice(i, 1); 114 | } 115 | } 116 | for (let i = this.respFnsOnce[type].length - 1; i >= 0; i--) { 117 | if (this.respFnsOnce[type][i] == f) { 118 | this.respFnsOnce[type].splice(i, 1); 119 | } 120 | } 121 | } 122 | } 123 | exports.RawWvLinewise = RawWvLinewise; 124 | class RawWvLinewiseMock extends RawWvLinewise { 125 | constructor() { 126 | super({ invoke: (_s) => { } }); 127 | this.streamData = new Map(); 128 | this.params = []; 129 | this.running = new Set(); 130 | this.started = new Set(); 131 | this.startedCounts = new Map(); 132 | } 133 | addStreamData(streamName, data) { 134 | if (!this.streamData.has(streamName)) { 135 | this.streamData.set(streamName, []); 136 | } 137 | this.streamData.set(streamName, (this.streamData.get(streamName) || []).concat(data)); 138 | } 139 | addParam(name, value) { 140 | this.params.push({ name, value }); 141 | } 142 | start(name, count) { 143 | this.startedCounts.set(name, count); 144 | this.running.add(name); 145 | if (!this.started.has(name)) { 146 | this.fire({ name: name, rewindable: false, type: RESPONSE_TYPE.DETAILS }); 147 | this.started.add(name); 148 | } 149 | let stream = this.streamData.get(name) || []; 150 | let lineNumber = 0; 151 | while ((lineNumber++ < count) && stream.length) { 152 | let line = stream.shift(); 153 | this.fire({ name: name, data: line, type: RESPONSE_TYPE.LINE }); 154 | } 155 | this.running.delete(name); 156 | if (stream.length) { 157 | this.fire({ name: name, type: RESPONSE_TYPE.PAUSED }); 158 | } 159 | else { 160 | this.fire({ name: name, type: RESPONSE_TYPE.FINISHED }); 161 | } 162 | } 163 | request(j) { 164 | return __awaiter(this, void 0, void 0, function* () { 165 | switch (j.msg) { 166 | case REQUEST_TYPE.EXIT: 167 | window.document.body.innerText = "EXIT DONE"; 168 | break; 169 | case REQUEST_TYPE.STREAM_LIST: 170 | this.fire({ type: RESPONSE_TYPE.STREAM_LIST, streams: Array.from(this.streamData.keys()) }); 171 | break; 172 | case REQUEST_TYPE.PARAMS: 173 | this.fire({ type: RESPONSE_TYPE.PARAMS, params: this.params }); 174 | break; 175 | case REQUEST_TYPE.STREAM_CONTINUE: 176 | this.start(j.name, this.startedCounts.get(j.name) || 0); 177 | break; 178 | case REQUEST_TYPE.OUT: 179 | if (j.descriptor == 2) { 180 | console.log(`STDERR: ${j.data}`); 181 | } 182 | if (j.descriptor == 1) { 183 | console.log(`STDOUT: ${j.data}`); 184 | } 185 | if ((j.descriptor > 2) && (j.descriptor < 10)) { 186 | console.log(`STD${j.descriptor}: ${j.data}`); 187 | } 188 | break; 189 | case REQUEST_TYPE.STREAM_START: 190 | if (!j.hasOwnProperty("name") || !j.hasOwnProperty("count")) { 191 | return; 192 | } 193 | if (!this.streamData.has(j.name)) { 194 | this.fire({ name: j.name, error: "No such stream", type: RESPONSE_TYPE.ERROR }); 195 | return; 196 | } 197 | if ((this.running.has(j.name)) || !this.streamData.has(j.name)) { 198 | return; 199 | } 200 | this.start(j.name, j.count); 201 | break; 202 | } 203 | }); 204 | } 205 | } 206 | exports.RawWvLinewiseMock = RawWvLinewiseMock; 207 | class WvLinewise { 208 | constructor(raw) { 209 | this.raw = raw; 210 | } 211 | streamStart(streamName, count) { 212 | this.raw.request({ msg: REQUEST_TYPE.STREAM_START, name: streamName, count }); 213 | } 214 | streamContinue(streamName) { 215 | this.raw.request({ msg: REQUEST_TYPE.STREAM_CONTINUE, name: streamName }); 216 | } 217 | requestParams() { 218 | this.raw.request({ msg: REQUEST_TYPE.PARAMS }); 219 | } 220 | exit(status) { 221 | this.raw.request({ msg: REQUEST_TYPE.EXIT, status }); 222 | } 223 | requestStreamList() { 224 | this.raw.request({ msg: REQUEST_TYPE.STREAM_LIST }); 225 | } 226 | out(text, descriptor = OUT_REQUEST_DESCRIPTOR.STDOUT) { 227 | this.raw.request({ msg: REQUEST_TYPE.OUT, descriptor, data: text }); 228 | } 229 | on(type, f) { 230 | this.raw.on(type, f); 231 | } 232 | once(type, f) { 233 | this.raw.once(type, f); 234 | } 235 | clear(type) { 236 | this.raw.clear(type); 237 | } 238 | off(type, f) { 239 | this.raw.off(type, f); 240 | } 241 | } 242 | exports.WvLinewise = WvLinewise; 243 | function runningInWvLinewise() { 244 | if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.external && window.webkit.messageHandlers.external.postMessage) { 245 | window.external = { 246 | invoke: (e) => { 247 | window.webkit.messageHandlers.external.postMessage(e); 248 | } 249 | }; 250 | return true; 251 | } 252 | return !!(window.external && window.external.invoke); 253 | } 254 | exports.runningInWvLinewise = runningInWvLinewise; 255 | function externalInvoke(e) { 256 | if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.external && window.webkit.messageHandlers.external.postMessage) { 257 | return window.webkit.messageHandlers.external.postMessage(e); 258 | } 259 | if (window.external && window.external.invoke) { 260 | return window.external.invoke(e); 261 | } 262 | throw new Error("WV Linewise: Could not post message: " + JSON.stringify(e)); 263 | } 264 | exports.externalInvoke = externalInvoke; 265 | -------------------------------------------------------------------------------- /js-lib/docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /js-lib/docs/README.md: -------------------------------------------------------------------------------- 1 | wv-linewise-js-lib / [Modules](modules.md) 2 | 3 | # wv-linewise-js-lib 4 | 5 | There are API docs available in the [docs](https://github.com/forbesmyester/wv-linewise/blob/master/js-lib/docs/README.md) directory. 6 | 7 | Overall usage documentation can be found in the [WV Linewise repository](https://github.com/forbesmyester/wv-linewise/README.md) 8 | -------------------------------------------------------------------------------- /js-lib/docs/classes/wv_linewise.RawWvLinewise.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / RawWvLinewise 2 | 3 | # Class: RawWvLinewise 4 | 5 | [wv-linewise](../modules/wv_linewise.md).RawWvLinewise 6 | 7 | ## Hierarchy 8 | 9 | - **`RawWvLinewise`** 10 | 11 | ↳ [`RawWvLinewiseMock`](wv_linewise.RawWvLinewiseMock.md) 12 | 13 | ## Table of contents 14 | 15 | ### Constructors 16 | 17 | - [constructor](wv_linewise.RawWvLinewise.md#constructor) 18 | 19 | ### Properties 20 | 21 | - [respFns](wv_linewise.RawWvLinewise.md#respfns) 22 | - [respFnsOnce](wv_linewise.RawWvLinewise.md#respfnsonce) 23 | 24 | ### Methods 25 | 26 | - [clear](wv_linewise.RawWvLinewise.md#clear) 27 | - [fire](wv_linewise.RawWvLinewise.md#fire) 28 | - [getResponseDispatcher](wv_linewise.RawWvLinewise.md#getresponsedispatcher) 29 | - [off](wv_linewise.RawWvLinewise.md#off) 30 | - [on](wv_linewise.RawWvLinewise.md#on) 31 | - [once](wv_linewise.RawWvLinewise.md#once) 32 | - [request](wv_linewise.RawWvLinewise.md#request) 33 | 34 | ## Constructors 35 | 36 | ### constructor 37 | 38 | • **new RawWvLinewise**(`external`) 39 | 40 | #### Parameters 41 | 42 | | Name | Type | 43 | | :------ | :------ | 44 | | `external` | `Object` | 45 | | `external.invoke` | (`e`: `string`) => `void` | 46 | 47 | #### Defined in 48 | 49 | [wv-linewise.ts:222](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L222) 50 | 51 | ## Properties 52 | 53 | ### respFns 54 | 55 | • `Private` **respFns**: `Object` 56 | 57 | #### Type declaration 58 | 59 | | Name | Type | 60 | | :------ | :------ | 61 | | `details` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`DetailsResponse`](../interfaces/wv_linewise.DetailsResponse.md)\>[] | 62 | | `error` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`ErrorResponse`](../interfaces/wv_linewise.ErrorResponse.md)\>[] | 63 | | `finished` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`FinishedResponse`](../interfaces/wv_linewise.FinishedResponse.md)\>[] | 64 | | `line` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`LineResponse`](../interfaces/wv_linewise.LineResponse.md)\>[] | 65 | | `messageError` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`MessageErrorResponse`](../interfaces/wv_linewise.MessageErrorResponse.md)\>[] | 66 | | `params` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`ParamsResponse`](../interfaces/wv_linewise.ParamsResponse.md)\>[] | 67 | | `paused` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`PausedResponse`](../interfaces/wv_linewise.PausedResponse.md)\>[] | 68 | | `streamList` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`StreamListResponse`](../interfaces/wv_linewise.StreamListResponse.md)\>[] | 69 | 70 | #### Defined in 71 | 72 | [wv-linewise.ts:211](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L211) 73 | 74 | ___ 75 | 76 | ### respFnsOnce 77 | 78 | • `Private` **respFnsOnce**: `Object` 79 | 80 | #### Type declaration 81 | 82 | | Name | Type | 83 | | :------ | :------ | 84 | | `details` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`DetailsResponse`](../interfaces/wv_linewise.DetailsResponse.md)\>[] | 85 | | `error` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`ErrorResponse`](../interfaces/wv_linewise.ErrorResponse.md)\>[] | 86 | | `finished` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`FinishedResponse`](../interfaces/wv_linewise.FinishedResponse.md)\>[] | 87 | | `line` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`LineResponse`](../interfaces/wv_linewise.LineResponse.md)\>[] | 88 | | `messageError` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`MessageErrorResponse`](../interfaces/wv_linewise.MessageErrorResponse.md)\>[] | 89 | | `params` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`ParamsResponse`](../interfaces/wv_linewise.ParamsResponse.md)\>[] | 90 | | `paused` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`PausedResponse`](../interfaces/wv_linewise.PausedResponse.md)\>[] | 91 | | `streamList` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<[`StreamListResponse`](../interfaces/wv_linewise.StreamListResponse.md)\>[] | 92 | 93 | #### Defined in 94 | 95 | [wv-linewise.ts:200](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L200) 96 | 97 | ## Methods 98 | 99 | ### clear 100 | 101 | ▸ **clear**<`T`\>(`type`): `void` 102 | 103 | #### Type parameters 104 | 105 | | Name | Type | 106 | | :------ | :------ | 107 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 108 | 109 | #### Parameters 110 | 111 | | Name | Type | 112 | | :------ | :------ | 113 | | `type` | `T`[``"type"``] | 114 | 115 | #### Returns 116 | 117 | `void` 118 | 119 | #### Defined in 120 | 121 | [wv-linewise.ts:258](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L258) 122 | 123 | ___ 124 | 125 | ### fire 126 | 127 | ▸ `Protected` **fire**(`d`): `void` 128 | 129 | #### Parameters 130 | 131 | | Name | Type | 132 | | :------ | :------ | 133 | | `d` | [`Response`](../modules/wv_linewise.md#response) | 134 | 135 | #### Returns 136 | 137 | `void` 138 | 139 | #### Defined in 140 | 141 | [wv-linewise.ts:236](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L236) 142 | 143 | ___ 144 | 145 | ### getResponseDispatcher 146 | 147 | ▸ `Private` **getResponseDispatcher**<`T`\>(`e`): [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\>[] 148 | 149 | #### Type parameters 150 | 151 | | Name | Type | 152 | | :------ | :------ | 153 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 154 | 155 | #### Parameters 156 | 157 | | Name | Type | 158 | | :------ | :------ | 159 | | `e` | `T`[``"type"``] | 160 | 161 | #### Returns 162 | 163 | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\>[] 164 | 165 | #### Defined in 166 | 167 | [wv-linewise.ts:228](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L228) 168 | 169 | ___ 170 | 171 | ### off 172 | 173 | ▸ **off**<`T`\>(`type`, `f`): `void` 174 | 175 | #### Type parameters 176 | 177 | | Name | Type | 178 | | :------ | :------ | 179 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 180 | 181 | #### Parameters 182 | 183 | | Name | Type | 184 | | :------ | :------ | 185 | | `type` | `T`[``"type"``] | 186 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 187 | 188 | #### Returns 189 | 190 | `void` 191 | 192 | #### Defined in 193 | 194 | [wv-linewise.ts:263](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L263) 195 | 196 | ___ 197 | 198 | ### on 199 | 200 | ▸ **on**<`T`\>(`type`, `f`): `void` 201 | 202 | #### Type parameters 203 | 204 | | Name | Type | 205 | | :------ | :------ | 206 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 207 | 208 | #### Parameters 209 | 210 | | Name | Type | 211 | | :------ | :------ | 212 | | `type` | `T`[``"type"``] | 213 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 214 | 215 | #### Returns 216 | 217 | `void` 218 | 219 | #### Defined in 220 | 221 | [wv-linewise.ts:250](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L250) 222 | 223 | ___ 224 | 225 | ### once 226 | 227 | ▸ **once**<`T`\>(`type`, `f`): `void` 228 | 229 | #### Type parameters 230 | 231 | | Name | Type | 232 | | :------ | :------ | 233 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 234 | 235 | #### Parameters 236 | 237 | | Name | Type | 238 | | :------ | :------ | 239 | | `type` | `T`[``"type"``] | 240 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 241 | 242 | #### Returns 243 | 244 | `void` 245 | 246 | #### Defined in 247 | 248 | [wv-linewise.ts:254](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L254) 249 | 250 | ___ 251 | 252 | ### request 253 | 254 | ▸ **request**(`j`): `void` 255 | 256 | #### Parameters 257 | 258 | | Name | Type | 259 | | :------ | :------ | 260 | | `j` | [`Request`](../modules/wv_linewise.md#request) | 261 | 262 | #### Returns 263 | 264 | `void` 265 | 266 | #### Defined in 267 | 268 | [wv-linewise.ts:246](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L246) 269 | -------------------------------------------------------------------------------- /js-lib/docs/classes/wv_linewise.RawWvLinewiseMock.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / RawWvLinewiseMock 2 | 3 | # Class: RawWvLinewiseMock 4 | 5 | [wv-linewise](../modules/wv_linewise.md).RawWvLinewiseMock 6 | 7 | ## Hierarchy 8 | 9 | - [`RawWvLinewise`](wv_linewise.RawWvLinewise.md) 10 | 11 | ↳ **`RawWvLinewiseMock`** 12 | 13 | ## Table of contents 14 | 15 | ### Constructors 16 | 17 | - [constructor](wv_linewise.RawWvLinewiseMock.md#constructor) 18 | 19 | ### Properties 20 | 21 | - [params](wv_linewise.RawWvLinewiseMock.md#params) 22 | - [running](wv_linewise.RawWvLinewiseMock.md#running) 23 | - [started](wv_linewise.RawWvLinewiseMock.md#started) 24 | - [startedCounts](wv_linewise.RawWvLinewiseMock.md#startedcounts) 25 | - [streamData](wv_linewise.RawWvLinewiseMock.md#streamdata) 26 | 27 | ### Methods 28 | 29 | - [addParam](wv_linewise.RawWvLinewiseMock.md#addparam) 30 | - [addStreamData](wv_linewise.RawWvLinewiseMock.md#addstreamdata) 31 | - [clear](wv_linewise.RawWvLinewiseMock.md#clear) 32 | - [fire](wv_linewise.RawWvLinewiseMock.md#fire) 33 | - [off](wv_linewise.RawWvLinewiseMock.md#off) 34 | - [on](wv_linewise.RawWvLinewiseMock.md#on) 35 | - [once](wv_linewise.RawWvLinewiseMock.md#once) 36 | - [request](wv_linewise.RawWvLinewiseMock.md#request) 37 | - [start](wv_linewise.RawWvLinewiseMock.md#start) 38 | 39 | ## Constructors 40 | 41 | ### constructor 42 | 43 | • **new RawWvLinewiseMock**() 44 | 45 | #### Overrides 46 | 47 | [RawWvLinewise](wv_linewise.RawWvLinewise.md).[constructor](wv_linewise.RawWvLinewise.md#constructor) 48 | 49 | #### Defined in 50 | 51 | [wv-linewise.ts:288](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L288) 52 | 53 | ## Properties 54 | 55 | ### params 56 | 57 | • `Private` **params**: [`Param`](../interfaces/wv_linewise.Param.md)[] = `[]` 58 | 59 | #### Defined in 60 | 61 | [wv-linewise.ts:283](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L283) 62 | 63 | ___ 64 | 65 | ### running 66 | 67 | • `Private` **running**: `Set`<`string`\> 68 | 69 | #### Defined in 70 | 71 | [wv-linewise.ts:284](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L284) 72 | 73 | ___ 74 | 75 | ### started 76 | 77 | • `Private` **started**: `Set`<`string`\> 78 | 79 | #### Defined in 80 | 81 | [wv-linewise.ts:285](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L285) 82 | 83 | ___ 84 | 85 | ### startedCounts 86 | 87 | • `Private` **startedCounts**: `Map`<`string`, `number`\> 88 | 89 | #### Defined in 90 | 91 | [wv-linewise.ts:286](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L286) 92 | 93 | ___ 94 | 95 | ### streamData 96 | 97 | • `Private` **streamData**: `Map`<`string`, `string`[]\> 98 | 99 | #### Defined in 100 | 101 | [wv-linewise.ts:282](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L282) 102 | 103 | ## Methods 104 | 105 | ### addParam 106 | 107 | ▸ **addParam**(`name`, `value`): `void` 108 | 109 | #### Parameters 110 | 111 | | Name | Type | 112 | | :------ | :------ | 113 | | `name` | `string` | 114 | | `value` | `string` | 115 | 116 | #### Returns 117 | 118 | `void` 119 | 120 | #### Defined in 121 | 122 | [wv-linewise.ts:299](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L299) 123 | 124 | ___ 125 | 126 | ### addStreamData 127 | 128 | ▸ **addStreamData**(`streamName`, `data`): `void` 129 | 130 | #### Parameters 131 | 132 | | Name | Type | 133 | | :------ | :------ | 134 | | `streamName` | `string` | 135 | | `data` | `string`[] | 136 | 137 | #### Returns 138 | 139 | `void` 140 | 141 | #### Defined in 142 | 143 | [wv-linewise.ts:292](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L292) 144 | 145 | ___ 146 | 147 | ### clear 148 | 149 | ▸ **clear**<`T`\>(`type`): `void` 150 | 151 | #### Type parameters 152 | 153 | | Name | Type | 154 | | :------ | :------ | 155 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 156 | 157 | #### Parameters 158 | 159 | | Name | Type | 160 | | :------ | :------ | 161 | | `type` | `T`[``"type"``] | 162 | 163 | #### Returns 164 | 165 | `void` 166 | 167 | #### Inherited from 168 | 169 | [RawWvLinewise](wv_linewise.RawWvLinewise.md).[clear](wv_linewise.RawWvLinewise.md#clear) 170 | 171 | #### Defined in 172 | 173 | [wv-linewise.ts:258](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L258) 174 | 175 | ___ 176 | 177 | ### fire 178 | 179 | ▸ `Protected` **fire**(`d`): `void` 180 | 181 | #### Parameters 182 | 183 | | Name | Type | 184 | | :------ | :------ | 185 | | `d` | [`Response`](../modules/wv_linewise.md#response) | 186 | 187 | #### Returns 188 | 189 | `void` 190 | 191 | #### Inherited from 192 | 193 | [RawWvLinewise](wv_linewise.RawWvLinewise.md).[fire](wv_linewise.RawWvLinewise.md#fire) 194 | 195 | #### Defined in 196 | 197 | [wv-linewise.ts:236](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L236) 198 | 199 | ___ 200 | 201 | ### off 202 | 203 | ▸ **off**<`T`\>(`type`, `f`): `void` 204 | 205 | #### Type parameters 206 | 207 | | Name | Type | 208 | | :------ | :------ | 209 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 210 | 211 | #### Parameters 212 | 213 | | Name | Type | 214 | | :------ | :------ | 215 | | `type` | `T`[``"type"``] | 216 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 217 | 218 | #### Returns 219 | 220 | `void` 221 | 222 | #### Inherited from 223 | 224 | [RawWvLinewise](wv_linewise.RawWvLinewise.md).[off](wv_linewise.RawWvLinewise.md#off) 225 | 226 | #### Defined in 227 | 228 | [wv-linewise.ts:263](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L263) 229 | 230 | ___ 231 | 232 | ### on 233 | 234 | ▸ **on**<`T`\>(`type`, `f`): `void` 235 | 236 | #### Type parameters 237 | 238 | | Name | Type | 239 | | :------ | :------ | 240 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 241 | 242 | #### Parameters 243 | 244 | | Name | Type | 245 | | :------ | :------ | 246 | | `type` | `T`[``"type"``] | 247 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 248 | 249 | #### Returns 250 | 251 | `void` 252 | 253 | #### Inherited from 254 | 255 | [RawWvLinewise](wv_linewise.RawWvLinewise.md).[on](wv_linewise.RawWvLinewise.md#on) 256 | 257 | #### Defined in 258 | 259 | [wv-linewise.ts:250](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L250) 260 | 261 | ___ 262 | 263 | ### once 264 | 265 | ▸ **once**<`T`\>(`type`, `f`): `void` 266 | 267 | #### Type parameters 268 | 269 | | Name | Type | 270 | | :------ | :------ | 271 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 272 | 273 | #### Parameters 274 | 275 | | Name | Type | 276 | | :------ | :------ | 277 | | `type` | `T`[``"type"``] | 278 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 279 | 280 | #### Returns 281 | 282 | `void` 283 | 284 | #### Inherited from 285 | 286 | [RawWvLinewise](wv_linewise.RawWvLinewise.md).[once](wv_linewise.RawWvLinewise.md#once) 287 | 288 | #### Defined in 289 | 290 | [wv-linewise.ts:254](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L254) 291 | 292 | ___ 293 | 294 | ### request 295 | 296 | ▸ **request**(`j`): `Promise`<`void`\> 297 | 298 | #### Parameters 299 | 300 | | Name | Type | 301 | | :------ | :------ | 302 | | `j` | [`Request`](../modules/wv_linewise.md#request) | 303 | 304 | #### Returns 305 | 306 | `Promise`<`void`\> 307 | 308 | #### Overrides 309 | 310 | [RawWvLinewise](wv_linewise.RawWvLinewise.md).[request](wv_linewise.RawWvLinewise.md#request) 311 | 312 | #### Defined in 313 | 314 | [wv-linewise.ts:324](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L324) 315 | 316 | ___ 317 | 318 | ### start 319 | 320 | ▸ **start**(`name`, `count`): `void` 321 | 322 | #### Parameters 323 | 324 | | Name | Type | 325 | | :------ | :------ | 326 | | `name` | `string` | 327 | | `count` | `number` | 328 | 329 | #### Returns 330 | 331 | `void` 332 | 333 | #### Defined in 334 | 335 | [wv-linewise.ts:303](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L303) 336 | -------------------------------------------------------------------------------- /js-lib/docs/classes/wv_linewise.WvLinewise.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / WvLinewise 2 | 3 | # Class: WvLinewise 4 | 5 | [wv-linewise](../modules/wv_linewise.md).WvLinewise 6 | 7 | ## Table of contents 8 | 9 | ### Constructors 10 | 11 | - [constructor](wv_linewise.WvLinewise.md#constructor) 12 | 13 | ### Properties 14 | 15 | - [raw](wv_linewise.WvLinewise.md#raw) 16 | 17 | ### Methods 18 | 19 | - [clear](wv_linewise.WvLinewise.md#clear) 20 | - [exit](wv_linewise.WvLinewise.md#exit) 21 | - [off](wv_linewise.WvLinewise.md#off) 22 | - [on](wv_linewise.WvLinewise.md#on) 23 | - [once](wv_linewise.WvLinewise.md#once) 24 | - [out](wv_linewise.WvLinewise.md#out) 25 | - [requestParams](wv_linewise.WvLinewise.md#requestparams) 26 | - [requestStreamList](wv_linewise.WvLinewise.md#requeststreamlist) 27 | - [streamContinue](wv_linewise.WvLinewise.md#streamcontinue) 28 | - [streamStart](wv_linewise.WvLinewise.md#streamstart) 29 | 30 | ## Constructors 31 | 32 | ### constructor 33 | 34 | • **new WvLinewise**(`raw`) 35 | 36 | #### Parameters 37 | 38 | | Name | Type | 39 | | :------ | :------ | 40 | | `raw` | [`RawWvLinewise`](wv_linewise.RawWvLinewise.md) | 41 | 42 | #### Defined in 43 | 44 | [wv-linewise.ts:369](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L369) 45 | 46 | ## Properties 47 | 48 | ### raw 49 | 50 | • **raw**: [`RawWvLinewise`](wv_linewise.RawWvLinewise.md) 51 | 52 | ## Methods 53 | 54 | ### clear 55 | 56 | ▸ **clear**<`T`\>(`type`): `void` 57 | 58 | #### Type parameters 59 | 60 | | Name | Type | 61 | | :------ | :------ | 62 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 63 | 64 | #### Parameters 65 | 66 | | Name | Type | 67 | | :------ | :------ | 68 | | `type` | `T`[``"type"``] | 69 | 70 | #### Returns 71 | 72 | `void` 73 | 74 | #### Defined in 75 | 76 | [wv-linewise.ts:404](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L404) 77 | 78 | ___ 79 | 80 | ### exit 81 | 82 | ▸ **exit**(`status`): `void` 83 | 84 | #### Parameters 85 | 86 | | Name | Type | 87 | | :------ | :------ | 88 | | `status` | `number` | 89 | 90 | #### Returns 91 | 92 | `void` 93 | 94 | #### Defined in 95 | 96 | [wv-linewise.ts:384](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L384) 97 | 98 | ___ 99 | 100 | ### off 101 | 102 | ▸ **off**<`T`\>(`type`, `f`): `void` 103 | 104 | #### Type parameters 105 | 106 | | Name | Type | 107 | | :------ | :------ | 108 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 109 | 110 | #### Parameters 111 | 112 | | Name | Type | 113 | | :------ | :------ | 114 | | `type` | `T`[``"type"``] | 115 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 116 | 117 | #### Returns 118 | 119 | `void` 120 | 121 | #### Defined in 122 | 123 | [wv-linewise.ts:408](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L408) 124 | 125 | ___ 126 | 127 | ### on 128 | 129 | ▸ **on**<`T`\>(`type`, `f`): `void` 130 | 131 | #### Type parameters 132 | 133 | | Name | Type | 134 | | :------ | :------ | 135 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 136 | 137 | #### Parameters 138 | 139 | | Name | Type | 140 | | :------ | :------ | 141 | | `type` | `T`[``"type"``] | 142 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 143 | 144 | #### Returns 145 | 146 | `void` 147 | 148 | #### Defined in 149 | 150 | [wv-linewise.ts:396](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L396) 151 | 152 | ___ 153 | 154 | ### once 155 | 156 | ▸ **once**<`T`\>(`type`, `f`): `void` 157 | 158 | #### Type parameters 159 | 160 | | Name | Type | 161 | | :------ | :------ | 162 | | `T` | extends [`Response`](../modules/wv_linewise.md#response) | 163 | 164 | #### Parameters 165 | 166 | | Name | Type | 167 | | :------ | :------ | 168 | | `type` | `T`[``"type"``] | 169 | | `f` | [`ResponseDispatcher`](../interfaces/wv_linewise.ResponseDispatcher.md)<`T`\> | 170 | 171 | #### Returns 172 | 173 | `void` 174 | 175 | #### Defined in 176 | 177 | [wv-linewise.ts:400](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L400) 178 | 179 | ___ 180 | 181 | ### out 182 | 183 | ▸ **out**(`text`, `descriptor?`): `void` 184 | 185 | #### Parameters 186 | 187 | | Name | Type | Default value | 188 | | :------ | :------ | :------ | 189 | | `text` | `string` | `undefined` | 190 | | `descriptor` | [`OUT_REQUEST_DESCRIPTOR`](../enums/wv_linewise.OUT_REQUEST_DESCRIPTOR.md) | `OUT_REQUEST_DESCRIPTOR.STDOUT` | 191 | 192 | #### Returns 193 | 194 | `void` 195 | 196 | #### Defined in 197 | 198 | [wv-linewise.ts:392](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L392) 199 | 200 | ___ 201 | 202 | ### requestParams 203 | 204 | ▸ **requestParams**(): `void` 205 | 206 | #### Returns 207 | 208 | `void` 209 | 210 | #### Defined in 211 | 212 | [wv-linewise.ts:380](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L380) 213 | 214 | ___ 215 | 216 | ### requestStreamList 217 | 218 | ▸ **requestStreamList**(): `void` 219 | 220 | #### Returns 221 | 222 | `void` 223 | 224 | #### Defined in 225 | 226 | [wv-linewise.ts:388](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L388) 227 | 228 | ___ 229 | 230 | ### streamContinue 231 | 232 | ▸ **streamContinue**(`streamName`): `void` 233 | 234 | #### Parameters 235 | 236 | | Name | Type | 237 | | :------ | :------ | 238 | | `streamName` | `string` | 239 | 240 | #### Returns 241 | 242 | `void` 243 | 244 | #### Defined in 245 | 246 | [wv-linewise.ts:376](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L376) 247 | 248 | ___ 249 | 250 | ### streamStart 251 | 252 | ▸ **streamStart**(`streamName`, `count`): `void` 253 | 254 | #### Parameters 255 | 256 | | Name | Type | 257 | | :------ | :------ | 258 | | `streamName` | `string` | 259 | | `count` | `number` | 260 | 261 | #### Returns 262 | 263 | `void` 264 | 265 | #### Defined in 266 | 267 | [wv-linewise.ts:372](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L372) 268 | -------------------------------------------------------------------------------- /js-lib/docs/classes/wv_linewise_buffer.WvLinewiseBuffer.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise-buffer](../modules/wv_linewise_buffer.md) / WvLinewiseBuffer 2 | 3 | # Class: WvLinewiseBuffer 4 | 5 | [wv-linewise-buffer](../modules/wv_linewise_buffer.md).WvLinewiseBuffer 6 | 7 | ## Table of contents 8 | 9 | ### Constructors 10 | 11 | - [constructor](wv_linewise_buffer.WvLinewiseBuffer.md#constructor) 12 | 13 | ### Properties 14 | 15 | - [buffer](wv_linewise_buffer.WvLinewiseBuffer.md#buffer) 16 | - [noSleep](wv_linewise_buffer.WvLinewiseBuffer.md#nosleep) 17 | - [state](wv_linewise_buffer.WvLinewiseBuffer.md#state) 18 | 19 | ### Methods 20 | 21 | - [notify](wv_linewise_buffer.WvLinewiseBuffer.md#notify) 22 | - [request](wv_linewise_buffer.WvLinewiseBuffer.md#request) 23 | - [shift](wv_linewise_buffer.WvLinewiseBuffer.md#shift) 24 | 25 | ## Constructors 26 | 27 | ### constructor 28 | 29 | • **new WvLinewiseBuffer**(`wvl`, `streamName`, `lowWaterMark`, `countToRequest`) 30 | 31 | #### Parameters 32 | 33 | | Name | Type | 34 | | :------ | :------ | 35 | | `wvl` | [`WvLinewise`](wv_linewise.WvLinewise.md) | 36 | | `streamName` | `string` | 37 | | `lowWaterMark` | `number` | 38 | | `countToRequest` | `number` | 39 | 40 | #### Defined in 41 | 42 | [wv-linewise-buffer.ts:35](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-buffer.ts#L35) 43 | 44 | ## Properties 45 | 46 | ### buffer 47 | 48 | • `Private` **buffer**: `string`[] = `[]` 49 | 50 | #### Defined in 51 | 52 | [wv-linewise-buffer.ts:31](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-buffer.ts#L31) 53 | 54 | ___ 55 | 56 | ### noSleep 57 | 58 | • `Protected` **noSleep**: `boolean` = `false` 59 | 60 | #### Defined in 61 | 62 | [wv-linewise-buffer.ts:33](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-buffer.ts#L33) 63 | 64 | ___ 65 | 66 | ### state 67 | 68 | • `Private` **state**: `WvLinewiseBufferState` = `WvLinewiseBufferState.NotStarted` 69 | 70 | #### Defined in 71 | 72 | [wv-linewise-buffer.ts:32](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-buffer.ts#L32) 73 | 74 | ## Methods 75 | 76 | ### notify 77 | 78 | ▸ **notify**(): `Promise`<`unknown`\> 79 | 80 | #### Returns 81 | 82 | `Promise`<`unknown`\> 83 | 84 | #### Defined in 85 | 86 | [wv-linewise-buffer.ts:53](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-buffer.ts#L53) 87 | 88 | ___ 89 | 90 | ### request 91 | 92 | ▸ **request**(): `void` 93 | 94 | #### Returns 95 | 96 | `void` 97 | 98 | #### Defined in 99 | 100 | [wv-linewise-buffer.ts:87](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-buffer.ts#L87) 101 | 102 | ___ 103 | 104 | ### shift 105 | 106 | ▸ **shift**(): `Promise`<``null`` \| `string`\> 107 | 108 | #### Returns 109 | 110 | `Promise`<``null`` \| `string`\> 111 | 112 | #### Defined in 113 | 114 | [wv-linewise-buffer.ts:103](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-buffer.ts#L103) 115 | -------------------------------------------------------------------------------- /js-lib/docs/classes/wv_linewise_fetch.WvLinewiseResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise-fetch](../modules/wv_linewise_fetch.md) / WvLinewiseResponse 2 | 3 | # Class: WvLinewiseResponse 4 | 5 | [wv-linewise-fetch](../modules/wv_linewise_fetch.md).WvLinewiseResponse 6 | 7 | ## Implements 8 | 9 | - `Response` 10 | 11 | ## Table of contents 12 | 13 | ### Constructors 14 | 15 | - [constructor](wv_linewise_fetch.WvLinewiseResponse.md#constructor) 16 | 17 | ### Properties 18 | 19 | - [body](wv_linewise_fetch.WvLinewiseResponse.md#body) 20 | - [bodyUsed](wv_linewise_fetch.WvLinewiseResponse.md#bodyused) 21 | - [headers](wv_linewise_fetch.WvLinewiseResponse.md#headers) 22 | - [ok](wv_linewise_fetch.WvLinewiseResponse.md#ok) 23 | - [redirected](wv_linewise_fetch.WvLinewiseResponse.md#redirected) 24 | - [status](wv_linewise_fetch.WvLinewiseResponse.md#status) 25 | - [statusText](wv_linewise_fetch.WvLinewiseResponse.md#statustext) 26 | - [trailer](wv_linewise_fetch.WvLinewiseResponse.md#trailer) 27 | - [type](wv_linewise_fetch.WvLinewiseResponse.md#type) 28 | - [url](wv_linewise_fetch.WvLinewiseResponse.md#url) 29 | 30 | ### Methods 31 | 32 | - [arrayBuffer](wv_linewise_fetch.WvLinewiseResponse.md#arraybuffer) 33 | - [blob](wv_linewise_fetch.WvLinewiseResponse.md#blob) 34 | - [clone](wv_linewise_fetch.WvLinewiseResponse.md#clone) 35 | - [formData](wv_linewise_fetch.WvLinewiseResponse.md#formdata) 36 | - [getStatusText](wv_linewise_fetch.WvLinewiseResponse.md#getstatustext) 37 | - [json](wv_linewise_fetch.WvLinewiseResponse.md#json) 38 | - [text](wv_linewise_fetch.WvLinewiseResponse.md#text) 39 | 40 | ## Constructors 41 | 42 | ### constructor 43 | 44 | • **new WvLinewiseResponse**(`url`, `resp_text`, `status`, `headers`) 45 | 46 | #### Parameters 47 | 48 | | Name | Type | 49 | | :------ | :------ | 50 | | `url` | `string` | 51 | | `resp_text` | `string` | 52 | | `status` | `number` | 53 | | `headers` | `Object` | 54 | 55 | #### Defined in 56 | 57 | [wv-linewise-fetch.ts:53](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L53) 58 | 59 | ## Properties 60 | 61 | ### body 62 | 63 | • `Readonly` **body**: ``null`` \| `ReadableStream`<`Uint8Array`\> = `null` 64 | 65 | #### Implementation of 66 | 67 | Response.body 68 | 69 | #### Defined in 70 | 71 | [wv-linewise-fetch.ts:47](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L47) 72 | 73 | ___ 74 | 75 | ### bodyUsed 76 | 77 | • `Readonly` **bodyUsed**: `boolean` = `true` 78 | 79 | #### Implementation of 80 | 81 | Response.bodyUsed 82 | 83 | #### Defined in 84 | 85 | [wv-linewise-fetch.ts:48](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L48) 86 | 87 | ___ 88 | 89 | ### headers 90 | 91 | • **headers**: `Headers` 92 | 93 | #### Implementation of 94 | 95 | Response.headers 96 | 97 | #### Defined in 98 | 99 | [wv-linewise-fetch.ts:41](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L41) 100 | 101 | ___ 102 | 103 | ### ok 104 | 105 | • `Readonly` **ok**: `boolean` 106 | 107 | #### Implementation of 108 | 109 | Response.ok 110 | 111 | #### Defined in 112 | 113 | [wv-linewise-fetch.ts:40](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L40) 114 | 115 | ___ 116 | 117 | ### redirected 118 | 119 | • `Readonly` **redirected**: ``false`` 120 | 121 | #### Implementation of 122 | 123 | Response.redirected 124 | 125 | #### Defined in 126 | 127 | [wv-linewise-fetch.ts:42](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L42) 128 | 129 | ___ 130 | 131 | ### status 132 | 133 | • `Readonly` **status**: `number` 134 | 135 | #### Implementation of 136 | 137 | Response.status 138 | 139 | ___ 140 | 141 | ### statusText 142 | 143 | • `Readonly` **statusText**: `string` 144 | 145 | #### Implementation of 146 | 147 | Response.statusText 148 | 149 | #### Defined in 150 | 151 | [wv-linewise-fetch.ts:43](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L43) 152 | 153 | ___ 154 | 155 | ### trailer 156 | 157 | • `Readonly` **trailer**: `Promise`<`Headers`\> 158 | 159 | #### Defined in 160 | 161 | [wv-linewise-fetch.ts:44](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L44) 162 | 163 | ___ 164 | 165 | ### type 166 | 167 | • `Readonly` **type**: `ResponseType` = `"basic"` 168 | 169 | #### Implementation of 170 | 171 | Response.type 172 | 173 | #### Defined in 174 | 175 | [wv-linewise-fetch.ts:45](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L45) 176 | 177 | ___ 178 | 179 | ### url 180 | 181 | • `Readonly` **url**: `string` 182 | 183 | #### Implementation of 184 | 185 | Response.url 186 | 187 | ## Methods 188 | 189 | ### arrayBuffer 190 | 191 | ▸ **arrayBuffer**(): `Promise`<`ArrayBuffer`\> 192 | 193 | #### Returns 194 | 195 | `Promise`<`ArrayBuffer`\> 196 | 197 | #### Implementation of 198 | 199 | Response.arrayBuffer 200 | 201 | #### Defined in 202 | 203 | [wv-linewise-fetch.ts:49](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L49) 204 | 205 | ___ 206 | 207 | ### blob 208 | 209 | ▸ **blob**(): `Promise`<`Blob`\> 210 | 211 | #### Returns 212 | 213 | `Promise`<`Blob`\> 214 | 215 | #### Implementation of 216 | 217 | Response.blob 218 | 219 | #### Defined in 220 | 221 | [wv-linewise-fetch.ts:50](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L50) 222 | 223 | ___ 224 | 225 | ### clone 226 | 227 | ▸ **clone**(): `Response` 228 | 229 | #### Returns 230 | 231 | `Response` 232 | 233 | #### Implementation of 234 | 235 | Response.clone 236 | 237 | #### Defined in 238 | 239 | [wv-linewise-fetch.ts:59](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L59) 240 | 241 | ___ 242 | 243 | ### formData 244 | 245 | ▸ **formData**(): `Promise`<`FormData`\> 246 | 247 | #### Returns 248 | 249 | `Promise`<`FormData`\> 250 | 251 | #### Implementation of 252 | 253 | Response.formData 254 | 255 | #### Defined in 256 | 257 | [wv-linewise-fetch.ts:51](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L51) 258 | 259 | ___ 260 | 261 | ### getStatusText 262 | 263 | ▸ `Private` **getStatusText**(`n`): `string` 264 | 265 | #### Parameters 266 | 267 | | Name | Type | 268 | | :------ | :------ | 269 | | `n` | `number` | 270 | 271 | #### Returns 272 | 273 | `string` 274 | 275 | #### Defined in 276 | 277 | [wv-linewise-fetch.ts:76](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L76) 278 | 279 | ___ 280 | 281 | ### json 282 | 283 | ▸ **json**(): `Promise`<`any`\> 284 | 285 | #### Returns 286 | 287 | `Promise`<`any`\> 288 | 289 | #### Implementation of 290 | 291 | Response.json 292 | 293 | #### Defined in 294 | 295 | [wv-linewise-fetch.ts:72](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L72) 296 | 297 | ___ 298 | 299 | ### text 300 | 301 | ▸ **text**(): `Promise`<`string`\> 302 | 303 | #### Returns 304 | 305 | `Promise`<`string`\> 306 | 307 | #### Implementation of 308 | 309 | Response.text 310 | 311 | #### Defined in 312 | 313 | [wv-linewise-fetch.ts:74](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L74) 314 | -------------------------------------------------------------------------------- /js-lib/docs/enums/wv_linewise.OUT_REQUEST_DESCRIPTOR.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / OUT\_REQUEST\_DESCRIPTOR 2 | 3 | # Enumeration: OUT\_REQUEST\_DESCRIPTOR 4 | 5 | [wv-linewise](../modules/wv_linewise.md).OUT_REQUEST_DESCRIPTOR 6 | 7 | Used by [OutRequest](../interfaces/wv_linewise.OutRequest.md) to control which UNIX stream to write to. 8 | 9 | ## Table of contents 10 | 11 | ### Enumeration members 12 | 13 | - [DESCRIPTOR\_3](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#descriptor_3) 14 | - [DESCRIPTOR\_4](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#descriptor_4) 15 | - [DESCRIPTOR\_5](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#descriptor_5) 16 | - [DESCRIPTOR\_6](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#descriptor_6) 17 | - [DESCRIPTOR\_7](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#descriptor_7) 18 | - [DESCRIPTOR\_8](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#descriptor_8) 19 | - [DESCRIPTOR\_9](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#descriptor_9) 20 | - [STDERR](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#stderr) 21 | - [STDOUT](wv_linewise.OUT_REQUEST_DESCRIPTOR.md#stdout) 22 | 23 | ## Enumeration members 24 | 25 | ### DESCRIPTOR\_3 26 | 27 | • **DESCRIPTOR\_3** = `3` 28 | 29 | #### Defined in 30 | 31 | [wv-linewise.ts:69](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L69) 32 | 33 | ___ 34 | 35 | ### DESCRIPTOR\_4 36 | 37 | • **DESCRIPTOR\_4** = `4` 38 | 39 | #### Defined in 40 | 41 | [wv-linewise.ts:70](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L70) 42 | 43 | ___ 44 | 45 | ### DESCRIPTOR\_5 46 | 47 | • **DESCRIPTOR\_5** = `5` 48 | 49 | #### Defined in 50 | 51 | [wv-linewise.ts:71](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L71) 52 | 53 | ___ 54 | 55 | ### DESCRIPTOR\_6 56 | 57 | • **DESCRIPTOR\_6** = `6` 58 | 59 | #### Defined in 60 | 61 | [wv-linewise.ts:72](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L72) 62 | 63 | ___ 64 | 65 | ### DESCRIPTOR\_7 66 | 67 | • **DESCRIPTOR\_7** = `7` 68 | 69 | #### Defined in 70 | 71 | [wv-linewise.ts:73](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L73) 72 | 73 | ___ 74 | 75 | ### DESCRIPTOR\_8 76 | 77 | • **DESCRIPTOR\_8** = `8` 78 | 79 | #### Defined in 80 | 81 | [wv-linewise.ts:74](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L74) 82 | 83 | ___ 84 | 85 | ### DESCRIPTOR\_9 86 | 87 | • **DESCRIPTOR\_9** = `9` 88 | 89 | #### Defined in 90 | 91 | [wv-linewise.ts:75](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L75) 92 | 93 | ___ 94 | 95 | ### STDERR 96 | 97 | • **STDERR** = `2` 98 | 99 | #### Defined in 100 | 101 | [wv-linewise.ts:68](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L68) 102 | 103 | ___ 104 | 105 | ### STDOUT 106 | 107 | • **STDOUT** = `1` 108 | 109 | #### Defined in 110 | 111 | [wv-linewise.ts:67](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L67) 112 | -------------------------------------------------------------------------------- /js-lib/docs/enums/wv_linewise.REQUEST_TYPE.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / REQUEST\_TYPE 2 | 3 | # Enumeration: REQUEST\_TYPE 4 | 5 | [wv-linewise](../modules/wv_linewise.md).REQUEST_TYPE 6 | 7 | Every [Request](../modules/wv_linewise.md#request) includes a `msg` which will from this enum. 8 | 9 | ## Table of contents 10 | 11 | ### Enumeration members 12 | 13 | - [EXIT](wv_linewise.REQUEST_TYPE.md#exit) 14 | - [OUT](wv_linewise.REQUEST_TYPE.md#out) 15 | - [PARAMS](wv_linewise.REQUEST_TYPE.md#params) 16 | - [STREAM\_CONTINUE](wv_linewise.REQUEST_TYPE.md#stream_continue) 17 | - [STREAM\_LIST](wv_linewise.REQUEST_TYPE.md#stream_list) 18 | - [STREAM\_START](wv_linewise.REQUEST_TYPE.md#stream_start) 19 | 20 | ## Enumeration members 21 | 22 | ### EXIT 23 | 24 | • **EXIT** = `"exit"` 25 | 26 | #### Defined in 27 | 28 | [wv-linewise.ts:11](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L11) 29 | 30 | ___ 31 | 32 | ### OUT 33 | 34 | • **OUT** = `"out"` 35 | 36 | #### Defined in 37 | 38 | [wv-linewise.ts:16](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L16) 39 | 40 | ___ 41 | 42 | ### PARAMS 43 | 44 | • **PARAMS** = `"params"` 45 | 46 | #### Defined in 47 | 48 | [wv-linewise.ts:15](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L15) 49 | 50 | ___ 51 | 52 | ### STREAM\_CONTINUE 53 | 54 | • **STREAM\_CONTINUE** = `"streamContinue"` 55 | 56 | #### Defined in 57 | 58 | [wv-linewise.ts:14](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L14) 59 | 60 | ___ 61 | 62 | ### STREAM\_LIST 63 | 64 | • **STREAM\_LIST** = `"streamList"` 65 | 66 | #### Defined in 67 | 68 | [wv-linewise.ts:12](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L12) 69 | 70 | ___ 71 | 72 | ### STREAM\_START 73 | 74 | • **STREAM\_START** = `"streamStart"` 75 | 76 | #### Defined in 77 | 78 | [wv-linewise.ts:13](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L13) 79 | -------------------------------------------------------------------------------- /js-lib/docs/enums/wv_linewise.RESPONSE_TYPE.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / RESPONSE\_TYPE 2 | 3 | # Enumeration: RESPONSE\_TYPE 4 | 5 | [wv-linewise](../modules/wv_linewise.md).RESPONSE_TYPE 6 | 7 | Every [Response](../modules/wv_linewise.md#response) includes a `type` which will from this enum. 8 | 9 | ## Table of contents 10 | 11 | ### Enumeration members 12 | 13 | - [DETAILS](wv_linewise.RESPONSE_TYPE.md#details) 14 | - [ERROR](wv_linewise.RESPONSE_TYPE.md#error) 15 | - [FINISHED](wv_linewise.RESPONSE_TYPE.md#finished) 16 | - [LINE](wv_linewise.RESPONSE_TYPE.md#line) 17 | - [MESSAGE\_ERROR](wv_linewise.RESPONSE_TYPE.md#message_error) 18 | - [PARAMS](wv_linewise.RESPONSE_TYPE.md#params) 19 | - [PAUSED](wv_linewise.RESPONSE_TYPE.md#paused) 20 | - [STREAM\_LIST](wv_linewise.RESPONSE_TYPE.md#stream_list) 21 | 22 | ## Enumeration members 23 | 24 | ### DETAILS 25 | 26 | • **DETAILS** = `"details"` 27 | 28 | #### Defined in 29 | 30 | [wv-linewise.ts:101](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L101) 31 | 32 | ___ 33 | 34 | ### ERROR 35 | 36 | • **ERROR** = `"error"` 37 | 38 | #### Defined in 39 | 40 | [wv-linewise.ts:104](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L104) 41 | 42 | ___ 43 | 44 | ### FINISHED 45 | 46 | • **FINISHED** = `"finished"` 47 | 48 | #### Defined in 49 | 50 | [wv-linewise.ts:102](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L102) 51 | 52 | ___ 53 | 54 | ### LINE 55 | 56 | • **LINE** = `"line"` 57 | 58 | #### Defined in 59 | 60 | [wv-linewise.ts:99](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L99) 61 | 62 | ___ 63 | 64 | ### MESSAGE\_ERROR 65 | 66 | • **MESSAGE\_ERROR** = `"messageError"` 67 | 68 | #### Defined in 69 | 70 | [wv-linewise.ts:105](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L105) 71 | 72 | ___ 73 | 74 | ### PARAMS 75 | 76 | • **PARAMS** = `"params"` 77 | 78 | #### Defined in 79 | 80 | [wv-linewise.ts:98](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L98) 81 | 82 | ___ 83 | 84 | ### PAUSED 85 | 86 | • **PAUSED** = `"paused"` 87 | 88 | #### Defined in 89 | 90 | [wv-linewise.ts:103](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L103) 91 | 92 | ___ 93 | 94 | ### STREAM\_LIST 95 | 96 | • **STREAM\_LIST** = `"streamList"` 97 | 98 | #### Defined in 99 | 100 | [wv-linewise.ts:100](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L100) 101 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.DetailsResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / DetailsResponse 2 | 3 | # Interface: DetailsResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).DetailsResponse 6 | 7 | Once a [StreamStartRequest](wv_linewise.StreamStartRequest.md) has been received, we will respond with 8 | the details about that stream before sending [LineResponse](wv_linewise.LineResponse.md)s. 9 | 10 | In future streams from files will likely be rewindable, but currently 11 | [rewindable](wv_linewise.DetailsResponse.md#rewindable) is always false. 12 | 13 | ## Table of contents 14 | 15 | ### Properties 16 | 17 | - [name](wv_linewise.DetailsResponse.md#name) 18 | - [rewindable](wv_linewise.DetailsResponse.md#rewindable) 19 | - [type](wv_linewise.DetailsResponse.md#type) 20 | 21 | ## Properties 22 | 23 | ### name 24 | 25 | • **name**: `string` 26 | 27 | #### Defined in 28 | 29 | [wv-linewise.ts:161](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L161) 30 | 31 | ___ 32 | 33 | ### rewindable 34 | 35 | • **rewindable**: `boolean` 36 | 37 | #### Defined in 38 | 39 | [wv-linewise.ts:162](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L162) 40 | 41 | ___ 42 | 43 | ### type 44 | 45 | • **type**: [`DETAILS`](../enums/wv_linewise.RESPONSE_TYPE.md#details) 46 | 47 | #### Defined in 48 | 49 | [wv-linewise.ts:160](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L160) 50 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.ErrorResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / ErrorResponse 2 | 3 | # Interface: ErrorResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).ErrorResponse 6 | 7 | This [Response](../modules/wv_linewise.md#response) is sent in response to errors which can be pinned down 8 | to a specific stream, or a request to a non-existing stream. 9 | 10 | ## Table of contents 11 | 12 | ### Properties 13 | 14 | - [error](wv_linewise.ErrorResponse.md#error) 15 | - [name](wv_linewise.ErrorResponse.md#name) 16 | - [type](wv_linewise.ErrorResponse.md#type) 17 | 18 | ## Properties 19 | 20 | ### error 21 | 22 | • **error**: `string` 23 | 24 | #### Defined in 25 | 26 | [wv-linewise.ts:190](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L190) 27 | 28 | ___ 29 | 30 | ### name 31 | 32 | • **name**: `string` 33 | 34 | #### Defined in 35 | 36 | [wv-linewise.ts:191](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L191) 37 | 38 | ___ 39 | 40 | ### type 41 | 42 | • **type**: [`ERROR`](../enums/wv_linewise.RESPONSE_TYPE.md#error) 43 | 44 | #### Defined in 45 | 46 | [wv-linewise.ts:189](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L189) 47 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.ExitRequest.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / ExitRequest 2 | 3 | # Interface: ExitRequest 4 | 5 | [wv-linewise](../modules/wv_linewise.md).ExitRequest 6 | 7 | [Request](../modules/wv_linewise.md#request) that the program exits (and the web view is closed). 8 | 9 | ## Table of contents 10 | 11 | ### Properties 12 | 13 | - [msg](wv_linewise.ExitRequest.md#msg) 14 | - [status](wv_linewise.ExitRequest.md#status) 15 | 16 | ## Properties 17 | 18 | ### msg 19 | 20 | • **msg**: [`EXIT`](../enums/wv_linewise.REQUEST_TYPE.md#exit) 21 | 22 | #### Defined in 23 | 24 | [wv-linewise.ts:34](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L34) 25 | 26 | ___ 27 | 28 | ### status 29 | 30 | • **status**: `number` 31 | 32 | This is the exit status returned to the software which started the webview, 0 is success 33 | 34 | #### Defined in 35 | 36 | [wv-linewise.ts:36](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L36) 37 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.FinishedResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / FinishedResponse 2 | 3 | # Interface: FinishedResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).FinishedResponse 6 | 7 | The stream of data started via a [StreamStartRequest](wv_linewise.StreamStartRequest.md) may be infinate, 8 | but it may also have an end. This marks the end. 9 | 10 | ## Table of contents 11 | 12 | ### Properties 13 | 14 | - [name](wv_linewise.FinishedResponse.md#name) 15 | - [type](wv_linewise.FinishedResponse.md#type) 16 | 17 | ## Properties 18 | 19 | ### name 20 | 21 | • **name**: `string` 22 | 23 | #### Defined in 24 | 25 | [wv-linewise.ts:149](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L149) 26 | 27 | ___ 28 | 29 | ### type 30 | 31 | • **type**: [`FINISHED`](../enums/wv_linewise.RESPONSE_TYPE.md#finished) 32 | 33 | #### Defined in 34 | 35 | [wv-linewise.ts:148](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L148) 36 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.LineResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / LineResponse 2 | 3 | # Interface: LineResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).LineResponse 6 | 7 | Once a [StreamStartRequest](wv_linewise.StreamStartRequest.md) has been received this message will contain 8 | the actual data from the file or STDIN. 9 | 10 | ## Table of contents 11 | 12 | ### Properties 13 | 14 | - [data](wv_linewise.LineResponse.md#data) 15 | - [name](wv_linewise.LineResponse.md#name) 16 | - [type](wv_linewise.LineResponse.md#type) 17 | 18 | ## Properties 19 | 20 | ### data 21 | 22 | • **data**: `string` 23 | 24 | #### Defined in 25 | 26 | [wv-linewise.ts:172](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L172) 27 | 28 | ___ 29 | 30 | ### name 31 | 32 | • **name**: `string` 33 | 34 | #### Defined in 35 | 36 | [wv-linewise.ts:171](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L171) 37 | 38 | ___ 39 | 40 | ### type 41 | 42 | • **type**: [`LINE`](../enums/wv_linewise.RESPONSE_TYPE.md#line) 43 | 44 | #### Defined in 45 | 46 | [wv-linewise.ts:170](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L170) 47 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.MessageErrorResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / MessageErrorResponse 2 | 3 | # Interface: MessageErrorResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).MessageErrorResponse 6 | 7 | This [Response](../modules/wv_linewise.md#response) is sent after a [Request](../modules/wv_linewise.md#request) is received that is 8 | invalid. 9 | 10 | ## Table of contents 11 | 12 | ### Properties 13 | 14 | - [error](wv_linewise.MessageErrorResponse.md#error) 15 | - [type](wv_linewise.MessageErrorResponse.md#type) 16 | 17 | ## Properties 18 | 19 | ### error 20 | 21 | • **error**: `string` 22 | 23 | #### Defined in 24 | 25 | [wv-linewise.ts:181](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L181) 26 | 27 | ___ 28 | 29 | ### type 30 | 31 | • **type**: [`MESSAGE_ERROR`](../enums/wv_linewise.RESPONSE_TYPE.md#message_error) 32 | 33 | #### Defined in 34 | 35 | [wv-linewise.ts:180](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L180) 36 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.OutRequest.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / OutRequest 2 | 3 | # Interface: OutRequest 4 | 5 | [wv-linewise](../modules/wv_linewise.md).OutRequest 6 | 7 | [Request](../modules/wv_linewise.md#request) that wv-linewise send [OutRequest.data](wv_linewise.OutRequest.md#data) to 8 | [OutRequest.descriptor](wv_linewise.OutRequest.md#descriptor) so it can be picked up by other programs 9 | further down the pipeline. 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [data](wv_linewise.OutRequest.md#data) 16 | - [descriptor](wv_linewise.OutRequest.md#descriptor) 17 | - [msg](wv_linewise.OutRequest.md#msg) 18 | 19 | ## Properties 20 | 21 | ### data 22 | 23 | • **data**: `string` 24 | 25 | #### Defined in 26 | 27 | [wv-linewise.ts:86](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L86) 28 | 29 | ___ 30 | 31 | ### descriptor 32 | 33 | • **descriptor**: [`OUT_REQUEST_DESCRIPTOR`](../enums/wv_linewise.OUT_REQUEST_DESCRIPTOR.md) 34 | 35 | #### Defined in 36 | 37 | [wv-linewise.ts:85](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L85) 38 | 39 | ___ 40 | 41 | ### msg 42 | 43 | • **msg**: [`OUT`](../enums/wv_linewise.REQUEST_TYPE.md#out) 44 | 45 | #### Defined in 46 | 47 | [wv-linewise.ts:84](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L84) 48 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.Param.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / Param 2 | 3 | # Interface: Param 4 | 5 | [wv-linewise](../modules/wv_linewise.md).Param 6 | 7 | This is a key/value pair which is embedded in a [ParamsResponse](wv_linewise.ParamsResponse.md). 8 | 9 | ## Table of contents 10 | 11 | ### Properties 12 | 13 | - [name](wv_linewise.Param.md#name) 14 | - [value](wv_linewise.Param.md#value) 15 | 16 | ## Properties 17 | 18 | ### name 19 | 20 | • **name**: `string` 21 | 22 | #### Defined in 23 | 24 | [wv-linewise.ts:112](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L112) 25 | 26 | ___ 27 | 28 | ### value 29 | 30 | • **value**: `string` 31 | 32 | #### Defined in 33 | 34 | [wv-linewise.ts:113](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L113) 35 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.ParamsRequest.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / ParamsRequest 2 | 3 | # Interface: ParamsRequest 4 | 5 | [wv-linewise](../modules/wv_linewise.md).ParamsRequest 6 | 7 | [Request](../modules/wv_linewise.md#request) the command line parameters passed in when starting the wv-linewise 8 | 9 | ## Table of contents 10 | 11 | ### Properties 12 | 13 | - [msg](wv_linewise.ParamsRequest.md#msg) 14 | 15 | ## Properties 16 | 17 | ### msg 18 | 19 | • **msg**: [`PARAMS`](../enums/wv_linewise.REQUEST_TYPE.md#params) 20 | 21 | #### Defined in 22 | 23 | [wv-linewise.ts:60](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L60) 24 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.ParamsResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / ParamsResponse 2 | 3 | # Interface: ParamsResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).ParamsResponse 6 | 7 | The parameters that were passed to WV Linewise, perhaps in BASH when it was started. 8 | 9 | ## Table of contents 10 | 11 | ### Properties 12 | 13 | - [params](wv_linewise.ParamsResponse.md#params) 14 | - [type](wv_linewise.ParamsResponse.md#type) 15 | 16 | ## Properties 17 | 18 | ### params 19 | 20 | • **params**: [`Param`](wv_linewise.Param.md)[] 21 | 22 | #### Defined in 23 | 24 | [wv-linewise.ts:121](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L121) 25 | 26 | ___ 27 | 28 | ### type 29 | 30 | • **type**: [`PARAMS`](../enums/wv_linewise.RESPONSE_TYPE.md#params) 31 | 32 | #### Defined in 33 | 34 | [wv-linewise.ts:120](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L120) 35 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.PausedResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / PausedResponse 2 | 3 | # Interface: PausedResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).PausedResponse 6 | 7 | After we have read [StreamStartRequest.count](wv_linewise.StreamStartRequest.md#count) lines we will 8 | [PausedResponse](wv_linewise.PausedResponse.md). 9 | 10 | To restart the stream use an [StreamContinueRequest](wv_linewise.StreamContinueRequest.md). 11 | 12 | ## Table of contents 13 | 14 | ### Properties 15 | 16 | - [name](wv_linewise.PausedResponse.md#name) 17 | - [type](wv_linewise.PausedResponse.md#type) 18 | 19 | ## Properties 20 | 21 | ### name 22 | 23 | • **name**: `string` 24 | 25 | #### Defined in 26 | 27 | [wv-linewise.ts:140](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L140) 28 | 29 | ___ 30 | 31 | ### type 32 | 33 | • **type**: [`PAUSED`](../enums/wv_linewise.RESPONSE_TYPE.md#paused) 34 | 35 | #### Defined in 36 | 37 | [wv-linewise.ts:139](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L139) 38 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.ResponseDispatcher.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / ResponseDispatcher 2 | 3 | # Interface: ResponseDispatcher 4 | 5 | [wv-linewise](../modules/wv_linewise.md).ResponseDispatcher 6 | 7 | ## Type parameters 8 | 9 | | Name | 10 | | :------ | 11 | | `Response` | 12 | 13 | ## Callable 14 | 15 | ### ResponseDispatcher 16 | 17 | ▸ **ResponseDispatcher**(`evt`): `void` 18 | 19 | #### Parameters 20 | 21 | | Name | Type | 22 | | :------ | :------ | 23 | | `evt` | `Response` | 24 | 25 | #### Returns 26 | 27 | `void` 28 | 29 | #### Defined in 30 | 31 | [wv-linewise.ts:195](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L195) 32 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.StreamContinueRequest.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / StreamContinueRequest 2 | 3 | # Interface: StreamContinueRequest 4 | 5 | [wv-linewise](../modules/wv_linewise.md).StreamContinueRequest 6 | 7 | Once a stream has been started, then [PausedResponse](wv_linewise.PausedResponse.md) because 8 | [StreamStartRequest.count](wv_linewise.StreamStartRequest.md#count) lines had been read you can restart it with 9 | this [Request](../modules/wv_linewise.md#request) 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [msg](wv_linewise.StreamContinueRequest.md#msg) 16 | - [name](wv_linewise.StreamContinueRequest.md#name) 17 | 18 | ## Properties 19 | 20 | ### msg 21 | 22 | • **msg**: [`STREAM_CONTINUE`](../enums/wv_linewise.REQUEST_TYPE.md#stream_continue) 23 | 24 | #### Defined in 25 | 26 | [wv-linewise.ts:52](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L52) 27 | 28 | ___ 29 | 30 | ### name 31 | 32 | • **name**: `string` 33 | 34 | #### Defined in 35 | 36 | [wv-linewise.ts:53](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L53) 37 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.StreamListRequest.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / StreamListRequest 2 | 3 | # Interface: StreamListRequest 4 | 5 | [wv-linewise](../modules/wv_linewise.md).StreamListRequest 6 | 7 | [Request](../modules/wv_linewise.md#request) To get a list of streams. 8 | 9 | ## Table of contents 10 | 11 | ### Properties 12 | 13 | - [msg](wv_linewise.StreamListRequest.md#msg) 14 | 15 | ## Properties 16 | 17 | ### msg 18 | 19 | • **msg**: [`STREAM_LIST`](../enums/wv_linewise.REQUEST_TYPE.md#stream_list) 20 | 21 | #### Defined in 22 | 23 | [wv-linewise.ts:43](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L43) 24 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.StreamListResponse.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / StreamListResponse 2 | 3 | # Interface: StreamListResponse 4 | 5 | [wv-linewise](../modules/wv_linewise.md).StreamListResponse 6 | 7 | A list of streams, in response to a [StreamListRequest](wv_linewise.StreamListRequest.md) 8 | 9 | ## Table of contents 10 | 11 | ### Properties 12 | 13 | - [streams](wv_linewise.StreamListResponse.md#streams) 14 | - [type](wv_linewise.StreamListResponse.md#type) 15 | 16 | ## Properties 17 | 18 | ### streams 19 | 20 | • **streams**: `string`[] 21 | 22 | #### Defined in 23 | 24 | [wv-linewise.ts:129](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L129) 25 | 26 | ___ 27 | 28 | ### type 29 | 30 | • **type**: [`STREAM_LIST`](../enums/wv_linewise.RESPONSE_TYPE.md#stream_list) 31 | 32 | #### Defined in 33 | 34 | [wv-linewise.ts:128](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L128) 35 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise.StreamStartRequest.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise](../modules/wv_linewise.md) / StreamStartRequest 2 | 3 | # Interface: StreamStartRequest 4 | 5 | [wv-linewise](../modules/wv_linewise.md).StreamStartRequest 6 | 7 | [Request](../modules/wv_linewise.md#request) to start a named stream. 8 | 9 | ## Table of contents 10 | 11 | ### Properties 12 | 13 | - [count](wv_linewise.StreamStartRequest.md#count) 14 | - [msg](wv_linewise.StreamStartRequest.md#msg) 15 | - [name](wv_linewise.StreamStartRequest.md#name) 16 | 17 | ## Properties 18 | 19 | ### count 20 | 21 | • **count**: `number` 22 | 23 | How many lines to read before the stream is [PausedResponse](wv_linewise.PausedResponse.md) 24 | 25 | #### Defined in 26 | 27 | [wv-linewise.ts:27](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L27) 28 | 29 | ___ 30 | 31 | ### msg 32 | 33 | • **msg**: [`STREAM_START`](../enums/wv_linewise.REQUEST_TYPE.md#stream_start) 34 | 35 | #### Defined in 36 | 37 | [wv-linewise.ts:23](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L23) 38 | 39 | ___ 40 | 41 | ### name 42 | 43 | • **name**: `string` 44 | 45 | The name of the stream to start 46 | 47 | #### Defined in 48 | 49 | [wv-linewise.ts:25](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L25) 50 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise_fetch.WvLinewiseFetchCurrent.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise-fetch](../modules/wv_linewise_fetch.md) / WvLinewiseFetchCurrent 2 | 3 | # Interface: WvLinewiseFetchCurrent 4 | 5 | [wv-linewise-fetch](../modules/wv_linewise_fetch.md).WvLinewiseFetchCurrent 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [body](wv_linewise_fetch.WvLinewiseFetchCurrent.md#body) 12 | - [end](wv_linewise_fetch.WvLinewiseFetchCurrent.md#end) 13 | - [headers](wv_linewise_fetch.WvLinewiseFetchCurrent.md#headers) 14 | - [id](wv_linewise_fetch.WvLinewiseFetchCurrent.md#id) 15 | - [status](wv_linewise_fetch.WvLinewiseFetchCurrent.md#status) 16 | 17 | ## Properties 18 | 19 | ### body 20 | 21 | • `Optional` **body**: `string`[] 22 | 23 | #### Defined in 24 | 25 | [wv-linewise-fetch.ts:144](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L144) 26 | 27 | ___ 28 | 29 | ### end 30 | 31 | • `Optional` **end**: `boolean` 32 | 33 | #### Defined in 34 | 35 | [wv-linewise-fetch.ts:145](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L145) 36 | 37 | ___ 38 | 39 | ### headers 40 | 41 | • `Optional` **headers**: `Object` 42 | 43 | #### Index signature 44 | 45 | ▪ [k: `string`]: `string` 46 | 47 | #### Defined in 48 | 49 | [wv-linewise-fetch.ts:143](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L143) 50 | 51 | ___ 52 | 53 | ### id 54 | 55 | • **id**: `number` 56 | 57 | #### Defined in 58 | 59 | [wv-linewise-fetch.ts:141](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L141) 60 | 61 | ___ 62 | 63 | ### status 64 | 65 | • `Optional` **status**: `number` 66 | 67 | #### Defined in 68 | 69 | [wv-linewise-fetch.ts:142](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L142) 70 | -------------------------------------------------------------------------------- /js-lib/docs/interfaces/wv_linewise_fetch.WvLinewiseRequest.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / [wv-linewise-fetch](../modules/wv_linewise_fetch.md) / WvLinewiseRequest 2 | 3 | # Interface: WvLinewiseRequest 4 | 5 | [wv-linewise-fetch](../modules/wv_linewise_fetch.md).WvLinewiseRequest 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [id](wv_linewise_fetch.WvLinewiseRequest.md#id) 12 | - [opts](wv_linewise_fetch.WvLinewiseRequest.md#opts) 13 | - [url](wv_linewise_fetch.WvLinewiseRequest.md#url) 14 | 15 | ## Properties 16 | 17 | ### id 18 | 19 | • **id**: `number` 20 | 21 | #### Defined in 22 | 23 | [wv-linewise-fetch.ts:136](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L136) 24 | 25 | ___ 26 | 27 | ### opts 28 | 29 | • **opts**: `RequestInit` 30 | 31 | #### Defined in 32 | 33 | [wv-linewise-fetch.ts:134](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L134) 34 | 35 | ___ 36 | 37 | ### url 38 | 39 | • **url**: `string` 40 | 41 | #### Defined in 42 | 43 | [wv-linewise-fetch.ts:135](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L135) 44 | -------------------------------------------------------------------------------- /js-lib/docs/modules.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](README.md) / Modules 2 | 3 | # wv-linewise-js-lib 4 | 5 | ## Table of contents 6 | 7 | ### Modules 8 | 9 | - [main](modules/main.md) 10 | - [wv-linewise](modules/wv_linewise.md) 11 | - [wv-linewise-buffer](modules/wv_linewise_buffer.md) 12 | - [wv-linewise-fetch](modules/wv_linewise_fetch.md) 13 | -------------------------------------------------------------------------------- /js-lib/docs/modules/main.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / main 2 | 3 | # Module: main 4 | 5 | ## Table of contents 6 | 7 | ### References 8 | 9 | - [DetailsResponse](main.md#detailsresponse) 10 | - [ErrorResponse](main.md#errorresponse) 11 | - [ExitRequest](main.md#exitrequest) 12 | - [FinishedResponse](main.md#finishedresponse) 13 | - [LineResponse](main.md#lineresponse) 14 | - [MessageErrorResponse](main.md#messageerrorresponse) 15 | - [OUT\_REQUEST\_DESCRIPTOR](main.md#out_request_descriptor) 16 | - [OutRequest](main.md#outrequest) 17 | - [Param](main.md#param) 18 | - [ParamsRequest](main.md#paramsrequest) 19 | - [ParamsResponse](main.md#paramsresponse) 20 | - [PausedResponse](main.md#pausedresponse) 21 | - [REQUEST\_TYPE](main.md#request_type) 22 | - [RESPONSE\_TYPE](main.md#response_type) 23 | - [RawWvLinewise](main.md#rawwvlinewise) 24 | - [RawWvLinewiseMock](main.md#rawwvlinewisemock) 25 | - [Request](main.md#request) 26 | - [Response](main.md#response) 27 | - [ResponseDispatcher](main.md#responsedispatcher) 28 | - [StreamContinueRequest](main.md#streamcontinuerequest) 29 | - [StreamListRequest](main.md#streamlistrequest) 30 | - [StreamListResponse](main.md#streamlistresponse) 31 | - [StreamStartRequest](main.md#streamstartrequest) 32 | - [WvLinewise](main.md#wvlinewise) 33 | - [WvLinewiseBuffer](main.md#wvlinewisebuffer) 34 | - [WvLinewiseFetchCurrent](main.md#wvlinewisefetchcurrent) 35 | - [WvLinewiseRequest](main.md#wvlinewiserequest) 36 | - [WvLinewiseResponse](main.md#wvlinewiseresponse) 37 | - [externalInvoke](main.md#externalinvoke) 38 | - [getWvLinewiseFetch](main.md#getwvlinewisefetch) 39 | - [getWvLinewiseManagedFetch](main.md#getwvlinewisemanagedfetch) 40 | - [runningInWvLinewise](main.md#runninginwvlinewise) 41 | 42 | ## References 43 | 44 | ### DetailsResponse 45 | 46 | Re-exports [DetailsResponse](../interfaces/wv_linewise.DetailsResponse.md) 47 | 48 | ___ 49 | 50 | ### ErrorResponse 51 | 52 | Re-exports [ErrorResponse](../interfaces/wv_linewise.ErrorResponse.md) 53 | 54 | ___ 55 | 56 | ### ExitRequest 57 | 58 | Re-exports [ExitRequest](../interfaces/wv_linewise.ExitRequest.md) 59 | 60 | ___ 61 | 62 | ### FinishedResponse 63 | 64 | Re-exports [FinishedResponse](../interfaces/wv_linewise.FinishedResponse.md) 65 | 66 | ___ 67 | 68 | ### LineResponse 69 | 70 | Re-exports [LineResponse](../interfaces/wv_linewise.LineResponse.md) 71 | 72 | ___ 73 | 74 | ### MessageErrorResponse 75 | 76 | Re-exports [MessageErrorResponse](../interfaces/wv_linewise.MessageErrorResponse.md) 77 | 78 | ___ 79 | 80 | ### OUT\_REQUEST\_DESCRIPTOR 81 | 82 | Re-exports [OUT_REQUEST_DESCRIPTOR](../enums/wv_linewise.OUT_REQUEST_DESCRIPTOR.md) 83 | 84 | ___ 85 | 86 | ### OutRequest 87 | 88 | Re-exports [OutRequest](../interfaces/wv_linewise.OutRequest.md) 89 | 90 | ___ 91 | 92 | ### Param 93 | 94 | Re-exports [Param](../interfaces/wv_linewise.Param.md) 95 | 96 | ___ 97 | 98 | ### ParamsRequest 99 | 100 | Re-exports [ParamsRequest](../interfaces/wv_linewise.ParamsRequest.md) 101 | 102 | ___ 103 | 104 | ### ParamsResponse 105 | 106 | Re-exports [ParamsResponse](../interfaces/wv_linewise.ParamsResponse.md) 107 | 108 | ___ 109 | 110 | ### PausedResponse 111 | 112 | Re-exports [PausedResponse](../interfaces/wv_linewise.PausedResponse.md) 113 | 114 | ___ 115 | 116 | ### REQUEST\_TYPE 117 | 118 | Re-exports [REQUEST_TYPE](../enums/wv_linewise.REQUEST_TYPE.md) 119 | 120 | ___ 121 | 122 | ### RESPONSE\_TYPE 123 | 124 | Re-exports [RESPONSE_TYPE](../enums/wv_linewise.RESPONSE_TYPE.md) 125 | 126 | ___ 127 | 128 | ### RawWvLinewise 129 | 130 | Re-exports [RawWvLinewise](../classes/wv_linewise.RawWvLinewise.md) 131 | 132 | ___ 133 | 134 | ### RawWvLinewiseMock 135 | 136 | Re-exports [RawWvLinewiseMock](../classes/wv_linewise.RawWvLinewiseMock.md) 137 | 138 | ___ 139 | 140 | ### Request 141 | 142 | Re-exports [Request](wv_linewise.md#request) 143 | 144 | ___ 145 | 146 | ### Response 147 | 148 | Re-exports [Response](wv_linewise.md#response) 149 | 150 | ___ 151 | 152 | ### ResponseDispatcher 153 | 154 | Re-exports [ResponseDispatcher](../interfaces/wv_linewise.ResponseDispatcher.md) 155 | 156 | ___ 157 | 158 | ### StreamContinueRequest 159 | 160 | Re-exports [StreamContinueRequest](../interfaces/wv_linewise.StreamContinueRequest.md) 161 | 162 | ___ 163 | 164 | ### StreamListRequest 165 | 166 | Re-exports [StreamListRequest](../interfaces/wv_linewise.StreamListRequest.md) 167 | 168 | ___ 169 | 170 | ### StreamListResponse 171 | 172 | Re-exports [StreamListResponse](../interfaces/wv_linewise.StreamListResponse.md) 173 | 174 | ___ 175 | 176 | ### StreamStartRequest 177 | 178 | Re-exports [StreamStartRequest](../interfaces/wv_linewise.StreamStartRequest.md) 179 | 180 | ___ 181 | 182 | ### WvLinewise 183 | 184 | Re-exports [WvLinewise](../classes/wv_linewise.WvLinewise.md) 185 | 186 | ___ 187 | 188 | ### WvLinewiseBuffer 189 | 190 | Re-exports [WvLinewiseBuffer](../classes/wv_linewise_buffer.WvLinewiseBuffer.md) 191 | 192 | ___ 193 | 194 | ### WvLinewiseFetchCurrent 195 | 196 | Re-exports [WvLinewiseFetchCurrent](../interfaces/wv_linewise_fetch.WvLinewiseFetchCurrent.md) 197 | 198 | ___ 199 | 200 | ### WvLinewiseRequest 201 | 202 | Re-exports [WvLinewiseRequest](../interfaces/wv_linewise_fetch.WvLinewiseRequest.md) 203 | 204 | ___ 205 | 206 | ### WvLinewiseResponse 207 | 208 | Re-exports [WvLinewiseResponse](../classes/wv_linewise_fetch.WvLinewiseResponse.md) 209 | 210 | ___ 211 | 212 | ### externalInvoke 213 | 214 | Re-exports [externalInvoke](wv_linewise.md#externalinvoke) 215 | 216 | ___ 217 | 218 | ### getWvLinewiseFetch 219 | 220 | Re-exports [getWvLinewiseFetch](wv_linewise_fetch.md#getwvlinewisefetch) 221 | 222 | ___ 223 | 224 | ### getWvLinewiseManagedFetch 225 | 226 | Re-exports [getWvLinewiseManagedFetch](wv_linewise_fetch.md#getwvlinewisemanagedfetch) 227 | 228 | ___ 229 | 230 | ### runningInWvLinewise 231 | 232 | Re-exports [runningInWvLinewise](wv_linewise.md#runninginwvlinewise) 233 | -------------------------------------------------------------------------------- /js-lib/docs/modules/wv_linewise.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / wv-linewise 2 | 3 | # Module: wv-linewise 4 | 5 | ## Table of contents 6 | 7 | ### Enumerations 8 | 9 | - [OUT\_REQUEST\_DESCRIPTOR](../enums/wv_linewise.OUT_REQUEST_DESCRIPTOR.md) 10 | - [REQUEST\_TYPE](../enums/wv_linewise.REQUEST_TYPE.md) 11 | - [RESPONSE\_TYPE](../enums/wv_linewise.RESPONSE_TYPE.md) 12 | 13 | ### Classes 14 | 15 | - [RawWvLinewise](../classes/wv_linewise.RawWvLinewise.md) 16 | - [RawWvLinewiseMock](../classes/wv_linewise.RawWvLinewiseMock.md) 17 | - [WvLinewise](../classes/wv_linewise.WvLinewise.md) 18 | 19 | ### Interfaces 20 | 21 | - [DetailsResponse](../interfaces/wv_linewise.DetailsResponse.md) 22 | - [ErrorResponse](../interfaces/wv_linewise.ErrorResponse.md) 23 | - [ExitRequest](../interfaces/wv_linewise.ExitRequest.md) 24 | - [FinishedResponse](../interfaces/wv_linewise.FinishedResponse.md) 25 | - [LineResponse](../interfaces/wv_linewise.LineResponse.md) 26 | - [MessageErrorResponse](../interfaces/wv_linewise.MessageErrorResponse.md) 27 | - [OutRequest](../interfaces/wv_linewise.OutRequest.md) 28 | - [Param](../interfaces/wv_linewise.Param.md) 29 | - [ParamsRequest](../interfaces/wv_linewise.ParamsRequest.md) 30 | - [ParamsResponse](../interfaces/wv_linewise.ParamsResponse.md) 31 | - [PausedResponse](../interfaces/wv_linewise.PausedResponse.md) 32 | - [ResponseDispatcher](../interfaces/wv_linewise.ResponseDispatcher.md) 33 | - [StreamContinueRequest](../interfaces/wv_linewise.StreamContinueRequest.md) 34 | - [StreamListRequest](../interfaces/wv_linewise.StreamListRequest.md) 35 | - [StreamListResponse](../interfaces/wv_linewise.StreamListResponse.md) 36 | - [StreamStartRequest](../interfaces/wv_linewise.StreamStartRequest.md) 37 | 38 | ### Type aliases 39 | 40 | - [Request](wv_linewise.md#request) 41 | - [Response](wv_linewise.md#response) 42 | 43 | ### Functions 44 | 45 | - [externalInvoke](wv_linewise.md#externalinvoke) 46 | - [runningInWvLinewise](wv_linewise.md#runninginwvlinewise) 47 | 48 | ## Type aliases 49 | 50 | ### Request 51 | 52 | Ƭ **Request**: [`StreamStartRequest`](../interfaces/wv_linewise.StreamStartRequest.md) \| [`StreamContinueRequest`](../interfaces/wv_linewise.StreamContinueRequest.md) \| [`ParamsRequest`](../interfaces/wv_linewise.ParamsRequest.md) \| [`OutRequest`](../interfaces/wv_linewise.OutRequest.md) \| [`ExitRequest`](../interfaces/wv_linewise.ExitRequest.md) \| [`StreamListRequest`](../interfaces/wv_linewise.StreamListRequest.md) 53 | 54 | Communication from the web-view to WV Linewise is sent via a Request and responeded to via a [Response](wv_linewise.md#response) 55 | 56 | #### Defined in 57 | 58 | [wv-linewise.ts:4](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L4) 59 | 60 | ___ 61 | 62 | ### Response 63 | 64 | Ƭ **Response**: [`ParamsResponse`](../interfaces/wv_linewise.ParamsResponse.md) \| [`PausedResponse`](../interfaces/wv_linewise.PausedResponse.md) \| [`FinishedResponse`](../interfaces/wv_linewise.FinishedResponse.md) \| [`DetailsResponse`](../interfaces/wv_linewise.DetailsResponse.md) \| [`LineResponse`](../interfaces/wv_linewise.LineResponse.md) \| [`MessageErrorResponse`](../interfaces/wv_linewise.MessageErrorResponse.md) \| [`ErrorResponse`](../interfaces/wv_linewise.ErrorResponse.md) \| [`StreamListResponse`](../interfaces/wv_linewise.StreamListResponse.md) 65 | 66 | Communication from the WV Linewise to the webview, usually in response to a [Request](wv_linewise.md#request) is sent via a Response. 67 | 68 | #### Defined in 69 | 70 | [wv-linewise.ts:92](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L92) 71 | 72 | ## Functions 73 | 74 | ### externalInvoke 75 | 76 | ▸ **externalInvoke**(`e`): `any` 77 | 78 | #### Parameters 79 | 80 | | Name | Type | 81 | | :------ | :------ | 82 | | `e` | `any` | 83 | 84 | #### Returns 85 | 86 | `any` 87 | 88 | #### Defined in 89 | 90 | [wv-linewise.ts:428](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L428) 91 | 92 | ___ 93 | 94 | ### runningInWvLinewise 95 | 96 | ▸ **runningInWvLinewise**(): `boolean` 97 | 98 | #### Returns 99 | 100 | `boolean` 101 | 102 | #### Defined in 103 | 104 | [wv-linewise.ts:414](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise.ts#L414) 105 | -------------------------------------------------------------------------------- /js-lib/docs/modules/wv_linewise_buffer.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / wv-linewise-buffer 2 | 3 | # Module: wv-linewise-buffer 4 | 5 | ## Table of contents 6 | 7 | ### Classes 8 | 9 | - [WvLinewiseBuffer](../classes/wv_linewise_buffer.WvLinewiseBuffer.md) 10 | -------------------------------------------------------------------------------- /js-lib/docs/modules/wv_linewise_fetch.md: -------------------------------------------------------------------------------- 1 | [wv-linewise-js-lib](../README.md) / [Modules](../modules.md) / wv-linewise-fetch 2 | 3 | # Module: wv-linewise-fetch 4 | 5 | ## Table of contents 6 | 7 | ### Classes 8 | 9 | - [WvLinewiseResponse](../classes/wv_linewise_fetch.WvLinewiseResponse.md) 10 | 11 | ### Interfaces 12 | 13 | - [WvLinewiseFetchCurrent](../interfaces/wv_linewise_fetch.WvLinewiseFetchCurrent.md) 14 | - [WvLinewiseRequest](../interfaces/wv_linewise_fetch.WvLinewiseRequest.md) 15 | 16 | ### Functions 17 | 18 | - [getWvLinewiseFetch](wv_linewise_fetch.md#getwvlinewisefetch) 19 | - [getWvLinewiseManagedFetch](wv_linewise_fetch.md#getwvlinewisemanagedfetch) 20 | 21 | ## Functions 22 | 23 | ### getWvLinewiseFetch 24 | 25 | ▸ **getWvLinewiseFetch**(`wvl`, `responseStream`): (`url`: `string`, `opts`: `RequestInit`) => `Promise`<`Response`\> 26 | 27 | #### Parameters 28 | 29 | | Name | Type | 30 | | :------ | :------ | 31 | | `wvl` | [`WvLinewise`](../classes/wv_linewise.WvLinewise.md) | 32 | | `responseStream` | `string` | 33 | 34 | #### Returns 35 | 36 | `fn` 37 | 38 | ▸ (`url`, `opts`): `Promise`<`Response`\> 39 | 40 | ##### Parameters 41 | 42 | | Name | Type | 43 | | :------ | :------ | 44 | | `url` | `string` | 45 | | `opts` | `RequestInit` | 46 | 47 | ##### Returns 48 | 49 | `Promise`<`Response`\> 50 | 51 | | Name | Type | 52 | | :------ | :------ | 53 | | `parse` | (`current`: [`WvLinewiseFetchCurrent`](../interfaces/wv_linewise_fetch.WvLinewiseFetchCurrent.md), `command`: `string`, `lineStripped`: `string`) => [`WvLinewiseFetchCurrent`](../interfaces/wv_linewise_fetch.WvLinewiseFetchCurrent.md) | 54 | | `process` | () => `Promise`<`boolean`\> | 55 | | `request` | (`url`: `string`, `opts`: `RequestInit`) => [`WvLinewiseRequest`](../interfaces/wv_linewise_fetch.WvLinewiseRequest.md) | 56 | | `serialize` | (`request`: [`WvLinewiseRequest`](../interfaces/wv_linewise_fetch.WvLinewiseRequest.md)) => `string` | 57 | | `pendingCount` | () => `number` | 58 | 59 | #### Defined in 60 | 61 | [wv-linewise-fetch.ts:149](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L149) 62 | 63 | ___ 64 | 65 | ### getWvLinewiseManagedFetch 66 | 67 | ▸ **getWvLinewiseManagedFetch**(`wvl`, `responseStream`, `getTimeout`): (`url`: `string`, `opts`: `RequestInit`) => `Promise`<`Response`\> 68 | 69 | #### Parameters 70 | 71 | | Name | Type | 72 | | :------ | :------ | 73 | | `wvl` | [`WvLinewise`](../classes/wv_linewise.WvLinewise.md) | 74 | | `responseStream` | `string` | 75 | | `getTimeout` | (`n`: `number`) => `number` | 76 | 77 | #### Returns 78 | 79 | `fn` 80 | 81 | ▸ (`url`, `opts`): `Promise`<`Response`\> 82 | 83 | ##### Parameters 84 | 85 | | Name | Type | 86 | | :------ | :------ | 87 | | `url` | `string` | 88 | | `opts` | `RequestInit` | 89 | 90 | ##### Returns 91 | 92 | `Promise`<`Response`\> 93 | 94 | | Name | Type | 95 | | :------ | :------ | 96 | | `running` | () => `boolean` | 97 | 98 | #### Defined in 99 | 100 | [wv-linewise-fetch.ts:298](https://github.com/forbesmyester/wv-linewise/blob/2999a94/js-lib/src/wv-linewise-fetch.ts#L298) 101 | -------------------------------------------------------------------------------- /js-lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wv-linewise-js-lib", 3 | "version": "0.0.6", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/forbesmyester/wv-linewise" 7 | }, 8 | "homepage": "https://github.com/forbesmyester/wv-linewise/tree/master/js-lib", 9 | "description": "Libs for Web View Linewise", 10 | "main": "dist/main.js", 11 | "scripts": { 12 | "test": "npx ts-node test/wv-linewise-fetch.ts && npx ts-node test/wv-linewise-buffer.ts", 13 | "build": "rm -rf dist ; npx tsc && npx rollup -c", 14 | "doc": "node_modules/.bin/typedoc docs --entryPointStrategy expand src" 15 | }, 16 | "author": "Matt Forrester ", 17 | "license": "MIT", 18 | "dependencies": { 19 | "typedoc": "^0.22.12", 20 | "typedoc-plugin-markdown": "^3.11.14", 21 | "typescript-language-server": "^0.5.4" 22 | }, 23 | "typings": "./dist/main.d.ts", 24 | "devDependencies": { 25 | "@rollup/plugin-typescript": "^4.1.2", 26 | "@types/tap": "^14.10.3", 27 | "@types/tape": "^4.13.2", 28 | "rollup": "^2.68.0", 29 | "rollup-plugin-typescript": "^1.0.1", 30 | "tap": "^15.1.6", 31 | "tape": "^5.5.2", 32 | "ts-node": "^8.10.2", 33 | "tslint": "^6.1.3", 34 | "typescript": "^4.5.5" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /js-lib/rollup.config.js: -------------------------------------------------------------------------------- 1 | // rollup.config.js 2 | import typescript from 'rollup-plugin-typescript'; 3 | 4 | export default { 5 | input: './src/main.ts', 6 | output: { 7 | file: 'dist/browser.js', 8 | format: 'umd', 9 | name: 'wv-linewise-js-lib' 10 | }, 11 | plugins: [ 12 | typescript() 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /js-lib/src/main.ts: -------------------------------------------------------------------------------- 1 | export * from "./wv-linewise"; 2 | export * from "./wv-linewise-buffer"; 3 | export * from "./wv-linewise-fetch"; 4 | -------------------------------------------------------------------------------- /js-lib/src/wv-linewise-buffer.ts: -------------------------------------------------------------------------------- 1 | import { Response, RawWvLinewise, RESPONSE_TYPE, LineResponse, FinishedResponse, PausedResponse, WvLinewise } from "./wv-linewise"; 2 | 3 | function onlyOnce(f: Function) { 4 | let called = false; 5 | return function onlyOnceImp(...args: any[]) { 6 | if (called) { return; } 7 | called = true; 8 | return f.apply(null, args); 9 | } 10 | } 11 | 12 | enum WvLinewiseBufferState { 13 | NotStarted = 0, 14 | Running = 1, 15 | Requesting = 2, 16 | End = 3, 17 | } 18 | 19 | function sleep(): Promise { 20 | return new Promise((resolve) => { 21 | setTimeout( 22 | () => { 23 | resolve(null); 24 | }, 1 25 | ); 26 | }); 27 | } 28 | 29 | export class WvLinewiseBuffer { 30 | 31 | private buffer: string[] = []; 32 | private state: WvLinewiseBufferState = WvLinewiseBufferState.NotStarted; 33 | protected noSleep = false; 34 | 35 | constructor(private wvl: WvLinewise, private streamName: string, private lowWaterMark: number, private countToRequest: number) { 36 | this.state = 0; // 1 = running, 2 = requesting, 3 = end 37 | if (countToRequest == 0) { 38 | throw new Error("WvLinewiseBuffer: countToRequest must be a positive number"); 39 | } 40 | this.wvl.on(RESPONSE_TYPE.LINE, ({ name, data }: LineResponse) => { 41 | if (name == this.streamName) { 42 | this.buffer.push(data); 43 | } 44 | }); 45 | this.wvl.on(RESPONSE_TYPE.FINISHED, () => { 46 | this.state = 3; 47 | }); 48 | this.wvl.on(RESPONSE_TYPE.PAUSED, () => { 49 | this.state = 1; 50 | }); 51 | } 52 | 53 | notify() { 54 | 55 | return new Promise((resolve) => { 56 | 57 | let onlyOnceResolve = onlyOnce(resolve); 58 | 59 | let eventNotification = async ({ name, type }: PausedResponse | LineResponse | FinishedResponse) => { 60 | 61 | if (name !== this.streamName) { 62 | return; 63 | } 64 | 65 | if (type == RESPONSE_TYPE.FINISHED) { this.state = 3; } 66 | if (type == RESPONSE_TYPE.PAUSED) { 67 | this.state = 1; 68 | if (!this.noSleep) { 69 | await sleep(); 70 | } 71 | return this.request(); 72 | } 73 | 74 | this.wvl.off(RESPONSE_TYPE.FINISHED, eventNotification); 75 | this.wvl.off(RESPONSE_TYPE.LINE, eventNotification); 76 | this.wvl.off(RESPONSE_TYPE.PAUSED, eventNotification); 77 | onlyOnceResolve(); 78 | }; 79 | 80 | this.wvl.on(RESPONSE_TYPE.FINISHED, eventNotification); 81 | this.wvl.on(RESPONSE_TYPE.LINE, eventNotification); 82 | this.wvl.on(RESPONSE_TYPE.PAUSED, eventNotification); 83 | 84 | }); 85 | } 86 | 87 | request() { 88 | if (this.state >= 2) { 89 | return; 90 | } 91 | 92 | if (this.state == 0) { 93 | this.state = 2; 94 | this.wvl.streamStart(this.streamName, this.countToRequest); 95 | } 96 | else { 97 | this.state = 2; 98 | this.wvl.streamContinue(this.streamName); 99 | } 100 | 101 | } 102 | 103 | async shift(): Promise { 104 | let now = () => { 105 | let r = this.buffer.length ? this.buffer.shift() : null; 106 | if (r === undefined) { 107 | return null; 108 | } 109 | return r; 110 | } 111 | if ((this.state < 2) && (this.buffer.length <= this.lowWaterMark)) { 112 | this.request(); 113 | } 114 | if (this.buffer.length == 0) { 115 | if (this.state == 2) { 116 | await this.notify(); 117 | return now(); 118 | } 119 | return Promise.resolve(null); 120 | } 121 | return Promise.resolve(now()); 122 | } 123 | 124 | } 125 | 126 | -------------------------------------------------------------------------------- /js-lib/test/wv-linewise-buffer.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import { Response, RawWvLinewise, RESPONSE_TYPE, WvLinewise, RawWvLinewiseMock } from "../src/wv-linewise"; 3 | import { WvLinewiseBuffer } from "../src/wv-linewise-buffer"; 4 | 5 | tap.test('testWvLinewiseBuffer', async function testWvLinewiseBuffer({is: assert, end}) { 6 | 7 | let progress = 0; 8 | 9 | class RawWvlTest extends RawWvLinewiseMock { 10 | 11 | constructor() { 12 | let x = { 13 | invoke: (s: string) => { 14 | } 15 | }; 16 | super(); 17 | } 18 | 19 | public fire(d: Response) { 20 | super.fire(d); 21 | } 22 | } 23 | 24 | class WvlTest extends WvLinewise { 25 | 26 | streamStart(name: string, count: number) { 27 | assert(name, "in"); 28 | assert(count, 3); 29 | progress++; 30 | } 31 | 32 | streamContinue(name: string) { 33 | assert(name, "in"); 34 | progress = progress + 10; 35 | } 36 | 37 | } 38 | 39 | class MyWvLinewiseBuffer extends WvLinewiseBuffer { 40 | protected noSleep = true; 41 | } 42 | 43 | let wvlr = new RawWvlTest(); 44 | let wvl = new WvlTest(wvlr); 45 | let wvlb = new MyWvLinewiseBuffer(wvl, "in", 3, 3); 46 | 47 | // Initial Get will start the Wvl 48 | // Get Count: 1, Requests: 1, Buffer: 3 - 1 49 | let p = wvlb.shift(); 50 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "A", name: "in" }); 51 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "B", name: "in" }); 52 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "C", name: "in" }); 53 | wvlr.fire({ type: RESPONSE_TYPE.PAUSED, name: "in" }); 54 | let line1: string = await p as string; 55 | assert(progress, 1); 56 | assert(line1, "A"); 57 | 58 | // The 2nd Get will be fulfillable via the buffer but will cause a Continue 59 | // 60 | // Get Count: 2, Requests: 2(in progress), Buffer: 3 - 2 61 | assert(await wvlb.shift(), "B"); 62 | assert(progress, 11); 63 | 64 | // The 3rd Get will be fulfillable via the buffer and not cause a Continue 65 | // because we have not finished the previous 66 | // 67 | // Get Count: 3, Requests: 2(in progress), Buffer: 3 - 3 68 | assert(await wvlb.shift(), "C"); 69 | assert(progress, 11); 70 | 71 | // The 4th Get requires the completion of the request from the second GET as 72 | // we have an empty buffer 73 | // 74 | // Get Count: 4, Requests: 2, Buffer: 6 - 4 75 | let line2 = wvlb.shift() as Promise; 76 | assert(progress, 11); 77 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "D", name: "in" }); 78 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "E", name: "in" }); 79 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "F", name: "in" }); 80 | wvlr.fire({ type: RESPONSE_TYPE.PAUSED, name: "in" }); 81 | assert(await line2, "D"); 82 | 83 | // 5th Get fulfillable from buffer but causes Continue as below water mark 84 | // 85 | // Get Count: 5, Requests: 3(In progress), Buffer: 6 - 5 86 | assert(await wvlb.shift(), "E"); 87 | assert(progress, 21); 88 | 89 | // Before the 6th Get our buffer gets filled with more items than we asked 90 | // for (which is fine) to put us over the low water mark... The Get will 91 | // cause no Continue. 92 | // 93 | // Get Count: 6, Requests: 3, Buffer: 10 - 6 94 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "G", name: "in" }); 95 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "H", name: "in" }); 96 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "I", name: "in" }); 97 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "J", name: "in" }); 98 | wvlr.fire({ type: RESPONSE_TYPE.PAUSED, name: "in" }); 99 | assert(await wvlb.shift(), "F"); 100 | assert(progress, 21); 101 | 102 | // 7th Get From Buffer 103 | // 104 | // Get Count: 7, Requests: 3, Buffer: 10 - 7 105 | assert(await wvlb.shift(), "G"); 106 | assert(progress, 21); 107 | 108 | // 8th Get From Buffer - But fallen below low water mark - Continue 109 | // 110 | // Get Count: 8, Requests: 4(in progress), Buffer: 10 - 8 111 | assert(await wvlb.shift(), "H"); 112 | assert(progress, 31); 113 | 114 | // Finish up, checking we shift null at end 115 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "K", name: "in" }); 116 | assert(await wvlb.shift(), "I"); 117 | assert(await wvlb.shift(), "J"); 118 | assert(await wvlb.shift(), "K"); 119 | 120 | // Check we can deal with a PAUSE directly after a shift, then restart 121 | let line3 = wvlb.shift() as Promise; 122 | wvlr.fire({ type: RESPONSE_TYPE.PAUSED, name: "in" }); 123 | assert(progress, 41); 124 | wvlr.fire({ type: RESPONSE_TYPE.LINE, data: "L", name: "in" }); 125 | assert(await line3, "L"); 126 | 127 | // Clean finish. 128 | wvlr.fire({ type: RESPONSE_TYPE.FINISHED, name: "in" }); 129 | assert(await wvlb.shift(), null); 130 | assert(progress, 41); 131 | 132 | end(); 133 | }); 134 | 135 | -------------------------------------------------------------------------------- /js-lib/test/wv-linewise-fetch.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import { Test } from "tap"; 3 | import { Response, WvLinewise, RawWvLinewiseMock, RESPONSE_TYPE } from "../src/wv-linewise"; 4 | import { getWvLinewiseFetch, getWvLinewiseManagedFetch } from "../src/wv-linewise-fetch"; 5 | 6 | tap.test('testFetchOutput', async function testFetchOutput(test) { 7 | 8 | let raw = new RawWvLinewiseMock(); 9 | let wvl = new WvLinewise(raw); 10 | let fet = getWvLinewiseFetch(wvl, 'responses'); 11 | raw.addStreamData( 12 | "responses", 13 | [ 14 | 'RESPONSE: 1: HEADERS: {"Content-Type": "text/csv"}', 15 | 'RESPONSE: 1: STATUS: 201', 16 | 'RESPONSE: 1: BODY:content,temperature', 17 | 'RESPONSE: 1: BODY:water,-1', 18 | 'RESPONSE: 2: BODY:content,temperature', 19 | 'RESPONSE: 1: END', 20 | 'RESPONSE: 2: BODY:steam,101', 21 | 'RESPONSE: 2: END', 22 | ] 23 | ); 24 | 25 | test.is(fet.pendingCount(), 0); 26 | let respP1 = fet('/snow', { cache: "default" }); 27 | test.is(fet.pendingCount(), 1); 28 | for (let i = 0; i < 6; i++) { 29 | await fet.process(); 30 | } 31 | let resp1 = await respP1; 32 | test.is(resp1.status, 201); 33 | test.is(await resp1.text(), "content,temperature\nwater,-1"); 34 | test.is(resp1.headers.get('Content-Type'), 'text/csv'); 35 | test.is(resp1.url, '/snow'); 36 | test.is(fet.pendingCount(), 0); 37 | 38 | 39 | test.is(fet.pendingCount(), 0); 40 | let respP2 = fet('/steam', { cache: "default" }); 41 | test.is(fet.pendingCount(), 1); 42 | for (let i = 0; i < 2; i++) { 43 | await fet.process(); 44 | } 45 | let resp2 = await respP2; 46 | test.is(resp2.status, 200); 47 | test.is(resp2.url, '/steam'); 48 | test.is(await resp2.text(), "content,temperature\nsteam,101"); 49 | test.is(fet.pendingCount(), 0); 50 | 51 | test.end(); 52 | 53 | }); 54 | 55 | 56 | tap.test('testSerialize', function testSerialize(test) { 57 | 58 | let raw = new RawWvLinewiseMock(); 59 | let wvl = new WvLinewise(raw); 60 | let fet = getWvLinewiseFetch(wvl, 'responses'); 61 | 62 | test.is( 63 | fet.serialize({ opts: { cache: "no-cache", method: "post", body: JSON.stringify({ a: 2 }) }, id: 3, url: '/snow' }), 64 | 'REQUEST: 3: POST: /snow {"a":2}' 65 | ); 66 | test.is( 67 | fet.serialize({ opts: { cache: "no-cache", method: "get" }, id: 3, url: '/snow' }), 68 | 'REQUEST: 3: GET: /snow {}' 69 | ); 70 | test.end() 71 | 72 | }); 73 | 74 | tap.test('testFetchOutputParse', function testFetchOutputParse(test) { 75 | 76 | 77 | let raw = new RawWvLinewiseMock(); 78 | let wvl = new WvLinewise(raw); 79 | let f1 = getWvLinewiseFetch(wvl, 'responses'); 80 | 81 | test.deepEquals(f1.parse({id: 1}, 'BODY', ' hello'),{id: 1, body: [' hello'] }); 82 | test.deepEquals(f1.parse({id: 1, body: ['one']}, 'BODY', 'two'),{id: 1, body: ['one', 'two'] }); 83 | test.deepEquals(f1.parse({id: 1}, 'HEADERS', ' {"x":1}'),{id: 1, headers: {"x": "1"}}); 84 | test.deepEquals(f1.parse({id: 1, headers: {"y": "2"}}, 'HEADERS', '{"x":1}'),{id: 1, headers: {"x": "1", "y": "2"}}); 85 | test.deepEquals(f1.parse({id: 1}, 'END', ''),{id: 1, headers: {}, body: [], end: true}); 86 | 87 | test.end(); 88 | 89 | }); 90 | 91 | 92 | tap.test('testManagedFetchOutput', async function testManagedFetchOutput(test) { 93 | 94 | class RawWvlTest extends RawWvLinewiseMock { 95 | 96 | constructor() { 97 | let x = { 98 | invoke: (s: string) => { 99 | } 100 | }; 101 | super(); 102 | } 103 | 104 | public fire(d: Response) { 105 | super.fire(d); 106 | } 107 | } 108 | 109 | function getTimeout(n: number): number { 110 | return 10; 111 | } 112 | 113 | function delay(n: number): Promise { 114 | return new Promise((resolve) => { 115 | setTimeout(() => resolve(true), n); 116 | }); 117 | } 118 | 119 | function delayAndAdd(n: number, data: string[]) { 120 | setTimeout( 121 | () => { 122 | raw.addStreamData( 123 | "responses", 124 | data 125 | ); 126 | }, 127 | n 128 | ); 129 | } 130 | 131 | let raw = new RawWvlTest(); 132 | let wvl = new WvLinewise(raw); 133 | let fet = getWvLinewiseManagedFetch(wvl, 'responses', getTimeout); 134 | 135 | // delayAndAdd( 136 | // 25, 137 | // [ 138 | // 'RESPONSE: 2: BODY:content,temperature', 139 | // 'RESPONSE: 2: BODY:water,10', 140 | // 'RESPONSE: 2: END', 141 | // ] 142 | // ); 143 | 144 | // delayAndAdd( 145 | // 35, 146 | // [ 147 | // 'RESPONSE: 3: BODY:content,temperature', 148 | // 'RESPONSE: 3: BODY:steam,101', 149 | // 'RESPONSE: 3: END', 150 | // ] 151 | // ); 152 | 153 | test.is(fet.running(), false); 154 | let resp1P = fet('/snow', { cache: "default" }); 155 | test.is(fet.running(), true); 156 | raw.fire({ 157 | type: RESPONSE_TYPE.LINE, 158 | data: 'RESPONSE: 1: HEADERS: {"Content-Type": "text/csv"}', 159 | name: "responses" 160 | }); 161 | raw.fire({ 162 | type: RESPONSE_TYPE.LINE, 163 | data: 'RESPONSE: 1: STATUS: 201', 164 | name: "responses" 165 | }); 166 | raw.fire({ 167 | type: RESPONSE_TYPE.LINE, 168 | data: 'RESPONSE: 1: BODY:content,temperature', 169 | name: "responses" 170 | }); 171 | raw.fire({ 172 | type: RESPONSE_TYPE.LINE, 173 | data: 'RESPONSE: 1: BODY:ice,-1', 174 | name: "responses" 175 | }); 176 | setTimeout(() => { 177 | raw.fire({ 178 | type: RESPONSE_TYPE.LINE, 179 | data: 'RESPONSE: 1: END', 180 | name: "responses" 181 | }); 182 | }, 100); 183 | let resp1 = await resp1P 184 | test.is(fet.running(), false); 185 | test.is(await resp1.text(), "content,temperature\nice,-1"); 186 | test.is(resp1.headers.get('Content-Type'), 'text/csv'); 187 | test.end(); 188 | 189 | // let resp2P = fet('/snow', { cache: "default" }); 190 | // test.is(fet.running(), true); 191 | // console.log(resp2P); 192 | // resp2P.then(async (resp2) => { 193 | // test.is(fet.running(), true); 194 | // test.is(await resp2.text(), "content,temperature\nwater,10"); 195 | // }); 196 | 197 | // let resp3P = fet('/snow', { cache: "default" }); 198 | // test.is(fet.running(), true); 199 | // console.log(resp3P); 200 | // resp2P.then(async (resp3) => { 201 | // test.is(fet.running(), false); 202 | // test.is(await resp3.text(), "content,temperature\nsteam,101"); 203 | // console.log("END"); 204 | // test.end(); 205 | // }); 206 | 207 | // }); 208 | // test.is(fet.running(), false); 209 | 210 | 211 | 212 | 213 | // for (let i = 0; i < 6; i++) { 214 | // await fet.process(); 215 | // } 216 | // let resp1 = await respP1; 217 | // test.is(resp1.status, 201); 218 | // test.is(await resp1.text(), "content,temperature\nwater,-1"); 219 | // test.is(resp1.headers.get('Content-Type'), 'text/csv'); 220 | // test.is(resp1.url, '/snow'); 221 | // test.is(fet.pendingCount(), 0); 222 | 223 | 224 | // test.is(fet.pendingCount(), 0); 225 | // let respP2 = fet('/steam', { cache: "default" }); 226 | // test.is(fet.pendingCount(), 1); 227 | // for (let i = 0; i < 2; i++) { 228 | // await fet.process(); 229 | // } 230 | // let resp2 = await respP2; 231 | // test.is(resp2.status, 200); 232 | // test.is(resp2.url, '/steam'); 233 | // test.is(await resp2.text(), "content,temperature\nsteam,101"); 234 | // test.is(fet.pendingCount(), 0); 235 | 236 | }); 237 | 238 | 239 | -------------------------------------------------------------------------------- /js-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ 5 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 6 | "lib": ["dom"], /* Specify library files to be included in the compilation. */ 7 | // "allowJs": true, /* Allow javascript files to be compiled. */ 8 | // "checkJs": true, /* Report errors in .js files. */ 9 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 10 | "declaration": true, /* Generates corresponding '.d.ts' file. */ 11 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 12 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 13 | // "outFile": "./", /* Concatenate and emit output to single file. */ 14 | "outDir": "./dist", /* Redirect output structure to the directory. */ 15 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 16 | // "composite": true, /* Enable project compilation */ 17 | // "removeComments": true, /* Do not emit comments to output. */ 18 | // "noEmit": true, /* Do not emit outputs. */ 19 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 20 | "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 21 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 22 | 23 | /* Strict Type-Checking Options */ 24 | "strict": true, /* Enable all strict type-checking options. */ 25 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 26 | // "strictNullChecks": true, /* Enable strict null checks. */ 27 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 28 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 29 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 30 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 31 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 32 | 33 | /* Additional Checks */ 34 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 35 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 36 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 37 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 38 | 39 | /* Module Resolution Options */ 40 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 41 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 42 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 43 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 44 | // "typeRoots": [], /* List of folders to include type definitions from. */ 45 | // "types": [], /* Type declaration files to be included in compilation. */ 46 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 47 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 48 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 49 | 50 | /* Source Map Options */ 51 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 52 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 53 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 54 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 55 | 56 | /* Experimental Options */ 57 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 58 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 59 | }, 60 | "exclude": [ 61 | "dist", 62 | "test" 63 | ] 64 | } 65 | -------------------------------------------------------------------------------- /js-lib/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "jsRules": {}, 7 | "rules": { 8 | "interface-name": [false], 9 | "max-line-length": [true, {"limit": 120, "ignore-pattern": "^ *function"}], 10 | "object-literal-sort-keys": false 11 | }, 12 | "rulesDirectory": [] 13 | } 14 | --------------------------------------------------------------------------------