Bundled output for commit f7e97f510b

Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
This commit is contained in:
flarum-bot 2021-10-30 22:46:26 +00:00
parent f7e97f510b
commit 574ba355c2
13 changed files with 218 additions and 140 deletions

View File

@ -1,3 +1,5 @@
import Application from '../common/Application';
import ExtensionData from './utils/ExtensionData';
export default class AdminApplication extends Application { export default class AdminApplication extends Application {
extensionData: ExtensionData; extensionData: ExtensionData;
extensionCategories: { extensionCategories: {
@ -11,7 +13,10 @@ export default class AdminApplication extends Application {
backUrl: () => any; backUrl: () => any;
back: () => void; back: () => void;
}; };
constructor();
/**
* @inheritdoc
*/
mount(): void;
getRequiredPermissions(permission: any): string[]; getRequiredPermissions(permission: any): string[];
} }
import Application from "../common/Application";
import ExtensionData from "./utils/ExtensionData";

View File

@ -1,3 +1,94 @@
import ItemList from './utils/ItemList';
import Translator from './Translator';
import Store from './Store';
import Session from './Session';
import Drawer from './utils/Drawer';
import Forum from './models/Forum';
import PageState from './states/PageState';
import ModalManagerState from './states/ModalManagerState';
import AlertManagerState from './states/AlertManagerState';
import type DefaultResolver from './resolvers/DefaultResolver';
import type Mithril from 'mithril';
import type Component from './Component';
import type { ComponentAttrs } from './Component';
export declare type FlarumScreens = 'phone' | 'tablet' | 'desktop' | 'desktop-hd';
export declare type FlarumGenericRoute = RouteItem<Record<string, unknown>, Component<{
routeName: string;
[key: string]: unknown;
}>, Record<string, unknown>>;
export interface FlarumRequestOptions<ResponseType> extends Omit<Mithril.RequestOptions<ResponseType>, 'extract'> {
errorHandler: (errorMessage: string) => void;
url: string;
/**
* Manipulate the response text before it is parsed into JSON.
*
* @deprecated Please use `modifyText` instead.
*/
extract: (responseText: string) => string;
/**
* Manipulate the response text before it is parsed into JSON.
*
* This overrides any `extract` method provided.
*/
modifyText: (responseText: string) => string;
}
/**
* A valid route definition.
*/
export declare type RouteItem<Attrs extends ComponentAttrs, Comp extends Component<Attrs & {
routeName: string;
}>, RouteArgs extends Record<string, unknown> = {}> = {
/**
* The path for your route.
*
* This might be a specific URL path (e.g.,`/myPage`), or it might
* contain a variable used by a resolver (e.g., `/myPage/:id`).
*
* @see https://docs.flarum.org/extend/frontend-pages.html#route-resolvers-advanced
*/
path: `/${string}`;
} & ({
/**
* The component to render when this route matches.
*/
component: {
new (): Comp;
};
/**
* A custom resolver class.
*
* This should be the class itself, and **not** an instance of the
* class.
*/
resolverClass?: {
new (): DefaultResolver<Attrs, Comp, RouteArgs>;
};
} | {
/**
* An instance of a route resolver.
*/
resolver: RouteResolver<Attrs, Comp, RouteArgs>;
});
export interface RouteResolver<Attrs extends ComponentAttrs, Comp extends Component<Attrs & {
routeName: string;
}>, RouteArgs extends Record<string, unknown> = {}> {
/**
* A method which selects which component to render based on
* conditional logic.
*
* Returns the component class, and **not** a Vnode or JSX
* expression.
*/
onmatch(this: this, args: RouteArgs, requestedPath: string, route: string): {
new (): Comp;
};
/**
* A function which renders the provided component.
*
* Returns a Mithril Vnode or other children.
*/
render(this: this, vnode: Mithril.Vnode<Attrs, Comp>): Mithril.Children;
}
/** /**
* The `App` class provides a container for an application, as well as various * The `App` class provides a container for an application, as well as various
* utilities for the rest of the app to use. * utilities for the rest of the app to use.
@ -5,11 +96,8 @@
export default class Application { export default class Application {
/** /**
* The forum model for this application. * The forum model for this application.
*
* @type {Forum}
* @public
*/ */
public forum: Forum; forum: Forum;
/** /**
* A map of routes, keyed by a unique route name. Each route is an object * A map of routes, keyed by a unique route name. Each route is an object
* containing the following properties: * containing the following properties:
@ -18,71 +106,42 @@ export default class Application {
* - `component` The Mithril component to render when this route is active. * - `component` The Mithril component to render when this route is active.
* *
* @example * @example
* app.routes.discussion = {path: '/d/:id', component: DiscussionPage.component()}; * app.routes.discussion = { path: '/d/:id', component: DiscussionPage };
*
* @type {Object}
* @public
*/ */
public routes: Object; routes: Record<string, FlarumGenericRoute>;
/** /**
* An ordered list of initializers to bootstrap the application. * An ordered list of initializers to bootstrap the application.
*
* @type {ItemList}
* @public
*/ */
public initializers: ItemList; initializers: ItemList<(app: this) => void>;
/** /**
* The app's session. * The app's session.
* *
* @type {Session} * Stores info about the current user.
* @public
*/ */
public session: Session; session: Session;
/** /**
* The app's translator. * The app's translator.
*
* @type {Translator}
* @public
*/ */
public translator: Translator; translator: Translator;
/** /**
* The app's data store. * The app's data store.
*
* @type {Store}
* @public
*/ */
public store: Store; store: Store;
/** /**
* A local cache that can be used to store data at the application level, so * A local cache that can be used to store data at the application level, so
* that is persists between different routes. * that is persists between different routes.
*
* @type {Object}
* @public
*/ */
public cache: Object; cache: Record<string, unknown>;
/** /**
* Whether or not the app has been booted. * Whether or not the app has been booted.
*
* @type {Boolean}
* @public
*/ */
public booted: boolean; booted: boolean;
/**
* The key for an Alert that was shown as a result of an AJAX request error.
* If present, it will be dismissed on the next successful request.
*
* @type {int}
* @private
*/
private requestErrorAlert;
/** /**
* The page the app is currently on. * The page the app is currently on.
* *
* This object holds information about the type of page we are currently * This object holds information about the type of page we are currently
* visiting, and sometimes additional arbitrary page state that may be * visiting, and sometimes additional arbitrary page state that may be
* relevant to lower-level components. * relevant to lower-level components.
*
* @type {PageState}
*/ */
current: PageState; current: PageState;
/** /**
@ -91,84 +150,82 @@ export default class Application {
* Once the application navigates to another page, the object previously * Once the application navigates to another page, the object previously
* assigned to this.current will be moved to this.previous, while this.current * assigned to this.current will be moved to this.previous, while this.current
* is re-initialized. * is re-initialized.
*
* @type {PageState}
*/ */
previous: PageState; previous: PageState;
/**
* An object that manages modal state.
*/
modal: ModalManagerState; modal: ModalManagerState;
/** /**
* An object that manages the state of active alerts. * An object that manages the state of active alerts.
*
* @type {AlertManagerState}
*/ */
alerts: AlertManagerState; alerts: AlertManagerState;
data: any; /**
title: string; * An object that manages the state of the navigation drawer.
titleCount: number; */
initialRoute: any; drawer: Drawer;
load(payload: any): void; data: {
apiDocument: Record<string, unknown> | null;
locale: string;
locales: Record<string, string>;
resources: Record<string, unknown>[];
session: {
userId: number;
csrfToken: string;
};
[key: string]: unknown;
};
private _title;
private _titleCount;
private set title(value);
get title(): string;
private set titleCount(value);
get titleCount(): number;
/**
* The key for an Alert that was shown as a result of an AJAX request error.
* If present, it will be dismissed on the next successful request.
*/
private requestErrorAlert;
initialRoute: string;
load(payload: Application['data']): void;
boot(): void; boot(): void;
bootExtensions(extensions: any): void; bootExtensions(extensions: Record<string, {
extend?: unknown[];
}>): void;
mount(basePath?: string): void; mount(basePath?: string): void;
drawer: Drawer | undefined;
/** /**
* Get the API response document that has been preloaded into the application. * Get the API response document that has been preloaded into the application.
*
* @return {Object|null}
* @public
*/ */
public preloadedApiDocument(): Object | null; preloadedApiDocument(): Record<string, unknown> | null;
/** /**
* Determine the current screen mode, based on our media queries. * Determine the current screen mode, based on our media queries.
*
* @returns {String} - one of "phone", "tablet", "desktop" or "desktop-hd"
*/ */
screen(): string; screen(): FlarumScreens;
/** /**
* Set the <title> of the page. * Set the `<title>` of the page.
* *
* @param {String} title * @param title New page title
* @public
*/ */
public setTitle(title: string): void; setTitle(title: string): void;
/** /**
* Set a number to display in the <title> of the page. * Set a number to display in the `<title>` of the page.
* *
* @param {Integer} count * @param count Number to display in title
*/ */
setTitleCount(count: any): void; setTitleCount(count: number): void;
updateTitle(): void; updateTitle(): void;
/** /**
* Make an AJAX request, handling any low-level errors that may occur. * Make an AJAX request, handling any low-level errors that may occur.
* *
* @see https://mithril.js.org/request.html * @see https://mithril.js.org/request.html
* @param {Object} options *
* @param options
* @return {Promise} * @return {Promise}
* @public
*/
public request(originalOptions: any): Promise<any>;
/**
* @param {RequestError} error
* @param {string[]} [formattedError]
* @private
*/ */
request<ResponseType>(originalOptions: FlarumRequestOptions<ResponseType>): Promise<ResponseType | string>;
private showDebug; private showDebug;
/** /**
* Construct a URL to the route with the given name. * Construct a URL to the route with the given name.
*
* @param {String} name
* @param {Object} params
* @return {String}
* @public
*/ */
public route(name: string, params?: Object): string; route(name: string, params?: Record<string, unknown>): string;
} }
import Forum from "./models/Forum";
import ItemList from "./utils/ItemList";
import Session from "./Session";
import Translator from "./Translator";
import Store from "./Store";
import PageState from "./states/PageState";
import ModalManagerState from "./states/ModalManagerState";
import AlertManagerState from "./states/AlertManagerState";
import Drawer from "./utils/Drawer";

View File

@ -1,21 +1,34 @@
import type Mithril from 'mithril'; import type Mithril from 'mithril';
import type { RouteResolver } from '../Application';
import type { default as Component, ComponentAttrs } from '../Component';
/** /**
* Generates a route resolver for a given component. * Generates a route resolver for a given component.
*
* In addition to regular route resolver functionality: * In addition to regular route resolver functionality:
* - It provide the current route name as an attr * - It provide the current route name as an attr
* - It sets a key on the component so a rerender will be triggered on route change. * - It sets a key on the component so a rerender will be triggered on route change.
*/ */
export default class DefaultResolver { export default class DefaultResolver<Attrs extends ComponentAttrs, Comp extends Component<Attrs & {
component: Mithril.Component;
routeName: string; routeName: string;
constructor(component: any, routeName: any); }>, RouteArgs extends Record<string, unknown> = {}> implements RouteResolver<Attrs, Comp, RouteArgs> {
component: {
new (): Comp;
};
routeName: string;
constructor(component: {
new (): Comp;
}, routeName: string);
/** /**
* When a route change results in a changed key, a full page * When a route change results in a changed key, a full page
* rerender occurs. This method can be overriden in subclasses * rerender occurs. This method can be overriden in subclasses
* to prevent rerenders on some route changes. * to prevent rerenders on some route changes.
*/ */
makeKey(): string; makeKey(): string;
makeAttrs(vnode: any): any; makeAttrs(vnode: Mithril.Vnode<Attrs, Comp>): Attrs & {
onmatch(args: any, requestedPath: any, route: any): Mithril.Component<{}, {}>; routeName: string;
render(vnode: any): any[]; };
onmatch(args: RouteArgs, requestedPath: string, route: string): {
new (): Comp;
};
render(vnode: Mithril.Vnode<Attrs, Comp>): Mithril.Children;
} }

View File

@ -4,12 +4,12 @@
*/ */
export default class ScrollListener { export default class ScrollListener {
/** /**
* @param {Function} callback The callback to run when the scroll position * @param {(top: number) => void} callback The callback to run when the scroll position
* changes. * changes.
* @public * @public
*/ */
constructor(callback: Function); constructor(callback: (top: number) => void);
callback: Function; callback: (top: number) => void;
ticking: boolean; ticking: boolean;
/** /**
* On each animation frame, as long as the listener is active, run the * On each animation frame, as long as the listener is active, run the

View File

@ -1,11 +1,13 @@
import type { FlarumGenericRoute, RouteResolver } from '../Application';
import type Component from '../Component';
/** /**
* The `mapRoutes` utility converts a map of named application routes into a * The `mapRoutes` utility converts a map of named application routes into a
* format that can be understood by Mithril, and wraps them in route resolvers * format that can be understood by Mithril, and wraps them in route resolvers
* to provide each route with the current route name. * to provide each route with the current route name.
* *
* @see https://mithril.js.org/route.html#signature * @see https://mithril.js.org/route.html#signature
* @param {Object} routes
* @param {String} [basePath]
* @return {Object}
*/ */
export default function mapRoutes(routes: Object, basePath?: string | undefined): Object; export default function mapRoutes(routes: Record<string, FlarumGenericRoute>, basePath?: string): Record<string, RouteResolver<Record<string, unknown>, Component<{
[key: string]: unknown;
routeName: string;
}, undefined>, Record<string, unknown>>>;

View File

@ -1,44 +1,53 @@
import History from './utils/History';
import Pane from './utils/Pane';
import Application from '../common/Application';
import NotificationListState from './states/NotificationListState';
import GlobalSearchState from './states/GlobalSearchState';
import DiscussionListState from './states/DiscussionListState';
import ComposerState from './states/ComposerState';
import type Notification from './components/Notification';
import type Post from './components/Post';
export default class ForumApplication extends Application { export default class ForumApplication extends Application {
/** /**
* A map of notification types to their components. * A map of notification types to their components.
*
* @type {Object}
*/ */
notificationComponents: Object; notificationComponents: Record<string, typeof Notification>;
/** /**
* A map of post types to their components. * A map of post types to their components.
*
* @type {Object}
*/ */
postComponents: Object; postComponents: Record<string, typeof Post>;
/** /**
* An object which controls the state of the page's side pane. * An object which controls the state of the page's side pane.
*
* @type {Pane}
*/ */
pane: Pane; pane: Pane | null;
/** /**
* The app's history stack, which keeps track of which routes the user visits * The app's history stack, which keeps track of which routes the user visits
* so that they can easily navigate back to the previous route. * so that they can easily navigate back to the previous route.
*
* @type {History}
*/ */
history: History; history: History;
/** /**
* An object which controls the state of the user's notifications. * An object which controls the state of the user's notifications.
*
* @type {NotificationListState}
*/ */
notifications: NotificationListState; notifications: NotificationListState;
/**
* An object which stores previously searched queries and provides convenient
* tools for retrieving and managing search values.
*/
search: GlobalSearchState; search: GlobalSearchState;
/**
* An object which controls the state of the composer.
*/
composer: ComposerState; composer: ComposerState;
/** /**
* An object which controls the state of the cached discussion list, which * An object which controls the state of the cached discussion list, which
* is used in the index page and the slideout pane. * is used in the index page and the slideout pane.
*
* @type {DiscussionListState}
*/ */
discussions: DiscussionListState; discussions: DiscussionListState;
constructor();
/**
* @inheritdoc
*/
mount(): void;
/** /**
* Check whether or not the user is currently viewing a discussion. * Check whether or not the user is currently viewing a discussion.
* *
@ -59,12 +68,5 @@ export default class ForumApplication extends Application {
* in, and thus the page is reloaded. * in, and thus the page is reloaded.
* @public * @public
*/ */
public authenticationComplete(payload: Object): void; authenticationComplete(payload: any): void;
} }
import Application from "../common/Application";
import Pane from "./utils/Pane";
import History from "./utils/History";
import NotificationListState from "./states/NotificationListState";
import GlobalSearchState from "./states/GlobalSearchState";
import ComposerState from "./states/ComposerState";
import DiscussionListState from "./states/DiscussionListState";

View File

@ -1,4 +1,3 @@
/// <reference types="mithril" />
import DefaultResolver from '../../common/resolvers/DefaultResolver'; import DefaultResolver from '../../common/resolvers/DefaultResolver';
/** /**
* A custom route resolver for DiscussionPage that generates the same key to all posts * A custom route resolver for DiscussionPage that generates the same key to all posts
@ -19,6 +18,6 @@ export default class DiscussionPageResolver extends DefaultResolver {
* @inheritdoc * @inheritdoc
*/ */
makeKey(): string; makeKey(): string;
onmatch(args: any, requestedPath: any, route: any): import("mithril").Component<{}, {}>; onmatch(args: any, requestedPath: any, route: any): any;
render(vnode: any): any[]; render(vnode: any): any;
} }

View File

@ -2,7 +2,7 @@ import PaginatedListState, { Page } from '../../common/states/PaginatedListState
import Discussion from '../../common/models/Discussion'; import Discussion from '../../common/models/Discussion';
export default class DiscussionListState extends PaginatedListState<Discussion> { export default class DiscussionListState extends PaginatedListState<Discussion> {
protected extraDiscussions: Discussion[]; protected extraDiscussions: Discussion[];
constructor(params: any, page: number); constructor(params: any, page?: number);
get type(): string; get type(): string;
requestParams(): any; requestParams(): any;
protected loadPage(page?: number): any; protected loadPage(page?: number): any;

View File

@ -10,5 +10,5 @@ export default class NotificationListState extends PaginatedListState<Notificati
/** /**
* Mark all of the notifications as read. * Mark all of the notifications as read.
*/ */
markAllAsRead(): Promise<any> | undefined; markAllAsRead(): Promise<unknown> | undefined;
} }

4
framework/core/js/dist/admin.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

6
framework/core/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long