Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-habitat

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-habitat - npm Package Compare versions

Comparing version 0.2.0-beta to 0.2.0-beta2

127

index.d.ts

@@ -9,50 +9,93 @@ /**

export interface IDomFactory {
/**
* An identifier string for the type of components this injects
*/
identifier: () => string;
/**
* The inject method after a wire-up has been requested
* @param {*} module - The component
* @param {object} props - The components properties
* @param {Element} target - The element to inject the component into
*/
inject?: (module: any, props: {}, target: Element) => void;
}
export interface IContainer {
/**
* Register a new component in the container
* @param {string} name - The key that identifies this component
* @param {*} comp - The component class
*/
registerComponent: (name: string, comp: any) => void;
/**
* Get a registered component for a key
* @param {string} name - The key name of the component that has been registered
*/
resolve: (name: string) => any;
}
export interface IBootstrapper {
/**
* The dom factory
*/
factory: IDomFactory;
/**
* Set the container
* @param {IContainer} container - The container
*/
setContainer: (container: IContainer) => void;
}
declare module ReactHabitat {
export interface IDomFactory {
/**
* An identifier string for the type of components this injects
*/
identifier: () => string;
/**
* The inject method after a wire-up has been requested
* @param {*} module - The component
* @param {object} props - The components properties
* @param {Element} target - The element to inject the component into
*/
inject?: (module: any, props: {}, target: Element) => void;
}
export class Bootstrapper implements IBootstrapper {
export interface IContainer {
/**
* Register a new component in the container
* @param {string} name - The key that identifies this component
* @param {*} comp - The component class
*/
registerComponent: (name: string, comp: any) => void;
/**
* Get a registered component for a key
* @param {string} name - The key name of the component that has been registered
*/
resolve: (name: string) => any;
}
/**
* The bootstrapping factory
*/
factory: IDomFactory;
export interface IBootstrapper {
factory: IDomFactory;
setContainer: (container: IContainer) => void;
}
/**
* Sets the container
*/
setContainer: (container: IContainer) => void;
export class Bootstrapper implements IBootstrapper {
factory: IDomFactory;
setContainer: (container: IContainer) => void;
componentSelector: string;
elements: NodeListOf<Element>;
_container: IContainer;
}
/**
* The component selector
*/
componentSelector: string;
export class Container implements IContainer {
registerComponent: (name: string, comp: any) => void;
resolve: (name: string) => any;
}
/**
* Collection of elements matching the component selector
*/
elements: NodeListOf<Element>;
}
/**
* The container
* @private
*/
_container: IContainer;
}
export class Container implements IContainer {
/**
* Register a component
*/
registerComponent: (name: string, comp: any) => void;
/**
* Resolve a component
*/
resolve: (name: string) => any;
}
}
export default ReactHabitat;
{
"name": "react-habitat",
"version": "0.2.0-beta",
"version": "0.2.0-beta2",
"description": "A React DOM Bootstrapper designed to harmonise a hybrid application",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -35,3 +35,2 @@ ![Deloitte Digital](https://raw.githubusercontent.com/DeloitteDigital/DDBreakpoints/master/docs/deloittedigital-logo-white.png)

- Simple and fast setup
- Pass data (props) to your components from HTML attributes

@@ -48,6 +47,6 @@ - Automatic data parsing

- Supports Browsers IE8+ and all the evergreens.
- Supports Browsers IE9+ and all the evergreens.
- ES5, ES6/7 & TypeScript
We recommend you use something like WebPack or Browserify when using this framework but not required.
We highly recommend you use something like [WebPack](https://webpack.github.io/) or [Browserify](http://browserify.org/) when using this framework but not required.

@@ -60,2 +59,3 @@ ## Installing

Alternatively you can manually install by downloading the `dist/react-habitat.min.js` file and including in your project.

@@ -67,3 +67,2 @@ ## Getting Started

- Structure your app with inversion of control (IoC) in mind.
- Add React references.
- At application startup...

@@ -74,3 +73,3 @@ - Create a Container.

- During application execution...
- Use the lifetime DOM scope to resolve instances of the components.
- Use the DOM scope to resolve instances of the components.

@@ -80,14 +79,12 @@ This getting started guide walks you through these steps for a simple React application.

- How to compile JSX
- How to use es6 modules; and
- How to compile JSX; and
- How to bundle using something like webpack or browserify
#### 1. Create a bootstrapper class
The class must extend `ReactHabitat.Bootstrapper` and is to be the *entry* point of your app.
So if you're using something like webpack or browserify then this is file to point it to.
The class must extend `ReactHabitat.Bootstrapper` and is intended to be the *entry* point of your app.
So if you're using something like webpack or browserify then this is file to point it to bundle from.
In the *constructor()* of the class you need to register your React components with it and then set
the container. The container is later bound to the DOM automatically.
the container. The container is later bound to the DOM automatically so your React components self-initiate.

@@ -188,3 +185,3 @@ In React Habitat, you'd register a component something like this

To *resolve* new instances your components you need to attach a `data-component` attribute to a `div` or a `span` element in the HTML. These elements should always
remain empty.
remain empty. Any child components should be nested inside the React components themselves.

@@ -191,0 +188,0 @@ Set the `data-component` value to equal a component name you have registered in the container.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc