@hybridly/core
Advanced tools
Comparing version 0.0.1-alpha.6 to 0.0.1-alpha.7
@@ -8,7 +8,7 @@ import { RequestData } from '@hybridly/utils'; | ||
/** | ||
* Called before anything when a visit is going to happen. | ||
* Called before anything when a navigation is going to happen. | ||
*/ | ||
before: (options: VisitOptions) => MaybePromise<any | boolean>; | ||
before: (options: HybridRequestOptions) => MaybePromise<any | boolean>; | ||
/** | ||
* Called before the request of a visit is going to happen. | ||
* Called before the request of a navigation is going to happen. | ||
*/ | ||
@@ -21,3 +21,3 @@ start: (context: InternalRouterContext) => MaybePromise<any>; | ||
/** | ||
* Called when data is received after a request for a visit. | ||
* Called when data is received after a request for a navigation. | ||
*/ | ||
@@ -28,3 +28,3 @@ data: (response: AxiosResponse) => MaybePromise<any>; | ||
*/ | ||
success: (payload: VisitPayload) => MaybePromise<any>; | ||
success: (payload: HybridPayload) => MaybePromise<any>; | ||
/** | ||
@@ -55,19 +55,18 @@ * Called when a request is successful but there were errors. | ||
/** | ||
* Called when a visit has been made and a page component has been navigated to. | ||
* Called when a navigation has been made and a page component has been navigated to. | ||
*/ | ||
navigate: (options: NavigationOptions) => MaybePromise<void>; | ||
navigated: (options: NavigationOptions) => MaybePromise<void>; | ||
} | ||
interface HookOptions { | ||
/** Executes the hook only once. */ | ||
once?: boolean; | ||
} | ||
/** | ||
* Registers a global hook. | ||
*/ | ||
declare function registerHook<T extends keyof Hooks>(hook: T, fn: Hooks[T]): () => void; | ||
/** | ||
* Registers a global hook that will run only once. | ||
*/ | ||
declare function registerHookOnce<T extends keyof Hooks>(hook: T, fn: Hooks[T]): void; | ||
declare function registerHook<T extends keyof Hooks>(hook: T, fn: Hooks[T], options?: HookOptions): () => void; | ||
interface Plugin { | ||
interface Plugin extends Partial<Hooks> { | ||
name: string; | ||
initialized: (context: InternalRouterContext) => MaybePromise<void>; | ||
hooks: Partial<Hooks>; | ||
initialized?: (context: InternalRouterContext) => MaybePromise<void>; | ||
} | ||
@@ -79,3 +78,3 @@ declare function definePlugin(plugin: Plugin): Plugin; | ||
/** The initial payload served by the browser. */ | ||
payload: VisitPayload; | ||
payload: HybridPayload; | ||
/** Adapter-specific functions. */ | ||
@@ -104,4 +103,4 @@ adapter: Adapter; | ||
state: Record<string, any>; | ||
/** Currently pending visit. */ | ||
activeVisit?: PendingVisit; | ||
/** Currently pending navigation. */ | ||
pendingNavigation?: PendingNavigation; | ||
/** History state serializer. */ | ||
@@ -151,8 +150,8 @@ serializer: Serializer; | ||
declare type ConditionalNavigationOption = boolean | ((payload: VisitPayload) => boolean); | ||
interface LocalVisitOptions { | ||
declare type ConditionalNavigationOption = boolean | ((payload: HybridPayload) => boolean); | ||
interface ComponentNavigationOptions { | ||
/** Name of the component to use. */ | ||
component?: string; | ||
/** Properties to apply to the component. */ | ||
properties: Properties; | ||
properties?: Properties; | ||
/** | ||
@@ -170,3 +169,3 @@ * Whether to replace the current history state instead of adding | ||
/** View to navigate to. */ | ||
payload?: VisitPayload; | ||
payload?: HybridPayload; | ||
/** | ||
@@ -199,3 +198,3 @@ * Whether to replace the current history state instead of adding | ||
/** | ||
* Defines whether this navigation is a back/forward visit from the popstate event. | ||
* Defines whether this navigation is a back/forward navigation from the popstate event. | ||
* @internal This is an advanced property meant to be used internally. | ||
@@ -206,4 +205,4 @@ */ | ||
declare type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; | ||
interface VisitOptions extends Omit<NavigationOptions, 'request'> { | ||
/** The URL to visit. */ | ||
interface HybridRequestOptions extends Omit<NavigationOptions, 'payload'> { | ||
/** The URL to navigation. */ | ||
url?: UrlResolvable; | ||
@@ -214,5 +213,5 @@ /** HTTP verb to use for the request. */ | ||
data?: RequestData; | ||
/** Which properties to update for this visit. Other properties will be ignored. */ | ||
/** Which properties to update for this navigation. Other properties will be ignored. */ | ||
only?: string | string[]; | ||
/** Which properties not to update for this visit. Other properties will be updated. */ | ||
/** Which properties not to update for this navigation. Other properties will be updated. */ | ||
except?: string | string[]; | ||
@@ -223,3 +222,3 @@ /** Specific headers to add to the request. */ | ||
errorBag?: string; | ||
/** Hooks for this visit. */ | ||
/** Hooks for this navigation. */ | ||
hooks?: Partial<Hooks>; | ||
@@ -229,3 +228,3 @@ /** If `true`, force the usage of a `FormData` object. */ | ||
} | ||
interface VisitResponse { | ||
interface NavigationResponse { | ||
response?: AxiosResponse; | ||
@@ -238,24 +237,24 @@ error?: { | ||
interface Router { | ||
/** Aborts the currently pending visit, if any. */ | ||
/** Aborts the currently pending navigate, if any. */ | ||
abort: () => Promise<void>; | ||
/** Checks if there is an active request. */ | ||
/** Checks if there is an active navigate. */ | ||
active: () => boolean; | ||
/** Makes a visit with the given options. */ | ||
visit: (options: VisitOptions) => Promise<VisitResponse>; | ||
/** Makes a navigate with the given options. */ | ||
navigate: (options: HybridRequestOptions) => Promise<NavigationResponse>; | ||
/** Reloads the current page. */ | ||
reload: (options?: VisitOptions) => Promise<VisitResponse>; | ||
reload: (options?: HybridRequestOptions) => Promise<NavigationResponse>; | ||
/** Makes a GET request to the given URL. */ | ||
get: (url: UrlResolvable, options?: Omit<VisitOptions, 'method' | 'url'>) => Promise<VisitResponse>; | ||
get: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>; | ||
/** Makes a POST request to the given URL. */ | ||
post: (url: UrlResolvable, options?: Omit<VisitOptions, 'method' | 'url'>) => Promise<VisitResponse>; | ||
post: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>; | ||
/** Makes a PUT request to the given URL. */ | ||
put: (url: UrlResolvable, options?: Omit<VisitOptions, 'method' | 'url'>) => Promise<VisitResponse>; | ||
put: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>; | ||
/** Makes a PATCH request to the given URL. */ | ||
patch: (url: UrlResolvable, options?: Omit<VisitOptions, 'method' | 'url'>) => Promise<VisitResponse>; | ||
patch: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>; | ||
/** Makes a DELETE request to the given URL. */ | ||
delete: (url: UrlResolvable, options?: Omit<VisitOptions, 'method' | 'url'>) => Promise<VisitResponse>; | ||
/** Navigates to the given external URL. Alias for `document.location.href`. */ | ||
external: (url: UrlResolvable, data?: VisitOptions['data']) => void; | ||
delete: (url: UrlResolvable, options?: Omit<HybridRequestOptions, 'method' | 'url'>) => Promise<NavigationResponse>; | ||
/** Navigates to the given external URL. Convenience method using `document.location.href`. */ | ||
external: (url: UrlResolvable, data?: HybridRequestOptions['data']) => void; | ||
/** Navigates to the given URL without a server round-trip. */ | ||
local: (url: UrlResolvable, options: LocalVisitOptions) => Promise<void>; | ||
local: (url: UrlResolvable, options: ComponentNavigationOptions) => Promise<void>; | ||
/** Access the history state. */ | ||
@@ -269,4 +268,4 @@ history: { | ||
} | ||
/** An axios visit being made. */ | ||
interface PendingVisit { | ||
/** A navigation being made. */ | ||
interface PendingNavigation { | ||
/** The URL to which the request is being made. */ | ||
@@ -276,5 +275,5 @@ url: URL; | ||
controller: AbortController; | ||
/** Options for the associated visit. */ | ||
options: VisitOptions; | ||
/** Visit identifier. */ | ||
/** Options for the associated hybrid request. */ | ||
options: HybridRequestOptions; | ||
/** Navigation identifier. */ | ||
id: string; | ||
@@ -304,4 +303,4 @@ } | ||
declare type SwapDialog = (options: SwapOptions<DialogComponent>) => Promise<void>; | ||
/** The payload of a visit request from the server. */ | ||
interface VisitPayload { | ||
/** The payload of a navigation request from the server. */ | ||
interface HybridPayload { | ||
/** The view to use in this request. */ | ||
@@ -350,3 +349,3 @@ view: View; | ||
declare const HYBRIDLY_HEADER = "x-hybrid"; | ||
declare const EXTERNAL_VISIT_HEADER: string; | ||
declare const EXTERNAL_NAVIGATION_HEADER: string; | ||
declare const PARTIAL_COMPONENT_HEADER: string; | ||
@@ -362,3 +361,3 @@ declare const ONLY_DATA_HEADER: string; | ||
declare const constants_HYBRIDLY_HEADER: typeof HYBRIDLY_HEADER; | ||
declare const constants_EXTERNAL_VISIT_HEADER: typeof EXTERNAL_VISIT_HEADER; | ||
declare const constants_EXTERNAL_NAVIGATION_HEADER: typeof EXTERNAL_NAVIGATION_HEADER; | ||
declare const constants_PARTIAL_COMPONENT_HEADER: typeof PARTIAL_COMPONENT_HEADER; | ||
@@ -375,3 +374,3 @@ declare const constants_ONLY_DATA_HEADER: typeof ONLY_DATA_HEADER; | ||
constants_HYBRIDLY_HEADER as HYBRIDLY_HEADER, | ||
constants_EXTERNAL_VISIT_HEADER as EXTERNAL_VISIT_HEADER, | ||
constants_EXTERNAL_NAVIGATION_HEADER as EXTERNAL_NAVIGATION_HEADER, | ||
constants_PARTIAL_COMPONENT_HEADER as PARTIAL_COMPONENT_HEADER, | ||
@@ -387,2 +386,2 @@ constants_ONLY_DATA_HEADER as ONLY_DATA_HEADER, | ||
export { Authorizable, MaybePromise, Method, Plugin, Progress, ResolveComponent, Router, RouterContext, RouterContextOptions, UrlResolvable, VisitOptions, VisitPayload, VisitResponse, can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, registerHookOnce, router, sameUrls }; | ||
export { Authorizable, HybridPayload, HybridRequestOptions, MaybePromise, Method, NavigationResponse, Plugin, Progress, ResolveComponent, Router, RouterContext, RouterContextOptions, UrlResolvable, can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, router, sameUrls }; |
{ | ||
"name": "@hybridly/core", | ||
"version": "0.0.1-alpha.6", | ||
"version": "0.0.1-alpha.7", | ||
"description": "A solution to develop server-driven, client-rendered applications", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@hybridly/utils": "0.0.1-alpha.6", | ||
"@hybridly/utils": "0.0.1-alpha.7", | ||
"qs": "^6.11.0" | ||
@@ -42,0 +42,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62293
1623
+ Added@hybridly/utils@0.0.1-alpha.7(transitive)
+ Addedlodash.clonedeep@4.5.0(transitive)
- Removed@hybridly/utils@0.0.1-alpha.6(transitive)