Compare commits

..

19 Commits

Author SHA1 Message Date
semantic-release-bot 2fad185062 chore(release): 0.2.0-develop.17 [skip ci]
# [0.2.0-develop.17](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.16...v0.2.0-develop.17) (2023-08-10)

### Bug Fixes

* refactor how we process a nodejs stream, as the current approach is extremely slow and wasteful. We need to do a bit of macgyvering and convert it via pipe to a passthrough so it passes a typeof check for Stream, then import it to form-data Response, and request a blob ([ae35797](ae35797a25))
2023-08-10 05:36:53 +00:00
Derrick Hammer 0625b1acbb
ci: refactor installing go and use the github action 2023-08-10 01:34:58 -04:00
Derrick Hammer cfdd7748d7
ci: debug 2023-08-09 15:32:47 -04:00
Derrick Hammer 5760b20fe7
ci: remove debug 2023-08-09 15:30:22 -04:00
Derrick Hammer f6bfaf4509
ci: hack 2023-08-09 15:30:12 -04:00
Derrick Hammer 693d703a4c
ci: debug 2023-08-09 15:09:56 -04:00
Derrick Hammer 0037179fd1
ci: hack source 2023-08-09 15:00:36 -04:00
Derrick Hammer ea68d0ec0d
ci: install bison 2023-08-09 14:58:55 -04:00
Derrick Hammer 9378f87336
ci: hack source 2023-08-09 14:57:20 -04:00
Derrick Hammer d24f5c89d5
ci: revert "ci: add bash debug"
This reverts commit cbdc097bda.
2023-08-09 14:56:16 -04:00
Derrick Hammer cbdc097bda
ci: add bash debug 2023-08-09 14:28:18 -04:00
Derrick Hammer 0d4d6c4007
ci: ensure hexdump is installed 2023-08-09 14:26:46 -04:00
Derrick Hammer 587f8696b2
ci: add dummy description to workflow_dispatch param 2023-08-09 14:16:59 -04:00
Derrick Hammer d59b39c8ed
ci: revert debug to using workflow_dispatch and the debug_enabled flag 2023-08-09 14:12:28 -04:00
Derrick Hammer 49082c4014
ci: add bash debug 2023-08-09 13:58:58 -04:00
Derrick Hammer 37b3389aa5
ci: try to use a or true over e switch as CI calls bash with e directly 2023-08-09 13:56:34 -04:00
Derrick Hammer f79a722e77
ci: hack to prevent from dying on error code from gvm installer 2023-08-09 06:31:10 -04:00
Derrick Hammer d85b90cfa0
Merge remote-tracking branch 'origin/develop' into develop 2023-08-09 06:11:36 -04:00
Derrick Hammer ae35797a25
fix: refactor how we process a nodejs stream, as the current approach is extremely slow and wasteful. We need to do a bit of macgyvering and convert it via pipe to a passthrough so it passes a typeof check for Stream, then import it to form-data Response, and request a blob 2023-08-09 06:11:18 -04:00
5 changed files with 39 additions and 20 deletions

View File

@ -6,6 +6,11 @@ on:
- master - master
- develop - develop
- develop-* - develop-*
workflow_dispatch:
inputs:
debug_enabled:
description: debug_enabled
type: boolean
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -16,24 +21,18 @@ jobs:
with: with:
node-version: 18.x node-version: 18.x
cache: 'npm' cache: 'npm'
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Setup Golang - name: Setup Golang
run: | run: |
sudo apt-get update;
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer);
source ~/.gvm/scripts/gvm;
gvm install go1.4 -B;
gvm use go1.4 --default;
gvm install go1.19 -B;
VERSION=0.28.1; VERSION=0.28.1;
TINYGO="tinygo_${VERSION}_amd64.deb"; TINYGO="tinygo_${VERSION}_amd64.deb";
wget -q https://github.com/tinygo-org/tinygo/releases/download/v$VERSION/$TINYGO; wget -q https://github.com/tinygo-org/tinygo/releases/download/v$VERSION/$TINYGO;
sudo dpkg -i $TINYGO && rm $TINYGO; sudo dpkg -i $TINYGO && rm $TINYGO;
- name: Fetch Wasm Deps - name: Fetch Wasm Deps
run: | run: cd src/golang && go get
source ~/.gvm/scripts/gvm;
gvm use go1.19 --default;
cd src/golang;
go get;
- run: npm ci - run: npm ci
- run: npm run build --if-present - run: npm run build --if-present
- name: Install SSH key - name: Install SSH key

View File

@ -1,3 +1,10 @@
# [0.2.0-develop.17](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.16...v0.2.0-develop.17) (2023-08-10)
### Bug Fixes
* refactor how we process a nodejs stream, as the current approach is extremely slow and wasteful. We need to do a bit of macgyvering and convert it via pipe to a passthrough so it passes a typeof check for Stream, then import it to form-data Response, and request a blob ([ae35797](https://git.lumeweb.com/LumeWeb/libportal/commit/ae35797a2525d23ac9a552d076a9904e68a7a142))
# [0.2.0-develop.16](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.15...v0.2.0-develop.16) (2023-07-18) # [0.2.0-develop.16](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.15...v0.2.0-develop.16) (2023-07-18)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.16", "version": "0.2.0-develop.17",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.16", "version": "0.2.0-develop.17",
"dependencies": { "dependencies": {
"@lumeweb/node-library-preset": "git+https://git.lumeweb.com/LumeWeb/node-library-preset.git", "@lumeweb/node-library-preset": "git+https://git.lumeweb.com/LumeWeb/node-library-preset.git",
"@noble/curves": "^1.1.0", "@noble/curves": "^1.1.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.16", "version": "0.2.0-develop.17",
"main": "lib/index.js", "main": "lib/index.js",
"module": "lib/index.mjs", "module": "lib/index.mjs",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@ -29,6 +29,7 @@ import isNode from "detect-node";
import { utf8ToBytes } from "@noble/curves/abstract/utils"; import { utf8ToBytes } from "@noble/curves/abstract/utils";
type NodeReadableStreamType = typeof import("stream").Readable; type NodeReadableStreamType = typeof import("stream").Readable;
type NodePassThroughStreamType = typeof import("stream").PassThrough;
export interface ClientOptions { export interface ClientOptions {
portalUrl: string; portalUrl: string;
@ -340,13 +341,14 @@ export class Client {
let NodeReadableStream = let NodeReadableStream =
(await this.getNodeReadableObject()) as NodeReadableStreamType; (await this.getNodeReadableObject()) as NodeReadableStreamType;
if (NodeReadableStream && stream instanceof NodeReadableStream) { let NodePassThroughStream =
let data = new Uint8Array(); (await this.getNodePassThroughObject()) as NodePassThroughStreamType;
for await (const chunk of stream) {
data = Uint8Array.from([...data, ...chunk]);
}
stream = data; if (NodeReadableStream && stream instanceof NodeReadableStream) {
const Response = await this.getFetchResponseObject();
stream = await new Response(
stream.pipe(new NodePassThroughStream()) as any,
).blob();
} }
if (stream instanceof Uint8Array) { if (stream instanceof Uint8Array) {
@ -541,6 +543,7 @@ export class Client {
return FormData; return FormData;
} }
private async getBlobObject() { private async getBlobObject() {
if (isNode) { if (isNode) {
return (await import("node-fetch")).Blob; return (await import("node-fetch")).Blob;
@ -556,6 +559,15 @@ export class Client {
return undefined; return undefined;
} }
private async getNodePassThroughObject() {
if (isNode) {
return (await import("stream")).PassThrough;
}
return undefined;
}
private async getFetchObject() { private async getFetchObject() {
if (isNode) { if (isNode) {
return (await import("node-fetch")).default; return (await import("node-fetch")).default;
@ -563,6 +575,7 @@ export class Client {
return fetch; return fetch;
} }
private async getFetchResponseObject() { private async getFetchResponseObject() {
if (isNode) { if (isNode) {
return (await import("node-fetch")).Response; return (await import("node-fetch")).Response;