Socket
Socket
Sign inDemoInstall

lesca-facebook-share

Package Overview
Dependencies
1
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

dist/bundle.js

88

lib/index.js

@@ -8,7 +8,89 @@ "use strict";

var _share = _interopRequireDefault(require("./share"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _default = _share["default"];
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _require = require('./constants'),
userAgent = _require.userAgent,
device = _require.device,
root = _require.root;
var defaultOption = {
v: 'v8.0',
onload: function onload() {}
};
var property = {};
var install = function install(uid, options) {
var opt = _objectSpread(_objectSpread({}, defaultOption), options);
var onload = opt.onload,
v = opt.v;
property.id = uid;
window.fbAsyncInit = function () {
FB.init({
appId: uid,
cookie: true,
xfbml: true,
version: v
});
onload === null || onload === void 0 ? void 0 : onload();
};
(function (d, s, id) {
var js,
fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = 'https://connect.facebook.net/en_US/sdk.js';
fjs.parentNode.insertBefore(js, fjs);
})(document, 'script', 'facebook-jssdk');
};
var share = function share(_ref) {
var redirect_uri = _ref.redirect_uri,
url = _ref.url,
hashtag = _ref.hashtag,
quote = _ref.quote;
var id = property.id;
if (!id) {
console.log('need to install');
return;
}
if (userAgent()) {
var p = {
method: 'share',
href: url
};
if (hashtag) p.hashtag = '#' + hashtag;
if (quote) p.quote = quote;
FB.ui(p, function () {
if (redirect_uri) window.location.replace(redirect_uri);
});
} else {
var u = ["https://www.facebook.com/dialog/share?app_id=".concat(id, "&href=").concat(encodeURIComponent(url))];
if (redirect_uri) u.push("&redirect_uri=".concat(encodeURIComponent(redirect_uri)));
if (hashtag) u.push("&hashtag=%23".concat(encodeURIComponent(hashtag)));
if (quote) u.push("&quote=".concat(encodeURIComponent(quote)));
if (redirect_uri) window.location.href = u.join('');else {
if (device() === 'desktop') window.open(u);else window.location.href = u.join('') + "&redirect_uri=".concat(encodeURIComponent(root()));
}
}
};
var Facebook = {
install: install,
share: share
};
var _default = Facebook;
exports["default"] = _default;

57

package.json
{
"name": "lesca-facebook-share",
"version": "1.0.3",
"description": "for facebook share only",
"version": "1.0.4",
"description": "Simple facebook share",
"main": "lib/index.js",

@@ -9,7 +9,8 @@ "scripts": {

"watch": "babel src/lib -w -d lib --copy-files",
"build": "babel src/lib -d lib --copy-files",
"op": "babel src/lib -d lib --copy-files",
"dev": "concurrently \"npm run lib:watch\" \"npm run docs\"",
"rm": "rm -rf node_modules/ package-lock.json",
"deploy": "gh-pages -d dist",
"docs:prod": "webpack --mode production"
"docs:prod": "webpack --mode production",
"build": "NODE_ENV=production webpack"
},

@@ -19,28 +20,30 @@ "keywords": [

"衝康吉",
"jameshsu1125"
"jameshsu1125",
"Facebook share"
],
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.0.0-beta.46",
"@babel/core": "^7.0.0-beta.46",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.46",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.46",
"@babel/preset-env": "^7.0.0-beta.46",
"@babel/preset-react": "^7.0.0-beta.46",
"autoprefixer": "^10.0.2",
"babel-loader": "^8.0.0-beta.0",
"concurrently": "^5.3.0",
"css-loader": "^1.0.0",
"@babel/cli": "^7.16.8",
"@babel/core": "^7.16.12",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.16.7",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"autoprefixer": "^10.4.2",
"babel-loader": "^8.2.3",
"concurrently": "^7.0.0",
"css-loader": "^6.5.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^3.2.0",
"less": "^3.12.2",
"less-loader": "^7.1.0",
"postcss": "^8.1.7",
"postcss-loader": "^4.0.4",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"style-loader": "^0.23.1",
"webpack": "^4.6.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.3"
"gh-pages": "^3.2.3",
"html-webpack-plugin": "^5.5.0",
"less": "^4.1.2",
"less-loader": "^10.2.0",
"postcss": "^8.4.5",
"postcss-loader": "^6.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"style-loader": "^3.3.1",
"webpack": "^5.67.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.3"
},

@@ -54,4 +57,4 @@ "author": "jamehsu1125 <jameshsu1125@gmail.com>",

"dependencies": {
"mobile-detect": "^1.4.4"
"mobile-detect": "^1.4.5"
}
}

@@ -1,2 +0,2 @@

[![dev by JamesHsu](https://img.shields.io/badge/Dev%20by-Jameshsu1125-green)](https://github.com/jameshsu1125/) [![made in Taiwan](https://img.shields.io/badge/Made%20in-Taiwan-orange)](https://github.com/jameshsu1125/)
[![dev by JamesHsu](https://img.shields.io/badge/Dev%20by-Jameshsu1125-green)](https://github.com/jameshsu1125/) [![made in Taiwan](https://img.shields.io/badge/Made%20in-Taiwan-orange)](https://github.com/jameshsu1125/) [![npm](https://img.shields.io/badge/npm-Jameshsu1125-red)](https://www.npmjs.com/~jameshsu1125)

@@ -6,5 +6,9 @@ # Installation

```sh
$ npm install lesca-facebook-share --save
npm install lesca-facebook-share --save
```
# Demo
[Live Demo](https://jameshsu1125.github.io/lesca-facebook-share/)
# Usage

@@ -15,13 +19,8 @@

Facebook.install('facebook-app-id', {
onload: () => {
console.log(FB);
},
});
Facebook.install('facebook-app-id'); // get one => https://developers.facebook.com/apps/
function share() {
Facebook.share({
url: 'https://lesca.net',
url: 'https://github.com/jameshsu1125/lesca-facebook-share',
quote: `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`,
hashtag: 'Lesca',
hashtag: 'lesca-facebook-share',
});

@@ -35,10 +34,8 @@ }

| method | options | description | default |
| :------------------------------------------- | :----------: | :--------------------------: | ------------: |
| install(uid, {v, onload }) | uid | facebook app id | |
| | v | version of facebook sdk.js | 8.0 |
| | onload | get FB function | |
| share({ url, hashtag, quote, redirect_uri }) | url | og:meta source | |
| | hashtag | hashtag | |
| | quote | quote | |
| | redirect_uri | !! mobile device necessary | location root |
| method | options | description | default |
| :------------------------------------------- | :----------: | :------------------------: | ------------: |
| install(uid) | uid | facebook app id | |
| share({ url, hashtag, quote, redirect_uri }) | url | og:meta source | |
| | hashtag | hashtag | |
| | quote | quote | |
| | redirect_uri | !! mobile device necessary | location root |

@@ -1,2 +0,65 @@

import Share from './share';
export default Share;
const { userAgent, device, root } = require('./constants');
const defaultOption = { v: 'v8.0', onload: () => {} };
const property = {};
const install = (uid, options) => {
const opt = { ...defaultOption, ...options };
const { onload, v } = opt;
property.id = uid;
window.fbAsyncInit = function () {
FB.init({
appId: uid,
cookie: true,
xfbml: true,
version: v,
});
onload?.();
};
(function (d, s, id) {
var js,
fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = 'https://connect.facebook.net/en_US/sdk.js';
fjs.parentNode.insertBefore(js, fjs);
})(document, 'script', 'facebook-jssdk');
};
const share = ({ redirect_uri, url, hashtag, quote }) => {
const { id } = property;
if (!id) {
console.log('need to install');
return;
}
if (userAgent()) {
const p = {
method: 'share',
href: url,
};
if (hashtag) p.hashtag = '#' + hashtag;
if (quote) p.quote = quote;
FB.ui(p, () => {
if (redirect_uri) window.location.replace(redirect_uri);
});
} else {
const u = [`https://www.facebook.com/dialog/share?app_id=${id}&href=${encodeURIComponent(url)}`];
if (redirect_uri) u.push(`&redirect_uri=${encodeURIComponent(redirect_uri)}`);
if (hashtag) u.push(`&hashtag=%23${encodeURIComponent(hashtag)}`);
if (quote) u.push(`&quote=${encodeURIComponent(quote)}`);
if (redirect_uri) window.location.href = u.join('');
else {
if (device() === 'desktop') window.open(u);
else window.location.href = u.join('') + `&redirect_uri=${encodeURIComponent(root())}`;
}
}
};
const Facebook = { install, share };
export default Facebook;

@@ -7,3 +7,3 @@ const path = require('path');

output: {
path: path.join(__dirname, 'docs'),
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',

@@ -31,6 +31,5 @@ },

devServer: {
contentBase: path.join(__dirname, 'docs'),
port: 8000,
stats: 'minimal',
https: true,
},
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc