29 lines
774 B
JavaScript
29 lines
774 B
JavaScript
|
/* Riot WIP, @license MIT */
|
||
|
import { COMPONENTS_IMPLEMENTATION_MAP, panic } from '@riotjs/util';
|
||
|
import { createComponentFromWrapper } from '../core/create-component-from-wrapper.js';
|
||
|
|
||
|
/**
|
||
|
* Register a custom tag by name
|
||
|
* @param {string} name - component name
|
||
|
* @param {Object} implementation - tag implementation
|
||
|
* @returns {Map} map containing all the components implementations
|
||
|
*/
|
||
|
|
||
|
function register(name, _ref) {
|
||
|
let {
|
||
|
css,
|
||
|
template,
|
||
|
exports
|
||
|
} = _ref;
|
||
|
if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`);
|
||
|
COMPONENTS_IMPLEMENTATION_MAP.set(name, createComponentFromWrapper({
|
||
|
name,
|
||
|
css,
|
||
|
template,
|
||
|
exports
|
||
|
}));
|
||
|
return COMPONENTS_IMPLEMENTATION_MAP;
|
||
|
}
|
||
|
|
||
|
export { register };
|