diff --git a/README.md b/README.md index 17fac1a..801c01c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This library allows you to asynchronous load multiple social media client API's Supports the following APIs: * Facebook +* Google+ * Tumblr * Twitter * Instagram diff --git a/package-lock.json b/package-lock.json index 854bb2a..301a002 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2016,12 +2016,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2036,17 +2038,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2163,7 +2168,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2175,6 +2181,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2189,6 +2196,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2196,12 +2204,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2220,6 +2230,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2300,7 +2311,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2312,6 +2324,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2433,6 +2446,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/rollup.config.js b/rollup.config.js index 40b2984..c314243 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,7 +2,7 @@ import typescript from 'rollup-plugin-typescript2'; import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; -const filenames = ['facebook', 'instagram', 'tumblr', 'twitter', 'vine', 'index']; +const filenames = ['facebook', 'instagram', 'tumblr', 'twitter', 'vine', 'google/plus', 'index']; export default { input: `src/index.ts`, diff --git a/src/google/plus.ts b/src/google/plus.ts new file mode 100644 index 0000000..fc3bdb1 --- /dev/null +++ b/src/google/plus.ts @@ -0,0 +1,31 @@ +import BaseApi from '../base-api'; + +declare global { + interface Window { + googlePlusOnLoadCallback: any; + } +} + +export default class GooglePlus extends BaseApi { + private gapi?: any; + + static get id() { + return 'google-plus'; + } + + protected async handleLoadApi(): Promise { + return new Promise(async (resolve, reject) => { + window.googlePlusOnLoadCallback = () => { + gapi.load('auth2', () => { + this.gapi = gapi; + resolve(gapi); + }); + }; + try { + await this.loadScript('https://apis.google.com/js/platform.js?onload=googlePlusOnLoadCallback'); + } catch (e) { + reject(e); + } + }); + } +} diff --git a/src/index.ts b/src/index.ts index 300877a..281d8f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,5 +3,6 @@ import Instagram from './instagram'; import Tumblr from './tumblr'; import Twitter from './twitter'; import Vine from './vine'; +import GooglePlus from './google/plus'; -export { Facebook, Instagram, Tumblr, Twitter, Vine }; +export { Facebook, Instagram, Tumblr, Twitter, Vine, GooglePlus };