-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(💧 BlueRainApp): Create basic BlueRain main app structure
- Loading branch information
Showing
12 changed files
with
111 additions
and
15 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ComponentRegistry, HookRegistry, PluginRegistry } from './registries'; | ||
import { BlueRainProvider } from './Context'; | ||
import { Logger } from './api'; | ||
import { register as registerInternalComponents } from './components'; | ||
import React from 'react'; | ||
|
||
export class BlueRain { | ||
|
||
// APIs | ||
public Logger = new Logger(this); | ||
|
||
// Registries | ||
public Components: ComponentRegistry = new ComponentRegistry(this); | ||
public Hooks: HookRegistry = new HookRegistry(this); | ||
public Plugins: PluginRegistry = new PluginRegistry(this); | ||
|
||
// Flags | ||
public booted = false; | ||
|
||
public async boot() { | ||
|
||
await registerInternalComponents(this); | ||
|
||
// Set View | ||
// const SystemApp = this.Components.resolve('SystemApp'); | ||
// SystemApp = await this.Hooks.run('bluerain.system.app', SystemApp); | ||
|
||
const BluerainApp = () => ( | ||
<BlueRainProvider value={this}> | ||
<this.Components.SystemApp /> | ||
</BlueRainProvider> | ||
); | ||
|
||
this.booted = true; | ||
|
||
return BluerainApp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { BR } from './instance'; | ||
import React from 'react'; | ||
|
||
export interface BlueRainAppProperties { | ||
|
||
// plugins: Plugin[] | ||
} | ||
|
||
interface BlueRainAppState { | ||
|
||
booted: boolean; | ||
|
||
Component: React.ComponentType<any> | ||
} | ||
|
||
export class BlueRainApp extends React.Component<BlueRainAppProperties, BlueRainAppState> { | ||
|
||
state = { | ||
booted: BR.booted, | ||
|
||
Component: () => <div>Loading</div> | ||
}; | ||
|
||
async componentDidMount() { | ||
try { | ||
const Component = await BR.boot(); | ||
this.setState({ | ||
Component, | ||
booted: BR.booted, | ||
}); | ||
} catch (error) { | ||
// tslint:disable-next-line:no-console | ||
console.error(error); | ||
} | ||
} | ||
|
||
render() { | ||
|
||
const Component = this.state.Component; | ||
|
||
return <Component />; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { BR } from './instance'; | ||
import { createContext } from 'react'; | ||
|
||
export const BlueRainContext = createContext(BR); | ||
export const BlueRainProvider = BlueRainContext.Provider; | ||
export const BlueRainConsumer = BlueRainContext.Consumer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
|
||
export class SystemApp extends React.PureComponent { | ||
|
||
render() { | ||
return 'BlueRain System App!'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './SystemApp'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './register'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BlueRain } from '../BlueRain'; | ||
import { SystemApp } from './SystemApp'; | ||
|
||
export async function register(BR: BlueRain) { | ||
|
||
await BR.Components.register('SystemApp', SystemApp); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export * from './BlueRain'; | ||
export * from './BlueRainApp'; | ||
export * from './Context'; | ||
export * from './instance'; | ||
export * from './registries'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { BlueRain } from './BlueRain'; | ||
|
||
export const BR = new BlueRain(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters