lesca-facebook-share
Advanced tools
Comparing version 1.0.9 to 1.1.0
183
lib/index.js
@@ -1,97 +0,90 @@ | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
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 _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) { (0, _defineProperty2["default"])(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 _require = require('./constants'), | ||
userAgent = _require.userAgent, | ||
device = _require.device, | ||
root = _require.root; | ||
var defaultOption = { | ||
v: 'v8.0', | ||
onload: function onload() {} | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
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 | ||
define(["require", "exports", "./mise"], function (require, exports, mise_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var defaultOption = { v: 'v8.0', onload: function () { } }; | ||
var property = { id: '' }; | ||
var install = function (uid, options) { | ||
var opt = __assign(__assign({}, defaultOption), options); | ||
var onload = opt.onload, v = opt.v; | ||
property.id = uid; | ||
window.fbAsyncInit = function () { | ||
window.FB.init({ | ||
appId: uid, | ||
cookie: true, | ||
xfbml: true, | ||
version: v, | ||
}); | ||
onload === null || onload === void 0 ? void 0 : onload(); | ||
}; | ||
(function (d, s, id) { | ||
var _a; | ||
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'; | ||
(_a = fjs.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(js, fjs); | ||
})(document, 'script', 'facebook-jssdk'); | ||
}; | ||
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(""e=".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; | ||
var defaultShareOptions = { | ||
method: 'share', | ||
href: '', | ||
}; | ||
var share = function (shareOptions) { | ||
if (shareOptions === void 0) { shareOptions = defaultShareOptions; } | ||
var href = shareOptions.href, redirect_uri = shareOptions.redirect_uri, hashtag = shareOptions.hashtag, quote = shareOptions.quote; | ||
var id = property.id; | ||
if (!id) { | ||
console.log('need to install'); | ||
return; | ||
} | ||
if ((0, mise_1.userAgent)()) { | ||
var p = { | ||
method: 'share', | ||
href: href, | ||
}; | ||
if (hashtag) | ||
p.hashtag = '#' + hashtag; | ||
if (quote) | ||
p.quote = quote; | ||
window.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(href)), | ||
]; | ||
if (redirect_uri) | ||
u.push("&redirect_uri=".concat(encodeURIComponent(redirect_uri))); | ||
if (hashtag) | ||
u.push("&hashtag=%23".concat(encodeURIComponent(hashtag))); | ||
if (quote) | ||
u.push(""e=".concat(encodeURIComponent(quote))); | ||
if (redirect_uri) | ||
window.location.href = u.join(''); | ||
else { | ||
if ((0, mise_1.device)() === 'desktop') | ||
window.open(u[0]); | ||
else | ||
window.location.href = u.join('') + "&redirect_uri=".concat(encodeURIComponent((0, mise_1.root)())); | ||
} | ||
} | ||
}; | ||
var Facebook = { install: install, share: share }; | ||
exports.default = Facebook; | ||
}); |
{ | ||
"name": "lesca-facebook-share", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "Simple facebook share", | ||
@@ -8,9 +8,9 @@ "main": "lib/index.js", | ||
"start": "webpack-dev-server --mode development", | ||
"watch": "babel src/lib -w -d lib --copy-files", | ||
"op": "babel src/lib -d lib --copy-files", | ||
"dev": "concurrently \"npm run watch\" \"npm run start\"", | ||
"watch": "babel --watch src/lib --out-dir lib --extensions '.ts,.tsx'", | ||
"build": "NODE_ENV=production webpack", | ||
"deploy": "gh-pages -d dist", | ||
"tsc": "npx tsc --watch", | ||
"dev": "concurrently \"npm run watch\" \"npm run tsc\" \"npm run start\"", | ||
"rm": "rm -rf node_modules/ package-lock.json", | ||
"deploy": "gh-pages -d dist", | ||
"docs:prod": "webpack --mode production", | ||
"build": "NODE_ENV=production webpack" | ||
"op": "babel src/lib -d lib --copy-files" | ||
}, | ||
@@ -25,35 +25,41 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/cli": "^7.17.6", | ||
"@babel/core": "^7.17.9", | ||
"@babel/plugin-proposal-class-properties": "^7.16.7", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.17.3", | ||
"@babel/plugin-transform-runtime": "^7.17.0", | ||
"@babel/preset-env": "^7.16.11", | ||
"@babel/preset-react": "^7.16.7", | ||
"@emotion/react": "^11.9.0", | ||
"@emotion/styled": "^11.8.1", | ||
"@mui/icons-material": "^5.6.0", | ||
"@mui/material": "^5.6.0", | ||
"autoprefixer": "^10.4.4", | ||
"babel-loader": "^8.2.4", | ||
"concurrently": "^7.1.0", | ||
"@babel/cli": "^7.18.6", | ||
"@babel/core": "^7.18.6", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.18.6", | ||
"@babel/plugin-transform-runtime": "^7.18.6", | ||
"@babel/preset-env": "^7.18.6", | ||
"@babel/preset-react": "^7.18.6", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@emotion/react": "^11.9.3", | ||
"@emotion/styled": "^11.9.3", | ||
"@mui/icons-material": "^5.8.4", | ||
"@mui/material": "^5.8.6", | ||
"autoprefixer": "^10.4.7", | ||
"babel-loader": "^8.2.5", | ||
"concurrently": "^7.2.2", | ||
"css-loader": "^6.7.1", | ||
"file-loader": "^6.2.0", | ||
"gh-pages": "^3.2.3", | ||
"gh-pages": "^4.0.0", | ||
"html-react-parser": "^2.0.0", | ||
"html-webpack-plugin": "^5.5.0", | ||
"less": "^4.1.2", | ||
"less-loader": "^10.2.0", | ||
"postcss": "^8.4.12", | ||
"postcss-loader": "^6.2.1", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0", | ||
"less": "^4.1.3", | ||
"less-loader": "^11.0.0", | ||
"less-vars-to-js": "^1.3.0", | ||
"postcss": "^8.4.14", | ||
"postcss-loader": "^7.0.0", | ||
"prismjs": "^1.28.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"style-loader": "^3.3.1", | ||
"less-vars-to-js": "^1.3.0", | ||
"webpack": "^5.71.0", | ||
"webpack-cli": "^4.9.2", | ||
"webpack-dev-server": "^4.8.1", | ||
"html-react-parser": "^1.4.10", | ||
"prismjs": "^1.27.0" | ||
"ts-loader": "^9.3.1", | ||
"typescript": "^4.7.4", | ||
"webpack": "^5.73.0", | ||
"webpack-cli": "^4.10.0", | ||
"webpack-dev-server": "^4.9.3" | ||
}, | ||
"author": "jamehsu1125 <jameshsu1125@gmail.com>" | ||
"author": "jamehsu1125 <jameshsu1125@gmail.com>", | ||
"dependencies": { | ||
"mobile-detect": "^1.4.5" | ||
} | ||
} |
@@ -1,7 +0,8 @@ | ||
[![NPM](https://img.shields.io/badge/NPM-ba443f?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/) | ||
[![React](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/en/) | ||
[![React](https://img.shields.io/badge/-ReactJs-61DAFB?style=for-the-badge&logo=react&logoColor=white)](https://zh-hant.reactjs.org/) | ||
[![React](https://img.shields.io/badge/Less-1d365d?style=for-the-badge&logo=less&logoColor=white)](https://lesscss.org/) | ||
[![React](https://img.shields.io/badge/Typescript-4277c0?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/) | ||
[![React](https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white)](https://www.w3schools.com/html/) | ||
[![React](https://img.shields.io/badge/-CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white)](https://www.w3schools.com/css/) | ||
[![NPM](https://img.shields.io/badge/NPM-ba443f?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/) | ||
[![React](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/en/) | ||
[![NPM](https://img.shields.io/badge/DEV-Jameshsu1125-9cf?style=for-the-badge)](https://www.npmjs.com/~jameshsu1125) | ||
@@ -35,3 +36,3 @@ | ||
Facebook.share({ | ||
url: 'https://github.com/jameshsu1125/lesca-facebook-share', | ||
href: 'https://github.com/jameshsu1125/lesca-facebook-share', | ||
quote: 'use share facebook api simply', | ||
@@ -47,6 +48,6 @@ hashtag: 'lesca_facebook_share', | ||
| method | description | return | | ||
| :--------------------------------------------------------------------------------------------------- | :---------------------------: | -----: | | ||
| .install(uid: _string_) | initialize with uid | void | | ||
| .share({ **url**: _string_, **hashtag**: _string_, **quote**: _string_, **redirect_url**: _string_}) | [parmaters](#share-parmaters) | | | ||
| method | description | return | | ||
| :---------------------------------------------------------------------------------------------------- | :---------------------------: | -----: | | ||
| .install(uid: _string_) | initialize with uid | void | | ||
| .share({ **href**: _string_, **hashtag**: _string_, **quote**: _string_, **redirect_url**: _string_}) | [parmaters](#share-parmaters) | | | ||
@@ -57,3 +58,3 @@ #### share parmaters | ||
| :------------------------- | :---------------------------------: | ------------: | | ||
| **url**: _string_ | share url | | | ||
| **href**: _string_ | share url | | | ||
| **hashtag**: _string_ | hashtag | void | | ||
@@ -60,0 +61,0 @@ | **quote**: _string_ | quote | void | |
@@ -10,3 +10,3 @@ import { Button, ButtonGroup } from '@mui/material'; | ||
const parameters = { | ||
url: 'https://www.npmjs.com/package/lesca-facebook-share', | ||
href: 'https://www.npmjs.com/package/lesca-facebook-share', | ||
quote: 'use share facebook api simply', | ||
@@ -13,0 +13,0 @@ hashtag: 'this_is_hashtag', |
@@ -21,3 +21,3 @@ import { Button, ButtonGroup } from '@mui/material'; | ||
code: `Facebook.share({ | ||
url: 'https://github.com/jameshsu1125/lesca-facebook-share', | ||
href: 'https://github.com/jameshsu1125/lesca-facebook-share', | ||
quote: 'use share facebook api simply', | ||
@@ -24,0 +24,0 @@ hashtag: 'lesca_facebook_share', |
const path = require('path'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const Meta = require('./template/template.meta'); | ||
const template = './template/template.meta'; | ||
const Meta = require(template); | ||
@@ -13,6 +14,27 @@ module.exports = { | ||
rules: [ | ||
{ test: /\.(js|jsx)$/, use: 'babel-loader', exclude: /node_modules/ }, | ||
{ test: /\.css$/, use: ['style-loader', 'css-loader', 'postcss-loader'] }, | ||
{ test: /\.less$/, use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'] }, | ||
{ | ||
test: /\.(js|jsx)$/, | ||
use: 'babel-loader', | ||
exclude: /node_modules/, | ||
}, | ||
{ | ||
test: /\.tsx?$/, | ||
use: ['babel-loader', 'ts-loader'], | ||
exclude: /node_modules/, | ||
}, | ||
{ | ||
test: /\.(less|css)$/, | ||
use: [ | ||
'style-loader', | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
esModule: false, | ||
}, | ||
}, | ||
'postcss-loader', | ||
'less-loader', | ||
], | ||
}, | ||
{ | ||
test: /\.(png|jpg|gif|svg)$/, | ||
@@ -35,3 +57,3 @@ use: [ | ||
resolve: { | ||
extensions: ['.js', '.jsx'], | ||
extensions: ['.tsx', '.ts', '.js', '.jsx'], | ||
}, | ||
@@ -38,0 +60,0 @@ devServer: { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24227
30
531
64
1
34
2
1
+ Addedmobile-detect@^1.4.5
+ Addedmobile-detect@1.4.5(transitive)