{"id":30369458,"url":"https://github.com/lucsoft/web_serial","last_synced_at":"2025-08-20T02:16:51.700Z","repository":{"id":303276886,"uuid":"1014918490","full_name":"lucsoft/web_serial","owner":"lucsoft","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-06T18:27:43.000Z","size":97,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-17T05:38:19.253Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-06T16:58:32.000Z","updated_at":"2025-08-03T19:39:04.000Z","dependencies_parsed_at":"2025-07-06T19:24:53.523Z","dependency_job_id":"5a2a5e1d-be19-4793-8073-9f58855af51f","html_url":"https://github.com/lucsoft/web_serial","commit_stats":null,"previous_names":["lucsoft/web_serial"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lucsoft/web_serial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucsoft%2Fweb_serial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucsoft%2Fweb_serial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucsoft%2Fweb_serial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucsoft%2Fweb_serial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucsoft","download_url":"https://codeload.github.com/lucsoft/web_serial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucsoft%2Fweb_serial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271252993,"owners_count":24726918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-20T02:16:50.705Z","updated_at":"2025-08-20T02:16:51.691Z","avatar_url":"https://github.com/lucsoft.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebSerial Polyfill for Deno\n\nThis project provides a polyfill for the [Web Serial API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) in [Deno](https://deno.com/), enabling serial port communication in Deno applications using a familiar web-compatible interface.\n\n## Usage\n\nCurrently, this project does not ship any pre-built binaries. To use the polyfill, you need to build the native adapter yourself:\n\n1. Clone the repository and navigate to its directory.\n2. Build the native binary using Cargo:\n\n    ```sh\n    cargo build --release\n    ```\n\n3. Set the `WEB_SERIAL_PATH` environment variable to the folder containing the compiled binary (typically `target/release`):\n\n    ```sh\n    export WEB_SERIAL_PATH=/path/to/deno_serial/target/release\n    ```\n\n4. Use the polyfill in your Deno project as documented.\n\nMake sure you have [Rust and Cargo](https://www.rust-lang.org/tools/install) installed.\n\n\n## Example\n\n1. Arduino Blink Sketch\n\n    Upload the following sketch to your Arduino:\n\n    ```cpp\n    String inputString = \"\";\n    bool stringComplete = false;\n\n    void setup() {\n        Serial.begin(115200);\n        inputString.reserve(200);\n\n        pinMode(2, OUTPUT);\n    }\n\n    void loop() {\n        if (!stringComplete) return;\n        inputString.trim();\n        if (inputString != \"OFF\" \u0026\u0026 inputString != \"ON\") return;\n        digitalWrite(2, inputString == \"ON\");\n\n        inputString = \"\";\n        stringComplete = false;\n    }\n\n    void serialEvent() {\n        while (Serial.available()) {\n            char inChar = (char)Serial.read();\n            inputString += inChar;\n            if (inChar == '\\n') {\n            stringComplete = true;\n            }\n        }\n    }\n    ```\n\n    Blinking via Web Serial in Deno:\n\n    ```typescript\n    import \"../mod.ts\"; // Import the polyfill\n    import { delay } from \"jsr:@std/async/delay\";\n\n    // get first available serial port\n    const port = await navigator.serial.requestPort();\n    await port.open({ baudRate: 115200 });\n\n    // read every chunk from the serial port\n    port.readable!\n        .pipeThrough(new TextDecoderStream())\n        .pipeTo(new WritableStream({\n            write(chunk) {\n                console.log(chunk.trim());\n            }\n        }));\n\n    // blink fast\n    const writer = port.writable!.getWriter();\n\n    while (true) {\n        await writer.write(new TextEncoder().encode(\"ON\\n\"));\n        await delay(100);\n        await writer.write(new TextEncoder().encode(\"OFF\\n\"));\n        await delay(100);\n    }\n    ```\n\n## License\n\nApache-2.0. Check [LICENSE](./LICENSE) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucsoft%2Fweb_serial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucsoft%2Fweb_serial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucsoft%2Fweb_serial/lists"}