Skip to content

Commit

Permalink
(Breaking) Support Deno v1.0.5
Browse files Browse the repository at this point in the history
- Update to reflect changes in Deno v1.0.5 plugin system which are not backwards compatible
- Update dependencies
- Improve documentation to mention platform support
  • Loading branch information
Pandawan committed Jun 6, 2020
1 parent 1a27841 commit e686c26
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Setup deno
uses: denolib/setup-deno@master
with:
deno-version: v1.x
deno-version: v1.0.5

- name: Install required build packages (linux)
if: startsWith(matrix.os, 'ubuntu')
Expand Down
97 changes: 34 additions & 63 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno_notify"
version = "0.2.2"
version = "0.3.0"
authors = ["Pandawan <pandawanfr@gmail.com>"]
edition = "2018"
publish = false
Expand All @@ -12,7 +12,7 @@ crate-type = ["cdylib"]

[dependencies]
futures = "0.3.5"
deno_core = "0.45.2"
notify-rust = "4.0.0-rc.1"
deno_core = "0.47.1"
notify-rust = "4.0.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![license](https://img.shields.io/github/license/PandawanFr/deno_notify)](https://github.com/PandawanFr/deno_notify/blob/master/LICENSE)
[![build](https://img.shields.io/github/workflow/status/PandawanFr/deno_notify/Build)](https://github.com/PandawanFr/deno_notify/actions)
[![deno version](https://img.shields.io/badge/deno-1.0.0-success)](https://github.com/denoland/deno)
[![deno version](https://img.shields.io/badge/deno-1.0.5-success)](https://github.com/denoland/deno)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/deno_notify/ts/mod.ts)

Send desktop notifications on all platforms in Deno.
Expand All @@ -17,15 +17,15 @@ A `prepared.ts` entrypoint is provided which uses [deno-plugin-prepare](https://
*You will need to run using the `--unstable` and `--allow-all` permissions to allow for automatic plugin loading and caching.*

```ts
import { notify } from 'https://deno.land/x/deno_notify@0.2.2/ts/prepared.ts';
import { notify } from 'https://deno.land/x/deno_notify@0.3.0/ts/prepared.ts';

// Pass a simple message string
notify('Message');
notify('My message');

// Pass an options object (See mod.ts's NotifyOptions)
notify({
title: 'Hello',
message: 'World',
title: 'A nice title',
message: 'My message',
icon: {
app: "Terminal",
},
Expand All @@ -36,12 +36,12 @@ notify({
### Manual Loading

If you prefer to handle the plugin loading manually, you can do so by using the `mod.ts` entrypoint.
Make sure you [download](https://github.com/PandawanFr/deno_notify/releases/tag/0.2.2) the correct plugin for your operating system.
Make sure you [download](https://github.com/PandawanFr/deno_notify/releases/tag/0.3.0) the correct plugin for your operating system.

*Because plugin loading is handled manually, you only need the `--unstable` and `--allow-plugin` permissions.*

```ts
import { notify } from 'https://deno.land/x/deno_notify@0.2.2/ts/mod.ts';
import { notify } from 'https://deno.land/x/deno_notify@0.3.0/ts/mod.ts';

// Load the plugin manually
Deno.openPlugin("./libdeno_notify.dylib");
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct SendNotificationResult {}
fn op_notify_send(
_interface: &mut dyn Interface,
data: &[u8],
_zero_copy: Option<ZeroCopyBuf>,
_zero_copy: &mut [ZeroCopyBuf],
) -> Op {
let mut response: NotifyResponse<SendNotificationResult> = NotifyResponse {
err: None,
Expand Down
19 changes: 12 additions & 7 deletions tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { notify, getPluginId } from "../ts/prepared.ts";
import { assert } from "https://deno.land/std@v0.54.0/testing/asserts.ts";
import { assert } from "https://deno.land/std@v0.55.0/testing/asserts.ts";

Deno.test("Check plugin id", () => {
assert(getPluginId() !== null && getPluginId() !== 0);
Expand All @@ -8,22 +8,27 @@ Deno.test("Check plugin id", () => {
// Need to send complete notification before simple because the icon can't change after being set on mac
Deno.test("Send complete notification", () => {
notify({
title: "Hey",
message: "Hello World",
title: "A nice title",
message: "A complete notification",
icon: {
app: "Safari",
},
sound: "Basso",
});
});

Deno.test("Send partial notification", () => {
notify({
message: "A partial notification"
});
});

Deno.test("Send simple notification", () => {
notify("Message");
notify("A simple notification");
});

/*
Deno.close doesn't work right now, see: https://github.com/denoland/deno/issues/5975
// Deno.close doesn't work right now, see: https://github.com/denoland/deno/issues/5975
Deno.test("Load plugin manually", () => {
const target = Deno.env.get("DENO_NOTIFY_PLUGIN_BASE");
// Only attempt to load manually if not using online version
Expand All @@ -33,7 +38,7 @@ Deno.test("Load plugin manually", () => {
if (pluginId !== null) {
Deno.close(pluginId);
notify('Test Message');
notify('My message');
}
assert(!(Deno as any).core.ops()['notify_send'], "Notify ops still exist after closing");
Expand Down
13 changes: 8 additions & 5 deletions ts/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import { unwrapResponse, opSync } from "./plugin.ts";

export type Icon = {
/**
* Name of the application to use the icon.
* **(MACOS)** Name of the application to use the icon from.
*
* Note: macOS does not explicitly support custom icons.
* To circumvent this, this option pretends your notifications are sent the given application.
*/
app: string;
} | {
/**
* File URL to the icon (must be file://).
* **(UNIX, WINDOWS)** A file:// URL to the icon.
*/
path: string;
} | {
/**
* Name of the icon in an icon theme, must be freedesktop.org compliant.
* **(UNIX)** Name of the icon in an icon theme, must be freedesktop.org compliant.
*/
name: string;
};
Expand All @@ -34,7 +37,7 @@ export interface NotifyOptions {
*/
icon?: Icon;
/**
* Sound to play when showing the notification.
* **(MACOS, WINDOWS)** Sound to play when showing the notification.
*/
sound?: string;
}
Expand All @@ -53,7 +56,7 @@ export interface NotifyResult {}
* @param message
* @example
* ```ts
* notify('Message');
* notify('My message');
* ```
*/
export function notify(message: string): NotifyResult;
Expand Down
4 changes: 2 additions & 2 deletions ts/prepared.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { prepare } from "https://deno.land/x/plugin_prepare@v0.6.0/mod.ts";
import { resolve } from "https://deno.land/std@v0.54.0/path/mod.ts";
import { resolve } from "https://deno.land/std@v0.55.0/path/mod.ts";

export * from "./mod.ts";

const releaseUrl =
"https://github.com/PandawanFr/deno_notify/releases/download/0.2.2";
"https://github.com/PandawanFr/deno_notify/releases/download/0.3.0";

/**
* Don't require env permissions if they're not given.
Expand Down

0 comments on commit e686c26

Please sign in to comment.