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

@react-app-composer/core

v0.2.0

Published

Compose your React app using react-app-composer. You can create many apps from the same elements

Downloads

1

Readme

REACT APP COMPOSER

Requirements

  • React v18
  • react-router-dom
  • eventrix

Description

Compose your React app with react-app-composer.

Installation

npm i @react-app-composer/core react-router-dom eventrix --save
Basic usage
import { Composer, DynamicModule } from "@react-app-composer/core";
import ReactDOM from "react-dom/client";
import config from "./config";

const root = ReactDOM.createRoot(document.getElementById("root"));

root.render(
    <Composer config={config} />
);

Recommended directories structure

/src
    /modules
        /Home
            Home.jsx
            index.js
        /Menu
            /components
                MenuItem.jsx
            Menu.jsx
            index.js
    /services
        /Authentication
            Authentication.js
            index.js
    /layouts
        /Basic
            Basic.jsx
            index.js
        /Login
            Login.jsx
            index.js
    index.js
webpack.config.js
package.json

Config file example in JSON format

{
  "services": {
    "authentication": {
      "dependencies": [
        "ajax"
      ],
      "load": "/services/authentication/1.0.0/index.js",
      "data": {
        "clientId": "services.frontend",
        "userTokenKey": "AUTHENTICATION_TOKEN",
        "urls": {
          "authServer": "http://somedomain.com/auth/realms/test/protocol/openid-connect"
        }
      }
    }
  },
  "modules": {
    "logo": {
      "dependencies": [],
      "data": {
        "logoUrl": "https://some-domain.com/images/logo.png"
      },
      "load": "/modules/logo/1.0.0/index.js"
    },
    "home": {
      "dependencies": [
        "config"
      ],
      "load": "/modules/home/1.0.0/index.js",
      "events": [],
      "data": {
        "someStaticData": "foo"
      }
    },
    "login": {
      "dependencies": [
        "authentication"
      ],
      "load": "/modules/login/1.0.0/index.js",
      "events": [],
      "data": {
        "someStaticData": "foo"
      }
    },
    "mainMenu": {
      "dependencies": [
        "authentication",
        "config"
      ],
      "load": "/modules/menu/1.0.0/index.js"
    }
  },
  "layouts": {
    "basic": {
      "dependencies": [],
      "load": "/layoyts/basic/1.0.0/index.js",
      "regions": {
        "leftnav": {
          "modules": [
            "logo",
            "mainMenu"
          ]
        },
        "topbar": {
          "modules": []
        },
        "main": {
          "modules": []
        },
        "footer": {
          "modules": []
        }
      },
      "data": {}
    },
    "login": {
      "dependencies": [],
      "load": "/layoyts/login/1.0.0/index.js",
      "regions": {
        "topbar": {
          "modules": [
            "logo"
          ]
        },
        "main": {
          "modules": []
        },
        "footer": {
          "modules": []
        }
      },
      "data": {}
    }
  },
  "routes": {
    "login": {
      "path": "/login",
      "layout": "login",
      "menuLabel": "Login",
      "title": "Login page",
      "description": "Login to application",
      "regions": {
        "main": {
          "modules": [
            "login"
          ]
        }
      }
    },
    "homePage": {
      "path": "/",
      "layout": "basic",
      "menuLabel": "Home",
      "title": "Home page",
      "description": "Home page with login",
      "regions": {
        "main": {
          "modules": [
            "home"
          ]
        }
      }
    },
    "test1": {
      "path": "/test23",
      "layout": "basic",
      "private": true,
      "menuLabel": "Test 1",
      "title": "Test 1",
      "description": "Test 1 page",
      "regions": {
        "main": {
          "modules": []
        }
      }
    }
  },
  "settings": {}
}

Config file example in JS format

// layouts
import loadBasicLayout from './layouts/Basic';
import loadLoginLayout from "./layouts/Login";

// modules
import loadLogoModule from "./modules/Logo";
import loadHomeModule from "./modules/Home";
import loadLoginModule from "./modules/Login";
import loadMainMenu from "./modules/MainMenu";

// components
import loadLoaderComponent from "./components/Loader";

// services
import loadKeycloakAuthenticationService from "./services/KeycloakAuthentication";

const config = {
    services: {
        authentication: {
            dependencies: ['ajax'],
            load: loadKeycloakAuthenticationService,
            data: {
                clientId: 'services.frontend',
                userTokenKey: 'AUTHENTICATION_TOKEN',
                urls: {
                    authServer: 'http://somedomain.com/auth/realms/test/protocol/openid-connect'
                }
            }
        },
    },
    components: {
        loader: {
            load: loadLoaderComponent,
            data: {
                size: 'large'
            }
        }
    },
    modules: {
        logo: {
            dependencies: [],
            data: {
                logoUrl: 'https://some-domain.com/images/logo.png',
            },
            load: loadLogoModule,
        },
        home: {
            dependencies: ['config'],
            load: loadHomeModule,
            events: [],
            data: {
                someStaticData: 'foo',
            },
        },
        login: {
            dependencies: ['authentication'],
            load: loadLoginModule,
            events: [],
            data: {
                someStaticData: 'foo',
            },
        },
        mainMenu: {
            dependencies: ['authentication', 'config'],
            load: loadMainMenu,
        },
    },
    layouts: {
        basic: {
            dependencies: [],
            load: loadBasicLayout,
            regions: {
                leftnav: {
                    modules: ['logo', 'mainMenu']
                },
                topbar: {
                    modules: [],
                },
                main: {
                    modules: []
                },
                footer: {
                    modules: []
                }
            },
            data: {},
        },
        login: {
            dependencies: [],
            load: loadLoginLayout,
            regions: {
                topbar: {
                    modules: ['logo'],
                },
                main: {
                    modules: []
                },
                footer: {
                    modules: []
                }
            },
            data: {},
        },
    },
    routes: {
        login: {
            path: '/login',
            layout: 'login',
            menuLabel: 'Login',
            title: 'Login page',
            description: 'Login to application',
            regions: {
                main: {
                    modules: ['login']
                }
            }
        },
        homePage: {
            path: '/',
            layout: 'basic',
            menuLabel: 'Home',
            title: 'Home page',
            description: 'Home page with login',
            regions: {
                main: {
                    modules: ['home']
                }
            }
        },
        test1: {
            path: '/test23',
            layout: 'basic',
            private: true,
            menuLabel: 'Test 1',
            title: 'Test 1',
            description: 'Test 1 page',
            regions: {
                main: {
                    modules: []
                },
            }
        },
    },
    settings: {}
};

export default config;

DynamicModule

import { DynamicModule } from "@react-app-composer/core";

const HeaderModule = () => {
    return (
        <div>
            <h1>Header title</h1>
            <DynamicModule name="Filters" somePropForModule="custom prop"/>
        </div>
    )
}

export default HeaderModule;

other example with create dynamic module instance

import { createDynamicModule } from "@react-app-composer/core";

const FiltersModule = createDynamicModule('Filters');

const HeaderModule = () => {
    return (
        <div>
            <h1>Header title</h1>
            <FiltersModule somePropForModule="custom prop"/>
        </div>
    )
}

export default HeaderModule;

DynamicComponent

import { DynamicComponent } from "@react-app-composer/core";

const HeaderModule = () => {
    return (
        <div>
            <h1>Header title</h1>
            <DynamicComponent name="button" color="blue">Send messange</DynamicComponent>
        </div>
    )
}

export default HeaderModule;

other example with create dynamic component instance

import { createDynamicComponent } from "@react-app-composer/core";
import DefaultButtonComponent from './components';

const Button = createDynamicComponent('button', DefaultButtonComponent);

const HeaderModule = () => {
    return (
        <div>
            <h1>Header title</h1>
            <Button color="blue">Send messange</Button>
        </div>
    )
}

export default HeaderModule;