working on making the file upload work over websocket and json

This commit is contained in:
2018-01-17 23:27:27 -05:00
parent 8e72ffb917
commit 06e9317c9a
7876 changed files with 385003 additions and 7978 deletions

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2015 Zilverline B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,66 @@
{
"_from": "react-tap-event-plugin@^2.0.1",
"_id": "react-tap-event-plugin@2.0.1",
"_inBundle": false,
"_integrity": "sha1-MWvrO8ZVbinshppyk+icgmqQdNI=",
"_location": "/material-ui-upload/react-tap-event-plugin",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "react-tap-event-plugin@^2.0.1",
"name": "react-tap-event-plugin",
"escapedName": "react-tap-event-plugin",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/material-ui-upload"
],
"_resolved": "https://registry.npmjs.org/react-tap-event-plugin/-/react-tap-event-plugin-2.0.1.tgz",
"_shasum": "316beb3bc6556e29ec869a7293e89c826a9074d2",
"_spec": "react-tap-event-plugin@^2.0.1",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\goTorrentWebUI\\node_modules\\material-ui-upload",
"bugs": {
"url": "https://github.com/zilverline/react-tap-event-plugin/issues"
},
"bundleDependencies": false,
"dependencies": {
"fbjs": "^0.8.6"
},
"deprecated": false,
"description": "Facebook's TapEventPlugin, temporarily available on npm until its made public in their repo",
"files": [
"src/"
],
"homepage": "http://facebook.github.io/react",
"keywords": [
"TapEventPlugin",
"react",
"touch",
"delay",
"300ms",
"react-tap-event-plugin"
],
"licenses": [
{
"type": "Apache-2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"main": "src/injectTapEventPlugin.js",
"name": "react-tap-event-plugin",
"peerDependencies": {
"react": "^15.4.0-0",
"react-dom": "^15.4.0-0"
},
"repository": {
"type": "git",
"url": "git://github.com/zilverline/react-tap-event-plugin.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "2.0.1"
}

View File

@@ -0,0 +1,171 @@
/**
* Copyright 2013-2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @providesModule TapEventPlugin
* @typechecks static-only
*/
"use strict";
var EventConstants = require('react-dom/lib/EventConstants');
var EventPluginUtils = require('react-dom/lib/EventPluginUtils');
var EventPropagators = require('react-dom/lib/EventPropagators');
var SyntheticUIEvent = require('react-dom/lib/SyntheticUIEvent');
var TouchEventUtils = require('./TouchEventUtils');
var ViewportMetrics = require('react-dom/lib/ViewportMetrics');
var keyOf = require('fbjs/lib/keyOf');
var topLevelTypes = EventConstants.topLevelTypes;
var isStartish = EventPluginUtils.isStartish;
var isEndish = EventPluginUtils.isEndish;
var isTouch = function(topLevelType) {
var touchTypes = [
'topTouchCancel',
'topTouchEnd',
'topTouchStart',
'topTouchMove'
];
return touchTypes.indexOf(topLevelType) >= 0;
}
/**
* Number of pixels that are tolerated in between a `touchStart` and `touchEnd`
* in order to still be considered a 'tap' event.
*/
var tapMoveThreshold = 10;
var ignoreMouseThreshold = 750;
var startCoords = {x: null, y: null};
var lastTouchEvent = null;
var Axis = {
x: {page: 'pageX', client: 'clientX', envScroll: 'currentPageScrollLeft'},
y: {page: 'pageY', client: 'clientY', envScroll: 'currentPageScrollTop'}
};
function getAxisCoordOfEvent(axis, nativeEvent) {
var singleTouch = TouchEventUtils.extractSingleTouch(nativeEvent);
if (singleTouch) {
return singleTouch[axis.page];
}
return axis.page in nativeEvent ?
nativeEvent[axis.page] :
nativeEvent[axis.client] + ViewportMetrics[axis.envScroll];
}
function getDistance(coords, nativeEvent) {
var pageX = getAxisCoordOfEvent(Axis.x, nativeEvent);
var pageY = getAxisCoordOfEvent(Axis.y, nativeEvent);
return Math.pow(
Math.pow(pageX - coords.x, 2) + Math.pow(pageY - coords.y, 2),
0.5
);
}
var touchEvents = [
'topTouchStart',
'topTouchCancel',
'topTouchEnd',
'topTouchMove',
];
var dependencies = [
'topMouseDown',
'topMouseMove',
'topMouseUp',
].concat(touchEvents);
var eventTypes = {
touchTap: {
phasedRegistrationNames: {
bubbled: keyOf({onTouchTap: null}),
captured: keyOf({onTouchTapCapture: null})
},
dependencies: dependencies
}
};
var now = (function() {
if (Date.now) {
return Date.now;
} else {
// IE8 support: http://stackoverflow.com/questions/9430357/please-explain-why-and-how-new-date-works-as-workaround-for-date-now-in
return function () {
return +new Date;
}
}
})();
function createTapEventPlugin(shouldRejectClick) {
return {
tapMoveThreshold: tapMoveThreshold,
ignoreMouseThreshold: ignoreMouseThreshold,
eventTypes: eventTypes,
/**
* @param {string} topLevelType Record from `EventConstants`.
* @param {DOMEventTarget} targetInst The listening component root node.
* @param {object} nativeEvent Native browser event.
* @return {*} An accumulation of synthetic events.
* @see {EventPluginHub.extractEvents}
*/
extractEvents: function(
topLevelType,
targetInst,
nativeEvent,
nativeEventTarget
) {
if (!isStartish(topLevelType) && !isEndish(topLevelType)) {
return null;
}
if (isTouch(topLevelType)) {
lastTouchEvent = now();
} else {
if (shouldRejectClick(lastTouchEvent, now())) {
return null;
}
}
var event = null;
var distance = getDistance(startCoords, nativeEvent);
if (isEndish(topLevelType) && distance < tapMoveThreshold) {
event = SyntheticUIEvent.getPooled(
eventTypes.touchTap,
targetInst,
nativeEvent,
nativeEventTarget
);
}
if (isStartish(topLevelType)) {
startCoords.x = getAxisCoordOfEvent(Axis.x, nativeEvent);
startCoords.y = getAxisCoordOfEvent(Axis.y, nativeEvent);
} else if (isEndish(topLevelType)) {
startCoords.x = 0;
startCoords.y = 0;
}
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
}
};
}
module.exports = createTapEventPlugin;

View File

@@ -0,0 +1,42 @@
/**
* Copyright 2013-2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @providesModule TouchEventUtils
*/
var TouchEventUtils = {
/**
* Utility function for common case of extracting out the primary touch from a
* touch event.
* - `touchEnd` events usually do not have the `touches` property.
* http://stackoverflow.com/questions/3666929/
* mobile-sarai-touchend-event-not-firing-when-last-touch-is-removed
*
* @param {Event} nativeEvent Native event that may or may not be a touch.
* @return {TouchesObject?} an object with pageX and pageY or null.
*/
extractSingleTouch: function(nativeEvent) {
var touches = nativeEvent.touches;
var changedTouches = nativeEvent.changedTouches;
var hasTouches = touches && touches.length > 0;
var hasChangedTouches = changedTouches && changedTouches.length > 0;
return !hasTouches && hasChangedTouches ? changedTouches[0] :
hasTouches ? touches[0] :
nativeEvent;
}
};
module.exports = TouchEventUtils;

View File

@@ -0,0 +1,5 @@
module.exports = function(lastTouchEvent, clickTimestamp) {
if (lastTouchEvent && (clickTimestamp - lastTouchEvent) < 750) {
return true;
}
};

View File

@@ -0,0 +1,26 @@
var invariant = require('fbjs/lib/invariant');
var defaultClickRejectionStrategy = require('./defaultClickRejectionStrategy');
var alreadyInjected = false;
module.exports = function injectTapEventPlugin (strategyOverrides) {
strategyOverrides = strategyOverrides || {}
var shouldRejectClick = strategyOverrides.shouldRejectClick || defaultClickRejectionStrategy;
if (process.env.NODE_ENV !== 'production') {
invariant(
!alreadyInjected,
'injectTapEventPlugin(): Can only be called once per application lifecycle.\n\n\
It is recommended to call injectTapEventPlugin() just before you call \
ReactDOM.render(). If you are using an external library which calls injectTapEventPlugin() \
itself, please contact the maintainer as it shouldn\'t be called in library code and \
should be injected by the application.'
)
}
alreadyInjected = true;
require('react-dom/lib/EventPluginHub').injection.injectEventPluginsByName({
'TapEventPlugin': require('./TapEventPlugin.js')(shouldRejectClick)
});
};