npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dhampir/core

v1.0.0-beta.18

Published

Project contains framework that allows you to start writing web apps with using Typescript, React, Redux, Rect Router v5, webpack(HMR), express and gulp

Downloads

23

Readme

Dhampir Core

Javascript library that includes features needed for building Web applications. Such as:

  • Enhanced Routing
  • Extensibility
  • Appearance
  • Components Library
  • Storage
  • Feature Toggling

Enhanced Routing Feature

Introduces several new concepts such as Root Route, Descendant Route, Routing Area, Area Rendering.

Root Route is a Routing Rule that describes the top level route, literally route that is a first section of the path. Eg

Descendant Route is a Routing Rule that is a child of the Root Route or another Descendant Route. Path of the child route will be included in resulting route url. For example if Root Route path is /store, and it has Descendant Route path /checkout then resulting path is /store/checkout.

Routing Area is a container in the layout of the page where Area Renderings are rendered. What does this mean? Routing Areas are defined within certain Route. When path of the url matches the Route then all Area Renderings associated with this route will be rendered in Rendering Area with id that the rule contain.

For example:

  1. When registering Root Route.
import { registerRootRouting, RoutingArea } from '@dhampir/core';
import { Header, Body, Layout, MainMenu } from '@components/layout';

registerRootRouting({
    id: 'manage',
    path: "/manage",
    component: Layout,
    renderings: [
        {
            area: RoutingArea.TOP,
            component: Header,
        },
        {
            area: RoutingArea.TOP_LEFT,
            component: Logo
        },
        {
            area: RoutingArea.TOP_CENTER,
            // We are using `exact={true}` to render it only when route matches exactly
            exact: true,
            component: MainMenu
        },
    ]
});

In example above if route matches /manage, then Layout component will render Header in Rendering Area with name Routing.TOP, Logo component in Rendering Area with name Routing.TOP_LEFT, MainMenu component in Rendering Area with name Routing.TOP_CENTER.

  1. When registering Root Route, within Descendant Route.
import { registerRootRouting, RoutingArea } from '@dhampir/core';
import { LeftBar, Nav, Page } from '@components/widgets';

registerRootRouting({
    id: 'manage',
    path: "/manage",
    component: Layout,
    routes: [
        {
            path: '/products',
            rendering: [
                {
                    exact: true,
                    area: RoutingArea.BODY_LEFT,
                    component: LeftBar,
                },
                {
                    area: RoutingArea.MENU_LEFT,
                    component: Nav,
                },
                {
                    area: RoutingArea.BODY_MAIN,
                    component: Page,
                },
            ],
            navigation: {
                label: 'Manage Products',
            },
        },
    ]
});

In example above if route matches /manage/products, then LeftBar component will be rendered in Rendering Area with name Routing.BODY_LEFT, Nav component - in Rendering Area with name Routing.MENU_LEFT, Page component - in Rendering Area with name Routing.BODY_MAIN.

  1. When extending Descendant Route.
import { extendRoute, RoutingArea } from '@dhampir/core';
extendRoute(['/manage', '/products'], {
    path: '/list',
    rendering: [
        {
            area: RoutingArea.BODY_LEFT,
            render: () => <div>Product List</div>
        },
        {
            area: RoutingArea.BODY_MAIN,
            render: () => <div>Product Details</div>
        },
    ],
    navigation: {
        label: 'Product List'
    }
});

In example above if route matches /manage/products/list, then render function will be executed in order to render content in Rendering Area with name Routing.BODY_LEFT, the same will happen in Rendering Area with name RoutingArea.BODY_MAIN.

Layout component contains Rendering Areas represented with Area component. Implementation may be different.

import { FunctionComponent } from 'react';
import { useLocation } from 'react-router';

import { AppLayoutProps, Column, Screen, Row } from '../../../components';
import { Area, isAreaVisible, RoutingArea } from '../../../routing';
import { Direction } from '../../API';

const Layout: FunctionComponent<AppLayoutProps> = () => {
    const location = useLocation();
    return (
        <Screen fullScreen={true} direction={Direction.VERTICAL}>
            {isAreaVisible(RoutingArea.TOP, location.pathname) && <Row>
                <Area area={RoutingArea.TOP} />
            </Row>}
            {isAreaVisible(RoutingArea.MENU, location.pathname) && <Row>
                <Area area={RoutingArea.MENU} />
            </Row>}
            <Row greedy={true} asGrid={true}>
                {isAreaVisible(RoutingArea.BODY_LEFT, location.pathname) &&
                <Column>
                    <Area area={RoutingArea.BODY_LEFT} />
                </Column>}
                <Column greedy={true}>
                    <Area area={RoutingArea.BODY_MAIN}/>
                </Column>
                {isAreaVisible(RoutingArea.BODY_RIGHT, location.pathname) && <Column>
                    <Area area={RoutingArea.BODY_RIGHT} />
                </Column>}
            </Row>
            {isAreaVisible(RoutingArea.BOTTOM, location.pathname) && <Row>
                <Area area={RoutingArea.BOTTOM} />
            </Row>}
        </Screen>
    );
};

export { Layout };

Note: Rendering Area name just a string, string enum RoutingArea is used for convenience.

Area Rendering is a part of the Routing Rule that contains identifier or name of the Area and function or component that * Routing Feature* will render to that Area.

Extensibility

At this moment extensibility is achieved by extending routes.

Appearance

This feature allows user to do the following:

  • register custom Color Themes;
  • inject theme colors to individual component;
  • develop custom components that use Color Theme;
  • use additional API to work with Themes, use them, edit them, switch between them;

Components Library

Contains components that are a generic layout building blocks. They may be used for building more complex components. Support using Color Themes.

State Management

Allows user to configure which data storage to use. Dhampir Core supports Redux and React Query OOTB.

Feature Toggling

In progress.