@rallie/core
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -1,18 +0,7 @@ | ||
import type { LifecyleCallbackType, DependencyType, RelateType } from '../types'; | ||
export declare class App { | ||
name: string; | ||
dependenciesReady: boolean; | ||
bootstrapping: Promise<void>; | ||
dependencies: Array<{ | ||
name: string; | ||
ctx?: Record<string, any>; | ||
data?: any; | ||
}>; | ||
relatedApps: Array<{ | ||
name: string; | ||
ctx?: Record<string, any>; | ||
}>; | ||
doBootstrap?: LifecyleCallbackType; | ||
doActivate?: LifecyleCallbackType; | ||
doDestroy?: LifecyleCallbackType; | ||
activated: Promise<void>; | ||
dependencies: Array<string>; | ||
relatedApps: Array<string>; | ||
doActivate?: () => void | Promise<void>; | ||
isRallieCoreApp: boolean; | ||
@@ -25,23 +14,13 @@ constructor(name: string); | ||
*/ | ||
relateTo(relatedApps: RelateType[]): this; | ||
relateTo(relatedApps: string[]): this; | ||
/** | ||
* indicate the apps to be activate before your app is bootstrapped | ||
* indicate the apps to be activate before your app is activated | ||
* @param dependencies | ||
*/ | ||
relyOn(dependencies: DependencyType[]): this; | ||
relyOn(dependencies: string[]): this; | ||
/** | ||
* indicate the callback your app will run when it's activated the first time | ||
* @param {function} callback | ||
*/ | ||
onBootstrap(callback: LifecyleCallbackType): this; | ||
/** | ||
* indicate the callback your app will run when it's activated after the first time | ||
* indicate the callback your app will run when it's activated | ||
* @param callback | ||
*/ | ||
onActivate(callback: LifecyleCallbackType): this; | ||
/** | ||
* indicate the callback when your app is destroyed | ||
* @param callback | ||
*/ | ||
onDestroy(callback: LifecyleCallbackType): this; | ||
onActivate(callback: () => void | Promise<void>): this; | ||
} |
@@ -16,75 +16,18 @@ import { Socket } from './socket'; | ||
private isRallieCoreApp; | ||
/** | ||
* config the bus | ||
* @param conf the new configuration object | ||
*/ | ||
config(conf: Partial<ConfType>): this; | ||
/** | ||
* register the middleware | ||
* @param middleware | ||
*/ | ||
use(middleware: MiddlewareFnType): this; | ||
/** | ||
* create the context to pass to the middleware | ||
* @param ctx | ||
* @returns | ||
*/ | ||
private createContext; | ||
/** | ||
* the core middleware | ||
* @param ctx the context | ||
*/ | ||
private loadResourcesFromAssetsConfig; | ||
/** | ||
* create a socket | ||
* @return the socket instance | ||
*/ | ||
private innerActivateApp; | ||
private activateDependencies; | ||
private loadRelatedApps; | ||
createSocket(): Socket; | ||
/** | ||
* return true if an app is created | ||
*/ | ||
existApp(name: string): boolean; | ||
/** | ||
* create an app | ||
* @param name the name of the app | ||
* @return the app instance | ||
*/ | ||
createApp(name: string): App; | ||
/** | ||
* load the resources of an app | ||
* @param ctx | ||
*/ | ||
loadApp(name: string, ctx?: Record<string, any>): Promise<void>; | ||
private activateDependencies; | ||
private loadRelatedApps; | ||
/** | ||
* activate an app | ||
* @param name | ||
* @param data | ||
*/ | ||
activateApp<T = any>(name: string, data?: T, ctx?: Record<string, any>, visitPath?: string[]): Promise<void>; | ||
/** | ||
* destroy an app | ||
* @param name | ||
* @param data | ||
*/ | ||
destroyApp<T = any>(name: string, data?: T): Promise<void>; | ||
loadApp(name: string): Promise<void>; | ||
activateApp(name: string): Promise<void>; | ||
config(conf: Partial<ConfType>): this; | ||
use(middleware: MiddlewareFnType): this; | ||
} | ||
export declare const DEFAULT_BUS_NAME = "DEFAULT_BUS"; | ||
/** | ||
* create a bus and record it on window.RALLIE_BUS_STORE | ||
* @param name the name of the bus | ||
*/ | ||
export declare const createBus: (name?: string) => Bus; | ||
/** | ||
* get the bus from window.RALLIE_BUS_STORE | ||
* @param name the name of the bus | ||
* @returns | ||
*/ | ||
export declare const getBus: (name?: string) => Bus; | ||
/** | ||
* get the bus from window.RALLIE_BUS_STORE, if the bus is not created, then create it | ||
* @param name the name of the bus | ||
* @returns | ||
*/ | ||
export declare const touchBus: (name?: string) => [Bus, boolean]; |
@@ -1,8 +0,7 @@ | ||
import type { CallbackType } from '../types'; | ||
export declare class EventEmitter { | ||
private broadcastEvents; | ||
private unicastEvents; | ||
addBroadcastEventListener(event: string, callback: CallbackType): void; | ||
addUnicastEventListener(event: string, callback: CallbackType): void; | ||
removeBroadcastEventListener(event: string, callback: CallbackType): void; | ||
addBroadcastEventListener(event: string, callback: Function): void; | ||
addUnicastEventListener(event: string, callback: Function): void; | ||
removeBroadcastEventListener(event: string, callback: Function): void; | ||
removeUnicastEventListener(event: string): void; | ||
@@ -9,0 +8,0 @@ emitBroadcast(event: string, ...args: any[]): void; |
import type { EventEmitter } from './event-emitter'; | ||
import type { CallbackType, StoresType } from '../types'; | ||
import type { StoresType } from '../types'; | ||
import { Watcher } from './watcher'; | ||
@@ -13,3 +13,3 @@ export declare class Socket { | ||
*/ | ||
onBroadcast<T extends Record<string, CallbackType>>(events: T): (eventName?: string) => void; | ||
onBroadcast<T extends Record<string, Function>>(events: T): (eventName?: string) => void; | ||
/** | ||
@@ -19,3 +19,3 @@ * add unicast event listeners | ||
*/ | ||
onUnicast<T extends Record<string, CallbackType>>(events: T): (eventName?: string) => void; | ||
onUnicast<T extends Record<string, Function>>(events: T): (eventName?: string) => void; | ||
/** | ||
@@ -25,3 +25,3 @@ * create a proxy to emit a broadcast event | ||
*/ | ||
createBroadcaster<T extends Record<string, CallbackType>>(logger?: (eventName: string) => void): T; | ||
createBroadcaster<T extends Record<string, Function>>(logger?: (eventName: string) => void): T; | ||
/** | ||
@@ -31,3 +31,3 @@ * create a proxy to emit unicast event | ||
*/ | ||
createUnicaster<T extends Record<string, CallbackType>>(logger?: (eventName: string) => void): T; | ||
createUnicaster<T extends Record<string, Function>>(logger?: (eventName: string) => void): T; | ||
/** | ||
@@ -34,0 +34,0 @@ * judge if state has been initialized |
@@ -1,2 +0,2 @@ | ||
import type { MiddlewareFnType, NextFnType, ContextType, DependencyType, RelateType } from '../types'; | ||
import type { MiddlewareFnType, NextFnType, ContextType } from '../types'; | ||
export declare const Errors: { | ||
@@ -26,3 +26,2 @@ removeNonExistedBroadcast: (eventName: string) => string; | ||
export declare function isPrimitive(object: unknown): boolean; | ||
export declare function deduplicate<T extends DependencyType | RelateType>(items: T[]): T[]; | ||
/** | ||
@@ -29,0 +28,0 @@ * the compose function copied from koa-compose |
@@ -1,4 +0,3 @@ | ||
import { Socket } from './lib/socket'; | ||
import { Watcher } from './lib/watcher'; | ||
export type CallbackType = (...args: any[]) => any; | ||
import type { Socket } from './lib/socket'; | ||
import type { Watcher } from './lib/watcher'; | ||
export type ScriptType = Partial<HTMLScriptElement> | string | HTMLScriptElement; | ||
@@ -22,12 +21,2 @@ export type LinkType = Partial<HTMLLinkElement> | string | HTMLLinkElement; | ||
export type MiddlewareFnType = (ctx: ContextType, next: NextFnType) => void | Promise<void>; | ||
export type LifecyleCallbackType = (data?: any) => Promise<void> | void; | ||
export type DependencyType = { | ||
name: string; | ||
data?: any; | ||
ctx?: Record<string, any>; | ||
} | string; | ||
export type RelateType = { | ||
name: string; | ||
ctx: Record<string, any>; | ||
} | string; | ||
export type StoreType<T = any> = { | ||
@@ -34,0 +23,0 @@ state: T; |
{ | ||
"name": "@rallie/core", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "a progressive micro front framework", | ||
@@ -27,3 +27,3 @@ "main": "./dist/index.umd.js", | ||
"homepage": "https://github.com/ralliejs/rallie#readme", | ||
"gitHead": "bc6d9465958937011c312f9680d9c8190f081e1b" | ||
"gitHead": "3b989f55f96104c39eb8f2b2c4af0d82df09cf43" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222587
5437