UNPKG

@dark-engine/core

Version:

The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)

31 lines (30 loc) 896 B
import { KEY_ATTR } from '../constants'; class Component { type = null; props = null; token = null; displayName = ''; shouldUpdate = null; children = null; constructor(type, props, token = null, displayName = '') { this.type = type; this.props = props; this.token = token; this.displayName = displayName; } inject(shouldUpdate, token) { this.shouldUpdate = shouldUpdate; this.token = token; return this; } } function component(type, options = {}) { const { token, displayName } = options; const factory = (props = {}) => new Component(type, props, token, displayName); factory.displayName = displayName; return factory; } const detectIsComponent = x => x instanceof Component; const getComponentKey = x => x.props[KEY_ATTR] ?? null; export { Component, component, detectIsComponent, getComponentKey }; //# sourceMappingURL=component.js.map