Bump @justinribeiro/lite-youtube from 0.9.0 to 0.9.1 in /build/javascript (#273)
* Commit updated Javascript packages * Bump preact from 10.5.4 to 10.5.5 in /build/javascript (#265) * Trying a new github workflow to install javascript packages * Bump tailwindcss from 1.9.2 to 1.9.4 in /build/javascript (#266) Bumps [tailwindcss](https://github.com/tailwindlabs/tailwindcss) from 1.9.2 to 1.9.4. - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/master/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/compare/v1.9.2...v1.9.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Commit updated Javascript packages * Bump preact from 10.5.4 to 10.5.5 in /build/javascript Bumps [preact](https://github.com/preactjs/preact) from 10.5.4 to 10.5.5. - [Release notes](https://github.com/preactjs/preact/releases) - [Commits](https://github.com/preactjs/preact/compare/10.5.4...10.5.5) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Gabe Kangas <gabek@real-ity.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Owncast <owncast@owncast.online> * Bump @justinribeiro/lite-youtube in /build/javascript Bumps [@justinribeiro/lite-youtube](https://github.com/justinribeiro/lite-youtube) from 0.9.0 to 0.9.1. - [Release notes](https://github.com/justinribeiro/lite-youtube/releases) - [Commits](https://github.com/justinribeiro/lite-youtube/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Owncast <owncast@owncast.online> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
21
build/javascript/node_modules/preact/LICENSE
generated
vendored
Normal file
21
build/javascript/node_modules/preact/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
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.
|
||||
185
build/javascript/node_modules/preact/README.md
generated
vendored
Normal file
185
build/javascript/node_modules/preact/README.md
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
<p align="center">
|
||||
<a href="https://preactjs.com" target="_blank">
|
||||
|
||||

|
||||
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">Fast <b>3kB</b> alternative to React with the same modern API.</p>
|
||||
|
||||
**All the power of Virtual DOM components, without the overhead:**
|
||||
|
||||
- Familiar React API & patterns: ES6 Class, hooks, and Functional Components
|
||||
- Extensive React compatibility via a simple [preact/compat] alias
|
||||
- Everything you need: JSX, <abbr title="Virtual DOM">VDOM</abbr>, [DevTools], <abbr title="Hot Module Replacement">HMR</abbr>, <abbr title="Server-Side Rendering">SSR</abbr>.
|
||||
- Highly optimized diff algorithm and seamless hydration from Server Side Rendering
|
||||
- Supports all modern browsers and IE11
|
||||
- Transparent asynchronous rendering with a pluggable scheduler
|
||||
- **Instant production-grade app setup with [Preact CLI](https://github.com/preactjs/preact-cli)**
|
||||
|
||||
### 💁 More information at the [Preact Website ➞](https://preactjs.com)
|
||||
|
||||
|
||||
<table border="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
[](http://npm.im/preact)
|
||||
[](https://chat.preactjs.com)
|
||||
[](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
[](https://coveralls.io/github/preactjs/preact)
|
||||
[](https://unpkg.com/preact/dist/preact.min.js)
|
||||
[](https://unpkg.com/preact/dist/preact.min.js)
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<img src="https://saucelabs.com/browser-matrix/preact.svg" title="Browser support matrix">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
You can find some awesome libraries in the [awesome-preact list](https://github.com/preactjs/awesome-preact) :sunglasses:
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
> 💁 _**Note:** You [don't need ES2015 to use Preact](https://github.com/developit/preact-in-es3)... but give it a try!_
|
||||
|
||||
The easiest way to get started with Preact is to install [Preact CLI](https://github.com/preactjs/preact-cli). This simple command-line tool wraps up the best possible tooling for you, and even keeps things like Webpack and Babel up-to-date as they change. Best of all, it's easy to understand! Start a project or compile for production in a single command (`preact build`), with no configuration needed and best practices baked in! 🙌
|
||||
|
||||
#### Tutorial: Building UI with Preact
|
||||
|
||||
With Preact, you create user interfaces by assembling trees of components and elements. Components are functions or classes that return a description of what their tree should output. These descriptions are typically written in [JSX](https://facebook.github.io/jsx/) (shown underneath), or [HTM](https://github.com/developit/htm) which leverages standard JavaScript Tagged Templates. Both syntaxes can express trees of elements with "props" (similar to HTML attributes) and children.
|
||||
|
||||
To get started using Preact, first look at the render() function. This function accepts a tree description and creates the structure described. Next, it appends this structure to a parent DOM element provided as the second argument. Future calls to render() will reuse the existing tree and update it in-place in the DOM. Internally, render() will calculate the difference from previous outputted structures in an attempt to perform as few DOM operations as possible.
|
||||
|
||||
```js
|
||||
import { h, render } from 'preact';
|
||||
// Tells babel to use h for JSX. It's better to configure this globally.
|
||||
// See https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#usage
|
||||
// In tsconfig you can specify this with the jsxFactory
|
||||
/** @jsx h */
|
||||
|
||||
// create our tree and append it to document.body:
|
||||
render(<main><h1>Hello</h1></main>, document.body);
|
||||
|
||||
// update the tree in-place:
|
||||
render(<main><h1>Hello World!</h1></main>, document.body);
|
||||
// ^ this second invocation of render(...) will use a single DOM call to update the text of the <h1>
|
||||
```
|
||||
|
||||
Hooray! render() has taken our structure and output a User Interface! This approach demonstrates a simple case, but would be difficult to use as an application grows in complexity. Each change would be forced to calculate the difference between the current and updated structure for the entire application. Components can help here – by dividing the User Interface into nested Components each can calculate their difference from their mounted point. Here's an example:
|
||||
|
||||
```js
|
||||
import { render, h } from 'preact';
|
||||
import { useState } from 'preact/hooks';
|
||||
|
||||
/** @jsx h */
|
||||
|
||||
const App = () => {
|
||||
const [input, setInput] = useState('');
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>Do you agree to the statement: "Preact is awesome"?</p>
|
||||
<input value={input} onChange={e => setInput(e.target.value)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
render(<App />, document.body);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/preact#backer)]
|
||||
|
||||
<a href="https://opencollective.com/preact/backer/0/website" target="_blank"><img src="https://opencollective.com/preact/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/1/website" target="_blank"><img src="https://opencollective.com/preact/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/2/website" target="_blank"><img src="https://opencollective.com/preact/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/3/website" target="_blank"><img src="https://opencollective.com/preact/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/4/website" target="_blank"><img src="https://opencollective.com/preact/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/5/website" target="_blank"><img src="https://opencollective.com/preact/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/6/website" target="_blank"><img src="https://opencollective.com/preact/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/7/website" target="_blank"><img src="https://opencollective.com/preact/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/8/website" target="_blank"><img src="https://opencollective.com/preact/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/9/website" target="_blank"><img src="https://opencollective.com/preact/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/10/website" target="_blank"><img src="https://opencollective.com/preact/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/11/website" target="_blank"><img src="https://opencollective.com/preact/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/12/website" target="_blank"><img src="https://opencollective.com/preact/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/13/website" target="_blank"><img src="https://opencollective.com/preact/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/14/website" target="_blank"><img src="https://opencollective.com/preact/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/15/website" target="_blank"><img src="https://opencollective.com/preact/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/16/website" target="_blank"><img src="https://opencollective.com/preact/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/17/website" target="_blank"><img src="https://opencollective.com/preact/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/18/website" target="_blank"><img src="https://opencollective.com/preact/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/19/website" target="_blank"><img src="https://opencollective.com/preact/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/20/website" target="_blank"><img src="https://opencollective.com/preact/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/21/website" target="_blank"><img src="https://opencollective.com/preact/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/22/website" target="_blank"><img src="https://opencollective.com/preact/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/23/website" target="_blank"><img src="https://opencollective.com/preact/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/24/website" target="_blank"><img src="https://opencollective.com/preact/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/25/website" target="_blank"><img src="https://opencollective.com/preact/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/26/website" target="_blank"><img src="https://opencollective.com/preact/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/27/website" target="_blank"><img src="https://opencollective.com/preact/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/28/website" target="_blank"><img src="https://opencollective.com/preact/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/backer/29/website" target="_blank"><img src="https://opencollective.com/preact/backer/29/avatar.svg"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/preact#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/preact/sponsor/0/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/1/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/2/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/3/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/4/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/5/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/6/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/7/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/8/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/9/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/10/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/11/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/12/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/13/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/14/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/15/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/16/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/17/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/18/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/19/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/20/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/21/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/22/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/23/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/24/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/25/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/26/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/27/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/28/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/preact/sponsor/29/website" target="_blank"><img src="https://opencollective.com/preact/sponsor/29/avatar.svg"></a>
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
|
||||
|
||||
[](https://preactjs.com)
|
||||
|
||||
|
||||
[preact/compat]: https://github.com/preactjs/preact/tree/master/compat
|
||||
[hyperscript]: https://github.com/dominictarr/hyperscript
|
||||
[DevTools]: https://github.com/preactjs/preact-devtools
|
||||
21
build/javascript/node_modules/preact/compat/LICENSE
generated
vendored
Normal file
21
build/javascript/node_modules/preact/compat/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
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.
|
||||
19
build/javascript/node_modules/preact/compat/package.json
generated
vendored
Normal file
19
build/javascript/node_modules/preact/compat/package.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "preact-compat",
|
||||
"amdName": "preactCompat",
|
||||
"version": "4.0.0",
|
||||
"private": true,
|
||||
"description": "A React compatibility layer for Preact",
|
||||
"main": "dist/compat.js",
|
||||
"module": "dist/compat.module.js",
|
||||
"umd:main": "dist/compat.umd.js",
|
||||
"source": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
"license": "MIT",
|
||||
"mangle": {
|
||||
"regex": "^_"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"preact": "^10.0.0"
|
||||
}
|
||||
}
|
||||
18
build/javascript/node_modules/preact/compat/server.js
generated
vendored
Normal file
18
build/javascript/node_modules/preact/compat/server.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/* eslint-disable */
|
||||
var renderToString;
|
||||
try {
|
||||
renderToString = dep(require('preact-render-to-string'));
|
||||
} catch (e) {
|
||||
throw Error(
|
||||
'renderToString() error: missing "preact-render-to-string" dependency.'
|
||||
);
|
||||
}
|
||||
|
||||
function dep(obj) {
|
||||
return obj['default'] || obj;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
renderToString: renderToString,
|
||||
renderToStaticMarkup: renderToString
|
||||
};
|
||||
21
build/javascript/node_modules/preact/compat/src/Children.js
generated
vendored
Normal file
21
build/javascript/node_modules/preact/compat/src/Children.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { toChildArray } from 'preact';
|
||||
|
||||
const mapFn = (children, fn) => {
|
||||
if (children == null) return null;
|
||||
return toChildArray(toChildArray(children).map(fn));
|
||||
};
|
||||
|
||||
// This API is completely unnecessary for Preact, so it's basically passthrough.
|
||||
export const Children = {
|
||||
map: mapFn,
|
||||
forEach: mapFn,
|
||||
count(children) {
|
||||
return children ? toChildArray(children).length : 0;
|
||||
},
|
||||
only(children) {
|
||||
const normalized = toChildArray(children);
|
||||
if (normalized.length !== 1) throw 'Children.only';
|
||||
return normalized[0];
|
||||
},
|
||||
toArray: toChildArray
|
||||
};
|
||||
15
build/javascript/node_modules/preact/compat/src/PureComponent.js
generated
vendored
Normal file
15
build/javascript/node_modules/preact/compat/src/PureComponent.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Component } from 'preact';
|
||||
import { shallowDiffers } from './util';
|
||||
|
||||
/**
|
||||
* Component class with a predefined `shouldComponentUpdate` implementation
|
||||
*/
|
||||
export function PureComponent(p) {
|
||||
this.props = p;
|
||||
}
|
||||
PureComponent.prototype = new Component();
|
||||
// Some third-party libraries check if this property is present
|
||||
PureComponent.prototype.isPureReactComponent = true;
|
||||
PureComponent.prototype.shouldComponentUpdate = function(props, state) {
|
||||
return shallowDiffers(this.props, props) || shallowDiffers(this.state, state);
|
||||
};
|
||||
51
build/javascript/node_modules/preact/compat/src/forwardRef.js
generated
vendored
Normal file
51
build/javascript/node_modules/preact/compat/src/forwardRef.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { options } from 'preact';
|
||||
import { assign } from './util';
|
||||
|
||||
let oldDiffHook = options._diff;
|
||||
options._diff = vnode => {
|
||||
if (vnode.type && vnode.type._forwarded && vnode.ref) {
|
||||
vnode.props.ref = vnode.ref;
|
||||
vnode.ref = null;
|
||||
}
|
||||
if (oldDiffHook) oldDiffHook(vnode);
|
||||
};
|
||||
|
||||
export const REACT_FORWARD_SYMBOL =
|
||||
(typeof Symbol != 'undefined' &&
|
||||
Symbol.for &&
|
||||
Symbol.for('react.forward_ref')) ||
|
||||
0xf47;
|
||||
|
||||
/**
|
||||
* Pass ref down to a child. This is mainly used in libraries with HOCs that
|
||||
* wrap components. Using `forwardRef` there is an easy way to get a reference
|
||||
* of the wrapped component instead of one of the wrapper itself.
|
||||
* @param {import('./index').ForwardFn} fn
|
||||
* @returns {import('./internal').FunctionalComponent}
|
||||
*/
|
||||
export function forwardRef(fn) {
|
||||
// We always have ref in props.ref, except for
|
||||
// mobx-react. It will call this function directly
|
||||
// and always pass ref as the second argument.
|
||||
function Forwarded(props, ref) {
|
||||
let clone = assign({}, props);
|
||||
delete clone.ref;
|
||||
ref = props.ref || ref;
|
||||
return fn(
|
||||
clone,
|
||||
!ref || (typeof ref === 'object' && !('current' in ref)) ? null : ref
|
||||
);
|
||||
}
|
||||
|
||||
// mobx-react checks for this being present
|
||||
Forwarded.$$typeof = REACT_FORWARD_SYMBOL;
|
||||
// mobx-react heavily relies on implementation details.
|
||||
// It expects an object here with a `render` property,
|
||||
// and prototype.render will fail. Without this
|
||||
// mobx-react throws.
|
||||
Forwarded.render = Forwarded;
|
||||
|
||||
Forwarded.prototype.isReactComponent = Forwarded._forwarded = true;
|
||||
Forwarded.displayName = 'ForwardRef(' + (fn.displayName || fn.name) + ')';
|
||||
return Forwarded;
|
||||
}
|
||||
124
build/javascript/node_modules/preact/compat/src/index.d.ts
generated
vendored
Normal file
124
build/javascript/node_modules/preact/compat/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
import * as _hooks from '../../hooks';
|
||||
import * as preact from '../../src';
|
||||
import { JSXInternal } from '../../src/jsx';
|
||||
import * as _Suspense from './suspense';
|
||||
import * as _SuspenseList from './suspense-list'
|
||||
|
||||
// export default React;
|
||||
export = React;
|
||||
export as namespace React;
|
||||
declare namespace React {
|
||||
// Export JSX
|
||||
export import JSX = JSXInternal;
|
||||
|
||||
// Hooks
|
||||
export import CreateHandle = _hooks.CreateHandle;
|
||||
export import EffectCallback = _hooks.EffectCallback;
|
||||
export import Inputs = _hooks.Inputs;
|
||||
export import PropRef = _hooks.PropRef;
|
||||
export import Reducer = _hooks.Reducer;
|
||||
export import Ref = _hooks.Ref;
|
||||
export import StateUpdater = _hooks.StateUpdater;
|
||||
export import useCallback = _hooks.useCallback;
|
||||
export import useContext = _hooks.useContext;
|
||||
export import useDebugValue = _hooks.useDebugValue;
|
||||
export import useEffect = _hooks.useEffect;
|
||||
export import useImperativeHandle = _hooks.useImperativeHandle;
|
||||
export import useLayoutEffect = _hooks.useLayoutEffect;
|
||||
export import useMemo = _hooks.useMemo;
|
||||
export import useReducer = _hooks.useReducer;
|
||||
export import useRef = _hooks.useRef;
|
||||
export import useState = _hooks.useState;
|
||||
|
||||
// Preact Defaults
|
||||
export import Component = preact.Component;
|
||||
export import FunctionComponent = preact.FunctionComponent;
|
||||
export import FC = preact.FunctionComponent;
|
||||
export import createContext = preact.createContext;
|
||||
export import createRef = preact.createRef;
|
||||
export import Fragment = preact.Fragment;
|
||||
export import createElement = preact.createElement;
|
||||
export import cloneElement = preact.cloneElement;
|
||||
|
||||
// Suspense
|
||||
export import Suspense = _Suspense.Suspense;
|
||||
export import lazy = _Suspense.lazy;
|
||||
export import SuspenseList = _SuspenseList.SuspenseList
|
||||
|
||||
// Compat
|
||||
export import StrictMode = preact.Fragment;
|
||||
export const version: string;
|
||||
|
||||
export function createPortal(
|
||||
vnode: preact.VNode,
|
||||
container: Element
|
||||
): preact.VNode<any>;
|
||||
|
||||
export function render(
|
||||
vnode: preact.VNode<any>,
|
||||
parent: Element,
|
||||
callback?: () => void
|
||||
): Component | null;
|
||||
|
||||
export function hydrate(
|
||||
vnode: preact.VNode<any>,
|
||||
parent: Element,
|
||||
callback?: () => void
|
||||
): Component | null;
|
||||
|
||||
export function unmountComponentAtNode(
|
||||
container: Element | Document | ShadowRoot | DocumentFragment
|
||||
): boolean;
|
||||
|
||||
export function createFactory(
|
||||
type: preact.VNode<any>['type']
|
||||
): (
|
||||
props?: any,
|
||||
...children: preact.ComponentChildren[]
|
||||
) => preact.VNode<any>;
|
||||
export function isValidElement(element: any): boolean;
|
||||
export function findDOMNode(component: preact.Component): Element | null;
|
||||
|
||||
export abstract class PureComponent<P = {}, S = {}> extends preact.Component<
|
||||
P,
|
||||
S
|
||||
> {
|
||||
isPureReactComponent: boolean;
|
||||
}
|
||||
|
||||
export function memo<C extends preact.FunctionalComponent<any>>(
|
||||
component: C,
|
||||
comparer?: (
|
||||
prev: preact.ComponentProps<C>,
|
||||
next: preact.ComponentProps<C>
|
||||
) => boolean
|
||||
): C;
|
||||
|
||||
export interface ForwardFn<P = {}, T = any> {
|
||||
(props: P, ref: Ref<T>): preact.ComponentChild;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export function forwardRef<R, P = {}>(
|
||||
fn: ForwardFn<P, R>
|
||||
): preact.FunctionalComponent<P>;
|
||||
|
||||
export function unstable_batchedUpdates(
|
||||
callback: (arg?: any) => void,
|
||||
arg?: any
|
||||
): void;
|
||||
|
||||
export const Children: {
|
||||
map<T extends preact.ComponentChild, R>(
|
||||
children: T | T[],
|
||||
fn: (child: T, i: number) => R
|
||||
): R[];
|
||||
forEach<T extends preact.ComponentChild>(
|
||||
children: T | T[],
|
||||
fn: (child: T, i: number) => void
|
||||
): void;
|
||||
count: (children: preact.ComponentChildren) => number;
|
||||
only: (children: preact.ComponentChildren) => preact.ComponentChild;
|
||||
toArray: (children: preact.ComponentChildren) => preact.VNode<{}>[];
|
||||
};
|
||||
}
|
||||
174
build/javascript/node_modules/preact/compat/src/index.js
generated
vendored
Normal file
174
build/javascript/node_modules/preact/compat/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
import {
|
||||
createElement,
|
||||
render as preactRender,
|
||||
cloneElement as preactCloneElement,
|
||||
createRef,
|
||||
Component,
|
||||
createContext,
|
||||
Fragment
|
||||
} from 'preact';
|
||||
import {
|
||||
useState,
|
||||
useReducer,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useImperativeHandle,
|
||||
useMemo,
|
||||
useCallback,
|
||||
useContext,
|
||||
useDebugValue
|
||||
} from 'preact/hooks';
|
||||
import { PureComponent } from './PureComponent';
|
||||
import { memo } from './memo';
|
||||
import { forwardRef } from './forwardRef';
|
||||
import { Children } from './Children';
|
||||
import { Suspense, lazy } from './suspense';
|
||||
import { SuspenseList } from './suspense-list';
|
||||
import { createPortal } from './portals';
|
||||
import {
|
||||
hydrate,
|
||||
render,
|
||||
REACT_ELEMENT_TYPE,
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
||||
} from './render';
|
||||
|
||||
const version = '16.8.0'; // trick libraries to think we are react
|
||||
|
||||
/**
|
||||
* Legacy version of createElement.
|
||||
* @param {import('./internal').VNode["type"]} type The node name or Component constructor
|
||||
*/
|
||||
function createFactory(type) {
|
||||
return createElement.bind(null, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the passed element is a valid (p)react node.
|
||||
* @param {*} element The element to check
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isValidElement(element) {
|
||||
return !!element && element.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap `cloneElement` to abort if the passed element is not a valid element and apply
|
||||
* all vnode normalizations.
|
||||
* @param {import('./internal').VNode} element The vnode to clone
|
||||
* @param {object} props Props to add when cloning
|
||||
* @param {Array<import('./internal').ComponentChildren>} rest Optional component children
|
||||
*/
|
||||
function cloneElement(element) {
|
||||
if (!isValidElement(element)) return element;
|
||||
return preactCloneElement.apply(null, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a component tree from the DOM, including state and event handlers.
|
||||
* @param {import('./internal').PreactElement} container
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function unmountComponentAtNode(container) {
|
||||
if (container._children) {
|
||||
preactRender(null, container);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the matching DOM node for a component
|
||||
* @param {import('./internal').Component} component
|
||||
* @returns {import('./internal').PreactElement | null}
|
||||
*/
|
||||
function findDOMNode(component) {
|
||||
return (
|
||||
(component &&
|
||||
(component.base || (component.nodeType === 1 && component))) ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated way to control batched rendering inside the reconciler, but we
|
||||
* already schedule in batches inside our rendering code
|
||||
* @template Arg
|
||||
* @param {(arg: Arg) => void} callback function that triggers the updated
|
||||
* @param {Arg} [arg] Optional argument that can be passed to the callback
|
||||
*/
|
||||
// eslint-disable-next-line camelcase
|
||||
const unstable_batchedUpdates = (callback, arg) => callback(arg);
|
||||
|
||||
/**
|
||||
* Strict Mode is not implemented in Preact, so we provide a stand-in for it
|
||||
* that just renders its children without imposing any restrictions.
|
||||
*/
|
||||
const StrictMode = Fragment;
|
||||
|
||||
export * from 'preact/hooks';
|
||||
export {
|
||||
version,
|
||||
Children,
|
||||
render,
|
||||
hydrate,
|
||||
unmountComponentAtNode,
|
||||
createPortal,
|
||||
createElement,
|
||||
createContext,
|
||||
createFactory,
|
||||
cloneElement,
|
||||
createRef,
|
||||
Fragment,
|
||||
isValidElement,
|
||||
findDOMNode,
|
||||
Component,
|
||||
PureComponent,
|
||||
memo,
|
||||
forwardRef,
|
||||
// eslint-disable-next-line camelcase
|
||||
unstable_batchedUpdates,
|
||||
StrictMode,
|
||||
Suspense,
|
||||
SuspenseList,
|
||||
lazy,
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
||||
};
|
||||
|
||||
// React copies the named exports to the default one.
|
||||
export default {
|
||||
useState,
|
||||
useReducer,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useImperativeHandle,
|
||||
useMemo,
|
||||
useCallback,
|
||||
useContext,
|
||||
useDebugValue,
|
||||
version,
|
||||
Children,
|
||||
render,
|
||||
hydrate,
|
||||
unmountComponentAtNode,
|
||||
createPortal,
|
||||
createElement,
|
||||
createContext,
|
||||
createFactory,
|
||||
cloneElement,
|
||||
createRef,
|
||||
Fragment,
|
||||
isValidElement,
|
||||
findDOMNode,
|
||||
Component,
|
||||
PureComponent,
|
||||
memo,
|
||||
forwardRef,
|
||||
unstable_batchedUpdates,
|
||||
StrictMode,
|
||||
Suspense,
|
||||
SuspenseList,
|
||||
lazy,
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
||||
};
|
||||
46
build/javascript/node_modules/preact/compat/src/internal.d.ts
generated
vendored
Normal file
46
build/javascript/node_modules/preact/compat/src/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
Component as PreactComponent,
|
||||
VNode as PreactVNode,
|
||||
FunctionalComponent as PreactFunctionalComponent
|
||||
} from '../../src/internal';
|
||||
import { SuspenseProps } from './suspense';
|
||||
|
||||
export { ComponentChildren } from '../..';
|
||||
|
||||
export { PreactElement } from '../../src/internal';
|
||||
|
||||
export interface Component<P = {}, S = {}> extends PreactComponent<P, S> {
|
||||
isReactComponent?: object;
|
||||
isPureReactComponent?: true;
|
||||
_patchedLifecycles?: true;
|
||||
|
||||
_childDidSuspend?(
|
||||
error: Promise<void>,
|
||||
suspendingComponent: Component<any, any>,
|
||||
oldVNode?: VNode
|
||||
): void;
|
||||
_suspendedComponentWillUnmount?(): void;
|
||||
}
|
||||
|
||||
export interface FunctionalComponent<P = {}>
|
||||
extends PreactFunctionalComponent<P> {
|
||||
shouldComponentUpdate?(nextProps: Readonly<P>): boolean;
|
||||
_forwarded?: boolean;
|
||||
_patchedLifecycles?: true;
|
||||
}
|
||||
|
||||
export interface VNode<T = any> extends PreactVNode<T> {
|
||||
$$typeof?: symbol | string;
|
||||
preactCompatNormalized?: boolean;
|
||||
}
|
||||
|
||||
export interface SuspenseState {
|
||||
_suspended?: null | VNode<any>;
|
||||
}
|
||||
|
||||
export interface SuspenseComponent
|
||||
extends PreactComponent<SuspenseProps, SuspenseState> {
|
||||
_pendingSuspensionCount: number;
|
||||
_suspenders: Component[];
|
||||
_detachOnNextRender: null | VNode<any>;
|
||||
}
|
||||
34
build/javascript/node_modules/preact/compat/src/memo.js
generated
vendored
Normal file
34
build/javascript/node_modules/preact/compat/src/memo.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { createElement } from 'preact';
|
||||
import { shallowDiffers } from './util';
|
||||
|
||||
/**
|
||||
* Memoize a component, so that it only updates when the props actually have
|
||||
* changed. This was previously known as `React.pure`.
|
||||
* @param {import('./internal').FunctionalComponent} c functional component
|
||||
* @param {(prev: object, next: object) => boolean} [comparer] Custom equality function
|
||||
* @returns {import('./internal').FunctionalComponent}
|
||||
*/
|
||||
export function memo(c, comparer) {
|
||||
function shouldUpdate(nextProps) {
|
||||
let ref = this.props.ref;
|
||||
let updateRef = ref == nextProps.ref;
|
||||
if (!updateRef && ref) {
|
||||
ref.call ? ref(null) : (ref.current = null);
|
||||
}
|
||||
|
||||
if (!comparer) {
|
||||
return shallowDiffers(this.props, nextProps);
|
||||
}
|
||||
|
||||
return !comparer(this.props, nextProps) || !updateRef;
|
||||
}
|
||||
|
||||
function Memoed(props) {
|
||||
this.shouldComponentUpdate = shouldUpdate;
|
||||
return createElement(c, props);
|
||||
}
|
||||
Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
|
||||
Memoed.prototype.isReactComponent = true;
|
||||
Memoed._forwarded = true;
|
||||
return Memoed;
|
||||
}
|
||||
89
build/javascript/node_modules/preact/compat/src/portals.js
generated
vendored
Normal file
89
build/javascript/node_modules/preact/compat/src/portals.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
import { createElement, hydrate, render, __u as _unmount } from 'preact';
|
||||
|
||||
function ContextProvider(props) {
|
||||
this.getChildContext = () => props.context;
|
||||
return props.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Portal component
|
||||
* @param {object | null | undefined} props
|
||||
*
|
||||
* TODO: this could use the "fake root node" trick from the partial hydration demo
|
||||
*/
|
||||
function Portal(props) {
|
||||
const _this = this;
|
||||
let container = props._container;
|
||||
let wrap = createElement(
|
||||
ContextProvider,
|
||||
{ context: _this.context },
|
||||
props._vnode
|
||||
);
|
||||
|
||||
_this.componentWillUnmount = function() {
|
||||
let parent = _this._temp.parentNode;
|
||||
if (parent) parent.removeChild(_this._temp);
|
||||
_unmount(_this._wrap);
|
||||
};
|
||||
|
||||
// When we change container we should clear our old container and
|
||||
// indicate a new mount.
|
||||
if (_this._container && _this._container !== container) {
|
||||
_this.componentWillUnmount();
|
||||
// if (_this._temp.parentNode) _this._container.removeChild(_this._temp);
|
||||
// _unmount(_this._wrap);
|
||||
_this._hasMounted = false;
|
||||
}
|
||||
|
||||
// When props.vnode is undefined/false/null we are dealing with some kind of
|
||||
// conditional vnode. This should not trigger a render.
|
||||
if (props._vnode) {
|
||||
if (!_this._hasMounted) {
|
||||
// Create a placeholder that we can use to insert into.
|
||||
_this._temp = document.createTextNode('');
|
||||
// temporarily store the current children of the container to restore them after render
|
||||
_this._children = container._children;
|
||||
// Hydrate existing nodes to keep the dom intact, when rendering
|
||||
// wrap into the container.
|
||||
hydrate('', container);
|
||||
// Append to the container (this matches React's behavior)
|
||||
container.appendChild(_this._temp);
|
||||
// At this point we have mounted and should set our container.
|
||||
_this._hasMounted = true;
|
||||
_this._container = container;
|
||||
// Render our wrapping element into temp.
|
||||
render(wrap, container, _this._temp);
|
||||
// restore the previous children of the container
|
||||
container._children = _this._children;
|
||||
// store the children of the new vnode to be used in subsequent re-renders
|
||||
_this._children = _this._temp._children;
|
||||
} else {
|
||||
// When we have mounted and the vnode is present it means the
|
||||
// props have changed or a parent is triggering a rerender.
|
||||
// This implies we only need to call render. But we need to keep
|
||||
// the old tree around, otherwise will treat the vnodes as new and
|
||||
// will wrongly call `componentDidMount` on them
|
||||
container._children = _this._children;
|
||||
render(wrap, container);
|
||||
_this._children = container._children;
|
||||
}
|
||||
}
|
||||
// When we come from a conditional render, on a mounted
|
||||
// portal we should clear the DOM.
|
||||
else if (_this._hasMounted) {
|
||||
_this.componentWillUnmount();
|
||||
// if (_this._temp.parentNode) _this._container.removeChild(_this._temp);
|
||||
// _unmount(_this._wrap);
|
||||
}
|
||||
// Set the wrapping element for future unmounting.
|
||||
_this._wrap = wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
||||
* @param {import('./internal').VNode} vnode The vnode to render
|
||||
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
||||
*/
|
||||
export function createPortal(vnode, container) {
|
||||
return createElement(Portal, { _vnode: vnode, _container: container });
|
||||
}
|
||||
195
build/javascript/node_modules/preact/compat/src/render.js
generated
vendored
Normal file
195
build/javascript/node_modules/preact/compat/src/render.js
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
import {
|
||||
render as preactRender,
|
||||
hydrate as preactHydrate,
|
||||
options,
|
||||
toChildArray,
|
||||
Component
|
||||
} from 'preact';
|
||||
|
||||
export const REACT_ELEMENT_TYPE =
|
||||
(typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
|
||||
0xeac7;
|
||||
|
||||
const CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
||||
|
||||
// Input types for which onchange should not be converted to oninput.
|
||||
// type="file|checkbox|radio", plus "range" in IE11.
|
||||
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
|
||||
const ONCHANGE_INPUT_TYPES =
|
||||
typeof Symbol != 'undefined' ? /fil|che|rad/i : /fil|che|ra/i;
|
||||
|
||||
// Some libraries like `react-virtualized` explicitly check for this.
|
||||
Component.prototype.isReactComponent = {};
|
||||
|
||||
// `UNSAFE_*` lifecycle hooks
|
||||
// Preact only ever invokes the unprefixed methods.
|
||||
// Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
|
||||
// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
|
||||
// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
|
||||
// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
|
||||
// See https://github.com/preactjs/preact/issues/1941
|
||||
[
|
||||
'componentWillMount',
|
||||
'componentWillReceiveProps',
|
||||
'componentWillUpdate'
|
||||
].forEach(key => {
|
||||
Object.defineProperty(Component.prototype, key, {
|
||||
configurable: true,
|
||||
get() {
|
||||
return this['UNSAFE_' + key];
|
||||
},
|
||||
set(v) {
|
||||
Object.defineProperty(this, key, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: v
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Proxy render() since React returns a Component reference.
|
||||
* @param {import('./internal').VNode} vnode VNode tree to render
|
||||
* @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
|
||||
* @param {() => void} [callback] Optional callback that will be called after rendering
|
||||
* @returns {import('./internal').Component | null} The root component reference or null
|
||||
*/
|
||||
export function render(vnode, parent, callback) {
|
||||
// React destroys any existing DOM nodes, see #1727
|
||||
// ...but only on the first render, see #1828
|
||||
if (parent._children == null) {
|
||||
parent.textContent = '';
|
||||
}
|
||||
|
||||
preactRender(vnode, parent);
|
||||
if (typeof callback == 'function') callback();
|
||||
|
||||
return vnode ? vnode._component : null;
|
||||
}
|
||||
|
||||
export function hydrate(vnode, parent, callback) {
|
||||
preactHydrate(vnode, parent);
|
||||
if (typeof callback == 'function') callback();
|
||||
|
||||
return vnode ? vnode._component : null;
|
||||
}
|
||||
|
||||
let oldEventHook = options.event;
|
||||
options.event = e => {
|
||||
if (oldEventHook) e = oldEventHook(e);
|
||||
e.persist = empty;
|
||||
e.isPropagationStopped = isPropagationStopped;
|
||||
e.isDefaultPrevented = isDefaultPrevented;
|
||||
return (e.nativeEvent = e);
|
||||
};
|
||||
|
||||
function empty() {}
|
||||
|
||||
function isPropagationStopped() {
|
||||
return this.cancelBubble;
|
||||
}
|
||||
|
||||
function isDefaultPrevented() {
|
||||
return this.defaultPrevented;
|
||||
}
|
||||
|
||||
let classNameDescriptor = {
|
||||
configurable: true,
|
||||
get() {
|
||||
return this.class;
|
||||
}
|
||||
};
|
||||
|
||||
let oldVNodeHook = options.vnode;
|
||||
options.vnode = vnode => {
|
||||
let type = vnode.type;
|
||||
let props = vnode.props;
|
||||
let normalizedProps = props;
|
||||
|
||||
// only normalize props on Element nodes
|
||||
if (typeof type === 'string') {
|
||||
normalizedProps = {};
|
||||
|
||||
for (let i in props) {
|
||||
let value = props[i];
|
||||
|
||||
if (i === 'defaultValue' && 'value' in props && props.value == null) {
|
||||
// `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
|
||||
// `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
|
||||
i = 'value';
|
||||
} else if (i === 'download' && value === true) {
|
||||
// Calling `setAttribute` with a truthy value will lead to it being
|
||||
// passed as a stringified value, e.g. `download="true"`. React
|
||||
// converts it to an empty string instead, otherwise the attribute
|
||||
// value will be used as the file name and the file will be called
|
||||
// "true" upon downloading it.
|
||||
value = '';
|
||||
} else if (/ondoubleclick/i.test(i)) {
|
||||
i = 'ondblclick';
|
||||
} else if (
|
||||
/^onchange(textarea|input)/i.test(i + type) &&
|
||||
!ONCHANGE_INPUT_TYPES.test(props.type)
|
||||
) {
|
||||
i = 'oninput';
|
||||
} else if (/^on(Ani|Tra|Tou|BeforeInp)/.test(i)) {
|
||||
i = i.toLowerCase();
|
||||
} else if (CAMEL_PROPS.test(i)) {
|
||||
i = i.replace(/[A-Z0-9]/, '-$&').toLowerCase();
|
||||
} else if (value === null) {
|
||||
value = undefined;
|
||||
}
|
||||
|
||||
normalizedProps[i] = value;
|
||||
}
|
||||
|
||||
// Add support for array select values: <select multiple value={[]} />
|
||||
if (
|
||||
type == 'select' &&
|
||||
normalizedProps.multiple &&
|
||||
Array.isArray(normalizedProps.value)
|
||||
) {
|
||||
// forEach() always returns undefined, which we abuse here to unset the value prop.
|
||||
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
||||
child.props.selected =
|
||||
normalizedProps.value.indexOf(child.props.value) != -1;
|
||||
});
|
||||
}
|
||||
|
||||
vnode.props = normalizedProps;
|
||||
}
|
||||
|
||||
if (type && props.class != props.className) {
|
||||
classNameDescriptor.enumerable = 'className' in props;
|
||||
if (props.className != null) normalizedProps.class = props.className;
|
||||
Object.defineProperty(normalizedProps, 'className', classNameDescriptor);
|
||||
}
|
||||
|
||||
vnode.$$typeof = REACT_ELEMENT_TYPE;
|
||||
|
||||
if (oldVNodeHook) oldVNodeHook(vnode);
|
||||
};
|
||||
|
||||
// Only needed for react-relay
|
||||
let currentComponent;
|
||||
const oldBeforeRender = options._render;
|
||||
options._render = function(vnode) {
|
||||
if (oldBeforeRender) {
|
||||
oldBeforeRender(vnode);
|
||||
}
|
||||
currentComponent = vnode._component;
|
||||
};
|
||||
|
||||
// This is a very very private internal function for React it
|
||||
// is used to sort-of do runtime dependency injection. So far
|
||||
// only `react-relay` makes use of it. It uses it to read the
|
||||
// context value.
|
||||
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
||||
ReactCurrentDispatcher: {
|
||||
current: {
|
||||
readContext(context) {
|
||||
return currentComponent._globalContext[context._id].props.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
14
build/javascript/node_modules/preact/compat/src/suspense-list.d.ts
generated
vendored
Normal file
14
build/javascript/node_modules/preact/compat/src/suspense-list.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Component, ComponentChild } from '../../src';
|
||||
|
||||
//
|
||||
// SuspenseList
|
||||
// -----------------------------------
|
||||
|
||||
export interface SuspenseListProps {
|
||||
children?: preact.ComponentChildren;
|
||||
revealOrder?: 'forwards' | 'backwards' | 'together';
|
||||
}
|
||||
|
||||
export class SuspenseList extends Component<SuspenseListProps> {
|
||||
render(): ComponentChild;
|
||||
}
|
||||
126
build/javascript/node_modules/preact/compat/src/suspense-list.js
generated
vendored
Normal file
126
build/javascript/node_modules/preact/compat/src/suspense-list.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import { Component, toChildArray } from 'preact';
|
||||
import { suspended } from './suspense.js';
|
||||
|
||||
// Indexes to linked list nodes (nodes are stored as arrays to save bytes).
|
||||
const SUSPENDED_COUNT = 0;
|
||||
const RESOLVED_COUNT = 1;
|
||||
const NEXT_NODE = 2;
|
||||
|
||||
// Having custom inheritance instead of a class here saves a lot of bytes.
|
||||
export function SuspenseList() {
|
||||
this._next = null;
|
||||
this._map = null;
|
||||
}
|
||||
|
||||
// Mark one of child's earlier suspensions as resolved.
|
||||
// Some pending callbacks may become callable due to this
|
||||
// (e.g. the last suspended descendant gets resolved when
|
||||
// revealOrder === 'together'). Process those callbacks as well.
|
||||
const resolve = (list, child, node) => {
|
||||
if (++node[RESOLVED_COUNT] === node[SUSPENDED_COUNT]) {
|
||||
// The number a child (or any of its descendants) has been suspended
|
||||
// matches the number of times it's been resolved. Therefore we
|
||||
// mark the child as completely resolved by deleting it from ._map.
|
||||
// This is used to figure out when *all* children have been completely
|
||||
// resolved when revealOrder is 'together'.
|
||||
list._map.delete(child);
|
||||
}
|
||||
|
||||
// If revealOrder is falsy then we can do an early exit, as the
|
||||
// callbacks won't get queued in the node anyway.
|
||||
// If revealOrder is 'together' then also do an early exit
|
||||
// if all suspended descendants have not yet been resolved.
|
||||
if (
|
||||
!list.props.revealOrder ||
|
||||
(list.props.revealOrder[0] === 't' && list._map.size)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Walk the currently suspended children in order, calling their
|
||||
// stored callbacks on the way. Stop if we encounter a child that
|
||||
// has not been completely resolved yet.
|
||||
node = list._next;
|
||||
while (node) {
|
||||
while (node.length > 3) {
|
||||
node.pop()();
|
||||
}
|
||||
if (node[RESOLVED_COUNT] < node[SUSPENDED_COUNT]) {
|
||||
break;
|
||||
}
|
||||
list._next = node = node[NEXT_NODE];
|
||||
}
|
||||
};
|
||||
|
||||
// Things we do here to save some bytes but are not proper JS inheritance:
|
||||
// - call `new Component()` as the prototype
|
||||
// - do not set `Suspense.prototype.constructor` to `Suspense`
|
||||
SuspenseList.prototype = new Component();
|
||||
|
||||
SuspenseList.prototype._suspended = function(child) {
|
||||
const list = this;
|
||||
const delegated = suspended(list._vnode);
|
||||
|
||||
let node = list._map.get(child);
|
||||
node[SUSPENDED_COUNT]++;
|
||||
|
||||
return unsuspend => {
|
||||
const wrappedUnsuspend = () => {
|
||||
if (!list.props.revealOrder) {
|
||||
// Special case the undefined (falsy) revealOrder, as there
|
||||
// is no need to coordinate a specific order or unsuspends.
|
||||
unsuspend();
|
||||
} else {
|
||||
node.push(unsuspend);
|
||||
resolve(list, child, node);
|
||||
}
|
||||
};
|
||||
if (delegated) {
|
||||
delegated(wrappedUnsuspend);
|
||||
} else {
|
||||
wrappedUnsuspend();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
SuspenseList.prototype.render = function(props) {
|
||||
this._next = null;
|
||||
this._map = new Map();
|
||||
|
||||
const children = toChildArray(props.children);
|
||||
if (props.revealOrder && props.revealOrder[0] === 'b') {
|
||||
// If order === 'backwards' (or, well, anything starting with a 'b')
|
||||
// then flip the child list around so that the last child will be
|
||||
// the first in the linked list.
|
||||
children.reverse();
|
||||
}
|
||||
// Build the linked list. Iterate through the children in reverse order
|
||||
// so that `_next` points to the first linked list node to be resolved.
|
||||
for (let i = children.length; i--; ) {
|
||||
// Create a new linked list node as an array of form:
|
||||
// [suspended_count, resolved_count, next_node]
|
||||
// where suspended_count and resolved_count are numeric counters for
|
||||
// keeping track how many times a node has been suspended and resolved.
|
||||
//
|
||||
// Note that suspended_count starts from 1 instead of 0, so we can block
|
||||
// processing callbacks until componentDidMount has been called. In a sense
|
||||
// node is suspended at least until componentDidMount gets called!
|
||||
//
|
||||
// Pending callbacks are added to the end of the node:
|
||||
// [suspended_count, resolved_count, next_node, callback_0, callback_1, ...]
|
||||
this._map.set(children[i], (this._next = [1, 0, this._next]));
|
||||
}
|
||||
return props.children;
|
||||
};
|
||||
|
||||
SuspenseList.prototype.componentDidUpdate = SuspenseList.prototype.componentDidMount = function() {
|
||||
// Iterate through all children after mounting for two reasons:
|
||||
// 1. As each node[SUSPENDED_COUNT] starts from 1, this iteration increases
|
||||
// each node[RELEASED_COUNT] by 1, therefore balancing the counters.
|
||||
// The nodes can now be completely consumed from the linked list.
|
||||
// 2. Handle nodes that might have gotten resolved between render and
|
||||
// componentDidMount.
|
||||
this._map.forEach((node, child) => {
|
||||
resolve(this, child, node);
|
||||
});
|
||||
};
|
||||
15
build/javascript/node_modules/preact/compat/src/suspense.d.ts
generated
vendored
Normal file
15
build/javascript/node_modules/preact/compat/src/suspense.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Component, ComponentChild } from '../../src';
|
||||
|
||||
//
|
||||
// Suspense/lazy
|
||||
// -----------------------------------
|
||||
export function lazy<T>(loader: () => Promise<{ default: T }>): T;
|
||||
|
||||
export interface SuspenseProps {
|
||||
children?: preact.ComponentChildren;
|
||||
fallback: preact.ComponentChildren;
|
||||
}
|
||||
|
||||
export class Suspense extends Component<SuspenseProps> {
|
||||
render(): ComponentChild;
|
||||
}
|
||||
199
build/javascript/node_modules/preact/compat/src/suspense.js
generated
vendored
Normal file
199
build/javascript/node_modules/preact/compat/src/suspense.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
import { Component, createElement, options, Fragment } from 'preact';
|
||||
import { assign } from './util';
|
||||
|
||||
const oldCatchError = options._catchError;
|
||||
options._catchError = function(error, newVNode, oldVNode) {
|
||||
if (error.then) {
|
||||
/** @type {import('./internal').Component} */
|
||||
let component;
|
||||
let vnode = newVNode;
|
||||
|
||||
for (; (vnode = vnode._parent); ) {
|
||||
if ((component = vnode._component) && component._childDidSuspend) {
|
||||
if (newVNode._dom == null) {
|
||||
newVNode._dom = oldVNode._dom;
|
||||
newVNode._children = oldVNode._children;
|
||||
}
|
||||
// Don't call oldCatchError if we found a Suspense
|
||||
return component._childDidSuspend(error, newVNode._component);
|
||||
}
|
||||
}
|
||||
}
|
||||
oldCatchError(error, newVNode, oldVNode);
|
||||
};
|
||||
|
||||
function detachedClone(vnode) {
|
||||
if (vnode) {
|
||||
vnode = assign({}, vnode);
|
||||
vnode._component = null;
|
||||
vnode._children = vnode._children && vnode._children.map(detachedClone);
|
||||
}
|
||||
return vnode;
|
||||
}
|
||||
|
||||
function removeOriginal(vnode) {
|
||||
if (vnode) {
|
||||
vnode._original = null;
|
||||
vnode._children = vnode._children && vnode._children.map(removeOriginal);
|
||||
}
|
||||
return vnode;
|
||||
}
|
||||
|
||||
// having custom inheritance instead of a class here saves a lot of bytes
|
||||
export function Suspense() {
|
||||
// we do not call super here to golf some bytes...
|
||||
this._pendingSuspensionCount = 0;
|
||||
this._suspenders = null;
|
||||
this._detachOnNextRender = null;
|
||||
}
|
||||
|
||||
// Things we do here to save some bytes but are not proper JS inheritance:
|
||||
// - call `new Component()` as the prototype
|
||||
// - do not set `Suspense.prototype.constructor` to `Suspense`
|
||||
Suspense.prototype = new Component();
|
||||
|
||||
/**
|
||||
* @param {Promise} promise The thrown promise
|
||||
* @param {Component<any, any>} suspendingComponent The suspending component
|
||||
*/
|
||||
Suspense.prototype._childDidSuspend = function(promise, suspendingComponent) {
|
||||
/** @type {import('./internal').SuspenseComponent} */
|
||||
const c = this;
|
||||
|
||||
if (c._suspenders == null) {
|
||||
c._suspenders = [];
|
||||
}
|
||||
c._suspenders.push(suspendingComponent);
|
||||
|
||||
const resolve = suspended(c._vnode);
|
||||
|
||||
let resolved = false;
|
||||
const onResolved = () => {
|
||||
if (resolved) return;
|
||||
|
||||
resolved = true;
|
||||
suspendingComponent.componentWillUnmount =
|
||||
suspendingComponent._suspendedComponentWillUnmount;
|
||||
|
||||
if (resolve) {
|
||||
resolve(onSuspensionComplete);
|
||||
} else {
|
||||
onSuspensionComplete();
|
||||
}
|
||||
};
|
||||
|
||||
suspendingComponent._suspendedComponentWillUnmount =
|
||||
suspendingComponent.componentWillUnmount;
|
||||
suspendingComponent.componentWillUnmount = () => {
|
||||
onResolved();
|
||||
|
||||
if (suspendingComponent._suspendedComponentWillUnmount) {
|
||||
suspendingComponent._suspendedComponentWillUnmount();
|
||||
}
|
||||
};
|
||||
|
||||
const onSuspensionComplete = () => {
|
||||
if (!--c._pendingSuspensionCount) {
|
||||
c._vnode._children[0] = removeOriginal(c.state._suspended);
|
||||
c.setState({ _suspended: (c._detachOnNextRender = null) });
|
||||
|
||||
let suspended;
|
||||
while ((suspended = c._suspenders.pop())) {
|
||||
suspended.forceUpdate();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* We do not set `suspended: true` during hydration because we want the actual markup
|
||||
* to remain on screen and hydrate it when the suspense actually gets resolved.
|
||||
* While in non-hydration cases the usual fallback -> component flow would occour.
|
||||
*/
|
||||
const vnode = c._vnode;
|
||||
const wasHydrating = vnode && vnode._hydrating === true;
|
||||
if (!wasHydrating && !c._pendingSuspensionCount++) {
|
||||
c.setState({ _suspended: (c._detachOnNextRender = c._vnode._children[0]) });
|
||||
}
|
||||
promise.then(onResolved, onResolved);
|
||||
};
|
||||
|
||||
Suspense.prototype.componentWillUnmount = function() {
|
||||
this._suspenders = [];
|
||||
};
|
||||
|
||||
Suspense.prototype.render = function(props, state) {
|
||||
if (this._detachOnNextRender) {
|
||||
// When the Suspense's _vnode was created by a call to createVNode
|
||||
// (i.e. due to a setState further up in the tree)
|
||||
// it's _children prop is null, in this case we "forget" about the parked vnodes to detach
|
||||
if (this._vnode._children)
|
||||
this._vnode._children[0] = detachedClone(this._detachOnNextRender);
|
||||
this._detachOnNextRender = null;
|
||||
}
|
||||
|
||||
// Wrap fallback tree in a VNode that prevents itself from being marked as aborting mid-hydration:
|
||||
const fallback =
|
||||
state._suspended && createElement(Fragment, null, props.fallback);
|
||||
if (fallback) fallback._hydrating = null;
|
||||
|
||||
return [
|
||||
createElement(Fragment, null, state._suspended ? null : props.children),
|
||||
fallback
|
||||
];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks and calls the parent component's _suspended method, passing in the
|
||||
* suspended vnode. This is a way for a parent (e.g. SuspenseList) to get notified
|
||||
* that one of its children/descendants suspended.
|
||||
*
|
||||
* The parent MAY return a callback. The callback will get called when the
|
||||
* suspension resolves, notifying the parent of the fact.
|
||||
* Moreover, the callback gets function `unsuspend` as a parameter. The resolved
|
||||
* child descendant will not actually get unsuspended until `unsuspend` gets called.
|
||||
* This is a way for the parent to delay unsuspending.
|
||||
*
|
||||
* If the parent does not return a callback then the resolved vnode
|
||||
* gets unsuspended immediately when it resolves.
|
||||
*
|
||||
* @param {import('../src/internal').VNode} vnode
|
||||
* @returns {((unsuspend: () => void) => void)?}
|
||||
*/
|
||||
export function suspended(vnode) {
|
||||
let component = vnode._parent._component;
|
||||
return component && component._suspended && component._suspended(vnode);
|
||||
}
|
||||
|
||||
export function lazy(loader) {
|
||||
let prom;
|
||||
let component;
|
||||
let error;
|
||||
|
||||
function Lazy(props) {
|
||||
if (!prom) {
|
||||
prom = loader();
|
||||
prom.then(
|
||||
exports => {
|
||||
component = exports.default || exports;
|
||||
},
|
||||
e => {
|
||||
error = e;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!component) {
|
||||
throw prom;
|
||||
}
|
||||
|
||||
return createElement(component, props);
|
||||
}
|
||||
|
||||
Lazy.displayName = 'Lazy';
|
||||
Lazy._forwarded = true;
|
||||
return Lazy;
|
||||
}
|
||||
23
build/javascript/node_modules/preact/compat/src/util.js
generated
vendored
Normal file
23
build/javascript/node_modules/preact/compat/src/util.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two objects have a different shape
|
||||
* @param {object} a
|
||||
* @param {object} b
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function shallowDiffers(a, b) {
|
||||
for (let i in a) if (i !== '__source' && !(i in b)) return true;
|
||||
for (let i in b) if (i !== '__source' && a[i] !== b[i]) return true;
|
||||
return false;
|
||||
}
|
||||
21
build/javascript/node_modules/preact/debug/LICENSE
generated
vendored
Normal file
21
build/javascript/node_modules/preact/debug/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
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.
|
||||
18
build/javascript/node_modules/preact/debug/package.json
generated
vendored
Normal file
18
build/javascript/node_modules/preact/debug/package.json
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
54
build/javascript/node_modules/preact/debug/src/check-props.js
generated
vendored
Normal file
54
build/javascript/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
build/javascript/node_modules/preact/debug/src/component-stack.js
generated
vendored
Normal file
146
build/javascript/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
build/javascript/node_modules/preact/debug/src/constants.js
generated
vendored
Normal file
3
build/javascript/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;
|
||||
459
build/javascript/node_modules/preact/debug/src/debug.js
generated
vendored
Normal file
459
build/javascript/node_modules/preact/debug/src/debug.js
generated
vendored
Normal file
@@ -0,0 +1,459 @@
|
||||
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) => {
|
||||
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 {
|
||||
oldCatchError(error, vnode, oldVNode);
|
||||
|
||||
// when an error was handled by an ErrorBoundary we will nontheless 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 (child && child.type === undefined) {
|
||||
// Remove internal vnode keys that will always be patched
|
||||
delete child._parent;
|
||||
delete child._depth;
|
||||
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)}`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** @type {import('./internal').Component} */
|
||||
const component = vnode._component;
|
||||
if (component && component.__hooks) {
|
||||
let hooks = component.__hooks;
|
||||
if (Array.isArray(hooks._list)) {
|
||||
hooks._list.forEach(hook => {
|
||||
if (hook._factory && (!hook._args || !Array.isArray(hook._args))) {
|
||||
let componentName = getDisplayName(vnode);
|
||||
console.warn(
|
||||
`In ${componentName} you are calling useMemo/useCallback without passing arguments.\n` +
|
||||
`This is a noop since it will not be able to memoize, it will execute it every render.` +
|
||||
`\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())}`
|
||||
);
|
||||
}
|
||||
} else if (this._parentDom == null) {
|
||||
console.warn(
|
||||
`Can't call "this.setState" 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 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 + '>' : ' />'
|
||||
}`;
|
||||
}
|
||||
6
build/javascript/node_modules/preact/debug/src/index.js
generated
vendored
Normal file
6
build/javascript/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
build/javascript/node_modules/preact/debug/src/internal.d.ts
generated
vendored
Normal file
82
build/javascript/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
build/javascript/node_modules/preact/debug/src/util.js
generated
vendored
Normal file
11
build/javascript/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);
|
||||
}
|
||||
21
build/javascript/node_modules/preact/devtools/LICENSE
generated
vendored
Normal file
21
build/javascript/node_modules/preact/devtools/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
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.
|
||||
15
build/javascript/node_modules/preact/devtools/package.json
generated
vendored
Normal file
15
build/javascript/node_modules/preact/devtools/package.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "preact-devtools",
|
||||
"amdName": "preactDevtools",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Preact bridge for Preact devtools",
|
||||
"main": "dist/devtools.js",
|
||||
"module": "dist/devtools.module.js",
|
||||
"umd:main": "dist/devtools.umd.js",
|
||||
"source": "src/index.js",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"preact": "^10.0.0"
|
||||
}
|
||||
}
|
||||
10
build/javascript/node_modules/preact/devtools/src/devtools.js
generated
vendored
Normal file
10
build/javascript/node_modules/preact/devtools/src/devtools.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { options, Fragment, Component } from 'preact';
|
||||
|
||||
export function initDevTools() {
|
||||
if (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {
|
||||
window.__PREACT_DEVTOOLS__.attachPreact('10.5.4', options, {
|
||||
Fragment,
|
||||
Component
|
||||
});
|
||||
}
|
||||
}
|
||||
3
build/javascript/node_modules/preact/devtools/src/index.js
generated
vendored
Normal file
3
build/javascript/node_modules/preact/devtools/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { initDevTools } from './devtools';
|
||||
|
||||
initDevTools();
|
||||
21
build/javascript/node_modules/preact/hooks/LICENSE
generated
vendored
Normal file
21
build/javascript/node_modules/preact/hooks/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
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.
|
||||
26
build/javascript/node_modules/preact/hooks/package.json
generated
vendored
Normal file
26
build/javascript/node_modules/preact/hooks/package.json
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "preact-hooks",
|
||||
"amdName": "preactHooks",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Hook addon for Preact",
|
||||
"main": "dist/hooks.js",
|
||||
"module": "dist/hooks.module.js",
|
||||
"umd:main": "dist/hooks.umd.js",
|
||||
"source": "src/index.js",
|
||||
"license": "MIT",
|
||||
"types": "src/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "microbundle build --raw",
|
||||
"dev": "microbundle watch --raw --format cjs",
|
||||
"test": "npm-run-all build --parallel test:karma",
|
||||
"test:karma": "karma start test/karma.conf.js --single-run",
|
||||
"test:karma:watch": "karma start test/karma.conf.js --no-single-run"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"preact": "^10.0.0"
|
||||
},
|
||||
"mangle": {
|
||||
"regex": "^_"
|
||||
}
|
||||
}
|
||||
133
build/javascript/node_modules/preact/hooks/src/index.d.ts
generated
vendored
Normal file
133
build/javascript/node_modules/preact/hooks/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
import { PreactContext, Ref as PreactRef } from '../..';
|
||||
|
||||
type Inputs = ReadonlyArray<unknown>;
|
||||
|
||||
export type StateUpdater<S> = (value: S | ((prevState: S) => S)) => void;
|
||||
/**
|
||||
* Returns a stateful value, and a function to update it.
|
||||
* @param initialState The initial value (or a function that returns the initial value)
|
||||
*/
|
||||
export function useState<S>(initialState: S | (() => S)): [S, StateUpdater<S>];
|
||||
|
||||
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
||||
/**
|
||||
* An alternative to `useState`.
|
||||
*
|
||||
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
||||
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
||||
* updates because you can pass `dispatch` down instead of callbacks.
|
||||
* @param reducer Given the current state and an action, returns the new state
|
||||
* @param initialState The initial value to store as state
|
||||
*/
|
||||
export function useReducer<S, A>(
|
||||
reducer: Reducer<S, A>,
|
||||
initialState: S
|
||||
): [S, (action: A) => void];
|
||||
|
||||
/**
|
||||
* An alternative to `useState`.
|
||||
*
|
||||
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
||||
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
||||
* updates because you can pass `dispatch` down instead of callbacks.
|
||||
* @param reducer Given the current state and an action, returns the new state
|
||||
* @param initialArg The initial argument to pass to the `init` function
|
||||
* @param init A function that, given the `initialArg`, returns the initial value to store as state
|
||||
*/
|
||||
export function useReducer<S, A, I>(
|
||||
reducer: Reducer<S, A>,
|
||||
initialArg: I,
|
||||
init: (arg: I) => S
|
||||
): [S, (action: A) => void];
|
||||
|
||||
type PropRef<T> = { current?: T };
|
||||
type Ref<T> = { current: T };
|
||||
|
||||
/**
|
||||
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
||||
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
||||
*
|
||||
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
||||
* value around similar to how you’d use instance fields in classes.
|
||||
*/
|
||||
export function useRef<T>(initialValue?: T | null): Ref<T>;
|
||||
|
||||
/**
|
||||
* `useRef` without an initial value is the special case handling `ref` props.
|
||||
* If you want a non prop-based, mutable ref, you can explicitly give it an initial value of undefined/null/etc.
|
||||
* You should explicitly set the type parameter for the expected ref value to either a DOM Element like `HTMLInputElement` or a `Component`
|
||||
*/
|
||||
export function useRef<T = unknown>(): PropRef<T>;
|
||||
|
||||
type EffectCallback = () => void | (() => void);
|
||||
/**
|
||||
* Accepts a function that contains imperative, possibly effectful code.
|
||||
* The effects run after browser paint, without blocking it.
|
||||
*
|
||||
* @param effect Imperative function that can return a cleanup function
|
||||
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
||||
*/
|
||||
export function useEffect(effect: EffectCallback, inputs?: Inputs): void;
|
||||
|
||||
type CreateHandle = () => object;
|
||||
|
||||
/**
|
||||
* @param ref The ref that will be mutated
|
||||
* @param create The function that will be executed to get the value that will be attached to
|
||||
* ref.current
|
||||
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
||||
*/
|
||||
export function useImperativeHandle<T, R extends T>(
|
||||
ref: PreactRef<T>,
|
||||
create: () => R,
|
||||
inputs?: Inputs
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Accepts a function that contains imperative, possibly effectful code.
|
||||
* Use this to read layout from the DOM and synchronously re-render.
|
||||
* Updates scheduled inside `useLayoutEffect` will be flushed synchronously, after all DOM mutations but before the browser has a chance to paint.
|
||||
* Prefer the standard `useEffect` hook when possible to avoid blocking visual updates.
|
||||
*
|
||||
* @param effect Imperative function that can return a cleanup function
|
||||
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
||||
*/
|
||||
export function useLayoutEffect(effect: EffectCallback, inputs?: Inputs): void;
|
||||
|
||||
/**
|
||||
* Returns a memoized version of the callback that only changes if one of the `inputs`
|
||||
* has changed (using ===).
|
||||
*/
|
||||
export function useCallback<T extends Function>(callback: T, inputs: Inputs): T;
|
||||
|
||||
/**
|
||||
* Pass a factory function and an array of inputs.
|
||||
* useMemo will only recompute the memoized value when one of the inputs has changed.
|
||||
* This optimization helps to avoid expensive calculations on every render.
|
||||
* If no array is provided, a new value will be computed whenever a new function instance is passed as the first argument.
|
||||
*/
|
||||
// for `inputs`, allow undefined, but don't make it optional as that is very likely a mistake
|
||||
export function useMemo<T>(factory: () => T, inputs: Inputs | undefined): T;
|
||||
|
||||
/**
|
||||
* Returns the current context value, as given by the nearest context provider for the given context.
|
||||
* When the provider updates, this Hook will trigger a rerender with the latest context value.
|
||||
*
|
||||
* @param context The context you want to use
|
||||
*/
|
||||
export function useContext<T>(context: PreactContext<T>): T;
|
||||
|
||||
/**
|
||||
* Customize the displayed value in the devtools panel.
|
||||
*
|
||||
* @param value Custom hook name or object that is passed to formatter
|
||||
* @param formatter Formatter to modify value before sending it to the devtools
|
||||
*/
|
||||
export function useDebugValue<T>(
|
||||
value: T,
|
||||
formatter?: (value: T) => any
|
||||
): void;
|
||||
|
||||
export function useErrorBoundary(
|
||||
callback?: (error: any) => Promise<void> | void
|
||||
): [any, () => void];
|
||||
360
build/javascript/node_modules/preact/hooks/src/index.js
generated
vendored
Normal file
360
build/javascript/node_modules/preact/hooks/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,360 @@
|
||||
import { options } from 'preact';
|
||||
|
||||
/** @type {number} */
|
||||
let currentIndex;
|
||||
|
||||
/** @type {import('./internal').Component} */
|
||||
let currentComponent;
|
||||
|
||||
/** @type {number} */
|
||||
let currentHook = 0;
|
||||
|
||||
/** @type {Array<import('./internal').Component>} */
|
||||
let afterPaintEffects = [];
|
||||
|
||||
let oldBeforeRender = options._render;
|
||||
let oldAfterDiff = options.diffed;
|
||||
let oldCommit = options._commit;
|
||||
let oldBeforeUnmount = options.unmount;
|
||||
|
||||
const RAF_TIMEOUT = 100;
|
||||
let prevRaf;
|
||||
|
||||
options._render = vnode => {
|
||||
if (oldBeforeRender) oldBeforeRender(vnode);
|
||||
|
||||
currentComponent = vnode._component;
|
||||
currentIndex = 0;
|
||||
|
||||
const hooks = currentComponent.__hooks;
|
||||
if (hooks) {
|
||||
hooks._pendingEffects.forEach(invokeCleanup);
|
||||
hooks._pendingEffects.forEach(invokeEffect);
|
||||
hooks._pendingEffects = [];
|
||||
}
|
||||
};
|
||||
|
||||
options.diffed = vnode => {
|
||||
if (oldAfterDiff) oldAfterDiff(vnode);
|
||||
|
||||
const c = vnode._component;
|
||||
if (c && c.__hooks && c.__hooks._pendingEffects.length) {
|
||||
afterPaint(afterPaintEffects.push(c));
|
||||
}
|
||||
};
|
||||
|
||||
options._commit = (vnode, commitQueue) => {
|
||||
commitQueue.some(component => {
|
||||
try {
|
||||
component._renderCallbacks.forEach(invokeCleanup);
|
||||
component._renderCallbacks = component._renderCallbacks.filter(cb =>
|
||||
cb._value ? invokeEffect(cb) : true
|
||||
);
|
||||
} catch (e) {
|
||||
commitQueue.some(c => {
|
||||
if (c._renderCallbacks) c._renderCallbacks = [];
|
||||
});
|
||||
commitQueue = [];
|
||||
options._catchError(e, component._vnode);
|
||||
}
|
||||
});
|
||||
|
||||
if (oldCommit) oldCommit(vnode, commitQueue);
|
||||
};
|
||||
|
||||
options.unmount = vnode => {
|
||||
if (oldBeforeUnmount) oldBeforeUnmount(vnode);
|
||||
|
||||
const c = vnode._component;
|
||||
if (c && c.__hooks) {
|
||||
try {
|
||||
c.__hooks._list.forEach(invokeCleanup);
|
||||
} catch (e) {
|
||||
options._catchError(e, c._vnode);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a hook's state from the currentComponent
|
||||
* @param {number} index The index of the hook to get
|
||||
* @param {number} type The index of the hook to get
|
||||
* @returns {import('./internal').HookState}
|
||||
*/
|
||||
function getHookState(index, type) {
|
||||
if (options._hook) {
|
||||
options._hook(currentComponent, index, currentHook || type);
|
||||
}
|
||||
currentHook = 0;
|
||||
|
||||
// Largely inspired by:
|
||||
// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs
|
||||
// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs
|
||||
// Other implementations to look at:
|
||||
// * https://codesandbox.io/s/mnox05qp8
|
||||
const hooks =
|
||||
currentComponent.__hooks ||
|
||||
(currentComponent.__hooks = {
|
||||
_list: [],
|
||||
_pendingEffects: []
|
||||
});
|
||||
|
||||
if (index >= hooks._list.length) {
|
||||
hooks._list.push({});
|
||||
}
|
||||
return hooks._list[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./index').StateUpdater<any>} initialState
|
||||
*/
|
||||
export function useState(initialState) {
|
||||
currentHook = 1;
|
||||
return useReducer(invokeOrReturn, initialState);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./index').Reducer<any, any>} reducer
|
||||
* @param {import('./index').StateUpdater<any>} initialState
|
||||
* @param {(initialState: any) => void} [init]
|
||||
* @returns {[ any, (state: any) => void ]}
|
||||
*/
|
||||
export function useReducer(reducer, initialState, init) {
|
||||
/** @type {import('./internal').ReducerHookState} */
|
||||
const hookState = getHookState(currentIndex++, 2);
|
||||
hookState._reducer = reducer;
|
||||
if (!hookState._component) {
|
||||
hookState._value = [
|
||||
!init ? invokeOrReturn(undefined, initialState) : init(initialState),
|
||||
|
||||
action => {
|
||||
const nextValue = hookState._reducer(hookState._value[0], action);
|
||||
if (hookState._value[0] !== nextValue) {
|
||||
hookState._value = [nextValue, hookState._value[1]];
|
||||
hookState._component.setState({});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
hookState._component = currentComponent;
|
||||
}
|
||||
|
||||
return hookState._value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./internal').Effect} callback
|
||||
* @param {any[]} args
|
||||
*/
|
||||
export function useEffect(callback, args) {
|
||||
/** @type {import('./internal').EffectHookState} */
|
||||
const state = getHookState(currentIndex++, 3);
|
||||
if (!options._skipEffects && argsChanged(state._args, args)) {
|
||||
state._value = callback;
|
||||
state._args = args;
|
||||
|
||||
currentComponent.__hooks._pendingEffects.push(state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./internal').Effect} callback
|
||||
* @param {any[]} args
|
||||
*/
|
||||
export function useLayoutEffect(callback, args) {
|
||||
/** @type {import('./internal').EffectHookState} */
|
||||
const state = getHookState(currentIndex++, 4);
|
||||
if (!options._skipEffects && argsChanged(state._args, args)) {
|
||||
state._value = callback;
|
||||
state._args = args;
|
||||
|
||||
currentComponent._renderCallbacks.push(state);
|
||||
}
|
||||
}
|
||||
|
||||
export function useRef(initialValue) {
|
||||
currentHook = 5;
|
||||
return useMemo(() => ({ current: initialValue }), []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} ref
|
||||
* @param {() => object} createHandle
|
||||
* @param {any[]} args
|
||||
*/
|
||||
export function useImperativeHandle(ref, createHandle, args) {
|
||||
currentHook = 6;
|
||||
useLayoutEffect(
|
||||
() => {
|
||||
if (typeof ref == 'function') ref(createHandle());
|
||||
else if (ref) ref.current = createHandle();
|
||||
},
|
||||
args == null ? args : args.concat(ref)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {() => any} factory
|
||||
* @param {any[]} args
|
||||
*/
|
||||
export function useMemo(factory, args) {
|
||||
/** @type {import('./internal').MemoHookState} */
|
||||
const state = getHookState(currentIndex++, 7);
|
||||
if (argsChanged(state._args, args)) {
|
||||
state._value = factory();
|
||||
state._args = args;
|
||||
state._factory = factory;
|
||||
}
|
||||
|
||||
return state._value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {() => void} callback
|
||||
* @param {any[]} args
|
||||
*/
|
||||
export function useCallback(callback, args) {
|
||||
currentHook = 8;
|
||||
return useMemo(() => callback, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./internal').PreactContext} context
|
||||
*/
|
||||
export function useContext(context) {
|
||||
const provider = currentComponent.context[context._id];
|
||||
// We could skip this call here, but than we'd not call
|
||||
// `options._hook`. We need to do that in order to make
|
||||
// the devtools aware of this hook.
|
||||
const state = getHookState(currentIndex++, 9);
|
||||
// The devtools needs access to the context object to
|
||||
// be able to pull of the default value when no provider
|
||||
// is present in the tree.
|
||||
state._context = context;
|
||||
if (!provider) return context._defaultValue;
|
||||
// This is probably not safe to convert to "!"
|
||||
if (state._value == null) {
|
||||
state._value = true;
|
||||
provider.sub(currentComponent);
|
||||
}
|
||||
return provider.props.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a custom label for a custom hook for the devtools panel
|
||||
* @type {<T>(value: T, cb?: (value: T) => string | number) => void}
|
||||
*/
|
||||
export function useDebugValue(value, formatter) {
|
||||
if (options.useDebugValue) {
|
||||
options.useDebugValue(formatter ? formatter(value) : value);
|
||||
}
|
||||
}
|
||||
|
||||
export function useErrorBoundary(cb) {
|
||||
const state = getHookState(currentIndex++, 10);
|
||||
const errState = useState();
|
||||
state._value = cb;
|
||||
if (!currentComponent.componentDidCatch) {
|
||||
currentComponent.componentDidCatch = err => {
|
||||
if (state._value) state._value(err);
|
||||
errState[1](err);
|
||||
};
|
||||
}
|
||||
return [
|
||||
errState[0],
|
||||
() => {
|
||||
errState[1](undefined);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* After paint effects consumer.
|
||||
*/
|
||||
function flushAfterPaintEffects() {
|
||||
afterPaintEffects.some(component => {
|
||||
if (component._parentDom) {
|
||||
try {
|
||||
component.__hooks._pendingEffects.forEach(invokeCleanup);
|
||||
component.__hooks._pendingEffects.forEach(invokeEffect);
|
||||
component.__hooks._pendingEffects = [];
|
||||
} catch (e) {
|
||||
component.__hooks._pendingEffects = [];
|
||||
options._catchError(e, component._vnode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
afterPaintEffects = [];
|
||||
}
|
||||
|
||||
let HAS_RAF = typeof requestAnimationFrame == 'function';
|
||||
|
||||
/**
|
||||
* Schedule a callback to be invoked after the browser has a chance to paint a new frame.
|
||||
* Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after
|
||||
* the next browser frame.
|
||||
*
|
||||
* Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked
|
||||
* even if RAF doesn't fire (for example if the browser tab is not visible)
|
||||
*
|
||||
* @param {() => void} callback
|
||||
*/
|
||||
function afterNextFrame(callback) {
|
||||
const done = () => {
|
||||
clearTimeout(timeout);
|
||||
if (HAS_RAF) cancelAnimationFrame(raf);
|
||||
setTimeout(callback);
|
||||
};
|
||||
const timeout = setTimeout(done, RAF_TIMEOUT);
|
||||
|
||||
let raf;
|
||||
if (HAS_RAF) {
|
||||
raf = requestAnimationFrame(done);
|
||||
}
|
||||
}
|
||||
|
||||
// Note: if someone used options.debounceRendering = requestAnimationFrame,
|
||||
// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.
|
||||
// Perhaps this is not such a big deal.
|
||||
/**
|
||||
* Schedule afterPaintEffects flush after the browser paints
|
||||
* @param {number} newQueueLength
|
||||
*/
|
||||
function afterPaint(newQueueLength) {
|
||||
if (newQueueLength === 1 || prevRaf !== options.requestAnimationFrame) {
|
||||
prevRaf = options.requestAnimationFrame;
|
||||
(prevRaf || afterNextFrame)(flushAfterPaintEffects);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./internal').EffectHookState} hook
|
||||
*/
|
||||
function invokeCleanup(hook) {
|
||||
if (typeof hook._cleanup == 'function') hook._cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke a Hook's effect
|
||||
* @param {import('./internal').EffectHookState} hook
|
||||
*/
|
||||
function invokeEffect(hook) {
|
||||
hook._cleanup = hook._value();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any[]} oldArgs
|
||||
* @param {any[]} newArgs
|
||||
*/
|
||||
function argsChanged(oldArgs, newArgs) {
|
||||
return (
|
||||
!oldArgs ||
|
||||
oldArgs.length !== newArgs.length ||
|
||||
newArgs.some((arg, index) => arg !== oldArgs[index])
|
||||
);
|
||||
}
|
||||
|
||||
function invokeOrReturn(arg, f) {
|
||||
return typeof f == 'function' ? f(arg) : f;
|
||||
}
|
||||
57
build/javascript/node_modules/preact/hooks/src/internal.d.ts
generated
vendored
Normal file
57
build/javascript/node_modules/preact/hooks/src/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Component as PreactComponent } from '../../src/internal';
|
||||
import { Reducer } from '.';
|
||||
|
||||
export { PreactContext } from '../../src/internal';
|
||||
|
||||
/**
|
||||
* The type of arguments passed to a Hook function. While this type is not
|
||||
* strictly necessary, they are given a type name to make it easier to read
|
||||
* the following types and trace the flow of data.
|
||||
*/
|
||||
export type HookArgs = any;
|
||||
|
||||
/**
|
||||
* The return type of a Hook function. While this type is not
|
||||
* strictly necessary, they are given a type name to make it easier to read
|
||||
* the following types and trace the flow of data.
|
||||
*/
|
||||
export type HookReturnValue = any;
|
||||
|
||||
/** The public function a user invokes to use a Hook */
|
||||
export type Hook = (...args: HookArgs[]) => HookReturnValue;
|
||||
|
||||
// Hook tracking
|
||||
|
||||
export interface ComponentHooks {
|
||||
/** The list of hooks a component uses */
|
||||
_list: HookState[];
|
||||
/** List of Effects to be invoked after the next frame is rendered */
|
||||
_pendingEffects: EffectHookState[];
|
||||
}
|
||||
|
||||
export interface Component extends PreactComponent<any, any> {
|
||||
__hooks?: ComponentHooks;
|
||||
}
|
||||
|
||||
export type HookState = EffectHookState | MemoHookState | ReducerHookState;
|
||||
|
||||
export type Effect = () => void | Cleanup;
|
||||
export type Cleanup = () => void;
|
||||
|
||||
export interface EffectHookState {
|
||||
_value?: Effect;
|
||||
_args?: any[];
|
||||
_cleanup?: Cleanup;
|
||||
}
|
||||
|
||||
export interface MemoHookState {
|
||||
_value?: any;
|
||||
_args?: any[];
|
||||
_factory?: () => any;
|
||||
}
|
||||
|
||||
export interface ReducerHookState {
|
||||
_value?: any;
|
||||
_component?: Component;
|
||||
_reducer?: Reducer<any, any>;
|
||||
}
|
||||
21
build/javascript/node_modules/preact/jsx-runtime/LICENSE
generated
vendored
Normal file
21
build/javascript/node_modules/preact/jsx-runtime/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
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.
|
||||
19
build/javascript/node_modules/preact/jsx-runtime/package.json
generated
vendored
Normal file
19
build/javascript/node_modules/preact/jsx-runtime/package.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "jsx-runtime",
|
||||
"amdName": "jsxRuntime",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Preact JSX runtime",
|
||||
"main": "dist/jsxRuntime.js",
|
||||
"module": "dist/jsxRuntime.module.js",
|
||||
"umd:main": "dist/jsxRuntime.umd.js",
|
||||
"source": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"preact": "^10.0.0"
|
||||
},
|
||||
"mangle": {
|
||||
"regex": "^_"
|
||||
}
|
||||
}
|
||||
57
build/javascript/node_modules/preact/jsx-runtime/src/index.d.ts
generated
vendored
Normal file
57
build/javascript/node_modules/preact/jsx-runtime/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
export { Fragment } from '../../';
|
||||
import {
|
||||
ComponentType,
|
||||
ComponentChild,
|
||||
ComponentChildren,
|
||||
VNode,
|
||||
Attributes
|
||||
} from '../../';
|
||||
import { JSXInternal } from '../../src/jsx';
|
||||
|
||||
export function jsx(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChild },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsx<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChild },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export namespace jsx {
|
||||
export import JSX = JSXInternal;
|
||||
}
|
||||
|
||||
export function jsxs(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChild[] },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsxs<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChild[] },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export namespace jsxs {
|
||||
export import JSX = JSXInternal;
|
||||
}
|
||||
|
||||
export function jsxDEV(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChildren },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsxDEV<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChildren },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export namespace jsxDEV {
|
||||
export import JSX = JSXInternal;
|
||||
}
|
||||
60
build/javascript/node_modules/preact/jsx-runtime/src/index.js
generated
vendored
Normal file
60
build/javascript/node_modules/preact/jsx-runtime/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { options, Fragment } from 'preact';
|
||||
|
||||
/** @typedef {import('preact').VNode} VNode */
|
||||
|
||||
/**
|
||||
* @fileoverview
|
||||
* This file exports various methods that implement Babel's "automatic" JSX runtime API:
|
||||
* - jsx(type, props, key)
|
||||
* - jsxs(type, props, key)
|
||||
* - jsxDEV(type, props, key, __source, __self)
|
||||
*
|
||||
* The implementation of createVNode here is optimized for performance.
|
||||
* Benchmarks: https://esbench.com/bench/5f6b54a0b4632100a7dcd2b3
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSX.Element factory used by Babel's {runtime:"automatic"} JSX transform
|
||||
* @param {VNode['type']} type
|
||||
* @param {VNode['props']} props
|
||||
* @param {VNode['key']} [key]
|
||||
* @param {string} [__source]
|
||||
* @param {string} [__self]
|
||||
*/
|
||||
function createVNode(type, props, key, __source, __self) {
|
||||
const vnode = {
|
||||
type,
|
||||
props,
|
||||
key,
|
||||
ref: props && props.ref,
|
||||
_children: null,
|
||||
_parent: null,
|
||||
_depth: 0,
|
||||
_dom: null,
|
||||
_nextDom: undefined,
|
||||
_component: null,
|
||||
_hydrating: null,
|
||||
constructor: undefined,
|
||||
_original: undefined,
|
||||
__source,
|
||||
__self
|
||||
};
|
||||
vnode._original = vnode;
|
||||
|
||||
// If a Component VNode, check for and apply defaultProps.
|
||||
// Note: `type` is often a String, and can be `undefined` in development.
|
||||
let defaults, i;
|
||||
if (typeof type === 'function' && (defaults = type.defaultProps)) {
|
||||
for (i in defaults) if (props[i] === undefined) props[i] = defaults[i];
|
||||
}
|
||||
|
||||
if (options.vnode) options.vnode(vnode);
|
||||
return vnode;
|
||||
}
|
||||
|
||||
export {
|
||||
createVNode as jsx,
|
||||
createVNode as jsxs,
|
||||
createVNode as jsxDEV,
|
||||
Fragment
|
||||
};
|
||||
287
build/javascript/node_modules/preact/package.json
generated
vendored
Normal file
287
build/javascript/node_modules/preact/package.json
generated
vendored
Normal file
@@ -0,0 +1,287 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"preact@10.5.4",
|
||||
"/home/runner/work/owncast/owncast/build/javascript"
|
||||
]
|
||||
],
|
||||
"_from": "preact@10.5.4",
|
||||
"_id": "preact@10.5.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-u0LnVtL9WWF61RLzIbEsVFOdsahoTQkQqeRwyf4eWuLMFrxTH/C47tqcnizbUH54E4KG8UzuuZaMc9KarHmpqQ==",
|
||||
"_location": "/preact",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "preact@10.5.4",
|
||||
"name": "preact",
|
||||
"escapedName": "preact",
|
||||
"rawSpec": "10.5.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "10.5.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/preact/-/preact-10.5.4.tgz",
|
||||
"_spec": "10.5.4",
|
||||
"_where": "/home/runner/work/owncast/owncast/build/javascript",
|
||||
"amdName": "preact",
|
||||
"authors": [
|
||||
"The Preact Authors (https://github.com/preactjs/preact/contributors)"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/preactjs/preact/issues"
|
||||
},
|
||||
"description": "Fast 3kb React-compatible Virtual DOM library.",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.7.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
|
||||
"@babel/plugin-transform-react-jsx": "^7.7.0",
|
||||
"@babel/plugin-transform-react-jsx-source": "^7.7.4",
|
||||
"@babel/preset-env": "^7.7.1",
|
||||
"@babel/register": "^7.7.0",
|
||||
"@types/chai": "^4.1.2",
|
||||
"@types/mocha": "^5.0.0",
|
||||
"@types/node": "^10.5.2",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-istanbul": "^6.0.0",
|
||||
"babel-plugin-transform-async-to-promises": "^0.8.15",
|
||||
"babel-plugin-transform-rename-properties": "0.0.3",
|
||||
"benchmark": "^2.1.4",
|
||||
"chai": "^4.1.2",
|
||||
"check-export-map": "^1.0.1",
|
||||
"coveralls": "^3.0.0",
|
||||
"cross-env": "^5.2.0",
|
||||
"diff": "^3.5.0",
|
||||
"eslint": "5.15.1",
|
||||
"eslint-config-developit": "^1.1.1",
|
||||
"eslint-config-prettier": "^6.5.0",
|
||||
"eslint-plugin-react": "7.12.4",
|
||||
"husky": "^3.0.9",
|
||||
"karma": "^3.0.0",
|
||||
"karma-chai-sinon": "^0.1.5",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-coverage": "^2.0.1",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-mocha-reporter": "^2.2.5",
|
||||
"karma-sauce-launcher": "^1.2.0",
|
||||
"karma-sinon": "^1.0.5",
|
||||
"karma-sourcemap-loader": "^0.3.7",
|
||||
"karma-webpack": "^3.0.5",
|
||||
"lint-staged": "^9.4.2",
|
||||
"lodash": "^4.17.10",
|
||||
"microbundle": "^0.11.0",
|
||||
"mocha": "^5.2.0",
|
||||
"npm-merge-driver-install": "^1.1.1",
|
||||
"npm-run-all": "^4.0.0",
|
||||
"prettier": "^1.18.2",
|
||||
"prop-types": "^15.7.2",
|
||||
"sinon": "^6.1.3",
|
||||
"sinon-chai": "^3.0.0",
|
||||
"typescript": "3.5.3",
|
||||
"webpack": "^4.3.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"developit",
|
||||
"prettier"
|
||||
],
|
||||
"settings": {
|
||||
"react": {
|
||||
"pragma": "createElement"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"camelcase": [
|
||||
1,
|
||||
{
|
||||
"allow": [
|
||||
"__test__*",
|
||||
"unstable_*",
|
||||
"UNSAFE_*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"no-unused-vars": [
|
||||
2,
|
||||
{
|
||||
"args": "none",
|
||||
"varsIgnorePattern": "^h|React$"
|
||||
}
|
||||
],
|
||||
"prefer-rest-params": 0,
|
||||
"prefer-spread": 0,
|
||||
"no-cond-assign": 0,
|
||||
"react/jsx-no-bind": 0,
|
||||
"react/no-danger": "off",
|
||||
"react/prefer-stateless-function": 0,
|
||||
"react/sort-comp": 0,
|
||||
"jest/valid-expect": 0,
|
||||
"jest/no-disabled-tests": 0,
|
||||
"react/no-find-dom-node": 0
|
||||
}
|
||||
},
|
||||
"eslintIgnore": [
|
||||
"test/fixtures",
|
||||
"test/ts/",
|
||||
"*.ts",
|
||||
"dist"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"browser": "./dist/preact.module.js",
|
||||
"umd": "./dist/preact.umd.js",
|
||||
"import": "./dist/preact.mjs",
|
||||
"require": "./dist/preact.js"
|
||||
},
|
||||
"./compat": {
|
||||
"browser": "./compat/dist/compat.module.js",
|
||||
"umd": "./compat/dist/compat.umd.js",
|
||||
"require": "./compat/dist/compat.js",
|
||||
"import": "./compat/dist/compat.mjs"
|
||||
},
|
||||
"./debug": {
|
||||
"browser": "./debug/dist/debug.module.js",
|
||||
"umd": "./debug/dist/debug.umd.js",
|
||||
"require": "./debug/dist/debug.js",
|
||||
"import": "./debug/dist/debug.mjs"
|
||||
},
|
||||
"./devtools": {
|
||||
"browser": "./devtools/dist/devtools.module.js",
|
||||
"umd": "./devtools/dist/devtools.umd.js",
|
||||
"require": "./devtools/dist/devtools.js",
|
||||
"import": "./devtools/dist/devtools.mjs"
|
||||
},
|
||||
"./hooks": {
|
||||
"browser": "./hooks/dist/hooks.module.js",
|
||||
"umd": "./hooks/dist/hooks.umd.js",
|
||||
"require": "./hooks/dist/hooks.js",
|
||||
"import": "./hooks/dist/hooks.mjs"
|
||||
},
|
||||
"./test-utils": {
|
||||
"browser": "./test-utils/dist/testUtils.module.js",
|
||||
"umd": "./test-utils/dist/testUtils.umd.js",
|
||||
"require": "./test-utils/dist/testUtils.js",
|
||||
"import": "./test-utils/dist/testUtils.mjs"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
"browser": "./jsx-runtime/dist/jsxRuntime.module.js",
|
||||
"umd": "./jsx-runtime/dist/jsxRuntime.umd.js",
|
||||
"require": "./jsx-runtime/dist/jsxRuntime.js",
|
||||
"import": "./jsx-runtime/dist/jsxRuntime.mjs"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
"browser": "./jsx-runtime/dist/jsxRuntime.module.js",
|
||||
"umd": "./jsx-runtime/dist/jsxRuntime.umd.js",
|
||||
"require": "./jsx-runtime/dist/jsxRuntime.js",
|
||||
"import": "./jsx-runtime/dist/jsxRuntime.mjs"
|
||||
},
|
||||
"./compat/server": {
|
||||
"require": "./compat/server.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./": "./"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"compat/dist",
|
||||
"compat/src",
|
||||
"compat/server.js",
|
||||
"compat/package.json",
|
||||
"debug/dist",
|
||||
"debug/src",
|
||||
"debug/package.json",
|
||||
"devtools/dist",
|
||||
"devtools/src",
|
||||
"devtools/package.json",
|
||||
"hooks/dist",
|
||||
"hooks/src",
|
||||
"hooks/package.json",
|
||||
"jsx-runtime/dist",
|
||||
"jsx-runtime/src",
|
||||
"jsx-runtime/package.json",
|
||||
"test-utils/src",
|
||||
"test-utils/package.json",
|
||||
"test-utils/dist"
|
||||
],
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/preact"
|
||||
},
|
||||
"homepage": "https://preactjs.com",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
"preact",
|
||||
"react",
|
||||
"ui",
|
||||
"user interface",
|
||||
"virtual dom",
|
||||
"vdom",
|
||||
"components",
|
||||
"dom diff"
|
||||
],
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"**/*.{js,jsx,ts,tsx,yml}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "dist/preact.js",
|
||||
"module": "dist/preact.module.js",
|
||||
"name": "preact",
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"useTabs": true,
|
||||
"tabWidth": 2
|
||||
},
|
||||
"private": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/preactjs/preact.git"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "npm run test:karma:bench -- no-single-run",
|
||||
"build": "npm-run-all --parallel build:*",
|
||||
"build:compat": "microbundle build --raw --cwd compat --globals 'preact/hooks=preactHooks'",
|
||||
"build:core": "microbundle build --raw",
|
||||
"build:core-min": "microbundle build --raw -f iife src/cjs.js -o dist/preact.min.js",
|
||||
"build:debug": "microbundle build --raw --cwd debug",
|
||||
"build:devtools": "microbundle build --raw --cwd devtools",
|
||||
"build:hooks": "microbundle build --raw --cwd hooks",
|
||||
"build:jsx": "microbundle build --raw --cwd jsx-runtime",
|
||||
"build:test-utils": "microbundle build --raw --cwd test-utils",
|
||||
"dev": "microbundle watch --raw --format cjs",
|
||||
"dev:compat": "microbundle watch --raw --format cjs --cwd compat --globals 'preact/hooks=preactHooks'",
|
||||
"dev:hooks": "microbundle watch --raw --format cjs --cwd hooks",
|
||||
"lint": "eslint src test debug compat hooks test-utils",
|
||||
"postbuild": "node ./config/node-13-exports.js",
|
||||
"prepare": "run-s build && check-export-map",
|
||||
"test": "npm-run-all build lint test:unit",
|
||||
"test:karma": "cross-env COVERAGE=true karma start karma.conf.js --single-run",
|
||||
"test:karma:bench": "cross-env PERFORMANCE=true COVERAGE=false karma start karma.conf.js --grep=test/benchmarks/**.js --single-run",
|
||||
"test:karma:hooks": "cross-env COVERAGE=false karma start karma.conf.js --grep=hooks/test/browser/**.js --no-single-run",
|
||||
"test:karma:minify": "cross-env COVERAGE=true MINIFY=true karma start karma.conf.js --single-run",
|
||||
"test:karma:test-utils": "cross-env PERFORMANCE=false COVERAGE=false karma start karma.conf.js --grep=test-utils/test/shared/**.js --no-single-run",
|
||||
"test:karma:watch": "karma start karma.conf.js --no-single-run",
|
||||
"test:mocha": "mocha --recursive --require \"@babel/register\" test/shared test/node",
|
||||
"test:mocha:watch": "npm run test:mocha -- --watch",
|
||||
"test:ts": "run-p test:ts:*",
|
||||
"test:ts:compat": "tsc -p compat/test/ts/",
|
||||
"test:ts:core": "tsc -p test/ts/ && mocha --require \"@babel/register\" test/ts/**/*-test.js",
|
||||
"test:unit": "run-p test:mocha test:karma:minify test:ts"
|
||||
},
|
||||
"source": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
"umd:main": "dist/preact.umd.js",
|
||||
"unpkg": "dist/preact.min.js",
|
||||
"version": "10.5.4"
|
||||
}
|
||||
3
build/javascript/node_modules/preact/src/cjs.js
generated
vendored
Normal file
3
build/javascript/node_modules/preact/src/cjs.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as preact from './index.js';
|
||||
if (typeof module < 'u') module.exports = preact;
|
||||
else self.preact = preact;
|
||||
39
build/javascript/node_modules/preact/src/clone-element.js
generated
vendored
Normal file
39
build/javascript/node_modules/preact/src/clone-element.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { assign } from './util';
|
||||
import { createVNode } from './create-element';
|
||||
|
||||
/**
|
||||
* Clones the given VNode, optionally adding attributes/props and replacing its children.
|
||||
* @param {import('./internal').VNode} vnode The virtual DOM element to clone
|
||||
* @param {object} props Attributes/props to add when cloning
|
||||
* @param {Array<import('./index').ComponentChildren>} rest Any additional arguments will be used as replacement children.
|
||||
* @returns {import('./internal').VNode}
|
||||
*/
|
||||
export function cloneElement(vnode, props, children) {
|
||||
let normalizedProps = assign({}, vnode.props),
|
||||
key,
|
||||
ref,
|
||||
i;
|
||||
for (i in props) {
|
||||
if (i == 'key') key = props[i];
|
||||
else if (i == 'ref') ref = props[i];
|
||||
else normalizedProps[i] = props[i];
|
||||
}
|
||||
|
||||
if (arguments.length > 3) {
|
||||
children = [children];
|
||||
for (i = 3; i < arguments.length; i++) {
|
||||
children.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
if (children != null) {
|
||||
normalizedProps.children = children;
|
||||
}
|
||||
|
||||
return createVNode(
|
||||
vnode.type,
|
||||
normalizedProps,
|
||||
key || vnode.key,
|
||||
ref || vnode.ref,
|
||||
null
|
||||
);
|
||||
}
|
||||
223
build/javascript/node_modules/preact/src/component.js
generated
vendored
Normal file
223
build/javascript/node_modules/preact/src/component.js
generated
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
import { assign } from './util';
|
||||
import { diff, commitRoot } from './diff/index';
|
||||
import options from './options';
|
||||
import { Fragment } from './create-element';
|
||||
|
||||
/**
|
||||
* Base Component class. Provides `setState()` and `forceUpdate()`, which
|
||||
* trigger rendering
|
||||
* @param {object} props The initial component props
|
||||
* @param {object} context The initial context from parent components'
|
||||
* getChildContext
|
||||
*/
|
||||
export function Component(props, context) {
|
||||
this.props = props;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update component state and schedule a re-render.
|
||||
* @param {object | ((s: object, p: object) => object)} update A hash of state
|
||||
* properties to update with new values or a function that given the current
|
||||
* state and props returns a new partial state
|
||||
* @param {() => void} [callback] A function to be called once component state is
|
||||
* updated
|
||||
*/
|
||||
Component.prototype.setState = function(update, callback) {
|
||||
// only clone state when copying to nextState the first time.
|
||||
let s;
|
||||
if (this._nextState != null && this._nextState !== this.state) {
|
||||
s = this._nextState;
|
||||
} else {
|
||||
s = this._nextState = assign({}, this.state);
|
||||
}
|
||||
|
||||
if (typeof update == 'function') {
|
||||
// Some libraries like `immer` mark the current state as readonly,
|
||||
// preventing us from mutating it, so we need to clone it. See #2716
|
||||
update = update(assign({}, s), this.props);
|
||||
}
|
||||
|
||||
if (update) {
|
||||
assign(s, update);
|
||||
}
|
||||
|
||||
// Skip update if updater function returned null
|
||||
if (update == null) return;
|
||||
|
||||
if (this._vnode) {
|
||||
if (callback) this._renderCallbacks.push(callback);
|
||||
enqueueRender(this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Immediately perform a synchronous re-render of the component
|
||||
* @param {() => void} [callback] A function to be called after component is
|
||||
* re-rendered
|
||||
*/
|
||||
Component.prototype.forceUpdate = function(callback) {
|
||||
if (this._vnode) {
|
||||
// Set render mode so that we can differentiate where the render request
|
||||
// is coming from. We need this because forceUpdate should never call
|
||||
// shouldComponentUpdate
|
||||
this._force = true;
|
||||
if (callback) this._renderCallbacks.push(callback);
|
||||
enqueueRender(this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Accepts `props` and `state`, and returns a new Virtual DOM tree to build.
|
||||
* Virtual DOM is generally constructed via [JSX](http://jasonformat.com/wtf-is-jsx).
|
||||
* @param {object} props Props (eg: JSX attributes) received from parent
|
||||
* element/component
|
||||
* @param {object} state The component's current state
|
||||
* @param {object} context Context object, as returned by the nearest
|
||||
* ancestor's `getChildContext()`
|
||||
* @returns {import('./index').ComponentChildren | void}
|
||||
*/
|
||||
Component.prototype.render = Fragment;
|
||||
|
||||
/**
|
||||
* @param {import('./internal').VNode} vnode
|
||||
* @param {number | null} [childIndex]
|
||||
*/
|
||||
export function getDomSibling(vnode, childIndex) {
|
||||
if (childIndex == null) {
|
||||
// Use childIndex==null as a signal to resume the search from the vnode's sibling
|
||||
return vnode._parent
|
||||
? getDomSibling(vnode._parent, vnode._parent._children.indexOf(vnode) + 1)
|
||||
: null;
|
||||
}
|
||||
|
||||
let sibling;
|
||||
for (; childIndex < vnode._children.length; childIndex++) {
|
||||
sibling = vnode._children[childIndex];
|
||||
|
||||
if (sibling != null && sibling._dom != null) {
|
||||
// Since updateParentDomPointers keeps _dom pointer correct,
|
||||
// we can rely on _dom to tell us if this subtree contains a
|
||||
// rendered DOM node, and what the first rendered DOM node is
|
||||
return sibling._dom;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, we have not found a DOM node in this vnode's children.
|
||||
// We must resume from this vnode's sibling (in it's parent _children array)
|
||||
// Only climb up and search the parent if we aren't searching through a DOM
|
||||
// VNode (meaning we reached the DOM parent of the original vnode that began
|
||||
// the search)
|
||||
return typeof vnode.type == 'function' ? getDomSibling(vnode) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger in-place re-rendering of a component.
|
||||
* @param {import('./internal').Component} component The component to rerender
|
||||
*/
|
||||
function renderComponent(component) {
|
||||
let vnode = component._vnode,
|
||||
oldDom = vnode._dom,
|
||||
parentDom = component._parentDom;
|
||||
|
||||
if (parentDom) {
|
||||
let commitQueue = [];
|
||||
const oldVNode = assign({}, vnode);
|
||||
oldVNode._original = oldVNode;
|
||||
|
||||
let newDom = diff(
|
||||
parentDom,
|
||||
vnode,
|
||||
oldVNode,
|
||||
component._globalContext,
|
||||
parentDom.ownerSVGElement !== undefined,
|
||||
vnode._hydrating != null ? [oldDom] : null,
|
||||
commitQueue,
|
||||
oldDom == null ? getDomSibling(vnode) : oldDom,
|
||||
vnode._hydrating
|
||||
);
|
||||
commitRoot(commitQueue, vnode);
|
||||
|
||||
if (newDom != oldDom) {
|
||||
updateParentDomPointers(vnode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./internal').VNode} vnode
|
||||
*/
|
||||
function updateParentDomPointers(vnode) {
|
||||
if ((vnode = vnode._parent) != null && vnode._component != null) {
|
||||
vnode._dom = vnode._component.base = null;
|
||||
for (let i = 0; i < vnode._children.length; i++) {
|
||||
let child = vnode._children[i];
|
||||
if (child != null && child._dom != null) {
|
||||
vnode._dom = vnode._component.base = child._dom;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return updateParentDomPointers(vnode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The render queue
|
||||
* @type {Array<import('./internal').Component>}
|
||||
*/
|
||||
let rerenderQueue = [];
|
||||
|
||||
/**
|
||||
* Asynchronously schedule a callback
|
||||
* @type {(cb: () => void) => void}
|
||||
*/
|
||||
/* istanbul ignore next */
|
||||
// Note the following line isn't tree-shaken by rollup cuz of rollup/rollup#2566
|
||||
const defer =
|
||||
typeof Promise == 'function'
|
||||
? Promise.prototype.then.bind(Promise.resolve())
|
||||
: setTimeout;
|
||||
|
||||
/*
|
||||
* The value of `Component.debounce` must asynchronously invoke the passed in callback. It is
|
||||
* important that contributors to Preact can consistently reason about what calls to `setState`, etc.
|
||||
* do, and when their effects will be applied. See the links below for some further reading on designing
|
||||
* asynchronous APIs.
|
||||
* * [Designing APIs for Asynchrony](https://blog.izs.me/2013/08/designing-apis-for-asynchrony)
|
||||
* * [Callbacks synchronous and asynchronous](https://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/)
|
||||
*/
|
||||
|
||||
let prevDebounce;
|
||||
|
||||
/**
|
||||
* Enqueue a rerender of a component
|
||||
* @param {import('./internal').Component} c The component to rerender
|
||||
*/
|
||||
export function enqueueRender(c) {
|
||||
if (
|
||||
(!c._dirty &&
|
||||
(c._dirty = true) &&
|
||||
rerenderQueue.push(c) &&
|
||||
!process._rerenderCount++) ||
|
||||
prevDebounce !== options.debounceRendering
|
||||
) {
|
||||
prevDebounce = options.debounceRendering;
|
||||
(prevDebounce || defer)(process);
|
||||
}
|
||||
}
|
||||
|
||||
/** Flush the render queue by rerendering all queued components */
|
||||
function process() {
|
||||
let queue;
|
||||
while ((process._rerenderCount = rerenderQueue.length)) {
|
||||
queue = rerenderQueue.sort((a, b) => a._vnode._depth - b._vnode._depth);
|
||||
rerenderQueue = [];
|
||||
// Don't update `renderCount` yet. Keep its value non-zero to prevent unnecessary
|
||||
// process() calls from getting scheduled while `queue` is still being consumed.
|
||||
queue.some(c => {
|
||||
if (c._dirty) renderComponent(c);
|
||||
});
|
||||
}
|
||||
}
|
||||
process._rerenderCount = 0;
|
||||
3
build/javascript/node_modules/preact/src/constants.js
generated
vendored
Normal file
3
build/javascript/node_modules/preact/src/constants.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export const EMPTY_OBJ = {};
|
||||
export const EMPTY_ARR = [];
|
||||
export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
||||
66
build/javascript/node_modules/preact/src/create-context.js
generated
vendored
Normal file
66
build/javascript/node_modules/preact/src/create-context.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { enqueueRender } from './component';
|
||||
|
||||
export let i = 0;
|
||||
|
||||
export function createContext(defaultValue, contextId) {
|
||||
contextId = '__cC' + i++;
|
||||
|
||||
const context = {
|
||||
_id: contextId,
|
||||
_defaultValue: defaultValue,
|
||||
Consumer(props, contextValue) {
|
||||
// return props.children(
|
||||
// context[contextId] ? context[contextId].props.value : defaultValue
|
||||
// );
|
||||
return props.children(contextValue);
|
||||
},
|
||||
Provider(props, subs, ctx) {
|
||||
if (!this.getChildContext) {
|
||||
subs = [];
|
||||
ctx = {};
|
||||
ctx[contextId] = this;
|
||||
|
||||
this.getChildContext = () => ctx;
|
||||
|
||||
this.shouldComponentUpdate = function(_props) {
|
||||
if (this.props.value !== _props.value) {
|
||||
// I think the forced value propagation here was only needed when `options.debounceRendering` was being bypassed:
|
||||
// https://github.com/preactjs/preact/commit/4d339fb803bea09e9f198abf38ca1bf8ea4b7771#diff-54682ce380935a717e41b8bfc54737f6R358
|
||||
// In those cases though, even with the value corrected, we're double-rendering all nodes.
|
||||
// It might be better to just tell folks not to use force-sync mode.
|
||||
// Currently, using `useContext()` in a class component will overwrite its `this.context` value.
|
||||
// subs.some(c => {
|
||||
// c.context = _props.value;
|
||||
// enqueueRender(c);
|
||||
// });
|
||||
|
||||
// subs.some(c => {
|
||||
// c.context[contextId] = _props.value;
|
||||
// enqueueRender(c);
|
||||
// });
|
||||
subs.some(enqueueRender);
|
||||
}
|
||||
};
|
||||
|
||||
this.sub = c => {
|
||||
subs.push(c);
|
||||
let old = c.componentWillUnmount;
|
||||
c.componentWillUnmount = () => {
|
||||
subs.splice(subs.indexOf(c), 1);
|
||||
if (old) old.call(c);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
return props.children;
|
||||
}
|
||||
};
|
||||
|
||||
// Devtools needs access to the context object when it
|
||||
// encounters a Provider. This is necessary to support
|
||||
// setting `displayName` on the context object instead
|
||||
// of on the component itself. See:
|
||||
// https://reactjs.org/docs/context.html#contextdisplayname
|
||||
|
||||
return (context.Provider._contextRef = context.Consumer.contextType = context);
|
||||
}
|
||||
101
build/javascript/node_modules/preact/src/create-element.js
generated
vendored
Normal file
101
build/javascript/node_modules/preact/src/create-element.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
import options from './options';
|
||||
|
||||
/**
|
||||
* Create an virtual node (used for JSX)
|
||||
* @param {import('./internal').VNode["type"]} type The node name or Component
|
||||
* constructor for this virtual node
|
||||
* @param {object | null | undefined} [props] The properties of the virtual node
|
||||
* @param {Array<import('.').ComponentChildren>} [children] The children of the virtual node
|
||||
* @returns {import('./internal').VNode}
|
||||
*/
|
||||
export function createElement(type, props, children) {
|
||||
let normalizedProps = {},
|
||||
key,
|
||||
ref,
|
||||
i;
|
||||
for (i in props) {
|
||||
if (i == 'key') key = props[i];
|
||||
else if (i == 'ref') ref = props[i];
|
||||
else normalizedProps[i] = props[i];
|
||||
}
|
||||
|
||||
if (arguments.length > 3) {
|
||||
children = [children];
|
||||
// https://github.com/preactjs/preact/issues/1916
|
||||
for (i = 3; i < arguments.length; i++) {
|
||||
children.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
if (children != null) {
|
||||
normalizedProps.children = children;
|
||||
}
|
||||
|
||||
// If a Component VNode, check for and apply defaultProps
|
||||
// Note: type may be undefined in development, must never error here.
|
||||
if (typeof type == 'function' && type.defaultProps != null) {
|
||||
for (i in type.defaultProps) {
|
||||
if (normalizedProps[i] === undefined) {
|
||||
normalizedProps[i] = type.defaultProps[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return createVNode(type, normalizedProps, key, ref, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a VNode (used internally by Preact)
|
||||
* @param {import('./internal').VNode["type"]} type The node name or Component
|
||||
* Constructor for this virtual node
|
||||
* @param {object | string | number | null} props The properties of this virtual node.
|
||||
* If this virtual node represents a text node, this is the text of the node (string or number).
|
||||
* @param {string | number | null} key The key for this virtual node, used when
|
||||
* diffing it against its children
|
||||
* @param {import('./internal').VNode["ref"]} ref The ref property that will
|
||||
* receive a reference to its created child
|
||||
* @returns {import('./internal').VNode}
|
||||
*/
|
||||
export function createVNode(type, props, key, ref, original) {
|
||||
// V8 seems to be better at detecting type shapes if the object is allocated from the same call site
|
||||
// Do not inline into createElement and coerceToVNode!
|
||||
const vnode = {
|
||||
type,
|
||||
props,
|
||||
key,
|
||||
ref,
|
||||
_children: null,
|
||||
_parent: null,
|
||||
_depth: 0,
|
||||
_dom: null,
|
||||
// _nextDom must be initialized to undefined b/c it will eventually
|
||||
// be set to dom.nextSibling which can return `null` and it is important
|
||||
// to be able to distinguish between an uninitialized _nextDom and
|
||||
// a _nextDom that has been set to `null`
|
||||
_nextDom: undefined,
|
||||
_component: null,
|
||||
_hydrating: null,
|
||||
constructor: undefined,
|
||||
_original: original
|
||||
};
|
||||
|
||||
if (original == null) vnode._original = vnode;
|
||||
if (options.vnode != null) options.vnode(vnode);
|
||||
|
||||
return vnode;
|
||||
}
|
||||
|
||||
export function createRef() {
|
||||
return { current: null };
|
||||
}
|
||||
|
||||
export function Fragment(props) {
|
||||
return props.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a the argument is a valid Preact VNode.
|
||||
* @param {*} vnode
|
||||
* @returns {vnode is import('./internal').VNode}
|
||||
*/
|
||||
export const isValidElement = vnode =>
|
||||
vnode != null && vnode.constructor === undefined;
|
||||
43
build/javascript/node_modules/preact/src/diff/catch-error.js
generated
vendored
Normal file
43
build/javascript/node_modules/preact/src/diff/catch-error.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// import { enqueueRender } from '../component';
|
||||
|
||||
/**
|
||||
* Find the closest error boundary to a thrown error and call it
|
||||
* @param {object} error The thrown value
|
||||
* @param {import('../internal').VNode} vnode The vnode that threw
|
||||
* the error that was caught (except for unmounting when this parameter
|
||||
* is the highest parent that was being unmounted)
|
||||
*/
|
||||
export function _catchError(error, vnode) {
|
||||
/** @type {import('../internal').Component} */
|
||||
let component, ctor, handled;
|
||||
|
||||
const wasHydrating = vnode._hydrating;
|
||||
|
||||
for (; (vnode = vnode._parent); ) {
|
||||
if ((component = vnode._component) && !component._processingException) {
|
||||
try {
|
||||
ctor = component.constructor;
|
||||
|
||||
if (ctor && ctor.getDerivedStateFromError != null) {
|
||||
component.setState(ctor.getDerivedStateFromError(error));
|
||||
handled = component._dirty;
|
||||
}
|
||||
|
||||
if (component.componentDidCatch != null) {
|
||||
component.componentDidCatch(error);
|
||||
handled = component._dirty;
|
||||
}
|
||||
|
||||
// This is an error boundary. Mark it as having bailed out, and whether it was mid-hydration.
|
||||
if (handled) {
|
||||
vnode._hydrating = wasHydrating;
|
||||
return (component._pendingError = component);
|
||||
}
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
309
build/javascript/node_modules/preact/src/diff/children.js
generated
vendored
Normal file
309
build/javascript/node_modules/preact/src/diff/children.js
generated
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
import { diff, unmount, applyRef } from './index';
|
||||
import { createVNode, Fragment } from '../create-element';
|
||||
import { EMPTY_OBJ, EMPTY_ARR } from '../constants';
|
||||
import { removeNode } from '../util';
|
||||
import { getDomSibling } from '../component';
|
||||
|
||||
/**
|
||||
* Diff the children of a virtual node
|
||||
* @param {import('../internal').PreactElement} parentDom The DOM element whose
|
||||
* children are being diffed
|
||||
* @param {import('../index').ComponentChildren[]} renderResult
|
||||
* @param {import('../internal').VNode} newParentVNode The new virtual
|
||||
* node whose children should be diff'ed against oldParentVNode
|
||||
* @param {import('../internal').VNode} oldParentVNode The old virtual
|
||||
* node whose children should be diff'ed against newParentVNode
|
||||
* @param {object} globalContext The current context object - modified by getChildContext
|
||||
* @param {boolean} isSvg Whether or not this DOM node is an SVG node
|
||||
* @param {Array<import('../internal').PreactElement>} excessDomChildren
|
||||
* @param {Array<import('../internal').Component>} commitQueue List of components
|
||||
* which have callbacks to invoke in commitRoot
|
||||
* @param {Node | Text} oldDom The current attached DOM
|
||||
* element any new dom elements should be placed around. Likely `null` on first
|
||||
* render (except when hydrating). Can be a sibling DOM element when diffing
|
||||
* Fragments that have siblings. In most cases, it starts out as `oldChildren[0]._dom`.
|
||||
* @param {boolean} isHydrating Whether or not we are in hydration
|
||||
*/
|
||||
export function diffChildren(
|
||||
parentDom,
|
||||
renderResult,
|
||||
newParentVNode,
|
||||
oldParentVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
oldDom,
|
||||
isHydrating
|
||||
) {
|
||||
let i, j, oldVNode, childVNode, newDom, firstChildDom, refs;
|
||||
|
||||
// This is a compression of oldParentVNode!=null && oldParentVNode != EMPTY_OBJ && oldParentVNode._children || EMPTY_ARR
|
||||
// as EMPTY_OBJ._children should be `undefined`.
|
||||
let oldChildren = (oldParentVNode && oldParentVNode._children) || EMPTY_ARR;
|
||||
|
||||
let oldChildrenLength = oldChildren.length;
|
||||
|
||||
// Only in very specific places should this logic be invoked (top level `render` and `diffElementNodes`).
|
||||
// I'm using `EMPTY_OBJ` to signal when `diffChildren` is invoked in these situations. I can't use `null`
|
||||
// for this purpose, because `null` is a valid value for `oldDom` which can mean to skip to this logic
|
||||
// (e.g. if mounting a new tree in which the old DOM should be ignored (usually for Fragments).
|
||||
if (oldDom == EMPTY_OBJ) {
|
||||
if (excessDomChildren != null) {
|
||||
oldDom = excessDomChildren[0];
|
||||
} else if (oldChildrenLength) {
|
||||
oldDom = getDomSibling(oldParentVNode, 0);
|
||||
} else {
|
||||
oldDom = null;
|
||||
}
|
||||
}
|
||||
|
||||
newParentVNode._children = [];
|
||||
for (i = 0; i < renderResult.length; i++) {
|
||||
childVNode = renderResult[i];
|
||||
|
||||
if (childVNode == null || typeof childVNode == 'boolean') {
|
||||
childVNode = newParentVNode._children[i] = null;
|
||||
}
|
||||
// If this newVNode is being reused (e.g. <div>{reuse}{reuse}</div>) in the same diff,
|
||||
// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have
|
||||
// it's own DOM & etc. pointers
|
||||
else if (typeof childVNode == 'string' || typeof childVNode == 'number') {
|
||||
childVNode = newParentVNode._children[i] = createVNode(
|
||||
null,
|
||||
childVNode,
|
||||
null,
|
||||
null,
|
||||
childVNode
|
||||
);
|
||||
} else if (Array.isArray(childVNode)) {
|
||||
childVNode = newParentVNode._children[i] = createVNode(
|
||||
Fragment,
|
||||
{ children: childVNode },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
} else if (childVNode._dom != null || childVNode._component != null) {
|
||||
childVNode = newParentVNode._children[i] = createVNode(
|
||||
childVNode.type,
|
||||
childVNode.props,
|
||||
childVNode.key,
|
||||
null,
|
||||
childVNode._original
|
||||
);
|
||||
} else {
|
||||
childVNode = newParentVNode._children[i] = childVNode;
|
||||
}
|
||||
|
||||
// Terser removes the `continue` here and wraps the loop body
|
||||
// in a `if (childVNode) { ... } condition
|
||||
if (childVNode == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
childVNode._parent = newParentVNode;
|
||||
childVNode._depth = newParentVNode._depth + 1;
|
||||
|
||||
// Check if we find a corresponding element in oldChildren.
|
||||
// If found, delete the array item by setting to `undefined`.
|
||||
// We use `undefined`, as `null` is reserved for empty placeholders
|
||||
// (holes).
|
||||
oldVNode = oldChildren[i];
|
||||
|
||||
if (
|
||||
oldVNode === null ||
|
||||
(oldVNode &&
|
||||
childVNode.key == oldVNode.key &&
|
||||
childVNode.type === oldVNode.type)
|
||||
) {
|
||||
oldChildren[i] = undefined;
|
||||
} else {
|
||||
// Either oldVNode === undefined or oldChildrenLength > 0,
|
||||
// so after this loop oldVNode == null or oldVNode is a valid value.
|
||||
for (j = 0; j < oldChildrenLength; j++) {
|
||||
oldVNode = oldChildren[j];
|
||||
// If childVNode is unkeyed, we only match similarly unkeyed nodes, otherwise we match by key.
|
||||
// We always match by type (in either case).
|
||||
if (
|
||||
oldVNode &&
|
||||
childVNode.key == oldVNode.key &&
|
||||
childVNode.type === oldVNode.type
|
||||
) {
|
||||
oldChildren[j] = undefined;
|
||||
break;
|
||||
}
|
||||
oldVNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
oldVNode = oldVNode || EMPTY_OBJ;
|
||||
|
||||
// Morph the old element into the new one, but don't append it to the dom yet
|
||||
newDom = diff(
|
||||
parentDom,
|
||||
childVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
oldDom,
|
||||
isHydrating
|
||||
);
|
||||
|
||||
if ((j = childVNode.ref) && oldVNode.ref != j) {
|
||||
if (!refs) refs = [];
|
||||
if (oldVNode.ref) refs.push(oldVNode.ref, null, childVNode);
|
||||
refs.push(j, childVNode._component || newDom, childVNode);
|
||||
}
|
||||
|
||||
if (newDom != null) {
|
||||
if (firstChildDom == null) {
|
||||
firstChildDom = newDom;
|
||||
}
|
||||
|
||||
oldDom = placeChild(
|
||||
parentDom,
|
||||
childVNode,
|
||||
oldVNode,
|
||||
oldChildren,
|
||||
excessDomChildren,
|
||||
newDom,
|
||||
oldDom
|
||||
);
|
||||
|
||||
// Browsers will infer an option's `value` from `textContent` when
|
||||
// no value is present. This essentially bypasses our code to set it
|
||||
// later in `diff()`. It works fine in all browsers except for IE11
|
||||
// where it breaks setting `select.value`. There it will be always set
|
||||
// to an empty string. Re-applying an options value will fix that, so
|
||||
// there are probably some internal data structures that aren't
|
||||
// updated properly.
|
||||
//
|
||||
// To fix it we make sure to reset the inferred value, so that our own
|
||||
// value check in `diff()` won't be skipped.
|
||||
if (!isHydrating && newParentVNode.type == 'option') {
|
||||
parentDom.value = '';
|
||||
} else if (typeof newParentVNode.type == 'function') {
|
||||
// Because the newParentVNode is Fragment-like, we need to set it's
|
||||
// _nextDom property to the nextSibling of its last child DOM node.
|
||||
//
|
||||
// `oldDom` contains the correct value here because if the last child
|
||||
// is a Fragment-like, then oldDom has already been set to that child's _nextDom.
|
||||
// If the last child is a DOM VNode, then oldDom will be set to that DOM
|
||||
// node's nextSibling.
|
||||
newParentVNode._nextDom = oldDom;
|
||||
}
|
||||
} else if (
|
||||
oldDom &&
|
||||
oldVNode._dom == oldDom &&
|
||||
oldDom.parentNode != parentDom
|
||||
) {
|
||||
// The above condition is to handle null placeholders. See test in placeholder.test.js:
|
||||
// `efficiently replace null placeholders in parent rerenders`
|
||||
oldDom = getDomSibling(oldVNode);
|
||||
}
|
||||
}
|
||||
|
||||
newParentVNode._dom = firstChildDom;
|
||||
|
||||
// Remove children that are not part of any vnode.
|
||||
if (excessDomChildren != null && typeof newParentVNode.type != 'function') {
|
||||
for (i = excessDomChildren.length; i--; ) {
|
||||
if (excessDomChildren[i] != null) removeNode(excessDomChildren[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove remaining oldChildren if there are any.
|
||||
for (i = oldChildrenLength; i--; ) {
|
||||
if (oldChildren[i] != null) unmount(oldChildren[i], oldChildren[i]);
|
||||
}
|
||||
|
||||
// Set refs only after unmount
|
||||
if (refs) {
|
||||
for (i = 0; i < refs.length; i++) {
|
||||
applyRef(refs[i], refs[++i], refs[++i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten and loop through the children of a virtual node
|
||||
* @param {import('../index').ComponentChildren} children The unflattened
|
||||
* children of a virtual node
|
||||
* @returns {import('../internal').VNode[]}
|
||||
*/
|
||||
export function toChildArray(children, out) {
|
||||
out = out || [];
|
||||
if (children == null || typeof children == 'boolean') {
|
||||
} else if (Array.isArray(children)) {
|
||||
children.some(child => {
|
||||
toChildArray(child, out);
|
||||
});
|
||||
} else {
|
||||
out.push(children);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function placeChild(
|
||||
parentDom,
|
||||
childVNode,
|
||||
oldVNode,
|
||||
oldChildren,
|
||||
excessDomChildren,
|
||||
newDom,
|
||||
oldDom
|
||||
) {
|
||||
let nextDom;
|
||||
if (childVNode._nextDom !== undefined) {
|
||||
// Only Fragments or components that return Fragment like VNodes will
|
||||
// have a non-undefined _nextDom. Continue the diff from the sibling
|
||||
// of last DOM child of this child VNode
|
||||
nextDom = childVNode._nextDom;
|
||||
|
||||
// Eagerly cleanup _nextDom. We don't need to persist the value because
|
||||
// it is only used by `diffChildren` to determine where to resume the diff after
|
||||
// diffing Components and Fragments. Once we store it the nextDOM local var, we
|
||||
// can clean up the property
|
||||
childVNode._nextDom = undefined;
|
||||
} else if (
|
||||
excessDomChildren == oldVNode ||
|
||||
newDom != oldDom ||
|
||||
newDom.parentNode == null
|
||||
) {
|
||||
// NOTE: excessDomChildren==oldVNode above:
|
||||
// This is a compression of excessDomChildren==null && oldVNode==null!
|
||||
// The values only have the same type when `null`.
|
||||
|
||||
outer: if (oldDom == null || oldDom.parentNode !== parentDom) {
|
||||
parentDom.appendChild(newDom);
|
||||
nextDom = null;
|
||||
} else {
|
||||
// `j<oldChildrenLength; j+=2` is an alternative to `j++<oldChildrenLength/2`
|
||||
for (
|
||||
let sibDom = oldDom, j = 0;
|
||||
(sibDom = sibDom.nextSibling) && j < oldChildren.length;
|
||||
j += 2
|
||||
) {
|
||||
if (sibDom == newDom) {
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
parentDom.insertBefore(newDom, oldDom);
|
||||
nextDom = oldDom;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have pre-calculated the nextDOM node, use it. Else calculate it now
|
||||
// Strictly check for `undefined` here cuz `null` is a valid value of `nextDom`.
|
||||
// See more detail in create-element.js:createVNode
|
||||
if (nextDom !== undefined) {
|
||||
oldDom = nextDom;
|
||||
} else {
|
||||
oldDom = newDom.nextSibling;
|
||||
}
|
||||
|
||||
return oldDom;
|
||||
}
|
||||
526
build/javascript/node_modules/preact/src/diff/index.js
generated
vendored
Normal file
526
build/javascript/node_modules/preact/src/diff/index.js
generated
vendored
Normal file
@@ -0,0 +1,526 @@
|
||||
import { EMPTY_OBJ, EMPTY_ARR } from '../constants';
|
||||
import { Component } from '../component';
|
||||
import { Fragment } from '../create-element';
|
||||
import { diffChildren, placeChild } from './children';
|
||||
import { diffProps, setProperty } from './props';
|
||||
import { assign, removeNode } from '../util';
|
||||
import options from '../options';
|
||||
|
||||
function reorderChildren(newVNode, oldDom, parentDom) {
|
||||
for (let tmp = 0; tmp < newVNode._children.length; tmp++) {
|
||||
const vnode = newVNode._children[tmp];
|
||||
if (vnode) {
|
||||
vnode._parent = newVNode;
|
||||
|
||||
if (vnode._dom) {
|
||||
if (typeof vnode.type == 'function' && vnode._children.length > 1) {
|
||||
reorderChildren(vnode, oldDom, parentDom);
|
||||
}
|
||||
|
||||
oldDom = placeChild(
|
||||
parentDom,
|
||||
vnode,
|
||||
vnode,
|
||||
newVNode._children,
|
||||
null,
|
||||
vnode._dom,
|
||||
oldDom
|
||||
);
|
||||
|
||||
if (typeof newVNode.type == 'function') {
|
||||
newVNode._nextDom = oldDom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff two virtual nodes and apply proper changes to the DOM
|
||||
* @param {import('../internal').PreactElement} parentDom The parent of the DOM element
|
||||
* @param {import('../internal').VNode} newVNode The new virtual node
|
||||
* @param {import('../internal').VNode} oldVNode The old virtual node
|
||||
* @param {object} globalContext The current context object. Modified by getChildContext
|
||||
* @param {boolean} isSvg Whether or not this element is an SVG node
|
||||
* @param {Array<import('../internal').PreactElement>} excessDomChildren
|
||||
* @param {Array<import('../internal').Component>} commitQueue List of components
|
||||
* which have callbacks to invoke in commitRoot
|
||||
* @param {Element | Text} oldDom The current attached DOM
|
||||
* element any new dom elements should be placed around. Likely `null` on first
|
||||
* render (except when hydrating). Can be a sibling DOM element when diffing
|
||||
* Fragments that have siblings. In most cases, it starts out as `oldChildren[0]._dom`.
|
||||
* @param {boolean} [isHydrating] Whether or not we are in hydration
|
||||
*/
|
||||
export function diff(
|
||||
parentDom,
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
oldDom,
|
||||
isHydrating
|
||||
) {
|
||||
let tmp,
|
||||
newType = newVNode.type;
|
||||
|
||||
// When passing through createElement it assigns the object
|
||||
// constructor as undefined. This to prevent JSON-injection.
|
||||
if (newVNode.constructor !== undefined) return null;
|
||||
|
||||
// If the previous diff bailed out, resume creating/hydrating.
|
||||
if (oldVNode._hydrating != null) {
|
||||
isHydrating = oldVNode._hydrating;
|
||||
oldDom = newVNode._dom = oldVNode._dom;
|
||||
// if we resume, we want the tree to be "unlocked"
|
||||
newVNode._hydrating = null;
|
||||
excessDomChildren = [oldDom];
|
||||
}
|
||||
|
||||
if ((tmp = options._diff)) tmp(newVNode);
|
||||
|
||||
try {
|
||||
outer: if (typeof newType == 'function') {
|
||||
let c, isNew, oldProps, oldState, snapshot, clearProcessingException;
|
||||
let newProps = newVNode.props;
|
||||
|
||||
// Necessary for createContext api. Setting this property will pass
|
||||
// the context value as `this.context` just for this component.
|
||||
tmp = newType.contextType;
|
||||
let provider = tmp && globalContext[tmp._id];
|
||||
let componentContext = tmp
|
||||
? provider
|
||||
? provider.props.value
|
||||
: tmp._defaultValue
|
||||
: globalContext;
|
||||
|
||||
// Get component and set it to `c`
|
||||
if (oldVNode._component) {
|
||||
c = newVNode._component = oldVNode._component;
|
||||
clearProcessingException = c._processingException = c._pendingError;
|
||||
} else {
|
||||
// Instantiate the new component
|
||||
if ('prototype' in newType && newType.prototype.render) {
|
||||
newVNode._component = c = new newType(newProps, componentContext); // eslint-disable-line new-cap
|
||||
} else {
|
||||
newVNode._component = c = new Component(newProps, componentContext);
|
||||
c.constructor = newType;
|
||||
c.render = doRender;
|
||||
}
|
||||
if (provider) provider.sub(c);
|
||||
|
||||
c.props = newProps;
|
||||
if (!c.state) c.state = {};
|
||||
c.context = componentContext;
|
||||
c._globalContext = globalContext;
|
||||
isNew = c._dirty = true;
|
||||
c._renderCallbacks = [];
|
||||
}
|
||||
|
||||
// Invoke getDerivedStateFromProps
|
||||
if (c._nextState == null) {
|
||||
c._nextState = c.state;
|
||||
}
|
||||
if (newType.getDerivedStateFromProps != null) {
|
||||
if (c._nextState == c.state) {
|
||||
c._nextState = assign({}, c._nextState);
|
||||
}
|
||||
|
||||
assign(
|
||||
c._nextState,
|
||||
newType.getDerivedStateFromProps(newProps, c._nextState)
|
||||
);
|
||||
}
|
||||
|
||||
oldProps = c.props;
|
||||
oldState = c.state;
|
||||
|
||||
// Invoke pre-render lifecycle methods
|
||||
if (isNew) {
|
||||
if (
|
||||
newType.getDerivedStateFromProps == null &&
|
||||
c.componentWillMount != null
|
||||
) {
|
||||
c.componentWillMount();
|
||||
}
|
||||
|
||||
if (c.componentDidMount != null) {
|
||||
c._renderCallbacks.push(c.componentDidMount);
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
newType.getDerivedStateFromProps == null &&
|
||||
newProps !== oldProps &&
|
||||
c.componentWillReceiveProps != null
|
||||
) {
|
||||
c.componentWillReceiveProps(newProps, componentContext);
|
||||
}
|
||||
|
||||
if (
|
||||
(!c._force &&
|
||||
c.shouldComponentUpdate != null &&
|
||||
c.shouldComponentUpdate(
|
||||
newProps,
|
||||
c._nextState,
|
||||
componentContext
|
||||
) === false) ||
|
||||
newVNode._original === oldVNode._original
|
||||
) {
|
||||
c.props = newProps;
|
||||
c.state = c._nextState;
|
||||
// More info about this here: https://gist.github.com/JoviDeCroock/bec5f2ce93544d2e6070ef8e0036e4e8
|
||||
if (newVNode._original !== oldVNode._original) c._dirty = false;
|
||||
c._vnode = newVNode;
|
||||
newVNode._dom = oldVNode._dom;
|
||||
newVNode._children = oldVNode._children;
|
||||
if (c._renderCallbacks.length) {
|
||||
commitQueue.push(c);
|
||||
}
|
||||
|
||||
reorderChildren(newVNode, oldDom, parentDom);
|
||||
break outer;
|
||||
}
|
||||
|
||||
if (c.componentWillUpdate != null) {
|
||||
c.componentWillUpdate(newProps, c._nextState, componentContext);
|
||||
}
|
||||
|
||||
if (c.componentDidUpdate != null) {
|
||||
c._renderCallbacks.push(() => {
|
||||
c.componentDidUpdate(oldProps, oldState, snapshot);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
c.context = componentContext;
|
||||
c.props = newProps;
|
||||
c.state = c._nextState;
|
||||
|
||||
if ((tmp = options._render)) tmp(newVNode);
|
||||
|
||||
c._dirty = false;
|
||||
c._vnode = newVNode;
|
||||
c._parentDom = parentDom;
|
||||
|
||||
tmp = c.render(c.props, c.state, c.context);
|
||||
|
||||
// Handle setState called in render, see #2553
|
||||
c.state = c._nextState;
|
||||
|
||||
if (c.getChildContext != null) {
|
||||
globalContext = assign(assign({}, globalContext), c.getChildContext());
|
||||
}
|
||||
|
||||
if (!isNew && c.getSnapshotBeforeUpdate != null) {
|
||||
snapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);
|
||||
}
|
||||
|
||||
let isTopLevelFragment =
|
||||
tmp != null && tmp.type == Fragment && tmp.key == null;
|
||||
let renderResult = isTopLevelFragment ? tmp.props.children : tmp;
|
||||
|
||||
diffChildren(
|
||||
parentDom,
|
||||
Array.isArray(renderResult) ? renderResult : [renderResult],
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
oldDom,
|
||||
isHydrating
|
||||
);
|
||||
|
||||
c.base = newVNode._dom;
|
||||
|
||||
// We successfully rendered this VNode, unset any stored hydration/bailout state:
|
||||
newVNode._hydrating = null;
|
||||
|
||||
if (c._renderCallbacks.length) {
|
||||
commitQueue.push(c);
|
||||
}
|
||||
|
||||
if (clearProcessingException) {
|
||||
c._pendingError = c._processingException = null;
|
||||
}
|
||||
|
||||
c._force = false;
|
||||
} else if (
|
||||
excessDomChildren == null &&
|
||||
newVNode._original === oldVNode._original
|
||||
) {
|
||||
newVNode._children = oldVNode._children;
|
||||
newVNode._dom = oldVNode._dom;
|
||||
} else {
|
||||
newVNode._dom = diffElementNodes(
|
||||
oldVNode._dom,
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
isHydrating
|
||||
);
|
||||
}
|
||||
|
||||
if ((tmp = options.diffed)) tmp(newVNode);
|
||||
} catch (e) {
|
||||
newVNode._original = null;
|
||||
// if hydrating or creating initial tree, bailout preserves DOM:
|
||||
if (isHydrating || excessDomChildren != null) {
|
||||
newVNode._dom = oldDom;
|
||||
newVNode._hydrating = !!isHydrating;
|
||||
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
|
||||
// ^ could possibly be simplified to:
|
||||
// excessDomChildren.length = 0;
|
||||
}
|
||||
options._catchError(e, newVNode, oldVNode);
|
||||
}
|
||||
|
||||
return newVNode._dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<import('../internal').Component>} commitQueue List of components
|
||||
* which have callbacks to invoke in commitRoot
|
||||
* @param {import('../internal').VNode} root
|
||||
*/
|
||||
export function commitRoot(commitQueue, root) {
|
||||
if (options._commit) options._commit(root, commitQueue);
|
||||
|
||||
commitQueue.some(c => {
|
||||
try {
|
||||
commitQueue = c._renderCallbacks;
|
||||
c._renderCallbacks = [];
|
||||
commitQueue.some(cb => {
|
||||
cb.call(c);
|
||||
});
|
||||
} catch (e) {
|
||||
options._catchError(e, c._vnode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff two virtual nodes representing DOM element
|
||||
* @param {import('../internal').PreactElement} dom The DOM element representing
|
||||
* the virtual nodes being diffed
|
||||
* @param {import('../internal').VNode} newVNode The new virtual node
|
||||
* @param {import('../internal').VNode} oldVNode The old virtual node
|
||||
* @param {object} globalContext The current context object
|
||||
* @param {boolean} isSvg Whether or not this DOM node is an SVG node
|
||||
* @param {*} excessDomChildren
|
||||
* @param {Array<import('../internal').Component>} commitQueue List of components
|
||||
* which have callbacks to invoke in commitRoot
|
||||
* @param {boolean} isHydrating Whether or not we are in hydration
|
||||
* @returns {import('../internal').PreactElement}
|
||||
*/
|
||||
function diffElementNodes(
|
||||
dom,
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
isHydrating
|
||||
) {
|
||||
let i;
|
||||
let oldProps = oldVNode.props;
|
||||
let newProps = newVNode.props;
|
||||
|
||||
// Tracks entering and exiting SVG namespace when descending through the tree.
|
||||
isSvg = newVNode.type === 'svg' || isSvg;
|
||||
|
||||
if (excessDomChildren != null) {
|
||||
for (i = 0; i < excessDomChildren.length; i++) {
|
||||
const child = excessDomChildren[i];
|
||||
|
||||
// if newVNode matches an element in excessDomChildren or the `dom`
|
||||
// argument matches an element in excessDomChildren, remove it from
|
||||
// excessDomChildren so it isn't later removed in diffChildren
|
||||
if (
|
||||
child != null &&
|
||||
((newVNode.type === null
|
||||
? child.nodeType === 3
|
||||
: child.localName === newVNode.type) ||
|
||||
dom == child)
|
||||
) {
|
||||
dom = child;
|
||||
excessDomChildren[i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dom == null) {
|
||||
if (newVNode.type === null) {
|
||||
return document.createTextNode(newProps);
|
||||
}
|
||||
|
||||
dom = isSvg
|
||||
? document.createElementNS('http://www.w3.org/2000/svg', newVNode.type)
|
||||
: document.createElement(
|
||||
newVNode.type,
|
||||
newProps.is && { is: newProps.is }
|
||||
);
|
||||
// we created a new parent, so none of the previously attached children can be reused:
|
||||
excessDomChildren = null;
|
||||
// we are creating a new node, so we can assume this is a new subtree (in case we are hydrating), this deopts the hydrate
|
||||
isHydrating = false;
|
||||
}
|
||||
|
||||
if (newVNode.type === null) {
|
||||
// During hydration, we still have to split merged text from SSR'd HTML.
|
||||
if (oldProps !== newProps && (!isHydrating || dom.data !== newProps)) {
|
||||
dom.data = newProps;
|
||||
}
|
||||
} else {
|
||||
if (excessDomChildren != null) {
|
||||
excessDomChildren = EMPTY_ARR.slice.call(dom.childNodes);
|
||||
}
|
||||
|
||||
oldProps = oldVNode.props || EMPTY_OBJ;
|
||||
|
||||
let oldHtml = oldProps.dangerouslySetInnerHTML;
|
||||
let newHtml = newProps.dangerouslySetInnerHTML;
|
||||
|
||||
// During hydration, props are not diffed at all (including dangerouslySetInnerHTML)
|
||||
// @TODO we should warn in debug mode when props don't match here.
|
||||
if (!isHydrating) {
|
||||
// But, if we are in a situation where we are using existing DOM (e.g. replaceNode)
|
||||
// we should read the existing DOM attributes to diff them
|
||||
if (excessDomChildren != null) {
|
||||
oldProps = {};
|
||||
for (let i = 0; i < dom.attributes.length; i++) {
|
||||
oldProps[dom.attributes[i].name] = dom.attributes[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
if (newHtml || oldHtml) {
|
||||
// Avoid re-applying the same '__html' if it did not changed between re-render
|
||||
if (
|
||||
!newHtml ||
|
||||
((!oldHtml || newHtml.__html != oldHtml.__html) &&
|
||||
newHtml.__html !== dom.innerHTML)
|
||||
) {
|
||||
dom.innerHTML = (newHtml && newHtml.__html) || '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
diffProps(dom, newProps, oldProps, isSvg, isHydrating);
|
||||
|
||||
// If the new vnode didn't have dangerouslySetInnerHTML, diff its children
|
||||
if (newHtml) {
|
||||
newVNode._children = [];
|
||||
} else {
|
||||
i = newVNode.props.children;
|
||||
diffChildren(
|
||||
dom,
|
||||
Array.isArray(i) ? i : [i],
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
newVNode.type === 'foreignObject' ? false : isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
EMPTY_OBJ,
|
||||
isHydrating
|
||||
);
|
||||
}
|
||||
|
||||
// (as above, don't diff props during hydration)
|
||||
if (!isHydrating) {
|
||||
if (
|
||||
'value' in newProps &&
|
||||
(i = newProps.value) !== undefined &&
|
||||
// #2756 For the <progress>-element the initial value is 0,
|
||||
// despite the attribute not being present. When the attribute
|
||||
// is missing the progress bar is treated as indeterminate.
|
||||
// To fix that we'll always update it when it is 0 for progress elements
|
||||
(i !== dom.value || (newVNode.type === 'progress' && !i))
|
||||
) {
|
||||
setProperty(dom, 'value', i, oldProps.value, false);
|
||||
}
|
||||
if (
|
||||
'checked' in newProps &&
|
||||
(i = newProps.checked) !== undefined &&
|
||||
i !== dom.checked
|
||||
) {
|
||||
setProperty(dom, 'checked', i, oldProps.checked, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke or update a ref, depending on whether it is a function or object ref.
|
||||
* @param {object|function} ref
|
||||
* @param {any} value
|
||||
* @param {import('../internal').VNode} vnode
|
||||
*/
|
||||
export function applyRef(ref, value, vnode) {
|
||||
try {
|
||||
if (typeof ref == 'function') ref(value);
|
||||
else ref.current = value;
|
||||
} catch (e) {
|
||||
options._catchError(e, vnode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmount a virtual node from the tree and apply DOM changes
|
||||
* @param {import('../internal').VNode} vnode The virtual node to unmount
|
||||
* @param {import('../internal').VNode} parentVNode The parent of the VNode that
|
||||
* initiated the unmount
|
||||
* @param {boolean} [skipRemove] Flag that indicates that a parent node of the
|
||||
* current element is already detached from the DOM.
|
||||
*/
|
||||
export function unmount(vnode, parentVNode, skipRemove) {
|
||||
let r;
|
||||
if (options.unmount) options.unmount(vnode);
|
||||
|
||||
if ((r = vnode.ref)) {
|
||||
if (!r.current || r.current === vnode._dom) applyRef(r, null, parentVNode);
|
||||
}
|
||||
|
||||
let dom;
|
||||
if (!skipRemove && typeof vnode.type != 'function') {
|
||||
skipRemove = (dom = vnode._dom) != null;
|
||||
}
|
||||
|
||||
// Must be set to `undefined` to properly clean up `_nextDom`
|
||||
// for which `null` is a valid value. See comment in `create-element.js`
|
||||
vnode._dom = vnode._nextDom = undefined;
|
||||
|
||||
if ((r = vnode._component) != null) {
|
||||
if (r.componentWillUnmount) {
|
||||
try {
|
||||
r.componentWillUnmount();
|
||||
} catch (e) {
|
||||
options._catchError(e, parentVNode);
|
||||
}
|
||||
}
|
||||
|
||||
r.base = r._parentDom = null;
|
||||
}
|
||||
|
||||
if ((r = vnode._children)) {
|
||||
for (let i = 0; i < r.length; i++) {
|
||||
if (r[i]) unmount(r[i], parentVNode, skipRemove);
|
||||
}
|
||||
}
|
||||
|
||||
if (dom != null) removeNode(dom);
|
||||
}
|
||||
|
||||
/** The `.render()` method for a PFC backing instance. */
|
||||
function doRender(props, state, context) {
|
||||
return this.constructor(props, context);
|
||||
}
|
||||
163
build/javascript/node_modules/preact/src/diff/props.js
generated
vendored
Normal file
163
build/javascript/node_modules/preact/src/diff/props.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
import { IS_NON_DIMENSIONAL } from '../constants';
|
||||
import options from '../options';
|
||||
|
||||
/**
|
||||
* Diff the old and new properties of a VNode and apply changes to the DOM node
|
||||
* @param {import('../internal').PreactElement} dom The DOM node to apply
|
||||
* changes to
|
||||
* @param {object} newProps The new props
|
||||
* @param {object} oldProps The old props
|
||||
* @param {boolean} isSvg Whether or not this node is an SVG node
|
||||
* @param {boolean} hydrate Whether or not we are in hydration mode
|
||||
*/
|
||||
export function diffProps(dom, newProps, oldProps, isSvg, hydrate) {
|
||||
let i;
|
||||
|
||||
for (i in oldProps) {
|
||||
if (i !== 'children' && i !== 'key' && !(i in newProps)) {
|
||||
setProperty(dom, i, null, oldProps[i], isSvg);
|
||||
}
|
||||
}
|
||||
|
||||
for (i in newProps) {
|
||||
if (
|
||||
(!hydrate || typeof newProps[i] == 'function') &&
|
||||
i !== 'children' &&
|
||||
i !== 'key' &&
|
||||
i !== 'value' &&
|
||||
i !== 'checked' &&
|
||||
oldProps[i] !== newProps[i]
|
||||
) {
|
||||
setProperty(dom, i, newProps[i], oldProps[i], isSvg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setStyle(style, key, value) {
|
||||
if (key[0] === '-') {
|
||||
style.setProperty(key, value);
|
||||
} else if (value == null) {
|
||||
style[key] = '';
|
||||
} else if (typeof value != 'number' || IS_NON_DIMENSIONAL.test(key)) {
|
||||
style[key] = value;
|
||||
} else {
|
||||
style[key] = value + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property value on a DOM node
|
||||
* @param {import('../internal').PreactElement} dom The DOM node to modify
|
||||
* @param {string} name The name of the property to set
|
||||
* @param {*} value The value to set the property to
|
||||
* @param {*} oldValue The old value the property had
|
||||
* @param {boolean} isSvg Whether or not this DOM node is an SVG node or not
|
||||
*/
|
||||
export function setProperty(dom, name, value, oldValue, isSvg) {
|
||||
let useCapture, nameLower, proxy;
|
||||
|
||||
if (isSvg && name == 'className') name = 'class';
|
||||
|
||||
// if (isSvg) {
|
||||
// if (name === 'className') name = 'class';
|
||||
// } else if (name === 'class') name += 'Name';
|
||||
|
||||
if (name === 'style') {
|
||||
if (typeof value == 'string') {
|
||||
dom.style.cssText = value;
|
||||
} else {
|
||||
if (typeof oldValue == 'string') {
|
||||
dom.style.cssText = oldValue = '';
|
||||
}
|
||||
|
||||
if (oldValue) {
|
||||
for (name in oldValue) {
|
||||
if (!(value && name in value)) {
|
||||
setStyle(dom.style, name, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value) {
|
||||
for (name in value) {
|
||||
if (!oldValue || value[name] !== oldValue[name]) {
|
||||
setStyle(dom.style, name, value[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6
|
||||
else if (name[0] === 'o' && name[1] === 'n') {
|
||||
useCapture = name !== (name = name.replace(/Capture$/, ''));
|
||||
nameLower = name.toLowerCase();
|
||||
if (nameLower in dom) name = nameLower;
|
||||
name = name.slice(2);
|
||||
|
||||
if (!dom._listeners) dom._listeners = {};
|
||||
dom._listeners[name + useCapture] = value;
|
||||
|
||||
proxy = useCapture ? eventProxyCapture : eventProxy;
|
||||
if (value) {
|
||||
if (!oldValue) dom.addEventListener(name, proxy, useCapture);
|
||||
} else {
|
||||
dom.removeEventListener(name, proxy, useCapture);
|
||||
}
|
||||
} else if (
|
||||
name !== 'list' &&
|
||||
name !== 'tagName' &&
|
||||
// HTMLButtonElement.form and HTMLInputElement.form are read-only but can be set using
|
||||
// setAttribute
|
||||
name !== 'form' &&
|
||||
name !== 'type' &&
|
||||
name !== 'size' &&
|
||||
name !== 'download' &&
|
||||
name !== 'href' &&
|
||||
!isSvg &&
|
||||
name in dom
|
||||
) {
|
||||
dom[name] = value == null ? '' : value;
|
||||
} else if (typeof value != 'function' && name !== 'dangerouslySetInnerHTML') {
|
||||
if (name !== (name = name.replace(/xlink:?/, ''))) {
|
||||
if (value == null || value === false) {
|
||||
dom.removeAttributeNS(
|
||||
'http://www.w3.org/1999/xlink',
|
||||
name.toLowerCase()
|
||||
);
|
||||
} else {
|
||||
dom.setAttributeNS(
|
||||
'http://www.w3.org/1999/xlink',
|
||||
name.toLowerCase(),
|
||||
value
|
||||
);
|
||||
}
|
||||
} else if (
|
||||
value == null ||
|
||||
(value === false &&
|
||||
// ARIA-attributes have a different notion of boolean values.
|
||||
// The value `false` is different from the attribute not
|
||||
// existing on the DOM, so we can't remove it. For non-boolean
|
||||
// ARIA-attributes we could treat false as a removal, but the
|
||||
// amount of exceptions would cost us too many bytes. On top of
|
||||
// that other VDOM frameworks also always stringify `false`.
|
||||
!/^ar/.test(name))
|
||||
) {
|
||||
dom.removeAttribute(name);
|
||||
} else {
|
||||
dom.setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy an event to hooked event handlers
|
||||
* @param {Event} e The event object from the browser
|
||||
* @private
|
||||
*/
|
||||
function eventProxy(e) {
|
||||
this._listeners[e.type + false](options.event ? options.event(e) : e);
|
||||
}
|
||||
|
||||
function eventProxyCapture(e) {
|
||||
this._listeners[e.type + true](options.event ? options.event(e) : e);
|
||||
}
|
||||
306
build/javascript/node_modules/preact/src/index.d.ts
generated
vendored
Normal file
306
build/javascript/node_modules/preact/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,306 @@
|
||||
export = preact;
|
||||
export as namespace preact;
|
||||
|
||||
import { JSXInternal } from './jsx';
|
||||
|
||||
declare namespace preact {
|
||||
export import JSX = JSXInternal;
|
||||
|
||||
//
|
||||
// Preact Virtual DOM
|
||||
// -----------------------------------
|
||||
|
||||
interface VNode<P = {}> {
|
||||
type: ComponentType<P> | string;
|
||||
props: P & { children: ComponentChildren };
|
||||
key: Key;
|
||||
/**
|
||||
* ref is not guaranteed by React.ReactElement, for compatibility reasons
|
||||
* with popular react libs we define it as optional too
|
||||
*/
|
||||
ref?: Ref<any> | null;
|
||||
/**
|
||||
* The time this `vnode` started rendering. Will only be set when
|
||||
* the devtools are attached.
|
||||
* Default value: `0`
|
||||
*/
|
||||
startTime?: number;
|
||||
/**
|
||||
* The time that the rendering of this `vnode` was completed. Will only be
|
||||
* set when the devtools are attached.
|
||||
* Default value: `-1`
|
||||
*/
|
||||
endTime?: number;
|
||||
}
|
||||
|
||||
//
|
||||
// Preact Component interface
|
||||
// -----------------------------------
|
||||
|
||||
type Key = string | number | any;
|
||||
|
||||
type RefObject<T> = { current?: T | null };
|
||||
type RefCallback<T> = (instance: T | null) => void;
|
||||
type Ref<T> = RefObject<T> | RefCallback<T>;
|
||||
|
||||
type ComponentChild =
|
||||
| VNode<any>
|
||||
| object
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| undefined;
|
||||
type ComponentChildren = ComponentChild[] | ComponentChild;
|
||||
|
||||
interface Attributes {
|
||||
key?: Key;
|
||||
jsx?: boolean;
|
||||
}
|
||||
|
||||
interface ClassAttributes<T> extends Attributes {
|
||||
ref?: Ref<T>;
|
||||
}
|
||||
|
||||
interface PreactDOMAttributes {
|
||||
children?: ComponentChildren;
|
||||
dangerouslySetInnerHTML?: {
|
||||
__html: string;
|
||||
};
|
||||
}
|
||||
|
||||
type RenderableProps<P, RefType = any> = P &
|
||||
Readonly<Attributes & { children?: ComponentChildren; ref?: Ref<RefType> }>;
|
||||
|
||||
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
||||
type ComponentFactory<P = {}> = ComponentType<P>;
|
||||
|
||||
type ComponentProps<
|
||||
C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements
|
||||
> = C extends ComponentType<infer P>
|
||||
? P
|
||||
: C extends keyof JSXInternal.IntrinsicElements
|
||||
? JSXInternal.IntrinsicElements[C]
|
||||
: never;
|
||||
|
||||
interface FunctionComponent<P = {}> {
|
||||
(props: RenderableProps<P>, context?: any): VNode<any> | null;
|
||||
displayName?: string;
|
||||
defaultProps?: Partial<P>;
|
||||
}
|
||||
interface FunctionalComponent<P = {}> extends FunctionComponent<P> {}
|
||||
|
||||
interface ComponentClass<P = {}, S = {}> {
|
||||
new (props: P, context?: any): Component<P, S>;
|
||||
displayName?: string;
|
||||
defaultProps?: Partial<P>;
|
||||
getDerivedStateFromProps?(
|
||||
props: Readonly<P>,
|
||||
state: Readonly<S>
|
||||
): Partial<S> | null;
|
||||
getDerivedStateFromError?(error: any): Partial<S> | null;
|
||||
}
|
||||
interface ComponentConstructor<P = {}, S = {}> extends ComponentClass<P, S> {}
|
||||
|
||||
// Type alias for a component instance considered generally, whether stateless or stateful.
|
||||
type AnyComponent<P = {}, S = {}> = FunctionComponent<P> | Component<P, S>;
|
||||
|
||||
interface Component<P = {}, S = {}> {
|
||||
componentWillMount?(): void;
|
||||
componentDidMount?(): void;
|
||||
componentWillUnmount?(): void;
|
||||
getChildContext?(): object;
|
||||
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
|
||||
shouldComponentUpdate?(
|
||||
nextProps: Readonly<P>,
|
||||
nextState: Readonly<S>,
|
||||
nextContext: any
|
||||
): boolean;
|
||||
componentWillUpdate?(
|
||||
nextProps: Readonly<P>,
|
||||
nextState: Readonly<S>,
|
||||
nextContext: any
|
||||
): void;
|
||||
getSnapshotBeforeUpdate?(oldProps: Readonly<P>, oldState: Readonly<S>): any;
|
||||
componentDidUpdate?(
|
||||
previousProps: Readonly<P>,
|
||||
previousState: Readonly<S>,
|
||||
snapshot: any
|
||||
): void;
|
||||
componentDidCatch?(error: any, errorInfo: any): void;
|
||||
}
|
||||
|
||||
abstract class Component<P, S> {
|
||||
constructor(props?: P, context?: any);
|
||||
|
||||
static displayName?: string;
|
||||
static defaultProps?: any;
|
||||
static contextType?: Context<any>;
|
||||
|
||||
// Static members cannot reference class type parameters. This is not
|
||||
// supported in TypeScript. Reusing the same type arguments from `Component`
|
||||
// will lead to an impossible state where one cannot satisfy the type
|
||||
// constraint under no circumstances, see #1356.In general type arguments
|
||||
// seem to be a bit buggy and not supported well at the time of this
|
||||
// writing with TS 3.3.3333.
|
||||
static getDerivedStateFromProps?(
|
||||
props: Readonly<object>,
|
||||
state: Readonly<object>
|
||||
): object | null;
|
||||
static getDerivedStateFromError?(error: any): object | null;
|
||||
|
||||
state: Readonly<S>;
|
||||
props: RenderableProps<P>;
|
||||
context: any;
|
||||
base?: Element | Text;
|
||||
|
||||
// From https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e836acc75a78cf0655b5dfdbe81d69fdd4d8a252/types/react/index.d.ts#L402
|
||||
// // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
|
||||
// // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
|
||||
setState<K extends keyof S>(
|
||||
state:
|
||||
| ((
|
||||
prevState: Readonly<S>,
|
||||
props: Readonly<P>
|
||||
) => Pick<S, K> | Partial<S> | null)
|
||||
| (Pick<S, K> | Partial<S> | null),
|
||||
callback?: () => void
|
||||
): void;
|
||||
|
||||
forceUpdate(callback?: () => void): void;
|
||||
|
||||
abstract render(
|
||||
props?: RenderableProps<P>,
|
||||
state?: Readonly<S>,
|
||||
context?: any
|
||||
): ComponentChild;
|
||||
}
|
||||
|
||||
//
|
||||
// Preact createElement
|
||||
// -----------------------------------
|
||||
|
||||
function createElement(
|
||||
type: string,
|
||||
props:
|
||||
| (JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any>)
|
||||
| null,
|
||||
...children: ComponentChildren[]
|
||||
): VNode<any>;
|
||||
function createElement<P>(
|
||||
type: ComponentType<P>,
|
||||
props: (Attributes & P) | null,
|
||||
...children: ComponentChildren[]
|
||||
): VNode<any>;
|
||||
namespace createElement {
|
||||
export import JSX = JSXInternal;
|
||||
}
|
||||
|
||||
function h(
|
||||
type: string,
|
||||
props:
|
||||
| (JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any>)
|
||||
| null,
|
||||
...children: ComponentChildren[]
|
||||
): VNode<any>;
|
||||
function h<P>(
|
||||
type: ComponentType<P>,
|
||||
props: (Attributes & P) | null,
|
||||
...children: ComponentChildren[]
|
||||
): VNode<any>;
|
||||
namespace h {
|
||||
export import JSX = JSXInternal;
|
||||
}
|
||||
|
||||
//
|
||||
// Preact render
|
||||
// -----------------------------------
|
||||
|
||||
function render(
|
||||
vnode: ComponentChild,
|
||||
parent: Element | Document | ShadowRoot | DocumentFragment,
|
||||
replaceNode?: Element | Text
|
||||
): void;
|
||||
function hydrate(
|
||||
vnode: ComponentChild,
|
||||
parent: Element | Document | ShadowRoot | DocumentFragment
|
||||
): void;
|
||||
function cloneElement(
|
||||
vnode: VNode<any>,
|
||||
props?: any,
|
||||
...children: ComponentChildren[]
|
||||
): VNode<any>;
|
||||
function cloneElement<P>(
|
||||
vnode: VNode<P>,
|
||||
props?: any,
|
||||
...children: ComponentChildren[]
|
||||
): VNode<P>;
|
||||
|
||||
//
|
||||
// Preact Built-in Components
|
||||
// -----------------------------------
|
||||
|
||||
// TODO: Revisit what the public type of this is...
|
||||
const Fragment: ComponentClass<{}, {}>;
|
||||
|
||||
//
|
||||
// Preact options
|
||||
// -----------------------------------
|
||||
|
||||
/**
|
||||
* Global options for preact
|
||||
*/
|
||||
interface Options {
|
||||
/** Attach a hook that is invoked whenever a VNode is created. */
|
||||
vnode?(vnode: VNode): void;
|
||||
/** Attach a hook that is invoked immediately before a vnode is unmounted. */
|
||||
unmount?(vnode: VNode): void;
|
||||
/** Attach a hook that is invoked after a vnode has rendered. */
|
||||
diffed?(vnode: VNode): void;
|
||||
event?(e: Event): any;
|
||||
requestAnimationFrame?: typeof requestAnimationFrame;
|
||||
debounceRendering?(cb: () => void): void;
|
||||
useDebugValue?(value: string | number): void;
|
||||
__suspenseDidResolve?(vnode: VNode, cb: () => void): void;
|
||||
// __canSuspenseResolve?(vnode: VNode, cb: () => void): void;
|
||||
}
|
||||
|
||||
const options: Options;
|
||||
|
||||
//
|
||||
// Preact helpers
|
||||
// -----------------------------------
|
||||
function createRef<T = any>(): RefObject<T>;
|
||||
function toChildArray(
|
||||
children: ComponentChildren
|
||||
): Array<VNode | string | number>;
|
||||
function isValidElement(vnode: any): vnode is VNode;
|
||||
|
||||
//
|
||||
// Context
|
||||
// -----------------------------------
|
||||
interface Consumer<T>
|
||||
extends FunctionComponent<{
|
||||
children: (value: T) => ComponentChildren;
|
||||
}> {}
|
||||
interface PreactConsumer<T> extends Consumer<T> {}
|
||||
|
||||
interface Provider<T>
|
||||
extends FunctionComponent<{
|
||||
value: T;
|
||||
children: ComponentChildren;
|
||||
}> {}
|
||||
interface PreactProvider<T> extends Provider<T> {}
|
||||
|
||||
interface Context<T> {
|
||||
Consumer: Consumer<T>;
|
||||
Provider: Provider<T>;
|
||||
}
|
||||
interface PreactContext<T> extends Context<T> {}
|
||||
|
||||
function createContext<T>(defaultValue: T): Context<T>;
|
||||
}
|
||||
14
build/javascript/node_modules/preact/src/index.js
generated
vendored
Normal file
14
build/javascript/node_modules/preact/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export { render, hydrate } from './render';
|
||||
export {
|
||||
createElement,
|
||||
createElement as h,
|
||||
Fragment,
|
||||
createRef,
|
||||
isValidElement
|
||||
} from './create-element';
|
||||
export { Component } from './component';
|
||||
export { cloneElement } from './clone-element';
|
||||
export { createContext } from './create-context';
|
||||
export { toChildArray } from './diff/children';
|
||||
export { unmount as __u } from './diff';
|
||||
export { default as options } from './options';
|
||||
117
build/javascript/node_modules/preact/src/internal.d.ts
generated
vendored
Normal file
117
build/javascript/node_modules/preact/src/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import * as preact from './index';
|
||||
|
||||
export enum HookType {
|
||||
useState = 1,
|
||||
useReducer = 2,
|
||||
useEffect = 3,
|
||||
useLayoutEffect = 4,
|
||||
useRef = 5,
|
||||
useImperativeHandle = 6,
|
||||
useMemo = 7,
|
||||
useCallback = 8,
|
||||
useContext = 9,
|
||||
useErrorBoundary = 10,
|
||||
// Not a real hook, but the devtools treat is as such
|
||||
useDebugvalue = 11
|
||||
}
|
||||
|
||||
export interface DevSource {
|
||||
fileName: string;
|
||||
lineNumber: number;
|
||||
}
|
||||
|
||||
export interface Options extends preact.Options {
|
||||
/** Attach a hook that is invoked before render, mainly to check the arguments. */
|
||||
_root?(
|
||||
vnode: preact.ComponentChild,
|
||||
parent: Element | Document | ShadowRoot | DocumentFragment
|
||||
): void;
|
||||
/** Attach a hook that is invoked before a vnode is diffed. */
|
||||
_diff?(vnode: VNode): void;
|
||||
/** Attach a hook that is invoked after a tree was mounted or was updated. */
|
||||
_commit?(vnode: VNode, commitQueue: Component[]): void;
|
||||
/** Attach a hook that is invoked before a vnode has rendered. */
|
||||
_render?(vnode: VNode): void;
|
||||
/** Attach a hook that is invoked before a hook's state is queried. */
|
||||
_hook?(component: Component, index: number, type: HookType): void;
|
||||
/** Bypass effect execution. Currenty only used in devtools for hooks inspection */
|
||||
_skipEffects?: boolean;
|
||||
/** Attach a hook that is invoked after an error is caught in a component but before calling lifecycle hooks */
|
||||
_catchError(error: any, vnode: VNode, oldVNode: VNode | undefined): void;
|
||||
}
|
||||
|
||||
export interface FunctionalComponent<P = {}>
|
||||
extends preact.FunctionComponent<P> {
|
||||
// Define getDerivedStateFromProps as undefined on FunctionalComponent
|
||||
// to get rid of some errors in `diff()`
|
||||
getDerivedStateFromProps?: undefined;
|
||||
}
|
||||
|
||||
// Redefine ComponentFactory using our new internal FunctionalComponent interface above
|
||||
export type ComponentFactory<P> =
|
||||
| preact.ComponentClass<P>
|
||||
| FunctionalComponent<P>;
|
||||
|
||||
export interface PreactElement extends HTMLElement, Text {
|
||||
_children?: VNode<any> | null;
|
||||
/** Event listeners to support event delegation */
|
||||
_listeners: Record<string, (e: Event) => void>;
|
||||
|
||||
// Preact uses this attribute to detect SVG nodes
|
||||
ownerSVGElement?: SVGElement | null;
|
||||
|
||||
// style: HTMLElement["style"]; // From HTMLElement
|
||||
|
||||
data?: string | number; // From Text node
|
||||
}
|
||||
|
||||
export interface VNode<P = {}> extends preact.VNode<P> {
|
||||
// Redefine type here using our internal ComponentFactory type
|
||||
type: string | ComponentFactory<P>;
|
||||
props: P & { children: preact.ComponentChildren };
|
||||
_children: Array<VNode<any>> | null;
|
||||
_parent: VNode | null;
|
||||
_depth: number | null;
|
||||
/**
|
||||
* The [first (for Fragments)] DOM child of a VNode
|
||||
*/
|
||||
_dom: PreactElement | null;
|
||||
/**
|
||||
* The last dom child of a Fragment, or components that return a Fragment
|
||||
*/
|
||||
_nextDom: PreactElement | null;
|
||||
_component: Component | null;
|
||||
_hydrating: boolean | null;
|
||||
constructor: undefined;
|
||||
_original?: VNode | null;
|
||||
}
|
||||
|
||||
export interface Component<P = {}, S = {}> extends preact.Component<P, S> {
|
||||
// When component is functional component, this is reset to functional component
|
||||
constructor: preact.ComponentType<P>;
|
||||
state: S; // Override Component["state"] to not be readonly for internal use, specifically Hooks
|
||||
base?: PreactElement;
|
||||
|
||||
_dirty: boolean;
|
||||
_force?: boolean;
|
||||
_renderCallbacks: Array<() => void>; // Only class components
|
||||
_globalContext?: any;
|
||||
_vnode?: VNode<P> | null;
|
||||
_nextState?: S | null; // Only class components
|
||||
/** Only used in the devtools to later dirty check if state has changed */
|
||||
_prevState?: S | null;
|
||||
/**
|
||||
* Pointer to the parent dom node. This is only needed for top-level Fragment
|
||||
* components or array returns.
|
||||
*/
|
||||
_parentDom?: PreactElement | null;
|
||||
// Always read, set only when handling error
|
||||
_processingException?: Component<any, any> | null;
|
||||
// Always read, set only when handling error. This is used to indicate at diffTime to set _processingException
|
||||
_pendingError?: Component<any, any> | null;
|
||||
}
|
||||
|
||||
export interface PreactContext extends preact.Context<any> {
|
||||
_id: string;
|
||||
_defaultValue: any;
|
||||
}
|
||||
931
build/javascript/node_modules/preact/src/jsx.d.ts
generated
vendored
Normal file
931
build/javascript/node_modules/preact/src/jsx.d.ts
generated
vendored
Normal file
@@ -0,0 +1,931 @@
|
||||
// Users who only use Preact for SSR might not specify "dom" in their lib in tsconfig.json
|
||||
/// <reference lib="dom" />
|
||||
|
||||
type Defaultize<Props, Defaults> =
|
||||
// Distribute over unions
|
||||
Props extends any // Make any properties included in Default optional
|
||||
? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> &
|
||||
// Include the remaining properties from Props
|
||||
Pick<Props, Exclude<keyof Props, keyof Defaults>>
|
||||
: never;
|
||||
|
||||
export namespace JSXInternal {
|
||||
type LibraryManagedAttributes<Component, Props> = Component extends {
|
||||
defaultProps: infer Defaults;
|
||||
}
|
||||
? Defaultize<Props, Defaults>
|
||||
: Props;
|
||||
|
||||
interface IntrinsicAttributes {
|
||||
key?: any;
|
||||
}
|
||||
|
||||
interface Element extends preact.VNode<any> {}
|
||||
|
||||
interface ElementClass extends preact.Component<any, any> {}
|
||||
|
||||
interface ElementAttributesProperty {
|
||||
props: any;
|
||||
}
|
||||
|
||||
interface ElementChildrenAttribute {
|
||||
children: any;
|
||||
}
|
||||
|
||||
interface SVGAttributes<Target extends EventTarget = SVGElement>
|
||||
extends HTMLAttributes<Target> {
|
||||
accentHeight?: number | string;
|
||||
accumulate?: 'none' | 'sum';
|
||||
additive?: 'replace' | 'sum';
|
||||
alignmentBaseline?:
|
||||
| 'auto'
|
||||
| 'baseline'
|
||||
| 'before-edge'
|
||||
| 'text-before-edge'
|
||||
| 'middle'
|
||||
| 'central'
|
||||
| 'after-edge'
|
||||
| 'text-after-edge'
|
||||
| 'ideographic'
|
||||
| 'alphabetic'
|
||||
| 'hanging'
|
||||
| 'mathematical'
|
||||
| 'inherit';
|
||||
allowReorder?: 'no' | 'yes';
|
||||
alphabetic?: number | string;
|
||||
amplitude?: number | string;
|
||||
arabicForm?: 'initial' | 'medial' | 'terminal' | 'isolated';
|
||||
ascent?: number | string;
|
||||
attributeName?: string;
|
||||
attributeType?: string;
|
||||
autoReverse?: number | string;
|
||||
azimuth?: number | string;
|
||||
baseFrequency?: number | string;
|
||||
baselineShift?: number | string;
|
||||
baseProfile?: number | string;
|
||||
bbox?: number | string;
|
||||
begin?: number | string;
|
||||
bias?: number | string;
|
||||
by?: number | string;
|
||||
calcMode?: number | string;
|
||||
capHeight?: number | string;
|
||||
clip?: number | string;
|
||||
clipPath?: string;
|
||||
clipPathUnits?: number | string;
|
||||
clipRule?: number | string;
|
||||
colorInterpolation?: number | string;
|
||||
colorInterpolationFilters?: 'auto' | 'sRGB' | 'linearRGB' | 'inherit';
|
||||
colorProfile?: number | string;
|
||||
colorRendering?: number | string;
|
||||
contentScriptType?: number | string;
|
||||
contentStyleType?: number | string;
|
||||
cursor?: number | string;
|
||||
cx?: number | string;
|
||||
cy?: number | string;
|
||||
d?: string;
|
||||
decelerate?: number | string;
|
||||
descent?: number | string;
|
||||
diffuseConstant?: number | string;
|
||||
direction?: number | string;
|
||||
display?: number | string;
|
||||
divisor?: number | string;
|
||||
dominantBaseline?: number | string;
|
||||
dur?: number | string;
|
||||
dx?: number | string;
|
||||
dy?: number | string;
|
||||
edgeMode?: number | string;
|
||||
elevation?: number | string;
|
||||
enableBackground?: number | string;
|
||||
end?: number | string;
|
||||
exponent?: number | string;
|
||||
externalResourcesRequired?: number | string;
|
||||
fill?: string;
|
||||
fillOpacity?: number | string;
|
||||
fillRule?: 'nonzero' | 'evenodd' | 'inherit';
|
||||
filter?: string;
|
||||
filterRes?: number | string;
|
||||
filterUnits?: number | string;
|
||||
floodColor?: number | string;
|
||||
floodOpacity?: number | string;
|
||||
focusable?: number | string;
|
||||
fontFamily?: string;
|
||||
fontSize?: number | string;
|
||||
fontSizeAdjust?: number | string;
|
||||
fontStretch?: number | string;
|
||||
fontStyle?: number | string;
|
||||
fontVariant?: number | string;
|
||||
fontWeight?: number | string;
|
||||
format?: number | string;
|
||||
from?: number | string;
|
||||
fx?: number | string;
|
||||
fy?: number | string;
|
||||
g1?: number | string;
|
||||
g2?: number | string;
|
||||
glyphName?: number | string;
|
||||
glyphOrientationHorizontal?: number | string;
|
||||
glyphOrientationVertical?: number | string;
|
||||
glyphRef?: number | string;
|
||||
gradientTransform?: string;
|
||||
gradientUnits?: string;
|
||||
hanging?: number | string;
|
||||
horizAdvX?: number | string;
|
||||
horizOriginX?: number | string;
|
||||
ideographic?: number | string;
|
||||
imageRendering?: number | string;
|
||||
in2?: number | string;
|
||||
in?: string;
|
||||
intercept?: number | string;
|
||||
k1?: number | string;
|
||||
k2?: number | string;
|
||||
k3?: number | string;
|
||||
k4?: number | string;
|
||||
k?: number | string;
|
||||
kernelMatrix?: number | string;
|
||||
kernelUnitLength?: number | string;
|
||||
kerning?: number | string;
|
||||
keyPoints?: number | string;
|
||||
keySplines?: number | string;
|
||||
keyTimes?: number | string;
|
||||
lengthAdjust?: number | string;
|
||||
letterSpacing?: number | string;
|
||||
lightingColor?: number | string;
|
||||
limitingConeAngle?: number | string;
|
||||
local?: number | string;
|
||||
markerEnd?: string;
|
||||
markerHeight?: number | string;
|
||||
markerMid?: string;
|
||||
markerStart?: string;
|
||||
markerUnits?: number | string;
|
||||
markerWidth?: number | string;
|
||||
mask?: string;
|
||||
maskContentUnits?: number | string;
|
||||
maskUnits?: number | string;
|
||||
mathematical?: number | string;
|
||||
mode?: number | string;
|
||||
numOctaves?: number | string;
|
||||
offset?: number | string;
|
||||
opacity?: number | string;
|
||||
operator?: number | string;
|
||||
order?: number | string;
|
||||
orient?: number | string;
|
||||
orientation?: number | string;
|
||||
origin?: number | string;
|
||||
overflow?: number | string;
|
||||
overlinePosition?: number | string;
|
||||
overlineThickness?: number | string;
|
||||
paintOrder?: number | string;
|
||||
panose1?: number | string;
|
||||
pathLength?: number | string;
|
||||
patternContentUnits?: string;
|
||||
patternTransform?: number | string;
|
||||
patternUnits?: string;
|
||||
pointerEvents?: number | string;
|
||||
points?: string;
|
||||
pointsAtX?: number | string;
|
||||
pointsAtY?: number | string;
|
||||
pointsAtZ?: number | string;
|
||||
preserveAlpha?: number | string;
|
||||
preserveAspectRatio?: string;
|
||||
primitiveUnits?: number | string;
|
||||
r?: number | string;
|
||||
radius?: number | string;
|
||||
refX?: number | string;
|
||||
refY?: number | string;
|
||||
renderingIntent?: number | string;
|
||||
repeatCount?: number | string;
|
||||
repeatDur?: number | string;
|
||||
requiredExtensions?: number | string;
|
||||
requiredFeatures?: number | string;
|
||||
restart?: number | string;
|
||||
result?: string;
|
||||
rotate?: number | string;
|
||||
rx?: number | string;
|
||||
ry?: number | string;
|
||||
scale?: number | string;
|
||||
seed?: number | string;
|
||||
shapeRendering?: number | string;
|
||||
slope?: number | string;
|
||||
spacing?: number | string;
|
||||
specularConstant?: number | string;
|
||||
specularExponent?: number | string;
|
||||
speed?: number | string;
|
||||
spreadMethod?: string;
|
||||
startOffset?: number | string;
|
||||
stdDeviation?: number | string;
|
||||
stemh?: number | string;
|
||||
stemv?: number | string;
|
||||
stitchTiles?: number | string;
|
||||
stopColor?: string;
|
||||
stopOpacity?: number | string;
|
||||
strikethroughPosition?: number | string;
|
||||
strikethroughThickness?: number | string;
|
||||
string?: number | string;
|
||||
stroke?: string;
|
||||
strokeDasharray?: string | number;
|
||||
strokeDashoffset?: string | number;
|
||||
strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit';
|
||||
strokeLinejoin?: 'miter' | 'round' | 'bevel' | 'inherit';
|
||||
strokeMiterlimit?: string | number;
|
||||
strokeOpacity?: number | string;
|
||||
strokeWidth?: number | string;
|
||||
surfaceScale?: number | string;
|
||||
systemLanguage?: number | string;
|
||||
tableValues?: number | string;
|
||||
targetX?: number | string;
|
||||
targetY?: number | string;
|
||||
textAnchor?: string;
|
||||
textDecoration?: number | string;
|
||||
textLength?: number | string;
|
||||
textRendering?: number | string;
|
||||
to?: number | string;
|
||||
transform?: string;
|
||||
u1?: number | string;
|
||||
u2?: number | string;
|
||||
underlinePosition?: number | string;
|
||||
underlineThickness?: number | string;
|
||||
unicode?: number | string;
|
||||
unicodeBidi?: number | string;
|
||||
unicodeRange?: number | string;
|
||||
unitsPerEm?: number | string;
|
||||
vAlphabetic?: number | string;
|
||||
values?: string;
|
||||
vectorEffect?: number | string;
|
||||
version?: string;
|
||||
vertAdvY?: number | string;
|
||||
vertOriginX?: number | string;
|
||||
vertOriginY?: number | string;
|
||||
vHanging?: number | string;
|
||||
vIdeographic?: number | string;
|
||||
viewBox?: string;
|
||||
viewTarget?: number | string;
|
||||
visibility?: number | string;
|
||||
vMathematical?: number | string;
|
||||
widths?: number | string;
|
||||
wordSpacing?: number | string;
|
||||
writingMode?: number | string;
|
||||
x1?: number | string;
|
||||
x2?: number | string;
|
||||
x?: number | string;
|
||||
xChannelSelector?: string;
|
||||
xHeight?: number | string;
|
||||
xlinkActuate?: string;
|
||||
xlinkArcrole?: string;
|
||||
xlinkHref?: string;
|
||||
xlinkRole?: string;
|
||||
xlinkShow?: string;
|
||||
xlinkTitle?: string;
|
||||
xlinkType?: string;
|
||||
xmlBase?: string;
|
||||
xmlLang?: string;
|
||||
xmlns?: string;
|
||||
xmlnsXlink?: string;
|
||||
xmlSpace?: string;
|
||||
y1?: number | string;
|
||||
y2?: number | string;
|
||||
y?: number | string;
|
||||
yChannelSelector?: string;
|
||||
z?: number | string;
|
||||
zoomAndPan?: string;
|
||||
}
|
||||
|
||||
interface PathAttributes {
|
||||
d: string;
|
||||
}
|
||||
|
||||
type TargetedEvent<
|
||||
Target extends EventTarget = EventTarget,
|
||||
TypedEvent extends Event = Event
|
||||
> = Omit<TypedEvent, 'currentTarget'> & {
|
||||
readonly currentTarget: Target;
|
||||
};
|
||||
|
||||
type TargetedAnimationEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
AnimationEvent
|
||||
>;
|
||||
type TargetedClipboardEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
ClipboardEvent
|
||||
>;
|
||||
type TargetedCompositionEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
CompositionEvent
|
||||
>;
|
||||
type TargetedDragEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
DragEvent
|
||||
>;
|
||||
type TargetedFocusEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
FocusEvent
|
||||
>;
|
||||
type TargetedKeyboardEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
KeyboardEvent
|
||||
>;
|
||||
type TargetedMouseEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
MouseEvent
|
||||
>;
|
||||
type TargetedPointerEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
PointerEvent
|
||||
>;
|
||||
type TargetedTouchEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
TouchEvent
|
||||
>;
|
||||
type TargetedTransitionEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
TransitionEvent
|
||||
>;
|
||||
type TargetedUIEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
UIEvent
|
||||
>;
|
||||
type TargetedWheelEvent<Target extends EventTarget> = TargetedEvent<
|
||||
Target,
|
||||
WheelEvent
|
||||
>;
|
||||
|
||||
interface EventHandler<E extends TargetedEvent> {
|
||||
/**
|
||||
* The `this` keyword always points to the DOM element the event handler
|
||||
* was invoked on. See: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers#Event_handlers_parameters_this_binding_and_the_return_value
|
||||
*/
|
||||
(this: E['currentTarget'], event: E): void;
|
||||
}
|
||||
|
||||
type AnimationEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedAnimationEvent<Target>
|
||||
>;
|
||||
type ClipboardEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedClipboardEvent<Target>
|
||||
>;
|
||||
type CompositionEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedCompositionEvent<Target>
|
||||
>;
|
||||
type DragEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedDragEvent<Target>
|
||||
>;
|
||||
type FocusEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedFocusEvent<Target>
|
||||
>;
|
||||
type GenericEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedEvent<Target>
|
||||
>;
|
||||
type KeyboardEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedKeyboardEvent<Target>
|
||||
>;
|
||||
type MouseEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedMouseEvent<Target>
|
||||
>;
|
||||
type PointerEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedPointerEvent<Target>
|
||||
>;
|
||||
type TouchEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedTouchEvent<Target>
|
||||
>;
|
||||
type TransitionEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedTransitionEvent<Target>
|
||||
>;
|
||||
type UIEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedUIEvent<Target>
|
||||
>;
|
||||
type WheelEventHandler<Target extends EventTarget> = EventHandler<
|
||||
TargetedWheelEvent<Target>
|
||||
>;
|
||||
|
||||
interface DOMAttributes<Target extends EventTarget>
|
||||
extends preact.PreactDOMAttributes {
|
||||
// Image Events
|
||||
onLoad?: GenericEventHandler<Target>;
|
||||
onLoadCapture?: GenericEventHandler<Target>;
|
||||
onError?: GenericEventHandler<Target>;
|
||||
onErrorCapture?: GenericEventHandler<Target>;
|
||||
|
||||
// Clipboard Events
|
||||
onCopy?: ClipboardEventHandler<Target>;
|
||||
onCopyCapture?: ClipboardEventHandler<Target>;
|
||||
onCut?: ClipboardEventHandler<Target>;
|
||||
onCutCapture?: ClipboardEventHandler<Target>;
|
||||
onPaste?: ClipboardEventHandler<Target>;
|
||||
onPasteCapture?: ClipboardEventHandler<Target>;
|
||||
|
||||
// Composition Events
|
||||
onCompositionEnd?: CompositionEventHandler<Target>;
|
||||
onCompositionEndCapture?: CompositionEventHandler<Target>;
|
||||
onCompositionStart?: CompositionEventHandler<Target>;
|
||||
onCompositionStartCapture?: CompositionEventHandler<Target>;
|
||||
onCompositionUpdate?: CompositionEventHandler<Target>;
|
||||
onCompositionUpdateCapture?: CompositionEventHandler<Target>;
|
||||
|
||||
// Details Events
|
||||
onToggle?: GenericEventHandler<Target>;
|
||||
|
||||
// Focus Events
|
||||
onFocus?: FocusEventHandler<Target>;
|
||||
onFocusCapture?: FocusEventHandler<Target>;
|
||||
onBlur?: FocusEventHandler<Target>;
|
||||
onBlurCapture?: FocusEventHandler<Target>;
|
||||
|
||||
// Form Events
|
||||
onChange?: GenericEventHandler<Target>;
|
||||
onChangeCapture?: GenericEventHandler<Target>;
|
||||
onInput?: GenericEventHandler<Target>;
|
||||
onInputCapture?: GenericEventHandler<Target>;
|
||||
onSearch?: GenericEventHandler<Target>;
|
||||
onSearchCapture?: GenericEventHandler<Target>;
|
||||
onSubmit?: GenericEventHandler<Target>;
|
||||
onSubmitCapture?: GenericEventHandler<Target>;
|
||||
onInvalid?: GenericEventHandler<Target>;
|
||||
onInvalidCapture?: GenericEventHandler<Target>;
|
||||
onReset?: GenericEventHandler<Target>;
|
||||
onResetCapture?: GenericEventHandler<Target>;
|
||||
onFormData?: GenericEventHandler<Target>;
|
||||
onFormDataCapture?: GenericEventHandler<Target>;
|
||||
|
||||
// Keyboard Events
|
||||
onKeyDown?: KeyboardEventHandler<Target>;
|
||||
onKeyDownCapture?: KeyboardEventHandler<Target>;
|
||||
onKeyPress?: KeyboardEventHandler<Target>;
|
||||
onKeyPressCapture?: KeyboardEventHandler<Target>;
|
||||
onKeyUp?: KeyboardEventHandler<Target>;
|
||||
onKeyUpCapture?: KeyboardEventHandler<Target>;
|
||||
|
||||
// Media Events
|
||||
onAbort?: GenericEventHandler<Target>;
|
||||
onAbortCapture?: GenericEventHandler<Target>;
|
||||
onCanPlay?: GenericEventHandler<Target>;
|
||||
onCanPlayCapture?: GenericEventHandler<Target>;
|
||||
onCanPlayThrough?: GenericEventHandler<Target>;
|
||||
onCanPlayThroughCapture?: GenericEventHandler<Target>;
|
||||
onDurationChange?: GenericEventHandler<Target>;
|
||||
onDurationChangeCapture?: GenericEventHandler<Target>;
|
||||
onEmptied?: GenericEventHandler<Target>;
|
||||
onEmptiedCapture?: GenericEventHandler<Target>;
|
||||
onEncrypted?: GenericEventHandler<Target>;
|
||||
onEncryptedCapture?: GenericEventHandler<Target>;
|
||||
onEnded?: GenericEventHandler<Target>;
|
||||
onEndedCapture?: GenericEventHandler<Target>;
|
||||
onLoadedData?: GenericEventHandler<Target>;
|
||||
onLoadedDataCapture?: GenericEventHandler<Target>;
|
||||
onLoadedMetadata?: GenericEventHandler<Target>;
|
||||
onLoadedMetadataCapture?: GenericEventHandler<Target>;
|
||||
onLoadStart?: GenericEventHandler<Target>;
|
||||
onLoadStartCapture?: GenericEventHandler<Target>;
|
||||
onPause?: GenericEventHandler<Target>;
|
||||
onPauseCapture?: GenericEventHandler<Target>;
|
||||
onPlay?: GenericEventHandler<Target>;
|
||||
onPlayCapture?: GenericEventHandler<Target>;
|
||||
onPlaying?: GenericEventHandler<Target>;
|
||||
onPlayingCapture?: GenericEventHandler<Target>;
|
||||
onProgress?: GenericEventHandler<Target>;
|
||||
onProgressCapture?: GenericEventHandler<Target>;
|
||||
onRateChange?: GenericEventHandler<Target>;
|
||||
onRateChangeCapture?: GenericEventHandler<Target>;
|
||||
onSeeked?: GenericEventHandler<Target>;
|
||||
onSeekedCapture?: GenericEventHandler<Target>;
|
||||
onSeeking?: GenericEventHandler<Target>;
|
||||
onSeekingCapture?: GenericEventHandler<Target>;
|
||||
onStalled?: GenericEventHandler<Target>;
|
||||
onStalledCapture?: GenericEventHandler<Target>;
|
||||
onSuspend?: GenericEventHandler<Target>;
|
||||
onSuspendCapture?: GenericEventHandler<Target>;
|
||||
onTimeUpdate?: GenericEventHandler<Target>;
|
||||
onTimeUpdateCapture?: GenericEventHandler<Target>;
|
||||
onVolumeChange?: GenericEventHandler<Target>;
|
||||
onVolumeChangeCapture?: GenericEventHandler<Target>;
|
||||
onWaiting?: GenericEventHandler<Target>;
|
||||
onWaitingCapture?: GenericEventHandler<Target>;
|
||||
|
||||
// MouseEvents
|
||||
onClick?: MouseEventHandler<Target>;
|
||||
onClickCapture?: MouseEventHandler<Target>;
|
||||
onContextMenu?: MouseEventHandler<Target>;
|
||||
onContextMenuCapture?: MouseEventHandler<Target>;
|
||||
onDblClick?: MouseEventHandler<Target>;
|
||||
onDblClickCapture?: MouseEventHandler<Target>;
|
||||
onDrag?: DragEventHandler<Target>;
|
||||
onDragCapture?: DragEventHandler<Target>;
|
||||
onDragEnd?: DragEventHandler<Target>;
|
||||
onDragEndCapture?: DragEventHandler<Target>;
|
||||
onDragEnter?: DragEventHandler<Target>;
|
||||
onDragEnterCapture?: DragEventHandler<Target>;
|
||||
onDragExit?: DragEventHandler<Target>;
|
||||
onDragExitCapture?: DragEventHandler<Target>;
|
||||
onDragLeave?: DragEventHandler<Target>;
|
||||
onDragLeaveCapture?: DragEventHandler<Target>;
|
||||
onDragOver?: DragEventHandler<Target>;
|
||||
onDragOverCapture?: DragEventHandler<Target>;
|
||||
onDragStart?: DragEventHandler<Target>;
|
||||
onDragStartCapture?: DragEventHandler<Target>;
|
||||
onDrop?: DragEventHandler<Target>;
|
||||
onDropCapture?: DragEventHandler<Target>;
|
||||
onMouseDown?: MouseEventHandler<Target>;
|
||||
onMouseDownCapture?: MouseEventHandler<Target>;
|
||||
onMouseEnter?: MouseEventHandler<Target>;
|
||||
onMouseEnterCapture?: MouseEventHandler<Target>;
|
||||
onMouseLeave?: MouseEventHandler<Target>;
|
||||
onMouseLeaveCapture?: MouseEventHandler<Target>;
|
||||
onMouseMove?: MouseEventHandler<Target>;
|
||||
onMouseMoveCapture?: MouseEventHandler<Target>;
|
||||
onMouseOut?: MouseEventHandler<Target>;
|
||||
onMouseOutCapture?: MouseEventHandler<Target>;
|
||||
onMouseOver?: MouseEventHandler<Target>;
|
||||
onMouseOverCapture?: MouseEventHandler<Target>;
|
||||
onMouseUp?: MouseEventHandler<Target>;
|
||||
onMouseUpCapture?: MouseEventHandler<Target>;
|
||||
|
||||
// Selection Events
|
||||
onSelect?: GenericEventHandler<Target>;
|
||||
onSelectCapture?: GenericEventHandler<Target>;
|
||||
|
||||
// Touch Events
|
||||
onTouchCancel?: TouchEventHandler<Target>;
|
||||
onTouchCancelCapture?: TouchEventHandler<Target>;
|
||||
onTouchEnd?: TouchEventHandler<Target>;
|
||||
onTouchEndCapture?: TouchEventHandler<Target>;
|
||||
onTouchMove?: TouchEventHandler<Target>;
|
||||
onTouchMoveCapture?: TouchEventHandler<Target>;
|
||||
onTouchStart?: TouchEventHandler<Target>;
|
||||
onTouchStartCapture?: TouchEventHandler<Target>;
|
||||
|
||||
// Pointer Events
|
||||
onPointerOver?: PointerEventHandler<Target>;
|
||||
onPointerOverCapture?: PointerEventHandler<Target>;
|
||||
onPointerEnter?: PointerEventHandler<Target>;
|
||||
onPointerEnterCapture?: PointerEventHandler<Target>;
|
||||
onPointerDown?: PointerEventHandler<Target>;
|
||||
onPointerDownCapture?: PointerEventHandler<Target>;
|
||||
onPointerMove?: PointerEventHandler<Target>;
|
||||
onPointerMoveCapture?: PointerEventHandler<Target>;
|
||||
onPointerUp?: PointerEventHandler<Target>;
|
||||
onPointerUpCapture?: PointerEventHandler<Target>;
|
||||
onPointerCancel?: PointerEventHandler<Target>;
|
||||
onPointerCancelCapture?: PointerEventHandler<Target>;
|
||||
onPointerOut?: PointerEventHandler<Target>;
|
||||
onPointerOutCapture?: PointerEventHandler<Target>;
|
||||
onPointerLeave?: PointerEventHandler<Target>;
|
||||
onPointerLeaveCapture?: PointerEventHandler<Target>;
|
||||
onGotPointerCapture?: PointerEventHandler<Target>;
|
||||
onGotPointerCaptureCapture?: PointerEventHandler<Target>;
|
||||
onLostPointerCapture?: PointerEventHandler<Target>;
|
||||
onLostPointerCaptureCapture?: PointerEventHandler<Target>;
|
||||
|
||||
// UI Events
|
||||
onScroll?: UIEventHandler<Target>;
|
||||
onScrollCapture?: UIEventHandler<Target>;
|
||||
|
||||
// Wheel Events
|
||||
onWheel?: WheelEventHandler<Target>;
|
||||
onWheelCapture?: WheelEventHandler<Target>;
|
||||
|
||||
// Animation Events
|
||||
onAnimationStart?: AnimationEventHandler<Target>;
|
||||
onAnimationStartCapture?: AnimationEventHandler<Target>;
|
||||
onAnimationEnd?: AnimationEventHandler<Target>;
|
||||
onAnimationEndCapture?: AnimationEventHandler<Target>;
|
||||
onAnimationIteration?: AnimationEventHandler<Target>;
|
||||
onAnimationIterationCapture?: AnimationEventHandler<Target>;
|
||||
|
||||
// Transition Events
|
||||
onTransitionEnd?: TransitionEventHandler<Target>;
|
||||
onTransitionEndCapture?: TransitionEventHandler<Target>;
|
||||
}
|
||||
|
||||
interface HTMLAttributes<RefType extends EventTarget = EventTarget>
|
||||
extends preact.ClassAttributes<RefType>,
|
||||
DOMAttributes<RefType> {
|
||||
// Standard HTML Attributes
|
||||
accept?: string;
|
||||
acceptCharset?: string;
|
||||
accessKey?: string;
|
||||
action?: string;
|
||||
allowFullScreen?: boolean;
|
||||
allowTransparency?: boolean;
|
||||
alt?: string;
|
||||
as?: string;
|
||||
async?: boolean;
|
||||
autocomplete?: string;
|
||||
autoComplete?: string;
|
||||
autocorrect?: string;
|
||||
autoCorrect?: string;
|
||||
autofocus?: boolean;
|
||||
autoFocus?: boolean;
|
||||
autoPlay?: boolean;
|
||||
capture?: boolean | string;
|
||||
cellPadding?: number | string;
|
||||
cellSpacing?: number | string;
|
||||
charSet?: string;
|
||||
challenge?: string;
|
||||
checked?: boolean;
|
||||
class?: string;
|
||||
className?: string;
|
||||
cols?: number;
|
||||
colSpan?: number;
|
||||
content?: string;
|
||||
contentEditable?: boolean;
|
||||
contextMenu?: string;
|
||||
controls?: boolean;
|
||||
controlsList?: string;
|
||||
coords?: string;
|
||||
crossOrigin?: string;
|
||||
data?: string;
|
||||
dateTime?: string;
|
||||
default?: boolean;
|
||||
defer?: boolean;
|
||||
dir?: 'auto' | 'rtl' | 'ltr';
|
||||
disabled?: boolean;
|
||||
disableRemotePlayback?: boolean;
|
||||
download?: any;
|
||||
draggable?: boolean;
|
||||
encType?: string;
|
||||
form?: string;
|
||||
formAction?: string;
|
||||
formEncType?: string;
|
||||
formMethod?: string;
|
||||
formNoValidate?: boolean;
|
||||
formTarget?: string;
|
||||
frameBorder?: number | string;
|
||||
headers?: string;
|
||||
height?: number | string;
|
||||
hidden?: boolean;
|
||||
high?: number;
|
||||
href?: string;
|
||||
hrefLang?: string;
|
||||
for?: string;
|
||||
htmlFor?: string;
|
||||
httpEquiv?: string;
|
||||
icon?: string;
|
||||
id?: string;
|
||||
inputMode?: string;
|
||||
integrity?: string;
|
||||
is?: string;
|
||||
keyParams?: string;
|
||||
keyType?: string;
|
||||
kind?: string;
|
||||
label?: string;
|
||||
lang?: string;
|
||||
list?: string;
|
||||
loading?: 'eager' | 'lazy';
|
||||
loop?: boolean;
|
||||
low?: number;
|
||||
manifest?: string;
|
||||
marginHeight?: number;
|
||||
marginWidth?: number;
|
||||
max?: number | string;
|
||||
maxLength?: number;
|
||||
media?: string;
|
||||
mediaGroup?: string;
|
||||
method?: string;
|
||||
min?: number | string;
|
||||
minLength?: number;
|
||||
multiple?: boolean;
|
||||
muted?: boolean;
|
||||
name?: string;
|
||||
nonce?: string;
|
||||
noValidate?: boolean;
|
||||
open?: boolean;
|
||||
optimum?: number;
|
||||
pattern?: string;
|
||||
placeholder?: string;
|
||||
playsInline?: boolean;
|
||||
poster?: string;
|
||||
preload?: string;
|
||||
radioGroup?: string;
|
||||
readOnly?: boolean;
|
||||
rel?: string;
|
||||
required?: boolean;
|
||||
role?: string;
|
||||
rows?: number;
|
||||
rowSpan?: number;
|
||||
sandbox?: string;
|
||||
scope?: string;
|
||||
scoped?: boolean;
|
||||
scrolling?: string;
|
||||
seamless?: boolean;
|
||||
selected?: boolean;
|
||||
shape?: string;
|
||||
size?: number;
|
||||
sizes?: string;
|
||||
slot?: string;
|
||||
span?: number;
|
||||
spellcheck?: boolean;
|
||||
src?: string;
|
||||
srcset?: string;
|
||||
srcDoc?: string;
|
||||
srcLang?: string;
|
||||
srcSet?: string;
|
||||
start?: number;
|
||||
step?: number | string;
|
||||
style?: string | { [key: string]: string | number };
|
||||
summary?: string;
|
||||
tabIndex?: number;
|
||||
target?: string;
|
||||
title?: string;
|
||||
type?: string;
|
||||
useMap?: string;
|
||||
value?: string | string[] | number;
|
||||
volume?: string | number;
|
||||
width?: number | string;
|
||||
wmode?: string;
|
||||
wrap?: string;
|
||||
|
||||
// RDFa Attributes
|
||||
about?: string;
|
||||
datatype?: string;
|
||||
inlist?: any;
|
||||
prefix?: string;
|
||||
property?: string;
|
||||
resource?: string;
|
||||
typeof?: string;
|
||||
vocab?: string;
|
||||
|
||||
// Microdata Attributes
|
||||
itemProp?: string;
|
||||
itemScope?: boolean;
|
||||
itemType?: string;
|
||||
itemID?: string;
|
||||
itemRef?: string;
|
||||
}
|
||||
|
||||
interface HTMLMarqueeElement extends HTMLElement {
|
||||
behavior?: 'scroll' | 'slide' | 'alternate';
|
||||
bgColor?: string;
|
||||
direction?: 'left' | 'right' | 'up' | 'down';
|
||||
height?: number | string;
|
||||
hspace?: number | string;
|
||||
loop?: number | string;
|
||||
scrollAmount?: number | string;
|
||||
scrollDelay?: number | string;
|
||||
trueSpeed?: boolean;
|
||||
vspace?: number | string;
|
||||
width?: number | string;
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
// HTML
|
||||
a: HTMLAttributes<HTMLAnchorElement>;
|
||||
abbr: HTMLAttributes<HTMLElement>;
|
||||
address: HTMLAttributes<HTMLElement>;
|
||||
area: HTMLAttributes<HTMLAreaElement>;
|
||||
article: HTMLAttributes<HTMLElement>;
|
||||
aside: HTMLAttributes<HTMLElement>;
|
||||
audio: HTMLAttributes<HTMLAudioElement>;
|
||||
b: HTMLAttributes<HTMLElement>;
|
||||
base: HTMLAttributes<HTMLBaseElement>;
|
||||
bdi: HTMLAttributes<HTMLElement>;
|
||||
bdo: HTMLAttributes<HTMLElement>;
|
||||
big: HTMLAttributes<HTMLElement>;
|
||||
blockquote: HTMLAttributes<HTMLQuoteElement>;
|
||||
body: HTMLAttributes<HTMLBodyElement>;
|
||||
br: HTMLAttributes<HTMLBRElement>;
|
||||
button: HTMLAttributes<HTMLButtonElement>;
|
||||
canvas: HTMLAttributes<HTMLCanvasElement>;
|
||||
caption: HTMLAttributes<HTMLTableCaptionElement>;
|
||||
cite: HTMLAttributes<HTMLElement>;
|
||||
code: HTMLAttributes<HTMLElement>;
|
||||
col: HTMLAttributes<HTMLTableColElement>;
|
||||
colgroup: HTMLAttributes<HTMLTableColElement>;
|
||||
data: HTMLAttributes<HTMLDataElement>;
|
||||
datalist: HTMLAttributes<HTMLDataListElement>;
|
||||
dd: HTMLAttributes<HTMLElement>;
|
||||
del: HTMLAttributes<HTMLModElement>;
|
||||
details: HTMLAttributes<HTMLDetailsElement>;
|
||||
dfn: HTMLAttributes<HTMLElement>;
|
||||
dialog: HTMLAttributes<HTMLDialogElement>;
|
||||
div: HTMLAttributes<HTMLDivElement>;
|
||||
dl: HTMLAttributes<HTMLDListElement>;
|
||||
dt: HTMLAttributes<HTMLElement>;
|
||||
em: HTMLAttributes<HTMLElement>;
|
||||
embed: HTMLAttributes<HTMLEmbedElement>;
|
||||
fieldset: HTMLAttributes<HTMLFieldSetElement>;
|
||||
figcaption: HTMLAttributes<HTMLElement>;
|
||||
figure: HTMLAttributes<HTMLElement>;
|
||||
footer: HTMLAttributes<HTMLElement>;
|
||||
form: HTMLAttributes<HTMLFormElement>;
|
||||
h1: HTMLAttributes<HTMLHeadingElement>;
|
||||
h2: HTMLAttributes<HTMLHeadingElement>;
|
||||
h3: HTMLAttributes<HTMLHeadingElement>;
|
||||
h4: HTMLAttributes<HTMLHeadingElement>;
|
||||
h5: HTMLAttributes<HTMLHeadingElement>;
|
||||
h6: HTMLAttributes<HTMLHeadingElement>;
|
||||
head: HTMLAttributes<HTMLHeadElement>;
|
||||
header: HTMLAttributes<HTMLElement>;
|
||||
hgroup: HTMLAttributes<HTMLElement>;
|
||||
hr: HTMLAttributes<HTMLHRElement>;
|
||||
html: HTMLAttributes<HTMLHtmlElement>;
|
||||
i: HTMLAttributes<HTMLElement>;
|
||||
iframe: HTMLAttributes<HTMLIFrameElement>;
|
||||
img: HTMLAttributes<HTMLImageElement>;
|
||||
input: HTMLAttributes<HTMLInputElement>;
|
||||
ins: HTMLAttributes<HTMLModElement>;
|
||||
kbd: HTMLAttributes<HTMLElement>;
|
||||
keygen: HTMLAttributes<HTMLUnknownElement>;
|
||||
label: HTMLAttributes<HTMLLabelElement>;
|
||||
legend: HTMLAttributes<HTMLLegendElement>;
|
||||
li: HTMLAttributes<HTMLLIElement>;
|
||||
link: HTMLAttributes<HTMLLinkElement>;
|
||||
main: HTMLAttributes<HTMLElement>;
|
||||
map: HTMLAttributes<HTMLMapElement>;
|
||||
mark: HTMLAttributes<HTMLElement>;
|
||||
marquee: HTMLAttributes<HTMLMarqueeElement>;
|
||||
menu: HTMLAttributes<HTMLMenuElement>;
|
||||
menuitem: HTMLAttributes<HTMLUnknownElement>;
|
||||
meta: HTMLAttributes<HTMLMetaElement>;
|
||||
meter: HTMLAttributes<HTMLMeterElement>;
|
||||
nav: HTMLAttributes<HTMLElement>;
|
||||
noscript: HTMLAttributes<HTMLElement>;
|
||||
object: HTMLAttributes<HTMLObjectElement>;
|
||||
ol: HTMLAttributes<HTMLOListElement>;
|
||||
optgroup: HTMLAttributes<HTMLOptGroupElement>;
|
||||
option: HTMLAttributes<HTMLOptionElement>;
|
||||
output: HTMLAttributes<HTMLOutputElement>;
|
||||
p: HTMLAttributes<HTMLParagraphElement>;
|
||||
param: HTMLAttributes<HTMLParamElement>;
|
||||
picture: HTMLAttributes<HTMLPictureElement>;
|
||||
pre: HTMLAttributes<HTMLPreElement>;
|
||||
progress: HTMLAttributes<HTMLProgressElement>;
|
||||
q: HTMLAttributes<HTMLQuoteElement>;
|
||||
rp: HTMLAttributes<HTMLElement>;
|
||||
rt: HTMLAttributes<HTMLElement>;
|
||||
ruby: HTMLAttributes<HTMLElement>;
|
||||
s: HTMLAttributes<HTMLElement>;
|
||||
samp: HTMLAttributes<HTMLElement>;
|
||||
script: HTMLAttributes<HTMLScriptElement>;
|
||||
section: HTMLAttributes<HTMLElement>;
|
||||
select: HTMLAttributes<HTMLSelectElement>;
|
||||
slot: HTMLAttributes<HTMLSlotElement>;
|
||||
small: HTMLAttributes<HTMLElement>;
|
||||
source: HTMLAttributes<HTMLSourceElement>;
|
||||
span: HTMLAttributes<HTMLSpanElement>;
|
||||
strong: HTMLAttributes<HTMLElement>;
|
||||
style: HTMLAttributes<HTMLStyleElement>;
|
||||
sub: HTMLAttributes<HTMLElement>;
|
||||
summary: HTMLAttributes<HTMLElement>;
|
||||
sup: HTMLAttributes<HTMLElement>;
|
||||
table: HTMLAttributes<HTMLTableElement>;
|
||||
tbody: HTMLAttributes<HTMLTableSectionElement>;
|
||||
td: HTMLAttributes<HTMLTableCellElement>;
|
||||
textarea: HTMLAttributes<HTMLTextAreaElement>;
|
||||
tfoot: HTMLAttributes<HTMLTableSectionElement>;
|
||||
th: HTMLAttributes<HTMLTableCellElement>;
|
||||
thead: HTMLAttributes<HTMLTableSectionElement>;
|
||||
time: HTMLAttributes<HTMLTimeElement>;
|
||||
title: HTMLAttributes<HTMLTitleElement>;
|
||||
tr: HTMLAttributes<HTMLTableRowElement>;
|
||||
track: HTMLAttributes<HTMLTrackElement>;
|
||||
u: HTMLAttributes<HTMLElement>;
|
||||
ul: HTMLAttributes<HTMLUListElement>;
|
||||
var: HTMLAttributes<HTMLElement>;
|
||||
video: HTMLAttributes<HTMLVideoElement>;
|
||||
wbr: HTMLAttributes<HTMLElement>;
|
||||
|
||||
//SVG
|
||||
svg: SVGAttributes<SVGSVGElement>;
|
||||
animate: SVGAttributes<SVGAnimateElement>;
|
||||
circle: SVGAttributes<SVGCircleElement>;
|
||||
clipPath: SVGAttributes<SVGClipPathElement>;
|
||||
defs: SVGAttributes<SVGDefsElement>;
|
||||
desc: SVGAttributes<SVGDescElement>;
|
||||
ellipse: SVGAttributes<SVGEllipseElement>;
|
||||
feBlend: SVGAttributes<SVGFEBlendElement>;
|
||||
feColorMatrix: SVGAttributes<SVGFEColorMatrixElement>;
|
||||
feComponentTransfer: SVGAttributes<SVGFEComponentTransferElement>;
|
||||
feComposite: SVGAttributes<SVGFECompositeElement>;
|
||||
feConvolveMatrix: SVGAttributes<SVGFEConvolveMatrixElement>;
|
||||
feDiffuseLighting: SVGAttributes<SVGFEDiffuseLightingElement>;
|
||||
feDisplacementMap: SVGAttributes<SVGFEDisplacementMapElement>;
|
||||
feDropShadow: SVGAttributes<SVGFEDropShadowElement>;
|
||||
feFlood: SVGAttributes<SVGFEFloodElement>;
|
||||
feGaussianBlur: SVGAttributes<SVGFEGaussianBlurElement>;
|
||||
feImage: SVGAttributes<SVGFEImageElement>;
|
||||
feMerge: SVGAttributes<SVGFEMergeElement>;
|
||||
feMergeNode: SVGAttributes<SVGFEMergeNodeElement>;
|
||||
feMorphology: SVGAttributes<SVGFEMorphologyElement>;
|
||||
feOffset: SVGAttributes<SVGFEOffsetElement>;
|
||||
feSpecularLighting: SVGAttributes<SVGFESpecularLightingElement>;
|
||||
feTile: SVGAttributes<SVGFETileElement>;
|
||||
feTurbulence: SVGAttributes<SVGFETurbulenceElement>;
|
||||
filter: SVGAttributes<SVGFilterElement>;
|
||||
foreignObject: SVGAttributes<SVGForeignObjectElement>;
|
||||
g: SVGAttributes<SVGGElement>;
|
||||
image: SVGAttributes<SVGImageElement>;
|
||||
line: SVGAttributes<SVGLineElement>;
|
||||
linearGradient: SVGAttributes<SVGLinearGradientElement>;
|
||||
marker: SVGAttributes<SVGMarkerElement>;
|
||||
mask: SVGAttributes<SVGMaskElement>;
|
||||
path: SVGAttributes<SVGPathElement>;
|
||||
pattern: SVGAttributes<SVGPatternElement>;
|
||||
polygon: SVGAttributes<SVGPolygonElement>;
|
||||
polyline: SVGAttributes<SVGPolylineElement>;
|
||||
radialGradient: SVGAttributes<SVGRadialGradientElement>;
|
||||
rect: SVGAttributes<SVGRectElement>;
|
||||
stop: SVGAttributes<SVGStopElement>;
|
||||
symbol: SVGAttributes<SVGSymbolElement>;
|
||||
text: SVGAttributes<SVGTextElement>;
|
||||
tspan: SVGAttributes<SVGTSpanElement>;
|
||||
use: SVGAttributes<SVGUseElement>;
|
||||
}
|
||||
}
|
||||
16
build/javascript/node_modules/preact/src/options.js
generated
vendored
Normal file
16
build/javascript/node_modules/preact/src/options.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { _catchError } from './diff/catch-error';
|
||||
|
||||
/**
|
||||
* The `option` object can potentially contain callback functions
|
||||
* that are called during various stages of our renderer. This is the
|
||||
* foundation on which all our addons like `preact/debug`, `preact/compat`,
|
||||
* and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`
|
||||
* for a full list of available option hooks (most editors/IDEs allow you to
|
||||
* ctrl+click or cmd+click on mac the type definition below).
|
||||
* @type {import('./internal').Options}
|
||||
*/
|
||||
const options = {
|
||||
_catchError
|
||||
};
|
||||
|
||||
export default options;
|
||||
68
build/javascript/node_modules/preact/src/render.js
generated
vendored
Normal file
68
build/javascript/node_modules/preact/src/render.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { EMPTY_OBJ, EMPTY_ARR } from './constants';
|
||||
import { commitRoot, diff } from './diff/index';
|
||||
import { createElement, Fragment } from './create-element';
|
||||
import options from './options';
|
||||
|
||||
const IS_HYDRATE = EMPTY_OBJ;
|
||||
|
||||
/**
|
||||
* Render a Preact virtual node into a DOM element
|
||||
* @param {import('./index').ComponentChild} vnode The virtual node to render
|
||||
* @param {import('./internal').PreactElement} parentDom The DOM element to
|
||||
* render into
|
||||
* @param {Element | Text} [replaceNode] Optional: Attempt to re-use an
|
||||
* existing DOM tree rooted at `replaceNode`
|
||||
*/
|
||||
export function render(vnode, parentDom, replaceNode) {
|
||||
if (options._root) options._root(vnode, parentDom);
|
||||
|
||||
// We abuse the `replaceNode` parameter in `hydrate()` to signal if we
|
||||
// are in hydration mode or not by passing `IS_HYDRATE` instead of a
|
||||
// DOM element.
|
||||
let isHydrating = replaceNode === IS_HYDRATE;
|
||||
|
||||
// To be able to support calling `render()` multiple times on the same
|
||||
// DOM node, we need to obtain a reference to the previous tree. We do
|
||||
// this by assigning a new `_children` property to DOM nodes which points
|
||||
// to the last rendered tree. By default this property is not present, which
|
||||
// means that we are mounting a new tree for the first time.
|
||||
let oldVNode = isHydrating
|
||||
? null
|
||||
: (replaceNode && replaceNode._children) || parentDom._children;
|
||||
vnode = createElement(Fragment, null, [vnode]);
|
||||
|
||||
// List of effects that need to be called after diffing.
|
||||
let commitQueue = [];
|
||||
diff(
|
||||
parentDom,
|
||||
// Determine the new vnode tree and store it on the DOM element on
|
||||
// our custom `_children` property.
|
||||
((isHydrating ? parentDom : replaceNode || parentDom)._children = vnode),
|
||||
oldVNode || EMPTY_OBJ,
|
||||
EMPTY_OBJ,
|
||||
parentDom.ownerSVGElement !== undefined,
|
||||
replaceNode && !isHydrating
|
||||
? [replaceNode]
|
||||
: oldVNode
|
||||
? null
|
||||
: parentDom.childNodes.length
|
||||
? EMPTY_ARR.slice.call(parentDom.childNodes)
|
||||
: null,
|
||||
commitQueue,
|
||||
replaceNode || EMPTY_OBJ,
|
||||
isHydrating
|
||||
);
|
||||
|
||||
// Flush all queued effects
|
||||
commitRoot(commitQueue, vnode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing DOM element with data from a Preact virtual node
|
||||
* @param {import('./index').ComponentChild} vnode The virtual node to render
|
||||
* @param {import('./internal').PreactElement} parentDom The DOM element to
|
||||
* update
|
||||
*/
|
||||
export function hydrate(vnode, parentDom) {
|
||||
render(vnode, parentDom, IS_HYDRATE);
|
||||
}
|
||||
22
build/javascript/node_modules/preact/src/util.js
generated
vendored
Normal file
22
build/javascript/node_modules/preact/src/util.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a child node from its parent if attached. This is a workaround for
|
||||
* IE11 which doesn't support `Element.prototype.remove()`. Using this function
|
||||
* is smaller than including a dedicated polyfill.
|
||||
* @param {Node} node The node to remove
|
||||
*/
|
||||
export function removeNode(node) {
|
||||
let parentNode = node.parentNode;
|
||||
if (parentNode) parentNode.removeChild(node);
|
||||
}
|
||||
19
build/javascript/node_modules/preact/test-utils/package.json
generated
vendored
Normal file
19
build/javascript/node_modules/preact/test-utils/package.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "test-utils",
|
||||
"amdName": "preactTestUtils",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Test-utils for Preact",
|
||||
"main": "dist/testUtils.js",
|
||||
"module": "dist/testUtils.module.js",
|
||||
"umd:main": "dist/testUtils.umd.js",
|
||||
"source": "src/index.js",
|
||||
"license": "MIT",
|
||||
"types": "src/index.d.ts",
|
||||
"peerDependencies": {
|
||||
"preact": "^10.0.0"
|
||||
},
|
||||
"mangle": {
|
||||
"regex": "^_"
|
||||
}
|
||||
}
|
||||
3
build/javascript/node_modules/preact/test-utils/src/index.d.ts
generated
vendored
Normal file
3
build/javascript/node_modules/preact/test-utils/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function setupRerender(): () => void;
|
||||
export function act(callback: () => void | Promise<void>): Promise<void>;
|
||||
export function teardown(): void;
|
||||
117
build/javascript/node_modules/preact/test-utils/src/index.js
generated
vendored
Normal file
117
build/javascript/node_modules/preact/test-utils/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import { options } from 'preact';
|
||||
|
||||
/**
|
||||
* Setup a rerender function that will drain the queue of pending renders
|
||||
* @returns {() => void}
|
||||
*/
|
||||
export function setupRerender() {
|
||||
options.__test__previousDebounce = options.debounceRendering;
|
||||
options.debounceRendering = cb => (options.__test__drainQueue = cb);
|
||||
return () => options.__test__drainQueue && options.__test__drainQueue();
|
||||
}
|
||||
|
||||
const isThenable = value => value != null && typeof value.then == 'function';
|
||||
|
||||
/** Depth of nested calls to `act`. */
|
||||
let actDepth = 0;
|
||||
|
||||
/**
|
||||
* Run a test function, and flush all effects and rerenders after invoking it.
|
||||
*
|
||||
* Returns a Promise which resolves "immediately" if the callback is
|
||||
* synchronous or when the callback's result resolves if it is asynchronous.
|
||||
*
|
||||
* @param {() => void|Promise<void>} cb The function under test. This may be sync or async.
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
export function act(cb) {
|
||||
if (++actDepth > 1) {
|
||||
// If calls to `act` are nested, a flush happens only when the
|
||||
// outermost call returns. In the inner call, we just execute the
|
||||
// callback and return since the infrastructure for flushing has already
|
||||
// been set up.
|
||||
//
|
||||
// If an exception occurs, the outermost `act` will handle cleanup.
|
||||
const result = cb();
|
||||
if (isThenable(result)) {
|
||||
return result.then(() => {
|
||||
--actDepth;
|
||||
});
|
||||
}
|
||||
--actDepth;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const previousRequestAnimationFrame = options.requestAnimationFrame;
|
||||
const rerender = setupRerender();
|
||||
|
||||
/** @type {() => void} */
|
||||
let flush, toFlush;
|
||||
|
||||
// Override requestAnimationFrame so we can flush pending hooks.
|
||||
options.requestAnimationFrame = fc => (flush = fc);
|
||||
|
||||
const finish = () => {
|
||||
try {
|
||||
rerender();
|
||||
while (flush) {
|
||||
toFlush = flush;
|
||||
flush = null;
|
||||
|
||||
toFlush();
|
||||
rerender();
|
||||
}
|
||||
teardown();
|
||||
} catch (e) {
|
||||
if (!err) {
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
|
||||
options.requestAnimationFrame = previousRequestAnimationFrame;
|
||||
--actDepth;
|
||||
};
|
||||
|
||||
let err;
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = cb();
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
|
||||
if (isThenable(result)) {
|
||||
return result.then(finish, err => {
|
||||
finish();
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
// nb. If the callback is synchronous, effects must be flushed before
|
||||
// `act` returns, so that the caller does not have to await the result,
|
||||
// even though React recommends this.
|
||||
finish();
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Teardown test environment and reset preact's internal state
|
||||
*/
|
||||
export function teardown() {
|
||||
if (options.__test__drainQueue) {
|
||||
// Flush any pending updates leftover by test
|
||||
options.__test__drainQueue();
|
||||
delete options.__test__drainQueue;
|
||||
}
|
||||
|
||||
if (typeof options.__test__previousDebounce != 'undefined') {
|
||||
options.debounceRendering = options.__test__previousDebounce;
|
||||
delete options.__test__previousDebounce;
|
||||
} else {
|
||||
options.debounceRendering = undefined;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user