From 8d52e148db53f0c2e68653601b59ce2839baaada Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 6 Sep 2022 14:24:43 +0000 Subject: [PATCH] chore(release): 1.0.9 [skip ci] ## [1.0.9](https://github.com/flowscripter/template-deno-rust-library/compare/v1.0.8...v1.0.9) (2022-09-06) ### Bug Fixes * trying to force through updated deno_bindgen fixes [#19](https://github.com/flowscripter/template-deno-rust-library/issues/19) ([#49](https://github.com/flowscripter/template-deno-rust-library/issues/49)) ([b541a3a](https://github.com/flowscripter/template-deno-rust-library/commit/b541a3ae7a7bcceede8ae509f1aa1ef6ef7cb43d)) --- Cargo.lock | 2 +- Cargo.toml | 2 +- bindings/bindings.ts | 63 +++++++++++++++++++++++++++++++------------- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f20220d..fae533a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,7 +48,7 @@ dependencies = [ [[package]] name = "flowscripter_template_deno_rust_library" -version = "1.0.8" +version = "1.0.9" dependencies = [ "deno_bindgen", "flowscripter_template_rust_library", diff --git a/Cargo.toml b/Cargo.toml index b4a75a1..9768f7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flowscripter_template_deno_rust_library" -version ="1.0.8" +version ="1.0.9" edition = "2021" description = "Project template for a Rust library with Deno FFI bindings." homepage = "https://github.com/flowscripter" diff --git a/bindings/bindings.ts b/bindings/bindings.ts index 096b858..fdc93fa 100644 --- a/bindings/bindings.ts +++ b/bindings/bindings.ts @@ -1,32 +1,59 @@ // Auto-generated with deno_bindgen -import { CachePolicy, prepare } from "https://deno.land/x/plug@0.5.1/plug.ts"; +import { CachePolicy, prepare } from "https://deno.land/x/plug@0.5.2/plug.ts" + function encode(v: string | Uint8Array): Uint8Array { - if (typeof v !== "string") return v; - return new TextEncoder().encode(v); + if (typeof v !== "string") return v + return new TextEncoder().encode(v) } + function decode(v: Uint8Array): string { - return new TextDecoder().decode(v); + return new TextDecoder().decode(v) } + function readPointer(v: any): Uint8Array { - const ptr = new Deno.UnsafePointerView(v as Deno.UnsafePointer); - const lengthBe = new Uint8Array(4); - const view = new DataView(lengthBe.buffer); - ptr.copyInto(lengthBe, 0); - const buf = new Uint8Array(view.getUint32(0)); - ptr.copyInto(buf, 4); - return buf; + const ptr = new Deno.UnsafePointerView(v as bigint) + const lengthBe = new Uint8Array(4) + const view = new DataView(lengthBe.buffer) + ptr.copyInto(lengthBe, 0) + const buf = new Uint8Array(view.getUint32(0)) + ptr.copyInto(buf, 4) + return buf } + +const url = new URL( + "https://github.com/flowscripter/template-deno-rust-library/releases/download/v1.0.9", + import.meta.url, +) +let uri = url.toString() +if (!uri.endsWith("/")) uri += "/" + +let darwin: string | { aarch64: string; x86_64: string } = uri + + "libflowscripter_template_deno_rust_library.dylib" + +if (url.protocol !== "file:") { + // Assume that remote assets follow naming scheme + // for each macOS artifact. + darwin = { + aarch64: uri + "libflowscripter_template_deno_rust_library_arm64.dylib", + x86_64: uri + "libflowscripter_template_deno_rust_library.dylib", + } +} + const opts = { name: "flowscripter_template_deno_rust_library", - url: (new URL("../target/debug", import.meta.url)).toString(), - policy: CachePolicy.NONE, -}; + urls: { + darwin, + windows: uri + "flowscripter_template_deno_rust_library.dll", + linux: uri + "libflowscripter_template_deno_rust_library.so", + }, + policy: undefined, +} const _lib = await prepare(opts, { add: { parameters: ["i32", "i32"], result: "i32", nonblocking: false }, -}); +}) export function add(a0: number, a1: number) { - let rawResult = _lib.symbols.add(a0, a1); - const result = rawResult; - return result; + let rawResult = _lib.symbols.add(a0, a1) + const result = rawResult + return result }