feat: gatherComponents

This commit is contained in:
cha0s 2021-04-06 17:41:03 -05:00
parent 442826f287
commit feb6feabf9
4 changed files with 28 additions and 1 deletions

View File

@ -13,7 +13,7 @@ const debug = D('@latus/core/gather');
export const hotGathered = new Map(); export const hotGathered = new Map();
const transformPath = (transformer, path) => { export const transformPath = (transformer, path) => {
const parts = dirname(path).split('/'); const parts = dirname(path).split('/');
if ('.' === parts[0]) { if ('.' === parts[0]) {
parts.shift(); parts.shift();

View File

@ -16,6 +16,7 @@ export {
gatherFlat, gatherFlat,
gatherWithLatus, gatherWithLatus,
default as gather, default as gather,
transformPath,
} from './gather'; } from './gather';
export {default as Middleware} from './middleware'; export {default as Middleware} from './middleware';
export {default as Latus} from './latus'; export {default as Latus} from './latus';

View File

@ -0,0 +1,24 @@
import {
camelCase,
transformPath,
} from '@latus/core';
export default (
context,
{
transformer = camelCase,
} = {},
) => () => (
Object.fromEntries(
context.keys()
.map(
(path) => {
const {default: Component} = context(path);
return [
transformPath(transformer, path),
Component,
];
},
),
)
);

View File

@ -1,10 +1,12 @@
export {default as React} from 'react'; export {default as React} from 'react';
export * from 'react'; export * from 'react';
export {default as ReactDom} from 'react-dom'; export {default as ReactDom} from 'react-dom';
export {hot} from 'react-hot-loader';
export {default as PropTypes} from 'prop-types'; export {default as PropTypes} from 'prop-types';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
export {LatusContext} from '@latus/react/client'; export {LatusContext} from '@latus/react/client';
export {default as gatherComponents} from './gather-components';
export {default as useEvent} from './hooks/use-event'; export {default as useEvent} from './hooks/use-event';
export {default as useLatus} from './hooks/use-latus'; export {default as useLatus} from './hooks/use-latus';
export {default as usePrevious} from './hooks/use-previous'; export {default as usePrevious} from './hooks/use-previous';