Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
vue-lite libraries
/*! *****************************************************************************
Copyright (C) Microsoft. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
// The "reflect-metadata" module has no imports or exports, but can be imported by modules to load the polyfill.
export { };
declare global {
namespace Reflect {
/**
* Applies a set of decorators to a target object.
* @param decorators An array of decorators.
* @param target The target object.
* @returns The result of applying the provided decorators.
* @remarks Decorators are applied in reverse order of their positions in the array.
* @example
*
* class Example { }
*
* // constructor
* Example = Reflect.decorate(decoratorsArray, Example);
*
*/
function decorate(decorators: ClassDecorator[], target: Function): Function;
/**
* Applies a set of decorators to a property of a target object.
* @param decorators An array of decorators.
* @param target The target object.
* @param propertyKey The property key to decorate.
* @param attributes A property descriptor.
* @remarks Decorators are applied in reverse order.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod() { }
* method() { }
* }
*
* // property (on constructor)
* Reflect.decorate(decoratorsArray, Example, "staticProperty");
*
* // property (on prototype)
* Reflect.decorate(decoratorsArray, Example.prototype, "property");
*
* // method (on constructor)
* Object.defineProperty(Example, "staticMethod",
* Reflect.decorate(decoratorsArray, Example, "staticMethod",
* Object.getOwnPropertyDescriptor(Example, "staticMethod")));
*
* // method (on prototype)
* Object.defineProperty(Example.prototype, "method",
* Reflect.decorate(decoratorsArray, Example.prototype, "method",
* Object.getOwnPropertyDescriptor(Example.prototype, "method")));
*
*/
function decorate(decorators: (PropertyDecorator | MethodDecorator)[], target: Object, propertyKey: string | symbol, attributes?: PropertyDescriptor): PropertyDescriptor;
/**
* A default metadata decorator factory that can be used on a class, class member, or parameter.
* @param metadataKey The key for the metadata entry.
* @param metadataValue The value for the metadata entry.
* @returns A decorator function.
* @remarks
* If `metadataKey` is already defined for the target and target key, the
* metadataValue for that key will be overwritten.
* @example
*
* // constructor
* @Reflect.metadata(key, value)
* class Example {
* }
*
* // property (on constructor, TypeScript only)
* class Example {
* @Reflect.metadata(key, value)
* static staticProperty;
* }
*
* // property (on prototype, TypeScript only)
* class Example {
* @Reflect.metadata(key, value)
* property;
* }
*
* // method (on constructor)
* class Example {
* @Reflect.metadata(key, value)
* static staticMethod() { }
* }
*
* // method (on prototype)
* class Example {
* @Reflect.metadata(key, value)
* method() { }
* }
*
*/
function metadata(metadataKey: any, metadataValue: any): {
(target: Function): void;
(target: Object, propertyKey: string | symbol): void;
};
/**
* Define a unique metadata entry on the target.
* @param metadataKey A key used to store and retrieve metadata.
* @param metadataValue A value that contains attached metadata.
* @param target The target object on which to define metadata.
* @example
*
* class Example {
* }
*
* // constructor
* Reflect.defineMetadata("custom:annotation", options, Example);
*
* // decorator factory as metadata-producing annotation.
* function MyAnnotation(options): ClassDecorator {
* return target => Reflect.defineMetadata("custom:annotation", options, target);
* }
*
*/
function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void;
/**
* Define a unique metadata entry on the target.
* @param metadataKey A key used to store and retrieve metadata.
* @param metadataValue A value that contains attached metadata.
* @param target The target object on which to define metadata.
* @param propertyKey The property key for the target.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* Reflect.defineMetadata("custom:annotation", Number, Example, "staticProperty");
*
* // property (on prototype)
* Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "property");
*
* // method (on constructor)
* Reflect.defineMetadata("custom:annotation", Number, Example, "staticMethod");
*
* // method (on prototype)
* Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "method");
*
* // decorator factory as metadata-producing annotation.
* function MyAnnotation(options): PropertyDecorator {
* return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key);
* }
*
*/
function defineMetadata(metadataKey: any, metadataValue: any, target: Object, propertyKey: string | symbol): void;
/**
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
* @example
*
* class Example {
* }
*
* // constructor
* result = Reflect.hasMetadata("custom:annotation", Example);
*
*/
function hasMetadata(metadataKey: any, target: Object): boolean;
/**
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey The property key for the target.
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* result = Reflect.hasMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.hasMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.hasMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.hasMetadata("custom:annotation", Example.prototype, "method");
*
*/
function hasMetadata(metadataKey: any, target: Object, propertyKey: string | symbol): boolean;
/**
* Gets a value indicating whether the target object has the provided metadata key defined.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
* @example
*
* class Example {
* }
*
* // constructor
* result = Reflect.hasOwnMetadata("custom:annotation", Example);
*
*/
function hasOwnMetadata(metadataKey: any, target: Object): boolean;
/**
* Gets a value indicating whether the target object has the provided metadata key defined.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey The property key for the target.
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "method");
*
*/
function hasOwnMetadata(metadataKey: any, target: Object, propertyKey: string | symbol): boolean;
/**
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
* @example
*
* class Example {
* }
*
* // constructor
* result = Reflect.getMetadata("custom:annotation", Example);
*
*/
function getMetadata(metadataKey: any, target: Object): any;
/**
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey The property key for the target.
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* result = Reflect.getMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getMetadata("custom:annotation", Example.prototype, "method");
*
*/
function getMetadata(metadataKey: any, target: Object, propertyKey: string | symbol): any;
/**
* Gets the metadata value for the provided metadata key on the target object.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
* @example
*
* class Example {
* }
*
* // constructor
* result = Reflect.getOwnMetadata("custom:annotation", Example);
*
*/
function getOwnMetadata(metadataKey: any, target: Object): any;
/**
* Gets the metadata value for the provided metadata key on the target object.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey The property key for the target.
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* result = Reflect.getOwnMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getOwnMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "method");
*
*/
function getOwnMetadata(metadataKey: any, target: Object, propertyKey: string | symbol): any;
/**
* Gets the metadata keys defined on the target object or its prototype chain.
* @param target The target object on which the metadata is defined.
* @returns An array of unique metadata keys.
* @example
*
* class Example {
* }
*
* // constructor
* result = Reflect.getMetadataKeys(Example);
*
*/
function getMetadataKeys(target: Object): any[];
/**
* Gets the metadata keys defined on the target object or its prototype chain.
* @param target The target object on which the metadata is defined.
* @param propertyKey The property key for the target.
* @returns An array of unique metadata keys.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* result = Reflect.getMetadataKeys(Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getMetadataKeys(Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getMetadataKeys(Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getMetadataKeys(Example.prototype, "method");
*
*/
function getMetadataKeys(target: Object, propertyKey: string | symbol): any[];
/**
* Gets the unique metadata keys defined on the target object.
* @param target The target object on which the metadata is defined.
* @returns An array of unique metadata keys.
* @example
*
* class Example {
* }
*
* // constructor
* result = Reflect.getOwnMetadataKeys(Example);
*
*/
function getOwnMetadataKeys(target: Object): any[];
/**
* Gets the unique metadata keys defined on the target object.
* @param target The target object on which the metadata is defined.
* @param propertyKey The property key for the target.
* @returns An array of unique metadata keys.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* result = Reflect.getOwnMetadataKeys(Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getOwnMetadataKeys(Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getOwnMetadataKeys(Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getOwnMetadataKeys(Example.prototype, "method");
*
*/
function getOwnMetadataKeys(target: Object, propertyKey: string | symbol): any[];
/**
* Deletes the metadata entry from the target object with the provided key.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
* @example
*
* class Example {
* }
*
* // constructor
* result = Reflect.deleteMetadata("custom:annotation", Example);
*
*/
function deleteMetadata(metadataKey: any, target: Object): boolean;
/**
* Deletes the metadata entry from the target object with the provided key.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey The property key for the target.
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* }
*
* // property (on constructor)
* result = Reflect.deleteMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.deleteMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "method");
*
*/
function deleteMetadata(metadataKey: any, target: Object, propertyKey: string | symbol): boolean;
}
}
import Vue, { ComponentOptions } from 'vue';
import { VueClass } from './declarations';
export declare const $internalHooks: string[];
export declare function componentFactory(Component: VueClass<Vue>, options?: ComponentOptions<Vue>): VueClass<Vue>;
import Vue from 'vue';
import { VueClass } from './declarations';
export declare function collectDataFromConstructor(vm: Vue, Component: VueClass<Vue>): {};
import Vue, { ComponentOptions } from 'vue';
export declare type VueClass<V> = {
new (...args: any[]): V & Vue;
} & typeof Vue;
export declare type DecoratedClass = VueClass<Vue> & {
__decorators__?: ((options: ComponentOptions<Vue>) => void)[];
};
import Vue, { ComponentOptions } from 'vue';
import { VueClass } from './declarations';
export { createDecorator, VueDecorator, mixins } from './util';
declare function Component<V extends Vue>(options: ComponentOptions<V> & ThisType<V>): <VC extends VueClass<V>>(target: VC) => VC;
declare namespace Component {
var registerHooks: (keys: string[]) => void;
}
declare function Component<VC extends VueClass<Vue>>(target: VC): VC;
declare namespace Component {
var registerHooks: (keys: string[]) => void;
}
export default Component;
import Vue, { VueConstructor } from 'vue';
import { VueClass } from './declarations';
export declare const reflectionIsSupported: false | typeof Reflect.getOwnMetadataKeys;
export declare function copyReflectionMetadata(to: VueConstructor, from: VueClass<Vue>): void;
import Vue, { ComponentOptions } from 'vue';
import { VueClass } from './declarations';
export declare const noop: () => void;
export declare const hasProto: boolean;
export interface VueDecorator {
(Ctor: typeof Vue): void;
(target: Vue, key: string): void;
(target: Vue, key: string, index: number): void;
}
export declare function createDecorator(factory: (options: ComponentOptions<Vue>, key: string, index: number) => void): VueDecorator;
export declare function mixins<A>(CtorA: VueClass<A>): VueClass<A>;
export declare function mixins<A, B>(CtorA: VueClass<A>, CtorB: VueClass<B>): VueClass<A & B>;
export declare function mixins<A, B, C>(CtorA: VueClass<A>, CtorB: VueClass<B>, CtorC: VueClass<C>): VueClass<A & B & C>;
export declare function mixins<A, B, C, D>(CtorA: VueClass<A>, CtorB: VueClass<B>, CtorC: VueClass<C>, CtorD: VueClass<D>): VueClass<A & B & C & D>;
export declare function mixins<A, B, C, D, E>(CtorA: VueClass<A>, CtorB: VueClass<B>, CtorC: VueClass<C>, CtorD: VueClass<D>, CtorE: VueClass<E>): VueClass<A & B & C & D & E>;
export declare function mixins<T>(...Ctors: VueClass<Vue>[]): VueClass<T>;
export declare function isPrimitive(value: any): boolean;
export declare function warn(message: string): void;
/** vue-property-decorator verson 8.0.0 MIT LICENSE copyright 2018 kaorun343 */
import Vue, { PropOptions, WatchOptions } from 'vue';
import Component, { mixins } from 'vue-class-component';
import { InjectKey } from '../vue/options';
export declare type Constructor = {
new (...args: any[]): any;
};
export { Component, Vue, mixins as Mixins };
/**
* decorator of an inject
* @param from key
* @return PropertyDecorator
*/
export declare function Inject(options?: {
from?: InjectKey;
default?: any;
} | InjectKey): PropertyDecorator;
/**
* decorator of a provide
* @param key key
* @return PropertyDecorator | void
*/
export declare function Provide(key?: string | symbol): PropertyDecorator;
/**
* decorator of model
* @param event event name
* @param options options
* @return PropertyDecorator
*/
export declare function Model(event?: string, options?: (PropOptions | Constructor[] | Constructor)): PropertyDecorator;
/**
* decorator of a prop
* @param options the options for the prop
* @return PropertyDecorator | void
*/
export declare function Prop(options?: (PropOptions | Constructor[] | Constructor)): PropertyDecorator;
/**
* decorator of a watch function
* @param path the path or the expression to observe
* @param WatchOption
* @return MethodDecorator
*/
export declare function Watch(path: string, options?: WatchOptions): MethodDecorator;
/**
* decorator of an event-emitter function
* @param event The name of the event
* @return MethodDecorator
*/
export declare function Emit(event?: string): MethodDecorator;
import "./vue";
import { VueRouter } from "./router";
export default VueRouter;
export {
RouterMode,
RawLocation,
RedirectOption,
RouterOptions,
RouteConfig,
RouteRecord,
Location,
Route,
NavigationGuard
} from "./router";
import Vue, { ComponentOptions, PluginFunction, AsyncComponent } from "vue";
type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent;
type Dictionary<T> = { [key: string]: T };
type ErrorHandler = (err: Error) => void;
export type RouterMode = "hash" | "history" | "abstract";
export type RawLocation = string | Location;
export type RedirectOption = RawLocation | ((to: Route) => RawLocation);
export type NavigationGuard<V extends Vue = Vue> = (
to: Route,
from: Route,
next: (to?: RawLocation | false | ((vm: V) => any) | void) => void
) => any
export declare class VueRouter {
constructor (options?: RouterOptions);
app: Vue;
mode: RouterMode;
currentRoute: Route;
beforeEach (guard: NavigationGuard): Function;
beforeResolve (guard: NavigationGuard): Function;
afterEach (hook: (to: Route, from: Route) => any): Function;
push (location: RawLocation, onComplete?: Function, onAbort?: ErrorHandler): void;
replace (location: RawLocation, onComplete?: Function, onAbort?: ErrorHandler): void;
go (n: number): void;
back (): void;
forward (): void;
getMatchedComponents (to?: RawLocation | Route): Component[];
onReady (cb: Function, errorCb?: ErrorHandler): void;
onError (cb: ErrorHandler): void;
addRoutes (routes: RouteConfig[]): void;
resolve (to: RawLocation, current?: Route, append?: boolean): {
location: Location;
route: Route;
href: string;
// backwards compat
normalizedTo: Location;
resolved: Route;
};
static install: PluginFunction<never>;
}
type Position = { x: number, y: number };
type PositionResult = Position | { selector: string, offset?: Position } | void;
export interface RouterOptions {
routes?: RouteConfig[];
mode?: RouterMode;
fallback?: boolean;
base?: string;
linkActiveClass?: string;
linkExactActiveClass?: string;
parseQuery?: (query: string) => Object;
stringifyQuery?: (query: Object) => string;
scrollBehavior?: (
to: Route,
from: Route,
savedPosition: Position | void
) => PositionResult | Promise<PositionResult>;
}
type RoutePropsFunction = (route: Route) => Object;
export interface PathToRegexpOptions {
sensitive?: boolean;
strict?: boolean;
end?: boolean;
}
export interface RouteConfig {
path: string;
name?: string;
component?: Component;
components?: Dictionary<Component>;
redirect?: RedirectOption;
alias?: string | string[];
children?: RouteConfig[];
meta?: any;
beforeEnter?: NavigationGuard;
props?: boolean | Object | RoutePropsFunction;
caseSensitive?: boolean;
pathToRegexpOptions?: PathToRegexpOptions;
}
export interface RouteRecord {
path: string;
regex: RegExp;
components: Dictionary<Component>;
instances: Dictionary<Vue>;
name?: string;
parent?: RouteRecord;
redirect?: RedirectOption;
matchAs?: string;
meta: any;
beforeEnter?: (
route: Route,
redirect: (location: RawLocation) => void,
next: () => void
) => any;
props: boolean | Object | RoutePropsFunction | Dictionary<boolean | Object | RoutePropsFunction>;
}
export interface Location {
name?: string;
path?: string;
hash?: string;
query?: Dictionary<string | (string | null)[] | null | undefined>;
params?: Dictionary<string>;
append?: boolean;
replace?: boolean;
}
export interface Route {
path: string;
name?: string;
hash: string;
query: Dictionary<string | (string | null)[]>;
params: Dictionary<string>;
fullPath: string;
matched: RouteRecord[];
redirectedFrom?: string;
meta?: any;
}
/**
* Augment the typings of Vue.js
*/
import Vue from "vue";
import VueRouter, { Route, RawLocation, NavigationGuard } from "./index";
declare module "vue/vue" {
interface Vue {
$router: VueRouter;
$route: Route;
}
}
declare module "vue/options" {
interface ComponentOptions<V extends Vue> {
router?: VueRouter;
beforeRouteEnter?: NavigationGuard<V>;
beforeRouteLeave?: NavigationGuard<V>;
beforeRouteUpdate?: NavigationGuard<V>;
}
}
import { Vue } from "./vue";
export default Vue;
export as namespace Vue;
export {
CreateElement,
VueConstructor
} from "./vue";
export {
Component,
AsyncComponent,
ComponentOptions,
FunctionalComponentOptions,
RenderContext,
PropType,
PropOptions,
ComputedOptions,
WatchHandler,
WatchOptions,
WatchOptionsWithHandler,
DirectiveFunction,
DirectiveOptions
} from "./options";
export {
PluginFunction,
PluginObject
} from "./plugin";
export {
VNodeChildren,
VNodeChildrenArrayContents,
VNode,
VNodeComponentOptions,
VNodeData,
VNodeDirective
} from "./vnode";
import { Vue, CreateElement, CombinedVueInstance } from "./vue";
import { VNode, VNodeData, VNodeDirective, ScopedSlot } from "./vnode";
type Constructor = {
new (...args: any[]): any;
}
// we don't support infer props in async component
// N.B. ComponentOptions<V> is contravariant, the default generic should be bottom type
export type Component<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> =
| typeof Vue
| FunctionalComponentOptions<Props>
| ComponentOptions<never, Data, Methods, Computed, Props>
interface EsModuleComponent {
default: Component
}
export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps>
= AsyncComponentPromise<Data, Methods, Computed, Props>
| AsyncComponentFactory<Data, Methods, Computed, Props>
export type AsyncComponentPromise<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = (
resolve: (component: Component<Data, Methods, Computed, Props>) => void,
reject: (reason?: any) => void
) => Promise<Component | EsModuleComponent> | void;
export type AsyncComponentFactory<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = () => {
component: AsyncComponentPromise<Data, Methods, Computed, Props>;
loading?: Component | EsModuleComponent;
error?: Component | EsModuleComponent;
delay?: number;
timeout?: number;
}
/**
* When the `Computed` type parameter on `ComponentOptions` is inferred,
* it should have a property with the return type of every get-accessor.
* Since there isn't a way to query for the return type of a function, we allow TypeScript
* to infer from the shape of `Accessors<Computed>` and work backwards.
*/
export type Accessors<T> = {
[K in keyof T]: (() => T[K]) | ComputedOptions<T[K]>
}
type DataDef<Data, Props, V> = Data | ((this: Readonly<Props> & V) => Data)
/**
* This type should be used when an array of strings is used for a component's `props` value.
*/
export type ThisTypedComponentOptionsWithArrayProps<V extends Vue, Data, Methods, Computed, PropNames extends string> =
object &
ComponentOptions<V, DataDef<Data, Record<PropNames, any>, V>, Methods, Computed, PropNames[], Record<PropNames, any>> &
ThisType<CombinedVueInstance<V, Data, Methods, Computed, Readonly<Record<PropNames, any>>>>;
/**
* This type should be used when an object mapped to `PropOptions` is used for a component's `props` value.
*/
export type ThisTypedComponentOptionsWithRecordProps<V extends Vue, Data, Methods, Computed, Props> =
object &
ComponentOptions<V, DataDef<Data, Props, V>, Methods, Computed, RecordPropsDefinition<Props>, Props> &
ThisType<CombinedVueInstance<V, Data, Methods, Computed, Readonly<Props>>>;
type DefaultData<V> = object | ((this: V) => object);
type DefaultProps = Record<string, any>;
type DefaultMethods<V> = { [key: string]: (this: V, ...args: any[]) => any };
type DefaultComputed = { [key: string]: any };
export interface ComponentOptions<
V extends Vue,
Data=DefaultData<V>,
Methods=DefaultMethods<V>,
Computed=DefaultComputed,
PropsDef=PropsDefinition<DefaultProps>,
Props=DefaultProps> {
data?: Data;
props?: PropsDef;
propsData?: object;
computed?: Accessors<Computed>;
methods?: Methods;
watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any> | string>;
el?: Element | string;
template?: string;
// hack is for functional component type inference, should not be used in user code
render?(createElement: CreateElement, hack: RenderContext<Props>): VNode;
renderError?(createElement: CreateElement, err: Error): VNode;
staticRenderFns?: ((createElement: CreateElement) => VNode)[];
beforeCreate?(this: V): void;
created?(): void;
beforeDestroy?(): void;
destroyed?(): void;
beforeMount?(): void;
mounted?(): void;
beforeUpdate?(): void;
updated?(): void;
activated?(): void;
deactivated?(): void;
errorCaptured?(err: Error, vm: Vue, info: string): boolean | void;
serverPrefetch?(this: V): Promise<void>;
directives?: { [key: string]: DirectiveFunction | DirectiveOptions };
components?: { [key: string]: Component<any, any, any, any> | AsyncComponent<any, any, any, any> };
transitions?: { [key: string]: object };
filters?: { [key: string]: Function };
provide?: object | (() => object);
inject?: InjectOptions;
model?: {
prop?: string;
event?: string;
};
parent?: Vue;
mixins?: (ComponentOptions<Vue> | typeof Vue)[];
name?: string;
// TODO: support properly inferred 'extends'
extends?: ComponentOptions<Vue> | typeof Vue;
delimiters?: [string, string];
comments?: boolean;
inheritAttrs?: boolean;
}
export interface FunctionalComponentOptions<Props = DefaultProps, PropDefs = PropsDefinition<Props>> {
name?: string;
props?: PropDefs;
model?: {
prop?: string;
event?: string;
};
inject?: InjectOptions;
functional: boolean;
render?(this: undefined, createElement: CreateElement, context: RenderContext<Props>): VNode | VNode[];
}
export interface RenderContext<Props=DefaultProps> {
props: Props;
children: VNode[];
slots(): any;
data: VNodeData;
parent: Vue;
listeners: { [key: string]: Function | Function[] };
scopedSlots: { [key: string]: ScopedSlot };
injections: any
}
export type Prop<T> = { (): T } | { new(...args: any[]): T & object }
export type PropType<T> = Prop<T> | Prop<T>[];
export type PropValidator<T> = PropOptions<T> | PropType<T>;
export interface PropOptions<T=any> {
type?: PropType<T>;
required?: boolean;
default?: T | null | undefined | (() => T | null | undefined);
validator?(value: T): boolean;
}
export type RecordPropsDefinition<T> = {
[K in keyof T]: PropValidator<T[K]>
}
export type ArrayPropsDefinition<T> = (keyof T)[];
export type PropsDefinition<T> = ArrayPropsDefinition<T> | RecordPropsDefinition<T>;
export interface ComputedOptions<T> {
get?(): T;
set?(value: T): void;
cache?: boolean;
}
export type WatchHandler<T> = (val: T, oldVal: T) => void;
export interface WatchOptions {
deep?: boolean;
immediate?: boolean;
}
export interface WatchOptionsWithHandler<T> extends WatchOptions {
handler: WatchHandler<T>;
}
export interface DirectiveBinding extends Readonly<VNodeDirective> {
readonly modifiers: { [key: string]: boolean };
}
export type DirectiveFunction = (
el: HTMLElement,
binding: DirectiveBinding,
vnode: VNode,
oldVnode: VNode
) => void;
export interface DirectiveOptions {
bind?: DirectiveFunction;
inserted?: DirectiveFunction;
update?: DirectiveFunction;
componentUpdated?: DirectiveFunction;
unbind?: DirectiveFunction;
}
export type InjectKey = string | symbol;
export type InjectOptions = {
[key: string]: InjectKey | { from?: InjectKey, default?: any }
} | string[];
import { Vue as _Vue } from "./vue";
export type PluginFunction<T> = (Vue: typeof _Vue, options?: T) => void;
export interface PluginObject<T> {
install: PluginFunction<T>;
[key: string]: any;
}
import { Vue } from "./vue";
export type ScopedSlot = (props: any) => ScopedSlotReturnValue;
type ScopedSlotReturnValue = VNode | string | boolean | null | undefined | ScopedSlotReturnArray;
interface ScopedSlotReturnArray extends Array<ScopedSlotReturnValue> {}
// Scoped slots are guaranteed to return Array of VNodes starting in 2.6
export type NormalizedScopedSlot = (props: any) => ScopedSlotChildren;
export type ScopedSlotChildren = VNode[] | undefined;
// Relaxed type compatible with $createElement
export type VNodeChildren = VNodeChildrenArrayContents | [ScopedSlot] | string | boolean | null | undefined;
export interface VNodeChildrenArrayContents extends Array<VNodeChildren | VNode> {}
export interface VNode {
tag?: string;
data?: VNodeData;
children?: VNode[];
text?: string;
elm?: Node;
ns?: string;
context?: Vue;
key?: string | number;
componentOptions?: VNodeComponentOptions;
componentInstance?: Vue;
parent?: VNode;
raw?: boolean;
isStatic?: boolean;
isRootInsert: boolean;
isComment: boolean;
}
export interface VNodeComponentOptions {
Ctor: typeof Vue;
propsData?: object;
listeners?: object;
children?: VNode[];
tag?: string;
}
export interface VNodeData {
key?: string | number;
slot?: string;
scopedSlots?: { [key: string]: ScopedSlot | undefined };
ref?: string;
refInFor?: boolean;
tag?: string;
staticClass?: string;
class?: any;
staticStyle?: { [key: string]: any };
style?: object[] | object;
props?: { [key: string]: any };
attrs?: { [key: string]: any };
domProps?: { [key: string]: any };
hook?: { [key: string]: Function };
on?: { [key: string]: Function | Function[] };
nativeOn?: { [key: string]: Function | Function[] };
transition?: object;
show?: boolean;
inlineTemplate?: {
render: Function;
staticRenderFns: Function[];
};
directives?: VNodeDirective[];
keepAlive?: boolean;
}
export interface VNodeDirective {
name: string;
value?: any;
oldValue?: any;
expression?: any;
arg?: string;
oldArg?: string;
modifiers?: { [key: string]: boolean };
}
import {
Component,
AsyncComponent,
ComponentOptions,
FunctionalComponentOptions,
WatchOptionsWithHandler,
WatchHandler,
DirectiveOptions,
DirectiveFunction,
RecordPropsDefinition,
ThisTypedComponentOptionsWithArrayProps,
ThisTypedComponentOptionsWithRecordProps,
WatchOptions,
} from "./options";
import { VNode, VNodeData, VNodeChildren, ScopedSlot, NormalizedScopedSlot } from "./vnode";
import { PluginFunction, PluginObject } from "./plugin";
export interface CreateElement {
(tag?: string | Component<any, any, any, any> | AsyncComponent<any, any, any, any> | (() => Component), children?: VNodeChildren): VNode;
(tag?: string | Component<any, any, any, any> | AsyncComponent<any, any, any, any> | (() => Component), data?: VNodeData, children?: VNodeChildren): VNode;
}
export interface Vue {
readonly $el: Element;
readonly $options: ComponentOptions<Vue>;
readonly $parent: Vue;
readonly $root: Vue;
readonly $children: Vue[];
readonly $refs: { [key: string]: Vue | Element | Vue[] | Element[] };
readonly $slots: { [key: string]: VNode[] | undefined };
readonly $scopedSlots: { [key: string]: NormalizedScopedSlot | undefined };
readonly $isServer: boolean;
readonly $data: Record<string, any>;
readonly $props: Record<string, any>;
readonly $ssrContext: any;
readonly $vnode: VNode;
readonly $attrs: Record<string, string>;
readonly $listeners: Record<string, Function | Function[]>;
$mount(elementOrSelector?: Element | string, hydrating?: boolean): this;
$forceUpdate(): void;
$destroy(): void;
$set: typeof Vue.set;
$delete: typeof Vue.delete;
$watch(
expOrFn: string,
callback: (this: this, n: any, o: any) => void,
options?: WatchOptions
): (() => void);
$watch<T>(
expOrFn: (this: this) => T,
callback: (this: this, n: T, o: T) => void,
options?: WatchOptions
): (() => void);
$on(event: string | string[], callback: Function): this;
$once(event: string | string[], callback: Function): this;
$off(event?: string | string[], callback?: Function): this;
$emit(event: string, ...args: any[]): this;
$nextTick(callback: (this: this) => void): void;
$nextTick(): Promise<void>;
$createElement: CreateElement;
}
export type CombinedVueInstance<Instance extends Vue, Data, Methods, Computed, Props> = Data & Methods & Computed & Props & Instance;
export type ExtendedVue<Instance extends Vue, Data, Methods, Computed, Props> = VueConstructor<CombinedVueInstance<Instance, Data, Methods, Computed, Props> & Vue>;
export interface VueConfiguration {
silent: boolean;
optionMergeStrategies: any;
devtools: boolean;
productionTip: boolean;
performance: boolean;
errorHandler(err: Error, vm: Vue, info: string): void;
warnHandler(msg: string, vm: Vue, trace: string): void;
ignoredElements: (string | RegExp)[];
keyCodes: { [key: string]: number | number[] };
async: boolean;
}
export interface VueConstructor<V extends Vue = Vue> {
new <Data = object, Methods = object, Computed = object, PropNames extends string = never>(options?: ThisTypedComponentOptionsWithArrayProps<V, Data, Methods, Computed, PropNames>): CombinedVueInstance<V, Data, Methods, Computed, Record<PropNames, any>>;
// ideally, the return type should just contain Props, not Record<keyof Props, any>. But TS requires to have Base constructors with the same return type.
new <Data = object, Methods = object, Computed = object, Props = object>(options?: ThisTypedComponentOptionsWithRecordProps<V, Data, Methods, Computed, Props>): CombinedVueInstance<V, Data, Methods, Computed, Record<keyof Props, any>>;
new (options?: ComponentOptions<V>): CombinedVueInstance<V, object, object, object, Record<keyof object, any>>;
extend<Data, Methods, Computed, PropNames extends string = never>(options?: ThisTypedComponentOptionsWithArrayProps<V, Data, Methods, Computed, PropNames>): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>>;
extend<Data, Methods, Computed, Props>(options?: ThisTypedComponentOptionsWithRecordProps<V, Data, Methods, Computed, Props>): ExtendedVue<V, Data, Methods, Computed, Props>;
extend<PropNames extends string = never>(definition: FunctionalComponentOptions<Record<PropNames, any>, PropNames[]>): ExtendedVue<V, {}, {}, {}, Record<PropNames, any>>;
extend<Props>(definition: FunctionalComponentOptions<Props, RecordPropsDefinition<Props>>): ExtendedVue<V, {}, {}, {}, Props>;
extend(options?: ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}>;
nextTick<T>(callback: (this: T) => void, context?: T): void;
nextTick(): Promise<void>
set<T>(object: object, key: string | number, value: T): T;
set<T>(array: T[], key: number, value: T): T;
delete(object: object, key: string | number): void;
delete<T>(array: T[], key: number): void;
directive(
id: string,
definition?: DirectiveOptions | DirectiveFunction
): DirectiveOptions;
filter(id: string, definition?: Function): Function;
component(id: string): VueConstructor;
component<VC extends VueConstructor>(id: string, constructor: VC): VC;
component<Data, Methods, Computed, Props>(id: string, definition: AsyncComponent<Data, Methods, Computed, Props>): ExtendedVue<V, Data, Methods, Computed, Props>;
component<Data, Methods, Computed, PropNames extends string = never>(id: string, definition?: ThisTypedComponentOptionsWithArrayProps<V, Data, Methods, Computed, PropNames>): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>>;
component<Data, Methods, Computed, Props>(id: string, definition?: ThisTypedComponentOptionsWithRecordProps<V, Data, Methods, Computed, Props>): ExtendedVue<V, Data, Methods, Computed, Props>;
component<PropNames extends string>(id: string, definition: FunctionalComponentOptions<Record<PropNames, any>, PropNames[]>): ExtendedVue<V, {}, {}, {}, Record<PropNames, any>>;
component<Props>(id: string, definition: FunctionalComponentOptions<Props, RecordPropsDefinition<Props>>): ExtendedVue<V, {}, {}, {}, Props>;
component(id: string, definition?: ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}>;
use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): VueConstructor<V>;
use(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): VueConstructor<V>;
mixin(mixin: VueConstructor | ComponentOptions<Vue>): VueConstructor<V>;
compile(template: string): {
render(createElement: typeof Vue.prototype.$createElement): VNode;
staticRenderFns: (() => VNode)[];
};
observable<T>(obj: T): T;
config: VueConfiguration;
version: string;
}
export const Vue: VueConstructor;
import 'fetch-everywhere';
export interface IReturnVoid {
createResponse(): any;
}
export interface IReturn<T> {
createResponse(): T;
}
export declare class ResponseStatus {
constructor(init?: Partial<ResponseStatus>);
errorCode: string;
message: string;
stackTrace: string;
errors: ResponseError[];
meta: {
[index: string]: string;
};
}
export declare class ResponseError {
constructor(init?: Partial<ResponseError>);
errorCode: string;
fieldName: string;
message: string;
meta: {
[index: string]: string;
};
}
export declare class ErrorResponse {
constructor(init?: Partial<ErrorResponse>);
type: ErrorResponseType;
responseStatus: ResponseStatus;
}
export declare class NavItem {
label: string;
href: string;
exact: boolean;
id: string;
className: string;
iconHtml: string;
show: string;
hide: string;
children: NavItem[];
meta: {
[index: string]: string;
};
constructor(init?: Partial<NavItem>);
}
export declare class GetNavItems {
constructor(init?: Partial<GetNavItems>);
createResponse(): GetNavItemsResponse;
getTypeName(): string;
}
export declare class GetNavItemsResponse {
baseUrl: string;
results: NavItem[];
navItemsMap: {
[index: string]: NavItem[];
};
meta: {
[index: string]: string;
};
responseStatus: ResponseStatus;
constructor(init?: Partial<GetNavItemsResponse>);
}
export declare type ErrorResponseType = null | "RefreshTokenException";
export interface IAuthSession {
userName: string;
displayName: string;
userId?: string;
roles?: string[];
permissions?: string[];
profileUrl?: string;
}
export interface IResolver {
tryResolve(Function: any): any;
}
export declare class NewInstanceResolver implements IResolver {
tryResolve(ctor: ObjectConstructor): any;
}
export declare class SingletonInstanceResolver implements IResolver {
tryResolve(ctor: ObjectConstructor): any;
}
export interface ServerEventMessage {
type: "ServerEventConnect" | "ServerEventHeartbeat" | "ServerEventJoin" | "ServerEventLeave" | "ServerEventUpdate" | "ServerEventMessage";
eventId: number;
channel: string;
data: string;
selector: string;
json: string;
op: string;
target: string;
cssSelector: string;
body: any;
meta: {
[index: string]: string;
};
}
export interface ServerEventCommand extends ServerEventMessage {
userId: string;
displayName: string;
channels: string;
profileUrl: string;
}
export interface ServerEventConnect extends ServerEventCommand {
id: string;
unRegisterUrl: string;
heartbeatUrl: string;
updateSubscriberUrl: string;
heartbeatIntervalMs: number;
idleTimeoutMs: number;
}
export interface ServerEventHeartbeat extends ServerEventCommand {
}
export interface ServerEventJoin extends ServerEventCommand {
}
export interface ServerEventLeave extends ServerEventCommand {
}
export interface ServerEventUpdate extends ServerEventCommand {
}
export interface IReconnectServerEventsOptions {
url?: string;
onerror?: (...args: any[]) => void;
onmessage?: (...args: any[]) => void;
error?: Error;
}
/**
* EventSource
*/
export declare enum ReadyState {
CONNECTING = 0,
OPEN = 1,
CLOSED = 2,
}
export interface IEventSourceStatic extends EventTarget {
new (url: string, eventSourceInitDict?: IEventSourceInit): IEventSourceStatic;
url: string;
withCredentials: boolean;
CONNECTING: ReadyState;
OPEN: ReadyState;
CLOSED: ReadyState;
readyState: ReadyState;
onopen: Function;
onmessage: (event: IOnMessageEvent) => void;
onerror: Function;
close: () => void;
}
export interface IEventSourceInit {
withCredentials?: boolean;
}
export interface IOnMessageEvent {
data: string;
}
export interface IEventSourceOptions {
channels?: string;
handlers?: any;
receivers?: any;
onException?: Function;
onReconnect?: Function;
onTick?: Function;
resolver?: IResolver;
validate?: (request: ServerEventMessage) => boolean;
heartbeatUrl?: string;
unRegisterUrl?: string;
updateSubscriberUrl?: string;
heartbeatIntervalMs?: number;
heartbeat?: number;
resolveStreamUrl?: (url: string) => string;
}
export declare class ServerEventsClient {
channels: string[];
options: IEventSourceOptions;
eventSource: IEventSourceStatic;
static UnknownChannel: string;
eventStreamUri: string;
updateSubscriberUrl: string;
connectionInfo: ServerEventConnect;
serviceClient: JsonServiceClient;
stopped: boolean;
resolver: IResolver;
listeners: {
[index: string]: ((e: ServerEventMessage) => void)[];
};
EventSource: IEventSourceStatic;
withCredentials: boolean;
constructor(baseUrl: string, channels: string[], options?: IEventSourceOptions, eventSource?: IEventSourceStatic);
onMessage: (e: IOnMessageEvent) => void;
onError: (error?: any) => void;
getEventSourceOptions(): {
withCredentials: boolean;
};
reconnectServerEvents(opt?: IReconnectServerEventsOptions): IEventSourceStatic;
start(): this;
stop(): Promise<void>;
invokeReceiver(r: any, cmd: string, el: Element, request: ServerEventMessage, name: string): void;
hasConnected(): boolean;
registerHandler(name: string, fn: Function): this;
setResolver(resolver: IResolver): this;
registerReceiver(receiver: any): this;
registerNamedReceiver(name: string, receiver: any): this;
unregisterReceiver(name?: string): this;
updateChannels(channels: string[]): void;
update(subscribe: string | string[], unsubscribe: string | string[]): void;
addListener(eventName: string, handler: ((e: ServerEventMessage) => void)): this;
removeListener(eventName: string, handler: ((e: ServerEventMessage) => void)): this;
raiseEvent(eventName: string, msg: ServerEventMessage): void;
getConnectionInfo(): ServerEventConnect;
getSubscriptionId(): string;
updateSubscriber(request: UpdateEventSubscriber): Promise<void>;
subscribeToChannels(...channels: string[]): Promise<void>;
unsubscribeFromChannels(...channels: string[]): Promise<void>;
getChannelSubscribers(): Promise<ServerEventUser[]>;
toServerEventUser(map: {
[id: string]: string;
}): ServerEventUser;
}
export interface IReceiver {
noSuchMethod(selector: string, message: any): any;
}
export declare class ServerEventReceiver implements IReceiver {
client: ServerEventsClient;
request: ServerEventMessage;
noSuchMethod(selector: string, message: any): void;
}
export declare class UpdateEventSubscriber implements IReturn<UpdateEventSubscriberResponse> {
id: string;
subscribeChannels: string[];
unsubscribeChannels: string[];
createResponse(): UpdateEventSubscriberResponse;
getTypeName(): string;
}
export declare class UpdateEventSubscriberResponse {
responseStatus: ResponseStatus;
}
export declare class GetEventSubscribers implements IReturn<any[]> {
channels: string[];
createResponse(): any[];
getTypeName(): string;
}
export declare class ServerEventUser {
userId: string;
displayName: string;
profileUrl: string;
channels: string[];
meta: {
[index: string]: string;
};
}
export declare class HttpMethods {
static Get: string;
static Post: string;
static Put: string;
static Delete: string;
static Patch: string;
static Head: string;
static Options: string;
static hasRequestBody: (method: string) => boolean;
}
export interface IRequestFilterOptions {
url: string;
}
export interface IRequestInit extends RequestInit {
url?: string;
compress?: boolean;
}
export interface Cookie {
name: string;
value: string;
path: string;
domain?: string;
expires?: Date;
httpOnly?: boolean;
secure?: boolean;
sameSite?: string;
}
export declare class GetAccessTokenResponse {
accessToken: string;
responseStatus: ResponseStatus;
}
export interface ISendRequest {
method: string;
request: any | null;
body?: any | null;
args?: any;
url?: string;
returns?: {
createResponse: () => any;
};
}
export declare class JsonServiceClient {
baseUrl: string;
replyBaseUrl: string;
oneWayBaseUrl: string;
mode: RequestMode;
credentials: RequestCredentials;
headers: Headers;
userName: string;
password: string;
bearerToken: string;
refreshToken: string;
refreshTokenUri: string;
useTokenCookie: boolean;
requestFilter: (req: IRequestInit) => void;
responseFilter: (res: Response) => void;
exceptionFilter: (res: Response, error: any) => void;
urlFilter: (url: string) => void;
onAuthenticationRequired: () => Promise<any>;
manageCookies: boolean;
cookies: {
[index: string]: Cookie;
};
static toBase64: (rawString: string) => string;
constructor(baseUrl?: string);
setCredentials(userName: string, password: string): void;
setBearerToken(token: string): void;
get<T>(request: IReturn<T> | string, args?: any): Promise<T>;
delete<T>(request: IReturn<T> | string, args?: any): Promise<T>;
post<T>(request: IReturn<T>, args?: any): Promise<T>;
postToUrl<T>(url: string, request: IReturn<T>, args?: any): Promise<T>;
postBody<T>(request: IReturn<T>, body: string | any, args?: any): Promise<T>;
put<T>(request: IReturn<T>, args?: any): Promise<T>;
putToUrl<T>(url: string, request: IReturn<T>, args?: any): Promise<T>;
putBody<T>(request: IReturn<T>, body: string | any, args?: any): Promise<T>;
patch<T>(request: IReturn<T>, args?: any): Promise<T>;
patchToUrl<T>(url: string, request: IReturn<T>, args?: any): Promise<T>;
patchBody<T>(request: IReturn<T>, body: string | any, args?: any): Promise<T>;
sendAll<T>(requests: IReturn<T>[]): Promise<T[]>;
sendAllOneWay<T>(requests: IReturn<T>[]): Promise<void>;
createUrlFromDto<T>(method: string, request: IReturn<T>): string;
toAbsoluteUrl(relativeOrAbsoluteUrl: string): string;
deleteCookie(name: string): void;
private createRequest({method, request, url, args, body});
private createResponse<T>(res, request);
private handleError(holdRes, res, type?);
send<T>(method: string, request: any | null, args?: any, url?: string): Promise<T>;
private sendBody<T>(method, request, body, args?);
sendRequest<T>(info: ISendRequest): Promise<T>;
raiseError(res: Response, error: any): any;
}
export declare const isFormData: (body: any) => boolean;
export declare const toCamelCase: (s: string) => string;
export declare const toPascalCase: (s: string) => string;
export declare const sanitize: (status: any) => any;
export declare const nameOf: (o: any) => any;
export declare const css: (selector: string | NodeListOf<Element>, name: string, value: string) => void;
export declare const splitOnFirst: (s: string, c: string) => string[];
export declare const splitOnLast: (s: string, c: string) => string[];
export declare const humanize: (s: any) => any;
export declare const queryString: (url: string) => any;
export declare const combinePaths: (...paths: string[]) => string;
export declare const createPath: (route: string, args: any) => string;
export declare const createUrl: (route: string, args: any) => string;
export declare const appendQueryString: (url: string, args: any) => string;
export declare const bytesToBase64: (aBytes: Uint8Array) => string;
export declare const stripQuotes: (s: string) => string;
export declare const tryDecode: (s: string) => string;
export declare const parseCookie: (setCookie: string) => Cookie;
export declare const normalizeKey: (key: string) => string;
export declare const normalize: (dto: any, deep?: boolean) => any;
export declare const getField: (o: any, name: string) => any;
export declare const parseResponseStatus: (json: string, defaultMsg?: any) => any;
export declare function toFormData(o: any): FormData;
export declare function toObject(keys: any): {};
export declare function errorResponseSummary(): any;
export declare function errorResponseExcept(fieldNames: string[] | string): any;
export declare function errorResponse(fieldName: string): any;
export declare const toDate: (s: any) => Date;
export declare const toDateFmt: (s: string) => string;
export declare const padInt: (n: number) => string | number;
export declare const dateFmt: (d?: Date) => string;
export declare const dateFmtHM: (d?: Date) => string;
export declare const timeFmt12: (d?: Date) => string;
export interface ICreateElementOptions {
insertAfter?: Element | null;
}
export declare function createElement(tagName: string, options?: ICreateElementOptions, attrs?: any): HTMLElement;
export declare function bootstrap(el?: Element): void;
export declare function bindHandlers(handlers: any, el?: Node): void;
export interface IAjaxFormOptions {
type?: string;
url?: string;
model?: any;
credentials?: RequestCredentials;
validate?: (this: HTMLFormElement) => boolean;
onSubmitDisable?: string;
submit?: (this: HTMLFormElement, options: IAjaxFormOptions) => Promise<any>;
success?: (this: HTMLFormElement, result: any) => void;
error?: (this: HTMLFormElement, e: any) => void;
complete?: (this: HTMLFormElement) => void;
requestFilter?: (req: IRequestInit) => void;
responseFilter?: (res: Response) => void;
errorFilter?: (this: IValidation, message: string, errorCode: string, type: string) => void;
messages?: {
[index: string]: string;
};
}
export declare function bootstrapForm(form: HTMLFormElement | null, options: IAjaxFormOptions): void;
export interface IValidation {
overrideMessages: boolean;
messages: {
[index: string]: string;
};
errorFilter?: (this: IValidation, message: string, errorCode: string, type: string) => void;
}
export declare const toVarNames: (names: string | string[]) => string[];
export declare function formSubmit(this: HTMLFormElement, options?: IAjaxFormOptions): Promise<any>;
export declare function ajaxSubmit(f: HTMLFormElement, options?: IAjaxFormOptions): any;
export declare function serializeForm(form: HTMLFormElement, contentType?: string | null): string | FormData;
export declare const serializeToObject: (form: HTMLFormElement) => any;
export declare function serializeToUrlEncoded(form: HTMLFormElement): string;
export declare const serializeToFormData: (form: HTMLFormElement) => FormData;
export declare function triggerEvent(el: Element, name: string, data?: any): void;
export declare function populateForm(form: HTMLFormElement, model: any): void;
export declare function trimEnd(s: string, c: string): string;
export declare function safeVarName(s: string): string;
export declare function pick(o: any, keys: string[]): {};
export declare function omit(o: any, keys: string[]): {};
export declare function activeClassNav(x: NavItem, activePath: string): string;
export declare function activeClass(href: string | null, activePath: string, exact?: boolean): string;
export declare const BootstrapColors: string[];
export declare function btnColorClass(props: any): string;
export declare const BootstrapSizes: string[];
export declare function btnSizeClass(props: any): string;
export declare function btnClasses(props: any): any[];
export declare class NavDefaults {
static navClass: string;
static navItemClass: string;
static navLinkClass: string;
static childNavItemClass: string;
static childNavLinkClass: string;
static childNavMenuClass: string;
static childNavMenuItemClass: string;
static parseIconHtml: ((html: string) => any) | null;
static create(): NavOptions;
static forNav(options?: NavOptions | null): NavOptions;
static overrideDefaults(targets: NavOptions | null | undefined, source: NavOptions): NavOptions;
static showNav(navItem: NavItem, attributes: string[]): boolean;
}
export declare class NavLinkDefaults {
static forNavLink(options?: NavOptions | null): NavOptions;
}
export declare class NavbarDefaults {
static navClass: string;
static create(): NavOptions;
static forNavbar(options?: NavOptions | null): NavOptions;
}
export declare class NavButtonGroupDefaults {
static navClass: string;
static navItemClass: string;
static create(): NavOptions;
static forNavButtonGroup(options?: NavOptions | null): NavOptions;
}
export declare class LinkButtonDefaults {
static navItemClass: string;
static create(): NavOptions;
static forLinkButton(options?: NavOptions | null): NavOptions;
}
export declare class UserAttributes {
static fromSession(session: IAuthSession | null): string[];
}
export declare class NavOptions {
static fromSession(session: IAuthSession | null, to?: NavOptions): NavOptions;
attributes: string[];
activePath?: string;
baseHref?: string;
navClass?: string;
navItemClass?: string;
navLinkClass?: string;
childNavItemClass?: string;
childNavLinkClass?: string;
childNavMenuClass?: string;
childNavMenuItemClass?: string;
constructor(init?: Partial<NavOptions>);
}
export declare function classNames(...args: any[]): string;
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "fetch-everywhere"], factory);
}
else if (typeof window != "undefined") factory(window.require||function(){}, window["@servicestack/client"]={});
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("fetch-everywhere");
var ResponseStatus = /** @class */ (function () {
function ResponseStatus(init) {
Object.assign(this, init);
}
return ResponseStatus;
}());
exports.ResponseStatus = ResponseStatus;
var ResponseError = /** @class */ (function () {
function ResponseError(init) {
Object.assign(this, init);
}
return ResponseError;
}());
exports.ResponseError = ResponseError;
var ErrorResponse = /** @class */ (function () {
function ErrorResponse(init) {
Object.assign(this, init);
}
return ErrorResponse;
}());
exports.ErrorResponse = ErrorResponse;
var NavItem = /** @class */ (function () {
function NavItem(init) {
Object.assign(this, init);
}
return NavItem;
}());
exports.NavItem = NavItem;
var GetNavItems = /** @class */ (function () {
function GetNavItems(init) {
Object.assign(this, init);
}
GetNavItems.prototype.createResponse = function () { return new GetNavItemsResponse(); };
GetNavItems.prototype.getTypeName = function () { return 'GetNavItems'; };
return GetNavItems;
}());
exports.GetNavItems = GetNavItems;
var GetNavItemsResponse = /** @class */ (function () {
function GetNavItemsResponse(init) {
Object.assign(this, init);
}
return GetNavItemsResponse;
}());
exports.GetNavItemsResponse = GetNavItemsResponse;
var NewInstanceResolver = /** @class */ (function () {
function NewInstanceResolver() {
}
NewInstanceResolver.prototype.tryResolve = function (ctor) {
return new ctor();
};
return NewInstanceResolver;
}());
exports.NewInstanceResolver = NewInstanceResolver;
var SingletonInstanceResolver = /** @class */ (function () {
function SingletonInstanceResolver() {
}
SingletonInstanceResolver.prototype.tryResolve = function (ctor) {
return ctor.instance
|| (ctor.instance = new ctor());
};
return SingletonInstanceResolver;
}());
exports.SingletonInstanceResolver = SingletonInstanceResolver;
var TypeMap = {
onConnect: "ServerEventConnect",
onHeartbeat: "ServerEventHeartbeat",
onJoin: "ServerEventJoin",
onLeave: "ServerEventLeave",
onUpdate: "ServerEventUpdate"
};
/**
* EventSource
*/
var ReadyState;
(function (ReadyState) {
ReadyState[ReadyState["CONNECTING"] = 0] = "CONNECTING";
ReadyState[ReadyState["OPEN"] = 1] = "OPEN";
ReadyState[ReadyState["CLOSED"] = 2] = "CLOSED";
})(ReadyState = exports.ReadyState || (exports.ReadyState = {}));
var ServerEventsClient = /** @class */ (function () {
function ServerEventsClient(baseUrl, channels, options, eventSource) {
if (options === void 0) { options = {}; }
if (eventSource === void 0) { eventSource = null; }
var _this = this;
this.channels = channels;
this.options = options;
this.eventSource = eventSource;
this.onMessage = function (e) {
if (_this.stopped)
return;
var opt = _this.options;
if (typeof document == "undefined") {
var document = {
querySelectorAll: function (sel) { return []; }
};
}
var $ = document.querySelectorAll.bind(document);
var parts = exports.splitOnFirst(e.data, " ");
var channel = null;
var selector = parts[0];
var selParts = exports.splitOnFirst(selector, "@");
if (selParts.length > 1) {
channel = selParts[0];
selector = selParts[1];
}
var json = parts[1];
var body = null;
try {
body = json ? JSON.parse(json) : null;
}
catch (ignore) { }
parts = exports.splitOnFirst(selector, ".");
if (parts.length <= 1)
throw "invalid selector format: " + selector;
var op = parts[0], target = parts[1].replace(new RegExp("%20", "g"), " ");
var tokens = exports.splitOnFirst(target, "$");
var cmd = tokens[0], cssSelector = tokens[1];
var els = cssSelector && $(cssSelector);
var el = els && els[0];
var eventId = parseInt(e.lastEventId);
var data = e.data;
var type = TypeMap[cmd] || "ServerEventMessage";
var request = { eventId: eventId, data: data, type: type,
channel: channel, selector: selector, json: json, body: body, op: op, target: tokens[0], cssSelector: cssSelector, meta: {} };
var mergedBody = typeof body == "object"
? Object.assign({}, request, body)
: request;
if (opt.validate && opt.validate(request) === false)
return;
var headers = new Headers();
headers.set("Content-Type", "text/plain");
if (op === "cmd") {
if (cmd === "onConnect") {
_this.connectionInfo = mergedBody;
if (typeof body.heartbeatIntervalMs == "string")
_this.connectionInfo.heartbeatIntervalMs = parseInt(body.heartbeatIntervalMs);
if (typeof body.idleTimeoutMs == "string")
_this.connectionInfo.idleTimeoutMs = parseInt(body.idleTimeoutMs);
Object.assign(opt, body);
var fn = opt.handlers["onConnect"];
if (fn) {
fn.call(el || document.body, _this.connectionInfo, request);
if (_this.stopped)
return;
}
if (opt.heartbeatUrl) {
if (opt.heartbeat) {
clearInterval(opt.heartbeat);
}
opt.heartbeat = setInterval(function () {
if (_this.eventSource.readyState === EventSource.CLOSED) {
clearInterval(opt.heartbeat);
var stopFn = opt.handlers["onStop"];
if (stopFn != null)
stopFn.apply(_this.eventSource);
_this.reconnectServerEvents({ error: new Error("EventSource is CLOSED") });
return;
}
fetch(new Request(opt.heartbeatUrl, { method: "POST", mode: "cors", headers: headers, credentials: _this.serviceClient.credentials }))
.then(function (res) { if (!res.ok)
throw new Error(res.status + " - " + res.statusText); })
.catch(function (error) { return _this.reconnectServerEvents({ error: error }); });
}, (_this.connectionInfo && _this.connectionInfo.heartbeatIntervalMs) || opt.heartbeatIntervalMs || 10000);
}
if (opt.unRegisterUrl) {
if (typeof window != "undefined") {
window.onunload = function () { return _this.stop(); };
}
}
_this.updateSubscriberUrl = opt.updateSubscriberUrl;
_this.updateChannels((opt.channels || "").split(","));
}
else {
var isCmdMsg = cmd == "onJoin" || cmd == "onLeave" || cmd == "onUpdate";
var fn = opt.handlers[cmd];
if (fn) {
if (isCmdMsg) {
fn.call(el || document.body, mergedBody);
}
else {
fn.call(el || document.body, body, request);
}
}
else {
if (!isCmdMsg) { //global receiver
var r = opt.receivers && opt.receivers["cmd"];
_this.invokeReceiver(r, cmd, el, request, "cmd");
}
}
if (isCmdMsg) {
fn = opt.handlers["onCommand"];
if (fn) {
fn.call(el || document.body, mergedBody);
}
}
}
}
else if (op === "trigger") {
_this.raiseEvent(target, request);
}
else if (op === "css") {
exports.css(els || $("body"), cmd, body);
}
//Named Receiver
var r = opt.receivers && opt.receivers[op];
_this.invokeReceiver(r, cmd, el, request, op);
if (!TypeMap[cmd]) {
var fn = opt.handlers["onMessage"];
if (fn) {
fn.call(el || document.body, mergedBody);
}
}
if (opt.onTick)
opt.onTick();
};
this.onError = function (error) {
if (_this.stopped)
return;
if (!error)
error = event;
var fn = _this.options.onException;
if (fn != null)
fn.call(_this.eventSource, error);
if (_this.options.onTick)
_this.options.onTick();
};
if (this.channels.length === 0)
throw "at least 1 channel is required";
this.resolver = this.options.resolver || new NewInstanceResolver();
this.eventStreamUri = exports.combinePaths(baseUrl, "event-stream") + "?";
this.updateChannels(channels);
this.serviceClient = new JsonServiceClient(baseUrl);
this.listeners = {};
this.withCredentials = true;
if (!this.options.handlers)
this.options.handlers = {};
}
ServerEventsClient.prototype.getEventSourceOptions = function () {
return { withCredentials: this.withCredentials };
};
ServerEventsClient.prototype.reconnectServerEvents = function (opt) {
var _this = this;
if (opt === void 0) { opt = {}; }
if (this.stopped)
return;
if (opt.error)
this.onError(opt.error);
var hold = this.eventSource;
var url = opt.url || this.eventStreamUri || hold.url;
if (this.options.resolveStreamUrl != null) {
url = this.options.resolveStreamUrl(url);
}
var es = this.EventSource
? new this.EventSource(url, this.getEventSourceOptions())
: new EventSource(url, this.getEventSourceOptions());
es.addEventListener('error', function (e) { return opt.onerror || hold.onerror || _this.onError; });
es.addEventListener('message', opt.onmessage || hold.onmessage || this.onMessage);
var fn = this.options.onReconnect;
if (fn != null)
fn.call(es, opt.error);
if (hold.removeEventListener) {
hold.removeEventListener('error', this.onError);
hold.removeEventListener('message', this.onMessage);
}
hold.close();
return this.eventSource = es;
};
ServerEventsClient.prototype.start = function () {
var _this = this;
this.stopped = false;
if (this.eventSource == null || this.eventSource.readyState === EventSource.CLOSED) {
var url = this.eventStreamUri;
if (this.options.resolveStreamUrl != null) {
url = this.options.resolveStreamUrl(url);
}
this.eventSource = this.EventSource
? new this.EventSource(url, this.getEventSourceOptions())
: new EventSource(url, this.getEventSourceOptions());
this.eventSource.addEventListener('error', this.onError);
this.eventSource.addEventListener('message', function (e) { return _this.onMessage(e); });
}
return this;
};
ServerEventsClient.prototype.stop = function () {
this.stopped = true;
if (this.eventSource) {
this.eventSource.close();
}
var opt = this.options;
if (opt && opt.heartbeat) {
clearInterval(opt.heartbeat);
}
var hold = this.connectionInfo;
if (hold == null || hold.unRegisterUrl == null)
return new Promise(function (resolve, reject) { return resolve(); });
this.connectionInfo = null;
return fetch(new Request(hold.unRegisterUrl, { method: "POST", mode: "cors", credentials: this.serviceClient.credentials }))
.then(function (res) { if (!res.ok)
throw new Error(res.status + " - " + res.statusText); })
.catch(this.onError);
};
ServerEventsClient.prototype.invokeReceiver = function (r, cmd, el, request, name) {
if (r) {
if (typeof r == "function") {
r = this.resolver.tryResolve(r);
}
cmd = cmd.replace("-", "");
r.client = this;
r.request = request;
if (typeof (r[cmd]) == "function") {
r[cmd].call(el || r, request.body, request);
}
else if (cmd in r) {
r[cmd] = request.body;
}
else {
var cmdLower = cmd.toLowerCase();
for (var k in r) {
if (k.toLowerCase() == cmdLower) {
if (typeof r[k] == "function") {
r[k].call(el || r, request.body, request);
}
else {
r[k] = request.body;
}
return;
}
}
var noSuchMethod = r["noSuchMethod"];
if (typeof noSuchMethod == "function") {
noSuchMethod.call(el || r, request.target, request);
}
}
}
};
ServerEventsClient.prototype.hasConnected = function () {
return this.connectionInfo != null;
};
ServerEventsClient.prototype.registerHandler = function (name, fn) {
if (!this.options.handlers)
this.options.handlers = {};
this.options.handlers[name] = fn;
return this;
};
ServerEventsClient.prototype.setResolver = function (resolver) {
this.options.resolver = resolver;
return this;
};
ServerEventsClient.prototype.registerReceiver = function (receiver) {
return this.registerNamedReceiver("cmd", receiver);
};
ServerEventsClient.prototype.registerNamedReceiver = function (name, receiver) {
if (!this.options.receivers)
this.options.receivers = {};
this.options.receivers[name] = receiver;
return this;
};
ServerEventsClient.prototype.unregisterReceiver = function (name) {
if (name === void 0) { name = "cmd"; }
if (this.options.receivers) {
delete this.options.receivers[name];
}
return this;
};
ServerEventsClient.prototype.updateChannels = function (channels) {
this.channels = channels;
var url = this.eventSource != null
? this.eventSource.url
: this.eventStreamUri;
this.eventStreamUri = url.substring(0, Math.min(url.indexOf("?"), url.length)) + "?channels=" + channels.join(",") + "&t=" + new Date().getTime();
};
ServerEventsClient.prototype.update = function (subscribe, unsubscribe) {
var sub = typeof subscribe == "string" ? subscribe.split(',') : subscribe;
var unsub = typeof unsubscribe == "string" ? unsubscribe.split(',') : unsubscribe;
var channels = [];
for (var i in this.channels) {
var c = this.channels[i];
if (unsub == null || unsub.indexOf(c) === -1) {
channels.push(c);
}
}
if (sub) {
for (var i in sub) {
var c = sub[i];
if (channels.indexOf(c) === -1) {
channels.push(c);
}
}
}
this.updateChannels(channels);
};
ServerEventsClient.prototype.addListener = function (eventName, handler) {
var handlers = this.listeners[eventName] || (this.listeners[eventName] = []);
handlers.push(handler);
return this;
};
ServerEventsClient.prototype.removeListener = function (eventName, handler) {
var handlers = this.listeners[eventName];
if (handlers) {
var pos = handlers.indexOf(handler);
if (pos >= 0) {
handlers.splice(pos, 1);
}
}
return this;
};
ServerEventsClient.prototype.raiseEvent = function (eventName, msg) {
var _this = this;
var handlers = this.listeners[eventName];
if (handlers) {
handlers.forEach(function (x) {
try {
x(msg);
}
catch (e) {
_this.onError(e);
}
});
}
};
ServerEventsClient.prototype.getConnectionInfo = function () {
if (this.connectionInfo == null)
throw "Not Connected";
return this.connectionInfo;
};
ServerEventsClient.prototype.getSubscriptionId = function () {
return this.getConnectionInfo().id;
};
ServerEventsClient.prototype.updateSubscriber = function (request) {
var _this = this;
if (request.id == null)
request.id = this.getSubscriptionId();
return this.serviceClient.post(request)
.then(function (x) {
_this.update(request.subscribeChannels, request.unsubscribeChannels);
}).catch(this.onError);
};
ServerEventsClient.prototype.subscribeToChannels = function () {
var _this = this;
var channels = [];
for (var _i = 0; _i < arguments.length; _i++) {
channels[_i] = arguments[_i];
}
var request = new UpdateEventSubscriber();
request.id = this.getSubscriptionId();
request.subscribeChannels = channels;
return this.serviceClient.post(request)
.then(function (x) {
_this.update(channels, null);
}).catch(this.onError);
};
ServerEventsClient.prototype.unsubscribeFromChannels = function () {
var _this = this;
var channels = [];
for (var _i = 0; _i < arguments.length; _i++) {
channels[_i] = arguments[_i];
}
var request = new UpdateEventSubscriber();
request.id = this.getSubscriptionId();
request.unsubscribeChannels = channels;
return this.serviceClient.post(request)
.then(function (x) {
_this.update(null, channels);
}).catch(this.onError);
};
ServerEventsClient.prototype.getChannelSubscribers = function () {
var _this = this;
var request = new GetEventSubscribers();
request.channels = this.channels;
return this.serviceClient.get(request)
.then(function (r) { return r.map(function (x) { return _this.toServerEventUser(x); }); })
.catch(function (e) {
_this.onError(e);
return [];
});
};
ServerEventsClient.prototype.toServerEventUser = function (map) {
var channels = map["channels"];
var to = new ServerEventUser();
to.userId = map["userId"];
to.displayName = map["displayName"];
to.profileUrl = map["profileUrl"];
to.channels = channels ? channels.split(',') : null;
for (var k in map) {
if (k == "userId" || k == "displayName" ||
k == "profileUrl" || k == "channels")
continue;
if (to.meta == null)
to.meta = {};
to