mirror of
https://github.com/flarum/core.git
synced 2025-08-08 17:36:38 +02:00
Bundled output for commit bac0e594ee
Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci]
This commit is contained in:
10
js/dist-typings/common/Application.d.ts
vendored
10
js/dist-typings/common/Application.d.ts
vendored
@@ -3,6 +3,7 @@ import Translator from './Translator';
|
||||
import Store from './Store';
|
||||
import Session from './Session';
|
||||
import Drawer from './utils/Drawer';
|
||||
import RequestError, { InternalFlarumRequestOptions } from './utils/RequestError';
|
||||
import Forum from './models/Forum';
|
||||
import PageState from './states/PageState';
|
||||
import ModalManagerState from './states/ModalManagerState';
|
||||
@@ -17,20 +18,20 @@ export declare type FlarumGenericRoute = RouteItem<Record<string, unknown>, Comp
|
||||
[key: string]: unknown;
|
||||
}>, Record<string, unknown>>;
|
||||
export interface FlarumRequestOptions<ResponseType> extends Omit<Mithril.RequestOptions<ResponseType>, 'extract'> {
|
||||
errorHandler: (errorMessage: string) => void;
|
||||
errorHandler?: (error: RequestError) => void;
|
||||
url: string;
|
||||
/**
|
||||
* Manipulate the response text before it is parsed into JSON.
|
||||
*
|
||||
* @deprecated Please use `modifyText` instead.
|
||||
*/
|
||||
extract: (responseText: string) => string;
|
||||
extract?: (responseText: string) => string;
|
||||
/**
|
||||
* Manipulate the response text before it is parsed into JSON.
|
||||
*
|
||||
* This overrides any `extract` method provided.
|
||||
*/
|
||||
modifyText: (responseText: string) => string;
|
||||
modifyText?: (responseText: string) => string;
|
||||
}
|
||||
/**
|
||||
* A valid route definition.
|
||||
@@ -192,7 +193,7 @@ export default class Application {
|
||||
bootExtensions(extensions: Record<string, {
|
||||
extend?: unknown[];
|
||||
}>): void;
|
||||
mount(basePath?: string): void;
|
||||
protected mount(basePath?: string): void;
|
||||
/**
|
||||
* Get the API response document that has been preloaded into the application.
|
||||
*/
|
||||
@@ -214,6 +215,7 @@ export default class Application {
|
||||
*/
|
||||
setTitleCount(count: number): void;
|
||||
updateTitle(): void;
|
||||
protected transformRequestOptions<ResponseType>(flarumOptions: FlarumRequestOptions<ResponseType>): InternalFlarumRequestOptions<ResponseType>;
|
||||
/**
|
||||
* Make an AJAX request, handling any low-level errors that may occur.
|
||||
*
|
||||
|
114
js/dist-typings/common/Component.d.ts
vendored
Normal file
114
js/dist-typings/common/Component.d.ts
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
import type Mithril from 'mithril';
|
||||
export interface ComponentAttrs extends Mithril.Attributes {
|
||||
}
|
||||
/**
|
||||
* The `Component` class defines a user interface 'building block'. A component
|
||||
* generates a virtual DOM to be rendered on each redraw.
|
||||
*
|
||||
* Essentially, this is a wrapper for Mithril's components that adds several useful features:
|
||||
*
|
||||
* - In the `oninit` and `onbeforeupdate` lifecycle hooks, we store vnode attrs in `this.attrs.
|
||||
* This allows us to use attrs across components without having to pass the vnode to every single
|
||||
* method.
|
||||
* - The static `initAttrs` method allows a convenient way to provide defaults (or to otherwise modify)
|
||||
* the attrs that have been passed into a component.
|
||||
* - When the component is created in the DOM, we store its DOM element under `this.element`; this lets
|
||||
* us use jQuery to modify child DOM state from internal methods via the `this.$()` method.
|
||||
* - A convenience `component` method, which serves as an alternative to hyperscript and JSX.
|
||||
*
|
||||
* As with other Mithril components, components extending Component can be initialized
|
||||
* and nested using JSX, hyperscript, or a combination of both. The `component` method can also
|
||||
* be used.
|
||||
*
|
||||
* @example
|
||||
* return m('div', <MyComponent foo="bar"><p>Hello World</p></MyComponent>);
|
||||
*
|
||||
* @example
|
||||
* return m('div', MyComponent.component({foo: 'bar'), m('p', 'Hello World!'));
|
||||
*
|
||||
* @see https://mithril.js.org/components.html
|
||||
*/
|
||||
export default abstract class Component<Attrs extends ComponentAttrs = ComponentAttrs, State = undefined> implements Mithril.ClassComponent<Attrs> {
|
||||
/**
|
||||
* The root DOM element for the component.
|
||||
*/
|
||||
protected element: Element;
|
||||
/**
|
||||
* The attributes passed into the component.
|
||||
*
|
||||
* @see https://mithril.js.org/components.html#passing-data-to-components
|
||||
*/
|
||||
protected attrs: Attrs;
|
||||
/**
|
||||
* Class component state that is persisted between redraws.
|
||||
*
|
||||
* Updating this will **not** automatically trigger a redraw, unlike
|
||||
* other frameworks.
|
||||
*
|
||||
* This is different to Vnode state, which is always an instance of your
|
||||
* class component.
|
||||
*
|
||||
* This is `undefined` by default.
|
||||
*/
|
||||
protected state: State;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
abstract view(vnode: Mithril.Vnode<Attrs, this>): Mithril.Children;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
oninit(vnode: Mithril.Vnode<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
oncreate(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onbeforeupdate(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onupdate(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onbeforeremove(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onremove(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* Returns a jQuery object for this component's element. If you pass in a
|
||||
* selector string, this method will return a jQuery object, using the current
|
||||
* element as its buffer.
|
||||
*
|
||||
* For example, calling `component.$('li')` will return a jQuery object
|
||||
* containing all of the `li` elements inside the DOM element of this
|
||||
* component.
|
||||
*
|
||||
* @param [selector] a jQuery-compatible selector string
|
||||
* @returns the jQuery object for the DOM node
|
||||
* @final
|
||||
*/
|
||||
protected $(selector?: string): JQuery;
|
||||
/**
|
||||
* Convenience method to attach a component without JSX.
|
||||
* Has the same effect as calling `m(THIS_CLASS, attrs, children)`.
|
||||
*
|
||||
* @see https://mithril.js.org/hyperscript.html#mselector,-attributes,-children
|
||||
*/
|
||||
static component<SAttrs extends ComponentAttrs = ComponentAttrs>(attrs?: SAttrs, children?: Mithril.Children): Mithril.Vnode;
|
||||
/**
|
||||
* Saves a reference to the vnode attrs after running them through initAttrs,
|
||||
* and checking for common issues.
|
||||
*/
|
||||
private setAttrs;
|
||||
/**
|
||||
* Initialize the component's attrs.
|
||||
*
|
||||
* This can be used to assign default values for missing, optional attrs.
|
||||
*/
|
||||
protected static initAttrs<T>(attrs: T): void;
|
||||
}
|
2
js/dist-typings/common/Fragment.d.ts
vendored
2
js/dist-typings/common/Fragment.d.ts
vendored
@@ -32,7 +32,7 @@ export default abstract class Fragment {
|
||||
* @returns {jQuery} the jQuery object for the DOM node
|
||||
* @final
|
||||
*/
|
||||
$(selector: any): JQuery<any>;
|
||||
$(selector?: string): JQuery;
|
||||
/**
|
||||
* Get the renderable virtual DOM that represents the fragment's view.
|
||||
*
|
||||
|
2
js/dist-typings/common/components/Alert.d.ts
vendored
2
js/dist-typings/common/components/Alert.d.ts
vendored
@@ -15,5 +15,5 @@ export interface AlertAttrs extends ComponentAttrs {
|
||||
* some controls, and may be dismissible.
|
||||
*/
|
||||
export default class Alert<T extends AlertAttrs = AlertAttrs> extends Component<T> {
|
||||
view(vnode: Mithril.Vnode): JSX.Element;
|
||||
view(vnode: Mithril.VnodeDOM<T, this>): JSX.Element;
|
||||
}
|
||||
|
@@ -60,8 +60,8 @@ export interface IButtonAttrs extends ComponentAttrs {
|
||||
* styles can be applied by providing `className="Button"` to the Button component.
|
||||
*/
|
||||
export default class Button<CustomAttrs extends IButtonAttrs = IButtonAttrs> extends Component<CustomAttrs> {
|
||||
view(vnode: Mithril.Vnode<IButtonAttrs, never>): JSX.Element;
|
||||
oncreate(vnode: Mithril.VnodeDOM<IButtonAttrs, this>): void;
|
||||
view(vnode: Mithril.VnodeDOM<CustomAttrs, this>): JSX.Element;
|
||||
oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
|
||||
/**
|
||||
* Get the template for the button's content.
|
||||
*/
|
||||
|
2
js/dist-typings/common/components/Modal.d.ts
vendored
2
js/dist-typings/common/components/Modal.d.ts
vendored
@@ -17,7 +17,7 @@ export default abstract class Modal<ModalAttrs = {}> extends Component<ModalAttr
|
||||
/**
|
||||
* Determine whether or not the modal should be dismissible via an 'x' button.
|
||||
*/
|
||||
static readonly isDismissible = true;
|
||||
static readonly isDismissible: boolean;
|
||||
protected loading: boolean;
|
||||
/**
|
||||
* Attributes for an alert component to show below the header.
|
||||
|
19
js/dist-typings/common/components/Page.d.ts
vendored
19
js/dist-typings/common/components/Page.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
import type Mithril from 'mithril';
|
||||
import Component from '../Component';
|
||||
export interface IPageAttrs {
|
||||
key?: number;
|
||||
@@ -9,7 +10,19 @@ export interface IPageAttrs {
|
||||
* @abstract
|
||||
*/
|
||||
export default abstract class Page<CustomAttrs extends IPageAttrs = IPageAttrs> extends Component<CustomAttrs> {
|
||||
oninit(vnode: any): void;
|
||||
oncreate(vnode: any): void;
|
||||
onremove(vnode: any): void;
|
||||
/**
|
||||
* A class name to apply to the body while the route is active.
|
||||
*/
|
||||
protected bodyClass: string;
|
||||
/**
|
||||
* Whether we should scroll to the top of the page when its rendered.
|
||||
*/
|
||||
protected scrollTopOnCreate: boolean;
|
||||
/**
|
||||
* Whether the browser should restore scroll state on refreshes.
|
||||
*/
|
||||
protected useBrowserScrollRestoration: boolean;
|
||||
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
|
||||
oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
|
||||
onremove(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
|
||||
}
|
||||
|
5
js/dist-typings/common/helpers/avatar.d.ts
vendored
5
js/dist-typings/common/helpers/avatar.d.ts
vendored
@@ -1,9 +1,12 @@
|
||||
import type Mithril from 'mithril';
|
||||
import type { ComponentAttrs } from '../Component';
|
||||
import User from '../models/User';
|
||||
export interface AvatarAttrs extends ComponentAttrs {
|
||||
}
|
||||
/**
|
||||
* The `avatar` helper displays a user's avatar.
|
||||
*
|
||||
* @param user
|
||||
* @param attrs Attributes to apply to the avatar element
|
||||
*/
|
||||
export default function avatar(user: User, attrs?: Object): Mithril.Vnode;
|
||||
export default function avatar(user: User, attrs?: ComponentAttrs): Mithril.Vnode;
|
||||
|
10
js/dist-typings/common/helpers/listItems.d.ts
vendored
10
js/dist-typings/common/helpers/listItems.d.ts
vendored
@@ -1,12 +1,16 @@
|
||||
import type Mithril from 'mithril';
|
||||
import type * as Component from '../Component';
|
||||
import Component, { ComponentAttrs } from '../Component';
|
||||
export interface ModdedVnodeAttrs {
|
||||
itemClassName?: string;
|
||||
key?: string;
|
||||
}
|
||||
export declare type ModdedVnode<Attrs> = Mithril.Vnode<ModdedVnodeAttrs, Component.default<Attrs> | {}> & {
|
||||
export declare type ModdedVnode<Attrs> = Mithril.Vnode<ModdedVnodeAttrs, Component<Attrs> | {}> & {
|
||||
itemName?: string;
|
||||
itemClassName?: string;
|
||||
tag: Mithril.Vnode['tag'] & {
|
||||
isListItem?: boolean;
|
||||
isActive?: (attrs: ComponentAttrs) => boolean;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* The `listItems` helper wraps an array of components in the provided tag,
|
||||
@@ -15,4 +19,4 @@ export declare type ModdedVnode<Attrs> = Mithril.Vnode<ModdedVnodeAttrs, Compone
|
||||
* By default, this tag is an `<li>` tag, but this is customisable through the
|
||||
* second function parameter, `customTag`.
|
||||
*/
|
||||
export default function listItems<Attrs extends Record<string, unknown>>(items: ModdedVnode<Attrs> | ModdedVnode<Attrs>[], customTag?: string | Component.default<Attrs>, attributes?: Attrs): Mithril.Vnode[];
|
||||
export default function listItems<Attrs extends Record<string, unknown>>(rawItems: ModdedVnode<Attrs> | ModdedVnode<Attrs>[], customTag?: string | Component<Attrs>, attributes?: Attrs): Mithril.Vnode[];
|
||||
|
@@ -3,4 +3,4 @@ import User from '../models/User';
|
||||
/**
|
||||
* The `useronline` helper displays a green circle if the user is online
|
||||
*/
|
||||
export default function userOnline(user: User): Mithril.Vnode;
|
||||
export default function userOnline(user: User): Mithril.Vnode<{}, {}> | null;
|
||||
|
@@ -10,15 +10,18 @@ export interface PaginationLocation {
|
||||
startIndex?: number;
|
||||
endIndex?: number;
|
||||
}
|
||||
export default abstract class PaginatedListState<T extends Model> {
|
||||
export interface PaginatedListParams {
|
||||
[key: string]: any;
|
||||
}
|
||||
export default abstract class PaginatedListState<T extends Model, P extends PaginatedListParams = PaginatedListParams> {
|
||||
protected location: PaginationLocation;
|
||||
protected pageSize: number;
|
||||
protected pages: Page<T>[];
|
||||
protected params: any;
|
||||
protected params: P;
|
||||
protected initialLoading: boolean;
|
||||
protected loadingPrev: boolean;
|
||||
protected loadingNext: boolean;
|
||||
protected constructor(params?: any, page?: number, pageSize?: number);
|
||||
protected constructor(params?: P, page?: number, pageSize?: number);
|
||||
abstract get type(): string;
|
||||
clear(): void;
|
||||
loadPrev(): Promise<void>;
|
||||
@@ -44,7 +47,7 @@ export default abstract class PaginatedListState<T extends Model> {
|
||||
* @param page
|
||||
* @see requestParams
|
||||
*/
|
||||
refreshParams(newParams: any, page: number): Promise<void> | undefined;
|
||||
refreshParams(newParams: P, page: number): Promise<void>;
|
||||
refresh(page?: number): Promise<void>;
|
||||
getPages(): Page<T>[];
|
||||
getLocation(): PaginationLocation;
|
||||
@@ -73,6 +76,6 @@ export default abstract class PaginatedListState<T extends Model> {
|
||||
getParams(): any;
|
||||
protected getNextPageNumber(): number;
|
||||
protected getPrevPageNumber(): number;
|
||||
protected paramsChanged(newParams: any): boolean;
|
||||
protected paramsChanged(newParams: P): boolean;
|
||||
protected getAllItems(): T[];
|
||||
}
|
||||
|
20
js/dist-typings/common/utils/RequestError.d.ts
vendored
20
js/dist-typings/common/utils/RequestError.d.ts
vendored
@@ -1,9 +1,21 @@
|
||||
export default class RequestError {
|
||||
import type Mithril from 'mithril';
|
||||
export declare type InternalFlarumRequestOptions<ResponseType> = Mithril.RequestOptions<ResponseType> & {
|
||||
errorHandler: (error: RequestError) => void;
|
||||
url: string;
|
||||
};
|
||||
export default class RequestError<ResponseType = string> {
|
||||
status: number;
|
||||
options: Record<string, unknown>;
|
||||
options: InternalFlarumRequestOptions<ResponseType>;
|
||||
xhr: XMLHttpRequest;
|
||||
responseText: string | null;
|
||||
response: Record<string, unknown> | null;
|
||||
response: {
|
||||
[key: string]: unknown;
|
||||
errors?: {
|
||||
detail?: string;
|
||||
code?: string;
|
||||
[key: string]: unknown;
|
||||
}[];
|
||||
} | null;
|
||||
alert: any;
|
||||
constructor(status: number, responseText: string | null, options: Record<string, unknown>, xhr: XMLHttpRequest);
|
||||
constructor(status: number, responseText: string | null, options: InternalFlarumRequestOptions<ResponseType>, xhr: XMLHttpRequest);
|
||||
}
|
||||
|
3
js/dist-typings/common/utils/humanTime.d.ts
vendored
3
js/dist-typings/common/utils/humanTime.d.ts
vendored
@@ -1,5 +1,6 @@
|
||||
import dayjs from 'dayjs';
|
||||
/**
|
||||
* The `humanTime` utility converts a date to a localized, human-readable time-
|
||||
* ago string.
|
||||
*/
|
||||
export default function humanTime(time: Date): string;
|
||||
export default function humanTime(time: dayjs.ConfigType): string;
|
||||
|
Reference in New Issue
Block a user