added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
View File
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Baruch Velez
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.
+231
View File
@@ -0,0 +1,231 @@
# resq (React Element Selector Query) ![npm](https://img.shields.io/npm/v/resq.svg) [![Build Status](https://travis-ci.org/baruchvlz/resq.svg?branch=master)](https://travis-ci.org/baruchvlz/resq) [![codecov](https://codecov.io/gh/baruchvlz/resq/branch/master/graph/badge.svg)](https://codecov.io/gh/baruchvlz/resq)
## Requirements
- React v16 or higher
- Node 8 or higher
- React DevTools (optional)
This library tries to implement something similar to `querySelector` and `querySelectorAll`, but through the React VirtualDOM. You can query for React composite elements or HTML elements. It provides two functions `resq$` and `resq$$` for selecting one or multiple components, respectively.
## Installation
```
$ npm install --save resq
$ yarn add resq
```
## Usage
To get the most out of the library, we recommend you use React Dev Tools to verify the component names you want to select. Granted for basic usage you don't need this as long as you know the component name beforehand, but for Styled components and MaterialUI components it will be of great help.
#### Type definition
```typescript
interface RESQNode {
name: 'MyComponent',
node: HTMLElement | null,
isFragment: boolean,
state: string | boolean | any[] | {},
props: {},
children: RESQNode[]
}
resq$(selector: string, element?: HTMLElement): RESQNode
resq$$(selector: string, element?: HTMLElement): Array<RESQNode>
```
* [Basic Usage](README.md#basic-usage)
* [Wildcard selection](README.md#wildcard-selection)
* [Async selection](README.md#async-selection)
* [Filtering selection](README.md#filtering-selection)
#### Basic Usage
Take this React App:
```jsx
// imports
const MyComponent = () => (
<div>My Component</div>
)
const App = () => (
<div><MyComponent /></div>
)
ReactDOM.render(<App />, document.getElementById('root'))
```
Selecting `MyComponent`:
```js
import { resq$ } from 'resq'
const root = document.getElementById('root');
resq$('MyComponent', root);
/*
{
name: 'MyComponent',
node: <div />,
isFragment: false,
state: {},
props: {},
children: []
}
*/
```
#### Wildcard selection
You can select your components by partial name use a wildcard selectors:
```jsx
// imports
const MyComponent = () => (
<div>My Component</div>
)
const MyAnotherComponent = () => (
<div>My Another Component</div>
)
const App = () => (
<div>
<MyComponent />
<MyAnotherComponent />
</div>
)
ReactDOM.render(<App />, document.getElementById('root'))
```
Selecting both components by wildcard:
```js
import { resq$$ } from 'resq'
const root = document.getElementById('root');
resq$$('My*', root);
/*
[
{
name: 'MyComponent',
node: <div />,
isFragment: false,
state: {},
props: {},
children: []
},
{
name: 'MyAnotherComponent',
node: <div />,
isFragment: false,
state: {},
props: {},
children: []
},
]
*/
```
Selecting `MyAnotherComponent` by wildcard:
```js
import { resq$ } from 'resq'
const root = document.getElementById('root');
resq$('My*Component', root);
/*
{
name: 'MyAnotherComponent',
node: <div />,
isFragment: false,
state: {},
props: {},
children: []
}
*/
```
#### Async selection
Going by the same example as in [basic usage](README.md#basic-usage), if you don't want to pass the root element to the function, you can do it this way:
```js
import { resq$, waitToLoadReact } from 'resq'
async function getReactElement(name) {
try {
await waitToLoadReact(2000) // time in MS to wait before erroring
return resq$(name)
} catch (error) {
console.warn('resq error', error)
}
}
getReactElement('MyComponent')
```
#### Filtering selection
You can filter your selections `byState` or `byProps`. These are methods attached to the RESQNode return objects.
Example app:
```jsx
// imports
const MyComponent = ({ someBooleanProp }) => (
<div>My Component {someBooleanProp ? 'show this' : ''} </div>
)
const App = () => (
<div>
<MyComponent />
<MyComponent someBooleanProp={true} />
</div>
)
ReactDOM.render(<App />, document.getElementById('root'))
```
To select the first instance of `MyComponent` where `someBooleanProp` is true:
```js
import { resq$ } from 'resq'
const root = document.getElementById('root')
const myComponent = resq$('MyComponent', root)
const filtered = myComponent.byProps({ someBooleanProp: true })
console.log(filtered)
/*
{
name: 'MyComponent',
node: <div />,
isFragment: false,
state: {},
props: {
someBooleanProp: true,
},
children: []
}
*/
```
**Deep Matching with `exact` flag**
If you are in need of filtering `byProps` or `byState` and require the filter to match exactly every property and value in the object (or nested objects), you can pass the `exact` flag to the function:
```js
import { resq$ } from 'resq'
const root = document.getElementById('root')
const myComponent = resq$('MyComponent', root)
const filtered = myComponent.byProps({ someBooleanProp: true }, { exact: true })
```
+1
View File
File diff suppressed because one or more lines are too long
+15
View File
@@ -0,0 +1,15 @@
type NotFunc<T> = Exclude<T, Function>
interface RESQNode {
name: string,
node: HTMLElement | null,
isFragment: boolean,
state: NotFunc<any>,
props: {},
children: RESQNode[]
_nodes: Array<RESQNode>
}
export const waitToLoadReact: (timeInMs?: number, rootElSelector?: string) => Promise<null | string>
export const resq$: (selector: string, element?: HTMLElement) => RESQNode
export const resq$$: (selector: string, element?: HTMLElement) => Array<RESQNode>
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Evgeny Poberezkin
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.
+58
View File
@@ -0,0 +1,58 @@
# fast-deep-equal
The fastest deep equal
[![Build Status](https://travis-ci.org/epoberezkin/fast-deep-equal.svg?branch=master)](https://travis-ci.org/epoberezkin/fast-deep-equal)
[![npm version](https://badge.fury.io/js/fast-deep-equal.svg)](http://badge.fury.io/js/fast-deep-equal)
[![Coverage Status](https://coveralls.io/repos/github/epoberezkin/fast-deep-equal/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/fast-deep-equal?branch=master)
## Install
```bash
npm install fast-deep-equal
```
## Features
- ES5 compatible
- works in node.js (0.10+) and browsers (IE9+)
- checks equality of Date and RegExp objects by value.
## Usage
```javascript
var equal = require('fast-deep-equal');
console.log(equal({foo: 'bar'}, {foo: 'bar'})); // true
```
## Performance benchmark
Node.js v9.11.1:
```
fast-deep-equal x 226,960 ops/sec ±1.55% (86 runs sampled)
nano-equal x 218,210 ops/sec ±0.79% (89 runs sampled)
shallow-equal-fuzzy x 206,762 ops/sec ±0.84% (88 runs sampled)
underscore.isEqual x 128,668 ops/sec ±0.75% (91 runs sampled)
lodash.isEqual x 44,895 ops/sec ±0.67% (85 runs sampled)
deep-equal x 51,616 ops/sec ±0.96% (90 runs sampled)
deep-eql x 28,218 ops/sec ±0.42% (85 runs sampled)
assert.deepStrictEqual x 1,777 ops/sec ±1.05% (86 runs sampled)
ramda.equals x 13,466 ops/sec ±0.82% (86 runs sampled)
The fastest is fast-deep-equal
```
To run benchmark (requires node.js 6+):
```bash
npm install
node benchmark
```
## License
[MIT](https://github.com/epoberezkin/fast-deep-equal/blob/master/LICENSE)
+4
View File
@@ -0,0 +1,4 @@
declare module 'fast-deep-equal' {
const equal: (a: any, b: any) => boolean;
export = equal;
}
+55
View File
@@ -0,0 +1,55 @@
'use strict';
var isArray = Array.isArray;
var keyList = Object.keys;
var hasProp = Object.prototype.hasOwnProperty;
module.exports = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = isArray(a)
, arrB = isArray(b)
, i
, length
, key;
if (arrA && arrB) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
var dateA = a instanceof Date
, dateB = b instanceof Date;
if (dateA != dateB) return false;
if (dateA && dateB) return a.getTime() == b.getTime();
var regexpA = a instanceof RegExp
, regexpB = b instanceof RegExp;
if (regexpA != regexpB) return false;
if (regexpA && regexpB) return a.toString() == b.toString();
var keys = keyList(a);
length = keys.length;
if (length !== keyList(b).length)
return false;
for (i = length; i-- !== 0;)
if (!hasProp.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
return a!==a && b!==b;
};
+90
View File
@@ -0,0 +1,90 @@
{
"_args": [
[
"fast-deep-equal@2.0.1",
"/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror"
]
],
"_development": true,
"_from": "fast-deep-equal@2.0.1",
"_id": "fast-deep-equal@2.0.1",
"_inBundle": false,
"_integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=",
"_location": "/resq/fast-deep-equal",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "fast-deep-equal@2.0.1",
"name": "fast-deep-equal",
"escapedName": "fast-deep-equal",
"rawSpec": "2.0.1",
"saveSpec": null,
"fetchSpec": "2.0.1"
},
"_requiredBy": [
"/resq"
],
"_resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"_spec": "2.0.1",
"_where": "/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror",
"author": {
"name": "Evgeny Poberezkin"
},
"bugs": {
"url": "https://github.com/epoberezkin/fast-deep-equal/issues"
},
"description": "Fast deep equal",
"devDependencies": {
"benchmark": "^2.1.4",
"coveralls": "^2.13.1",
"deep-eql": "latest",
"deep-equal": "latest",
"eslint": "^4.0.0",
"lodash": "latest",
"mocha": "^3.4.2",
"nano-equal": "latest",
"nyc": "^11.0.2",
"pre-commit": "^1.2.2",
"ramda": "latest",
"shallow-equal-fuzzy": "latest",
"typescript": "^2.6.1",
"underscore": "latest"
},
"files": [
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/epoberezkin/fast-deep-equal#readme",
"keywords": [
"fast",
"equal",
"deep-equal"
],
"license": "MIT",
"main": "index.js",
"name": "fast-deep-equal",
"nyc": {
"exclude": [
"**/spec/**",
"node_modules"
],
"reporter": [
"lcov",
"text-summary"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/epoberezkin/fast-deep-equal.git"
},
"scripts": {
"eslint": "eslint *.js benchmark spec",
"test": "npm run eslint && npm run test-ts && npm run test-cov",
"test-cov": "nyc npm run test-spec",
"test-spec": "mocha spec/*.spec.js -R spec",
"test-ts": "tsc --target ES5 --noImplicitAny index.d.ts"
},
"types": "index.d.ts",
"version": "2.0.1"
}
+107
View File
@@ -0,0 +1,107 @@
{
"_args": [
[
"resq@1.10.1",
"/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror"
]
],
"_development": true,
"_from": "resq@1.10.1",
"_id": "resq@1.10.1",
"_inBundle": false,
"_integrity": "sha512-zhp1iyUH02MLciv3bIM2bNtTFx/fqRsK4Jk73jcPqp00d/sMTTjOtjdTMAcgjrQKGx5DvQ/HSpeqaMW0atGRJA==",
"_location": "/resq",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "resq@1.10.1",
"name": "resq",
"escapedName": "resq",
"rawSpec": "1.10.1",
"saveSpec": null,
"fetchSpec": "1.10.1"
},
"_requiredBy": [
"/webdriverio"
],
"_resolved": "https://registry.npmjs.org/resq/-/resq-1.10.1.tgz",
"_spec": "1.10.1",
"_where": "/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror",
"author": {
"name": "Baruch Velez",
"email": "baruchvelez@gmail.com"
},
"bugs": {
"url": "https://github.com/baruchvlz/resq/issues"
},
"dependencies": {
"fast-deep-equal": "^2.0.1"
},
"description": "React Element Selector Query (resq) - Query React components and children by selector (component name)",
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.4.0",
"@babel/plugin-transform-runtime": "7.4.0",
"@babel/preset-env": "7.4.1",
"@babel/runtime": "^7.4.2",
"babel-eslint": "10.0.1",
"babel-jest": "24.5.0",
"babel-loader": "^8.0.6",
"codecov": "^3.3.0",
"eslint": "5.15.3",
"eslint-plugin-jest": "22.4.1",
"jest": "24.5.0",
"npm-run-all": "4.1.5",
"rimraf": "^2.6.3",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
},
"files": [
"dist/index.js",
"index.d.ts"
],
"homepage": "https://github.com/baruchvlz/resq#readme",
"jest": {
"transform": {
"^.+\\.jsx?$": "babel-jest"
},
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"coverageThreshold": {
"global": {
"branches": 97,
"functions": 100,
"lines": 100,
"statements": 100
}
}
},
"keywords": [
"react",
"selector",
"resq",
"rescue",
"queryselector",
"query"
],
"license": "MIT",
"main": "dist/index.js",
"name": "resq",
"repository": {
"url": "git+https://github.com/baruchvlz/resq.git"
},
"scripts": {
"build": "webpack",
"commit": "git-cz",
"lint": "eslint . --fix",
"prebuild": "rimraf dist",
"prepublish": "yarn test && yarn build",
"prepush": "npm run test --coverage",
"test": "jest ./tests --verbose --coverage",
"test:dev": "jest ./tests --coverage --watch"
},
"version": "1.10.1"
}