Compare commits

...

17 Commits

Author SHA1 Message Date
semantic-release-bot 7319f5a048 chore(release): 0.2.0-develop.10 [skip ci]
# [0.2.0-develop.10](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.9...v0.2.0-develop.10) (2023-06-26)

### Bug Fixes

* add missing controller.enqueue ([2aa53fa](2aa53faf00))
* add properties and methods to go wasm middleware, accessed via reflection ([53dd352](53dd352c95))
* ensure root and proof are Uint8Array's ([0c320f9](0c320f992b))
* exit not properly exported in wasm ([23a55f7](23a55f772b))
* fix wasmDone logic error ([68fec66](68fec66069))
* need to refactor verification stream logic further and check if the stream is done but wasm isn't ([051f4b2](051f4b2da7))
* rename exit to kill to fix symbol conflict ([50a7c80](50a7c80358))
* update uploadFile overload types ([45fbc1b](45fbc1b63d))
2023-06-26 04:03:52 +00:00
Derrick Hammer 97489a577f
ci: run golang scripts before npm 2023-06-26 00:02:17 -04:00
Derrick Hammer 589821c570
ci: update ci config as it is too custom to use the template 2023-06-25 23:59:23 -04:00
Derrick Hammer a0c131ffb7
ci: fix build script 2023-06-25 23:45:59 -04:00
Derrick Hammer 5b82a9c561
ci: switch to github actions 2023-06-25 23:43:33 -04:00
Derrick Hammer 45fbc1b63d
fix: update uploadFile overload types 2023-06-25 23:39:22 -04:00
Derrick Hammer 06a8093786
chore: add npm-shrinkwrap.json 2023-06-25 18:02:25 -04:00
Derrick Hammer b8ab5faced
chore: update @lumeweb/node-library-preset 2023-06-25 18:02:02 -04:00
Derrick Hammer dd43e29b29
refactor: update presetter and switch to @lumeweb/node-library-preset 2023-06-25 17:20:40 -04:00
Derrick Hammer 051f4b2da7
fix: need to refactor verification stream logic further and check if the stream is done but wasm isn't 2023-06-24 04:28:08 -04:00
Derrick Hammer 50a7c80358
fix: rename exit to kill to fix symbol conflict 2023-06-24 04:27:08 -04:00
Derrick Hammer 68283d14e5
Merge remote-tracking branch 'origin/develop' into develop 2023-06-24 04:12:05 -04:00
Derrick Hammer 23a55f772b
fix: exit not properly exported in wasm 2023-06-24 04:11:55 -04:00
Derrick Hammer 53dd352c95
fix: add properties and methods to go wasm middleware, accessed via reflection 2023-06-24 04:11:37 -04:00
Derrick Hammer 2aa53faf00
fix: add missing controller.enqueue 2023-06-24 04:10:51 -04:00
Derrick Hammer 68fec66069
fix: fix wasmDone logic error 2023-06-24 04:10:39 -04:00
Derrick Hammer 0c320f992b
fix: ensure root and proof are Uint8Array's 2023-06-24 04:10:09 -04:00
11 changed files with 5205 additions and 16801 deletions

View File

@ -1,70 +0,0 @@
version: 2.1
orbs:
node: circleci/node@5.1.0
ssh: credijusto/ssh@0.5.2
workflows:
release:
jobs:
- node/run:
name: build
npm-run: build
pre-steps:
- run:
name: Setup Golang
command: >
sudo apt-get update;
sudo apt-get install bison;
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;
TINYGO="tinygo_${VERSION}_amd64.deb";
wget https://github.com/tinygo-org/tinygo/releases/download/v$VERSION/$TINYGO;
sudo dpkg -i $TINYGO && rm $TINYGO;
setup:
- run:
name: Fetch Wasm Deps
command: >
source ~/.gvm/scripts/gvm;
gvm use go1.19 --default;
cd src/golang;
go get;
post-steps:
- persist_to_workspace:
root: .
paths:
- lib/
filters:
branches:
only:
- master
- develop
- /^develop-.*$/
- node/run:
name: release
npm-run: semantic-release
requires:
- build
filters:
branches:
only:
- master
- develop
- /^develop-.*$/
context:
- publish
setup:
- attach_workspace:
at: ./
- add_ssh_keys:
fingerprints:
- "47:cf:a1:17:d9:81:8e:c5:51:e5:53:c8:33:e4:33:b9"
- ssh/ssh-add-host:
host_url: GITEA_HOST

54
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- name: Setup Golang
run: |
sudo apt-get update;
sudo apt-get install bison;
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;
TINYGO="tinygo_${VERSION}_amd64.deb";
wget https://github.com/tinygo-org/tinygo/releases/download/v$VERSION/$TINYGO;
sudo dpkg -i $TINYGO && rm $TINYGO;
- name: Fetch Wasm Deps
run: |
source ~/.gvm/scripts/gvm;
gvm use go1.19 --default;
cd src/golang;
go get;
- run: npm ci
- run: npm run build --if-present
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.GITEA_SSH_KEY }}
known_hosts: ${{ secrets.GITEA_KNOWN_HOST }}
- name: Publish
run: npm run semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && failure() }}
with:
limit-access-to-actor: true

View File

@ -1,22 +1,6 @@
{
"preset": [
"presetter-preset-essentials",
"presetter-preset-hybrid"
],
"config": {
"tsconfig": {
"compilerOptions": {
"lib": [
"ES2020",
"dom"
"presetter-preset-hybrid",
"@lumeweb/node-library-preset"
]
}
},
"prettier": {
"singleQuote": false
}
},
"variable": {
"source": "src"
}
}

View File

@ -1,32 +0,0 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "docs/CHANGELOG.md"
}
],
"@semantic-release/npm",
"@semantic-release/git",
{
"assets": [
"package.json",
"docs/CHANGELOG.md",
"npm-shrinkwrap.json"
]
}
],
"branches": [
"master",
{
name: "develop",
prerelease: true
},
{
name: "develop-*",
prerelease: true
},
]
}

13
CHANGELOG.md Normal file
View File

@ -0,0 +1,13 @@
# [0.2.0-develop.10](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.9...v0.2.0-develop.10) (2023-06-26)
### Bug Fixes
* add missing controller.enqueue ([2aa53fa](https://git.lumeweb.com/LumeWeb/libportal/commit/2aa53faf00cc7024a24dc97fffaeb855faa4e650))
* add properties and methods to go wasm middleware, accessed via reflection ([53dd352](https://git.lumeweb.com/LumeWeb/libportal/commit/53dd352c95fec8ec266a53c03f19cecbecf8821b))
* ensure root and proof are Uint8Array's ([0c320f9](https://git.lumeweb.com/LumeWeb/libportal/commit/0c320f992bdf269614716b51818ed7063086c01c))
* exit not properly exported in wasm ([23a55f7](https://git.lumeweb.com/LumeWeb/libportal/commit/23a55f772b7dde7712742ee5f47a5fda5bb8afd2))
* fix wasmDone logic error ([68fec66](https://git.lumeweb.com/LumeWeb/libportal/commit/68fec66069721a6dc94027419ddd2cafbc877cbc))
* need to refactor verification stream logic further and check if the stream is done but wasm isn't ([051f4b2](https://git.lumeweb.com/LumeWeb/libportal/commit/051f4b2da75ab2287c99a3514af5d0d4f28017bf))
* rename exit to kill to fix symbol conflict ([50a7c80](https://git.lumeweb.com/LumeWeb/libportal/commit/50a7c803584b57e4e294aca117fc1e8b9a2a09c7))
* update uploadFile overload types ([45fbc1b](https://git.lumeweb.com/LumeWeb/libportal/commit/45fbc1b63d2c19e186d6f21b022fee62be61866a))

21744
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/libportal",
"version": "0.2.0-develop.9",
"version": "0.2.0-develop.10",
"main": "lib/index.js",
"module": "lib/index.mjs",
"types": "lib/index.d.ts",
@ -21,19 +21,20 @@
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^10.0.4",
"@semantic-release/release-notes-generator": "^11.0.3",
"presetter": "^3.5.5",
"presetter-preset-essentials": "^3.5.5",
"presetter-preset-hybrid": "^3.5.5",
"presetter": "^4.0.1",
"presetter-preset-hybrid": "4.0.1",
"presetter-preset-strict": "^4.0.1",
"semantic-release": "^21.0.5"
},
"readme": "ERROR: No README data found!",
"scripts": {
"prepare": "presetter bootstrap",
"build": "presetter run build",
"build": "run build",
"build:wasm": "bash -c \"source ~/.gvm/scripts/gvm; mkdir ./lib/wasm && cd src/golang; tinygo build -o ../../lib/wasm/bao.wasm -target wasm ./main.go\"",
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/node-library-preset": "git+https://git.lumeweb.com/LumeWeb/node-library-preset.git",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",
"detect-node": "^2.1.0",

View File

@ -282,18 +282,18 @@ export class Client {
);
}
async uploadFile(stream: Blob, size?: bigint);
async uploadFile(stream: Blob, size?: bigint): Promise<string>;
async uploadFile(
stream: ReadableStream,
hashStream: ReadableStream,
size: bigint,
);
): Promise<string>;
async uploadFile(stream: Uint8Array, size?: bigint);
async uploadFile(
stream: NodeJS.ReadableStream,
hashStream: NodeJS.ReadableStream,
size?: bigint,
);
): Promise<string>;
async uploadFile(
stream: any,
hashStream?: any,

View File

@ -82,6 +82,7 @@ export default class Go {
private exited = false;
private _resolveCallbackPromise?: () => void;
importObject: ImportObject;
private _pendingEvent?: any;
constructor() {
this._callbackTimeouts = new Map();
@ -437,6 +438,16 @@ export default class Go {
}
this._inst.exports.resume();
}
_makeFuncWrapper(id) {
const go = this;
return function () {
const event = { id: id, this: this, args: arguments };
go._pendingEvent = event;
go._resume();
// @ts-ignore
return event.result;
};
}
}
if (

View File

@ -13,14 +13,14 @@ var activeReader *reader
var pipe chan []byte
var callbackId int
var nextBytes chan int
var exitChan chan bool
var killChan chan bool
func main() {
pipe = make(chan []byte)
nextBytes = make(chan int)
exitChan = make(chan bool)
killChan = make(chan bool)
callbackId = rand.Int()
<-exitChan
<-killChan
}
type reader struct {
@ -89,9 +89,9 @@ func start() int {
return callbackId
}
// exit write
func exit() {
exitChan <- true
//export kill
func kill() {
killChan <- true
}
func createWritePromiseHandler() js.Value {

View File

@ -12,6 +12,13 @@ export async function getVerifiableStream(
const reader = new VariableChunkStream(data);
let bytesToRead;
if (root instanceof ArrayBuffer) {
root = new Uint8Array(root);
}
if (proof instanceof ArrayBuffer) {
proof = new Uint8Array(proof);
}
const getNextBytes = async () => {
bytesToRead = getWasmProperty(wasmId, "write_promise");
bytesToRead = await bytesToRead;
@ -24,7 +31,7 @@ export async function getVerifiableStream(
// @ts-ignore
const exit = () => {
callExports("exit");
callExports("kill");
cleanup();
};
@ -67,22 +74,32 @@ export async function getVerifiableStream(
const result = getWasmProperty(wasmId, "result");
const wasmDone = result === undefined;
const wasmDone = result !== undefined;
if (result === undefined) {
if (!wasmDone) {
await getNextBytes();
}
if (chunk.done || wasmDone) {
if (wasmDone) {
if (result) {
controller.enqueue(chunk.value);
done(controller);
} else {
controller.error(getWasmProperty(wasmId, "error"));
exit();
}
} else {
if (!wasmDone) {
controller.error("stream is ended but verification not complete");
exit();
return;
}
controller.enqueue(chunk.value);
done(controller);
}
} else {
controller.enqueue(chunk.value);
}
},
async cancel(reason: any) {