sunmi-bridge
Advanced tools
+39
-49
@@ -1,26 +0,12 @@ | ||
| 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); | ||
| }; | ||
| import { UAParser } from 'ua-parser-js'; | ||
| var SunmiJSBridge = /** @class */ (function () { | ||
| function SunmiJSBridge() { | ||
| var parser = new UAParser(); | ||
| SunmiJSBridge.ua = parser.getResult(); | ||
| SunmiJSBridge.call = SunmiJSBridge.createBridgeCall(); | ||
| } | ||
| SunmiJSBridge.createBridgeCall = function () { | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const ua_parser_js_1 = require("ua-parser-js"); | ||
| class SunmiJSBridge { | ||
| static createBridgeCall() { | ||
| if (!window.webkit && !window.SunmiJSBridge) { | ||
| return function () { return null; }; | ||
| return () => null; | ||
| } | ||
| return function (fn, arg) { | ||
| var message = arg ? JSON.stringify(arg) : ''; | ||
| var result; | ||
| return (fn, arg) => { | ||
| const message = arg ? JSON.stringify(arg) : ''; | ||
| let result; | ||
| switch (SunmiJSBridge.ua.os.name) { | ||
@@ -55,35 +41,40 @@ case 'iOS': | ||
| }; | ||
| }; | ||
| SunmiJSBridge.prototype.log = function (arg) { | ||
| } | ||
| constructor() { | ||
| const parser = new ua_parser_js_1.UAParser(); | ||
| SunmiJSBridge.ua = parser.getResult(); | ||
| SunmiJSBridge.call = SunmiJSBridge.createBridgeCall(); | ||
| } | ||
| log(arg) { | ||
| SunmiJSBridge.call('log', arg); | ||
| }; | ||
| SunmiJSBridge.prototype.openMiniProgram = function (params) { | ||
| SunmiJSBridge.call('openMiniProgram', __assign({}, params)); | ||
| }; | ||
| } | ||
| openMiniProgram(params) { | ||
| SunmiJSBridge.call('openMiniProgram', Object.assign({}, params)); | ||
| } | ||
| // 打开新窗口 | ||
| SunmiJSBridge.prototype.pushWindow = function (params) { | ||
| pushWindow(params) { | ||
| SunmiJSBridge.call('pushWindow', params); | ||
| }; | ||
| } | ||
| // 打开新窗口 | ||
| SunmiJSBridge.prototype.pushWindowWithClose = function (params) { | ||
| pushWindowWithClose(params) { | ||
| SunmiJSBridge.call('pushWindowWithClose', params); | ||
| }; | ||
| } | ||
| // 拨打电话 | ||
| SunmiJSBridge.prototype.callUp = function (phone) { | ||
| SunmiJSBridge.call('callUp', { phone: phone }); | ||
| }; | ||
| callUp(phone) { | ||
| SunmiJSBridge.call('callUp', { phone }); | ||
| } | ||
| // 显示loading | ||
| SunmiJSBridge.prototype.showLoading = function (params) { | ||
| showLoading(params) { | ||
| SunmiJSBridge.call('showLoading', params); | ||
| }; | ||
| SunmiJSBridge.prototype.hideLoading = function () { | ||
| } | ||
| hideLoading() { | ||
| SunmiJSBridge.call('hideLoading'); | ||
| }; | ||
| SunmiJSBridge.prototype.showToast = function (params) { | ||
| } | ||
| showToast(params) { | ||
| SunmiJSBridge.call('showToast', params); | ||
| }; | ||
| SunmiJSBridge.prototype.hideToast = function () { | ||
| } | ||
| hideToast() { | ||
| SunmiJSBridge.call('hideToast'); | ||
| }; | ||
| SunmiJSBridge.prototype.getUserInfo = function () { | ||
| } | ||
| getUserInfo() { | ||
| switch (SunmiJSBridge.ua.os.name) { | ||
@@ -109,5 +100,4 @@ // iOS兼容 | ||
| } | ||
| }; | ||
| return SunmiJSBridge; | ||
| }()); | ||
| export { SunmiJSBridge }; | ||
| } | ||
| } | ||
| exports.SunmiJSBridge = SunmiJSBridge; |
+3
-4
| { | ||
| "name": "sunmi-bridge", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "description": "this is a javascript bridge", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "build": "tsc" | ||
| "build": " rm -rf dist/ && tsc" | ||
| }, | ||
@@ -25,4 +25,3 @@ "repository": { | ||
| "ua-parser-js": "^0.7.19" | ||
| }, | ||
| "gitHead": "9836750c32c592e0b16fef5481562e25bd498ede" | ||
| } | ||
| } |
+2
-2
| { | ||
| "compilerOptions": { | ||
| "target": "es5", | ||
| "target": "es6", | ||
| "moduleResolution": "node", | ||
| "module": "esnext", | ||
| "module": "none", | ||
| "declaration": true, | ||
@@ -7,0 +7,0 @@ "outDir": "./dist", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
5961
-11.74%169
-5.59%1
Infinity%