Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

21
static/js/ketcher2/node_modules/preact/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 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.

493
static/js/ketcher2/node_modules/preact/README.md generated vendored Normal file
View File

@ -0,0 +1,493 @@
<p align="center">
<a href="https://preactjs.com" target="_blank">
<img alt="Preact" title="Preact" src="https://cdn.rawgit.com/developit/b4416d5c92b743dbaec1e68bc4c27cda/raw/3235dc508f7eb834ebf48418aea212a05df13db1/preact-logo-trans.svg" width="550">
</a>
</p>
<p align="center">Fast <b>3kB</b> alternative to React, with the same ES2015 API.</p>
**All the power of Virtual DOM components, without the overhead:**
- Familiar React API & patterns: [ES6 Class] and [Functional Components]
- Extensive React compatibility via a simple [preact-compat] alias
- Everything you need: JSX, <abbr title="Virtual DOM">VDOM</abbr>, React DevTools, <abbr title="Hot Module Replacement">HMR</abbr>, <abbr title="Server-Side Rendering">SSR</abbr>..
- A highly optimized diff algorithm and seamless Server Side Rendering
- Transparent asynchronous rendering with a pluggable scheduler
### 💁 More information at the [Preact Website ➞](https://preactjs.com)
---
<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
- [Demos](#demos)
- [Libraries & Add-ons](#libraries--add-ons)
- [Getting Started](#getting-started)
- [Import what you need](#import-what-you-need)
- [Rendering JSX](#rendering-jsx)
- [Components](#components)
- [Props & State](#props--state)
- [Linked State](#linked-state)
- [Examples](#examples)
- [Extensions](#extensions)
- [Developer Tools](#developer-tools)
- [Backers](#backers)
- [Sponsors](#sponsors)
- [License](#license)
<!-- /TOC -->
# Preact
[![npm](https://img.shields.io/npm/v/preact.svg)](http://npm.im/preact)
[![CDNJS](https://img.shields.io/cdnjs/v/preact.svg)](https://cdnjs.com/libraries/preact)
[![Preact Slack Community](https://preact-slack.now.sh/badge.svg)](https://preact-slack.now.sh)
[![OpenCollective Backers](https://opencollective.com/preact/backers/badge.svg)](#backers)
[![OpenCollective Sponsors](https://opencollective.com/preact/sponsors/badge.svg)](#sponsors)
[![travis](https://travis-ci.org/developit/preact.svg?branch=master)](https://travis-ci.org/developit/preact)
[![coveralls](https://img.shields.io/coveralls/developit/preact/master.svg)](https://coveralls.io/github/developit/preact)
Preact supports modern browsers and IE9+:
[![Browsers](https://saucelabs.com/browser-matrix/preact.svg)](https://saucelabs.com/u/preact)
---
## Demos
- [**ESBench**](http://esbench.com) is built using Preact.
- [**Nectarine.rocks**](http://nectarine.rocks) _([Github Project](https://github.com/developit/nectarine))_ :peach:
- [**Documentation Viewer**](https://documentation-viewer.firebaseapp.com) _([Github Project](https://github.com/developit/documentation-viewer))_
- [**TodoMVC**](https://preact-todomvc.surge.sh) _([Github Project](https://github.com/developit/preact-todomvc))_
- [**Hacker News Minimal**](https://developit.github.io/hn_minimal/) _([Github Project](https://github.com/developit/hn_minimal))_
- [**Preact Boilerplate**](https://preact-boilerplate.surge.sh) _([Github Project](https://github.com/developit/preact-boilerplate))_ :zap:
- [**Preact Offline Starter**](https://preact-starter.now.sh) _([Github Project](https://github.com/lukeed/preact-starter))_ :100:
- [**Preact PWA**](https://preact-pwa.appspot.com/) _([Github Project](https://github.com/ezekielchentnik/preact-pwa))_ :hamburger:
- [**Preact Mobx Starter**](https://awaw00.github.io/preact-mobx-starter/) _([Github Project](https://github.com/awaw00/preact-mobx-starter))_ :sunny:
- [**Preact Redux Example**](https://github.com/developit/preact-redux-example) :star:
- [**Flickr Browser**](http://codepen.io/developit/full/VvMZwK/) (@ CodePen)
- [**Animating Text**](http://codepen.io/developit/full/LpNOdm/) (@ CodePen)
- [**60FPS Rainbow Spiral**](http://codepen.io/developit/full/xGoagz/) (@ CodePen)
- [**Simple Clock**](http://jsfiddle.net/developit/u9m5x0L7/embedded/result,js/) (@ JSFiddle)
- [**3D + ThreeJS**](http://codepen.io/developit/pen/PPMNjd?editors=0010) (@ CodePen)
- [**Stock Ticker**](http://codepen.io/developit/pen/wMYoBb?editors=0010) (@ CodePen)
- [**Create your Own!**](https://jsfiddle.net/developit/rs6zrh5f/embedded/result/) (@ JSFiddle)
- [**Preact Coffeescript**](https://github.com/crisward/preact-coffee)
- [**GuriVR**](https://gurivr.com) _([Github Project](https://github.com/opennewslabs/guri-vr))_
- [**V2EX Preact**](https://github.com/yanni4night/v2ex-preact)
- [**BigWebQuiz**](https://bigwebquiz.com/) _([Github Project](https://github.com/jakearchibald/big-web-quiz))_
- [**Color Picker**](https://colors.now.sh) _([Github Project](https://github.com/lukeed/colors-app))_ :art:
- [**Rainbow Explorer**](https://use-the-platform.com/rainbow-explorer/) _([Github Project](https://github.com/vaneenige/rainbow-explorer/))_ :rainbow:
- [**Offline Gallery**](https://use-the-platform.com/offline-gallery/) _([Github Project](https://github.com/vaneenige/offline-gallery/))_ :balloon:
## Libraries & Add-ons
- :raised_hands: [**preact-compat**](https://git.io/preact-compat): use any React library with Preact *([full example](http://git.io/preact-compat-example))*
- :page_facing_up: [**preact-render-to-string**](https://git.io/preact-render-to-string): Universal rendering.
- :earth_americas: [**preact-router**](https://git.io/preact-router): URL routing for your components
- :bookmark_tabs: [**preact-markup**](https://git.io/preact-markup): Render HTML & Custom Elements as JSX & Components
- :satellite: [**preact-portal**](https://git.io/preact-portal): Render Preact components into (a) SPACE :milky_way:
- :pencil: [**preact-richtextarea**](https://git.io/preact-richtextarea): Simple HTML editor component
- :bookmark: [**preact-token-input**](https://github.com/developit/preact-token-input): Text field that tokenizes input, for things like tags
- :card_index: [**preact-virtual-list**](https://github.com/developit/preact-virtual-list): Easily render lists with millions of rows ([demo](https://jsfiddle.net/developit/qqan9pdo/))
- :repeat: [**preact-cycle**](https://git.io/preact-cycle): Functional-reactive paradigm for Preact
- :triangular_ruler: [**preact-layout**](https://download.github.io/preact-layout/): Small and simple layout library
- :thought_balloon: [**preact-socrates**](https://github.com/matthewmueller/preact-socrates): Preact plugin for [Socrates](http://github.com/matthewmueller/socrates)
- :rowboat: [**preact-flyd**](https://github.com/xialvjun/preact-flyd): Use [flyd](https://github.com/paldepind/flyd) FRP streams in Preact + JSX
- :speech_balloon: [**preact-i18nline**](https://github.com/download/preact-i18nline): Integrates the ecosystem around [i18n-js](https://github.com/everydayhero/i18n-js) with Preact via [i18nline](https://github.com/download/i18nline).
- :metal: [**preact-mui**](https://git.io/v1aVO): The MUI CSS Preact library.
- :white_square_button: [**preact-mdl**](https://git.io/preact-mdl): Use [MDL](https://getmdl.io) as Preact components
- :rocket: [**preact-photon**](https://git.io/preact-photon): build beautiful desktop UI with [photon](http://photonkit.com)
- :microscope: [**preact-jsx-chai**](https://git.io/preact-jsx-chai): JSX assertion testing _(no DOM, right in Node)_
- :tophat: [**preact-classless-component**](https://github.com/ld0rman/preact-classless-component): create preact components without the class keyword
- :hammer: [**preact-hyperscript**](https://github.com/queckezz/preact-hyperscript): Hyperscript-like syntax for creating elements
- :white_check_mark: [**shallow-compare**](https://github.com/tkh44/shallow-compare): simplified `shouldComponentUpdate` helper.
- :shaved_ice: [**preact-codemod**](https://github.com/vutran/preact-codemod): Transform your React code to Preact.
- :construction_worker: [**preact-helmet**](https://github.com/download/preact-helmet): A document head manager for Preact
- :necktie: [**preact-delegate**](https://github.com/NekR/preact-delegate): Delegate DOM events
---
## Getting Started
> 💁 You [don't _have_ to use ES2015 to use Preact](https://github.com/developit/preact-without-babel)... but you should.
The following guide assumes you have some sort of ES2015 build set up using babel and/or webpack/browserify/gulp/grunt/etc. If you don't, start with [preact-boilerplate] or a [CodePen Template](http://codepen.io/developit/pen/pgaROe?editors=0010).
### Import what you need
The `preact` module provides both named and default exports, so you can either import everything under a namespace of your choosing, or just what you need as locals:
##### Named:
```js
import { h, render, Component } from 'preact';
// Tell Babel to transform JSX into h() calls:
/** @jsx h */
```
##### Default:
```js
import preact from 'preact';
// Tell Babel to transform JSX into preact.h() calls:
/** @jsx preact.h */
```
> Named imports work well for highly structured applications, whereas the default import is quick and never needs to be updated when using different parts of the library.
>
> Instead of declaring the `@jsx` pragma in your code, it's best to configure it globally in a `.babelrc`:
>
> **For Babel 5 and prior:**
>
> ```json
> { "jsxPragma": "h" }
> ```
>
> **For Babel 6:**
>
> ```json
> {
> "plugins": [
> ["transform-react-jsx", { "pragma":"h" }]
> ]
> }
> ```
### Rendering JSX
Out of the box, Preact provides an `h()` function that turns your JSX into Virtual DOM elements _([here's how](http://jasonformat.com/wtf-is-jsx))_. It also provides a `render()` function that creates a DOM tree from that Virtual DOM.
To render some JSX, just import those two functions and use them like so:
```js
import { h, render } from 'preact';
render((
<div id="foo">
<span>Hello, world!</span>
<button onClick={ e => alert("hi!") }>Click Me</button>
</div>
), document.body);
```
This should seem pretty straightforward if you've used hyperscript or one of its many friends. If you're not, the short of it is that the h function import gets used in the final, transpiled code as a drop in replacement for React.createElement, and so needs to be imported even if you don't explicitly use it in the code you write. Also note that if you're the kind of person who likes writing your React code in "pure JavaScript" (you know who you are) you will need to use h(...) wherever you would otherwise use React.createElement.
Rendering hyperscript with a virtual DOM is pointless, though. We want to render components and have them updated when data changes - that's where the power of virtual DOM diffing shines. :star2:
### Components
Preact exports a generic `Component` class, which can be extended to build encapsulated, self-updating pieces of a User Interface. Components support all of the standard React [lifecycle methods], like `shouldComponentUpdate()` and `componentWillReceiveProps()`. Providing specific implementations of these methods is the preferred mechanism for controlling _when_ and _how_ components update.
Components also have a `render()` method, but unlike React this method is passed `(props, state)` as arguments. This provides an ergonomic means to destructure `props` and `state` into local variables to be referenced from JSX.
Let's take a look at a very simple `Clock` component, which shows the current time.
```js
import { h, render, Component } from 'preact';
class Clock extends Component {
render() {
let time = new Date().toLocaleTimeString();
return <span>{ time }</span>;
}
}
// render an instance of Clock into <body>:
render(<Clock />, document.body);
```
That's great. Running this produces the following HTML DOM structure:
```html
<span>10:28:57 PM</span>
```
In order to have the clock's time update every second, we need to know when `<Clock>` gets mounted to the DOM. _If you've used HTML5 Custom Elements, this is similar to the `attachedCallback` and `detachedCallback` lifecycle methods._ Preact invokes the following lifecycle methods if they are defined for a Component:
| Lifecycle method | When it gets called |
|-----------------------------|--------------------------------------------------|
| `componentWillMount` | before the component gets mounted to the DOM |
| `componentDidMount` | after the component gets mounted to the DOM |
| `componentWillUnmount` | prior to removal from the DOM |
| `componentWillReceiveProps` | before new props get accepted |
| `shouldComponentUpdate` | before `render()`. Return `false` to skip render |
| `componentWillUpdate` | before `render()` |
| `componentDidUpdate` | after `render()` |
So, we want to have a 1-second timer start once the Component gets added to the DOM, and stop if it is removed. We'll create the timer and store a reference to it in `componentDidMount`, and stop the timer in `componentWillUnmount`. On each timer tick, we'll update the component's `state` object with a new time value. Doing this will automatically re-render the component.
```js
import { h, render, Component } from 'preact';
class Clock extends Component {
constructor() {
super();
// set initial time:
this.state = {
time: Date.now()
};
}
componentDidMount() {
// update time every second
this.timer = setInterval(() => {
this.setState({ time: Date.now() });
}, 1000);
}
componentWillUnmount() {
// stop when not renderable
clearInterval(this.timer);
}
render(props, state) {
let time = new Date(state.time).toLocaleTimeString();
return <span>{ time }</span>;
}
}
// render an instance of Clock into <body>:
render(<Clock />, document.body);
```
Now we have [a ticking clock](http://jsfiddle.net/developit/u9m5x0L7/embedded/result,js/)!
### Props & State
The concept (and nomenclature) for `props` and `state` is the same as in React. `props` are passed to a component by defining attributes in JSX, `state` is internal state. Changing either triggers a re-render, though by default Preact re-renders Components asynchronously for `state` changes and synchronously for `props` changes. You can tell Preact to render `prop` changes asynchronously by setting `options.syncComponentUpdates` to `false`.
---
## Linked State
One area Preact takes a little further than React is in optimizing state changes. A common pattern in ES2015 React code is to use Arrow functions within a `render()` method in order to update state in response to events. Creating functions enclosed in a scope on every render is inefficient and forces the garbage collector to do more work than is necessary.
One solution to this is to bind component methods declaratively.
Here is an example using [decko](http://git.io/decko):
```js
class Foo extends Component {
@bind
updateText(e) {
this.setState({ text: e.target.value });
}
render({ }, { text }) {
return <input value={text} onInput={this.updateText} />;
}
}
```
While this achieves much better runtime performance, it's still a lot of unnecessary code to wire up state to UI.
Fortunately there is a solution, in the form of `linkState()`. Calling `component.linkState('text')` returns a function that accepts an Event and uses it's associated value to update the given property in your component's state. Calls to linkState() with the same state property are cached, so there is no performance penalty. Here is the previous example rewritten using _Linked State_:
```js
class Foo extends Component {
render({ }, { text }) {
return <input value={text} onInput={this.linkState('text')} />;
}
}
```
Simple and effective. It handles linking state from any input type, or an optional second parameter can be used to explicitly provide a keypath to the new state value.
## Examples
Here is a somewhat verbose Preact `<Link>` component:
```js
class Link extends Component {
render(props, state) {
return <a href={ props.href }>{ props.children }</a>;
}
}
```
Since this is ES6/ES2015, we can further simplify:
```js
class Link extends Component {
render({ href, children }) {
return <a {...{ href, children }} />;
}
}
// or, for wide-open props support:
class Link extends Component {
render(props) {
return <a {...props} />;
}
}
// or, as a stateless functional component:
const Link = ({ children, ...props }) => (
<a {...props}>{ children }</a>
);
```
## Extensions
It is likely that some projects based on Preact would wish to extend Component with great new functionality.
Perhaps automatic connection to stores for a Flux-like architecture, or mixed-in context bindings to make it feel more like `React.createClass()`. Just use ES2015 inheritance:
```js
class BoundComponent extends Component {
constructor(props) {
super(props);
this.bind();
}
bind() {
this.binds = {};
for (let i in this) {
this.binds[i] = this[i].bind(this);
}
}
}
// example usage
class Link extends BoundComponent {
click() {
open(this.href);
}
render() {
let { click } = this.binds;
return <span onclick={ click }>{ children }</span>;
}
}
```
The possibilities are pretty endless here. You could even add support for rudimentary mixins:
```js
class MixedComponent extends Component {
constructor() {
super();
(this.mixins || []).forEach( m => Object.assign(this, m) );
}
}
```
## Developer Tools
You can inspect and modify the state of your Preact UI components at runtime using the
[React Developer Tools](https://github.com/facebook/react-devtools) browser extension.
1. Install the [React Developer Tools](https://github.com/facebook/react-devtools) extension
2. Import the "preact/devtools" module in your app
3. Reload and go to the 'React' tab in the browser's development tools
```js
import { h, Component, render } from 'preact';
// Enable devtools. You can reduce the size of your app by only including this
// module in development builds. eg. In Webpack, wrap this with an `if (module.hot) {...}`
// check.
require('preact/devtools');
```
## 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
[![Preact](http://i.imgur.com/YqCHvEW.gif)](https://preactjs.com)
[preact-compat]: https://github.com/developit/preact-compat
[ES6 Class]: https://facebook.github.io/react/docs/reusable-components.html#es6-classes
[Functional Components]: https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html#stateless-functional-components
[hyperscript]: https://github.com/dominictarr/hyperscript
[preact-boilerplate]: https://github.com/developit/preact-boilerplate
[lifecycle methods]: https://facebook.github.io/react/docs/component-specs.html

400
static/js/ketcher2/node_modules/preact/devtools.js generated vendored Normal file
View File

@ -0,0 +1,400 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('preact')) :
typeof define === 'function' && define.amd ? define(['preact'], factory) :
(factory(global.preact));
}(this, (function (preact) { 'use strict';
// render modes
var ATTR_KEY = '__preactattr_';
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
// Internal helpers from preact
/**
* Return a ReactElement-compatible object for the current state of a preact
* component.
*/
function createReactElement(component) {
return {
type: component.constructor,
key: component.key,
ref: null, // Unsupported
props: component.props
};
}
/**
* Create a ReactDOMComponent-compatible object for a given DOM node rendered
* by preact.
*
* This implements the subset of the ReactDOMComponent interface that
* React DevTools requires in order to display DOM nodes in the inspector with
* the correct type and properties.
*
* @param {Node} node
*/
function createReactDOMComponent(node) {
var childNodes = node.nodeType === Node.ELEMENT_NODE ? Array.from(node.childNodes) : [];
var isText = node.nodeType === Node.TEXT_NODE;
return {
// --- ReactDOMComponent interface
_currentElement: isText ? node.textContent : {
type: node.nodeName.toLowerCase(),
props: node[ATTR_KEY]
},
_renderedChildren: childNodes.map(function (child) {
if (child._component) {
return updateReactComponent(child._component);
}
return updateReactComponent(child);
}),
_stringText: isText ? node.textContent : null,
// --- Additional properties used by preact devtools
// A flag indicating whether the devtools have been notified about the
// existence of this component instance yet.
// This is used to send the appropriate notifications when DOM components
// are added or updated between composite component updates.
_inDevTools: false,
node: node
};
}
/**
* Return the name of a component created by a `ReactElement`-like object.
*
* @param {ReactElement} element
*/
function typeName(element) {
if (typeof element.type === 'function') {
return element.type.displayName || element.type.name;
}
return element.type;
}
/**
* Return a ReactCompositeComponent-compatible object for a given preact
* component instance.
*
* This implements the subset of the ReactCompositeComponent interface that
* the DevTools requires in order to walk the component tree and inspect the
* component's properties.
*
* See https://github.com/facebook/react-devtools/blob/e31ec5825342eda570acfc9bcb43a44258fceb28/backend/getData.js
*/
function createReactCompositeComponent(component) {
var _currentElement = createReactElement(component);
var node = component.base;
var instance = {
// --- ReactDOMComponent properties
getName: function getName() {
return typeName(_currentElement);
},
_currentElement: createReactElement(component),
props: component.props,
state: component.state,
forceUpdate: component.forceUpdate && component.forceUpdate.bind(component),
setState: component.setState && component.setState.bind(component),
// --- Additional properties used by preact devtools
node: node
};
// React DevTools exposes the `_instance` field of the selected item in the
// component tree as `$r` in the console. `_instance` must refer to a
// React Component (or compatible) class instance with `props` and `state`
// fields and `setState()`, `forceUpdate()` methods.
instance._instance = component;
// If the root node returned by this component instance's render function
// was itself a composite component, there will be a `_component` property
// containing the child component instance.
if (component._component) {
instance._renderedComponent = updateReactComponent(component._component);
} else {
// Otherwise, if the render() function returned an HTML/SVG element,
// create a ReactDOMComponent-like object for the DOM node itself.
instance._renderedComponent = updateReactComponent(node);
}
return instance;
}
/**
* Map of Component|Node to ReactDOMComponent|ReactCompositeComponent-like
* object.
*
* The same React*Component instance must be used when notifying devtools
* about the initial mount of a component and subsequent updates.
*/
var instanceMap = typeof Map === 'function' && new Map();
/**
* Update (and create if necessary) the ReactDOMComponent|ReactCompositeComponent-like
* instance for a given preact component instance or DOM Node.
*
* @param {Component|Node} componentOrNode
*/
function updateReactComponent(componentOrNode) {
var newInstance = componentOrNode instanceof Node ? createReactDOMComponent(componentOrNode) : createReactCompositeComponent(componentOrNode);
if (instanceMap.has(componentOrNode)) {
var inst = instanceMap.get(componentOrNode);
Object.assign(inst, newInstance);
return inst;
}
instanceMap.set(componentOrNode, newInstance);
return newInstance;
}
function nextRootKey(roots) {
return '.' + Object.keys(roots).length;
}
/**
* Find all root component instances rendered by preact in `node`'s children
* and add them to the `roots` map.
*
* @param {DOMElement} node
* @param {[key: string] => ReactDOMComponent|ReactCompositeComponent}
*/
function findRoots(node, roots) {
Array.from(node.childNodes).forEach(function (child) {
if (child._component) {
roots[nextRootKey(roots)] = updateReactComponent(child._component);
} else {
findRoots(child, roots);
}
});
}
/**
* Create a bridge for exposing preact's component tree to React DevTools.
*
* It creates implementations of the interfaces that ReactDOM passes to
* devtools to enable it to query the component tree and hook into component
* updates.
*
* See https://github.com/facebook/react/blob/59ff7749eda0cd858d5ee568315bcba1be75a1ca/src/renderers/dom/ReactDOM.js
* for how ReactDOM exports its internals for use by the devtools and
* the `attachRenderer()` function in
* https://github.com/facebook/react-devtools/blob/e31ec5825342eda570acfc9bcb43a44258fceb28/backend/attachRenderer.js
* for how the devtools consumes the resulting objects.
*/
function createDevToolsBridge() {
// The devtools has different paths for interacting with the renderers from
// React Native, legacy React DOM and current React DOM.
//
// Here we emulate the interface for the current React DOM (v15+) lib.
// ReactDOMComponentTree-like object
var ComponentTree = {
getNodeFromInstance: function getNodeFromInstance(instance) {
return instance.node;
},
getClosestInstanceFromNode: function getClosestInstanceFromNode(node) {
while (node && !node._component) {
node = node.parentNode;
}
return node ? updateReactComponent(node._component) : null;
}
};
// Map of root ID (the ID is unimportant) to component instance.
var roots = {};
findRoots(document.body, roots);
// ReactMount-like object
//
// Used by devtools to discover the list of root component instances and get
// notified when new root components are rendered.
var Mount = {
_instancesByReactRootID: roots,
// Stub - React DevTools expects to find this method and replace it
// with a wrapper in order to observe new root components being added
_renderNewRootComponent: function _renderNewRootComponent() /* instance, ... */{}
};
// ReactReconciler-like object
var Reconciler = {
// Stubs - React DevTools expects to find these methods and replace them
// with wrappers in order to observe components being mounted, updated and
// unmounted
mountComponent: function mountComponent() /* instance, ... */{},
performUpdateIfNecessary: function performUpdateIfNecessary() /* instance, ... */{},
receiveComponent: function receiveComponent() /* instance, ... */{},
unmountComponent: function unmountComponent() /* instance, ... */{}
};
/** Notify devtools that a new component instance has been mounted into the DOM. */
var componentAdded = function componentAdded(component) {
var instance = updateReactComponent(component);
if (isRootComponent(component)) {
instance._rootID = nextRootKey(roots);
roots[instance._rootID] = instance;
Mount._renderNewRootComponent(instance);
}
visitNonCompositeChildren(instance, function (childInst) {
childInst._inDevTools = true;
Reconciler.mountComponent(childInst);
});
Reconciler.mountComponent(instance);
};
/** Notify devtools that a component has been updated with new props/state. */
var componentUpdated = function componentUpdated(component) {
var prevRenderedChildren = [];
visitNonCompositeChildren(instanceMap.get(component), function (childInst) {
prevRenderedChildren.push(childInst);
});
// Notify devtools about updates to this component and any non-composite
// children
var instance = updateReactComponent(component);
Reconciler.receiveComponent(instance);
visitNonCompositeChildren(instance, function (childInst) {
if (!childInst._inDevTools) {
// New DOM child component
childInst._inDevTools = true;
Reconciler.mountComponent(childInst);
} else {
// Updated DOM child component
Reconciler.receiveComponent(childInst);
}
});
// For any non-composite children that were removed by the latest render,
// remove the corresponding ReactDOMComponent-like instances and notify
// the devtools
prevRenderedChildren.forEach(function (childInst) {
if (!document.body.contains(childInst.node)) {
instanceMap['delete'](childInst.node);
Reconciler.unmountComponent(childInst);
}
});
};
/** Notify devtools that a component has been unmounted from the DOM. */
var componentRemoved = function componentRemoved(component) {
var instance = updateReactComponent(component);
visitNonCompositeChildren(function (childInst) {
instanceMap['delete'](childInst.node);
Reconciler.unmountComponent(childInst);
});
Reconciler.unmountComponent(instance);
instanceMap['delete'](component);
if (instance._rootID) {
delete roots[instance._rootID];
}
};
return {
componentAdded: componentAdded,
componentUpdated: componentUpdated,
componentRemoved: componentRemoved,
// Interfaces passed to devtools via __REACT_DEVTOOLS_GLOBAL_HOOK__.inject()
ComponentTree: ComponentTree,
Mount: Mount,
Reconciler: Reconciler
};
}
/**
* Return `true` if a preact component is a top level component rendered by
* `render()` into a container Element.
*/
function isRootComponent(component) {
// `_parentComponent` is actually `__u` after minification
if (component._parentComponent || component.__u) {
// Component with a composite parent
return false;
}
if (component.base.parentElement && component.base.parentElement[ATTR_KEY]) {
// Component with a parent DOM element rendered by Preact
return false;
}
return true;
}
/**
* Visit all child instances of a ReactCompositeComponent-like object that are
* not composite components (ie. they represent DOM elements or text)
*
* @param {Component} component
* @param {(Component) => void} visitor
*/
function visitNonCompositeChildren(component, visitor) {
if (component._renderedComponent) {
if (!component._renderedComponent._component) {
visitor(component._renderedComponent);
visitNonCompositeChildren(component._renderedComponent, visitor);
}
} else if (component._renderedChildren) {
component._renderedChildren.forEach(function (child) {
visitor(child);
if (!child._component) visitNonCompositeChildren(child, visitor);
});
}
}
/**
* Create a bridge between the preact component tree and React's dev tools
* and register it.
*
* After this function is called, the React Dev Tools should be able to detect
* "React" on the page and show the component tree.
*
* This function hooks into preact VNode creation in order to expose functional
* components correctly, so it should be called before the root component(s)
* are rendered.
*
* Returns a cleanup function which unregisters the hooks.
*/
function initDevTools() {
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
// React DevTools are not installed
return;
}
// Notify devtools when preact components are mounted, updated or unmounted
var bridge = createDevToolsBridge();
var nextAfterMount = preact.options.afterMount;
preact.options.afterMount = function (component) {
bridge.componentAdded(component);
if (nextAfterMount) nextAfterMount(component);
};
var nextAfterUpdate = preact.options.afterUpdate;
preact.options.afterUpdate = function (component) {
bridge.componentUpdated(component);
if (nextAfterUpdate) nextAfterUpdate(component);
};
var nextBeforeUnmount = preact.options.beforeUnmount;
preact.options.beforeUnmount = function (component) {
bridge.componentRemoved(component);
if (nextBeforeUnmount) nextBeforeUnmount(component);
};
// Notify devtools about this instance of "React"
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject(bridge);
return function () {
preact.options.afterMount = nextAfterMount;
preact.options.afterUpdate = nextAfterUpdate;
preact.options.beforeUnmount = nextBeforeUnmount;
};
}
initDevTools();
})));
//# sourceMappingURL=devtools.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,391 @@
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
import { options } from 'preact';
// Internal helpers from preact
import { ATTR_KEY } from '../src/constants';
/**
* Return a ReactElement-compatible object for the current state of a preact
* component.
*/
function createReactElement(component) {
return {
type: component.constructor,
key: component.key,
ref: null, // Unsupported
props: component.props
};
}
/**
* Create a ReactDOMComponent-compatible object for a given DOM node rendered
* by preact.
*
* This implements the subset of the ReactDOMComponent interface that
* React DevTools requires in order to display DOM nodes in the inspector with
* the correct type and properties.
*
* @param {Node} node
*/
function createReactDOMComponent(node) {
const childNodes = node.nodeType === Node.ELEMENT_NODE ?
Array.from(node.childNodes) : [];
const isText = node.nodeType === Node.TEXT_NODE;
return {
// --- ReactDOMComponent interface
_currentElement: isText ? node.textContent : {
type: node.nodeName.toLowerCase(),
props: node[ATTR_KEY]
},
_renderedChildren: childNodes.map(child => {
if (child._component) {
return updateReactComponent(child._component);
}
return updateReactComponent(child);
}),
_stringText: isText ? node.textContent : null,
// --- Additional properties used by preact devtools
// A flag indicating whether the devtools have been notified about the
// existence of this component instance yet.
// This is used to send the appropriate notifications when DOM components
// are added or updated between composite component updates.
_inDevTools: false,
node
};
}
/**
* Return the name of a component created by a `ReactElement`-like object.
*
* @param {ReactElement} element
*/
function typeName(element) {
if (typeof element.type === 'function') {
return element.type.displayName || element.type.name;
}
return element.type;
}
/**
* Return a ReactCompositeComponent-compatible object for a given preact
* component instance.
*
* This implements the subset of the ReactCompositeComponent interface that
* the DevTools requires in order to walk the component tree and inspect the
* component's properties.
*
* See https://github.com/facebook/react-devtools/blob/e31ec5825342eda570acfc9bcb43a44258fceb28/backend/getData.js
*/
function createReactCompositeComponent(component) {
const _currentElement = createReactElement(component);
const node = component.base;
let instance = {
// --- ReactDOMComponent properties
getName() {
return typeName(_currentElement);
},
_currentElement: createReactElement(component),
props: component.props,
state: component.state,
forceUpdate: component.forceUpdate && component.forceUpdate.bind(component),
setState: component.setState && component.setState.bind(component),
// --- Additional properties used by preact devtools
node
};
// React DevTools exposes the `_instance` field of the selected item in the
// component tree as `$r` in the console. `_instance` must refer to a
// React Component (or compatible) class instance with `props` and `state`
// fields and `setState()`, `forceUpdate()` methods.
instance._instance = component;
// If the root node returned by this component instance's render function
// was itself a composite component, there will be a `_component` property
// containing the child component instance.
if (component._component) {
instance._renderedComponent = updateReactComponent(component._component);
} else {
// Otherwise, if the render() function returned an HTML/SVG element,
// create a ReactDOMComponent-like object for the DOM node itself.
instance._renderedComponent = updateReactComponent(node);
}
return instance;
}
/**
* Map of Component|Node to ReactDOMComponent|ReactCompositeComponent-like
* object.
*
* The same React*Component instance must be used when notifying devtools
* about the initial mount of a component and subsequent updates.
*/
let instanceMap = typeof Map==='function' && new Map();
/**
* Update (and create if necessary) the ReactDOMComponent|ReactCompositeComponent-like
* instance for a given preact component instance or DOM Node.
*
* @param {Component|Node} componentOrNode
*/
function updateReactComponent(componentOrNode) {
const newInstance = componentOrNode instanceof Node ?
createReactDOMComponent(componentOrNode) :
createReactCompositeComponent(componentOrNode);
if (instanceMap.has(componentOrNode)) {
let inst = instanceMap.get(componentOrNode);
Object.assign(inst, newInstance);
return inst;
}
instanceMap.set(componentOrNode, newInstance);
return newInstance;
}
function nextRootKey(roots) {
return '.' + Object.keys(roots).length;
}
/**
* Find all root component instances rendered by preact in `node`'s children
* and add them to the `roots` map.
*
* @param {DOMElement} node
* @param {[key: string] => ReactDOMComponent|ReactCompositeComponent}
*/
function findRoots(node, roots) {
Array.from(node.childNodes).forEach(child => {
if (child._component) {
roots[nextRootKey(roots)] = updateReactComponent(child._component);
} else {
findRoots(child, roots);
}
});
}
/**
* Create a bridge for exposing preact's component tree to React DevTools.
*
* It creates implementations of the interfaces that ReactDOM passes to
* devtools to enable it to query the component tree and hook into component
* updates.
*
* See https://github.com/facebook/react/blob/59ff7749eda0cd858d5ee568315bcba1be75a1ca/src/renderers/dom/ReactDOM.js
* for how ReactDOM exports its internals for use by the devtools and
* the `attachRenderer()` function in
* https://github.com/facebook/react-devtools/blob/e31ec5825342eda570acfc9bcb43a44258fceb28/backend/attachRenderer.js
* for how the devtools consumes the resulting objects.
*/
function createDevToolsBridge() {
// The devtools has different paths for interacting with the renderers from
// React Native, legacy React DOM and current React DOM.
//
// Here we emulate the interface for the current React DOM (v15+) lib.
// ReactDOMComponentTree-like object
const ComponentTree = {
getNodeFromInstance(instance) {
return instance.node;
},
getClosestInstanceFromNode(node) {
while (node && !node._component) {
node = node.parentNode;
}
return node ? updateReactComponent(node._component) : null;
}
};
// Map of root ID (the ID is unimportant) to component instance.
let roots = {};
findRoots(document.body, roots);
// ReactMount-like object
//
// Used by devtools to discover the list of root component instances and get
// notified when new root components are rendered.
const Mount = {
_instancesByReactRootID: roots,
// Stub - React DevTools expects to find this method and replace it
// with a wrapper in order to observe new root components being added
_renderNewRootComponent(/* instance, ... */) { }
};
// ReactReconciler-like object
const Reconciler = {
// Stubs - React DevTools expects to find these methods and replace them
// with wrappers in order to observe components being mounted, updated and
// unmounted
mountComponent(/* instance, ... */) { },
performUpdateIfNecessary(/* instance, ... */) { },
receiveComponent(/* instance, ... */) { },
unmountComponent(/* instance, ... */) { }
};
/** Notify devtools that a new component instance has been mounted into the DOM. */
const componentAdded = component => {
const instance = updateReactComponent(component);
if (isRootComponent(component)) {
instance._rootID = nextRootKey(roots);
roots[instance._rootID] = instance;
Mount._renderNewRootComponent(instance);
}
visitNonCompositeChildren(instance, childInst => {
childInst._inDevTools = true;
Reconciler.mountComponent(childInst);
});
Reconciler.mountComponent(instance);
};
/** Notify devtools that a component has been updated with new props/state. */
const componentUpdated = component => {
const prevRenderedChildren = [];
visitNonCompositeChildren(instanceMap.get(component), childInst => {
prevRenderedChildren.push(childInst);
});
// Notify devtools about updates to this component and any non-composite
// children
const instance = updateReactComponent(component);
Reconciler.receiveComponent(instance);
visitNonCompositeChildren(instance, childInst => {
if (!childInst._inDevTools) {
// New DOM child component
childInst._inDevTools = true;
Reconciler.mountComponent(childInst);
} else {
// Updated DOM child component
Reconciler.receiveComponent(childInst);
}
});
// For any non-composite children that were removed by the latest render,
// remove the corresponding ReactDOMComponent-like instances and notify
// the devtools
prevRenderedChildren.forEach(childInst => {
if (!document.body.contains(childInst.node)) {
instanceMap.delete(childInst.node);
Reconciler.unmountComponent(childInst);
}
});
};
/** Notify devtools that a component has been unmounted from the DOM. */
const componentRemoved = component => {
const instance = updateReactComponent(component);
visitNonCompositeChildren(childInst => {
instanceMap.delete(childInst.node);
Reconciler.unmountComponent(childInst);
});
Reconciler.unmountComponent(instance);
instanceMap.delete(component);
if (instance._rootID) {
delete roots[instance._rootID];
}
};
return {
componentAdded,
componentUpdated,
componentRemoved,
// Interfaces passed to devtools via __REACT_DEVTOOLS_GLOBAL_HOOK__.inject()
ComponentTree,
Mount,
Reconciler
};
}
/**
* Return `true` if a preact component is a top level component rendered by
* `render()` into a container Element.
*/
function isRootComponent(component) {
// `_parentComponent` is actually `__u` after minification
if (component._parentComponent || component.__u) {
// Component with a composite parent
return false;
}
if (component.base.parentElement && component.base.parentElement[ATTR_KEY]) {
// Component with a parent DOM element rendered by Preact
return false;
}
return true;
}
/**
* Visit all child instances of a ReactCompositeComponent-like object that are
* not composite components (ie. they represent DOM elements or text)
*
* @param {Component} component
* @param {(Component) => void} visitor
*/
function visitNonCompositeChildren(component, visitor) {
if (component._renderedComponent) {
if (!component._renderedComponent._component) {
visitor(component._renderedComponent);
visitNonCompositeChildren(component._renderedComponent, visitor);
}
} else if (component._renderedChildren) {
component._renderedChildren.forEach(child => {
visitor(child);
if (!child._component) visitNonCompositeChildren(child, visitor);
});
}
}
/**
* Create a bridge between the preact component tree and React's dev tools
* and register it.
*
* After this function is called, the React Dev Tools should be able to detect
* "React" on the page and show the component tree.
*
* This function hooks into preact VNode creation in order to expose functional
* components correctly, so it should be called before the root component(s)
* are rendered.
*
* Returns a cleanup function which unregisters the hooks.
*/
export function initDevTools() {
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
// React DevTools are not installed
return;
}
// Notify devtools when preact components are mounted, updated or unmounted
const bridge = createDevToolsBridge();
const nextAfterMount = options.afterMount;
options.afterMount = component => {
bridge.componentAdded(component);
if (nextAfterMount) nextAfterMount(component);
};
const nextAfterUpdate = options.afterUpdate;
options.afterUpdate = component => {
bridge.componentUpdated(component);
if (nextAfterUpdate) nextAfterUpdate(component);
};
const nextBeforeUnmount = options.beforeUnmount;
options.beforeUnmount = component => {
bridge.componentRemoved(component);
if (nextBeforeUnmount) nextBeforeUnmount(component);
};
// Notify devtools about this instance of "React"
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject(bridge);
return () => {
options.afterMount = nextAfterMount;
options.afterUpdate = nextAfterUpdate;
options.beforeUnmount = nextBeforeUnmount;
};
}

View File

@ -0,0 +1,4 @@
import { initDevTools } from './devtools';
initDevTools();

754
static/js/ketcher2/node_modules/preact/dist/preact.d.ts generated vendored Normal file
View File

@ -0,0 +1,754 @@
declare namespace preact {
interface ComponentProps<C extends Component<any, any> | FunctionalComponent<any>> {
children?:JSX.Element[];
key?:string | number | any;
ref?:(el: C) => void;
}
interface DangerouslySetInnerHTML {
__html: string;
}
interface PreactHTMLAttributes {
dangerouslySetInnerHTML?:DangerouslySetInnerHTML;
key?:string;
ref?:(el?: Element) => void;
}
interface VNode {
nodeName:ComponentConstructor<any, any>|string;
attributes:{[name:string]:any};
children:VNode[];
key:string;
}
interface ComponentLifecycle<PropsType, StateType> {
componentWillMount?():void;
componentDidMount?():void;
componentWillUnmount?():void;
componentWillReceiveProps?(nextProps:PropsType,nextContext:any):void;
shouldComponentUpdate?(nextProps:PropsType,nextState:StateType,nextContext:any):boolean;
componentWillUpdate?(nextProps:PropsType,nextState:StateType,nextContext:any):void;
componentDidUpdate?(previousProps:PropsType,previousState:StateType,previousContext:any):void;
}
interface FunctionalComponent<PropsType> {
(props?:PropsType & ComponentProps<this>, context?:any):JSX.Element;
displayName?:string;
defaultProps?:any;
}
interface ComponentConstructor<PropsType, StateType> {
new (props?:PropsType, context?: any):Component<PropsType, StateType>;
}
// Type alias for a component considered generally, whether stateless or stateful.
type AnyComponent<PropsType, StateType> = FunctionalComponent<PropsType> | typeof Component;
abstract class Component<PropsType, StateType> implements ComponentLifecycle<PropsType, StateType> {
constructor(props?:PropsType, context?:any);
static displayName?:string;
static defaultProps?:any;
state:StateType;
props:PropsType & ComponentProps<this>;
context:any;
base:HTMLElement;
linkState:(name:string) => (event: Event) => void;
setState<K extends keyof StateType>(state:Pick<StateType, K>, callback?:() => void):void;
setState<K extends keyof StateType>(fn:(prevState:StateType, props:PropsType) => Pick<StateType, K>, callback?:() => void):void;
forceUpdate(callback?:() => void): void;
abstract render(props?:PropsType & ComponentProps<this>, state?:StateType, context?:any):JSX.Element;
}
function h<PropsType>(node:ComponentConstructor<PropsType, any> | FunctionalComponent<PropsType>, params:PropsType, ...children:(JSX.Element|JSX.Element[]|string)[]):JSX.Element;
function h(node:string, params:JSX.HTMLAttributes&JSX.SVGAttributes&{[propName: string]: any}, ...children:(JSX.Element|JSX.Element[]|string)[]):JSX.Element;
function render(node:JSX.Element, parent:Element|Document, mergeWith?:Element):Element;
function rerender():void;
function cloneElement(element:JSX.Element, props:any):JSX.Element;
var options:{
syncComponentUpdates?:boolean;
debounceRendering?:(render:() => void) => void;
vnode?:(vnode:VNode) => void;
event?:(event:Event) => Event;
};
}
declare module "preact" {
export = preact;
}
declare module "preact/devtools" {
// Empty. This module initializes the React Developer Tools integration
// when imported.
}
declare namespace JSX {
interface Element extends preact.VNode {
}
interface ElementClass extends preact.Component<any, any> {
}
interface ElementAttributesProperty {
props:any;
}
interface SVGAttributes extends HTMLAttributes {
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;
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;
}
interface EventHandler<E extends Event> {
(event:E):void;
}
type ClipboardEventHandler = EventHandler<ClipboardEvent>;
type CompositionEventHandler = EventHandler<CompositionEvent>;
type DragEventHandler = EventHandler<DragEvent>;
type FocusEventHandler = EventHandler<FocusEvent>;
type KeyboardEventHandler = EventHandler<KeyboardEvent>;
type MouseEventHandler = EventHandler<MouseEvent>;
type TouchEventHandler = EventHandler<TouchEvent>;
type UIEventHandler = EventHandler<UIEvent>;
type WheelEventHandler = EventHandler<WheelEvent>;
type AnimationEventHandler = EventHandler<AnimationEvent>;
type TransitionEventHandler = EventHandler<TransitionEvent>;
type GenericEventHandler = EventHandler<Event>;
interface DOMAttributes {
// Clipboard Events
onCopy?:ClipboardEventHandler;
onCut?:ClipboardEventHandler;
onPaste?:ClipboardEventHandler;
// Composition Events
onCompositionEnd?:CompositionEventHandler;
onCompositionStart?:CompositionEventHandler;
onCompositionUpdate?:CompositionEventHandler;
// Focus Events
onFocus?:FocusEventHandler;
onBlur?:FocusEventHandler;
// Form Events
onChange?:GenericEventHandler;
onInput?:GenericEventHandler;
onSubmit?:GenericEventHandler;
// Keyboard Events
onKeyDown?:KeyboardEventHandler;
onKeyPress?:KeyboardEventHandler;
onKeyUp?:KeyboardEventHandler;
// Media Events
onAbort?:GenericEventHandler;
onCanPlay?:GenericEventHandler;
onCanPlayThrough?:GenericEventHandler;
onDurationChange?:GenericEventHandler;
onEmptied?:GenericEventHandler;
onEncrypted?:GenericEventHandler;
onEnded?:GenericEventHandler;
onLoadedData?:GenericEventHandler;
onLoadedMetadata?:GenericEventHandler;
onLoadStart?:GenericEventHandler;
onPause?:GenericEventHandler;
onPlay?:GenericEventHandler;
onPlaying?:GenericEventHandler;
onProgress?:GenericEventHandler;
onRateChange?:GenericEventHandler;
onSeeked?:GenericEventHandler;
onSeeking?:GenericEventHandler;
onStalled?:GenericEventHandler;
onSuspend?:GenericEventHandler;
onTimeUpdate?:GenericEventHandler;
onVolumeChange?:GenericEventHandler;
onWaiting?:GenericEventHandler;
// MouseEvents
onClick?:MouseEventHandler;
onContextMenu?:MouseEventHandler;
onDoubleClick?:MouseEventHandler;
onDrag?:DragEventHandler;
onDragEnd?:DragEventHandler;
onDragEnter?:DragEventHandler;
onDragExit?:DragEventHandler;
onDragLeave?:DragEventHandler;
onDragOver?:DragEventHandler;
onDragStart?:DragEventHandler;
onDrop?:DragEventHandler;
onMouseDown?:MouseEventHandler;
onMouseEnter?:MouseEventHandler;
onMouseLeave?:MouseEventHandler;
onMouseMove?:MouseEventHandler;
onMouseOut?:MouseEventHandler;
onMouseOver?:MouseEventHandler;
onMouseUp?:MouseEventHandler;
// Selection Events
onSelect?:GenericEventHandler;
// Touch Events
onTouchCancel?:TouchEventHandler;
onTouchEnd?:TouchEventHandler;
onTouchMove?:TouchEventHandler;
onTouchStart?:TouchEventHandler;
// UI Events
onScroll?:UIEventHandler;
// Wheel Events
onWheel?:WheelEventHandler;
// Animation Events
onAnimationStart?:AnimationEventHandler;
onAnimationEnd?:AnimationEventHandler;
onAnimationIteration?:AnimationEventHandler;
// Transition Events
onTransitionEnd?:TransitionEventHandler;
}
interface HTMLAttributes extends preact.PreactHTMLAttributes, DOMAttributes {
// Standard HTML Attributes
accept?:string;
acceptCharset?:string;
accessKey?:string;
action?:string;
allowFullScreen?:boolean;
allowTransparency?:boolean;
alt?:string;
async?:boolean;
autocomplete?:string;
autofocus?:boolean;
autoPlay?:boolean;
capture?:boolean;
cellPadding?:number | string;
cellSpacing?:number | string;
charSet?:string;
challenge?:string;
checked?:boolean;
class?:string | { [key:string]: boolean };
className?:string | { [key:string]: boolean };
cols?:number;
colSpan?:number;
content?:string;
contentEditable?:boolean;
contextMenu?:string;
controls?:boolean;
coords?:string;
crossOrigin?:string;
data?:string;
dateTime?:string;
default?:boolean;
defer?:boolean;
dir?:string;
disabled?: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;
httpEquiv?:string;
icon?:string;
id?:string;
inputMode?:string;
integrity?:string;
is?:string;
keyParams?:string;
keyType?:string;
kind?:string;
label?:string;
lang?:string;
list?:string;
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;
noValidate?:boolean;
open?:boolean;
optimum?:number;
pattern?:string;
placeholder?:string;
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?:any;
summary?:string;
tabIndex?:number;
target?:string;
title?:string;
type?:string;
useMap?:string;
value?:string | string[];
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;
}
interface IntrinsicElements {
// HTML
a:HTMLAttributes;
abbr:HTMLAttributes;
address:HTMLAttributes;
area:HTMLAttributes;
article:HTMLAttributes;
aside:HTMLAttributes;
audio:HTMLAttributes;
b:HTMLAttributes;
base:HTMLAttributes;
bdi:HTMLAttributes;
bdo:HTMLAttributes;
big:HTMLAttributes;
blockquote:HTMLAttributes;
body:HTMLAttributes;
br:HTMLAttributes;
button:HTMLAttributes;
canvas:HTMLAttributes;
caption:HTMLAttributes;
cite:HTMLAttributes;
code:HTMLAttributes;
col:HTMLAttributes;
colgroup:HTMLAttributes;
data:HTMLAttributes;
datalist:HTMLAttributes;
dd:HTMLAttributes;
del:HTMLAttributes;
details:HTMLAttributes;
dfn:HTMLAttributes;
dialog:HTMLAttributes;
div:HTMLAttributes;
dl:HTMLAttributes;
dt:HTMLAttributes;
em:HTMLAttributes;
embed:HTMLAttributes;
fieldset:HTMLAttributes;
figcaption:HTMLAttributes;
figure:HTMLAttributes;
footer:HTMLAttributes;
form:HTMLAttributes;
h1:HTMLAttributes;
h2:HTMLAttributes;
h3:HTMLAttributes;
h4:HTMLAttributes;
h5:HTMLAttributes;
h6:HTMLAttributes;
head:HTMLAttributes;
header:HTMLAttributes;
hr:HTMLAttributes;
html:HTMLAttributes;
i:HTMLAttributes;
iframe:HTMLAttributes;
img:HTMLAttributes;
input:HTMLAttributes;
ins:HTMLAttributes;
kbd:HTMLAttributes;
keygen:HTMLAttributes;
label:HTMLAttributes;
legend:HTMLAttributes;
li:HTMLAttributes;
link:HTMLAttributes;
main:HTMLAttributes;
map:HTMLAttributes;
mark:HTMLAttributes;
menu:HTMLAttributes;
menuitem:HTMLAttributes;
meta:HTMLAttributes;
meter:HTMLAttributes;
nav:HTMLAttributes;
noscript:HTMLAttributes;
object:HTMLAttributes;
ol:HTMLAttributes;
optgroup:HTMLAttributes;
option:HTMLAttributes;
output:HTMLAttributes;
p:HTMLAttributes;
param:HTMLAttributes;
picture:HTMLAttributes;
pre:HTMLAttributes;
progress:HTMLAttributes;
q:HTMLAttributes;
rp:HTMLAttributes;
rt:HTMLAttributes;
ruby:HTMLAttributes;
s:HTMLAttributes;
samp:HTMLAttributes;
script:HTMLAttributes;
section:HTMLAttributes;
select:HTMLAttributes;
slot:HTMLAttributes;
small:HTMLAttributes;
source:HTMLAttributes;
span:HTMLAttributes;
strong:HTMLAttributes;
style:HTMLAttributes;
sub:HTMLAttributes;
summary:HTMLAttributes;
sup:HTMLAttributes;
table:HTMLAttributes;
tbody:HTMLAttributes;
td:HTMLAttributes;
textarea:HTMLAttributes;
tfoot:HTMLAttributes;
th:HTMLAttributes;
thead:HTMLAttributes;
time:HTMLAttributes;
title:HTMLAttributes;
tr:HTMLAttributes;
track:HTMLAttributes;
u:HTMLAttributes;
ul:HTMLAttributes;
"var":HTMLAttributes;
video:HTMLAttributes;
wbr:HTMLAttributes;
//SVG
svg:SVGAttributes;
animate:SVGAttributes;
circle:SVGAttributes;
clipPath:SVGAttributes;
defs:SVGAttributes;
ellipse:SVGAttributes;
feBlend:SVGAttributes;
feColorMatrix:SVGAttributes;
feComponentTransfer:SVGAttributes;
feComposite:SVGAttributes;
feConvolveMatrix:SVGAttributes;
feDiffuseLighting:SVGAttributes;
feDisplacementMap:SVGAttributes;
feFlood:SVGAttributes;
feGaussianBlur:SVGAttributes;
feImage:SVGAttributes;
feMerge:SVGAttributes;
feMergeNode:SVGAttributes;
feMorphology:SVGAttributes;
feOffset:SVGAttributes;
feSpecularLighting:SVGAttributes;
feTile:SVGAttributes;
feTurbulence:SVGAttributes;
filter:SVGAttributes;
foreignObject:SVGAttributes;
g:SVGAttributes;
image:SVGAttributes;
line:SVGAttributes;
linearGradient:SVGAttributes;
marker:SVGAttributes;
mask:SVGAttributes;
path:SVGAttributes;
pattern:SVGAttributes;
polygon:SVGAttributes;
polyline:SVGAttributes;
radialGradient:SVGAttributes;
rect:SVGAttributes;
stop:SVGAttributes;
symbol:SVGAttributes;
text:SVGAttributes;
tspan:SVGAttributes;
use:SVGAttributes;
}
}

View File

@ -0,0 +1,964 @@
(function () {
'use strict';
/** Virtual DOM Node */
function VNode() {}
/** Global options
* @public
* @namespace options {Object}
*/
var options = {
/** If `true`, `prop` changes trigger synchronous component updates.
* @name syncComponentUpdates
* @type Boolean
* @default true
*/
//syncComponentUpdates: true,
/** Processes all created VNodes.
* @param {VNode} vnode A newly-created VNode to normalize/process
*/
//vnode(vnode) { }
/** Hook invoked after a component is mounted. */
// afterMount(component) { }
/** Hook invoked after the DOM is updated with a component's latest render. */
// afterUpdate(component) { }
/** Hook invoked immediately before a component is unmounted. */
// beforeUnmount(component) { }
};
var stack = [];
var EMPTY_CHILDREN = [];
/** JSX/hyperscript reviver
* Benchmarks: https://esbench.com/bench/57ee8f8e330ab09900a1a1a0
* @see http://jasonformat.com/wtf-is-jsx
* @public
*/
function h(nodeName, attributes) {
var children = EMPTY_CHILDREN,
lastSimple,
child,
simple,
i;
for (i = arguments.length; i-- > 2;) {
stack.push(arguments[i]);
}
if (attributes && attributes.children != null) {
if (!stack.length) stack.push(attributes.children);
delete attributes.children;
}
while (stack.length) {
if ((child = stack.pop()) && child.pop !== undefined) {
for (i = child.length; i--;) stack.push(child[i]);
} else {
if (child === true || child === false) child = null;
if (simple = typeof nodeName !== 'function') {
if (child == null) child = '';else if (typeof child === 'number') child = String(child);else if (typeof child !== 'string') simple = false;
}
if (simple && lastSimple) {
children[children.length - 1] += child;
} else if (children === EMPTY_CHILDREN) {
children = [child];
} else {
children.push(child);
}
lastSimple = simple;
}
}
var p = new VNode();
p.nodeName = nodeName;
p.children = children;
p.attributes = attributes == null ? undefined : attributes;
p.key = attributes == null ? undefined : attributes.key;
// if a "vnode hook" is defined, pass every created VNode to it
if (options.vnode !== undefined) options.vnode(p);
return p;
}
/** Copy own-properties from `props` onto `obj`.
* @returns obj
* @private
*/
function extend(obj, props) {
for (var i in props) {
obj[i] = props[i];
}return obj;
}
function cloneElement(vnode, props) {
return h(vnode.nodeName, extend(extend({}, vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children);
}
// DOM properties that should NOT have "px" added when numeric
var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
/** Managed queue of dirty components to be re-rendered */
var items = [];
function enqueueRender(component) {
if (!component._dirty && (component._dirty = true) && items.push(component) == 1) {
(options.debounceRendering || setTimeout)(rerender);
}
}
function rerender() {
var p,
list = items;
items = [];
while (p = list.pop()) {
if (p._dirty) renderComponent(p);
}
}
/** Check if two nodes are equivalent.
* @param {Element} node
* @param {VNode} vnode
* @private
*/
function isSameNodeType(node, vnode, hydrating) {
if (typeof vnode === 'string' || typeof vnode === 'number') {
return node.splitText !== undefined;
}
if (typeof vnode.nodeName === 'string') {
return !node._componentConstructor && isNamedNode(node, vnode.nodeName);
}
return hydrating || node._componentConstructor === vnode.nodeName;
}
/** Check if an Element has a given normalized name.
* @param {Element} node
* @param {String} nodeName
*/
function isNamedNode(node, nodeName) {
return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase();
}
/**
* Reconstruct Component-style `props` from a VNode.
* Ensures default/fallback values from `defaultProps`:
* Own-properties of `defaultProps` not present in `vnode.attributes` are added.
* @param {VNode} vnode
* @returns {Object} props
*/
function getNodeProps(vnode) {
var props = extend({}, vnode.attributes);
props.children = vnode.children;
var defaultProps = vnode.nodeName.defaultProps;
if (defaultProps !== undefined) {
for (var i in defaultProps) {
if (props[i] === undefined) {
props[i] = defaultProps[i];
}
}
}
return props;
}
/** Create an element with the given nodeName.
* @param {String} nodeName
* @param {Boolean} [isSvg=false] If `true`, creates an element within the SVG namespace.
* @returns {Element} node
*/
function createNode(nodeName, isSvg) {
var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);
node.normalizedNodeName = nodeName;
return node;
}
/** Remove a child node from its parent if attached.
* @param {Element} node The node to remove
*/
function removeNode(node) {
if (node.parentNode) node.parentNode.removeChild(node);
}
/** Set a named attribute on the given Node, with special behavior for some names and event handlers.
* If `value` is `null`, the attribute/handler will be removed.
* @param {Element} node An element to mutate
* @param {string} name The name/key to set, such as an event or attribute name
* @param {any} old The last value that was set for this name/node pair
* @param {any} value An attribute value, such as a function to be used as an event handler
* @param {Boolean} isSvg Are we currently diffing inside an svg?
* @private
*/
function setAccessor(node, name, old, value, isSvg) {
if (name === 'className') name = 'class';
if (name === 'key') {
// ignore
} else if (name === 'ref') {
if (old) old(null);
if (value) value(node);
} else if (name === 'class' && !isSvg) {
node.className = value || '';
} else if (name === 'style') {
if (!value || typeof value === 'string' || typeof old === 'string') {
node.style.cssText = value || '';
}
if (value && typeof value === 'object') {
if (typeof old !== 'string') {
for (var i in old) {
if (!(i in value)) node.style[i] = '';
}
}
for (var i in value) {
node.style[i] = typeof value[i] === 'number' && IS_NON_DIMENSIONAL.test(i) === false ? value[i] + 'px' : value[i];
}
}
} else if (name === 'dangerouslySetInnerHTML') {
if (value) node.innerHTML = value.__html || '';
} else if (name[0] == 'o' && name[1] == 'n') {
var useCapture = name !== (name = name.replace(/Capture$/, ''));
name = name.toLowerCase().substring(2);
if (value) {
if (!old) node.addEventListener(name, eventProxy, useCapture);
} else {
node.removeEventListener(name, eventProxy, useCapture);
}
(node._listeners || (node._listeners = {}))[name] = value;
} else if (name !== 'list' && name !== 'type' && !isSvg && name in node) {
setProperty(node, name, value == null ? '' : value);
if (value == null || value === false) node.removeAttribute(name);
} else {
var ns = isSvg && name !== (name = name.replace(/^xlink\:?/, ''));
if (value == null || value === false) {
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);
} else if (typeof value !== 'function') {
if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);else node.setAttribute(name, value);
}
}
}
/** Attempt to set a DOM property to the given value.
* IE & FF throw for certain property-value combinations.
*/
function setProperty(node, name, value) {
try {
node[name] = value;
} catch (e) {}
}
/** Proxy an event to hooked event handlers
* @private
*/
function eventProxy(e) {
return this._listeners[e.type](options.event && options.event(e) || e);
}
/** Queue of components that have been mounted and are awaiting componentDidMount */
var mounts = [];
/** Diff recursion count, used to track the end of the diff cycle. */
var diffLevel = 0;
/** Global flag indicating if the diff is currently within an SVG */
var isSvgMode = false;
/** Global flag indicating if the diff is performing hydration */
var hydrating = false;
/** Invoke queued componentDidMount lifecycle methods */
function flushMounts() {
var c;
while (c = mounts.pop()) {
if (options.afterMount) options.afterMount(c);
if (c.componentDidMount) c.componentDidMount();
}
}
/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.
* @param {Element} [dom=null] A DOM node to mutate into the shape of the `vnode`
* @param {VNode} vnode A VNode (with descendants forming a tree) representing the desired DOM structure
* @returns {Element} dom The created/mutated element
* @private
*/
function diff(dom, vnode, context, mountAll, parent, componentRoot) {
// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)
if (! diffLevel++) {
// when first starting the diff, check if we're diffing an SVG or within an SVG
isSvgMode = parent != null && parent.ownerSVGElement !== undefined;
// hydration is inidicated by the existing element to be diffed not having a prop cache
hydrating = dom != null && !('__preactattr_' in dom);
}
var ret = idiff(dom, vnode, context, mountAll, componentRoot);
// append the element if its a new parent
if (parent && ret.parentNode !== parent) parent.appendChild(ret);
// diffLevel being reduced to 0 means we're exiting the diff
if (! --diffLevel) {
hydrating = false;
// invoke queued componentDidMount lifecycle methods
if (!componentRoot) flushMounts();
}
return ret;
}
/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */
function idiff(dom, vnode, context, mountAll, componentRoot) {
var out = dom,
prevSvgMode = isSvgMode;
// empty values (null & undefined) render as empty Text nodes
if (vnode == null) vnode = '';
// Fast case: Strings create/update Text nodes.
if (typeof vnode === 'string') {
// update if it's already a Text node:
if (dom && dom.splitText !== undefined && dom.parentNode && (!dom._component || componentRoot)) {
if (dom.nodeValue != vnode) {
dom.nodeValue = vnode;
}
} else {
// it wasn't a Text node: replace it with one and recycle the old Element
out = document.createTextNode(vnode);
if (dom) {
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
recollectNodeTree(dom, true);
}
}
out['__preactattr_'] = true;
return out;
}
// If the VNode represents a Component, perform a component diff:
if (typeof vnode.nodeName === 'function') {
return buildComponentFromVNode(dom, vnode, context, mountAll);
}
// Tracks entering and exiting SVG namespace when descending through the tree.
isSvgMode = vnode.nodeName === 'svg' ? true : vnode.nodeName === 'foreignObject' ? false : isSvgMode;
// If there's no existing element or it's the wrong type, create a new one:
if (!dom || !isNamedNode(dom, String(vnode.nodeName))) {
out = createNode(String(vnode.nodeName), isSvgMode);
if (dom) {
// move children into the replacement node
while (dom.firstChild) out.appendChild(dom.firstChild);
// if the previous Element was mounted into the DOM, replace it inline
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
// recycle the old element (skips non-Element node types)
recollectNodeTree(dom, true);
}
}
var fc = out.firstChild,
props = out['__preactattr_'] || (out['__preactattr_'] = {}),
vchildren = vnode.children;
// Optimization: fast-path for elements containing a single TextNode:
if (!hydrating && vchildren && vchildren.length === 1 && typeof vchildren[0] === 'string' && fc != null && fc.splitText !== undefined && fc.nextSibling == null) {
if (fc.nodeValue != vchildren[0]) {
fc.nodeValue = vchildren[0];
}
}
// otherwise, if there are existing or new children, diff them:
else if (vchildren && vchildren.length || fc != null) {
innerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML != null);
}
// Apply attributes/props from VNode to the DOM Element:
diffAttributes(out, vnode.attributes, props);
// restore previous SVG mode: (in case we're exiting an SVG namespace)
isSvgMode = prevSvgMode;
return out;
}
/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.
* @param {Element} dom Element whose children should be compared & mutated
* @param {Array} vchildren Array of VNodes to compare to `dom.childNodes`
* @param {Object} context Implicitly descendant context object (from most recent `getChildContext()`)
* @param {Boolean} mountAll
* @param {Boolean} isHydrating If `true`, consumes externally created elements similar to hydration
*/
function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {
var originalChildren = dom.childNodes,
children = [],
keyed = {},
keyedLen = 0,
min = 0,
len = originalChildren.length,
childrenLen = 0,
vlen = vchildren ? vchildren.length : 0,
j,
c,
vchild,
child;
// Build up a map of keyed children and an Array of unkeyed children:
if (len !== 0) {
for (var i = 0; i < len; i++) {
var _child = originalChildren[i],
props = _child['__preactattr_'],
key = vlen && props ? _child._component ? _child._component.__key : props.key : null;
if (key != null) {
keyedLen++;
keyed[key] = _child;
} else if (props || (_child.splitText !== undefined ? isHydrating ? _child.nodeValue.trim() : true : isHydrating)) {
children[childrenLen++] = _child;
}
}
}
if (vlen !== 0) {
for (var i = 0; i < vlen; i++) {
vchild = vchildren[i];
child = null;
// attempt to find a node based on key matching
var key = vchild.key;
if (key != null) {
if (keyedLen && keyed[key] !== undefined) {
child = keyed[key];
keyed[key] = undefined;
keyedLen--;
}
}
// attempt to pluck a node of the same type from the existing children
else if (!child && min < childrenLen) {
for (j = min; j < childrenLen; j++) {
if (children[j] !== undefined && isSameNodeType(c = children[j], vchild, isHydrating)) {
child = c;
children[j] = undefined;
if (j === childrenLen - 1) childrenLen--;
if (j === min) min++;
break;
}
}
}
// morph the matched/found/created DOM child to match vchild (deep)
child = idiff(child, vchild, context, mountAll);
if (child && child !== dom) {
if (i >= len) {
dom.appendChild(child);
} else if (child !== originalChildren[i]) {
if (child === originalChildren[i + 1]) {
removeNode(originalChildren[i]);
} else {
dom.insertBefore(child, originalChildren[i] || null);
}
}
}
}
}
// remove unused keyed children:
if (keyedLen) {
for (var i in keyed) {
if (keyed[i] !== undefined) recollectNodeTree(keyed[i], false);
}
}
// remove orphaned unkeyed children:
while (min <= childrenLen) {
if ((child = children[childrenLen--]) !== undefined) recollectNodeTree(child, false);
}
}
/** Recursively recycle (or just unmount) a node an its descendants.
* @param {Node} node DOM node to start unmount/removal from
* @param {Boolean} [unmountOnly=false] If `true`, only triggers unmount lifecycle, skips removal
*/
function recollectNodeTree(node, unmountOnly) {
var component = node._component;
if (component) {
// if node is owned by a Component, unmount that component (ends up recursing back here)
unmountComponent(component);
} else {
// If the node's VNode had a ref function, invoke it with null here.
// (this is part of the React spec, and smart for unsetting references)
if (node['__preactattr_'] != null && node['__preactattr_'].ref) node['__preactattr_'].ref(null);
if (unmountOnly === false || node['__preactattr_'] == null) {
removeNode(node);
}
removeChildren(node);
}
}
/** Recollect/unmount all children.
* - we use .lastChild here because it causes less reflow than .firstChild
* - it's also cheaper than accessing the .childNodes Live NodeList
*/
function removeChildren(node) {
node = node.lastChild;
while (node) {
var next = node.previousSibling;
recollectNodeTree(node, true);
node = next;
}
}
/** Apply differences in attributes from a VNode to the given DOM Element.
* @param {Element} dom Element with attributes to diff `attrs` against
* @param {Object} attrs The desired end-state key-value attribute pairs
* @param {Object} old Current/previous attributes (from previous VNode or element's prop cache)
*/
function diffAttributes(dom, attrs, old) {
var name;
// remove attributes no longer present on the vnode by setting them to undefined
for (name in old) {
if (!(attrs && attrs[name] != null) && old[name] != null) {
setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);
}
}
// add new & update changed attributes
for (name in attrs) {
if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) {
setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
}
}
}
/** Retains a pool of Components for re-use, keyed on component name.
* Note: since component names are not unique or even necessarily available, these are primarily a form of sharding.
* @private
*/
var components = {};
/** Reclaim a component for later re-use by the recycler. */
function collectComponent(component) {
var name = component.constructor.name;
(components[name] || (components[name] = [])).push(component);
}
/** Create a component. Normalizes differences between PFC's and classful Components. */
function createComponent(Ctor, props, context) {
var list = components[Ctor.name],
inst;
if (Ctor.prototype && Ctor.prototype.render) {
inst = new Ctor(props, context);
Component.call(inst, props, context);
} else {
inst = new Component(props, context);
inst.constructor = Ctor;
inst.render = doRender;
}
if (list) {
for (var i = list.length; i--;) {
if (list[i].constructor === Ctor) {
inst.nextBase = list[i].nextBase;
list.splice(i, 1);
break;
}
}
}
return inst;
}
/** The `.render()` method for a PFC backing instance. */
function doRender(props, state, context) {
return this.constructor(props, context);
}
/** Set a component's `props` (generally derived from JSX attributes).
* @param {Object} props
* @param {Object} [opts]
* @param {boolean} [opts.renderSync=false] If `true` and {@link options.syncComponentUpdates} is `true`, triggers synchronous rendering.
* @param {boolean} [opts.render=true] If `false`, no render will be triggered.
*/
function setComponentProps(component, props, opts, context, mountAll) {
if (component._disable) return;
component._disable = true;
if (component.__ref = props.ref) delete props.ref;
if (component.__key = props.key) delete props.key;
if (!component.base || mountAll) {
if (component.componentWillMount) component.componentWillMount();
} else if (component.componentWillReceiveProps) {
component.componentWillReceiveProps(props, context);
}
if (context && context !== component.context) {
if (!component.prevContext) component.prevContext = component.context;
component.context = context;
}
if (!component.prevProps) component.prevProps = component.props;
component.props = props;
component._disable = false;
if (opts !== 0) {
if (opts === 1 || options.syncComponentUpdates !== false || !component.base) {
renderComponent(component, 1, mountAll);
} else {
enqueueRender(component);
}
}
if (component.__ref) component.__ref(component);
}
/** Render a Component, triggering necessary lifecycle events and taking High-Order Components into account.
* @param {Component} component
* @param {Object} [opts]
* @param {boolean} [opts.build=false] If `true`, component will build and store a DOM node if not already associated with one.
* @private
*/
function renderComponent(component, opts, mountAll, isChild) {
if (component._disable) return;
var props = component.props,
state = component.state,
context = component.context,
previousProps = component.prevProps || props,
previousState = component.prevState || state,
previousContext = component.prevContext || context,
isUpdate = component.base,
nextBase = component.nextBase,
initialBase = isUpdate || nextBase,
initialChildComponent = component._component,
skip = false,
rendered,
inst,
cbase;
// if updating
if (isUpdate) {
component.props = previousProps;
component.state = previousState;
component.context = previousContext;
if (opts !== 2 && component.shouldComponentUpdate && component.shouldComponentUpdate(props, state, context) === false) {
skip = true;
} else if (component.componentWillUpdate) {
component.componentWillUpdate(props, state, context);
}
component.props = props;
component.state = state;
component.context = context;
}
component.prevProps = component.prevState = component.prevContext = component.nextBase = null;
component._dirty = false;
if (!skip) {
rendered = component.render(props, state, context);
// context to pass to the child, can be updated via (grand-)parent component
if (component.getChildContext) {
context = extend(extend({}, context), component.getChildContext());
}
var childComponent = rendered && rendered.nodeName,
toUnmount,
base;
if (typeof childComponent === 'function') {
// set up high order component link
var childProps = getNodeProps(rendered);
inst = initialChildComponent;
if (inst && inst.constructor === childComponent && childProps.key == inst.__key) {
setComponentProps(inst, childProps, 1, context, false);
} else {
toUnmount = inst;
component._component = inst = createComponent(childComponent, childProps, context);
inst.nextBase = inst.nextBase || nextBase;
inst._parentComponent = component;
setComponentProps(inst, childProps, 0, context, false);
renderComponent(inst, 1, mountAll, true);
}
base = inst.base;
} else {
cbase = initialBase;
// destroy high order component link
toUnmount = initialChildComponent;
if (toUnmount) {
cbase = component._component = null;
}
if (initialBase || opts === 1) {
if (cbase) cbase._component = null;
base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, true);
}
}
if (initialBase && base !== initialBase && inst !== initialChildComponent) {
var baseParent = initialBase.parentNode;
if (baseParent && base !== baseParent) {
baseParent.replaceChild(base, initialBase);
if (!toUnmount) {
initialBase._component = null;
recollectNodeTree(initialBase, false);
}
}
}
if (toUnmount) {
unmountComponent(toUnmount);
}
component.base = base;
if (base && !isChild) {
var componentRef = component,
t = component;
while (t = t._parentComponent) {
(componentRef = t).base = base;
}
base._component = componentRef;
base._componentConstructor = componentRef.constructor;
}
}
if (!isUpdate || mountAll) {
mounts.unshift(component);
} else if (!skip) {
// Ensure that pending componentDidMount() hooks of child components
// are called before the componentDidUpdate() hook in the parent.
flushMounts();
if (component.componentDidUpdate) {
component.componentDidUpdate(previousProps, previousState, previousContext);
}
if (options.afterUpdate) options.afterUpdate(component);
}
if (component._renderCallbacks != null) {
while (component._renderCallbacks.length) component._renderCallbacks.pop().call(component);
}
if (!diffLevel && !isChild) flushMounts();
}
/** Apply the Component referenced by a VNode to the DOM.
* @param {Element} dom The DOM node to mutate
* @param {VNode} vnode A Component-referencing VNode
* @returns {Element} dom The created/mutated element
* @private
*/
function buildComponentFromVNode(dom, vnode, context, mountAll) {
var c = dom && dom._component,
originalComponent = c,
oldDom = dom,
isDirectOwner = c && dom._componentConstructor === vnode.nodeName,
isOwner = isDirectOwner,
props = getNodeProps(vnode);
while (c && !isOwner && (c = c._parentComponent)) {
isOwner = c.constructor === vnode.nodeName;
}
if (c && isOwner && (!mountAll || c._component)) {
setComponentProps(c, props, 3, context, mountAll);
dom = c.base;
} else {
if (originalComponent && !isDirectOwner) {
unmountComponent(originalComponent);
dom = oldDom = null;
}
c = createComponent(vnode.nodeName, props, context);
if (dom && !c.nextBase) {
c.nextBase = dom;
// passing dom/oldDom as nextBase will recycle it if unused, so bypass recycling on L229:
oldDom = null;
}
setComponentProps(c, props, 1, context, mountAll);
dom = c.base;
if (oldDom && dom !== oldDom) {
oldDom._component = null;
recollectNodeTree(oldDom, false);
}
}
return dom;
}
/** Remove a component from the DOM and recycle it.
* @param {Component} component The Component instance to unmount
* @private
*/
function unmountComponent(component) {
if (options.beforeUnmount) options.beforeUnmount(component);
var base = component.base;
component._disable = true;
if (component.componentWillUnmount) component.componentWillUnmount();
component.base = null;
// recursively tear down & recollect high-order component children:
var inner = component._component;
if (inner) {
unmountComponent(inner);
} else if (base) {
if (base['__preactattr_'] && base['__preactattr_'].ref) base['__preactattr_'].ref(null);
component.nextBase = base;
removeNode(base);
collectComponent(component);
removeChildren(base);
}
if (component.__ref) component.__ref(null);
}
/** Base Component class.
* Provides `setState()` and `forceUpdate()`, which trigger rendering.
* @public
*
* @example
* class MyFoo extends Component {
* render(props, state) {
* return <div />;
* }
* }
*/
function Component(props, context) {
this._dirty = true;
/** @public
* @type {object}
*/
this.context = context;
/** @public
* @type {object}
*/
this.props = props;
/** @public
* @type {object}
*/
this.state = this.state || {};
}
extend(Component.prototype, {
/** Returns a `boolean` indicating if the component should re-render when receiving the given `props` and `state`.
* @param {object} nextProps
* @param {object} nextState
* @param {object} nextContext
* @returns {Boolean} should the component re-render
* @name shouldComponentUpdate
* @function
*/
/** Update component state by copying properties from `state` to `this.state`.
* @param {object} state A hash of state properties to update with new values
* @param {function} callback A function to be called once component state is updated
*/
setState: function setState(state, callback) {
var s = this.state;
if (!this.prevState) this.prevState = extend({}, s);
extend(s, typeof state === 'function' ? state(s, this.props) : state);
if (callback) (this._renderCallbacks = this._renderCallbacks || []).push(callback);
enqueueRender(this);
},
/** Immediately perform a synchronous re-render of the component.
* @param {function} callback A function to be called after component is re-rendered.
* @private
*/
forceUpdate: function forceUpdate(callback) {
if (callback) (this._renderCallbacks = this._renderCallbacks || []).push(callback);
renderComponent(this, 2);
},
/** 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 (if a parent component has provided context)
* @returns VNode
*/
render: function render() {}
});
/** Render JSX into a `parent` Element.
* @param {VNode} vnode A (JSX) VNode to render
* @param {Element} parent DOM element to render into
* @param {Element} [merge] Attempt to re-use an existing DOM tree rooted at `merge`
* @public
*
* @example
* // render a div into <body>:
* render(<div id="hello">hello!</div>, document.body);
*
* @example
* // render a "Thing" component into #foo:
* const Thing = ({ name }) => <span>{ name }</span>;
* render(<Thing name="one" />, document.querySelector('#foo'));
*/
function render(vnode, parent, merge) {
return diff(merge, vnode, {}, false, parent, false);
}
var preact = {
h: h,
createElement: h,
cloneElement: cloneElement,
Component: Component,
render: render,
rerender: rerender,
options: options
};
if (typeof module != 'undefined') module.exports = preact;else self.preact = preact;
}());
//# sourceMappingURL=preact.dev.js.map

File diff suppressed because one or more lines are too long

400
static/js/ketcher2/node_modules/preact/dist/preact.js generated vendored Normal file
View File

@ -0,0 +1,400 @@
!function() {
'use strict';
function VNode() {}
function h(nodeName, attributes) {
var lastSimple, child, simple, i, children = EMPTY_CHILDREN;
for (i = arguments.length; i-- > 2; ) stack.push(arguments[i]);
if (attributes && null != attributes.children) {
if (!stack.length) stack.push(attributes.children);
delete attributes.children;
}
while (stack.length) if ((child = stack.pop()) && void 0 !== child.pop) for (i = child.length; i--; ) stack.push(child[i]); else {
if (child === !0 || child === !1) child = null;
if (simple = 'function' != typeof nodeName) if (null == child) child = ''; else if ('number' == typeof child) child = String(child); else if ('string' != typeof child) simple = !1;
if (simple && lastSimple) children[children.length - 1] += child; else if (children === EMPTY_CHILDREN) children = [ child ]; else children.push(child);
lastSimple = simple;
}
var p = new VNode();
p.nodeName = nodeName;
p.children = children;
p.attributes = null == attributes ? void 0 : attributes;
p.key = null == attributes ? void 0 : attributes.key;
if (void 0 !== options.vnode) options.vnode(p);
return p;
}
function extend(obj, props) {
for (var i in props) obj[i] = props[i];
return obj;
}
function cloneElement(vnode, props) {
return h(vnode.nodeName, extend(extend({}, vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children);
}
function enqueueRender(component) {
if (!component.__d && (component.__d = !0) && 1 == items.push(component)) (options.debounceRendering || setTimeout)(rerender);
}
function rerender() {
var p, list = items;
items = [];
while (p = list.pop()) if (p.__d) renderComponent(p);
}
function isSameNodeType(node, vnode, hydrating) {
if ('string' == typeof vnode || 'number' == typeof vnode) return void 0 !== node.splitText;
if ('string' == typeof vnode.nodeName) return !node._componentConstructor && isNamedNode(node, vnode.nodeName); else return hydrating || node._componentConstructor === vnode.nodeName;
}
function isNamedNode(node, nodeName) {
return node.__n === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase();
}
function getNodeProps(vnode) {
var props = extend({}, vnode.attributes);
props.children = vnode.children;
var defaultProps = vnode.nodeName.defaultProps;
if (void 0 !== defaultProps) for (var i in defaultProps) if (void 0 === props[i]) props[i] = defaultProps[i];
return props;
}
function createNode(nodeName, isSvg) {
var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);
node.__n = nodeName;
return node;
}
function removeNode(node) {
if (node.parentNode) node.parentNode.removeChild(node);
}
function setAccessor(node, name, old, value, isSvg) {
if ('className' === name) name = 'class';
if ('key' === name) ; else if ('ref' === name) {
if (old) old(null);
if (value) value(node);
} else if ('class' === name && !isSvg) node.className = value || ''; else if ('style' === name) {
if (!value || 'string' == typeof value || 'string' == typeof old) node.style.cssText = value || '';
if (value && 'object' == typeof value) {
if ('string' != typeof old) for (var i in old) if (!(i in value)) node.style[i] = '';
for (var i in value) node.style[i] = 'number' == typeof value[i] && IS_NON_DIMENSIONAL.test(i) === !1 ? value[i] + 'px' : value[i];
}
} else if ('dangerouslySetInnerHTML' === name) {
if (value) node.innerHTML = value.__html || '';
} else if ('o' == name[0] && 'n' == name[1]) {
var useCapture = name !== (name = name.replace(/Capture$/, ''));
name = name.toLowerCase().substring(2);
if (value) {
if (!old) node.addEventListener(name, eventProxy, useCapture);
} else node.removeEventListener(name, eventProxy, useCapture);
(node.__l || (node.__l = {}))[name] = value;
} else if ('list' !== name && 'type' !== name && !isSvg && name in node) {
setProperty(node, name, null == value ? '' : value);
if (null == value || value === !1) node.removeAttribute(name);
} else {
var ns = isSvg && name !== (name = name.replace(/^xlink\:?/, ''));
if (null == value || value === !1) if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase()); else node.removeAttribute(name); else if ('function' != typeof value) if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value); else node.setAttribute(name, value);
}
}
function setProperty(node, name, value) {
try {
node[name] = value;
} catch (e) {}
}
function eventProxy(e) {
return this.__l[e.type](options.event && options.event(e) || e);
}
function flushMounts() {
var c;
while (c = mounts.pop()) {
if (options.afterMount) options.afterMount(c);
if (c.componentDidMount) c.componentDidMount();
}
}
function diff(dom, vnode, context, mountAll, parent, componentRoot) {
if (!diffLevel++) {
isSvgMode = null != parent && void 0 !== parent.ownerSVGElement;
hydrating = null != dom && !('__preactattr_' in dom);
}
var ret = idiff(dom, vnode, context, mountAll, componentRoot);
if (parent && ret.parentNode !== parent) parent.appendChild(ret);
if (!--diffLevel) {
hydrating = !1;
if (!componentRoot) flushMounts();
}
return ret;
}
function idiff(dom, vnode, context, mountAll, componentRoot) {
var out = dom, prevSvgMode = isSvgMode;
if (null == vnode) vnode = '';
if ('string' == typeof vnode) {
if (dom && void 0 !== dom.splitText && dom.parentNode && (!dom._component || componentRoot)) {
if (dom.nodeValue != vnode) dom.nodeValue = vnode;
} else {
out = document.createTextNode(vnode);
if (dom) {
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
recollectNodeTree(dom, !0);
}
}
out.__preactattr_ = !0;
return out;
}
if ('function' == typeof vnode.nodeName) return buildComponentFromVNode(dom, vnode, context, mountAll);
isSvgMode = 'svg' === vnode.nodeName ? !0 : 'foreignObject' === vnode.nodeName ? !1 : isSvgMode;
if (!dom || !isNamedNode(dom, String(vnode.nodeName))) {
out = createNode(String(vnode.nodeName), isSvgMode);
if (dom) {
while (dom.firstChild) out.appendChild(dom.firstChild);
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
recollectNodeTree(dom, !0);
}
}
var fc = out.firstChild, props = out.__preactattr_ || (out.__preactattr_ = {}), vchildren = vnode.children;
if (!hydrating && vchildren && 1 === vchildren.length && 'string' == typeof vchildren[0] && null != fc && void 0 !== fc.splitText && null == fc.nextSibling) {
if (fc.nodeValue != vchildren[0]) fc.nodeValue = vchildren[0];
} else if (vchildren && vchildren.length || null != fc) innerDiffNode(out, vchildren, context, mountAll, hydrating || null != props.dangerouslySetInnerHTML);
diffAttributes(out, vnode.attributes, props);
isSvgMode = prevSvgMode;
return out;
}
function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {
var j, c, vchild, child, originalChildren = dom.childNodes, children = [], keyed = {}, keyedLen = 0, min = 0, len = originalChildren.length, childrenLen = 0, vlen = vchildren ? vchildren.length : 0;
if (0 !== len) for (var i = 0; i < len; i++) {
var _child = originalChildren[i], props = _child.__preactattr_, key = vlen && props ? _child._component ? _child._component.__k : props.key : null;
if (null != key) {
keyedLen++;
keyed[key] = _child;
} else if (props || (void 0 !== _child.splitText ? isHydrating ? _child.nodeValue.trim() : !0 : isHydrating)) children[childrenLen++] = _child;
}
if (0 !== vlen) for (var i = 0; i < vlen; i++) {
vchild = vchildren[i];
child = null;
var key = vchild.key;
if (null != key) {
if (keyedLen && void 0 !== keyed[key]) {
child = keyed[key];
keyed[key] = void 0;
keyedLen--;
}
} else if (!child && min < childrenLen) for (j = min; j < childrenLen; j++) if (void 0 !== children[j] && isSameNodeType(c = children[j], vchild, isHydrating)) {
child = c;
children[j] = void 0;
if (j === childrenLen - 1) childrenLen--;
if (j === min) min++;
break;
}
child = idiff(child, vchild, context, mountAll);
if (child && child !== dom) if (i >= len) dom.appendChild(child); else if (child !== originalChildren[i]) if (child === originalChildren[i + 1]) removeNode(originalChildren[i]); else dom.insertBefore(child, originalChildren[i] || null);
}
if (keyedLen) for (var i in keyed) if (void 0 !== keyed[i]) recollectNodeTree(keyed[i], !1);
while (min <= childrenLen) if (void 0 !== (child = children[childrenLen--])) recollectNodeTree(child, !1);
}
function recollectNodeTree(node, unmountOnly) {
var component = node._component;
if (component) unmountComponent(component); else {
if (null != node.__preactattr_ && node.__preactattr_.ref) node.__preactattr_.ref(null);
if (unmountOnly === !1 || null == node.__preactattr_) removeNode(node);
removeChildren(node);
}
}
function removeChildren(node) {
node = node.lastChild;
while (node) {
var next = node.previousSibling;
recollectNodeTree(node, !0);
node = next;
}
}
function diffAttributes(dom, attrs, old) {
var name;
for (name in old) if ((!attrs || null == attrs[name]) && null != old[name]) setAccessor(dom, name, old[name], old[name] = void 0, isSvgMode);
for (name in attrs) if (!('children' === name || 'innerHTML' === name || name in old && attrs[name] === ('value' === name || 'checked' === name ? dom[name] : old[name]))) setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
}
function collectComponent(component) {
var name = component.constructor.name;
(components[name] || (components[name] = [])).push(component);
}
function createComponent(Ctor, props, context) {
var inst, list = components[Ctor.name];
if (Ctor.prototype && Ctor.prototype.render) {
inst = new Ctor(props, context);
Component.call(inst, props, context);
} else {
inst = new Component(props, context);
inst.constructor = Ctor;
inst.render = doRender;
}
if (list) for (var i = list.length; i--; ) if (list[i].constructor === Ctor) {
inst.__b = list[i].__b;
list.splice(i, 1);
break;
}
return inst;
}
function doRender(props, state, context) {
return this.constructor(props, context);
}
function setComponentProps(component, props, opts, context, mountAll) {
if (!component.__x) {
component.__x = !0;
if (component.__r = props.ref) delete props.ref;
if (component.__k = props.key) delete props.key;
if (!component.base || mountAll) {
if (component.componentWillMount) component.componentWillMount();
} else if (component.componentWillReceiveProps) component.componentWillReceiveProps(props, context);
if (context && context !== component.context) {
if (!component.__c) component.__c = component.context;
component.context = context;
}
if (!component.__p) component.__p = component.props;
component.props = props;
component.__x = !1;
if (0 !== opts) if (1 === opts || options.syncComponentUpdates !== !1 || !component.base) renderComponent(component, 1, mountAll); else enqueueRender(component);
if (component.__r) component.__r(component);
}
}
function renderComponent(component, opts, mountAll, isChild) {
if (!component.__x) {
var rendered, inst, cbase, props = component.props, state = component.state, context = component.context, previousProps = component.__p || props, previousState = component.__s || state, previousContext = component.__c || context, isUpdate = component.base, nextBase = component.__b, initialBase = isUpdate || nextBase, initialChildComponent = component._component, skip = !1;
if (isUpdate) {
component.props = previousProps;
component.state = previousState;
component.context = previousContext;
if (2 !== opts && component.shouldComponentUpdate && component.shouldComponentUpdate(props, state, context) === !1) skip = !0; else if (component.componentWillUpdate) component.componentWillUpdate(props, state, context);
component.props = props;
component.state = state;
component.context = context;
}
component.__p = component.__s = component.__c = component.__b = null;
component.__d = !1;
if (!skip) {
rendered = component.render(props, state, context);
if (component.getChildContext) context = extend(extend({}, context), component.getChildContext());
var toUnmount, base, childComponent = rendered && rendered.nodeName;
if ('function' == typeof childComponent) {
var childProps = getNodeProps(rendered);
inst = initialChildComponent;
if (inst && inst.constructor === childComponent && childProps.key == inst.__k) setComponentProps(inst, childProps, 1, context, !1); else {
toUnmount = inst;
component._component = inst = createComponent(childComponent, childProps, context);
inst.__b = inst.__b || nextBase;
inst.__u = component;
setComponentProps(inst, childProps, 0, context, !1);
renderComponent(inst, 1, mountAll, !0);
}
base = inst.base;
} else {
cbase = initialBase;
toUnmount = initialChildComponent;
if (toUnmount) cbase = component._component = null;
if (initialBase || 1 === opts) {
if (cbase) cbase._component = null;
base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, !0);
}
}
if (initialBase && base !== initialBase && inst !== initialChildComponent) {
var baseParent = initialBase.parentNode;
if (baseParent && base !== baseParent) {
baseParent.replaceChild(base, initialBase);
if (!toUnmount) {
initialBase._component = null;
recollectNodeTree(initialBase, !1);
}
}
}
if (toUnmount) unmountComponent(toUnmount);
component.base = base;
if (base && !isChild) {
var componentRef = component, t = component;
while (t = t.__u) (componentRef = t).base = base;
base._component = componentRef;
base._componentConstructor = componentRef.constructor;
}
}
if (!isUpdate || mountAll) mounts.unshift(component); else if (!skip) {
flushMounts();
if (component.componentDidUpdate) component.componentDidUpdate(previousProps, previousState, previousContext);
if (options.afterUpdate) options.afterUpdate(component);
}
if (null != component.__h) while (component.__h.length) component.__h.pop().call(component);
if (!diffLevel && !isChild) flushMounts();
}
}
function buildComponentFromVNode(dom, vnode, context, mountAll) {
var c = dom && dom._component, originalComponent = c, oldDom = dom, isDirectOwner = c && dom._componentConstructor === vnode.nodeName, isOwner = isDirectOwner, props = getNodeProps(vnode);
while (c && !isOwner && (c = c.__u)) isOwner = c.constructor === vnode.nodeName;
if (c && isOwner && (!mountAll || c._component)) {
setComponentProps(c, props, 3, context, mountAll);
dom = c.base;
} else {
if (originalComponent && !isDirectOwner) {
unmountComponent(originalComponent);
dom = oldDom = null;
}
c = createComponent(vnode.nodeName, props, context);
if (dom && !c.__b) {
c.__b = dom;
oldDom = null;
}
setComponentProps(c, props, 1, context, mountAll);
dom = c.base;
if (oldDom && dom !== oldDom) {
oldDom._component = null;
recollectNodeTree(oldDom, !1);
}
}
return dom;
}
function unmountComponent(component) {
if (options.beforeUnmount) options.beforeUnmount(component);
var base = component.base;
component.__x = !0;
if (component.componentWillUnmount) component.componentWillUnmount();
component.base = null;
var inner = component._component;
if (inner) unmountComponent(inner); else if (base) {
if (base.__preactattr_ && base.__preactattr_.ref) base.__preactattr_.ref(null);
component.__b = base;
removeNode(base);
collectComponent(component);
removeChildren(base);
}
if (component.__r) component.__r(null);
}
function Component(props, context) {
this.__d = !0;
this.context = context;
this.props = props;
this.state = this.state || {};
}
function render(vnode, parent, merge) {
return diff(merge, vnode, {}, !1, parent, !1);
}
var options = {};
var stack = [];
var EMPTY_CHILDREN = [];
var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
var items = [];
var mounts = [];
var diffLevel = 0;
var isSvgMode = !1;
var hydrating = !1;
var components = {};
extend(Component.prototype, {
setState: function(state, callback) {
var s = this.state;
if (!this.__s) this.__s = extend({}, s);
extend(s, 'function' == typeof state ? state(s, this.props) : state);
if (callback) (this.__h = this.__h || []).push(callback);
enqueueRender(this);
},
forceUpdate: function(callback) {
if (callback) (this.__h = this.__h || []).push(callback);
renderComponent(this, 2);
},
render: function() {}
});
var preact = {
h: h,
createElement: h,
cloneElement: cloneElement,
Component: Component,
render: render,
rerender: rerender,
options: options
};
if ('undefined' != typeof module) module.exports = preact; else self.preact = preact;
}();
//# sourceMappingURL=preact.js.map

View File

@ -0,0 +1,9 @@
/* @flow */
import { createElement as h, cloneElement, Component, render } from 'react';
export { h, cloneElement, Component, render };
export default { h, cloneElement, Component, render };
declare export function rerender(): void;
declare export var options: Object;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

146
static/js/ketcher2/node_modules/preact/package.json generated vendored Normal file
View File

@ -0,0 +1,146 @@
{
"_from": "preact@8.1.0",
"_id": "preact@8.1.0",
"_inBundle": false,
"_integrity": "sha1-8DW4CO67dORtViRrAsoPGQttZXQ=",
"_location": "/preact",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "preact@8.1.0",
"name": "preact",
"escapedName": "preact",
"rawSpec": "8.1.0",
"saveSpec": null,
"fetchSpec": "8.1.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/preact/-/preact-8.1.0.tgz",
"_shasum": "f035b808eebb74e46d56246b02ca0f190b6d6574",
"_spec": "preact@8.1.0",
"_where": "/home/manfred/enviPath/ketcher2/ketcher",
"author": {
"name": "Jason Miller",
"email": "jason@developit.ca"
},
"bugs": {
"url": "https://github.com/developit/preact/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Fast 3kb React alternative with the same ES6 API. Components & Virtual DOM.",
"dev:main": "dist/preact.dev.js",
"devDependencies": {
"babel": "^5.8.23",
"babel-core": "^5.8.24",
"babel-eslint": "^6.1.0",
"babel-loader": "^5.3.2",
"babel-runtime": "^5.8.24",
"chai": "^3.4.1",
"copyfiles": "^1.0.0",
"core-js": "^2.4.1",
"coveralls": "^2.11.15",
"cross-env": "^3.1.3",
"diff": "^3.0.0",
"eslint": "^3.0.0",
"eslint-plugin-react": "^6.0.0",
"gzip-size-cli": "^1.0.0",
"isparta-loader": "^2.0.0",
"jscodeshift": "^0.3.25",
"karma": "^1.1.0",
"karma-babel-preprocessor": "^5.2.2",
"karma-chai": "^0.1.0",
"karma-chai-sinon": "^0.1.5",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.0.0",
"karma-mocha": "^1.1.1",
"karma-mocha-reporter": "^2.0.4",
"karma-phantomjs-launcher": "^1.0.1",
"karma-sauce-launcher": "^1.1.0",
"karma-source-map-support": "^1.1.0",
"karma-sourcemap-loader": "^0.3.6",
"karma-webpack": "^2.0.1",
"mocha": "^3.0.1",
"npm-run-all": "^4.0.0",
"phantomjs-prebuilt": "^2.1.7",
"rimraf": "^2.5.3",
"rollup": "^0.40.0",
"rollup-plugin-babel": "^1.0.0",
"rollup-plugin-memory": "^2.0.0",
"rollup-plugin-node-resolve": "^2.0.0",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"typescript": "^2.2.2",
"uglify-js": "^2.7.5",
"webpack": "^1.13.1"
},
"eslintConfig": {
"extends": "./config/eslint-config.js"
},
"files": [
"devtools",
"src",
"dist",
"devtools.js",
"devtools.js.map",
"typings.json"
],
"greenkeeper": {
"ignore": [
"rollup-plugin-babel",
"babel",
"babel-core",
"babel-eslint",
"babel-loader",
"babel-runtime",
"jscodeshift"
]
},
"homepage": "https://github.com/developit/preact",
"jsnext:main": "src/preact.js",
"keywords": [
"preact",
"react",
"virtual dom",
"vdom",
"components",
"virtual",
"dom"
],
"license": "MIT",
"main": "dist/preact.js",
"minified:main": "dist/preact.min.js",
"name": "preact",
"repository": {
"type": "git",
"url": "git+https://github.com/developit/preact.git"
},
"scripts": {
"build": "npm-run-all --silent clean transpile copy-flow-definition copy-typescript-definition strip optimize minify size",
"clean": "rimraf dist/ devtools.js devtools.js.map",
"copy-flow-definition": "copyfiles -f src/preact.js.flow dist",
"copy-typescript-definition": "copyfiles -f src/preact.d.ts dist",
"lint": "eslint devtools src test",
"minify": "uglifyjs dist/preact.js -c collapse_vars,evaluate,screw_ie8,unsafe,loops=false,keep_fargs=false,pure_getters,unused,dead_code -m -o dist/preact.min.js -p relative --in-source-map dist/preact.js.map --source-map dist/preact.min.js.map",
"optimize": "uglifyjs dist/preact.dev.js -c conditionals=false,sequences=false,loops=false,join_vars=false,collapse_vars=false --pure-funcs=Object.defineProperty --mangle-props --mangle-regex=\"/^(_|normalizedNodeName|nextBase|prev[CPS]|_parentC)/\" --name-cache config/properties.json -b width=120,quote_style=3 -o dist/preact.js -p relative --in-source-map dist/preact.dev.js.map --source-map dist/preact.js.map",
"prepublish": "npm run build",
"release": "cross-env npm run smart-release",
"size": "node -e \"process.stdout.write('gzip size: ')\" && gzip-size dist/preact.min.js",
"smart-release": "npm run build && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish",
"strip": "jscodeshift --run-in-band -s -t config/codemod-strip-tdz.js dist/preact.dev.js && jscodeshift --run-in-band -s -t config/codemod-const.js dist/preact.dev.js",
"test": "npm-run-all lint --parallel test:mocha test:karma test:ts",
"test:karma": "karma start test/karma.conf.js --single-run",
"test:karma:watch": "npm run test:karma -- no-single-run",
"test:mocha": "mocha --recursive --compilers js:babel/register test/shared test/node",
"test:mocha:watch": "npm run test:mocha -- --watch",
"test:ts": "tsc -p test/ts/",
"transpile": "npm-run-all transpile:main transpile:devtools",
"transpile:devtools": "rollup -c config/rollup.config.devtools.js -o devtools.js -m devtools.js.map",
"transpile:main": "rollup -c config/rollup.config.js -m dist/preact.dev.js.map -n preact -o dist/preact.dev.js"
},
"typings": "./dist/preact.d.ts",
"version": "8.1.0"
}

View File

@ -0,0 +1,10 @@
import { extend } from './util';
import { h } from './h';
export function cloneElement(vnode, props) {
return h(
vnode.nodeName,
extend(extend({}, vnode.attributes), props),
arguments.length>2 ? [].slice.call(arguments, 2) : vnode.children
);
}

View File

@ -0,0 +1,81 @@
import { FORCE_RENDER } from './constants';
import { extend } from './util';
import { renderComponent } from './vdom/component';
import { enqueueRender } from './render-queue';
/** Base Component class.
* Provides `setState()` and `forceUpdate()`, which trigger rendering.
* @public
*
* @example
* class MyFoo extends Component {
* render(props, state) {
* return <div />;
* }
* }
*/
export function Component(props, context) {
this._dirty = true;
/** @public
* @type {object}
*/
this.context = context;
/** @public
* @type {object}
*/
this.props = props;
/** @public
* @type {object}
*/
this.state = this.state || {};
}
extend(Component.prototype, {
/** Returns a `boolean` indicating if the component should re-render when receiving the given `props` and `state`.
* @param {object} nextProps
* @param {object} nextState
* @param {object} nextContext
* @returns {Boolean} should the component re-render
* @name shouldComponentUpdate
* @function
*/
/** Update component state by copying properties from `state` to `this.state`.
* @param {object} state A hash of state properties to update with new values
* @param {function} callback A function to be called once component state is updated
*/
setState(state, callback) {
let s = this.state;
if (!this.prevState) this.prevState = extend({}, s);
extend(s, typeof state==='function' ? state(s, this.props) : state);
if (callback) (this._renderCallbacks = (this._renderCallbacks || [])).push(callback);
enqueueRender(this);
},
/** Immediately perform a synchronous re-render of the component.
* @param {function} callback A function to be called after component is re-rendered.
* @private
*/
forceUpdate(callback) {
if (callback) (this._renderCallbacks = (this._renderCallbacks || [])).push(callback);
renderComponent(this, FORCE_RENDER);
},
/** 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 (if a parent component has provided context)
* @returns VNode
*/
render() {}
});

View File

@ -0,0 +1,13 @@
// render modes
export const NO_RENDER = 0;
export const SYNC_RENDER = 1;
export const FORCE_RENDER = 2;
export const ASYNC_RENDER = 3;
export const ATTR_KEY = '__preactattr_';
// DOM properties that should NOT have "px" added when numeric
export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;

108
static/js/ketcher2/node_modules/preact/src/dom/index.js generated vendored Normal file
View File

@ -0,0 +1,108 @@
import { IS_NON_DIMENSIONAL } from '../constants';
import options from '../options';
/** Create an element with the given nodeName.
* @param {String} nodeName
* @param {Boolean} [isSvg=false] If `true`, creates an element within the SVG namespace.
* @returns {Element} node
*/
export function createNode(nodeName, isSvg) {
let node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);
node.normalizedNodeName = nodeName;
return node;
}
/** Remove a child node from its parent if attached.
* @param {Element} node The node to remove
*/
export function removeNode(node) {
if (node.parentNode) node.parentNode.removeChild(node);
}
/** Set a named attribute on the given Node, with special behavior for some names and event handlers.
* If `value` is `null`, the attribute/handler will be removed.
* @param {Element} node An element to mutate
* @param {string} name The name/key to set, such as an event or attribute name
* @param {any} old The last value that was set for this name/node pair
* @param {any} value An attribute value, such as a function to be used as an event handler
* @param {Boolean} isSvg Are we currently diffing inside an svg?
* @private
*/
export function setAccessor(node, name, old, value, isSvg) {
if (name==='className') name = 'class';
if (name==='key') {
// ignore
}
else if (name==='ref') {
if (old) old(null);
if (value) value(node);
}
else if (name==='class' && !isSvg) {
node.className = value || '';
}
else if (name==='style') {
if (!value || typeof value==='string' || typeof old==='string') {
node.style.cssText = value || '';
}
if (value && typeof value==='object') {
if (typeof old!=='string') {
for (let i in old) if (!(i in value)) node.style[i] = '';
}
for (let i in value) {
node.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];
}
}
}
else if (name==='dangerouslySetInnerHTML') {
if (value) node.innerHTML = value.__html || '';
}
else if (name[0]=='o' && name[1]=='n') {
let useCapture = name !== (name=name.replace(/Capture$/, ''));
name = name.toLowerCase().substring(2);
if (value) {
if (!old) node.addEventListener(name, eventProxy, useCapture);
}
else {
node.removeEventListener(name, eventProxy, useCapture);
}
(node._listeners || (node._listeners = {}))[name] = value;
}
else if (name!=='list' && name!=='type' && !isSvg && name in node) {
setProperty(node, name, value==null ? '' : value);
if (value==null || value===false) node.removeAttribute(name);
}
else {
let ns = isSvg && (name !== (name = name.replace(/^xlink\:?/, '')));
if (value==null || value===false) {
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());
else node.removeAttribute(name);
}
else if (typeof value!=='function') {
if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);
else node.setAttribute(name, value);
}
}
}
/** Attempt to set a DOM property to the given value.
* IE & FF throw for certain property-value combinations.
*/
function setProperty(node, name, value) {
try {
node[name] = value;
} catch (e) { }
}
/** Proxy an event to hooked event handlers
* @private
*/
function eventProxy(e) {
return this._listeners[e.type](options.event && options.event(e) || e);
}

60
static/js/ketcher2/node_modules/preact/src/h.js generated vendored Normal file
View File

@ -0,0 +1,60 @@
import { VNode } from './vnode';
import options from './options';
const stack = [];
const EMPTY_CHILDREN = [];
/** JSX/hyperscript reviver
* Benchmarks: https://esbench.com/bench/57ee8f8e330ab09900a1a1a0
* @see http://jasonformat.com/wtf-is-jsx
* @public
*/
export function h(nodeName, attributes) {
let children=EMPTY_CHILDREN, lastSimple, child, simple, i;
for (i=arguments.length; i-- > 2; ) {
stack.push(arguments[i]);
}
if (attributes && attributes.children!=null) {
if (!stack.length) stack.push(attributes.children);
delete attributes.children;
}
while (stack.length) {
if ((child = stack.pop()) && child.pop!==undefined) {
for (i=child.length; i--; ) stack.push(child[i]);
}
else {
if (child===true || child===false) child = null;
if ((simple = typeof nodeName!=='function')) {
if (child==null) child = '';
else if (typeof child==='number') child = String(child);
else if (typeof child!=='string') simple = false;
}
if (simple && lastSimple) {
children[children.length-1] += child;
}
else if (children===EMPTY_CHILDREN) {
children = [child];
}
else {
children.push(child);
}
lastSimple = simple;
}
}
let p = new VNode();
p.nodeName = nodeName;
p.children = children;
p.attributes = attributes==null ? undefined : attributes;
p.key = attributes==null ? undefined : attributes.key;
// if a "vnode hook" is defined, pass every created VNode to it
if (options.vnode!==undefined) options.vnode(p);
return p;
}

27
static/js/ketcher2/node_modules/preact/src/options.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
/** Global options
* @public
* @namespace options {Object}
*/
export default {
/** If `true`, `prop` changes trigger synchronous component updates.
* @name syncComponentUpdates
* @type Boolean
* @default true
*/
//syncComponentUpdates: true,
/** Processes all created VNodes.
* @param {VNode} vnode A newly-created VNode to normalize/process
*/
//vnode(vnode) { }
/** Hook invoked after a component is mounted. */
// afterMount(component) { }
/** Hook invoked after the DOM is updated with a component's latest render. */
// afterUpdate(component) { }
/** Hook invoked immediately before a component is unmounted. */
// beforeUnmount(component) { }
};

754
static/js/ketcher2/node_modules/preact/src/preact.d.ts generated vendored Normal file
View File

@ -0,0 +1,754 @@
declare namespace preact {
interface ComponentProps<C extends Component<any, any> | FunctionalComponent<any>> {
children?:JSX.Element[];
key?:string | number | any;
ref?:(el: C) => void;
}
interface DangerouslySetInnerHTML {
__html: string;
}
interface PreactHTMLAttributes {
dangerouslySetInnerHTML?:DangerouslySetInnerHTML;
key?:string;
ref?:(el?: Element) => void;
}
interface VNode {
nodeName:ComponentConstructor<any, any>|string;
attributes:{[name:string]:any};
children:VNode[];
key:string;
}
interface ComponentLifecycle<PropsType, StateType> {
componentWillMount?():void;
componentDidMount?():void;
componentWillUnmount?():void;
componentWillReceiveProps?(nextProps:PropsType,nextContext:any):void;
shouldComponentUpdate?(nextProps:PropsType,nextState:StateType,nextContext:any):boolean;
componentWillUpdate?(nextProps:PropsType,nextState:StateType,nextContext:any):void;
componentDidUpdate?(previousProps:PropsType,previousState:StateType,previousContext:any):void;
}
interface FunctionalComponent<PropsType> {
(props?:PropsType & ComponentProps<this>, context?:any):JSX.Element;
displayName?:string;
defaultProps?:any;
}
interface ComponentConstructor<PropsType, StateType> {
new (props?:PropsType, context?: any):Component<PropsType, StateType>;
}
// Type alias for a component considered generally, whether stateless or stateful.
type AnyComponent<PropsType, StateType> = FunctionalComponent<PropsType> | typeof Component;
abstract class Component<PropsType, StateType> implements ComponentLifecycle<PropsType, StateType> {
constructor(props?:PropsType, context?:any);
static displayName?:string;
static defaultProps?:any;
state:StateType;
props:PropsType & ComponentProps<this>;
context:any;
base:HTMLElement;
linkState:(name:string) => (event: Event) => void;
setState<K extends keyof StateType>(state:Pick<StateType, K>, callback?:() => void):void;
setState<K extends keyof StateType>(fn:(prevState:StateType, props:PropsType) => Pick<StateType, K>, callback?:() => void):void;
forceUpdate(callback?:() => void): void;
abstract render(props?:PropsType & ComponentProps<this>, state?:StateType, context?:any):JSX.Element;
}
function h<PropsType>(node:ComponentConstructor<PropsType, any> | FunctionalComponent<PropsType>, params:PropsType, ...children:(JSX.Element|JSX.Element[]|string)[]):JSX.Element;
function h(node:string, params:JSX.HTMLAttributes&JSX.SVGAttributes&{[propName: string]: any}, ...children:(JSX.Element|JSX.Element[]|string)[]):JSX.Element;
function render(node:JSX.Element, parent:Element|Document, mergeWith?:Element):Element;
function rerender():void;
function cloneElement(element:JSX.Element, props:any):JSX.Element;
var options:{
syncComponentUpdates?:boolean;
debounceRendering?:(render:() => void) => void;
vnode?:(vnode:VNode) => void;
event?:(event:Event) => Event;
};
}
declare module "preact" {
export = preact;
}
declare module "preact/devtools" {
// Empty. This module initializes the React Developer Tools integration
// when imported.
}
declare namespace JSX {
interface Element extends preact.VNode {
}
interface ElementClass extends preact.Component<any, any> {
}
interface ElementAttributesProperty {
props:any;
}
interface SVGAttributes extends HTMLAttributes {
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;
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;
}
interface EventHandler<E extends Event> {
(event:E):void;
}
type ClipboardEventHandler = EventHandler<ClipboardEvent>;
type CompositionEventHandler = EventHandler<CompositionEvent>;
type DragEventHandler = EventHandler<DragEvent>;
type FocusEventHandler = EventHandler<FocusEvent>;
type KeyboardEventHandler = EventHandler<KeyboardEvent>;
type MouseEventHandler = EventHandler<MouseEvent>;
type TouchEventHandler = EventHandler<TouchEvent>;
type UIEventHandler = EventHandler<UIEvent>;
type WheelEventHandler = EventHandler<WheelEvent>;
type AnimationEventHandler = EventHandler<AnimationEvent>;
type TransitionEventHandler = EventHandler<TransitionEvent>;
type GenericEventHandler = EventHandler<Event>;
interface DOMAttributes {
// Clipboard Events
onCopy?:ClipboardEventHandler;
onCut?:ClipboardEventHandler;
onPaste?:ClipboardEventHandler;
// Composition Events
onCompositionEnd?:CompositionEventHandler;
onCompositionStart?:CompositionEventHandler;
onCompositionUpdate?:CompositionEventHandler;
// Focus Events
onFocus?:FocusEventHandler;
onBlur?:FocusEventHandler;
// Form Events
onChange?:GenericEventHandler;
onInput?:GenericEventHandler;
onSubmit?:GenericEventHandler;
// Keyboard Events
onKeyDown?:KeyboardEventHandler;
onKeyPress?:KeyboardEventHandler;
onKeyUp?:KeyboardEventHandler;
// Media Events
onAbort?:GenericEventHandler;
onCanPlay?:GenericEventHandler;
onCanPlayThrough?:GenericEventHandler;
onDurationChange?:GenericEventHandler;
onEmptied?:GenericEventHandler;
onEncrypted?:GenericEventHandler;
onEnded?:GenericEventHandler;
onLoadedData?:GenericEventHandler;
onLoadedMetadata?:GenericEventHandler;
onLoadStart?:GenericEventHandler;
onPause?:GenericEventHandler;
onPlay?:GenericEventHandler;
onPlaying?:GenericEventHandler;
onProgress?:GenericEventHandler;
onRateChange?:GenericEventHandler;
onSeeked?:GenericEventHandler;
onSeeking?:GenericEventHandler;
onStalled?:GenericEventHandler;
onSuspend?:GenericEventHandler;
onTimeUpdate?:GenericEventHandler;
onVolumeChange?:GenericEventHandler;
onWaiting?:GenericEventHandler;
// MouseEvents
onClick?:MouseEventHandler;
onContextMenu?:MouseEventHandler;
onDoubleClick?:MouseEventHandler;
onDrag?:DragEventHandler;
onDragEnd?:DragEventHandler;
onDragEnter?:DragEventHandler;
onDragExit?:DragEventHandler;
onDragLeave?:DragEventHandler;
onDragOver?:DragEventHandler;
onDragStart?:DragEventHandler;
onDrop?:DragEventHandler;
onMouseDown?:MouseEventHandler;
onMouseEnter?:MouseEventHandler;
onMouseLeave?:MouseEventHandler;
onMouseMove?:MouseEventHandler;
onMouseOut?:MouseEventHandler;
onMouseOver?:MouseEventHandler;
onMouseUp?:MouseEventHandler;
// Selection Events
onSelect?:GenericEventHandler;
// Touch Events
onTouchCancel?:TouchEventHandler;
onTouchEnd?:TouchEventHandler;
onTouchMove?:TouchEventHandler;
onTouchStart?:TouchEventHandler;
// UI Events
onScroll?:UIEventHandler;
// Wheel Events
onWheel?:WheelEventHandler;
// Animation Events
onAnimationStart?:AnimationEventHandler;
onAnimationEnd?:AnimationEventHandler;
onAnimationIteration?:AnimationEventHandler;
// Transition Events
onTransitionEnd?:TransitionEventHandler;
}
interface HTMLAttributes extends preact.PreactHTMLAttributes, DOMAttributes {
// Standard HTML Attributes
accept?:string;
acceptCharset?:string;
accessKey?:string;
action?:string;
allowFullScreen?:boolean;
allowTransparency?:boolean;
alt?:string;
async?:boolean;
autocomplete?:string;
autofocus?:boolean;
autoPlay?:boolean;
capture?:boolean;
cellPadding?:number | string;
cellSpacing?:number | string;
charSet?:string;
challenge?:string;
checked?:boolean;
class?:string | { [key:string]: boolean };
className?:string | { [key:string]: boolean };
cols?:number;
colSpan?:number;
content?:string;
contentEditable?:boolean;
contextMenu?:string;
controls?:boolean;
coords?:string;
crossOrigin?:string;
data?:string;
dateTime?:string;
default?:boolean;
defer?:boolean;
dir?:string;
disabled?: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;
httpEquiv?:string;
icon?:string;
id?:string;
inputMode?:string;
integrity?:string;
is?:string;
keyParams?:string;
keyType?:string;
kind?:string;
label?:string;
lang?:string;
list?:string;
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;
noValidate?:boolean;
open?:boolean;
optimum?:number;
pattern?:string;
placeholder?:string;
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?:any;
summary?:string;
tabIndex?:number;
target?:string;
title?:string;
type?:string;
useMap?:string;
value?:string | string[];
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;
}
interface IntrinsicElements {
// HTML
a:HTMLAttributes;
abbr:HTMLAttributes;
address:HTMLAttributes;
area:HTMLAttributes;
article:HTMLAttributes;
aside:HTMLAttributes;
audio:HTMLAttributes;
b:HTMLAttributes;
base:HTMLAttributes;
bdi:HTMLAttributes;
bdo:HTMLAttributes;
big:HTMLAttributes;
blockquote:HTMLAttributes;
body:HTMLAttributes;
br:HTMLAttributes;
button:HTMLAttributes;
canvas:HTMLAttributes;
caption:HTMLAttributes;
cite:HTMLAttributes;
code:HTMLAttributes;
col:HTMLAttributes;
colgroup:HTMLAttributes;
data:HTMLAttributes;
datalist:HTMLAttributes;
dd:HTMLAttributes;
del:HTMLAttributes;
details:HTMLAttributes;
dfn:HTMLAttributes;
dialog:HTMLAttributes;
div:HTMLAttributes;
dl:HTMLAttributes;
dt:HTMLAttributes;
em:HTMLAttributes;
embed:HTMLAttributes;
fieldset:HTMLAttributes;
figcaption:HTMLAttributes;
figure:HTMLAttributes;
footer:HTMLAttributes;
form:HTMLAttributes;
h1:HTMLAttributes;
h2:HTMLAttributes;
h3:HTMLAttributes;
h4:HTMLAttributes;
h5:HTMLAttributes;
h6:HTMLAttributes;
head:HTMLAttributes;
header:HTMLAttributes;
hr:HTMLAttributes;
html:HTMLAttributes;
i:HTMLAttributes;
iframe:HTMLAttributes;
img:HTMLAttributes;
input:HTMLAttributes;
ins:HTMLAttributes;
kbd:HTMLAttributes;
keygen:HTMLAttributes;
label:HTMLAttributes;
legend:HTMLAttributes;
li:HTMLAttributes;
link:HTMLAttributes;
main:HTMLAttributes;
map:HTMLAttributes;
mark:HTMLAttributes;
menu:HTMLAttributes;
menuitem:HTMLAttributes;
meta:HTMLAttributes;
meter:HTMLAttributes;
nav:HTMLAttributes;
noscript:HTMLAttributes;
object:HTMLAttributes;
ol:HTMLAttributes;
optgroup:HTMLAttributes;
option:HTMLAttributes;
output:HTMLAttributes;
p:HTMLAttributes;
param:HTMLAttributes;
picture:HTMLAttributes;
pre:HTMLAttributes;
progress:HTMLAttributes;
q:HTMLAttributes;
rp:HTMLAttributes;
rt:HTMLAttributes;
ruby:HTMLAttributes;
s:HTMLAttributes;
samp:HTMLAttributes;
script:HTMLAttributes;
section:HTMLAttributes;
select:HTMLAttributes;
slot:HTMLAttributes;
small:HTMLAttributes;
source:HTMLAttributes;
span:HTMLAttributes;
strong:HTMLAttributes;
style:HTMLAttributes;
sub:HTMLAttributes;
summary:HTMLAttributes;
sup:HTMLAttributes;
table:HTMLAttributes;
tbody:HTMLAttributes;
td:HTMLAttributes;
textarea:HTMLAttributes;
tfoot:HTMLAttributes;
th:HTMLAttributes;
thead:HTMLAttributes;
time:HTMLAttributes;
title:HTMLAttributes;
tr:HTMLAttributes;
track:HTMLAttributes;
u:HTMLAttributes;
ul:HTMLAttributes;
"var":HTMLAttributes;
video:HTMLAttributes;
wbr:HTMLAttributes;
//SVG
svg:SVGAttributes;
animate:SVGAttributes;
circle:SVGAttributes;
clipPath:SVGAttributes;
defs:SVGAttributes;
ellipse:SVGAttributes;
feBlend:SVGAttributes;
feColorMatrix:SVGAttributes;
feComponentTransfer:SVGAttributes;
feComposite:SVGAttributes;
feConvolveMatrix:SVGAttributes;
feDiffuseLighting:SVGAttributes;
feDisplacementMap:SVGAttributes;
feFlood:SVGAttributes;
feGaussianBlur:SVGAttributes;
feImage:SVGAttributes;
feMerge:SVGAttributes;
feMergeNode:SVGAttributes;
feMorphology:SVGAttributes;
feOffset:SVGAttributes;
feSpecularLighting:SVGAttributes;
feTile:SVGAttributes;
feTurbulence:SVGAttributes;
filter:SVGAttributes;
foreignObject:SVGAttributes;
g:SVGAttributes;
image:SVGAttributes;
line:SVGAttributes;
linearGradient:SVGAttributes;
marker:SVGAttributes;
mask:SVGAttributes;
path:SVGAttributes;
pattern:SVGAttributes;
polygon:SVGAttributes;
polyline:SVGAttributes;
radialGradient:SVGAttributes;
rect:SVGAttributes;
stop:SVGAttributes;
symbol:SVGAttributes;
text:SVGAttributes;
tspan:SVGAttributes;
use:SVGAttributes;
}
}

26
static/js/ketcher2/node_modules/preact/src/preact.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
import { h, h as createElement } from './h';
import { cloneElement } from './clone-element';
import { Component } from './component';
import { render } from './render';
import { rerender } from './render-queue';
import options from './options';
export default {
h,
createElement,
cloneElement,
Component,
render,
rerender,
options
};
export {
h,
createElement,
cloneElement,
Component,
render,
rerender,
options
};

View File

@ -0,0 +1,9 @@
/* @flow */
import { createElement as h, cloneElement, Component, render } from 'react';
export { h, cloneElement, Component, render };
export default { h, cloneElement, Component, render };
declare export function rerender(): void;
declare export var options: Object;

View File

@ -0,0 +1,21 @@
import options from './options';
import { renderComponent } from './vdom/component';
/** Managed queue of dirty components to be re-rendered */
let items = [];
export function enqueueRender(component) {
if (!component._dirty && (component._dirty = true) && items.push(component)==1) {
(options.debounceRendering || setTimeout)(rerender);
}
}
export function rerender() {
let p, list = items;
items = [];
while ( (p = list.pop()) ) {
if (p._dirty) renderComponent(p);
}
}

20
static/js/ketcher2/node_modules/preact/src/render.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
import { diff } from './vdom/diff';
/** Render JSX into a `parent` Element.
* @param {VNode} vnode A (JSX) VNode to render
* @param {Element} parent DOM element to render into
* @param {Element} [merge] Attempt to re-use an existing DOM tree rooted at `merge`
* @public
*
* @example
* // render a div into <body>:
* render(<div id="hello">hello!</div>, document.body);
*
* @example
* // render a "Thing" component into #foo:
* const Thing = ({ name }) => <span>{ name }</span>;
* render(<Thing name="one" />, document.querySelector('#foo'));
*/
export function render(vnode, parent, merge) {
return diff(merge, vnode, {}, false, parent, false);
}

10
static/js/ketcher2/node_modules/preact/src/util.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
/** Copy own-properties from `props` onto `obj`.
* @returns obj
* @private
*/
export function extend(obj, props) {
for (let i in props) obj[i] = props[i];
return obj;
}

View File

@ -0,0 +1,49 @@
import { Component } from '../component';
/** Retains a pool of Components for re-use, keyed on component name.
* Note: since component names are not unique or even necessarily available, these are primarily a form of sharding.
* @private
*/
const components = {};
/** Reclaim a component for later re-use by the recycler. */
export function collectComponent(component) {
let name = component.constructor.name;
(components[name] || (components[name] = [])).push(component);
}
/** Create a component. Normalizes differences between PFC's and classful Components. */
export function createComponent(Ctor, props, context) {
let list = components[Ctor.name],
inst;
if (Ctor.prototype && Ctor.prototype.render) {
inst = new Ctor(props, context);
Component.call(inst, props, context);
}
else {
inst = new Component(props, context);
inst.constructor = Ctor;
inst.render = doRender;
}
if (list) {
for (let i=list.length; i--; ) {
if (list[i].constructor===Ctor) {
inst.nextBase = list[i].nextBase;
list.splice(i, 1);
break;
}
}
}
return inst;
}
/** The `.render()` method for a PFC backing instance. */
function doRender(props, state, context) {
return this.constructor(props, context);
}

View File

@ -0,0 +1,274 @@
import { SYNC_RENDER, NO_RENDER, FORCE_RENDER, ASYNC_RENDER, ATTR_KEY } from '../constants';
import options from '../options';
import { extend } from '../util';
import { enqueueRender } from '../render-queue';
import { getNodeProps } from './index';
import { diff, mounts, diffLevel, flushMounts, recollectNodeTree, removeChildren } from './diff';
import { createComponent, collectComponent } from './component-recycler';
import { removeNode } from '../dom';
/** Set a component's `props` (generally derived from JSX attributes).
* @param {Object} props
* @param {Object} [opts]
* @param {boolean} [opts.renderSync=false] If `true` and {@link options.syncComponentUpdates} is `true`, triggers synchronous rendering.
* @param {boolean} [opts.render=true] If `false`, no render will be triggered.
*/
export function setComponentProps(component, props, opts, context, mountAll) {
if (component._disable) return;
component._disable = true;
if ((component.__ref = props.ref)) delete props.ref;
if ((component.__key = props.key)) delete props.key;
if (!component.base || mountAll) {
if (component.componentWillMount) component.componentWillMount();
}
else if (component.componentWillReceiveProps) {
component.componentWillReceiveProps(props, context);
}
if (context && context!==component.context) {
if (!component.prevContext) component.prevContext = component.context;
component.context = context;
}
if (!component.prevProps) component.prevProps = component.props;
component.props = props;
component._disable = false;
if (opts!==NO_RENDER) {
if (opts===SYNC_RENDER || options.syncComponentUpdates!==false || !component.base) {
renderComponent(component, SYNC_RENDER, mountAll);
}
else {
enqueueRender(component);
}
}
if (component.__ref) component.__ref(component);
}
/** Render a Component, triggering necessary lifecycle events and taking High-Order Components into account.
* @param {Component} component
* @param {Object} [opts]
* @param {boolean} [opts.build=false] If `true`, component will build and store a DOM node if not already associated with one.
* @private
*/
export function renderComponent(component, opts, mountAll, isChild) {
if (component._disable) return;
let props = component.props,
state = component.state,
context = component.context,
previousProps = component.prevProps || props,
previousState = component.prevState || state,
previousContext = component.prevContext || context,
isUpdate = component.base,
nextBase = component.nextBase,
initialBase = isUpdate || nextBase,
initialChildComponent = component._component,
skip = false,
rendered, inst, cbase;
// if updating
if (isUpdate) {
component.props = previousProps;
component.state = previousState;
component.context = previousContext;
if (opts!==FORCE_RENDER
&& component.shouldComponentUpdate
&& component.shouldComponentUpdate(props, state, context) === false) {
skip = true;
}
else if (component.componentWillUpdate) {
component.componentWillUpdate(props, state, context);
}
component.props = props;
component.state = state;
component.context = context;
}
component.prevProps = component.prevState = component.prevContext = component.nextBase = null;
component._dirty = false;
if (!skip) {
rendered = component.render(props, state, context);
// context to pass to the child, can be updated via (grand-)parent component
if (component.getChildContext) {
context = extend(extend({}, context), component.getChildContext());
}
let childComponent = rendered && rendered.nodeName,
toUnmount, base;
if (typeof childComponent==='function') {
// set up high order component link
let childProps = getNodeProps(rendered);
inst = initialChildComponent;
if (inst && inst.constructor===childComponent && childProps.key==inst.__key) {
setComponentProps(inst, childProps, SYNC_RENDER, context, false);
}
else {
toUnmount = inst;
component._component = inst = createComponent(childComponent, childProps, context);
inst.nextBase = inst.nextBase || nextBase;
inst._parentComponent = component;
setComponentProps(inst, childProps, NO_RENDER, context, false);
renderComponent(inst, SYNC_RENDER, mountAll, true);
}
base = inst.base;
}
else {
cbase = initialBase;
// destroy high order component link
toUnmount = initialChildComponent;
if (toUnmount) {
cbase = component._component = null;
}
if (initialBase || opts===SYNC_RENDER) {
if (cbase) cbase._component = null;
base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, true);
}
}
if (initialBase && base!==initialBase && inst!==initialChildComponent) {
let baseParent = initialBase.parentNode;
if (baseParent && base!==baseParent) {
baseParent.replaceChild(base, initialBase);
if (!toUnmount) {
initialBase._component = null;
recollectNodeTree(initialBase, false);
}
}
}
if (toUnmount) {
unmountComponent(toUnmount);
}
component.base = base;
if (base && !isChild) {
let componentRef = component,
t = component;
while ((t=t._parentComponent)) {
(componentRef = t).base = base;
}
base._component = componentRef;
base._componentConstructor = componentRef.constructor;
}
}
if (!isUpdate || mountAll) {
mounts.unshift(component);
}
else if (!skip) {
// Ensure that pending componentDidMount() hooks of child components
// are called before the componentDidUpdate() hook in the parent.
flushMounts();
if (component.componentDidUpdate) {
component.componentDidUpdate(previousProps, previousState, previousContext);
}
if (options.afterUpdate) options.afterUpdate(component);
}
if (component._renderCallbacks!=null) {
while (component._renderCallbacks.length) component._renderCallbacks.pop().call(component);
}
if (!diffLevel && !isChild) flushMounts();
}
/** Apply the Component referenced by a VNode to the DOM.
* @param {Element} dom The DOM node to mutate
* @param {VNode} vnode A Component-referencing VNode
* @returns {Element} dom The created/mutated element
* @private
*/
export function buildComponentFromVNode(dom, vnode, context, mountAll) {
let c = dom && dom._component,
originalComponent = c,
oldDom = dom,
isDirectOwner = c && dom._componentConstructor===vnode.nodeName,
isOwner = isDirectOwner,
props = getNodeProps(vnode);
while (c && !isOwner && (c=c._parentComponent)) {
isOwner = c.constructor===vnode.nodeName;
}
if (c && isOwner && (!mountAll || c._component)) {
setComponentProps(c, props, ASYNC_RENDER, context, mountAll);
dom = c.base;
}
else {
if (originalComponent && !isDirectOwner) {
unmountComponent(originalComponent);
dom = oldDom = null;
}
c = createComponent(vnode.nodeName, props, context);
if (dom && !c.nextBase) {
c.nextBase = dom;
// passing dom/oldDom as nextBase will recycle it if unused, so bypass recycling on L229:
oldDom = null;
}
setComponentProps(c, props, SYNC_RENDER, context, mountAll);
dom = c.base;
if (oldDom && dom!==oldDom) {
oldDom._component = null;
recollectNodeTree(oldDom, false);
}
}
return dom;
}
/** Remove a component from the DOM and recycle it.
* @param {Component} component The Component instance to unmount
* @private
*/
export function unmountComponent(component) {
if (options.beforeUnmount) options.beforeUnmount(component);
let base = component.base;
component._disable = true;
if (component.componentWillUnmount) component.componentWillUnmount();
component.base = null;
// recursively tear down & recollect high-order component children:
let inner = component._component;
if (inner) {
unmountComponent(inner);
}
else if (base) {
if (base[ATTR_KEY] && base[ATTR_KEY].ref) base[ATTR_KEY].ref(null);
component.nextBase = base;
removeNode(base);
collectComponent(component);
removeChildren(base);
}
if (component.__ref) component.__ref(null);
}

303
static/js/ketcher2/node_modules/preact/src/vdom/diff.js generated vendored Normal file
View File

@ -0,0 +1,303 @@
import { ATTR_KEY } from '../constants';
import { isSameNodeType, isNamedNode } from './index';
import { buildComponentFromVNode } from './component';
import { createNode, setAccessor } from '../dom/index';
import { unmountComponent } from './component';
import options from '../options';
import { removeNode } from '../dom';
/** Queue of components that have been mounted and are awaiting componentDidMount */
export const mounts = [];
/** Diff recursion count, used to track the end of the diff cycle. */
export let diffLevel = 0;
/** Global flag indicating if the diff is currently within an SVG */
let isSvgMode = false;
/** Global flag indicating if the diff is performing hydration */
let hydrating = false;
/** Invoke queued componentDidMount lifecycle methods */
export function flushMounts() {
let c;
while ((c=mounts.pop())) {
if (options.afterMount) options.afterMount(c);
if (c.componentDidMount) c.componentDidMount();
}
}
/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.
* @param {Element} [dom=null] A DOM node to mutate into the shape of the `vnode`
* @param {VNode} vnode A VNode (with descendants forming a tree) representing the desired DOM structure
* @returns {Element} dom The created/mutated element
* @private
*/
export function diff(dom, vnode, context, mountAll, parent, componentRoot) {
// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)
if (!diffLevel++) {
// when first starting the diff, check if we're diffing an SVG or within an SVG
isSvgMode = parent!=null && parent.ownerSVGElement!==undefined;
// hydration is inidicated by the existing element to be diffed not having a prop cache
hydrating = dom!=null && !(ATTR_KEY in dom);
}
let ret = idiff(dom, vnode, context, mountAll, componentRoot);
// append the element if its a new parent
if (parent && ret.parentNode!==parent) parent.appendChild(ret);
// diffLevel being reduced to 0 means we're exiting the diff
if (!--diffLevel) {
hydrating = false;
// invoke queued componentDidMount lifecycle methods
if (!componentRoot) flushMounts();
}
return ret;
}
/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */
function idiff(dom, vnode, context, mountAll, componentRoot) {
let out = dom,
prevSvgMode = isSvgMode;
// empty values (null & undefined) render as empty Text nodes
if (vnode==null) vnode = '';
// Fast case: Strings create/update Text nodes.
if (typeof vnode==='string') {
// update if it's already a Text node:
if (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {
if (dom.nodeValue!=vnode) {
dom.nodeValue = vnode;
}
}
else {
// it wasn't a Text node: replace it with one and recycle the old Element
out = document.createTextNode(vnode);
if (dom) {
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
recollectNodeTree(dom, true);
}
}
out[ATTR_KEY] = true;
return out;
}
// If the VNode represents a Component, perform a component diff:
if (typeof vnode.nodeName==='function') {
return buildComponentFromVNode(dom, vnode, context, mountAll);
}
// Tracks entering and exiting SVG namespace when descending through the tree.
isSvgMode = vnode.nodeName==='svg' ? true : vnode.nodeName==='foreignObject' ? false : isSvgMode;
// If there's no existing element or it's the wrong type, create a new one:
if (!dom || !isNamedNode(dom, String(vnode.nodeName))) {
out = createNode(String(vnode.nodeName), isSvgMode);
if (dom) {
// move children into the replacement node
while (dom.firstChild) out.appendChild(dom.firstChild);
// if the previous Element was mounted into the DOM, replace it inline
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
// recycle the old element (skips non-Element node types)
recollectNodeTree(dom, true);
}
}
let fc = out.firstChild,
props = out[ATTR_KEY] || (out[ATTR_KEY] = {}),
vchildren = vnode.children;
// Optimization: fast-path for elements containing a single TextNode:
if (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {
if (fc.nodeValue!=vchildren[0]) {
fc.nodeValue = vchildren[0];
}
}
// otherwise, if there are existing or new children, diff them:
else if (vchildren && vchildren.length || fc!=null) {
innerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);
}
// Apply attributes/props from VNode to the DOM Element:
diffAttributes(out, vnode.attributes, props);
// restore previous SVG mode: (in case we're exiting an SVG namespace)
isSvgMode = prevSvgMode;
return out;
}
/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.
* @param {Element} dom Element whose children should be compared & mutated
* @param {Array} vchildren Array of VNodes to compare to `dom.childNodes`
* @param {Object} context Implicitly descendant context object (from most recent `getChildContext()`)
* @param {Boolean} mountAll
* @param {Boolean} isHydrating If `true`, consumes externally created elements similar to hydration
*/
function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {
let originalChildren = dom.childNodes,
children = [],
keyed = {},
keyedLen = 0,
min = 0,
len = originalChildren.length,
childrenLen = 0,
vlen = vchildren ? vchildren.length : 0,
j, c, vchild, child;
// Build up a map of keyed children and an Array of unkeyed children:
if (len!==0) {
for (let i=0; i<len; i++) {
let child = originalChildren[i],
props = child[ATTR_KEY],
key = vlen && props ? child._component ? child._component.__key : props.key : null;
if (key!=null) {
keyedLen++;
keyed[key] = child;
}
else if (props || (child.splitText!==undefined ? (isHydrating ? child.nodeValue.trim() : true) : isHydrating)) {
children[childrenLen++] = child;
}
}
}
if (vlen!==0) {
for (let i=0; i<vlen; i++) {
vchild = vchildren[i];
child = null;
// attempt to find a node based on key matching
let key = vchild.key;
if (key!=null) {
if (keyedLen && keyed[key]!==undefined) {
child = keyed[key];
keyed[key] = undefined;
keyedLen--;
}
}
// attempt to pluck a node of the same type from the existing children
else if (!child && min<childrenLen) {
for (j=min; j<childrenLen; j++) {
if (children[j]!==undefined && isSameNodeType(c = children[j], vchild, isHydrating)) {
child = c;
children[j] = undefined;
if (j===childrenLen-1) childrenLen--;
if (j===min) min++;
break;
}
}
}
// morph the matched/found/created DOM child to match vchild (deep)
child = idiff(child, vchild, context, mountAll);
if (child && child!==dom) {
if (i>=len) {
dom.appendChild(child);
}
else if (child!==originalChildren[i]) {
if (child===originalChildren[i+1]) {
removeNode(originalChildren[i]);
}
else {
dom.insertBefore(child, originalChildren[i] || null);
}
}
}
}
}
// remove unused keyed children:
if (keyedLen) {
for (let i in keyed) if (keyed[i]!==undefined) recollectNodeTree(keyed[i], false);
}
// remove orphaned unkeyed children:
while (min<=childrenLen) {
if ((child = children[childrenLen--])!==undefined) recollectNodeTree(child, false);
}
}
/** Recursively recycle (or just unmount) a node an its descendants.
* @param {Node} node DOM node to start unmount/removal from
* @param {Boolean} [unmountOnly=false] If `true`, only triggers unmount lifecycle, skips removal
*/
export function recollectNodeTree(node, unmountOnly) {
let component = node._component;
if (component) {
// if node is owned by a Component, unmount that component (ends up recursing back here)
unmountComponent(component);
}
else {
// If the node's VNode had a ref function, invoke it with null here.
// (this is part of the React spec, and smart for unsetting references)
if (node[ATTR_KEY]!=null && node[ATTR_KEY].ref) node[ATTR_KEY].ref(null);
if (unmountOnly===false || node[ATTR_KEY]==null) {
removeNode(node);
}
removeChildren(node);
}
}
/** Recollect/unmount all children.
* - we use .lastChild here because it causes less reflow than .firstChild
* - it's also cheaper than accessing the .childNodes Live NodeList
*/
export function removeChildren(node) {
node = node.lastChild;
while (node) {
let next = node.previousSibling;
recollectNodeTree(node, true);
node = next;
}
}
/** Apply differences in attributes from a VNode to the given DOM Element.
* @param {Element} dom Element with attributes to diff `attrs` against
* @param {Object} attrs The desired end-state key-value attribute pairs
* @param {Object} old Current/previous attributes (from previous VNode or element's prop cache)
*/
function diffAttributes(dom, attrs, old) {
let name;
// remove attributes no longer present on the vnode by setting them to undefined
for (name in old) {
if (!(attrs && attrs[name]!=null) && old[name]!=null) {
setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);
}
}
// add new & update changed attributes
for (name in attrs) {
if (name!=='children' && name!=='innerHTML' && (!(name in old) || attrs[name]!==(name==='value' || name==='checked' ? dom[name] : old[name]))) {
setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
}
}
}

View File

@ -0,0 +1,50 @@
import { extend } from '../util';
/** Check if two nodes are equivalent.
* @param {Element} node
* @param {VNode} vnode
* @private
*/
export function isSameNodeType(node, vnode, hydrating) {
if (typeof vnode==='string' || typeof vnode==='number') {
return node.splitText!==undefined;
}
if (typeof vnode.nodeName==='string') {
return !node._componentConstructor && isNamedNode(node, vnode.nodeName);
}
return hydrating || node._componentConstructor===vnode.nodeName;
}
/** Check if an Element has a given normalized name.
* @param {Element} node
* @param {String} nodeName
*/
export function isNamedNode(node, nodeName) {
return node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();
}
/**
* Reconstruct Component-style `props` from a VNode.
* Ensures default/fallback values from `defaultProps`:
* Own-properties of `defaultProps` not present in `vnode.attributes` are added.
* @param {VNode} vnode
* @returns {Object} props
*/
export function getNodeProps(vnode) {
let props = extend({}, vnode.attributes);
props.children = vnode.children;
let defaultProps = vnode.nodeName.defaultProps;
if (defaultProps!==undefined) {
for (let i in defaultProps) {
if (props[i]===undefined) {
props[i] = defaultProps[i];
}
}
}
return props;
}

2
static/js/ketcher2/node_modules/preact/src/vnode.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
/** Virtual DOM Node */
export function VNode() {}

5
static/js/ketcher2/node_modules/preact/typings.json generated vendored Normal file
View File

@ -0,0 +1,5 @@
{
"name": "preact",
"main": "src/preact.d.ts",
"version": false
}