mirror of
https://github.com/flarum/framework.git
synced 2025-01-26 14:44:58 +08:00
Bundled output for commit f7e97f510b
Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci]
This commit is contained in:
parent
f7e97f510b
commit
574ba355c2
|
@ -1,3 +1,5 @@
|
|||
import Application from '../common/Application';
|
||||
import ExtensionData from './utils/ExtensionData';
|
||||
export default class AdminApplication extends Application {
|
||||
extensionData: ExtensionData;
|
||||
extensionCategories: {
|
||||
|
@ -11,7 +13,10 @@ export default class AdminApplication extends Application {
|
|||
backUrl: () => any;
|
||||
back: () => void;
|
||||
};
|
||||
constructor();
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
mount(): void;
|
||||
getRequiredPermissions(permission: any): string[];
|
||||
}
|
||||
import Application from "../common/Application";
|
||||
import ExtensionData from "./utils/ExtensionData";
|
||||
|
|
|
@ -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
|
||||
* utilities for the rest of the app to use.
|
||||
|
@ -5,11 +96,8 @@
|
|||
export default class 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
|
||||
* containing the following properties:
|
||||
|
@ -18,71 +106,42 @@ export default class Application {
|
|||
* - `component` The Mithril component to render when this route is active.
|
||||
*
|
||||
* @example
|
||||
* app.routes.discussion = {path: '/d/:id', component: DiscussionPage.component()};
|
||||
*
|
||||
* @type {Object}
|
||||
* @public
|
||||
* app.routes.discussion = { path: '/d/:id', component: DiscussionPage };
|
||||
*/
|
||||
public routes: Object;
|
||||
routes: Record<string, FlarumGenericRoute>;
|
||||
/**
|
||||
* An ordered list of initializers to bootstrap the application.
|
||||
*
|
||||
* @type {ItemList}
|
||||
* @public
|
||||
*/
|
||||
public initializers: ItemList;
|
||||
initializers: ItemList<(app: this) => void>;
|
||||
/**
|
||||
* The app's session.
|
||||
*
|
||||
* @type {Session}
|
||||
* @public
|
||||
* Stores info about the current user.
|
||||
*/
|
||||
public session: Session;
|
||||
session: Session;
|
||||
/**
|
||||
* The app's translator.
|
||||
*
|
||||
* @type {Translator}
|
||||
* @public
|
||||
*/
|
||||
public translator: Translator;
|
||||
translator: Translator;
|
||||
/**
|
||||
* 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
|
||||
* that is persists between different routes.
|
||||
*
|
||||
* @type {Object}
|
||||
* @public
|
||||
*/
|
||||
public cache: Object;
|
||||
cache: Record<string, unknown>;
|
||||
/**
|
||||
* Whether or not the app has been booted.
|
||||
*
|
||||
* @type {Boolean}
|
||||
* @public
|
||||
*/
|
||||
public 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;
|
||||
booted: boolean;
|
||||
/**
|
||||
* The page the app is currently on.
|
||||
*
|
||||
* This object holds information about the type of page we are currently
|
||||
* visiting, and sometimes additional arbitrary page state that may be
|
||||
* relevant to lower-level components.
|
||||
*
|
||||
* @type {PageState}
|
||||
*/
|
||||
current: PageState;
|
||||
/**
|
||||
|
@ -91,84 +150,82 @@ export default class Application {
|
|||
* Once the application navigates to another page, the object previously
|
||||
* assigned to this.current will be moved to this.previous, while this.current
|
||||
* is re-initialized.
|
||||
*
|
||||
* @type {PageState}
|
||||
*/
|
||||
previous: PageState;
|
||||
/**
|
||||
* An object that manages modal state.
|
||||
*/
|
||||
modal: ModalManagerState;
|
||||
/**
|
||||
* An object that manages the state of active alerts.
|
||||
*
|
||||
* @type {AlertManagerState}
|
||||
*/
|
||||
alerts: AlertManagerState;
|
||||
data: any;
|
||||
title: string;
|
||||
titleCount: number;
|
||||
initialRoute: any;
|
||||
load(payload: any): void;
|
||||
/**
|
||||
* An object that manages the state of the navigation drawer.
|
||||
*/
|
||||
drawer: Drawer;
|
||||
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;
|
||||
bootExtensions(extensions: any): void;
|
||||
bootExtensions(extensions: Record<string, {
|
||||
extend?: unknown[];
|
||||
}>): void;
|
||||
mount(basePath?: string): void;
|
||||
drawer: Drawer | undefined;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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
|
||||
* @public
|
||||
* @param title New page title
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* Make an AJAX request, handling any low-level errors that may occur.
|
||||
*
|
||||
* @see https://mithril.js.org/request.html
|
||||
* @param {Object} options
|
||||
*
|
||||
* @param options
|
||||
* @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;
|
||||
/**
|
||||
* 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";
|
||||
|
|
|
@ -1,21 +1,34 @@
|
|||
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.
|
||||
*
|
||||
* In addition to regular route resolver functionality:
|
||||
* - 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.
|
||||
*/
|
||||
export default class DefaultResolver {
|
||||
component: Mithril.Component;
|
||||
export default class DefaultResolver<Attrs extends ComponentAttrs, Comp extends Component<Attrs & {
|
||||
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
|
||||
* rerender occurs. This method can be overriden in subclasses
|
||||
* to prevent rerenders on some route changes.
|
||||
*/
|
||||
makeKey(): string;
|
||||
makeAttrs(vnode: any): any;
|
||||
onmatch(args: any, requestedPath: any, route: any): Mithril.Component<{}, {}>;
|
||||
render(vnode: any): any[];
|
||||
makeAttrs(vnode: Mithril.Vnode<Attrs, Comp>): Attrs & {
|
||||
routeName: string;
|
||||
};
|
||||
onmatch(args: RouteArgs, requestedPath: string, route: string): {
|
||||
new (): Comp;
|
||||
};
|
||||
render(vnode: Mithril.Vnode<Attrs, Comp>): Mithril.Children;
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
*/
|
||||
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.
|
||||
* @public
|
||||
*/
|
||||
constructor(callback: Function);
|
||||
callback: Function;
|
||||
constructor(callback: (top: number) => void);
|
||||
callback: (top: number) => void;
|
||||
ticking: boolean;
|
||||
/**
|
||||
* On each animation frame, as long as the listener is active, run the
|
||||
|
|
|
@ -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
|
||||
* format that can be understood by Mithril, and wraps them in route resolvers
|
||||
* to provide each route with the current route name.
|
||||
*
|
||||
* @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>>>;
|
||||
|
|
|
@ -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 {
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
postComponents: Object;
|
||||
postComponents: Record<string, typeof Post>;
|
||||
/**
|
||||
* 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
|
||||
* so that they can easily navigate back to the previous route.
|
||||
*
|
||||
* @type {History}
|
||||
*/
|
||||
history: History;
|
||||
/**
|
||||
* An object which controls the state of the user's notifications.
|
||||
*
|
||||
* @type {NotificationListState}
|
||||
*/
|
||||
notifications: NotificationListState;
|
||||
/**
|
||||
* An object which stores previously searched queries and provides convenient
|
||||
* tools for retrieving and managing search values.
|
||||
*/
|
||||
search: GlobalSearchState;
|
||||
/**
|
||||
* An object which controls the state of the composer.
|
||||
*/
|
||||
composer: ComposerState;
|
||||
/**
|
||||
* An object which controls the state of the cached discussion list, which
|
||||
* is used in the index page and the slideout pane.
|
||||
*
|
||||
* @type {DiscussionListState}
|
||||
*/
|
||||
discussions: DiscussionListState;
|
||||
constructor();
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
mount(): void;
|
||||
/**
|
||||
* 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.
|
||||
* @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";
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/// <reference types="mithril" />
|
||||
import DefaultResolver from '../../common/resolvers/DefaultResolver';
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
makeKey(): string;
|
||||
onmatch(args: any, requestedPath: any, route: any): import("mithril").Component<{}, {}>;
|
||||
render(vnode: any): any[];
|
||||
onmatch(args: any, requestedPath: any, route: any): any;
|
||||
render(vnode: any): any;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import PaginatedListState, { Page } from '../../common/states/PaginatedListState
|
|||
import Discussion from '../../common/models/Discussion';
|
||||
export default class DiscussionListState extends PaginatedListState<Discussion> {
|
||||
protected extraDiscussions: Discussion[];
|
||||
constructor(params: any, page: number);
|
||||
constructor(params: any, page?: number);
|
||||
get type(): string;
|
||||
requestParams(): any;
|
||||
protected loadPage(page?: number): any;
|
||||
|
|
|
@ -10,5 +10,5 @@ export default class NotificationListState extends PaginatedListState<Notificati
|
|||
/**
|
||||
* Mark all of the notifications as read.
|
||||
*/
|
||||
markAllAsRead(): Promise<any> | undefined;
|
||||
markAllAsRead(): Promise<unknown> | undefined;
|
||||
}
|
||||
|
|
4
framework/core/js/dist/admin.js
generated
vendored
4
framework/core/js/dist/admin.js
generated
vendored
File diff suppressed because one or more lines are too long
2
framework/core/js/dist/admin.js.map
generated
vendored
2
framework/core/js/dist/admin.js.map
generated
vendored
File diff suppressed because one or more lines are too long
6
framework/core/js/dist/forum.js
generated
vendored
6
framework/core/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
framework/core/js/dist/forum.js.map
generated
vendored
2
framework/core/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user