@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)
37 lines (36 loc) • 1.17 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
exports.getComponentKey = exports.detectIsComponent = exports.component = exports.Component = void 0;
const constants_1 = require('../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;
}
}
exports.Component = Component;
function component(type, options = {}) {
const { token, displayName } = options;
const factory = (props = {}) => new Component(type, props, token, displayName);
factory.displayName = displayName;
return factory;
}
exports.component = component;
const detectIsComponent = x => x instanceof Component;
exports.detectIsComponent = detectIsComponent;
const getComponentKey = x => x.props[constants_1.KEY_ATTR] ?? null;
exports.getComponentKey = getComponentKey;
//# sourceMappingURL=component.js.map