Giter VIP home page Giter VIP logo

deno-clippy's Introduction

deno-clippy

This is cross-platform Deno library for writing and reading clipboard.
You can read from/write image and text.

This library uses Rust's arboard through FFI.
Therefore, it is basically not necessary to prepare some external commands when using this library.

However, if arboard returns an error, deno-clippy will fall back and use an external command (for example, xclip on Linux).
If arboard does not work properly and an error occurs, installing the external command may work.

Known issue.

Currently, arboard is not work on Linux.
So, please install xclip when you using library on Linux.

Example

import * as clippy from "https://deno.land/x/clippy/mod.ts";
import { readAll } from "https://deno.land/[email protected]/streams/conversion.ts";

// write image to clipboard
const f = await Deno.open("testdata/out.png");
await clippy.write_image(f);
f.close();

// read image from clipboard
const r = await clippy.read_image();
const data = await readAll(r);

// write text to clipboard
await clippy.write_text("hello clippy");

// read text from clipboard
const text = await clippy.read_text();

Contribution

Any contribution including documentations are welcome.

Development

To develop this library, the following must be installed.

If you modify the Rust code (under src/), you need to generate bindings/bindings.ts using deno_bindgen(just run make build).
bindings.ts is the glue code to handle dylib from Deno, and basically should not be edited and committed.
bindings.ts will only be changed for new releases as follows.

 const url = new URL(
-  "https://github.com/skanehira/deno-clippy/releases/download/v0.0.1/",
+  "https://github.com/skanehira/deno-clippy/releases/download/v0.1.0/",
   import.meta.url,
 )
 let uri = url.toString()

After implementation is complete, be sure to write tests as well.
The tests are to ensure the quality of this library.

The following is how to run the test.

# clean up dylib cache, and generate bindings.ts, dylib and run deno's test.
$ make deno-test
# run rust's tests.
$ make ffi-test
# run deno-test and ffi-test
$ make test

Author

skanehira

deno-clippy's People

Contributors

skanehira avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.