@hybridly/core
Advanced tools
Comparing version 0.0.1-alpha.14 to 0.0.1-alpha.15
import { RequestData } from '@hybridly/utils'; | ||
import { AxiosResponse, Axios, AxiosProgressEvent } from 'axios'; | ||
import { AxiosResponse, AxiosProgressEvent, Axios } from 'axios'; | ||
@@ -75,68 +75,2 @@ type MaybePromise<T> = T | Promise<T>; | ||
/** Options for creating a router context. */ | ||
interface RouterContextOptions { | ||
/** The initial payload served by the browser. */ | ||
payload: HybridPayload; | ||
/** Adapter-specific functions. */ | ||
adapter: Adapter; | ||
/** History state serializer. */ | ||
serializer?: Serializer; | ||
/** List of plugins. */ | ||
plugins?: Plugin[]; | ||
/** The Axios instance. */ | ||
axios?: Axios; | ||
} | ||
/** Router context. */ | ||
interface InternalRouterContext { | ||
/** The current, normalized URL. */ | ||
url: string; | ||
/** The current view. */ | ||
view: View; | ||
/** The current, optional dialog. */ | ||
dialog?: View; | ||
/** The current local asset version. */ | ||
version: string; | ||
/** The current adapter's functions. */ | ||
adapter: Adapter; | ||
/** Scroll positions of the current page's DOM elements. */ | ||
scrollRegions: ScrollRegion[]; | ||
/** Arbitrary state. */ | ||
state: Record<string, any>; | ||
/** Currently pending navigation. */ | ||
pendingNavigation?: PendingNavigation; | ||
/** History state serializer. */ | ||
serializer: Serializer; | ||
/** List of plugins. */ | ||
plugins: Plugin[]; | ||
/** Global hooks. */ | ||
hooks: Partial<Record<keyof Hooks, Array<Function>>>; | ||
/** The Axios instance. */ | ||
axios: Axios; | ||
} | ||
/** Router context. */ | ||
type RouterContext = Readonly<InternalRouterContext>; | ||
/** Adapter-specific functions. */ | ||
interface Adapter { | ||
/** Resolves a component from the given name. */ | ||
resolveComponent: ResolveComponent; | ||
/** Swaps to the given view. */ | ||
swapView: SwapView; | ||
/** Swaps to the given dialog. */ | ||
swapDialog: SwapDialog; | ||
/** Called when the context is updated. */ | ||
update?: (context: InternalRouterContext) => void; | ||
} | ||
interface ScrollRegion { | ||
top: number; | ||
left: number; | ||
} | ||
/** Provides methods to serialize the state into the history state. */ | ||
interface Serializer { | ||
serialize: <T>(view: T) => any; | ||
unserialize: <T>(state: any) => T; | ||
} | ||
/** Gets the current context. */ | ||
declare function getRouterContext(): RouterContext; | ||
type UrlResolvable = string | URL | Location; | ||
@@ -252,2 +186,4 @@ type UrlTransformable = Partial<Omit<URL, 'searchParams' | 'toJSON' | 'toString'>> & { | ||
reload: (options?: HybridRequestOptions) => Promise<NavigationResponse>; | ||
/** Makes a request to given named route. The HTTP verb is determined automatically but can be overriden. */ | ||
to: <T extends RouteName>(name: T, parameters?: RouteParameters<T>, options?: Omit<HybridRequestOptions, 'url'>) => Promise<NavigationResponse>; | ||
/** Makes a GET request to the given URL. */ | ||
@@ -329,2 +265,93 @@ get: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>; | ||
interface RoutingConfiguration { | ||
url: string; | ||
port?: number; | ||
defaults: Record<string, any>; | ||
routes: Record<string, RouteDefinition>; | ||
} | ||
interface RouteDefinition { | ||
uri: string; | ||
method: Method[]; | ||
bindings: Record<string, string>; | ||
domain?: string; | ||
wheres?: Record<string, string>; | ||
} | ||
interface GlobalRouteCollection extends RoutingConfiguration { | ||
} | ||
type RouteName = keyof GlobalRouteCollection['routes']; | ||
type RouteParameters<T extends RouteName> = Record<keyof GlobalRouteCollection['routes'][T]['bindings'], any> & Record<string, any>; | ||
/** Options for creating a router context. */ | ||
interface RouterContextOptions { | ||
/** The initial payload served by the browser. */ | ||
payload: HybridPayload; | ||
/** Adapter-specific functions. */ | ||
adapter: Adapter; | ||
/** History state serializer. */ | ||
serializer?: Serializer; | ||
/** List of plugins. */ | ||
plugins?: Plugin[]; | ||
/** The Axios instance. */ | ||
axios?: Axios; | ||
/** Initial routing configuration. */ | ||
routing?: RoutingConfiguration; | ||
} | ||
/** Router context. */ | ||
interface InternalRouterContext { | ||
/** The current, normalized URL. */ | ||
url: string; | ||
/** The current view. */ | ||
view: View; | ||
/** The current, optional dialog. */ | ||
dialog?: View; | ||
/** The current local asset version. */ | ||
version: string; | ||
/** The current adapter's functions. */ | ||
adapter: ResolvedAdapter; | ||
/** Scroll positions of the current page's DOM elements. */ | ||
scrollRegions: ScrollRegion[]; | ||
/** Arbitrary state. */ | ||
state: Record<string, any>; | ||
/** Currently pending navigation. */ | ||
pendingNavigation?: PendingNavigation; | ||
/** History state serializer. */ | ||
serializer: Serializer; | ||
/** List of plugins. */ | ||
plugins: Plugin[]; | ||
/** Global hooks. */ | ||
hooks: Partial<Record<keyof Hooks, Array<Function>>>; | ||
/** The Axios instance. */ | ||
axios: Axios; | ||
/** Routing configuration. */ | ||
routing?: RoutingConfiguration; | ||
} | ||
/** Router context. */ | ||
type RouterContext = Readonly<InternalRouterContext>; | ||
/** Adapter-specific functions. */ | ||
interface Adapter { | ||
/** Resolves a component from the given name. */ | ||
resolveComponent: ResolveComponent; | ||
/** Swaps to the given view. */ | ||
swapView: SwapView; | ||
/** Swaps to the given dialog. */ | ||
swapDialog: SwapDialog; | ||
/** Called when the context is updated. */ | ||
update?: (context: InternalRouterContext) => void; | ||
} | ||
interface ResolvedAdapter extends Adapter { | ||
updateRoutingConfiguration: (routing?: RoutingConfiguration) => void; | ||
} | ||
interface ScrollRegion { | ||
top: number; | ||
left: number; | ||
} | ||
/** Provides methods to serialize the state into the history state. */ | ||
interface Serializer { | ||
serialize: <T>(view: T) => any; | ||
unserialize: <T>(state: any) => T; | ||
} | ||
/** Gets the current context. */ | ||
declare function getRouterContext(): RouterContext; | ||
/** | ||
@@ -352,2 +379,7 @@ * The hybridly router. | ||
/** | ||
* Generates a route from the given route name. | ||
*/ | ||
declare function route<T extends RouteName>(name: T, parameters?: RouteParameters<T>, absolute?: boolean): string; | ||
declare const STORAGE_EXTERNAL_KEY = "hybridly:external"; | ||
@@ -389,2 +421,2 @@ declare const HYBRIDLY_HEADER = "x-hybrid"; | ||
export { Authorizable, HybridPayload, HybridRequestOptions, MaybePromise, Method, NavigationResponse, Plugin, Progress, ResolveComponent, Router, RouterContext, RouterContextOptions, UrlResolvable, can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, router, sameUrls }; | ||
export { Authorizable, GlobalRouteCollection, HybridPayload, HybridRequestOptions, MaybePromise, Method, NavigationResponse, Plugin, Progress, ResolveComponent, RouteDefinition, RouteName, RouteParameters, Router, RouterContext, RouterContextOptions, RoutingConfiguration, UrlResolvable, can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, route, router, sameUrls }; |
{ | ||
"name": "@hybridly/core", | ||
"version": "0.0.1-alpha.14", | ||
"version": "0.0.1-alpha.15", | ||
"description": "A solution to develop server-driven, client-rendered applications", | ||
@@ -39,4 +39,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@hybridly/utils": "0.0.1-alpha.14", | ||
"qs": "^6.11.0" | ||
"qs": "^6.11.0", | ||
"@hybridly/utils": "0.0.1-alpha.15" | ||
}, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
79862
2013
+ Added@hybridly/utils@0.0.1-alpha.15(transitive)
- Removed@hybridly/utils@0.0.1-alpha.14(transitive)