Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

global-input-react

Package Overview
Dependencies
Maintainers
1
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-input-react - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

dist/GlobalInputReceiver.js

227

dist/index.js
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "react", "global-input-message", "qrcode.react"], factory);
define(["exports", "./GlobalInputReceiver", "./GlobalInputSender"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("react"), require("global-input-message"), require("qrcode.react"));
factory(exports, require("./GlobalInputReceiver"), require("./GlobalInputSender"));
} else {

@@ -10,6 +10,6 @@ var mod = {

};
factory(mod.exports, global.react, global.globalInputMessage, global.qrcode);
factory(mod.exports, global.GlobalInputReceiver, global.GlobalInputSender);
global.index = mod.exports;
}
})(this, function (exports, _react, _globalInputMessage, _qrcode) {
})(this, function (exports, _GlobalInputReceiver, _GlobalInputSender) {
"use strict";

@@ -22,5 +22,5 @@

var _react2 = _interopRequireDefault(_react);
var _GlobalInputReceiver2 = _interopRequireDefault(_GlobalInputReceiver);
var _qrcode2 = _interopRequireDefault(_qrcode);
var _GlobalInputSender2 = _interopRequireDefault(_GlobalInputSender);

@@ -33,215 +33,4 @@ function _interopRequireDefault(obj) {

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
}
var GlobalInputReceiver = exports.GlobalInputReceiver = function (_Component) {
_inherits(GlobalInputReceiver, _Component);
function GlobalInputReceiver() {
_classCallCheck(this, GlobalInputReceiver);
return _possibleConstructorReturn(this, (GlobalInputReceiver.__proto__ || Object.getPrototypeOf(GlobalInputReceiver)).apply(this, arguments));
}
_createClass(GlobalInputReceiver, [{
key: "getGlobalInputConfig",
value: function getGlobalInputConfig() {
return {};
}
}, {
key: "onInput",
value: function onInput(inputMessage) {
this.getGlobalInputConfig().metadata[inputMessage.data.index].onInput(inputMessage.data.value);
}
}, {
key: "connectToMessenger",
value: function connectToMessenger() {
this.connector = (0, _globalInputMessage.createMessageConnector)();
var config = this.getGlobalInputConfig();
var options = { onInput: this.onInput.bind(this) };
if (this.props.onRegistered) {
options.onRegistered = this.props.onRegistered;
}
if (config.metadata) {
options.metadata = config.metadata.map(function (m) {
var metadata = Object.assign({}, m);
if (metadata.onInput) {
delete metadata.onInput;
}
return metadata;
});
}
console.log("new metadata:" + options.metadata);
if (config.url) {
options.url = config.url;
}
if (config.onInput) {
options.onInput = config.onInput;
}
this.connector.connect(options);
}
}, {
key: "displayInputCode",
value: function displayInputCode() {
var inputCodeData = JSON.stringify(this.connector.buildInputCodeData());
return _react2.default.createElement(_qrcode2.default, { value: inputCodeData });
}
}, {
key: "disconnectFromMessenger",
value: function disconnectFromMessenger() {
this.connector.disconnect();
}
}, {
key: "componentWillMount",
value: function componentWillMount() {
this.connectToMessenger();
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.disconnectFromMessenger();
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return GlobalInputReceiver;
}(_react.Component);
var GlobalInputSender = exports.GlobalInputSender = function (_Component2) {
_inherits(GlobalInputSender, _Component2);
function GlobalInputSender(props) {
_classCallCheck(this, GlobalInputSender);
var _this2 = _possibleConstructorReturn(this, (GlobalInputSender.__proto__ || Object.getPrototypeOf(GlobalInputSender)).call(this, props));
_this2.connector = (0, _globalInputMessage.createMessageConnector)();
return _this2;
}
_createClass(GlobalInputSender, [{
key: "createUUID",
value: function createUUID() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
function getTimeValue() {
return new Date().getTime();
}
return s4() + '-' + getTimeValue();
}
}, {
key: "disconnect",
value: function disconnect() {
this.connector.disconnect();
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.disconnect();
}
}, {
key: "componentWillMount",
value: function componentWillMount() {
var codedata = this.props.codedata;
this.processCodeData(codedata);
}
}, {
key: "processCodeData",
value: function processCodeData(codedata) {
var that = this;
var options = {
onInputPermissionResult: this.onInputPermissionResult.bind(this)
};
this.connector.processCodeData(options, codedata);
}
}, {
key: "onInputPermissionResult",
value: function onInputPermissionResult(message) {
console.log("*******sender received the onInputPermissionResult****");
var globalInputdata = message.metadata;
globalInputdata.forEach(function (dataitem) {
if (!dataitem.value) {
dataitem.value = "";
}
});
this.setState(Object.assign({}, this.state, { globalInputdata: globalInputdata }));
}
}, {
key: "setGlobalInputData",
value: function setGlobalInputData(index, value) {
if (!this.state.globalInputdata) {
console.log("ignored:" + index + ":" + value);
return;
}
var globalInputdata = this.state.globalInputdata.slice(0);
console.log("setting index:" + index + "value:" + value);
globalInputdata[index].value = value;
var message = {
id: this.createUUID,
value: value,
index: index
};
this.connector.sendInputMessage(message);
this.setState(Object.assign({}, this.state, { globalInputdata: globalInputdata }));
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return GlobalInputSender;
}(_react.Component);
exports.GlobalInputReceiver = _GlobalInputReceiver2.default;
exports.GlobalInputSender = _GlobalInputSender2.default;
});
{
"name": "global-input-react",
"version": "1.0.12",
"version": "1.0.13",
"description": "global input react component",

@@ -51,3 +51,3 @@ "repository": {

"dependencies": {
"global-input-message": "^1.2.3",
"global-input-message": "^1.2.4",
"qrcode.react": "^0.7.1",

@@ -54,0 +54,0 @@ "react": "~0.14.8 || ^15.0.0|| ^16.0.0"

@@ -7,4 +7,2 @@ # Global Input Software

This project is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
/*

@@ -11,0 +9,0 @@ * Copyright 2017 Dr. Dilshat Hewzulla (hewzulla@gmail.com)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc