📝 Commit Details:
This commit is contained in:
2
backend/node_modules/preact/debug/dist/debug.js
generated
vendored
Normal file
2
backend/node_modules/preact/debug/dist/debug.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
backend/node_modules/preact/debug/dist/debug.js.map
generated
vendored
Normal file
1
backend/node_modules/preact/debug/dist/debug.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
backend/node_modules/preact/debug/dist/debug.mjs
generated
vendored
Normal file
2
backend/node_modules/preact/debug/dist/debug.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
backend/node_modules/preact/debug/dist/debug.module.js
generated
vendored
Normal file
2
backend/node_modules/preact/debug/dist/debug.module.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
backend/node_modules/preact/debug/dist/debug.module.js.map
generated
vendored
Normal file
1
backend/node_modules/preact/debug/dist/debug.module.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
backend/node_modules/preact/debug/dist/debug.umd.js
generated
vendored
Normal file
2
backend/node_modules/preact/debug/dist/debug.umd.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
backend/node_modules/preact/debug/dist/debug.umd.js.map
generated
vendored
Normal file
1
backend/node_modules/preact/debug/dist/debug.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
26
backend/node_modules/preact/debug/package.json
generated
vendored
Normal file
26
backend/node_modules/preact/debug/package.json
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "preact-debug",
|
||||
"amdName": "preactDebug",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Preact extensions for development",
|
||||
"main": "dist/debug.js",
|
||||
"module": "dist/debug.module.js",
|
||||
"umd:main": "dist/debug.umd.js",
|
||||
"source": "src/index.js",
|
||||
"license": "MIT",
|
||||
"mangle": {
|
||||
"regex": "^(?!_renderer)^_"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"preact": "^10.0.0"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"browser": "./dist/debug.module.js",
|
||||
"umd": "./dist/debug.umd.js",
|
||||
"import": "./dist/debug.mjs",
|
||||
"require": "./dist/debug.js"
|
||||
}
|
||||
}
|
||||
}
|
54
backend/node_modules/preact/debug/src/check-props.js
generated
vendored
Normal file
54
backend/node_modules/preact/debug/src/check-props.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
||||
|
||||
let loggedTypeFailures = {};
|
||||
|
||||
/**
|
||||
* Reset the history of which prop type warnings have been logged.
|
||||
*/
|
||||
export function resetPropWarnings() {
|
||||
loggedTypeFailures = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the values match with the type specs.
|
||||
* Error messages are memorized and will only be shown once.
|
||||
*
|
||||
* Adapted from https://github.com/facebook/prop-types/blob/master/checkPropTypes.js
|
||||
*
|
||||
* @param {object} typeSpecs Map of name to a ReactPropType
|
||||
* @param {object} values Runtime values that need to be type-checked
|
||||
* @param {string} location e.g. "prop", "context", "child context"
|
||||
* @param {string} componentName Name of the component for error messages.
|
||||
* @param {?Function} getStack Returns the component stack.
|
||||
*/
|
||||
export function checkPropTypes(
|
||||
typeSpecs,
|
||||
values,
|
||||
location,
|
||||
componentName,
|
||||
getStack
|
||||
) {
|
||||
Object.keys(typeSpecs).forEach(typeSpecName => {
|
||||
let error;
|
||||
try {
|
||||
error = typeSpecs[typeSpecName](
|
||||
values,
|
||||
typeSpecName,
|
||||
componentName,
|
||||
location,
|
||||
null,
|
||||
ReactPropTypesSecret
|
||||
);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error && !(error.message in loggedTypeFailures)) {
|
||||
loggedTypeFailures[error.message] = true;
|
||||
console.error(
|
||||
`Failed ${location} type: ${error.message}${(getStack &&
|
||||
`\n${getStack()}`) ||
|
||||
''}`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
146
backend/node_modules/preact/debug/src/component-stack.js
generated
vendored
Normal file
146
backend/node_modules/preact/debug/src/component-stack.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
import { options, Fragment } from 'preact';
|
||||
|
||||
/**
|
||||
* Get human readable name of the component/dom node
|
||||
* @param {import('./internal').VNode} vnode
|
||||
* @param {import('./internal').VNode} vnode
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getDisplayName(vnode) {
|
||||
if (vnode.type === Fragment) {
|
||||
return 'Fragment';
|
||||
} else if (typeof vnode.type == 'function') {
|
||||
return vnode.type.displayName || vnode.type.name;
|
||||
} else if (typeof vnode.type == 'string') {
|
||||
return vnode.type;
|
||||
}
|
||||
|
||||
return '#text';
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to keep track of the currently rendered `vnode` and print it
|
||||
* in debug messages.
|
||||
*/
|
||||
let renderStack = [];
|
||||
|
||||
/**
|
||||
* Keep track of the current owners. An owner describes a component
|
||||
* which was responsible to render a specific `vnode`. This exclude
|
||||
* children that are passed via `props.children`, because they belong
|
||||
* to the parent owner.
|
||||
*
|
||||
* ```jsx
|
||||
* const Foo = props => <div>{props.children}</div> // div's owner is Foo
|
||||
* const Bar = props => {
|
||||
* return (
|
||||
* <Foo><span /></Foo> // Foo's owner is Bar, span's owner is Bar
|
||||
* )
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Note: A `vnode` may be hoisted to the root scope due to compiler
|
||||
* optimiztions. In these cases the `_owner` will be different.
|
||||
*/
|
||||
let ownerStack = [];
|
||||
|
||||
/**
|
||||
* Get the currently rendered `vnode`
|
||||
* @returns {import('./internal').VNode | null}
|
||||
*/
|
||||
export function getCurrentVNode() {
|
||||
return renderStack.length > 0 ? renderStack[renderStack.length - 1] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the user doesn't have `@babel/plugin-transform-react-jsx-source`
|
||||
* somewhere in his tool chain we can't print the filename and source
|
||||
* location of a component. In that case we just omit that, but we'll
|
||||
* print a helpful message to the console, notifying the user of it.
|
||||
*/
|
||||
let hasBabelPlugin = false;
|
||||
|
||||
/**
|
||||
* Check if a `vnode` is a possible owner.
|
||||
* @param {import('./internal').VNode} vnode
|
||||
*/
|
||||
function isPossibleOwner(vnode) {
|
||||
return typeof vnode.type == 'function' && vnode.type != Fragment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the component stack that was captured up to this point.
|
||||
* @param {import('./internal').VNode} vnode
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getOwnerStack(vnode) {
|
||||
const stack = [vnode];
|
||||
let next = vnode;
|
||||
while (next._owner != null) {
|
||||
stack.push(next._owner);
|
||||
next = next._owner;
|
||||
}
|
||||
|
||||
return stack.reduce((acc, owner) => {
|
||||
acc += ` in ${getDisplayName(owner)}`;
|
||||
|
||||
const source = owner.__source;
|
||||
if (source) {
|
||||
acc += ` (at ${source.fileName}:${source.lineNumber})`;
|
||||
} else if (!hasBabelPlugin) {
|
||||
hasBabelPlugin = true;
|
||||
console.warn(
|
||||
'Add @babel/plugin-transform-react-jsx-source to get a more detailed component stack. Note that you should not add it to production builds of your App for bundle size reasons.'
|
||||
);
|
||||
}
|
||||
|
||||
return (acc += '\n');
|
||||
}, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup code to capture the component trace while rendering. Note that
|
||||
* we cannot simply traverse `vnode._parent` upwards, because we have some
|
||||
* debug messages for `this.setState` where the `vnode` is `undefined`.
|
||||
*/
|
||||
export function setupComponentStack() {
|
||||
let oldDiff = options._diff;
|
||||
let oldDiffed = options.diffed;
|
||||
let oldRoot = options._root;
|
||||
let oldVNode = options.vnode;
|
||||
let oldRender = options._render;
|
||||
|
||||
options.diffed = vnode => {
|
||||
if (isPossibleOwner(vnode)) {
|
||||
ownerStack.pop();
|
||||
}
|
||||
renderStack.pop();
|
||||
if (oldDiffed) oldDiffed(vnode);
|
||||
};
|
||||
|
||||
options._diff = vnode => {
|
||||
if (isPossibleOwner(vnode)) {
|
||||
renderStack.push(vnode);
|
||||
}
|
||||
if (oldDiff) oldDiff(vnode);
|
||||
};
|
||||
|
||||
options._root = (vnode, parent) => {
|
||||
ownerStack = [];
|
||||
if (oldRoot) oldRoot(vnode, parent);
|
||||
};
|
||||
|
||||
options.vnode = vnode => {
|
||||
vnode._owner =
|
||||
ownerStack.length > 0 ? ownerStack[ownerStack.length - 1] : null;
|
||||
if (oldVNode) oldVNode(vnode);
|
||||
};
|
||||
|
||||
options._render = vnode => {
|
||||
if (isPossibleOwner(vnode)) {
|
||||
ownerStack.push(vnode);
|
||||
}
|
||||
|
||||
if (oldRender) oldRender(vnode);
|
||||
};
|
||||
}
|
3
backend/node_modules/preact/debug/src/constants.js
generated
vendored
Normal file
3
backend/node_modules/preact/debug/src/constants.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export const ELEMENT_NODE = 1;
|
||||
export const DOCUMENT_NODE = 9;
|
||||
export const DOCUMENT_FRAGMENT_NODE = 11;
|
434
backend/node_modules/preact/debug/src/debug.js
generated
vendored
Normal file
434
backend/node_modules/preact/debug/src/debug.js
generated
vendored
Normal file
@@ -0,0 +1,434 @@
|
||||
import { checkPropTypes } from './check-props';
|
||||
import { options, Component } from 'preact';
|
||||
import {
|
||||
ELEMENT_NODE,
|
||||
DOCUMENT_NODE,
|
||||
DOCUMENT_FRAGMENT_NODE
|
||||
} from './constants';
|
||||
import {
|
||||
getOwnerStack,
|
||||
setupComponentStack,
|
||||
getCurrentVNode,
|
||||
getDisplayName
|
||||
} from './component-stack';
|
||||
import { assign } from './util';
|
||||
|
||||
const isWeakMapSupported = typeof WeakMap == 'function';
|
||||
|
||||
function getClosestDomNodeParent(parent) {
|
||||
if (!parent) return {};
|
||||
if (typeof parent.type == 'function') {
|
||||
return getClosestDomNodeParent(parent._parent);
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
export function initDebug() {
|
||||
setupComponentStack();
|
||||
|
||||
let hooksAllowed = false;
|
||||
|
||||
/* eslint-disable no-console */
|
||||
let oldBeforeDiff = options._diff;
|
||||
let oldDiffed = options.diffed;
|
||||
let oldVnode = options.vnode;
|
||||
let oldCatchError = options._catchError;
|
||||
let oldRoot = options._root;
|
||||
let oldHook = options._hook;
|
||||
const warnedComponents = !isWeakMapSupported
|
||||
? null
|
||||
: {
|
||||
useEffect: new WeakMap(),
|
||||
useLayoutEffect: new WeakMap(),
|
||||
lazyPropTypes: new WeakMap()
|
||||
};
|
||||
const deprecations = [];
|
||||
|
||||
options._catchError = (error, vnode, oldVNode, errorInfo) => {
|
||||
let component = vnode && vnode._component;
|
||||
if (component && typeof error.then == 'function') {
|
||||
const promise = error;
|
||||
error = new Error(
|
||||
`Missing Suspense. The throwing component was: ${getDisplayName(vnode)}`
|
||||
);
|
||||
|
||||
let parent = vnode;
|
||||
for (; parent; parent = parent._parent) {
|
||||
if (parent._component && parent._component._childDidSuspend) {
|
||||
error = promise;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// We haven't recovered and we know at this point that there is no
|
||||
// Suspense component higher up in the tree
|
||||
if (error instanceof Error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
errorInfo = errorInfo || {};
|
||||
errorInfo.componentStack = getOwnerStack(vnode);
|
||||
oldCatchError(error, vnode, oldVNode, errorInfo);
|
||||
|
||||
// when an error was handled by an ErrorBoundary we will nonetheless emit an error
|
||||
// event on the window object. This is to make up for react compatibility in dev mode
|
||||
// and thus make the Next.js dev overlay work.
|
||||
if (typeof error.then != 'function') {
|
||||
setTimeout(() => {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
options._root = (vnode, parentNode) => {
|
||||
if (!parentNode) {
|
||||
throw new Error(
|
||||
'Undefined parent passed to render(), this is the second argument.\n' +
|
||||
'Check if the element is available in the DOM/has the correct id.'
|
||||
);
|
||||
}
|
||||
|
||||
let isValid;
|
||||
switch (parentNode.nodeType) {
|
||||
case ELEMENT_NODE:
|
||||
case DOCUMENT_FRAGMENT_NODE:
|
||||
case DOCUMENT_NODE:
|
||||
isValid = true;
|
||||
break;
|
||||
default:
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
let componentName = getDisplayName(vnode);
|
||||
throw new Error(
|
||||
`Expected a valid HTML node as a second argument to render. Received ${parentNode} instead: render(<${componentName} />, ${parentNode});`
|
||||
);
|
||||
}
|
||||
|
||||
if (oldRoot) oldRoot(vnode, parentNode);
|
||||
};
|
||||
|
||||
options._diff = vnode => {
|
||||
let { type, _parent: parent } = vnode;
|
||||
let parentVNode = getClosestDomNodeParent(parent);
|
||||
|
||||
hooksAllowed = true;
|
||||
|
||||
if (type === undefined) {
|
||||
throw new Error(
|
||||
'Undefined component passed to createElement()\n\n' +
|
||||
'You likely forgot to export your component or might have mixed up default and named imports' +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
} else if (type != null && typeof type == 'object') {
|
||||
if (type._children !== undefined && type._dom !== undefined) {
|
||||
throw new Error(
|
||||
`Invalid type passed to createElement(): ${type}\n\n` +
|
||||
'Did you accidentally pass a JSX literal as JSX twice?\n\n' +
|
||||
` let My${getDisplayName(vnode)} = ${serializeVNode(type)};\n` +
|
||||
` let vnode = <My${getDisplayName(vnode)} />;\n\n` +
|
||||
'This usually happens when you export a JSX literal and not the component.' +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
'Invalid type passed to createElement(): ' +
|
||||
(Array.isArray(type) ? 'array' : type)
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
(type === 'thead' || type === 'tfoot' || type === 'tbody') &&
|
||||
parentVNode.type !== 'table'
|
||||
) {
|
||||
console.error(
|
||||
'Improper nesting of table. Your <thead/tbody/tfoot> should have a <table> parent.' +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
} else if (
|
||||
type === 'tr' &&
|
||||
parentVNode.type !== 'thead' &&
|
||||
parentVNode.type !== 'tfoot' &&
|
||||
parentVNode.type !== 'tbody' &&
|
||||
parentVNode.type !== 'table'
|
||||
) {
|
||||
console.error(
|
||||
'Improper nesting of table. Your <tr> should have a <thead/tbody/tfoot/table> parent.' +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
} else if (type === 'td' && parentVNode.type !== 'tr') {
|
||||
console.error(
|
||||
'Improper nesting of table. Your <td> should have a <tr> parent.' +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
} else if (type === 'th' && parentVNode.type !== 'tr') {
|
||||
console.error(
|
||||
'Improper nesting of table. Your <th> should have a <tr>.' +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
vnode.ref !== undefined &&
|
||||
typeof vnode.ref != 'function' &&
|
||||
typeof vnode.ref != 'object' &&
|
||||
!('$$typeof' in vnode) // allow string refs when preact-compat is installed
|
||||
) {
|
||||
throw new Error(
|
||||
`Component's "ref" property should be a function, or an object created ` +
|
||||
`by createRef(), but got [${typeof vnode.ref}] instead\n` +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof vnode.type == 'string') {
|
||||
for (const key in vnode.props) {
|
||||
if (
|
||||
key[0] === 'o' &&
|
||||
key[1] === 'n' &&
|
||||
typeof vnode.props[key] != 'function' &&
|
||||
vnode.props[key] != null
|
||||
) {
|
||||
throw new Error(
|
||||
`Component's "${key}" property should be a function, ` +
|
||||
`but got [${typeof vnode.props[key]}] instead\n` +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check prop-types if available
|
||||
if (typeof vnode.type == 'function' && vnode.type.propTypes) {
|
||||
if (
|
||||
vnode.type.displayName === 'Lazy' &&
|
||||
warnedComponents &&
|
||||
!warnedComponents.lazyPropTypes.has(vnode.type)
|
||||
) {
|
||||
const m =
|
||||
'PropTypes are not supported on lazy(). Use propTypes on the wrapped component itself. ';
|
||||
try {
|
||||
const lazyVNode = vnode.type();
|
||||
warnedComponents.lazyPropTypes.set(vnode.type, true);
|
||||
console.warn(
|
||||
m + `Component wrapped in lazy() is ${getDisplayName(lazyVNode)}`
|
||||
);
|
||||
} catch (promise) {
|
||||
console.warn(
|
||||
m + "We will log the wrapped component's name once it is loaded."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let values = vnode.props;
|
||||
if (vnode.type._forwarded) {
|
||||
values = assign({}, values);
|
||||
delete values.ref;
|
||||
}
|
||||
|
||||
checkPropTypes(
|
||||
vnode.type.propTypes,
|
||||
values,
|
||||
'prop',
|
||||
getDisplayName(vnode),
|
||||
() => getOwnerStack(vnode)
|
||||
);
|
||||
}
|
||||
|
||||
if (oldBeforeDiff) oldBeforeDiff(vnode);
|
||||
};
|
||||
|
||||
options._hook = (comp, index, type) => {
|
||||
if (!comp || !hooksAllowed) {
|
||||
throw new Error('Hook can only be invoked from render methods.');
|
||||
}
|
||||
|
||||
if (oldHook) oldHook(comp, index, type);
|
||||
};
|
||||
|
||||
// Ideally we'd want to print a warning once per component, but we
|
||||
// don't have access to the vnode that triggered it here. As a
|
||||
// compromise and to avoid flooding the console with warnings we
|
||||
// print each deprecation warning only once.
|
||||
const warn = (property, message) => ({
|
||||
get() {
|
||||
const key = 'get' + property + message;
|
||||
if (deprecations && deprecations.indexOf(key) < 0) {
|
||||
deprecations.push(key);
|
||||
console.warn(`getting vnode.${property} is deprecated, ${message}`);
|
||||
}
|
||||
},
|
||||
set() {
|
||||
const key = 'set' + property + message;
|
||||
if (deprecations && deprecations.indexOf(key) < 0) {
|
||||
deprecations.push(key);
|
||||
console.warn(`setting vnode.${property} is not allowed, ${message}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const deprecatedAttributes = {
|
||||
nodeName: warn('nodeName', 'use vnode.type'),
|
||||
attributes: warn('attributes', 'use vnode.props'),
|
||||
children: warn('children', 'use vnode.props.children')
|
||||
};
|
||||
|
||||
const deprecatedProto = Object.create({}, deprecatedAttributes);
|
||||
|
||||
options.vnode = vnode => {
|
||||
const props = vnode.props;
|
||||
if (
|
||||
vnode.type !== null &&
|
||||
props != null &&
|
||||
('__source' in props || '__self' in props)
|
||||
) {
|
||||
const newProps = (vnode.props = {});
|
||||
for (let i in props) {
|
||||
const v = props[i];
|
||||
if (i === '__source') vnode.__source = v;
|
||||
else if (i === '__self') vnode.__self = v;
|
||||
else newProps[i] = v;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
vnode.__proto__ = deprecatedProto;
|
||||
if (oldVnode) oldVnode(vnode);
|
||||
};
|
||||
|
||||
options.diffed = vnode => {
|
||||
// Check if the user passed plain objects as children. Note that we cannot
|
||||
// move this check into `options.vnode` because components can receive
|
||||
// children in any shape they want (e.g.
|
||||
// `<MyJSONFormatter>{{ foo: 123, bar: "abc" }}</MyJSONFormatter>`).
|
||||
// Putting this check in `options.diffed` ensures that
|
||||
// `vnode._children` is set and that we only validate the children
|
||||
// that were actually rendered.
|
||||
if (vnode._children) {
|
||||
vnode._children.forEach(child => {
|
||||
if (typeof child === 'object' && child && child.type === undefined) {
|
||||
const keys = Object.keys(child).join(',');
|
||||
throw new Error(
|
||||
`Objects are not valid as a child. Encountered an object with the keys {${keys}}.` +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
hooksAllowed = false;
|
||||
|
||||
if (oldDiffed) oldDiffed(vnode);
|
||||
|
||||
if (vnode._children != null) {
|
||||
const keys = [];
|
||||
for (let i = 0; i < vnode._children.length; i++) {
|
||||
const child = vnode._children[i];
|
||||
if (!child || child.key == null) continue;
|
||||
|
||||
const key = child.key;
|
||||
if (keys.indexOf(key) !== -1) {
|
||||
console.error(
|
||||
'Following component has two or more children with the ' +
|
||||
`same key attribute: "${key}". This may cause glitches and misbehavior ` +
|
||||
'in rendering process. Component: \n\n' +
|
||||
serializeVNode(vnode) +
|
||||
`\n\n${getOwnerStack(vnode)}`
|
||||
);
|
||||
|
||||
// Break early to not spam the console
|
||||
break;
|
||||
}
|
||||
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const setState = Component.prototype.setState;
|
||||
Component.prototype.setState = function(update, callback) {
|
||||
if (this._vnode == null) {
|
||||
// `this._vnode` will be `null` during componentWillMount. But it
|
||||
// is perfectly valid to call `setState` during cWM. So we
|
||||
// need an additional check to verify that we are dealing with a
|
||||
// call inside constructor.
|
||||
if (this.state == null) {
|
||||
console.warn(
|
||||
`Calling "this.setState" inside the constructor of a component is a ` +
|
||||
`no-op and might be a bug in your application. Instead, set ` +
|
||||
`"this.state = {}" directly.\n\n${getOwnerStack(getCurrentVNode())}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return setState.call(this, update, callback);
|
||||
};
|
||||
|
||||
const forceUpdate = Component.prototype.forceUpdate;
|
||||
Component.prototype.forceUpdate = function(callback) {
|
||||
if (this._vnode == null) {
|
||||
console.warn(
|
||||
`Calling "this.forceUpdate" inside the constructor of a component is a ` +
|
||||
`no-op and might be a bug in your application.\n\n${getOwnerStack(
|
||||
getCurrentVNode()
|
||||
)}`
|
||||
);
|
||||
} else if (this._parentDom == null) {
|
||||
console.warn(
|
||||
`Can't call "this.forceUpdate" on an unmounted component. This is a no-op, ` +
|
||||
`but it indicates a memory leak in your application. To fix, cancel all ` +
|
||||
`subscriptions and asynchronous tasks in the componentWillUnmount method.` +
|
||||
`\n\n${getOwnerStack(this._vnode)}`
|
||||
);
|
||||
}
|
||||
return forceUpdate.call(this, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Serialize a vnode tree to a string
|
||||
* @param {import('./internal').VNode} vnode
|
||||
* @returns {string}
|
||||
*/
|
||||
export function serializeVNode(vnode) {
|
||||
let { props } = vnode;
|
||||
let name = getDisplayName(vnode);
|
||||
|
||||
let attrs = '';
|
||||
for (let prop in props) {
|
||||
if (props.hasOwnProperty(prop) && prop !== 'children') {
|
||||
let value = props[prop];
|
||||
|
||||
// If it is an object but doesn't have toString(), use Object.toString
|
||||
if (typeof value == 'function') {
|
||||
value = `function ${value.displayName || value.name}() {}`;
|
||||
}
|
||||
|
||||
value =
|
||||
Object(value) === value && !value.toString
|
||||
? Object.prototype.toString.call(value)
|
||||
: value + '';
|
||||
|
||||
attrs += ` ${prop}=${JSON.stringify(value)}`;
|
||||
}
|
||||
}
|
||||
|
||||
let children = props.children;
|
||||
return `<${name}${attrs}${
|
||||
children && children.length ? '>..</' + name + '>' : ' />'
|
||||
}`;
|
||||
}
|
4
backend/node_modules/preact/debug/src/index.d.ts
generated
vendored
Normal file
4
backend/node_modules/preact/debug/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Reset the history of which prop type warnings have been logged.
|
||||
*/
|
||||
export function resetPropWarnings(): void;
|
6
backend/node_modules/preact/debug/src/index.js
generated
vendored
Normal file
6
backend/node_modules/preact/debug/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { initDebug } from './debug';
|
||||
import 'preact/devtools';
|
||||
|
||||
initDebug();
|
||||
|
||||
export { resetPropWarnings } from './check-props';
|
82
backend/node_modules/preact/debug/src/internal.d.ts
generated
vendored
Normal file
82
backend/node_modules/preact/debug/src/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { Component, PreactElement, VNode, Options } from '../../src/internal';
|
||||
|
||||
export { Component, PreactElement, VNode, Options };
|
||||
|
||||
export interface DevtoolsInjectOptions {
|
||||
/** 1 = DEV, 0 = production */
|
||||
bundleType: 1 | 0;
|
||||
/** The devtools enable different features for different versions of react */
|
||||
version: string;
|
||||
/** Informative string, currently unused in the devtools */
|
||||
rendererPackageName: string;
|
||||
/** Find the root dom node of a vnode */
|
||||
findHostInstanceByFiber(vnode: VNode): HTMLElement | null;
|
||||
/** Find the closest vnode given a dom node */
|
||||
findFiberByHostInstance(instance: HTMLElement): VNode | null;
|
||||
}
|
||||
|
||||
export interface DevtoolsUpdater {
|
||||
setState(objOrFn: any): void;
|
||||
forceUpdate(): void;
|
||||
setInState(path: Array<string | number>, value: any): void;
|
||||
setInProps(path: Array<string | number>, value: any): void;
|
||||
setInContext(): void;
|
||||
}
|
||||
|
||||
export type NodeType = 'Composite' | 'Native' | 'Wrapper' | 'Text';
|
||||
|
||||
export interface DevtoolData {
|
||||
nodeType: NodeType;
|
||||
// Component type
|
||||
type: any;
|
||||
name: string;
|
||||
ref: any;
|
||||
key: string | number;
|
||||
updater: DevtoolsUpdater | null;
|
||||
text: string | number | null;
|
||||
state: any;
|
||||
props: any;
|
||||
children: VNode[] | string | number | null;
|
||||
publicInstance: PreactElement | Text | Component;
|
||||
memoizedInteractions: any[];
|
||||
|
||||
actualDuration: number;
|
||||
actualStartTime: number;
|
||||
treeBaseDuration: number;
|
||||
}
|
||||
|
||||
export type EventType =
|
||||
| 'unmount'
|
||||
| 'rootCommitted'
|
||||
| 'root'
|
||||
| 'mount'
|
||||
| 'update'
|
||||
| 'updateProfileTimes';
|
||||
|
||||
export interface DevtoolsEvent {
|
||||
data?: DevtoolData;
|
||||
internalInstance: VNode;
|
||||
renderer: string;
|
||||
type: EventType;
|
||||
}
|
||||
|
||||
export interface DevtoolsHook {
|
||||
_renderers: Record<string, any>;
|
||||
_roots: Set<VNode>;
|
||||
on(ev: string, listener: () => void): void;
|
||||
emit(ev: string, data?: object): void;
|
||||
helpers: Record<string, any>;
|
||||
getFiberRoots(rendererId: string): Set<any>;
|
||||
inject(config: DevtoolsInjectOptions): string;
|
||||
onCommitFiberRoot(rendererId: string, root: VNode): void;
|
||||
onCommitFiberUnmount(rendererId: string, vnode: VNode): void;
|
||||
}
|
||||
|
||||
export interface DevtoolsWindow extends Window {
|
||||
/**
|
||||
* If the devtools extension is installed it will inject this object into
|
||||
* the dom. This hook handles all communications between preact and the
|
||||
* devtools panel.
|
||||
*/
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__?: DevtoolsHook;
|
||||
}
|
11
backend/node_modules/preact/debug/src/util.js
generated
vendored
Normal file
11
backend/node_modules/preact/debug/src/util.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Assign properties from `props` to `obj`
|
||||
* @template O, P The obj and props types
|
||||
* @param {O} obj The object to copy properties to
|
||||
* @param {P} props The object to copy properties from
|
||||
* @returns {O & P}
|
||||
*/
|
||||
export function assign(obj, props) {
|
||||
for (let i in props) obj[i] = props[i];
|
||||
return /** @type {O & P} */ (obj);
|
||||
}
|
Reference in New Issue
Block a user