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

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