Skip to content

Commit

Permalink
Merge pull request #7 from mayteio/feature/react-native
Browse files Browse the repository at this point in the history
✨ react native support
  • Loading branch information
mayteio authored Jun 23, 2020
2 parents 9f8ae38 + d9f51a3 commit d03d5f0
Show file tree
Hide file tree
Showing 28 changed files with 7,707 additions and 131 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node_modules
coverage
build
dist
react-native
.rpt2_cache

# misc
Expand All @@ -18,6 +19,9 @@ dist
.env.test.local
.env.production.local

# jest artifacts, i.e. cache
.jest

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
34 changes: 27 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [v5.0.0](https://github.com/mayteio/use-pusher/compare/v4.1.5...v5.0.0)

> 23 June 2020
- 🗑 remove react-scripts dependency, introduce jest directly [`0460115`](https://github.com/mayteio/use-pusher/commit/0460115f6d079c4f5fe2382d9e82c5459a3cd856)
- ✨ Add react-native support! [`bd96f9f`](https://github.com/mayteio/use-pusher/commit/bd96f9fe7cb65c3c1b61c3672be90cbeb21df541)
- ⬆️ upgrade deps [`fcf3c92`](https://github.com/mayteio/use-pusher/commit/fcf3c921fa58d7a406632cceff43d05a5493e569)

#### [v4.1.5](https://github.com/mayteio/use-pusher/compare/v4.1.4...v4.1.5)

> 4 June 2020
Expand Down Expand Up @@ -36,7 +44,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v4.1.0](https://github.com/mayteio/use-pusher/compare/v4.0.1...v4.1.0)

<<<<<<< HEAD

> # 27 February 2020
>
> 26 February 2020
>
> > > > > > > master
- ✨ removed local mocks, migrate to pusher-js-mock. Not happy with the tests. [`8d09648`](https://github.com/mayteio/use-pusher/commit/8d09648b5ca4a12ce709704dca0a4dba574eba0d)

Expand Down Expand Up @@ -80,14 +94,14 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v3.1.3](https://github.com/mayteio/use-pusher/compare/v3.1.2...v3.1.3)

> 13 February 2020
> 14 February 2020
- udpate docs [`ac90b4d`](https://github.com/mayteio/use-pusher/commit/ac90b4d9cfe4513eaf998c8898f5ba7f1c95c620)
- 🚑 add useClientTrigger to docs [`7325511`](https://github.com/mayteio/use-pusher/commit/732551127de0686661163e6050b09349054a8b34)

#### [v3.1.2](https://github.com/mayteio/use-pusher/compare/v3.1.1...v3.1.2)

> 12 February 2020
> 13 February 2020
#### [v3.1.1](https://github.com/mayteio/use-pusher/compare/v3.1.0...v3.1.1)

Expand Down Expand Up @@ -116,7 +130,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [v3.0.5](https://github.com/mayteio/use-pusher/compare/v3.0.4...v3.0.5)

<<<<<<< HEAD

> # 14 February 2020
>
> 13 February 2020
>
> > > > > > > master
- 🏷 use official typescript typings [`d3b5d4f`](https://github.com/mayteio/use-pusher/commit/d3b5d4f7acc5d8d0a593ebf752d7d23fe94a58c5)
- udpate docs [`ac90b4d`](https://github.com/mayteio/use-pusher/commit/ac90b4d9cfe4513eaf998c8898f5ba7f1c95c620)
Expand Down Expand Up @@ -144,13 +164,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [v3.0.0](https://github.com/mayteio/use-pusher/compare/v2.0.0...v3.0.0)

> 28 October 2019
> 29 October 2019
- ♻️ improve DX: `useEvent&lt;T&gt;(data?: T)` [`42bb95a`](https://github.com/mayteio/use-pusher/commit/42bb95a48bb8b42c038166b5b557fea446d84607)
- ♻️ improve DX: `useEvent&lt;T&gt;(data?: T)` [`42bb95a`](https://github.com/mayteio/use-pusher/commit/42bb95a48bb8b42c038166b5b557fea446d84607)

### [v2.0.0](https://github.com/mayteio/use-pusher/compare/v1.1.5...v2.0.0)

> 17 October 2019
> 18 October 2019
- stable release [`9db276d`](https://github.com/mayteio/use-pusher/commit/9db276d02627ec8386e69f42ea64b13dbc679477)
- 📝 Testing presence channels [`f4e9929`](https://github.com/mayteio/use-pusher/commit/f4e9929fabccc5a78c1adbba394204005e146c3a)
Expand All @@ -167,7 +187,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v1.1.4](https://github.com/mayteio/use-pusher/compare/v1.1.3...v1.1.4)

> 22 August 2019
> 23 August 2019
- 📦 update deps + types [`9d4a5fb`](https://github.com/mayteio/use-pusher/commit/9d4a5fb53c797386d4d9d2c66a89c46030fc5a65)

Expand Down Expand Up @@ -231,7 +251,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 17 August 2019
- remove __tests__ from dist [`3bf4195`](https://github.com/mayteio/use-pusher/commit/3bf4195df85b7f4903fdd0b264e95e2199fdcc51)
- remove **tests** from dist [`3bf4195`](https://github.com/mayteio/use-pusher/commit/3bf4195df85b7f4903fdd0b264e95e2199fdcc51)

#### [v1.0.4](https://github.com/mayteio/use-pusher/compare/v1.0.3...v1.0.4)

Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@
[![NPM](https://img.shields.io/npm/v/@harelpls/use-pusher.svg)](https://www.npmjs.com/package/@harelpls/use-pusher) ![Typed](https://badgen.net/badge//types/Typescript?icon=typescript)

##### [API Reference/Docs](https://use-pusher-docs.netlify.com/)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Install](#install)
- [Hooks](#hooks)
- [Usage](#usage)
- [`useChannel`](#usechannel)
- [`usePresenceChannel`](#usepresencechannel)
- [`useEvent`](#useevent)
- [`useTrigger`](#usetrigger)
- [`usePusher`](#usepusher)
- [Trigger Server](#trigger-server)
- [`useClientTrigger`](#useclienttrigger)
- [Typescript](#typescript)
- [Testing](#testing)
- [React Native](#react-native)
- [Contributing](#contributing)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## [API Reference/Docs](https://use-pusher-docs.netlify.com/)

## Install

Expand Down Expand Up @@ -231,6 +252,14 @@ test("should show a title when it receives a title event", async () => {

[Check out the example tests](https://github.com/mayteio/use-pusher/blob/master/src/__tests__/Example.tsx) for testing presence channels.

## React Native

This package comes with React Native support. Import your `PusherProvider` from `@harelpls/use-pusher/react-native` instead of the default `@harelpls/use-pusher`. All exports (except testing utils) are re-exported from there.

```ts
import { PusherProvider, useChannel } from "@harelpls/use-pusher/react-native";
```

## Contributing

1. Clone the repository and run `yarn && yarn test:watch`
Expand Down
13 changes: 13 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
},
},
],
],
plugins: ["@babel/plugin-proposal-class-properties"],
};
20 changes: 20 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [Example app](#example-app)
- [Available Scripts](#available-scripts)
- [`yarn start`](#yarn-start)
- [`yarn test`](#yarn-test)
- [`yarn build`](#yarn-build)
- [`yarn eject`](#yarn-eject)
- [Learn More](#learn-more)
- [Code Splitting](#code-splitting)
- [Analyzing the Bundle Size](#analyzing-the-bundle-size)
- [Making a Progressive Web App](#making-a-progressive-web-app)
- [Advanced Configuration](#advanced-configuration)
- [Deployment](#deployment)
- [`yarn build` fails to minify](#yarn-build-fails-to-minify)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# Example app

This example app allows you to test the hooks with a real pusher client.
Expand Down
9 changes: 0 additions & 9 deletions example/src/App.test.js

This file was deleted.

14 changes: 13 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
module.exports = {
collectCoverageFrom: ["src/**/*.{ts,tsx}"],
coveragePathIgnorePatterns: ["./src/index.ts"]
coveragePathIgnorePatterns: ["./src/index.ts"],
roots: ["<rootDir>/src", "<rootDir>/example"],
testMatch: [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
"^.+\\.js$": "babel-jest"
},
automock: false,
setupFiles: ["./setupTests.js"],
preset: "ts-jest/presets/js-with-babel"
};
21 changes: 21 additions & 0 deletions jest.rn.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// jest.config.js
const { defaults: tsjPreset } = require("ts-jest/presets");

module.exports = {
...tsjPreset,
preset: "react-native",
transform: {
...tsjPreset.transform,
"\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
},
globals: {
"ts-jest": {
babelConfig: true,
},
},
testPathIgnorePatterns: ["<rootDir>/src/__tests__/useTrigger.tsx"],
// This is the only part which you can keep
// from the above linked tutorial's config:
cacheDirectory: ".jest/cache",
setupFiles: ["<rootDir>/setupTests.rn.js"],
};
34 changes: 22 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@harelpls/use-pusher",
"version": "4.1.5",
"version": "5.0.0",
"description": "A wrapper around pusher-js for easy-as hooks in React.",
"author": "@mayteio",
"keywords": [
Expand All @@ -16,7 +16,8 @@
"license": "MIT",
"repository": "https://github.com/mayteio/use-pusher",
"files": [
"dist"
"dist",
"react-native"
],
"main": "dist/index.js",
"module": "dist/index.es.js",
Expand All @@ -27,42 +28,51 @@
"npm": ">=5"
},
"scripts": {
"test": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"build": "rimraf dist && rollup -c",
"test": "cross-env CI=1 yarn test:web && yarn test:rn",
"test:web": "jest --config=jest.config.js",
"test:rn": "JEST_ENV=rn jest --config=jest.rn.config.js",
"build": "rimraf dist react-native && rollup -c",
"start": "rollup -c -w",
"types": "dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --external-imports pusher-js",
"docs": "typedoc --options ./typedoc.js ./src",
"release": "yarn test && yarn build && yarn types && yarn publish && ntl deploy"
},
"dependencies": {
"@react-native-community/netinfo": "^5.9.3",
"dequal": "^1.0.0",
"invariant": "^2.2.4",
"pusher-js": "^5.1.0"
"jest": "^25.1.0",
"pusher-js": "^6.0.3"
},
"peerDependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.5.5",
"@babel/core": "^7.8.6",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-transform-flow-strip-types": "^7.10.1",
"@babel/plugin-transform-object-assign": "^7.10.3",
"@babel/preset-env": "^7.8.6",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.3.1",
"@testing-library/react": "^9.1.2",
"@testing-library/react-hooks": "^2.0.1",
"@testing-library/react-native": "^5.0.3",
"@types/invariant": "^2.2.30",
"@types/jest": "^24.0.18",
"@types/react": "^16.7.22",
"@types/react-native": "^0.62.13",
"babel-jest": "^25.1.0",
"cross-env": "^5.2.0",
"dts-bundle-generator": "^3.2.0",
"gh-pages": "^2.0.1",
"jest-fetch-mock": "^2.1.2",
"pusher-js": "^5.1.0",
"pusher-js-mock": "mayteio/pusher-js-mock#feature/presence-channels-release",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "^3.0.1",
"react-native": "^0.62.2",
"react-native-typescript-transformer": "^1.2.13",
"react-test-renderer": "^16.9.0",
"rimraf": "^3.0.2",
"rollup": "^1.20.0",
Expand All @@ -73,8 +83,8 @@
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-typescript2": "^0.22.1",
"rollup-plugin-url": "^2.1.0",
"ts-jest": "^24.0.2",
"ts-jest": "^25.2.1",
"typedoc": "^0.16.9",
"typescript": "^3.2.4"
"typescript": "^3.8.3"
}
}
8 changes: 8 additions & 0 deletions rn-cli.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
getTransformModulePath() {
return require.resolve("react-native-typescript-transformer");
},
getSourceExts() {
return ["ts", "tsx"];
},
};
Loading

0 comments on commit d03d5f0

Please sign in to comment.