Skip to content

Commit

Permalink
Convert to extend-chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksteamdev committed Jun 9, 2020
1 parent 55d9125 commit 97fccb0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<!--
Template tags:
bumble-org
extend-chrome
messages
@bumble
@extend-chrome
https://imgur.com/cKFLQ0o.png
-->

<p align="center">
<a href="https: //github.com/bumble-org/messages" rel="noopener">
<img width=200px height=200px src="https://imgur.com/cKFLQ0o.png" alt="@bumble/messages logo"></a>
<a href="https: //github.com/extend-chrome/messages" rel="noopener">
<img width=200px height=200px src="https://imgur.com/cKFLQ0o.png" alt="@extend-chrome/messages logo"></a>
</p>

<h3 align="center">@bumble/messages</h3>
<h3 align="center">@extend-chrome/messages</h3>

<div align="center">

[![npm (scoped)](https://img.shields.io/npm/v/@bumble/messages.svg)](https://www.npmjs.com/package/@bumble/messages)
[![GitHub last commit](https://img.shields.io/github/last-commit/bumble-org/messages.svg)](https://github.com/bumble-org/messages)
[![npm (scoped)](https://img.shields.io/npm/v/@extend-chrome/messages.svg)](https://www.npmjs.com/package/@extend-chrome/messages)
[![GitHub last commit](https://img.shields.io/github/last-commit/extend-chrome/messages.svg)](https://github.com/extend-chrome/messages)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)
[![TypeScript Declarations Included](https://img.shields.io/badge/types-TypeScript-informational)](#typescript)

Expand Down Expand Up @@ -47,13 +47,13 @@ You will need to use a bundler like [Rollup](https://rollupjs.org/guide/en/),
Parcel, or Webpack to include this library in the build of Chrome extension.

See
[`rollup-plugin-chrome-extension`](https://github.com/bumble-org/rollup-plugin-chrome-extension)
[`rollup-plugin-chrome-extension`](https://github.com/extend-chrome/rollup-plugin-chrome-extension)
for an easy way use Rollup to build your Chrome extension!

### Installation

```sh
$ npm i @bumble/messages
$ npm i @extend-chrome/messages
```

## Usage <a name = "usage"></a>
Expand All @@ -63,7 +63,7 @@ traditional messages object.

```javascript
// messages.js, used in both the background and content script
import { getMessage } from '@bumble/messages'
import { getMessage } from '@extend-chrome/messages'

// getMessage returns [Function, Observable, Function]
export const [sendNumber, numberStream, waitForNumber] = getMessage(
Expand Down Expand Up @@ -101,7 +101,7 @@ Intellisense has you covered.

```typescript
// messages.ts
import { getMessage } from '@bumble/messages'
import { getMessage } from '@extend-chrome/messages'

interface Stats {
hi: number
Expand Down Expand Up @@ -168,7 +168,7 @@ messages internally, but you don't want to pollute the global messaging space.
### `getMessage(greeting)`

```javascript
import { getMessage } from '@bumble/messages'
import { getMessage } from '@extend-chrome/messages'

const [sendMessage, messageStream, waitForMessage] = getMessage('greeting')
```
Expand Down Expand Up @@ -207,7 +207,7 @@ that includes at least a `greeting` property.

```javascript
// content-script.js
import { messages } from '@bumble/messages'
import { messages } from '@extend-chrome/messages'

// Simple message with no data
messages.send({ greeting: 'hello' }).then(() => {
Expand Down Expand Up @@ -236,7 +236,7 @@ listeners with the third `sendResponse` argument will receive async messages.

```javascript
// content-script.js
import { messages } from '@bumble/messages'
import { messages } from '@extend-chrome/messages'

messages
.send(
Expand All @@ -260,7 +260,7 @@ The return value of the handler is unused.

```javascript
// background.js
import * as messages from '@bumble/messages'
import * as messages from '@extend-chrome/messages'

// Listener should have 2, 1, or 0 arguments
messages.on((message, sender) => {
Expand Down Expand Up @@ -308,7 +308,7 @@ Call this with the message handler function you wish to stop using.
An Observable of all messages in its scope.

```typescript
import { messages } from '@bumble/messages'
import { messages } from '@extend-chrome/messages'

// Receives all messages in the default scope
messages.stream.subscribe(([message, sender, sendResponse]) => {
Expand All @@ -325,7 +325,7 @@ This is useful if you are writing a library for Chrome extensions that uses
messages internally, but you don't want to pollute the global messaging space.

```javascript
import { messages, getScope } from '@bumble/messages'
import { messages, getScope } from '@extend-chrome/messages'

const myScope = getScope('my-library')

Expand All @@ -337,5 +337,5 @@ messages.send({ greeting: 'hello?' })
```

> Note: The Chrome API Event `chrome.runtime.onMessage` will still receive all
> messages, but projects using `@bumble/messages` will not receive messages from
> messages, but projects using `@extend-chrome/messages` will not receive messages from
> other scopes.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bumble/messages",
"name": "@extend-chrome/messages",
"version": "1.1.0",
"description": "An API for Chrome extension messages that makes sense.",
"keywords": [
Expand All @@ -12,11 +12,11 @@
"intellisense"
],
"bugs": {
"url": "https://github.com/bumble-org/messages/issues"
"url": "https://github.com/extend-chrome/messages/issues"
},
"repository": {
"type": "github",
"url": "https://github.com/bumble-org/messages.git"
"url": "https://github.com/extend-chrome/messages.git"
},
"license": "MIT",
"author": "Jack and Amy Steam <jacksteamdev@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { getScope } from './scope'
export { getScope, getScope as useScope }

// Default scope
export const __defaultScopeName = '@bumble/messages__root'
export const __defaultScopeName = '@extend-chrome/messages__root'
export const messages = getScope(__defaultScopeName)
export const { getMessage } = messages
2 changes: 1 addition & 1 deletion tests/units/events-async.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const coreMessage: CoreMessage = {
payload: message,
scope,
}
const sender = {} // Not used directly by @bumble/messages
const sender = {} // Not used directly by @extend-chrome/messages
const response = {
greeting: 'goodbye',
}
Expand Down
2 changes: 1 addition & 1 deletion tests/units/events-one-way.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const coreMessage: CoreMessage = {
tabId: null,
}

const sender = {} // Not used directly by @bumble/messages
const sender = {} // Not used directly by @extend-chrome/messages
const sendResponse = jest.fn()

afterEach(() => {
Expand Down

0 comments on commit 97fccb0

Please sign in to comment.