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

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() {}