fix: Assorted Typing Fixes (#3348)

With all the commits below, we resolve all outstanding typing issues in the repo, and CI jobs run green.

* fix: Convert DashboardPage and DashboardWidget to TypeScript

* fix: fix type errors in package manager ext

* fix: Convert Post component to TypeScript

* fix: avatar typings should accept null user

* fix: convert Notification component to TypeScript

* fix: properly use `typeof` in ForumApplication

* feat: make Notification content attr generic

* chore: format Notification component

* fix: Convert DiscussionRenamedNotification to TypeScript

* fix(pusher) move shims to a location where they get applied

* fix(pusher): fix some typing errors

* fix(akismet): fix some typing issues

* chore: update core dist typings

* chore(pusher): format

* fix: anchorScroll should accept string selectors

* fix: more accurately represent ApiQueryParamsPlural

* fix: convert PostStreamState to TypeScript

* chore(core): rebuild typings

* feat: allow extending app.routes

* fix: more flexible typings for highlight.ts

* fix: use primitive `number` type for Discussion typings

* fix: convert DiscussionListItem to TypeScript

* chore: rebuild core typings

* fix: final pusher type fixes

* feat: start tags TypeScript conversion

* fix: require-dev tags in pusher for CI TypeScript purposes.

* chore(core): format

* chore(tags): build dist typings

* feat(pusher): use dist types from tags.

* feat: convert flags to TypeScript

* chore(flags): generate dist typings

* fix(akismet): last type errors

* chore: update .yarn-integrity

* chore: partially run flarum-cli audit infra --fix

The tsconfig changes from that command are ignored, since we don't yet support "replacable sections" that would let us add custom config.

* chore: use type imports

* fix: broader gitattributes

* chore: run flarum-cli audit infra --monorepo --fix

* feat: make `app.data` typings extensible

* chore(core): format

* chore: boost tags TypeScript coverage

* fix(tags): further increase type coverage.
This commit is contained in:
Alexander Skvortsov 2022-03-23 11:43:14 -04:00 committed by GitHub
parent 4ecd9a9b2f
commit a595665bfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
255 changed files with 1578 additions and 1218 deletions

20
.gitattributes vendored Normal file
View File

@ -0,0 +1,20 @@
**/.gitattributes export-ignore
**/.gitignore export-ignore
**/.gitmodules export-ignore
**/.github export-ignore
**/.travis export-ignore
**/.travis.yml export-ignore
**/.editorconfig export-ignore
**/.styleci.yml export-ignore
**/phpunit.xml export-ignore
**/tests export-ignore
**/js/dist/**/* -diff
**/js/dist/**/* linguist-generated
**/js/dist-typings/**/* -diff
**/js/dist-typings/**/* linguist-generated
**/js/yarn.lock -diff
**/js/package-lock.json -diff
* text=auto eol=lf

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/akismet backend_directory: ./extensions/akismet
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/approval backend_directory: ./extensions/approval
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./framework/core backend_directory: ./framework/core
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/embed backend_directory: ./extensions/embed
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/emoji backend_directory: ./extensions/emoji
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -12,11 +12,12 @@ jobs:
with: with:
enable_bundlewatch: false enable_bundlewatch: false
enable_prettier: true enable_prettier: true
enable_typescript: false enable_typescript: true
frontend_directory: ./extensions/flags/js frontend_directory: ./extensions/flags/js
backend_directory: ./extensions/flags backend_directory: ./extensions/flags
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/likes backend_directory: ./extensions/likes
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/lock backend_directory: ./extensions/lock
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/markdown backend_directory: ./extensions/markdown
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/mentions backend_directory: ./extensions/mentions
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/nicknames backend_directory: ./extensions/nicknames
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/package-manager backend_directory: ./extensions/package-manager
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/pusher backend_directory: ./extensions/pusher
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/statistics backend_directory: ./extensions/statistics
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/sticky backend_directory: ./extensions/sticky
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/subscriptions backend_directory: ./extensions/subscriptions
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/suspend backend_directory: ./extensions/suspend
js_package_manager: yarn js_package_manager: yarn
main_git_branch: main main_git_branch: main
secrets: secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@ -12,7 +12,7 @@ jobs:
with: with:
enable_bundlewatch: false enable_bundlewatch: false
enable_prettier: false enable_prettier: false
enable_typescript: false enable_typescript: true
frontend_directory: ./extensions/tags/js frontend_directory: ./extensions/tags/js
backend_directory: ./extensions/tags backend_directory: ./extensions/tags

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -12,7 +12,7 @@
"check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report", "check-typings-coverage": "typescript-coverage-report",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings", "clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings", "build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'" "post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,18 +1,22 @@
import { extend, override } from 'flarum/common/extend'; import { extend, override } from 'flarum/common/extend';
import app from 'flarum/forum/app'; import app from 'flarum/forum/app';
import type Post from 'flarum/common/models/Post';
import type ItemList from 'flarum/common/utils/ItemList';
import PostControls from 'flarum/forum/utils/PostControls'; import PostControls from 'flarum/forum/utils/PostControls';
import CommentPost from 'flarum/forum/components/CommentPost'; import CommentPost from 'flarum/forum/components/CommentPost';
import ItemList from 'flarum/common/utils/ItemList'; import type Mithril from 'mithril';
import Post from 'flarum/common/models/Post';
app.initializers.add('flarum-akismet', () => { app.initializers.add('flarum-akismet', () => {
extend(PostControls, 'destructiveControls', function (items: ItemList, post: Post) { extend(PostControls, 'destructiveControls', function (items: ItemList<Mithril.Children>, post: Post) {
if (items.has('approve')) { if (items.has('approve')) {
const flags = post.flags(); const flags = post.flags();
if (flags && flags.some((flag) => flag.type() === 'akismet')) { if (flags && flags.some((flag) => flag?.type() === 'akismet')) {
items.get('approve').children = app.translator.trans('flarum-akismet.forum.post.not_spam_button'); const approveItem = items.get('approve');
if (approveItem && typeof approveItem === 'object' && 'children' in approveItem) {
approveItem.children = app.translator.trans('flarum-akismet.forum.post.not_spam_button');
}
} }
} }
}); });

View File

@ -4,13 +4,14 @@
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder // This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder
// and also tells your Typescript server to read core's global typings for // and also tells your Typescript server to read core's global typings for
// access to `dayjs` and `$` in the global namespace. // access to `dayjs` and `$` in the global namespace.
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*", "@types/**/*"], "include": ["src/**/*", "../vendor/*/*/js/dist-typings/@types/**/*", "@types/**/*"],
"compilerOptions": { "compilerOptions": {
// This will output typings to `dist-typings` // This will output typings to `dist-typings`
"declarationDir": "./dist-typings", "declarationDir": "./dist-typings",
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"] "flarum/*": ["../vendor/flarum/core/js/dist-typings/*"],
"flarum/flags/*": ["../vendor/flarum/flags/js/dist-typings/*"]
} }
} }
} }

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -49,7 +49,7 @@
"gitConf": true, "gitConf": true,
"githubActions": true, "githubActions": true,
"prettier": true, "prettier": true,
"typescript": false, "typescript": true,
"bundlewatch": false, "bundlewatch": false,
"backendTesting": true, "backendTesting": true,
"editorConfig": true, "editorConfig": true,

22
extensions/flags/js/dist-typings/@types/shims.d.ts generated vendored Normal file
View File

@ -0,0 +1,22 @@
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';
declare module 'flarum/common/models/Post' {
export default interface Post {
flags: () => false | (Flag | undefined)[];
canFlag: () => boolean;
}
}
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
flags: FlagListState;
}
}
declare module 'flarum/forum/components/Post' {
export default interface Post {
flagReason: (flag: Flag) => Mithril.Children;
}
}

1
extensions/flags/js/dist-typings/admin/index.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

19
extensions/flags/js/dist-typings/forum/compat.d.ts generated vendored Normal file
View File

@ -0,0 +1,19 @@
declare var _default: {
'flags/addFlagsToPosts': typeof addFlagsToPosts;
'flags/addFlagControl': typeof addFlagControl;
'flags/addFlagsDropdown': typeof addFlagsDropdown;
'flags/models/Flag': typeof Flag;
'flags/components/FlagList': typeof FlagList;
'flags/components/FlagPostModal': typeof FlagPostModal;
'flags/components/FlagsPage': typeof FlagsPage;
'flags/components/FlagsDropdown': typeof FlagsDropdown;
};
export default _default;
import addFlagsToPosts from "./addFlagsToPosts";
import addFlagControl from "./addFlagControl";
import addFlagsDropdown from "./addFlagsDropdown";
import Flag from "./models/Flag";
import FlagList from "./components/FlagList";
import FlagPostModal from "./components/FlagPostModal";
import FlagsPage from "./components/FlagsPage";
import FlagsDropdown from "./components/FlagsDropdown";

View File

@ -0,0 +1,7 @@
export default class FlagList extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
constructor();
oninit(vnode: any): void;
state: any;
view(): JSX.Element;
}
import Component from "flarum/common/Component";

View File

@ -0,0 +1,15 @@
/// <reference types="flarum/@types/translator-icu-rich" />
export default class FlagPostModal extends Modal<import("flarum/common/components/Modal").IInternalModalAttrs> {
constructor();
oninit(vnode: any): void;
success: boolean | undefined;
reason: Stream<string> | undefined;
reasonDetail: Stream<string> | undefined;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
content(): JSX.Element;
flagReasons(): ItemList<any>;
onsubmit(e: any): void;
}
import Modal from "flarum/common/components/Modal";
import Stream from "flarum/common/utils/Stream";
import ItemList from "flarum/common/utils/ItemList";

View File

@ -0,0 +1,7 @@
export default class FlagsDropdown {
static initAttrs(attrs: any): void;
getMenu(): JSX.Element;
goToRoute(): void;
getUnreadCount(): any;
getNewCount(): unknown;
}

View File

@ -0,0 +1,9 @@
/**
* The `FlagsPage` component shows the flags list. It is only
* used on mobile devices where the flags dropdown is within the drawer.
*/
export default class FlagsPage {
oninit(vnode: any): void;
bodyClass: string | undefined;
view(): JSX.Element;
}

1
extensions/flags/js/dist-typings/forum/index.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,11 @@
import Model from 'flarum/common/Model';
import Post from 'flarum/common/models/Post';
import User from 'flarum/common/models/User';
export default class Flag extends Model {
type(): string;
reason(): string | null;
reasonDetail(): string | null;
createdAt(): Date | null | undefined;
post(): false | Post;
user(): false | User | null;
}

View File

@ -0,0 +1,16 @@
export default class FlagListState {
constructor(app: any);
app: any;
/**
* Whether or not the flags are loading.
*
* @type {Boolean}
*/
loading: boolean;
/**
* Load flags into the application's cache if they haven't already
* been loaded.
*/
load(): void;
cache: any;
}

View File

@ -3,12 +3,8 @@
"name": "@flarum/flags", "name": "@flarum/flags",
"version": "0.0.0", "version": "0.0.0",
"prettier": "@flarum/prettier-config", "prettier": "@flarum/prettier-config",
"dependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-webpack-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2"
},
"devDependencies": { "devDependencies": {
"@types/mithril": "^2.0.8",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0", "flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0", "webpack": "^5.65.0",
@ -25,8 +21,9 @@
"format-check": "prettier --check src", "format-check": "prettier --check src",
"analyze": "cross-env ANALYZER=true yarn run build", "analyze": "cross-env ANALYZER=true yarn run build",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings", "clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "npm run clean-typings && cp -r src/@types dist-typings/@types && tsc", "build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report" "check-typings-coverage": "typescript-coverage-report",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"
} }
} }

View File

@ -0,0 +1,22 @@
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';
declare module 'flarum/common/models/Post' {
export default interface Post {
flags: () => false | (Flag | undefined)[];
canFlag: () => boolean;
}
}
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
flags: FlagListState;
}
}
declare module 'flarum/forum/components/Post' {
export default interface Post {
flagReason: (flag: Flag) => Mithril.Children;
}
}

View File

@ -9,8 +9,8 @@ import addFlagsDropdown from './addFlagsDropdown';
import addFlagsToPosts from './addFlagsToPosts'; import addFlagsToPosts from './addFlagsToPosts';
app.initializers.add('flarum-flags', () => { app.initializers.add('flarum-flags', () => {
app.store.models.posts.prototype.flags = Model.hasMany('flags'); Post.prototype.flags = Model.hasMany<Flag>('flags');
app.store.models.posts.prototype.canFlag = Model.attribute('canFlag'); Post.prototype.canFlag = Model.attribute<boolean>('canFlag');
app.store.models.flags = Flag; app.store.models.flags = Flag;
@ -26,5 +26,6 @@ app.initializers.add('flarum-flags', () => {
// Expose compat API // Expose compat API
import flagsCompat from './compat'; import flagsCompat from './compat';
import { compat } from '@flarum/core/forum'; import { compat } from '@flarum/core/forum';
import Post from 'flarum/common/models/Post';
Object.assign(compat, flagsCompat); Object.assign(compat, flagsCompat);

View File

@ -1,15 +0,0 @@
import Model from 'flarum/common/Model';
class Flag extends Model {}
Object.assign(Flag.prototype, {
type: Model.attribute('type'),
reason: Model.attribute('reason'),
reasonDetail: Model.attribute('reasonDetail'),
createdAt: Model.attribute('createdAt', Model.transformDate),
post: Model.hasOne('post'),
user: Model.hasOne('user'),
});
export default Flag;

View File

@ -0,0 +1,25 @@
import Model from 'flarum/common/Model';
import type Post from 'flarum/common/models/Post';
import type User from 'flarum/common/models/User';
export default class Flag extends Model {
type() {
return Model.attribute<string>('type').call(this);
}
reason() {
return Model.attribute<string | null>('reason').call(this);
}
reasonDetail() {
return Model.attribute<string | null>('reasonDetail').call(this);
}
createdAt() {
return Model.attribute('createdAt', Model.transformDate).call(this);
}
post() {
return Model.hasOne<Post>('post').call(this);
}
user() {
return Model.hasOne<User | null>('user').call(this);
}
}

View File

@ -0,0 +1,17 @@
{
// Use Flarum's tsconfig as a starting point
"extends": "flarum-tsconfig",
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder
// and also tells your Typescript server to read core's global typings for
// access to `dayjs` and `$` in the global namespace.
"include": ["src/**/*", "../vendor/*/*/js/dist-typings/@types/**/*", "@types/**/*"],
"compilerOptions": {
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"baseUrl": ".",
"paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"],
"@flarum/core/*": ["../vendor/flarum/core/js/dist-typings/*"]
}
}
}

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -21,7 +21,7 @@
"ci": "yarn install --immutable --immutable-cache", "ci": "yarn install --immutable --immutable-cache",
"analyze": "cross-env ANALYZER=true yarn run build", "analyze": "cross-env ANALYZER=true yarn run build",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings", "clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings", "build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report", "check-typings-coverage": "typescript-coverage-report",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'" "post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"

View File

@ -46,7 +46,7 @@ export default class Installer<Attrs> extends Component<Attrs> {
app.modal.show(LoadingModal); app.modal.show(LoadingModal);
app app
.request({ .request<{ id: string }>({
method: 'POST', method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/extensions`, url: `${app.forum.attribute('apiUrl')}/package-manager/extensions`,
body: { body: {

View File

@ -3,6 +3,7 @@ import app from 'flarum/admin/app';
import Component from 'flarum/common/Component'; import Component from 'flarum/common/Component';
import Button from 'flarum/common/components/Button'; import Button from 'flarum/common/components/Button';
import humanTime from 'flarum/common/helpers/humanTime'; import humanTime from 'flarum/common/helpers/humanTime';
import extractText from 'flarum/common/utils/extractText';
import LoadingModal from 'flarum/admin/components/LoadingModal'; import LoadingModal from 'flarum/admin/components/LoadingModal';
import errorHandler from '../utils/errorHandler'; import errorHandler from '../utils/errorHandler';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
@ -188,7 +189,7 @@ export default class Updater<Attrs> extends Component<Attrs> {
} }
updateCoreMinor() { updateCoreMinor() {
if (confirm(app.translator.trans('flarum-package-manager.admin.minor_update_confirmation.content'))) { if (confirm(extractText(app.translator.trans('flarum-package-manager.admin.minor_update_confirmation.content')))) {
app.modal.show(LoadingModal); app.modal.show(LoadingModal);
this.isLoading = 'minor-update'; this.isLoading = 'minor-update';

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -22,6 +22,9 @@
"flarum/core": "^1.2", "flarum/core": "^1.2",
"pusher/pusher-php-server": "^2.2" "pusher/pusher-php-server": "^2.2"
}, },
"require-dev": {
"flarum/tags": "^1.0"
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Flarum\\Pusher\\": "src/" "Flarum\\Pusher\\": "src/"

View File

@ -10,7 +10,7 @@
"format": "prettier --write src", "format": "prettier --write src",
"format-check": "prettier --check src", "format-check": "prettier --check src",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings", "clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings", "build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report", "check-typings-coverage": "typescript-coverage-report",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'" "post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"

View File

@ -6,7 +6,8 @@ import DiscussionPage from 'flarum/forum/components/DiscussionPage';
import IndexPage from 'flarum/forum/components/IndexPage'; import IndexPage from 'flarum/forum/components/IndexPage';
import Button from 'flarum/common/components/Button'; import Button from 'flarum/common/components/Button';
import ItemList from 'flarum/common/utils/ItemList'; import ItemList from 'flarum/common/utils/ItemList';
import { Children, VnodeDOM } from 'mithril'; import type { Children } from 'mithril';
import type Tag from 'flarum/tags/common/models/Tag';
export type PusherBinding = { export type PusherBinding = {
channels: { channels: {
@ -47,14 +48,15 @@ app.initializers.add('flarum-pusher', () => {
app.pusher.then((binding: PusherBinding) => { app.pusher.then((binding: PusherBinding) => {
const pusher = binding.pusher; const pusher = binding.pusher;
pusher.bind('newPost', (data: { tagIds: number[]; discussionId: number }) => { pusher.bind('newPost', (data: { tagIds: string[]; discussionId: number }) => {
const params = app.discussions.getParams(); const params = app.discussions.getParams();
if (!params.q && !params.sort && !params.filter) { if (!params.q && !params.sort && !params.filter) {
if (params.tags) { if (params.tags) {
const tag = app.store.getBy('tags', 'slug', params.tags); const tag = app.store.getBy<Tag>('tags', 'slug', params.tags);
const tagId = tag?.id();
if (!data.tagIds.includes(tag.id())) return; if (!tagId || !data.tagIds.includes(tagId)) return;
} }
const id = String(data.discussionId); const id = String(data.discussionId);
@ -79,11 +81,11 @@ app.initializers.add('flarum-pusher', () => {
}); });
}); });
extend(DiscussionList.prototype, 'view', function (this: DiscussionList, vdom: VnodeDOM) { extend(DiscussionList.prototype, 'view', function (this: DiscussionList, vdom: Children) {
if (app.pushedUpdates) { if (app.pushedUpdates) {
const count = app.pushedUpdates.length; const count = app.pushedUpdates.length;
if (count) { if (count && typeof vdom === 'object' && vdom && 'children' in vdom && vdom.children instanceof Array) {
vdom.children.unshift( vdom.children.unshift(
Button.component( Button.component(
{ {

View File

@ -13,3 +13,9 @@ declare module 'flarum/forum/ForumApplication' {
pushedUpdates: Array<any>; pushedUpdates: Array<any>;
} }
} }
declare module 'flarum/forum/components/DiscussionList' {
export default interface DiscussionList {
loadingUpdated?: boolean;
}
}

View File

@ -4,13 +4,14 @@
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder // This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder
// and also tells your Typescript server to read core's global typings for // and also tells your Typescript server to read core's global typings for
// access to `dayjs` and `$` in the global namespace. // access to `dayjs` and `$` in the global namespace.
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*", "@types/**/*"], "include": ["src/**/*", "../vendor/*/*/js/dist-typings/@types/**/*", "@types/**/*"],
"compilerOptions": { "compilerOptions": {
// This will output typings to `dist-typings` // This will output typings to `dist-typings`
"declarationDir": "./dist-typings", "declarationDir": "./dist-typings",
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"] "flarum/*": ["../vendor/flarum/core/js/dist-typings/*"],
"flarum/tags/*": ["../vendor/flarum/tags/js/dist-typings/*"]
} }
} }
} }

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -24,7 +24,7 @@
"format-check": "prettier --check src", "format-check": "prettier --check src",
"analyze": "cross-env ANALYZER=true yarn run build", "analyze": "cross-env ANALYZER=true yarn run build",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings", "clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings", "build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report", "check-typings-coverage": "typescript-coverage-report",
"ci": "yarn install --immutable --immutable-cache", "ci": "yarn install --immutable --immutable-cache",

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@ -54,7 +54,7 @@
"gitConf": true, "gitConf": true,
"githubActions": true, "githubActions": true,
"prettier": false, "prettier": false,
"typescript": false, "typescript": true,
"bundlewatch": false, "bundlewatch": false,
"backendTesting": true, "backendTesting": true,
"editorConfig": true, "editorConfig": true,

21
extensions/tags/js/dist-typings/@types/shims.d.ts generated vendored Normal file
View File

@ -0,0 +1,21 @@
import type Tag from "../common/models/Tag";
import type TagListState from "../forum/states/TagListState";
declare module 'flarum/forum/routes' {
export interface ForumRoutes {
tag: (tag: Tag) => string;
}
}
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
tagList: TagListState;
}
}
declare module 'flarum/common/models/Discussion' {
export default interface Discussion {
tags: () => false | (Tag | undefined)[];
canTag: () => boolean | undefined;
}
}

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

21
extensions/tags/js/dist-typings/admin/compat.d.ts generated vendored Normal file
View File

@ -0,0 +1,21 @@
declare var _default: {
'tags/utils/sortTags': typeof import("../common/utils/sortTags").default;
'tags/models/Tag': typeof import("../common/models/Tag").default;
'tags/helpers/tagsLabel': typeof import("../common/helpers/tagsLabel").default;
'tags/helpers/tagIcon': typeof import("../common/helpers/tagIcon").default;
'tags/helpers/tagLabel': typeof import("../common/helpers/tagLabel").default;
} & {
'tags/addTagsHomePageOption': typeof addTagsHomePageOption;
'tags/addTagChangePermission': typeof addTagChangePermission;
'tags/components/TagsPage': typeof TagsPage;
'tags/components/EditTagModal': typeof EditTagModal;
'tags/addTagPermission': typeof addTagPermission;
'tags/addTagsPermissionScope': typeof addTagsPermissionScope;
};
export default _default;
import addTagsHomePageOption from "./addTagsHomePageOption";
import addTagChangePermission from "./addTagChangePermission";
import TagsPage from "./components/TagsPage";
import EditTagModal from "./components/EditTagModal";
import addTagPermission from "./addTagPermission";
import addTagsPermissionScope from "./addTagsPermissionScope";

View File

@ -0,0 +1,34 @@
/// <reference types="flarum/@types/translator-icu-rich" />
/**
* The `EditTagModal` component shows a modal dialog which allows the user
* to create or edit a tag.
*/
export default class EditTagModal extends Modal<import("flarum/common/components/Modal").IInternalModalAttrs> {
constructor();
oninit(vnode: any): void;
tag: any;
name: Stream<any> | undefined;
slug: Stream<any> | undefined;
description: Stream<any> | undefined;
color: Stream<any> | undefined;
icon: Stream<any> | undefined;
isHidden: Stream<any> | undefined;
primary: Stream<any> | undefined;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray | import("mithril").Vnode<any, any>;
content(): JSX.Element;
fields(): ItemList<any>;
submitData(): {
name: any;
slug: any;
description: any;
color: any;
icon: any;
isHidden: any;
primary: any;
};
onsubmit(e: any): void;
delete(): void;
}
import Modal from "flarum/common/components/Modal";
import Stream from "flarum/common/utils/Stream";
import ItemList from "flarum/common/utils/ItemList";

View File

@ -0,0 +1,10 @@
export default class TagsPage extends ExtensionPage<import("flarum/admin/components/ExtensionPage").ExtensionPageAttrs> {
constructor();
oninit(vnode: any): void;
forcedRefreshKey: number | undefined;
content(): JSX.Element;
onListOnCreate(vnode: any): void;
setMinTags(minTags: any, maxTags: any, value: any): void;
onSortUpdate(e: any): void;
}
import ExtensionPage from "flarum/admin/components/ExtensionPage";

1
extensions/tags/js/dist-typings/admin/index.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export {};

13
extensions/tags/js/dist-typings/common/compat.d.ts generated vendored Normal file
View File

@ -0,0 +1,13 @@
declare var _default: {
'tags/utils/sortTags': typeof sortTags;
'tags/models/Tag': typeof Tag;
'tags/helpers/tagsLabel': typeof tagsLabel;
'tags/helpers/tagIcon': typeof tagIcon;
'tags/helpers/tagLabel': typeof tagLabel;
};
export default _default;
import sortTags from "./utils/sortTags";
import Tag from "./models/Tag";
import tagsLabel from "./helpers/tagsLabel";
import tagIcon from "./helpers/tagIcon";
import tagLabel from "./helpers/tagLabel";

View File

@ -0,0 +1 @@
export default function tagIcon(tag: any, attrs?: {}, settings?: {}): JSX.Element;

View File

@ -0,0 +1 @@
export default function tagLabel(tag: any, attrs?: {}): import("mithril").Vnode<any, any>;

View File

@ -0,0 +1 @@
export default function tagsLabel(tags: any, attrs?: {}): JSX.Element;

24
extensions/tags/js/dist-typings/common/models/Tag.d.ts generated vendored Normal file
View File

@ -0,0 +1,24 @@
import Model from 'flarum/common/Model';
import Discussion from 'flarum/common/models/Discussion';
export default class Tag extends Model {
name(): string;
slug(): string;
description(): string | null;
color(): string | null;
backgroundUrl(): string | null;
backgroundMode(): string | null;
icon(): string | null;
position(): number | null;
parent(): false | Tag | null;
children(): false | (Tag | undefined)[];
defaultSort(): string | null;
isChild(): boolean;
isHidden(): boolean;
discussionCount(): number;
lastPostedAt(): Date | null | undefined;
lastPostedDiscussion(): false | Discussion | null;
isRestricted(): boolean;
canStartDiscussion(): boolean;
canAddToDiscussion(): boolean;
isPrimary(): boolean;
}

View File

@ -0,0 +1 @@
export default function sortTags(tags: any): any;

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

View File

@ -0,0 +1 @@
export default function _default(): void;

31
extensions/tags/js/dist-typings/forum/compat.d.ts generated vendored Normal file
View File

@ -0,0 +1,31 @@
declare var _default: {
'tags/utils/sortTags': typeof import("../common/utils/sortTags").default;
'tags/models/Tag': typeof import("../common/models/Tag").default;
'tags/helpers/tagsLabel': typeof import("../common/helpers/tagsLabel").default;
'tags/helpers/tagIcon': typeof import("../common/helpers/tagIcon").default;
'tags/helpers/tagLabel': typeof import("../common/helpers/tagLabel").default;
} & {
'tags/addTagFilter': typeof addTagFilter;
'tags/addTagControl': typeof addTagControl;
'tags/components/TagHero': typeof TagHero;
'tags/components/TagDiscussionModal': typeof TagDiscussionModal;
'tags/components/TagsPage': typeof TagsPage;
'tags/components/DiscussionTaggedPost': typeof DiscussionTaggedPost;
'tags/components/TagLinkButton': typeof TagLinkButton;
'tags/addTagList': typeof addTagList;
'tags/addTagLabels': typeof addTagLabels;
'tags/addTagComposer': typeof addTagComposer;
'tags/utils/getSelectableTags': typeof getSelectableTags;
};
export default _default;
import addTagFilter from "./addTagFilter";
import addTagControl from "./addTagControl";
import TagHero from "./components/TagHero";
import TagDiscussionModal from "./components/TagDiscussionModal";
import TagsPage from "./components/TagsPage";
import DiscussionTaggedPost from "./components/DiscussionTaggedPost";
import TagLinkButton from "./components/TagLinkButton";
import addTagList from "./addTagList";
import addTagLabels from "./addTagLabels";
import addTagComposer from "./addTagComposer";
import getSelectableTags from "./utils/getSelectableTags";

View File

@ -0,0 +1,9 @@
export default class DiscussionTaggedPost extends EventPost {
static initAttrs(attrs: any): void;
descriptionKey(): "flarum-tags.forum.post_stream.added_and_removed_tags_text" | "flarum-tags.forum.post_stream.added_tags_text" | "flarum-tags.forum.post_stream.removed_tags_text";
descriptionData(): {
tagsAdded: any;
tagsRemoved: any;
};
}
import EventPost from "flarum/forum/components/EventPost";

View File

@ -0,0 +1,44 @@
export default class TagDiscussionModal extends Modal<import("flarum/common/components/Modal").IInternalModalAttrs> {
constructor();
oninit(vnode: any): void;
tagsLoading: boolean | undefined;
selected: any[] | undefined;
filter: Stream<string> | undefined;
focused: boolean | undefined;
minPrimary: any;
maxPrimary: any;
minSecondary: any;
maxSecondary: any;
bypassReqs: any;
navigator: KeyboardNavigatable | undefined;
tags: any;
index: any;
primaryCount(): number;
secondaryCount(): number;
/**
* Add the given tag to the list of selected tags.
*
* @param {Tag} tag
*/
addTag(tag: Tag): void;
/**
* Remove the given tag from the list of selected tags.
*
* @param {Tag} tag
*/
removeTag(tag: Tag): void;
title(): any;
getInstruction(primaryCount: any, secondaryCount: any): any;
content(): JSX.Element | JSX.Element[];
meetsRequirements(primaryCount: any, secondaryCount: any): boolean;
toggleTag(tag: any): void;
select(e: any): void;
selectableItems(): JQuery<HTMLElement>;
getCurrentNumericIndex(): number;
getItem(index: any): JQuery<HTMLElement>;
setIndex(index: any, scrollToItem: any): void;
onsubmit(e: any): void;
}
import Modal from "flarum/common/components/Modal";
import Stream from "flarum/common/utils/Stream";
import KeyboardNavigatable from "flarum/forum/utils/KeyboardNavigatable";

View File

@ -0,0 +1,5 @@
export default class TagHero extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
constructor();
view(): JSX.Element;
}
import Component from "flarum/common/Component";

Some files were not shown because too many files have changed in this diff Show More