dependabot did something

This commit is contained in:
horhik 2020-03-17 01:07:55 -04:00
commit 56f4aadfcd
18 changed files with 2372 additions and 650 deletions

View File

@ -1,8 +1,5 @@
module.exports = {
root: true,
extends: '@react-native-community',
plugins: [
react,
react-native
]
};
{
"root": true,
"extends": "@react-native-community",
"plugins": ["react", "react-native", "@react-native-community"]
}

View File

@ -3,9 +3,6 @@ import {Provider} from 'react-redux';
import StartScreen from './src/components/add-anklan-model';
import store from './src/store';
const App = props => {
useEffect(() => {
alert("heeey")
})
return (
<Provider store={store}>
<StartScreen />

View File

@ -6,7 +6,6 @@
*/
module.exports = {
getSourceExts: () => ['jsx', 'js'],
resolver: {
sourceExts: ['jsx', 'js'],
},

View File

@ -1,4 +1,5 @@
{
<<<<<<< HEAD
"name": "ankilan",
"version": "0.0.1",
"private": true,
@ -36,4 +37,48 @@
"jest": {
"preset": "react-native"
}
=======
"name": "ankilan",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"axios": "^0.19.2",
"babel-preset-react-native": "^4.0.1",
"native-base": "^2.13.8",
"node-fetch": "^2.6.0",
"react": "16.13.0",
"react-native": "^0.61.5",
"react-native-ankidroid": "^0.4.0",
"react-native-material-textfield": "^0.16.1",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"remote-redux-devtools": "^0.5.16",
"unirest": "^0.6.0",
"urban-dictionary": "^2.2.1",
"urban-dictionary-client": "^3.0.1"
},
"devDependencies": {
"@babel/core": "^7.8.7",
"@babel/runtime": "^7.8.7",
"@react-native-community/eslint-config": "^0.0.7",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.58.0",
"react-test-renderer": "16.13.0",
"remotedev-rn-debugger": "^0.8.4"
},
"jest": {
"preset": "react-native"
}
>>>>>>> master
}

View File

@ -1 +1 @@
REACT_DEBUGGER="rndebugger-open --open --port 8081" yarn start
REACT_DEBUGGER="rndebugger-open --open --port 8081" yarn start

View File

@ -0,0 +1,57 @@
import {search} from 'urban-dictionary-client';
import {SET_AVAILABLE_API} from '../../constants/api-constants';
const fetch = require('node-fetch');
async function getResFromWordsAPI(word) {
const req = await fetch(`https://wordsapiv1.p.rapidapi.com/words/${word}`, {
method: 'GET',
headers: {
'x-rapidapi-host': 'wordsapiv1.p.rapidapi.com',
'x-rapidapi-key': 'e08b0f617cmsh74abbf9a3b01eb0p164f22jsnabea29750b15',
},
});
const json = await req.json();
const res = {...json, source: 'wordsAPI'};
if (res.success === false) {
// throw new Error(res.message);
return false;
}
return Promise.resolve(res);
}
async function getResFromUrbanDictionary(word) {
const res = await search(word);
if (res.list.length === 0) {
// throw new Error('nothing was found');
return false;
}
return Promise.resolve({...res, word, source: 'urbanDictionary'});
}
const getAvailableApi = (apiArray = []) => {
for (const api of apiArray) {
if (api) {
return api;
}
}
return false;
};
const setAvailableApi = api => ({
type: SET_AVAILABLE_API,
payload: api,
});
export const wordInfo = word => async dispatch => {
try {
const api1 = await getResFromWordsAPI(word);
const api2 = await getResFromUrbanDictionary(word);
const availableApi = getAvailableApi([api1, api2]);
console.log(availableApi);
if (availableApi === false) {
throw new Error('word not found');
}
await dispatch(setAvailableApi(availableApi));
} catch (e) {
console.log(e);
}
};

View File

View File

@ -0,0 +1,13 @@
const getAudio = async url => {
const site = await fetch(url, {
method: 'GET',
headers: {'Content-Type': 'text/html'},
});
const html = await site.text();
const getSrc = new RegExp('<audio.+?src="(.+?)".+?/?>');
const src = html.match(getSrc)[1];
console.log(src);
return src;
};
export default getAudio;

View File

View File

@ -0,0 +1,39 @@
import fetch from 'node-fetch';
import {SET_YANDEX_DICTIONARY_RESPONSE} from '../../constants/api-constants';
const yKey =
'dict.1.1.20200313T141325Z.a8dfc0a8b66fb54c.f84fd712f759aa3abd7a7ecac35ac608181e2865';
const yDictionary = (
word = String,
languages = 'en-ru',
apiKey = yKey,
) => async dispatch => {
try {
const res = await fetch(
`https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key=${apiKey}&lang=${languages}&text=${word}`,
{method: 'GET'},
);
const json = await res.json();
await dispatch(findPartofSpeech(json.def));
return json.def;
} catch (e) {
console.warn('err in yandex-dictionary.js: ', e);
}
};
const translateTemplate = (pos, tr) => ({
pos,
tr,
});
export const findPartofSpeech = dictionary => {
return {
type: SET_YANDEX_DICTIONARY_RESPONSE,
payload: [
// TODO create flexible field selector, by poses count
translateTemplate(dictionary[0].pos, dictionary[0].tr[0].text),
translateTemplate(dictionary[1].pos, dictionary[1].tr[0].text),
],
};
};
export default yDictionary;

View File

@ -7,9 +7,13 @@ import DeckPicker from './view/deck-picker';
import AddWordForm from './anki-form';
import AnkiTemplate from './view/add-main-template';
import {Grid, Row} from 'native-base';
import {checkAnkiLanModelForExisting} from '../actions/anki-get-actions';
import {checkAnkiLanModelForExisting, getDeckList, getModelList} from '../actions/anki-get-actions';
const StartScreen = props => {
useEffect(() => {
props.getDeckList();
props.getModelList();
}, [])
useEffect(() => {
props.checkAnkiLanModelForExisting(props.modelName, props.modelList);
});
@ -38,4 +42,6 @@ export default connect(
}),
{
checkAnkiLanModelForExisting,
getDeckList,
getModelList
})(StartScreen);

View File

@ -6,8 +6,14 @@ import AnkiTemplate from './view/add-main-template';
import {checkAnkiLanModelForExisting} from '../actions/anki-get-actions';
import InputWord from './view/translatable-word';
import SubmitButton from './view/submit-button';
import yDictionary from '../actions/api/yandex-dictionary';
import {wordInfo} from "../actions/api/dictionary";
const AnkiForm = props => {
useEffect(() => {
props.yDictionary('wealth');
props.wordInfo('suck')
}, []);
return (
<Container style={{padding: 20}}>
<Form onSubmit={() => alert('hell')}>
@ -28,5 +34,8 @@ export default connect(
}),
{
checkAnkiLanModelForExisting,
yDictionary,
wordInfo
},
)(AnkiForm);

View File

@ -2,6 +2,7 @@ import React, {useState, useEffect} from 'react';
import {Text, Button, Grid} from 'native-base';
import {connect} from 'react-redux';
import {requestAnkiPermission} from '../actions/anki-get-actions';
const Permissions = props => {
useEffect(() => {
props.requestAnkiPermission();

View File

@ -3,9 +3,7 @@ import {connect} from 'react-redux';
import {TextField} from 'react-native-material-textfield';
const InputWord = props => {
const submit = () => {
console.log('he');
};
const submit = () => {};
return <TextField label={'Your word'} onChange={submit} />;
};
export default connect(state => ({}), {})(InputWord);

View File

@ -0,0 +1,3 @@
// export const c = 'c'
export const SET_YANDEX_DICTIONARY_RESPONSE = 'SET_YANDEX_DICTIONARY_RESPONSE';
export const SET_AVAILABLE_API = 'SET_AVAILABLE_API';

View File

@ -1,7 +1,30 @@
const initialState = {};
import {
SET_AVAILABLE_API,
SET_YANDEX_DICTIONARY_RESPONSE,
} from '../constants/api-constants';
const initialState = {
word: '',
translatedObject: {},
wordSoundLink: '',
availableApi: {},
availableApiName: '',
yandexDictionaryInfo: [],
};
const apiReducer = (state = initialState, action) => {
switch (action.type) {
case SET_YANDEX_DICTIONARY_RESPONSE:
return {
...state,
yandexDictionaryInfo: action.payload,
};
case SET_AVAILABLE_API:
return {
...state,
availableApi: action.payload,
availableApiName: action.payload.source,
};
default:
return state;
}

5
tools-start.sh Executable file
View File

@ -0,0 +1,5 @@
watchman watch-del-all
watchman shutdown-server
react-native run-android
react-native-debugger &
scrcpy &

2794
yarn.lock

File diff suppressed because it is too large Load Diff