First commit

This commit is contained in:
2021-03-07 05:58:59 +01:00
committed by Andreas Schaafsma
commit 6e1a5f9fe5
18475 changed files with 3309357 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 library-boilerplate-author
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,48 @@
react-deep-force-update
=========================
[![build status](https://img.shields.io/travis/gaearon/react-deep-force-update/master.svg?style=flat-square)](https://travis-ci.org/gaearon/react-deep-force-update)
[![npm version](https://img.shields.io/npm/v/react-deep-force-update.svg?style=flat-square)](https://www.npmjs.com/package/react-deep-force-update)
[![npm downloads](https://img.shields.io/npm/dm/react-deep-force-update.svg?style=flat-square)](https://www.npmjs.com/package/react-deep-force-update)
Force-updates React component tree recursively.
**Dont use this in your application code!**
Youll only need this if youre writing a React development tool and you want to enforce a deep update regardless of what component classes have to say.
## Installation
```
npm install --save react-deep-force-update
```
Requires React 0.14 and newer.
## Usage
```js
import React from 'react';
import { render } from 'react-dom';
import deepForceUpdate from 'react-deep-force-update';
const instance = render(<Something />);
// Will force-update the whole rendered tree
// even if components in the middle of it
// define a strict shouldComponentUpdate().
deepForceUpdate(instance);
```
## React Native
This will work with React Native when [facebook/react-native#2985](https://github.com/facebook/react-native/issues/2985) lands.
For now, you can keep using 1.x.
## Credits
This project is based on the [code written by @syranide](https://github.com/gaearon/react-hot-api/commit/b3d6059a17407ef44765814ce06b36716d110041).
## License
MIT

View File

@@ -0,0 +1,93 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = deepForceUpdate;
function traverseRenderedChildren(internalInstance, callback, argument) {
callback(internalInstance, argument);
if (internalInstance._renderedComponent) {
traverseRenderedChildren(internalInstance._renderedComponent, callback, argument);
} else {
for (var key in internalInstance._renderedChildren) {
if (internalInstance._renderedChildren.hasOwnProperty(key)) {
traverseRenderedChildren(internalInstance._renderedChildren[key], callback, argument);
}
}
}
}
function setPendingForceUpdate(internalInstance, shouldUpdate) {
if (internalInstance._pendingForceUpdate === false && shouldUpdate(internalInstance)) {
internalInstance._pendingForceUpdate = true;
}
}
function forceUpdateIfPending(internalInstance, onUpdate) {
if (internalInstance._pendingForceUpdate === true) {
var publicInstance = internalInstance._instance;
var updater = publicInstance.updater;
if (typeof publicInstance.forceUpdate === 'function') {
publicInstance.forceUpdate();
} else if (updater && typeof updater.enqueueForceUpdate === 'function') {
updater.enqueueForceUpdate(publicInstance);
}
onUpdate(internalInstance);
}
}
function deepForceUpdateStack(instance, shouldUpdate, onUpdate) {
var internalInstance = instance._reactInternalInstance;
traverseRenderedChildren(internalInstance, setPendingForceUpdate, shouldUpdate);
traverseRenderedChildren(internalInstance, forceUpdateIfPending, onUpdate);
}
function deepForceUpdate(instance) {
// TODO: this is temporarily disabled because it's not in 2.x release line.
// See https://github.com/gaearon/react-deep-force-update/issues/8
var shouldUpdate = function shouldUpdate() {
return true;
};
var onUpdate = function onUpdate() {};
var root = instance._reactInternalFiber || instance._reactInternalInstance;
if (typeof root.tag !== 'number') {
// Traverse stack-based React tree.
return deepForceUpdateStack(instance, shouldUpdate, onUpdate);
}
var node = root;
while (true) {
if (node.stateNode !== null && typeof node.type === 'function' && shouldUpdate(node)) {
var publicInstance = node.stateNode;
var updater = publicInstance.updater;
if (typeof publicInstance.forceUpdate === 'function') {
publicInstance.forceUpdate();
} else if (updater && typeof updater.enqueueForceUpdate === 'function') {
updater.enqueueForceUpdate(publicInstance);
}
onUpdate(node);
}
if (node.child) {
node.child.return = node;
node = node.child;
continue;
}
if (node === root) {
return undefined;
}
while (!node.sibling) {
if (!node.return || node.return === root) {
return undefined;
}
node = node.return;
}
node.sibling.return = node.return;
node = node.sibling;
}
}
module.exports = exports['default'];

View File

@@ -0,0 +1,79 @@
{
"_from": "react-deep-force-update@^2.0.1",
"_id": "react-deep-force-update@2.1.3",
"_inBundle": false,
"_integrity": "sha512-lqD4eHKVuB65RyO/hGbEST53E2/GPbcIPcFYyeW/p4vNngtH4G7jnKGlU6u1OqrFo0uNfIvwuBOg98IbLHlNEA==",
"_location": "/react-deep-force-update",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "react-deep-force-update@^2.0.1",
"name": "react-deep-force-update",
"escapedName": "react-deep-force-update",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/haxe-modular"
],
"_resolved": "https://registry.npmjs.org/react-deep-force-update/-/react-deep-force-update-2.1.3.tgz",
"_shasum": "740612322e617bcced38f61794a4af75dc3d98e7",
"_spec": "react-deep-force-update@^2.0.1",
"_where": "/home/andreas/Documents/Projects/haxe/openfl/nigger/node_modules/haxe-modular",
"author": {
"name": "Dan Abramov",
"email": "dan.abramov@me.com"
},
"bugs": {
"url": "https://github.com/gaearon/react-deep-force-update/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Force-updates React component tree recursively",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"create-react-class": "^15.6.0",
"eslint": "^4.7.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-prettier": "^2.5.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"jest": "^21.1.0",
"prettier": "^1.7.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"rimraf": "^2.6.2"
},
"files": [
"lib"
],
"homepage": "https://github.com/gaearon/react-deep-force-update",
"keywords": [
"react"
],
"license": "MIT",
"main": "lib/index.js",
"name": "react-deep-force-update",
"repository": {
"type": "git",
"url": "git+https://github.com/gaearon/react-deep-force-update.git"
},
"scripts": {
"build": "babel src --out-dir lib",
"clean": "rimraf lib",
"format": "prettier --write \"{src,test}/**/*.js\" *.js",
"lint": "eslint .",
"prepublish": "yarn clean && yarn build",
"test": "jest",
"test:watch": "yarn test -- --watch"
},
"version": "2.1.3"
}