From 0bc8f07de74fcff40d788839e7e8d2f435ba93ea Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 01:35:46 -0500 Subject: [PATCH 01/41] fix: Convert DashboardPage and DashboardWidget to TypeScript --- .../{DashboardPage.js => DashboardPage.tsx} | 5 ++-- .../src/admin/components/DashboardWidget.js | 25 ------------------- .../src/admin/components/DashboardWidget.tsx | 18 +++++++++++++ 3 files changed, 21 insertions(+), 27 deletions(-) rename framework/core/js/src/admin/components/{DashboardPage.js => DashboardPage.tsx} (85%) delete mode 100644 framework/core/js/src/admin/components/DashboardWidget.js create mode 100644 framework/core/js/src/admin/components/DashboardWidget.tsx diff --git a/framework/core/js/src/admin/components/DashboardPage.js b/framework/core/js/src/admin/components/DashboardPage.tsx similarity index 85% rename from framework/core/js/src/admin/components/DashboardPage.js rename to framework/core/js/src/admin/components/DashboardPage.tsx index 006c24b4f0..f4fa48c036 100644 --- a/framework/core/js/src/admin/components/DashboardPage.js +++ b/framework/core/js/src/admin/components/DashboardPage.tsx @@ -3,6 +3,7 @@ import StatusWidget from './StatusWidget'; import ExtensionsWidget from './ExtensionsWidget'; import ItemList from '../../common/utils/ItemList'; import AdminPage from './AdminPage'; +import { Children } from 'mithril'; export default class DashboardPage extends AdminPage { headerInfo() { @@ -18,8 +19,8 @@ export default class DashboardPage extends AdminPage { return this.availableWidgets().toArray(); } - availableWidgets() { - const items = new ItemList(); + availableWidgets(): ItemList { + const items = new ItemList(); items.add('status', , 30); diff --git a/framework/core/js/src/admin/components/DashboardWidget.js b/framework/core/js/src/admin/components/DashboardWidget.js deleted file mode 100644 index 1e42cc8fb3..0000000000 --- a/framework/core/js/src/admin/components/DashboardWidget.js +++ /dev/null @@ -1,25 +0,0 @@ -import Component from '../../common/Component'; - -export default class DashboardWidget extends Component { - view() { - return
{this.content()}
; - } - - /** - * Get the class name to apply to the widget. - * - * @return {string} - */ - className() { - return ''; - } - - /** - * Get the content of the widget. - * - * @return {import('mithril').Children} - */ - content() { - return null; - } -} diff --git a/framework/core/js/src/admin/components/DashboardWidget.tsx b/framework/core/js/src/admin/components/DashboardWidget.tsx new file mode 100644 index 0000000000..62d116ed06 --- /dev/null +++ b/framework/core/js/src/admin/components/DashboardWidget.tsx @@ -0,0 +1,18 @@ +import { Children, Vnode } from 'mithril'; +import Component, { ComponentAttrs } from '../../common/Component'; + +export interface IDashboardWidgetAttrs extends ComponentAttrs {} + +export default class DashboardWidget extends Component { + view(vnode: Vnode): Children { + return
{this.content()}
; + } + + className() { + return ''; + } + + content(): Children { + return null; + } +} From 509f8addd8b1e3e1e1c80c94d431503d36ea6f45 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 01:42:23 -0500 Subject: [PATCH 02/41] fix: fix type errors in package manager ext --- .../package-manager/js/src/admin/components/Installer.tsx | 2 +- extensions/package-manager/js/src/admin/components/Updater.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/package-manager/js/src/admin/components/Installer.tsx b/extensions/package-manager/js/src/admin/components/Installer.tsx index c8b67a79df..2abe3dfaa9 100755 --- a/extensions/package-manager/js/src/admin/components/Installer.tsx +++ b/extensions/package-manager/js/src/admin/components/Installer.tsx @@ -46,7 +46,7 @@ export default class Installer extends Component { app.modal.show(LoadingModal); app - .request({ + .request<{ id: string }>({ method: 'POST', url: `${app.forum.attribute('apiUrl')}/package-manager/extensions`, body: { diff --git a/extensions/package-manager/js/src/admin/components/Updater.tsx b/extensions/package-manager/js/src/admin/components/Updater.tsx index d621c360b0..4acbfb8604 100755 --- a/extensions/package-manager/js/src/admin/components/Updater.tsx +++ b/extensions/package-manager/js/src/admin/components/Updater.tsx @@ -3,6 +3,7 @@ import app from 'flarum/admin/app'; import Component from 'flarum/common/Component'; import Button from 'flarum/common/components/Button'; import humanTime from 'flarum/common/helpers/humanTime'; +import extractText from 'flarum/common/utils/extractText'; import LoadingModal from 'flarum/admin/components/LoadingModal'; import errorHandler from '../utils/errorHandler'; import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; @@ -188,7 +189,7 @@ export default class Updater extends Component { } 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); this.isLoading = 'minor-update'; From 2c6f301577ee550fd9a23667eb276a1f9c641166 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 01:55:01 -0500 Subject: [PATCH 03/41] fix: Convert Post component to TypeScript --- .../forum/components/{Post.js => Post.tsx} | 70 ++++++++----------- 1 file changed, 30 insertions(+), 40 deletions(-) rename framework/core/js/src/forum/components/{Post.js => Post.tsx} (76%) diff --git a/framework/core/js/src/forum/components/Post.js b/framework/core/js/src/forum/components/Post.tsx similarity index 76% rename from framework/core/js/src/forum/components/Post.js rename to framework/core/js/src/forum/components/Post.tsx index df13321ec7..e29560d338 100644 --- a/framework/core/js/src/forum/components/Post.js +++ b/framework/core/js/src/forum/components/Post.tsx @@ -1,53 +1,54 @@ import app from '../../forum/app'; -import Component from '../../common/Component'; +import Component, { ComponentAttrs } from '../../common/Component'; import SubtreeRetainer from '../../common/utils/SubtreeRetainer'; import Dropdown from '../../common/components/Dropdown'; import PostControls from '../utils/PostControls'; import listItems from '../../common/helpers/listItems'; import ItemList from '../../common/utils/ItemList'; +import PostModel from '../../common/models/Post'; import LoadingIndicator from '../../common/components/LoadingIndicator'; +import Mithril from 'mithril'; + +export interface IPostAttrs extends ComponentAttrs { + post: PostModel; +} /** * The `Post` component displays a single post. The basic post template just * includes a controls dropdown; subclasses must implement `content` and `attrs` * methods. - * - * ### Attrs - * - * - `post` - * - * @abstract */ -export default class Post extends Component { - oninit(vnode) { +export default abstract class Post extends Component { + /** + * May be set by subclasses. + */ + loading = false; + + /** + * Ensures that the post will not be redrawn + * unless new data comes in. + */ + subtree!: SubtreeRetainer; + + oninit(vnode: Mithril.Vnode) { super.oninit(vnode); - /** - * May be set by subclasses. - */ this.loading = false; - /** - * Set up a subtree retainer so that the post will not be redrawn - * unless new data comes in. - * - * @type {SubtreeRetainer} - */ this.subtree = new SubtreeRetainer( () => this.loading, () => this.attrs.post.freshness, () => { const user = this.attrs.post.user(); return user && user.freshness; - }, - () => this.controlsOpen + } ); } - view() { + view(vnode: Mithril.Vnode) { const attrs = this.elementAttrs(); - attrs.className = this.classes(attrs.className).join(' '); + attrs.className = this.classes(attrs.className as string | undefined).join(' '); const controls = PostControls.controls(this.attrs.post, this).toArray(); const footerItems = this.footerItems().toArray(); @@ -84,13 +85,13 @@ export default class Post extends Component { ); } - onbeforeupdate(vnode) { + onbeforeupdate(vnode: Mithril.VnodeDOM) { super.onbeforeupdate(vnode); return this.subtree.needsRebuild(); } - onupdate(vnode) { + onupdate(vnode: Mithril.VnodeDOM) { super.onupdate(vnode); const $actions = this.$('.Post-actions'); @@ -101,30 +102,23 @@ export default class Post extends Component { /** * Get attributes for the post element. - * - * @return {Record} */ - elementAttrs() { + elementAttrs(): Record { return {}; } /** * Get the post's content. - * - * @return {import('mithril').Children} */ - content() { + content(): Mithril.Children { // TODO: [Flarum 2.0] return `null` return []; } /** * Get the post's classes. - * - * @param {string} existing - * @returns {string[]} */ - classes(existing) { + classes(existing?: string): string[] { let classes = (existing || '').split(' ').concat(['Post']); const user = this.attrs.post.user(); @@ -147,19 +141,15 @@ export default class Post extends Component { /** * Build an item list for the post's actions. - * - * @return {ItemList} */ - actionItems() { + actionItems(): ItemList { return new ItemList(); } /** * Build an item list for the post's footer. - * - * @return {ItemList} */ - footerItems() { + footerItems(): ItemList { return new ItemList(); } } From 67c9d7dd77975f24de54c57676473b5baf7562db Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 01:59:18 -0500 Subject: [PATCH 04/41] fix: avatar typings should accept null user --- framework/core/js/src/common/helpers/avatar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/js/src/common/helpers/avatar.tsx b/framework/core/js/src/common/helpers/avatar.tsx index fb60bcd4d3..8cd5e2cce5 100644 --- a/framework/core/js/src/common/helpers/avatar.tsx +++ b/framework/core/js/src/common/helpers/avatar.tsx @@ -10,7 +10,7 @@ export interface AvatarAttrs extends ComponentAttrs {} * @param user * @param attrs Attributes to apply to the avatar element */ -export default function avatar(user: User, attrs: ComponentAttrs = {}): Mithril.Vnode { +export default function avatar(user: User | null, attrs: ComponentAttrs = {}): Mithril.Vnode { attrs.className = 'Avatar ' + (attrs.className || ''); let content: string = ''; From ef9e166cfd1f2990f64ba8562d0866a420aa6175 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:00:40 -0500 Subject: [PATCH 05/41] fix: convert Notification component to TypeScript --- .../{Notification.js => Notification.tsx} | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) rename framework/core/js/src/forum/components/{Notification.js => Notification.tsx} (71%) diff --git a/framework/core/js/src/forum/components/Notification.js b/framework/core/js/src/forum/components/Notification.tsx similarity index 71% rename from framework/core/js/src/forum/components/Notification.js rename to framework/core/js/src/forum/components/Notification.tsx index 91ac05daa2..08e213a1da 100644 --- a/framework/core/js/src/forum/components/Notification.js +++ b/framework/core/js/src/forum/components/Notification.tsx @@ -1,27 +1,29 @@ import app from '../../forum/app'; -import Component from '../../common/Component'; +import NotificationModel from '../../common/models/Notification'; +import Component, { ComponentAttrs } from '../../common/Component'; import avatar from '../../common/helpers/avatar'; import icon from '../../common/helpers/icon'; import humanTime from '../../common/helpers/humanTime'; import Button from '../../common/components/Button'; import Link from '../../common/components/Link'; import classList from '../../common/utils/classList'; +import Mithril from 'mithril'; + +export interface INotificationAttrs extends ComponentAttrs { + notification: NotificationModel; +} /** * The `Notification` component abstract displays a single notification. * Subclasses should implement the `icon`, `href`, and `content` methods. - * - * ### Attrs - * - * - `notification` - * - * @abstract */ -export default class Notification extends Component { - view() { +export default abstract class Notification extends Component { + view(vnode: Mithril.Vnode) { const notification = this.attrs.notification; const href = this.href(); + const fromUser = notification.fromUser(); + return ( - {avatar(notification.fromUser())} + {avatar(fromUser || null)} {icon(this.icon(), { className: 'Notification-icon' })} {this.content()} @@ -41,7 +43,7 @@ export default class Notification extends Component { className="Notification-action Button Button--link" icon="fas fa-check" title={app.translator.trans('core.forum.notifications.mark_as_read_tooltip')} - onclick={(e) => { + onclick={(e: Event) => { e.preventDefault(); e.stopPropagation(); @@ -56,35 +58,23 @@ export default class Notification extends Component { /** * Get the name of the icon that should be displayed in the notification. - * - * @return {string} - * @abstract */ - icon() {} + abstract icon(): string; /** * Get the URL that the notification should link to. - * - * @return {string} - * @abstract */ - href() {} + abstract href(): string /** * Get the content of the notification. - * - * @return {import('mithril').Children} - * @abstract */ - content() {} + abstract content(): Mithril.Children /** * Get the excerpt of the notification. - * - * @return {import('mithril').Children} - * @abstract */ - excerpt() {} + abstract excerpt(): Mithril.Children /** * Mark the notification as read. @@ -92,7 +82,7 @@ export default class Notification extends Component { markAsRead() { if (this.attrs.notification.isRead()) return; - app.session.user.pushAttributes({ unreadNotificationCount: app.session.user.unreadNotificationCount() - 1 }); + app.session.user?.pushAttributes({ unreadNotificationCount: (app.session.user.unreadNotificationCount() ?? 1) - 1 }); this.attrs.notification.save({ isRead: true }); } From a8b4b8fbd0b43b2c0310ce5247b350045690426c Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:08:29 -0500 Subject: [PATCH 06/41] fix: properly use `typeof` in ForumApplication --- framework/core/js/src/forum/ForumApplication.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/core/js/src/forum/ForumApplication.ts b/framework/core/js/src/forum/ForumApplication.ts index 2566d27669..e8350ab502 100644 --- a/framework/core/js/src/forum/ForumApplication.ts +++ b/framework/core/js/src/forum/ForumApplication.ts @@ -23,20 +23,22 @@ import isSafariMobile from './utils/isSafariMobile'; import type Notification from './components/Notification'; import type Post from './components/Post'; import Discussion from '../common/models/Discussion'; +import NotificationModel from '../common/models/Notification'; +import PostModel from '../common/models/Post'; import extractText from '../common/utils/extractText'; export default class ForumApplication extends Application { /** * A map of notification types to their components. */ - notificationComponents: Record = { + notificationComponents: Record>> = { discussionRenamed: DiscussionRenamedNotification, }; /** * A map of post types to their components. */ - postComponents: Record = { + postComponents: Record>> = { comment: CommentPost, discussionRenamed: DiscussionRenamedPost, }; From fc7ab1422113a97b9529f1d1cc495476314b2f86 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:09:25 -0500 Subject: [PATCH 07/41] feat: make Notification content attr generic --- framework/core/js/src/common/models/Notification.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/core/js/src/common/models/Notification.ts b/framework/core/js/src/common/models/Notification.ts index 3a2b714c95..e87654552c 100644 --- a/framework/core/js/src/common/models/Notification.ts +++ b/framework/core/js/src/common/models/Notification.ts @@ -5,8 +5,8 @@ export default class Notification extends Model { contentType() { return Model.attribute('contentType').call(this); } - content() { - return Model.attribute('content').call(this); + content() { + return Model.attribute('content').call(this); } createdAt() { return Model.attribute('createdAt', Model.transformDate).call(this); From 415f1470ab5eb38351c261f590adf6af3ef863c0 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:09:38 -0500 Subject: [PATCH 08/41] chore: format Notification component --- framework/core/js/src/forum/components/Notification.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/core/js/src/forum/components/Notification.tsx b/framework/core/js/src/forum/components/Notification.tsx index 08e213a1da..4a45b01173 100644 --- a/framework/core/js/src/forum/components/Notification.tsx +++ b/framework/core/js/src/forum/components/Notification.tsx @@ -64,17 +64,17 @@ export default abstract class Notification Date: Sat, 12 Mar 2022 02:09:59 -0500 Subject: [PATCH 09/41] fix: Convert DiscussionRenamedNotification to TypeScript --- ...n.js => DiscussionRenamedNotification.tsx} | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) rename framework/core/js/src/forum/components/{DiscussionRenamedNotification.js => DiscussionRenamedNotification.tsx} (60%) diff --git a/framework/core/js/src/forum/components/DiscussionRenamedNotification.js b/framework/core/js/src/forum/components/DiscussionRenamedNotification.tsx similarity index 60% rename from framework/core/js/src/forum/components/DiscussionRenamedNotification.js rename to framework/core/js/src/forum/components/DiscussionRenamedNotification.tsx index e254e38ff9..37d96e6fb6 100644 --- a/framework/core/js/src/forum/components/DiscussionRenamedNotification.js +++ b/framework/core/js/src/forum/components/DiscussionRenamedNotification.tsx @@ -1,13 +1,14 @@ +import Discussion from '../../common/models/Discussion'; import app from '../../forum/app'; import Notification from './Notification'; +interface DiscussionRenamedContent { + postNumber: number; +} + /** * The `DiscussionRenamedNotification` component displays a notification which * indicates that a discussion has had its title changed. - * - * ### Attrs - * - * - All of the attrs for Notification */ export default class DiscussionRenamedNotification extends Notification { icon() { @@ -16,11 +17,20 @@ export default class DiscussionRenamedNotification extends Notification { href() { const notification = this.attrs.notification; + const discussion = notification.subject(); + + if (!discussion) { + return '#'; + } - return app.route.discussion(notification.subject(), notification.content().postNumber); + return app.route.discussion(discussion as Discussion, notification.content().postNumber); } content() { return app.translator.trans('core.forum.notifications.discussion_renamed_text', { user: this.attrs.notification.fromUser() }); } + + excerpt() { + return ''; + } } From 589d0582cb5436e9b98a83f4c93809c88b1d0d95 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:16:07 -0500 Subject: [PATCH 10/41] fix(pusher) move shims to a location where they get applied --- extensions/pusher/js/{ => src/forum}/shims.d.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename extensions/pusher/js/{ => src/forum}/shims.d.ts (100%) diff --git a/extensions/pusher/js/shims.d.ts b/extensions/pusher/js/src/forum/shims.d.ts similarity index 100% rename from extensions/pusher/js/shims.d.ts rename to extensions/pusher/js/src/forum/shims.d.ts From d438648f3332f74da0915bc21c5d568e115113a8 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:22:07 -0500 Subject: [PATCH 11/41] fix(pusher): fix some typing errors --- extensions/pusher/js/src/forum/index.ts | 4 ++-- extensions/pusher/js/src/forum/shims.d.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/extensions/pusher/js/src/forum/index.ts b/extensions/pusher/js/src/forum/index.ts index 59bab5680b..ba9524c6ae 100644 --- a/extensions/pusher/js/src/forum/index.ts +++ b/extensions/pusher/js/src/forum/index.ts @@ -79,11 +79,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) { const count = app.pushedUpdates.length; - if (count) { + if (count && (typeof vdom === 'object') && vdom && 'children' in vdom && vdom.children instanceof Array) { vdom.children.unshift( Button.component( { diff --git a/extensions/pusher/js/src/forum/shims.d.ts b/extensions/pusher/js/src/forum/shims.d.ts index b4a2cee42a..72c9790ebd 100644 --- a/extensions/pusher/js/src/forum/shims.d.ts +++ b/extensions/pusher/js/src/forum/shims.d.ts @@ -13,3 +13,9 @@ declare module 'flarum/forum/ForumApplication' { pushedUpdates: Array; } } + +declare module 'flarum/forum/components/DiscussionList' { + export default interface DiscussionList { + loadingUpdated?: boolean; + } +} From 762a46977b32165988fc369f013545da78c88e3b Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:27:51 -0500 Subject: [PATCH 12/41] fix(akismet): fix some typing issues --- extensions/akismet/js/src/forum/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/akismet/js/src/forum/index.ts b/extensions/akismet/js/src/forum/index.ts index e5b3ae4320..bc19777581 100644 --- a/extensions/akismet/js/src/forum/index.ts +++ b/extensions/akismet/js/src/forum/index.ts @@ -5,14 +5,18 @@ import PostControls from 'flarum/forum/utils/PostControls'; import CommentPost from 'flarum/forum/components/CommentPost'; import ItemList from 'flarum/common/utils/ItemList'; import Post from 'flarum/common/models/Post'; +import Mithril from 'mithril'; app.initializers.add('flarum-akismet', () => { - extend(PostControls, 'destructiveControls', function (items: ItemList, post: Post) { + extend(PostControls, 'destructiveControls', function (items: ItemList, post: Post) { if (items.has('approve')) { const flags = post.flags(); 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'); + } } } }); From 6a5e59b46f84e7a00cd0c340320bc36a2d73b8a7 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:31:02 -0500 Subject: [PATCH 13/41] chore: update core dist typings --- .../admin/components/AdminHeader.d.ts | 1 + .../admin/components/AdminNav.d.ts | 4 ++ .../admin/components/AppearancePage.d.ts | 8 +++ .../admin/components/BasicsPage.d.ts | 9 ++++ .../admin/components/DashboardPage.d.ts | 20 ++++++-- .../admin/components/DashboardWidget.d.ts | 21 +++----- .../admin/components/EditCustomCssModal.d.ts | 3 ++ .../components/EditCustomFooterModal.d.ts | 3 ++ .../components/EditCustomHeaderModal.d.ts | 3 ++ .../admin/components/EditGroupModal.d.ts | 4 ++ .../admin/components/ExtensionLinkButton.d.ts | 1 + .../admin/components/ExtensionsWidget.d.ts | 5 +- .../admin/components/HeaderPrimary.d.ts | 1 + .../admin/components/HeaderSecondary.d.ts | 1 + .../admin/components/MailPage.d.ts | 10 ++++ .../admin/components/PermissionsPage.d.ts | 8 +++ .../admin/components/SessionDropdown.d.ts | 1 + .../admin/components/SettingsModal.d.ts | 3 ++ .../admin/components/StatusWidget.d.ts | 4 +- .../admin/components/UploadImageButton.d.ts | 1 + .../common/components/AlertManager.d.ts | 3 ++ .../dist-typings/common/components/Badge.d.ts | 1 + .../common/components/Checkbox.d.ts | 1 + .../components/ConfirmDocumentUnload.d.ts | 3 ++ .../common/components/Dropdown.d.ts | 3 ++ .../common/components/FieldSet.d.ts | 1 + .../dist-typings/common/components/Link.d.ts | 1 + .../common/components/LinkButton.d.ts | 1 + .../common/components/Navigation.d.ts | 1 + .../common/components/Placeholder.d.ts | 1 + .../common/components/Select.d.ts | 1 + .../common/components/SelectDropdown.d.ts | 1 + .../common/components/Separator.d.ts | 1 + .../common/components/SplitDropdown.d.ts | 1 + .../common/components/TextEditor.d.ts | 4 ++ .../common/components/TextEditorButton.d.ts | 1 + .../dist-typings/common/helpers/avatar.d.ts | 2 +- .../common/models/Notification.d.ts | 2 +- .../dist-typings/forum/ForumApplication.d.ts | 14 ++++- .../forum/components/AffixedSidebar.d.ts | 3 ++ .../forum/components/AvatarEditor.d.ts | 2 + .../forum/components/ChangeEmailModal.d.ts | 6 +++ .../forum/components/ChangePasswordModal.d.ts | 4 ++ .../forum/components/CommentPost.d.ts | 7 ++- .../forum/components/Composer.d.ts | 12 +++++ .../forum/components/ComposerBody.d.ts | 2 + .../forum/components/ComposerPostPreview.d.ts | 3 ++ .../forum/components/DiscussionComposer.d.ts | 1 + .../forum/components/DiscussionHero.d.ts | 1 + .../forum/components/DiscussionList.d.ts | 1 + .../forum/components/DiscussionListItem.d.ts | 4 ++ .../forum/components/DiscussionListPane.d.ts | 3 ++ .../DiscussionRenamedNotification.d.ts | 11 ++-- .../components/DiscussionRenamedPost.d.ts | 5 ++ .../forum/components/DiscussionsUserPage.d.ts | 9 ++++ .../forum/components/EventPost.d.ts | 4 +- .../forum/components/HeaderPrimary.d.ts | 1 + .../forum/components/HeaderSecondary.d.ts | 1 + .../forum/components/IndexPage.d.ts | 5 ++ .../forum/components/LoadingPost.d.ts | 1 + .../forum/components/LogInButtons.d.ts | 1 + .../forum/components/Notification.d.ts | 37 +++++--------- .../forum/components/NotificationGrid.d.ts | 3 ++ .../forum/components/NotificationList.d.ts | 3 ++ .../components/NotificationsDropdown.d.ts | 3 ++ .../forum/components/NotificationsPage.d.ts | 2 + .../dist-typings/forum/components/Post.d.ts | 51 ++++++++----------- .../forum/components/PostEdited.d.ts | 3 ++ .../forum/components/PostMeta.d.ts | 1 + .../forum/components/PostPreview.d.ts | 1 + .../forum/components/PostStream.d.ts | 5 ++ .../forum/components/PostStreamScrubber.d.ts | 5 ++ .../forum/components/PostUser.d.ts | 2 + .../forum/components/PostsUserPage.d.ts | 6 +++ .../components/RenameDiscussionModal.d.ts | 5 ++ .../forum/components/ReplyPlaceholder.d.ts | 1 + .../forum/components/SessionDropdown.d.ts | 1 + .../forum/components/SettingsPage.d.ts | 1 + .../forum/components/TerminalPost.d.ts | 1 + .../forum/components/UserCard.d.ts | 1 + .../forum/components/UserPage.d.ts | 7 +++ 81 files changed, 292 insertions(+), 88 deletions(-) diff --git a/framework/core/js/dist-typings/admin/components/AdminHeader.d.ts b/framework/core/js/dist-typings/admin/components/AdminHeader.d.ts index fca40754e8..66fcbc83ca 100644 --- a/framework/core/js/dist-typings/admin/components/AdminHeader.d.ts +++ b/framework/core/js/dist-typings/admin/components/AdminHeader.d.ts @@ -1,4 +1,5 @@ export default class AdminHeader extends Component { constructor(); + view(vnode: any): JSX.Element[]; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/admin/components/AdminNav.d.ts b/framework/core/js/dist-typings/admin/components/AdminNav.d.ts index f9f530582d..f1d5a331ee 100644 --- a/framework/core/js/dist-typings/admin/components/AdminNav.d.ts +++ b/framework/core/js/dist-typings/admin/components/AdminNav.d.ts @@ -1,6 +1,10 @@ export default class AdminNav extends Component { constructor(); + oninit(vnode: any): void; query: Stream | undefined; + view(): JSX.Element; + oncreate(vnode: any): void; + onupdate(vnode: any): void; scrollToActive(): void; /** * Build an item list of main links to show in the admin navigation. diff --git a/framework/core/js/dist-typings/admin/components/AppearancePage.d.ts b/framework/core/js/dist-typings/admin/components/AppearancePage.d.ts index c64cbf5d10..b491f845df 100644 --- a/framework/core/js/dist-typings/admin/components/AppearancePage.d.ts +++ b/framework/core/js/dist-typings/admin/components/AppearancePage.d.ts @@ -1,5 +1,13 @@ +/// export default class AppearancePage extends AdminPage { constructor(); + headerInfo(): { + className: string; + icon: string; + title: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + description: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + }; + content(): JSX.Element[]; colorItems(): ItemList; } import AdminPage from "./AdminPage"; diff --git a/framework/core/js/dist-typings/admin/components/BasicsPage.d.ts b/framework/core/js/dist-typings/admin/components/BasicsPage.d.ts index 9ca67ede40..fbba57eb68 100644 --- a/framework/core/js/dist-typings/admin/components/BasicsPage.d.ts +++ b/framework/core/js/dist-typings/admin/components/BasicsPage.d.ts @@ -1,8 +1,17 @@ +/// export default class BasicsPage extends AdminPage { constructor(); + oninit(vnode: any): void; localeOptions: {} | undefined; displayNameOptions: {} | undefined; slugDriverOptions: {} | undefined; + headerInfo(): { + className: string; + icon: string; + title: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + description: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + }; + content(): JSX.Element[]; /** * Build a list of options for the default homepage. Each option must be an * object with `path` and `label` properties. diff --git a/framework/core/js/dist-typings/admin/components/DashboardPage.d.ts b/framework/core/js/dist-typings/admin/components/DashboardPage.d.ts index b0df8eb479..9c5776859c 100644 --- a/framework/core/js/dist-typings/admin/components/DashboardPage.d.ts +++ b/framework/core/js/dist-typings/admin/components/DashboardPage.d.ts @@ -1,6 +1,16 @@ -export default class DashboardPage extends AdminPage { - constructor(); - availableWidgets(): ItemList; +/// +import ItemList from '../../common/utils/ItemList'; +import AdminPage from './AdminPage'; +import { Children } from 'mithril'; +export default class DashboardPage extends AdminPage { + headerInfo(): { + className: string; + icon: string; + title: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + description: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + }; + content(): (Children & { + itemName: string; + })[]; + availableWidgets(): ItemList; } -import AdminPage from "./AdminPage"; -import ItemList from "../../common/utils/ItemList"; diff --git a/framework/core/js/dist-typings/admin/components/DashboardWidget.d.ts b/framework/core/js/dist-typings/admin/components/DashboardWidget.d.ts index fb33cd6130..1e96d2d2f6 100644 --- a/framework/core/js/dist-typings/admin/components/DashboardWidget.d.ts +++ b/framework/core/js/dist-typings/admin/components/DashboardWidget.d.ts @@ -1,16 +1,9 @@ -export default class DashboardWidget extends Component { - constructor(); - /** - * Get the class name to apply to the widget. - * - * @return {string} - */ +import { Children, Vnode } from 'mithril'; +import Component, { ComponentAttrs } from '../../common/Component'; +export interface IDashboardWidgetAttrs extends ComponentAttrs { +} +export default class DashboardWidget extends Component { + view(vnode: Vnode): Children; className(): string; - /** - * Get the content of the widget. - * - * @return {import('mithril').Children} - */ - content(): import('mithril').Children; + content(): Children; } -import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/admin/components/EditCustomCssModal.d.ts b/framework/core/js/dist-typings/admin/components/EditCustomCssModal.d.ts index ee44396524..9baec5b990 100644 --- a/framework/core/js/dist-typings/admin/components/EditCustomCssModal.d.ts +++ b/framework/core/js/dist-typings/admin/components/EditCustomCssModal.d.ts @@ -1,3 +1,6 @@ +/// export default class EditCustomCssModal extends SettingsModal { + title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + form(): JSX.Element[]; } import SettingsModal from "./SettingsModal"; diff --git a/framework/core/js/dist-typings/admin/components/EditCustomFooterModal.d.ts b/framework/core/js/dist-typings/admin/components/EditCustomFooterModal.d.ts index e022048e33..0ead3a6fe8 100644 --- a/framework/core/js/dist-typings/admin/components/EditCustomFooterModal.d.ts +++ b/framework/core/js/dist-typings/admin/components/EditCustomFooterModal.d.ts @@ -1,3 +1,6 @@ +/// export default class EditCustomFooterModal extends SettingsModal { + title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + form(): JSX.Element[]; } import SettingsModal from "./SettingsModal"; diff --git a/framework/core/js/dist-typings/admin/components/EditCustomHeaderModal.d.ts b/framework/core/js/dist-typings/admin/components/EditCustomHeaderModal.d.ts index df083e1927..f4afd0d369 100644 --- a/framework/core/js/dist-typings/admin/components/EditCustomHeaderModal.d.ts +++ b/framework/core/js/dist-typings/admin/components/EditCustomHeaderModal.d.ts @@ -1,3 +1,6 @@ +/// export default class EditCustomHeaderModal extends SettingsModal { + title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + form(): JSX.Element[]; } import SettingsModal from "./SettingsModal"; diff --git a/framework/core/js/dist-typings/admin/components/EditGroupModal.d.ts b/framework/core/js/dist-typings/admin/components/EditGroupModal.d.ts index a84be2c35a..9f6147a73f 100644 --- a/framework/core/js/dist-typings/admin/components/EditGroupModal.d.ts +++ b/framework/core/js/dist-typings/admin/components/EditGroupModal.d.ts @@ -4,12 +4,15 @@ */ export default class EditGroupModal extends Modal { constructor(); + oninit(vnode: any): void; group: any; nameSingular: Stream | undefined; namePlural: Stream | undefined; icon: Stream | undefined; color: Stream | undefined; isHidden: Stream | undefined; + title(): any[]; + content(): JSX.Element; fields(): ItemList; submitData(): { nameSingular: any; @@ -18,6 +21,7 @@ export default class EditGroupModal extends Modal; } import LinkButton from "../../common/components/LinkButton"; diff --git a/framework/core/js/dist-typings/admin/components/ExtensionsWidget.d.ts b/framework/core/js/dist-typings/admin/components/ExtensionsWidget.d.ts index eb43f53e90..a552a5cf52 100644 --- a/framework/core/js/dist-typings/admin/components/ExtensionsWidget.d.ts +++ b/framework/core/js/dist-typings/admin/components/ExtensionsWidget.d.ts @@ -1,5 +1,8 @@ -export default class ExtensionsWidget extends DashboardWidget { +export default class ExtensionsWidget extends DashboardWidget { + constructor(); + oninit(vnode: any): void; categorizedExtensions: {} | undefined; + content(): JSX.Element; extensionCategory(category: any): JSX.Element; extensionWidget(extension: any): JSX.Element; } diff --git a/framework/core/js/dist-typings/admin/components/HeaderPrimary.d.ts b/framework/core/js/dist-typings/admin/components/HeaderPrimary.d.ts index 8ac7028b9d..a0e53f6e30 100644 --- a/framework/core/js/dist-typings/admin/components/HeaderPrimary.d.ts +++ b/framework/core/js/dist-typings/admin/components/HeaderPrimary.d.ts @@ -4,6 +4,7 @@ */ export default class HeaderPrimary extends Component { constructor(); + view(): JSX.Element; config(isInitialized: any, context: any): void; /** * Build an item list for the controls. diff --git a/framework/core/js/dist-typings/admin/components/HeaderSecondary.d.ts b/framework/core/js/dist-typings/admin/components/HeaderSecondary.d.ts index dc2ab3ca45..bc9a8bc070 100644 --- a/framework/core/js/dist-typings/admin/components/HeaderSecondary.d.ts +++ b/framework/core/js/dist-typings/admin/components/HeaderSecondary.d.ts @@ -3,6 +3,7 @@ */ export default class HeaderSecondary extends Component { constructor(); + view(): JSX.Element; /** * Build an item list for the controls. * diff --git a/framework/core/js/dist-typings/admin/components/MailPage.d.ts b/framework/core/js/dist-typings/admin/components/MailPage.d.ts index 03104b1433..f07e12811b 100644 --- a/framework/core/js/dist-typings/admin/components/MailPage.d.ts +++ b/framework/core/js/dist-typings/admin/components/MailPage.d.ts @@ -1,13 +1,23 @@ +/// export default class MailPage extends AdminPage { constructor(); + oninit(vnode: any): void; sendingTest: boolean | undefined; + headerInfo(): { + className: string; + icon: string; + title: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + description: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + }; refresh(): void; status: { sending: boolean; errors: {}; } | undefined; driverFields: any; + content(): JSX.Element; sendTestEmail(): void; testEmailSuccessAlert: number | undefined; + saveSettings(e: any): void; } import AdminPage from "./AdminPage"; diff --git a/framework/core/js/dist-typings/admin/components/PermissionsPage.d.ts b/framework/core/js/dist-typings/admin/components/PermissionsPage.d.ts index 27dbc74ef1..b96afdde3b 100644 --- a/framework/core/js/dist-typings/admin/components/PermissionsPage.d.ts +++ b/framework/core/js/dist-typings/admin/components/PermissionsPage.d.ts @@ -1,4 +1,12 @@ +/// export default class PermissionsPage extends AdminPage { constructor(); + headerInfo(): { + className: string; + icon: string; + title: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + description: import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + }; + content(): JSX.Element[]; } import AdminPage from "./AdminPage"; diff --git a/framework/core/js/dist-typings/admin/components/SessionDropdown.d.ts b/framework/core/js/dist-typings/admin/components/SessionDropdown.d.ts index 73c73376fd..25533df679 100644 --- a/framework/core/js/dist-typings/admin/components/SessionDropdown.d.ts +++ b/framework/core/js/dist-typings/admin/components/SessionDropdown.d.ts @@ -3,6 +3,7 @@ * avatar/name, with a dropdown of session controls. */ export default class SessionDropdown extends Dropdown { + getButtonContent(): (string | JSX.Element)[]; /** * Build an item list for the contents of the dropdown menu. * diff --git a/framework/core/js/dist-typings/admin/components/SettingsModal.d.ts b/framework/core/js/dist-typings/admin/components/SettingsModal.d.ts index 05b9a36323..381bb17dae 100644 --- a/framework/core/js/dist-typings/admin/components/SettingsModal.d.ts +++ b/framework/core/js/dist-typings/admin/components/SettingsModal.d.ts @@ -1,11 +1,14 @@ export default class SettingsModal extends Modal { constructor(); + oninit(vnode: any): void; settings: {} | undefined; form(): string; + content(): JSX.Element; submitButton(): JSX.Element; setting(key: any, fallback?: string): any; dirty(): {}; changed(): number; + onsubmit(e: any): void; onsaved(): void; } import Modal from "../../common/components/Modal"; diff --git a/framework/core/js/dist-typings/admin/components/StatusWidget.d.ts b/framework/core/js/dist-typings/admin/components/StatusWidget.d.ts index 5fb59c65ae..9372420850 100644 --- a/framework/core/js/dist-typings/admin/components/StatusWidget.d.ts +++ b/framework/core/js/dist-typings/admin/components/StatusWidget.d.ts @@ -1,4 +1,6 @@ -export default class StatusWidget extends DashboardWidget { +export default class StatusWidget extends DashboardWidget { + constructor(); + content(): JSX.Element; items(): ItemList; toolsItems(): ItemList; handleClearCache(e: any): void; diff --git a/framework/core/js/dist-typings/admin/components/UploadImageButton.d.ts b/framework/core/js/dist-typings/admin/components/UploadImageButton.d.ts index 8d3b9d310c..816cce598c 100644 --- a/framework/core/js/dist-typings/admin/components/UploadImageButton.d.ts +++ b/framework/core/js/dist-typings/admin/components/UploadImageButton.d.ts @@ -1,6 +1,7 @@ export default class UploadImageButton extends Button { constructor(); loading: boolean; + view(vnode: any): JSX.Element; /** * Prompt the user to upload an image. */ diff --git a/framework/core/js/dist-typings/common/components/AlertManager.d.ts b/framework/core/js/dist-typings/common/components/AlertManager.d.ts index d64d60d292..7850bdb29c 100644 --- a/framework/core/js/dist-typings/common/components/AlertManager.d.ts +++ b/framework/core/js/dist-typings/common/components/AlertManager.d.ts @@ -4,5 +4,8 @@ */ export default class AlertManager extends Component { constructor(); + oninit(vnode: any): void; + state: any; + view(): JSX.Element; } import Component from "../Component"; diff --git a/framework/core/js/dist-typings/common/components/Badge.d.ts b/framework/core/js/dist-typings/common/components/Badge.d.ts index 2341c7cf1f..9ef44e2e53 100644 --- a/framework/core/js/dist-typings/common/components/Badge.d.ts +++ b/framework/core/js/dist-typings/common/components/Badge.d.ts @@ -13,5 +13,6 @@ */ export default class Badge extends Component { constructor(); + view(): JSX.Element; } import Component from "../Component"; diff --git a/framework/core/js/dist-typings/common/components/Checkbox.d.ts b/framework/core/js/dist-typings/common/components/Checkbox.d.ts index 5683d3df6a..b7c53c9606 100644 --- a/framework/core/js/dist-typings/common/components/Checkbox.d.ts +++ b/framework/core/js/dist-typings/common/components/Checkbox.d.ts @@ -12,6 +12,7 @@ */ export default class Checkbox extends Component { constructor(); + view(vnode: any): JSX.Element; /** * Get the template for the checkbox's display (tick/cross icon). * diff --git a/framework/core/js/dist-typings/common/components/ConfirmDocumentUnload.d.ts b/framework/core/js/dist-typings/common/components/ConfirmDocumentUnload.d.ts index ccbad6dcdb..b424336f3f 100644 --- a/framework/core/js/dist-typings/common/components/ConfirmDocumentUnload.d.ts +++ b/framework/core/js/dist-typings/common/components/ConfirmDocumentUnload.d.ts @@ -17,6 +17,9 @@ export default class ConfirmDocumentUnload extends Component { constructor(); handler(): any; + oncreate(vnode: any): void; boundHandler: (() => any) | undefined; + onremove(vnode: any): void; + view(vnode: any): any; } import Component from "../Component"; diff --git a/framework/core/js/dist-typings/common/components/Dropdown.d.ts b/framework/core/js/dist-typings/common/components/Dropdown.d.ts index 11b526388b..31c49b276f 100644 --- a/framework/core/js/dist-typings/common/components/Dropdown.d.ts +++ b/framework/core/js/dist-typings/common/components/Dropdown.d.ts @@ -18,7 +18,10 @@ export default class Dropdown extends Component { static initAttrs(attrs: any): void; constructor(); + oninit(vnode: any): void; showing: boolean | undefined; + view(vnode: any): JSX.Element; + oncreate(vnode: any): void; /** * Get the template for the button. * diff --git a/framework/core/js/dist-typings/common/components/FieldSet.d.ts b/framework/core/js/dist-typings/common/components/FieldSet.d.ts index 3f6098b5e5..f2c06c2eeb 100644 --- a/framework/core/js/dist-typings/common/components/FieldSet.d.ts +++ b/framework/core/js/dist-typings/common/components/FieldSet.d.ts @@ -9,5 +9,6 @@ */ export default class FieldSet extends Component { constructor(); + view(vnode: any): JSX.Element; } import Component from "../Component"; diff --git a/framework/core/js/dist-typings/common/components/Link.d.ts b/framework/core/js/dist-typings/common/components/Link.d.ts index 609d91f4f5..c8d991bb3d 100644 --- a/framework/core/js/dist-typings/common/components/Link.d.ts +++ b/framework/core/js/dist-typings/common/components/Link.d.ts @@ -8,5 +8,6 @@ */ export default class Link extends Component { constructor(); + view(vnode: any): JSX.Element; } import Component from "../Component"; diff --git a/framework/core/js/dist-typings/common/components/LinkButton.d.ts b/framework/core/js/dist-typings/common/components/LinkButton.d.ts index 31b33a28ff..384a44a2c6 100644 --- a/framework/core/js/dist-typings/common/components/LinkButton.d.ts +++ b/framework/core/js/dist-typings/common/components/LinkButton.d.ts @@ -21,5 +21,6 @@ export default class LinkButton extends Button */ static isActive(attrs: object): boolean; constructor(); + view(vnode: any): JSX.Element; } import Button from "./Button"; diff --git a/framework/core/js/dist-typings/common/components/Navigation.d.ts b/framework/core/js/dist-typings/common/components/Navigation.d.ts index 2df2a274c9..9e25a95e58 100644 --- a/framework/core/js/dist-typings/common/components/Navigation.d.ts +++ b/framework/core/js/dist-typings/common/components/Navigation.d.ts @@ -15,6 +15,7 @@ */ export default class Navigation extends Component { constructor(); + view(): JSX.Element; /** * Get the back button. * diff --git a/framework/core/js/dist-typings/common/components/Placeholder.d.ts b/framework/core/js/dist-typings/common/components/Placeholder.d.ts index 61037cb5a1..413c53595b 100644 --- a/framework/core/js/dist-typings/common/components/Placeholder.d.ts +++ b/framework/core/js/dist-typings/common/components/Placeholder.d.ts @@ -8,5 +8,6 @@ */ export default class Placeholder extends Component { constructor(); + view(): JSX.Element; } import Component from "../Component"; diff --git a/framework/core/js/dist-typings/common/components/Select.d.ts b/framework/core/js/dist-typings/common/components/Select.d.ts index ee2bec3ae8..79c77ec862 100644 --- a/framework/core/js/dist-typings/common/components/Select.d.ts +++ b/framework/core/js/dist-typings/common/components/Select.d.ts @@ -12,5 +12,6 @@ */ export default class Select extends Component { constructor(); + view(): JSX.Element; } import Component from "../Component"; diff --git a/framework/core/js/dist-typings/common/components/SelectDropdown.d.ts b/framework/core/js/dist-typings/common/components/SelectDropdown.d.ts index d1a24456aa..d01490fd3e 100644 --- a/framework/core/js/dist-typings/common/components/SelectDropdown.d.ts +++ b/framework/core/js/dist-typings/common/components/SelectDropdown.d.ts @@ -9,5 +9,6 @@ * - `defaultLabel` */ export default class SelectDropdown extends Dropdown { + getButtonContent(children: any): JSX.Element[]; } import Dropdown from "./Dropdown"; diff --git a/framework/core/js/dist-typings/common/components/Separator.d.ts b/framework/core/js/dist-typings/common/components/Separator.d.ts index 9b0055169b..6b21df5a0f 100644 --- a/framework/core/js/dist-typings/common/components/Separator.d.ts +++ b/framework/core/js/dist-typings/common/components/Separator.d.ts @@ -4,6 +4,7 @@ export default Separator; */ declare class Separator extends Component { constructor(); + view(): JSX.Element; } declare namespace Separator { const isListItem: boolean; diff --git a/framework/core/js/dist-typings/common/components/SplitDropdown.d.ts b/framework/core/js/dist-typings/common/components/SplitDropdown.d.ts index ff7ad63d13..873f760a96 100644 --- a/framework/core/js/dist-typings/common/components/SplitDropdown.d.ts +++ b/framework/core/js/dist-typings/common/components/SplitDropdown.d.ts @@ -3,6 +3,7 @@ * is displayed as its own button prior to the toggle button. */ export default class SplitDropdown extends Dropdown { + getButton(children: any): JSX.Element[]; /** * Get the first child. If the first child is an array, the first item in that * array will be returned. diff --git a/framework/core/js/dist-typings/common/components/TextEditor.d.ts b/framework/core/js/dist-typings/common/components/TextEditor.d.ts index 3e328326f7..547afc11b0 100644 --- a/framework/core/js/dist-typings/common/components/TextEditor.d.ts +++ b/framework/core/js/dist-typings/common/components/TextEditor.d.ts @@ -13,6 +13,7 @@ */ export default class TextEditor extends Component { constructor(); + oninit(vnode: any): void; /** * The value of the editor. * @@ -23,6 +24,9 @@ export default class TextEditor extends Component { static initAttrs(attrs: any): void; constructor(); + view(vnode: any): JSX.Element; } import Button from "./Button"; diff --git a/framework/core/js/dist-typings/common/helpers/avatar.d.ts b/framework/core/js/dist-typings/common/helpers/avatar.d.ts index 06fd2293d6..9960e83890 100644 --- a/framework/core/js/dist-typings/common/helpers/avatar.d.ts +++ b/framework/core/js/dist-typings/common/helpers/avatar.d.ts @@ -9,4 +9,4 @@ export interface AvatarAttrs extends ComponentAttrs { * @param user * @param attrs Attributes to apply to the avatar element */ -export default function avatar(user: User, attrs?: ComponentAttrs): Mithril.Vnode; +export default function avatar(user: User | null, attrs?: ComponentAttrs): Mithril.Vnode; diff --git a/framework/core/js/dist-typings/common/models/Notification.d.ts b/framework/core/js/dist-typings/common/models/Notification.d.ts index e912b3287f..98e3bb25f7 100644 --- a/framework/core/js/dist-typings/common/models/Notification.d.ts +++ b/framework/core/js/dist-typings/common/models/Notification.d.ts @@ -2,7 +2,7 @@ import Model from '../Model'; import User from './User'; export default class Notification extends Model { contentType(): string; - content(): string; + content(): T; createdAt(): Date; isRead(): boolean; user(): false | User; diff --git a/framework/core/js/dist-typings/forum/ForumApplication.d.ts b/framework/core/js/dist-typings/forum/ForumApplication.d.ts index 929fbe12c0..2aaf1fca98 100644 --- a/framework/core/js/dist-typings/forum/ForumApplication.d.ts +++ b/framework/core/js/dist-typings/forum/ForumApplication.d.ts @@ -9,15 +9,25 @@ import ComposerState from './states/ComposerState'; import type Notification from './components/Notification'; import type Post from './components/Post'; import Discussion from '../common/models/Discussion'; +import NotificationModel from '../common/models/Notification'; +import PostModel from '../common/models/Post'; export default class ForumApplication extends Application { /** * A map of notification types to their components. */ - notificationComponents: Record; + notificationComponents: Record>>; /** * A map of post types to their components. */ - postComponents: Record; + postComponents: Record>>; /** * An object which controls the state of the page's side pane. */ diff --git a/framework/core/js/dist-typings/forum/components/AffixedSidebar.d.ts b/framework/core/js/dist-typings/forum/components/AffixedSidebar.d.ts index beb41c6053..8bd7247d42 100644 --- a/framework/core/js/dist-typings/forum/components/AffixedSidebar.d.ts +++ b/framework/core/js/dist-typings/forum/components/AffixedSidebar.d.ts @@ -11,7 +11,10 @@ */ export default class AffixedSidebar extends Component { constructor(); + view(vnode: any): any; + oncreate(vnode: any): void; boundOnresize: (() => void) | undefined; + onremove(vnode: any): void; onresize(): void; bottom: number | undefined; } diff --git a/framework/core/js/dist-typings/forum/components/AvatarEditor.d.ts b/framework/core/js/dist-typings/forum/components/AvatarEditor.d.ts index 78246ba5f5..585046d8c9 100644 --- a/framework/core/js/dist-typings/forum/components/AvatarEditor.d.ts +++ b/framework/core/js/dist-typings/forum/components/AvatarEditor.d.ts @@ -9,6 +9,7 @@ */ export default class AvatarEditor extends Component { constructor(); + oninit(vnode: any): void; /** * Whether or not an avatar upload is in progress. * @@ -21,6 +22,7 @@ export default class AvatarEditor extends Component /** * The `ChangeEmailModal` component shows a modal dialog which allows the user * to change their email address. */ export default class ChangeEmailModal extends Modal { constructor(); + oninit(vnode: any): void; /** * Whether or not the email has been changed successfully. * @@ -22,5 +24,9 @@ export default class ChangeEmailModal extends Modal /** * The `ChangePasswordModal` component shows a modal dialog which allows the * user to send themself a password reset email. */ export default class ChangePasswordModal extends Modal { constructor(); + title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + content(): JSX.Element; + onsubmit(e: any): void; } import Modal from "../../common/components/Modal"; diff --git a/framework/core/js/dist-typings/forum/components/CommentPost.d.ts b/framework/core/js/dist-typings/forum/components/CommentPost.d.ts index 8d6b92b28d..6671c3eb05 100644 --- a/framework/core/js/dist-typings/forum/components/CommentPost.d.ts +++ b/framework/core/js/dist-typings/forum/components/CommentPost.d.ts @@ -7,7 +7,9 @@ * * - `post` */ -export default class CommentPost extends Post { +export default class CommentPost extends Post { + constructor(); + oninit(vnode: any): void; /** * If the post has been hidden, then this flag determines whether or not its * content has been expanded. @@ -22,8 +24,11 @@ export default class CommentPost extends Post { * @type {Boolean} */ cardVisible: boolean | undefined; + content(): any; refreshContent(): void; contentHtml: any; + oncreate(vnode: any): void; + onupdate(vnode: any): void; isEditing(): boolean; /** * Toggle the visibility of a hidden post's content. diff --git a/framework/core/js/dist-typings/forum/components/Composer.d.ts b/framework/core/js/dist-typings/forum/components/Composer.d.ts index b667971811..f36d7aafb7 100644 --- a/framework/core/js/dist-typings/forum/components/Composer.d.ts +++ b/framework/core/js/dist-typings/forum/components/Composer.d.ts @@ -5,6 +5,13 @@ */ export default class Composer extends Component { constructor(); + oninit(vnode: any): void; + /** + * The composer's "state". + * + * @type {ComposerState} + */ + state: ComposerState | undefined; /** * Whether or not the composer currently has focus. * @@ -12,7 +19,11 @@ export default class Composer extends Component { constructor(); + oninit(vnode: any): void; composer: any; /** * Whether or not the component is loading. @@ -24,6 +25,7 @@ export default class ComposerBody extends Component { static initAttrs(attrs: any): void; constructor(); + view(): JSX.Element; + oncreate(vnode: any): void; updateInterval: NodeJS.Timer | undefined; + onremove(vnode: any): void; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/DiscussionComposer.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionComposer.d.ts index 95a5818dc6..15b796c355 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionComposer.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionComposer.d.ts @@ -24,6 +24,7 @@ export default class DiscussionComposer extends ComposerBody { * @param {KeyboardEvent} e */ onkeydown(e: KeyboardEvent): void; + hasChanges(): any; /** * Get the data to submit to the server when the discussion is saved. * diff --git a/framework/core/js/dist-typings/forum/components/DiscussionHero.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionHero.d.ts index c1d3769901..c4394618ee 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionHero.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionHero.d.ts @@ -7,6 +7,7 @@ */ export default class DiscussionHero extends Component { constructor(); + view(): JSX.Element; /** * Build an item list for the contents of the discussion hero. * diff --git a/framework/core/js/dist-typings/forum/components/DiscussionList.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionList.d.ts index 62670a0b1e..a726e2bc91 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionList.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionList.d.ts @@ -7,5 +7,6 @@ */ export default class DiscussionList extends Component { constructor(); + view(): JSX.Element; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts index 07feaf96bf..89d2417c3b 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts @@ -9,6 +9,7 @@ */ export default class DiscussionListItem extends Component { constructor(); + oninit(vnode: any): void; /** * Set up a subtree retainer so that the discussion will not be redrawn * unless new data comes in. @@ -19,7 +20,10 @@ export default class DiscussionListItem extends Component { constructor(); + view(): JSX.Element | undefined; + oncreate(vnode: any): void; + onremove(vnode: any): void; /** * Are we on a device that's larger than we consider "mobile"? * diff --git a/framework/core/js/dist-typings/forum/components/DiscussionRenamedNotification.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionRenamedNotification.d.ts index 4bcd16d29c..1d095c0843 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionRenamedNotification.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionRenamedNotification.d.ts @@ -1,11 +1,12 @@ +/// +import Notification from './Notification'; /** * The `DiscussionRenamedNotification` component displays a notification which * indicates that a discussion has had its title changed. - * - * ### Attrs - * - * - All of the attrs for Notification */ export default class DiscussionRenamedNotification extends Notification { + icon(): string; + href(): string; + content(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + excerpt(): string; } -import Notification from "./Notification"; diff --git a/framework/core/js/dist-typings/forum/components/DiscussionRenamedPost.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionRenamedPost.d.ts index a3fd8ee31c..3e64b94083 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionRenamedPost.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionRenamedPost.d.ts @@ -7,5 +7,10 @@ * - All of the attrs for EventPost */ export default class DiscussionRenamedPost extends EventPost { + description(data: any): JSX.Element; + descriptionData(): { + old: string; + new: JSX.Element; + }; } import EventPost from "./EventPost"; diff --git a/framework/core/js/dist-typings/forum/components/DiscussionsUserPage.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionsUserPage.d.ts index 97b13ae3d7..9f95ff1b70 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionsUserPage.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionsUserPage.d.ts @@ -3,5 +3,14 @@ * page. */ export default class DiscussionsUserPage extends UserPage { + show(user: any): void; + state: DiscussionListState<{ + filter: { + author: any; + }; + sort: string; + }>; + content(): JSX.Element; } import UserPage from "./UserPage"; +import DiscussionListState from "../states/DiscussionListState"; diff --git a/framework/core/js/dist-typings/forum/components/EventPost.d.ts b/framework/core/js/dist-typings/forum/components/EventPost.d.ts index 2c4f89061d..9149e2c03c 100644 --- a/framework/core/js/dist-typings/forum/components/EventPost.d.ts +++ b/framework/core/js/dist-typings/forum/components/EventPost.d.ts @@ -9,7 +9,9 @@ * * @abstract */ -export default class EventPost extends Post { +export default class EventPost extends Post { + constructor(); + content(): any; /** * Get the name of the event icon. * diff --git a/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts b/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts index ee6bc71015..303171287c 100644 --- a/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts +++ b/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts @@ -4,6 +4,7 @@ */ export default class HeaderPrimary extends Component { constructor(); + view(): JSX.Element; /** * Build an item list for the controls. * diff --git a/framework/core/js/dist-typings/forum/components/HeaderSecondary.d.ts b/framework/core/js/dist-typings/forum/components/HeaderSecondary.d.ts index 2092c4b369..cc485f023d 100644 --- a/framework/core/js/dist-typings/forum/components/HeaderSecondary.d.ts +++ b/framework/core/js/dist-typings/forum/components/HeaderSecondary.d.ts @@ -5,6 +5,7 @@ */ export default class HeaderSecondary extends Component { constructor(); + view(): JSX.Element; /** * Build an item list for the controls. * diff --git a/framework/core/js/dist-typings/forum/components/IndexPage.d.ts b/framework/core/js/dist-typings/forum/components/IndexPage.d.ts index e676395409..5bec4bb9f2 100644 --- a/framework/core/js/dist-typings/forum/components/IndexPage.d.ts +++ b/framework/core/js/dist-typings/forum/components/IndexPage.d.ts @@ -5,8 +5,13 @@ export default class IndexPage extends Page { static providesInitialSearch: boolean; constructor(); + oninit(vnode: any): void; lastDiscussion: any; + view(): JSX.Element; setTitle(): void; + oncreate(vnode: any): void; + onbeforeremove(vnode: any): void; + onremove(vnode: any): void; /** * Get the component to display as the hero. * diff --git a/framework/core/js/dist-typings/forum/components/LoadingPost.d.ts b/framework/core/js/dist-typings/forum/components/LoadingPost.d.ts index ea0619a109..ffadf4cb0e 100644 --- a/framework/core/js/dist-typings/forum/components/LoadingPost.d.ts +++ b/framework/core/js/dist-typings/forum/components/LoadingPost.d.ts @@ -4,5 +4,6 @@ */ export default class LoadingPost extends Component { constructor(); + view(): JSX.Element; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/LogInButtons.d.ts b/framework/core/js/dist-typings/forum/components/LogInButtons.d.ts index 37cfcd205e..1a0d2594d0 100644 --- a/framework/core/js/dist-typings/forum/components/LogInButtons.d.ts +++ b/framework/core/js/dist-typings/forum/components/LogInButtons.d.ts @@ -3,6 +3,7 @@ */ export default class LogInButtons extends Component { constructor(); + view(): JSX.Element; /** * Build a list of LogInButton components. * diff --git a/framework/core/js/dist-typings/forum/components/Notification.d.ts b/framework/core/js/dist-typings/forum/components/Notification.d.ts index 125ee1a620..99ec74df19 100644 --- a/framework/core/js/dist-typings/forum/components/Notification.d.ts +++ b/framework/core/js/dist-typings/forum/components/Notification.d.ts @@ -1,46 +1,33 @@ +import NotificationModel from '../../common/models/Notification'; +import Component, { ComponentAttrs } from '../../common/Component'; +import Mithril from 'mithril'; +export interface INotificationAttrs extends ComponentAttrs { + notification: NotificationModel; +} /** * The `Notification` component abstract displays a single notification. * Subclasses should implement the `icon`, `href`, and `content` methods. - * - * ### Attrs - * - * - `notification` - * - * @abstract */ -export default class Notification extends Component { - constructor(); +export default abstract class Notification extends Component { + view(vnode: Mithril.Vnode): JSX.Element; /** * Get the name of the icon that should be displayed in the notification. - * - * @return {string} - * @abstract */ - icon(): string; + abstract icon(): string; /** * Get the URL that the notification should link to. - * - * @return {string} - * @abstract */ - href(): string; + abstract href(): string; /** * Get the content of the notification. - * - * @return {import('mithril').Children} - * @abstract */ - content(): import('mithril').Children; + abstract content(): Mithril.Children; /** * Get the excerpt of the notification. - * - * @return {import('mithril').Children} - * @abstract */ - excerpt(): import('mithril').Children; + abstract excerpt(): Mithril.Children; /** * Mark the notification as read. */ markAsRead(): void; } -import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/NotificationGrid.d.ts b/framework/core/js/dist-typings/forum/components/NotificationGrid.d.ts index 145dee51cf..f1006eff6f 100644 --- a/framework/core/js/dist-typings/forum/components/NotificationGrid.d.ts +++ b/framework/core/js/dist-typings/forum/components/NotificationGrid.d.ts @@ -8,6 +8,7 @@ */ export default class NotificationGrid extends Component { constructor(); + oninit(vnode: any): void; /** * Information about the available notification methods. * @@ -34,6 +35,8 @@ export default class NotificationGrid extends Component { constructor(); + view(): JSX.Element; controlItems(): ItemList; content(state: any): any; + oncreate(vnode: any): void; $notifications: JQuery | undefined; $scrollParent: JQuery | JQuery | undefined; boundScrollHandler: (() => void) | undefined; + onremove(vnode: any): void; scrollHandler(): void; /** * If the NotificationList component isn't in a panel (e.g. on NotificationPage when mobile), diff --git a/framework/core/js/dist-typings/forum/components/NotificationsDropdown.d.ts b/framework/core/js/dist-typings/forum/components/NotificationsDropdown.d.ts index c57686b2f1..d677898310 100644 --- a/framework/core/js/dist-typings/forum/components/NotificationsDropdown.d.ts +++ b/framework/core/js/dist-typings/forum/components/NotificationsDropdown.d.ts @@ -1,4 +1,7 @@ export default class NotificationsDropdown extends Dropdown { + getButton(): import("mithril").Children; + getButtonContent(): (false | JSX.Element)[]; + getMenu(): JSX.Element; onclick(): void; goToRoute(): void; getUnreadCount(): number | undefined; diff --git a/framework/core/js/dist-typings/forum/components/NotificationsPage.d.ts b/framework/core/js/dist-typings/forum/components/NotificationsPage.d.ts index 6613404e1d..6bf094f7fe 100644 --- a/framework/core/js/dist-typings/forum/components/NotificationsPage.d.ts +++ b/framework/core/js/dist-typings/forum/components/NotificationsPage.d.ts @@ -4,5 +4,7 @@ */ export default class NotificationsPage extends Page { constructor(); + oninit(vnode: any): void; + view(): JSX.Element; } import Page from "../../common/components/Page"; diff --git a/framework/core/js/dist-typings/forum/components/Post.d.ts b/framework/core/js/dist-typings/forum/components/Post.d.ts index 1c7cb95e69..6244988a0c 100644 --- a/framework/core/js/dist-typings/forum/components/Post.d.ts +++ b/framework/core/js/dist-typings/forum/components/Post.d.ts @@ -1,59 +1,48 @@ +import Component, { ComponentAttrs } from '../../common/Component'; +import SubtreeRetainer from '../../common/utils/SubtreeRetainer'; +import ItemList from '../../common/utils/ItemList'; +import PostModel from '../../common/models/Post'; +import Mithril from 'mithril'; +export interface IPostAttrs extends ComponentAttrs { + post: PostModel; +} /** * The `Post` component displays a single post. The basic post template just * includes a controls dropdown; subclasses must implement `content` and `attrs` * methods. - * - * ### Attrs - * - * - `post` - * - * @abstract */ -export default class Post extends Component { - constructor(); +export default abstract class Post extends Component { /** * May be set by subclasses. */ - loading: boolean | undefined; + loading: boolean; /** - * Set up a subtree retainer so that the post will not be redrawn + * Ensures that the post will not be redrawn * unless new data comes in. - * - * @type {SubtreeRetainer} */ - subtree: SubtreeRetainer | undefined; + subtree: SubtreeRetainer; + oninit(vnode: Mithril.Vnode): void; + view(vnode: Mithril.Vnode): JSX.Element; + onbeforeupdate(vnode: Mithril.VnodeDOM): boolean; + onupdate(vnode: Mithril.VnodeDOM): void; /** * Get attributes for the post element. - * - * @return {Record} */ elementAttrs(): Record; /** * Get the post's content. - * - * @return {import('mithril').Children} */ - content(): import('mithril').Children; + content(): Mithril.Children; /** * Get the post's classes. - * - * @param {string} existing - * @returns {string[]} */ - classes(existing: string): string[]; + classes(existing?: string): string[]; /** * Build an item list for the post's actions. - * - * @return {ItemList} */ - actionItems(): ItemList; + actionItems(): ItemList; /** * Build an item list for the post's footer. - * - * @return {ItemList} */ - footerItems(): ItemList; + footerItems(): ItemList; } -import Component from "../../common/Component"; -import SubtreeRetainer from "../../common/utils/SubtreeRetainer"; -import ItemList from "../../common/utils/ItemList"; diff --git a/framework/core/js/dist-typings/forum/components/PostEdited.d.ts b/framework/core/js/dist-typings/forum/components/PostEdited.d.ts index d177dd9767..10d8bd8906 100644 --- a/framework/core/js/dist-typings/forum/components/PostEdited.d.ts +++ b/framework/core/js/dist-typings/forum/components/PostEdited.d.ts @@ -8,5 +8,8 @@ */ export default class PostEdited extends Component { constructor(); + oninit(vnode: any): void; + view(): JSX.Element; + oncreate(vnode: any): void; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/PostMeta.d.ts b/framework/core/js/dist-typings/forum/components/PostMeta.d.ts index 8151230510..3667411f94 100644 --- a/framework/core/js/dist-typings/forum/components/PostMeta.d.ts +++ b/framework/core/js/dist-typings/forum/components/PostMeta.d.ts @@ -9,6 +9,7 @@ */ export default class PostMeta extends Component { constructor(); + view(): JSX.Element; /** * Get the permalink for the given post. * diff --git a/framework/core/js/dist-typings/forum/components/PostPreview.d.ts b/framework/core/js/dist-typings/forum/components/PostPreview.d.ts index 453d9e9b49..a1389e6db5 100644 --- a/framework/core/js/dist-typings/forum/components/PostPreview.d.ts +++ b/framework/core/js/dist-typings/forum/components/PostPreview.d.ts @@ -8,5 +8,6 @@ */ export default class PostPreview extends Component { constructor(); + view(): JSX.Element; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/PostStream.d.ts b/framework/core/js/dist-typings/forum/components/PostStream.d.ts index b9ad86e670..8606e9ab78 100644 --- a/framework/core/js/dist-typings/forum/components/PostStream.d.ts +++ b/framework/core/js/dist-typings/forum/components/PostStream.d.ts @@ -11,9 +11,14 @@ */ export default class PostStream extends Component { constructor(); + oninit(vnode: any): void; discussion: any; stream: any; scrollListener: ScrollListener | undefined; + view(): JSX.Element; + onupdate(vnode: any): void; + oncreate(vnode: any): void; + onremove(vnode: any): void; /** * Start scrolling, if appropriate, to a newly-targeted post. */ diff --git a/framework/core/js/dist-typings/forum/components/PostStreamScrubber.d.ts b/framework/core/js/dist-typings/forum/components/PostStreamScrubber.d.ts index b56c71b341..50bb37f3b6 100644 --- a/framework/core/js/dist-typings/forum/components/PostStreamScrubber.d.ts +++ b/framework/core/js/dist-typings/forum/components/PostStreamScrubber.d.ts @@ -9,12 +9,17 @@ */ export default class PostStreamScrubber extends Component { constructor(); + oninit(vnode: any): void; stream: any; handlers: {} | undefined; scrollListener: ScrollListener | undefined; + view(): JSX.Element; + onupdate(vnode: any): void; + oncreate(vnode: any): void; dragging: boolean | undefined; mouseStart: any; indexStart: any; + onremove(vnode: any): void; /** * Update the scrollbar's position to reflect the current values of the * index/visible properties. diff --git a/framework/core/js/dist-typings/forum/components/PostUser.d.ts b/framework/core/js/dist-typings/forum/components/PostUser.d.ts index 8e83cc3444..f2601977fd 100644 --- a/framework/core/js/dist-typings/forum/components/PostUser.d.ts +++ b/framework/core/js/dist-typings/forum/components/PostUser.d.ts @@ -7,6 +7,8 @@ */ export default class PostUser extends Component { constructor(); + view(): JSX.Element; + oncreate(vnode: any): void; /** * Show the user card. */ diff --git a/framework/core/js/dist-typings/forum/components/PostsUserPage.d.ts b/framework/core/js/dist-typings/forum/components/PostsUserPage.d.ts index a591e4855d..9f86094154 100644 --- a/framework/core/js/dist-typings/forum/components/PostsUserPage.d.ts +++ b/framework/core/js/dist-typings/forum/components/PostsUserPage.d.ts @@ -27,6 +27,12 @@ export default class PostsUserPage extends UserPage { * @type {number} */ loadLimit: number | undefined; + content(): JSX.Element; + /** + * Initialize the component with a user, and trigger the loading of their + * activity feed. + */ + show(user: any): void; /** * Clear and reload the user's activity feed. */ diff --git a/framework/core/js/dist-typings/forum/components/RenameDiscussionModal.d.ts b/framework/core/js/dist-typings/forum/components/RenameDiscussionModal.d.ts index 6d5ae9f542..fee764d4a2 100644 --- a/framework/core/js/dist-typings/forum/components/RenameDiscussionModal.d.ts +++ b/framework/core/js/dist-typings/forum/components/RenameDiscussionModal.d.ts @@ -1,11 +1,16 @@ +/// /** * The 'RenameDiscussionModal' displays a modal dialog with an input to rename a discussion */ export default class RenameDiscussionModal extends Modal { constructor(); + oninit(vnode: any): void; discussion: any; currentTitle: any; newTitle: Stream | undefined; + title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + content(): JSX.Element; + onsubmit(e: any): any; } import Modal from "../../common/components/Modal"; import Stream from "../../common/utils/Stream"; diff --git a/framework/core/js/dist-typings/forum/components/ReplyPlaceholder.d.ts b/framework/core/js/dist-typings/forum/components/ReplyPlaceholder.d.ts index 4ac67f3a7b..3f85d6f560 100644 --- a/framework/core/js/dist-typings/forum/components/ReplyPlaceholder.d.ts +++ b/framework/core/js/dist-typings/forum/components/ReplyPlaceholder.d.ts @@ -8,6 +8,7 @@ */ export default class ReplyPlaceholder extends Component { constructor(); + view(): JSX.Element; anchorPreview(preview: any): void; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/SessionDropdown.d.ts b/framework/core/js/dist-typings/forum/components/SessionDropdown.d.ts index 24149fb2a8..5d6b39cad8 100644 --- a/framework/core/js/dist-typings/forum/components/SessionDropdown.d.ts +++ b/framework/core/js/dist-typings/forum/components/SessionDropdown.d.ts @@ -3,6 +3,7 @@ * avatar/name, with a dropdown of session controls. */ export default class SessionDropdown extends Dropdown { + getButtonContent(): (string | JSX.Element)[]; /** * Build an item list for the contents of the dropdown menu. * diff --git a/framework/core/js/dist-typings/forum/components/SettingsPage.d.ts b/framework/core/js/dist-typings/forum/components/SettingsPage.d.ts index 087658b09c..de55fccead 100644 --- a/framework/core/js/dist-typings/forum/components/SettingsPage.d.ts +++ b/framework/core/js/dist-typings/forum/components/SettingsPage.d.ts @@ -3,6 +3,7 @@ * the context of their user profile. */ export default class SettingsPage extends UserPage { + content(): JSX.Element; /** * Build an item list for the user's settings controls. * diff --git a/framework/core/js/dist-typings/forum/components/TerminalPost.d.ts b/framework/core/js/dist-typings/forum/components/TerminalPost.d.ts index a0cbc3cce4..3029171b27 100644 --- a/framework/core/js/dist-typings/forum/components/TerminalPost.d.ts +++ b/framework/core/js/dist-typings/forum/components/TerminalPost.d.ts @@ -8,5 +8,6 @@ */ export default class TerminalPost extends Component { constructor(); + view(): JSX.Element; } import Component from "../../common/Component"; diff --git a/framework/core/js/dist-typings/forum/components/UserCard.d.ts b/framework/core/js/dist-typings/forum/components/UserCard.d.ts index 2281af09d9..dcfaf2298b 100644 --- a/framework/core/js/dist-typings/forum/components/UserCard.d.ts +++ b/framework/core/js/dist-typings/forum/components/UserCard.d.ts @@ -12,6 +12,7 @@ */ export default class UserCard extends Component { constructor(); + view(): JSX.Element; /** * Build an item list of tidbits of info to show on this user's profile. * diff --git a/framework/core/js/dist-typings/forum/components/UserPage.d.ts b/framework/core/js/dist-typings/forum/components/UserPage.d.ts index bc552a491a..98a7d82ae9 100644 --- a/framework/core/js/dist-typings/forum/components/UserPage.d.ts +++ b/framework/core/js/dist-typings/forum/components/UserPage.d.ts @@ -7,12 +7,19 @@ */ export default class UserPage extends Page { constructor(); + oninit(vnode: any): void; /** * The user this page is for. * * @type {User} */ user: any; + /** + * Base view template for the user page. + * + * @return {import('mithril').Children} + */ + view(): import('mithril').Children; /** * Get the content to display in the user page. * From a593790dd0d23e3edb49dc94568702f47b0df035 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 12 Mar 2022 02:42:28 -0500 Subject: [PATCH 14/41] chore(pusher): format --- extensions/pusher/js/src/forum/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/pusher/js/src/forum/index.ts b/extensions/pusher/js/src/forum/index.ts index ba9524c6ae..b81102505d 100644 --- a/extensions/pusher/js/src/forum/index.ts +++ b/extensions/pusher/js/src/forum/index.ts @@ -83,7 +83,7 @@ app.initializers.add('flarum-pusher', () => { if (app.pushedUpdates) { const count = app.pushedUpdates.length; - if (count && (typeof vdom === 'object') && vdom && 'children' in vdom && vdom.children instanceof Array) { + if (count && typeof vdom === 'object' && vdom && 'children' in vdom && vdom.children instanceof Array) { vdom.children.unshift( Button.component( { From 7c6c16c20dd7b1d75e25be85b6840e105f5f7c92 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 13 Mar 2022 03:27:49 -0400 Subject: [PATCH 15/41] fix: anchorScroll should accept string selectors --- framework/core/js/src/common/utils/anchorScroll.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/js/src/common/utils/anchorScroll.js b/framework/core/js/src/common/utils/anchorScroll.js index 0bd0b8756a..8a18ea48df 100644 --- a/framework/core/js/src/common/utils/anchorScroll.js +++ b/framework/core/js/src/common/utils/anchorScroll.js @@ -8,7 +8,7 @@ * position can be anchor to an element that is in or below the viewport, so * the content in the viewport will stay the same. * - * @param {HTMLElement | SVGElement | Element} element The element to anchor the scroll position to. + * @param {string | HTMLElement | SVGElement | Element} element The element to anchor the scroll position to. * @param {() => void} callback The callback to run that will change page content. */ export default function anchorScroll(element, callback) { From b5e9e1b70fedbe501ae9186cf8719dd77d8ff012 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 13 Mar 2022 03:28:22 -0400 Subject: [PATCH 16/41] fix: more accurately represent ApiQueryParamsPlural --- framework/core/js/src/common/Store.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/core/js/src/common/Store.ts b/framework/core/js/src/common/Store.ts index 107efde2c8..77b8c81116 100644 --- a/framework/core/js/src/common/Store.ts +++ b/framework/core/js/src/common/Store.ts @@ -17,11 +17,13 @@ export interface ApiQueryParamsSingle { export interface ApiQueryParamsPlural { fields?: string[]; include?: string; - filter?: { - q: string; - [key: string]: string; - }; + filter?: + | { + q: string; + } + | Record; page?: { + near?: number; offset?: number; number?: number; limit?: number; From 268fc719980f6b5b6377386a39718407b2ffae80 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 13 Mar 2022 03:28:36 -0400 Subject: [PATCH 17/41] fix: convert PostStreamState to TypeScript --- .../src/forum/components/DiscussionPage.tsx | 12 +- ...{PostStreamState.js => PostStreamState.ts} | 214 ++++++++---------- 2 files changed, 99 insertions(+), 127 deletions(-) rename framework/core/js/src/forum/states/{PostStreamState.js => PostStreamState.ts} (70%) diff --git a/framework/core/js/src/forum/components/DiscussionPage.tsx b/framework/core/js/src/forum/components/DiscussionPage.tsx index aaf07a4776..fd802ced92 100644 --- a/framework/core/js/src/forum/components/DiscussionPage.tsx +++ b/framework/core/js/src/forum/components/DiscussionPage.tsx @@ -198,7 +198,7 @@ export default class DiscussionPage app.store.getById('posts', record.id)) - .sort((a?: Post, b?: Post) => (a?.number() ?? 0) - (b?.number() ?? 0)) + // We can make this assertion because posts should be in the store, + // since they were in the discussion's payload. + .map((record) => app.store.getById('posts', record.id) as Post) + .sort((a: Post, b: Post) => a.number() - b.number()) .slice(0, 20); } @@ -220,7 +222,9 @@ export default class DiscussionPage { + const rawNearParam = m.route.param('near'); + const nearParam = rawNearParam === 'reply' ? 'reply' : parseInt(rawNearParam); + this.stream.goToNumber(nearParam || (includedPosts[0]?.number() ?? 0), true).then(() => { this.discussion = discussion; app.current.set('discussion', discussion); diff --git a/framework/core/js/src/forum/states/PostStreamState.js b/framework/core/js/src/forum/states/PostStreamState.ts similarity index 70% rename from framework/core/js/src/forum/states/PostStreamState.js rename to framework/core/js/src/forum/states/PostStreamState.ts index 1a2272a8be..0eb83f100c 100644 --- a/framework/core/js/src/forum/states/PostStreamState.js +++ b/framework/core/js/src/forum/states/PostStreamState.ts @@ -1,55 +1,71 @@ import app from '../../forum/app'; import { throttle } from 'throttle-debounce'; import anchorScroll from '../../common/utils/anchorScroll'; +import Discussion from '../../common/models/Discussion'; +import Post from '../../common/models/Post'; -class PostStreamState { - constructor(discussion, includedPosts = []) { - /** - * The discussion to display the post stream for. - * - * @type {Discussion} - */ - this.discussion = discussion; +export default class PostStreamState { + /** + * @see https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-337560146 + */ + ['constructor']: typeof PostStreamState; + + /** + * The number of posts to load per page. + */ + static loadCount = 20; + + /** + * The discussion to display the post stream for. + */ + discussion: Discussion; + + /** + * Whether or not the infinite-scrolling auto-load functionality is + * disabled. + */ + paused = false; + + loadPageTimeouts: Record = {}; + pagesLoading = 0; + + index = 0; + number = 1; + + /** + * The number of posts that are currently visible in the viewport. + */ + visible = 1; + visibleStart = 0; + visibleEnd = 0; + + animateScroll = false; + needsScroll = false; + targetPost: { number: number } | { index: number; reply?: boolean } | null = null; + + /** + * The description to render on the scrubber. + */ + description = ''; + + /** + * When the page is scrolled, goToIndex is called, or the page is loaded, + * various listeners result in the scrubber being updated with a new + * position and values. However, if goToNumber is called, the scrubber + * will not be updated. Accordingly, we add logic to the scrubber's + * onupdate to update itself, but only when needed, as indicated by this + * property. + * + */ + forceUpdateScrubber = false; - /** - * Whether or not the infinite-scrolling auto-load functionality is - * disabled. - * - * @type {Boolean} - */ - this.paused = false; - - this.loadPageTimeouts = {}; - this.pagesLoading = 0; - - this.index = 0; - this.number = 1; - - /** - * The number of posts that are currently visible in the viewport. - * - * @type {Number} - */ - this.visible = 1; - - /** - * The description to render on the scrubber. - * - * @type {String} - */ - this.description = ''; - - /** - * When the page is scrolled, goToIndex is called, or the page is loaded, - * various listeners result in the scrubber being updated with a new - * position and values. However, if goToNumber is called, the scrubber - * will not be updated. Accordingly, we add logic to the scrubber's - * onupdate to update itself, but only when needed, as indicated by this - * property. - * - * @type {Boolean} - */ - this.forceUpdateScrubber = false; + loadPromise: Promise | null = null; + + loadNext: () => void; + loadPrevious: () => void; + + constructor(discussion: Discussion, includedPosts: Post[] = []) { + this.discussion = discussion; this.loadNext = throttle(300, this._loadNext); this.loadPrevious = throttle(300, this._loadPrevious); @@ -71,35 +87,29 @@ class PostStreamState { /** * Load and scroll up to the first post in the discussion. - * - * @return {Promise} */ - goToFirst() { + goToFirst(): Promise { return this.goToIndex(0); } /** * Load and scroll down to the last post in the discussion. - * - * @return {Promise} */ - goToLast() { + goToLast(): Promise { return this.goToIndex(this.count() - 1, true); } /** * Load and scroll to a post with a certain number. * - * @param {number | string} number The post number to go to. If 'reply', go to the last post and scroll the reply preview into view. - * @param {boolean} [noAnimation] - * @return {Promise} + * @param number The post number to go to. If 'reply', go to the last post and scroll the reply preview into view. */ - goToNumber(number, noAnimation = false) { + goToNumber(number: number | 'reply', noAnimation = false): Promise { // If we want to go to the reply preview, then we will go to the end of the // discussion and then scroll to the very bottom of the page. if (number === 'reply') { const resultPromise = this.goToLast(); - this.targetPost.reply = true; + this.targetPost = { ...(this.targetPost as { index: number }), reply: true }; return resultPromise; } @@ -122,12 +132,8 @@ class PostStreamState { /** * Load and scroll to a certain index within the discussion. - * - * @param {number} index - * @param {boolean} [noAnimation] - * @return {Promise} */ - goToIndex(index, noAnimation = false) { + goToIndex(index: number, noAnimation = false): Promise { this.paused = true; this.loadPromise = this.loadNearIndex(index); @@ -146,11 +152,8 @@ class PostStreamState { * Clear the stream and load posts near a certain number. Returns a promise. * If the post with the given number is already loaded, the promise will be * resolved immediately. - * - * @param {number} number - * @return {Promise} */ - loadNearNumber(number) { + loadNearNumber(number: number): Promise { if (this.posts().some((post) => post && Number(post.number()) === Number(number))) { return Promise.resolve(); } @@ -158,8 +161,8 @@ class PostStreamState { this.reset(); return app.store - .find('posts', { - filter: { discussion: this.discussion.id() }, + .find('posts', { + filter: { discussion: this.discussion.id() as string }, page: { near: number }, }) .then(this.show.bind(this)); @@ -169,11 +172,8 @@ class PostStreamState { * Clear the stream and load posts near a certain index. A page of posts * surrounding the given index will be loaded. Returns a promise. If the given * index is already loaded, the promise will be resolved immediately. - * - * @param {number} index - * @return {Promise} */ - loadNearIndex(index) { + loadNearIndex(index: number): Promise { if (index >= this.visibleStart && index < this.visibleEnd) { return Promise.resolve(); } @@ -201,7 +201,7 @@ class PostStreamState { if (this.loadPageTimeouts[twoPagesAway]) { clearTimeout(this.loadPageTimeouts[twoPagesAway]); - this.loadPageTimeouts[twoPagesAway] = null; + delete this.loadPageTimeouts[twoPagesAway]; this.pagesLoading--; } } @@ -224,7 +224,7 @@ class PostStreamState { if (this.loadPageTimeouts[twoPagesAway]) { clearTimeout(this.loadPageTimeouts[twoPagesAway]); - this.loadPageTimeouts[twoPagesAway] = null; + delete this.loadPageTimeouts[twoPagesAway]; this.pagesLoading--; } } @@ -234,12 +234,8 @@ class PostStreamState { /** * Load a page of posts into the stream and redraw. - * - * @param {number} start - * @param {number} end - * @param {boolean} backwards */ - loadPage(start, end, backwards = false) { + loadPage(start: number, end: number, backwards = false) { this.pagesLoading++; const redraw = () => { @@ -256,7 +252,7 @@ class PostStreamState { redraw(); this.pagesLoading--; }); - this.loadPageTimeouts[start] = null; + delete this.loadPageTimeouts[start]; }, this.pagesLoading - 1 ? 1000 : 0 ); @@ -265,20 +261,16 @@ class PostStreamState { /** * Load and inject the specified range of posts into the stream, without * clearing it. - * - * @param {number} start - * @param {number} end - * @return {Promise} */ - loadRange(start, end) { - const loadIds = []; - const loaded = []; + loadRange(start: number, end: number): Promise { + const loadIds: string[] = []; + const loaded: Post[] = []; this.discussion .postIds() .slice(start, end) .forEach((id) => { - const post = app.store.getById('posts', id); + const post = app.store.getById('posts', id); if (post && post.discussion() && typeof post.canEdit() !== 'undefined') { loaded.push(post); @@ -288,7 +280,7 @@ class PostStreamState { }); if (loadIds.length) { - return app.store.find('posts', loadIds).then((newPosts) => { + return app.store.find('posts', loadIds).then((newPosts) => { return loaded.concat(newPosts).sort((a, b) => a.number() - b.number()); }); } @@ -298,37 +290,30 @@ class PostStreamState { /** * Set up the stream with the given array of posts. - * - * @param {import('../../common/models/Post').default[]} posts */ - show(posts) { - this.visibleStart = posts.length ? this.discussion.postIds().indexOf(posts[0].id()) : 0; + show(posts: Post[]) { + this.visibleStart = posts.length ? this.discussion.postIds().indexOf(posts[0].id() ?? '0') : 0; this.visibleEnd = this.sanitizeIndex(this.visibleStart + posts.length); } /** * Reset the stream so that a specific range of posts is displayed. If a range * is not specified, the first page of posts will be displayed. - * - * @param {number} [start] - * @param {number} [end] */ - reset(start, end) { + reset(start?: number, end?: number) { this.visibleStart = start || 0; this.visibleEnd = this.sanitizeIndex(end || this.constructor.loadCount); } /** * Get the visible page of posts. - * - * @return {Post[]} */ - posts() { + posts(): (Post | null)[] { return this.discussion .postIds() .slice(this.visibleStart, this.visibleEnd) .map((id) => { - const post = app.store.getById('posts', id); + const post = app.store.getById('posts', id); return post && post.discussion() && typeof post.canEdit() !== 'undefined' ? post : null; }); @@ -336,29 +321,23 @@ class PostStreamState { /** * Get the total number of posts in the discussion. - * - * @return {number} */ - count() { + count(): number { return this.discussion.postIds().length; } /** * Check whether or not the scrubber should be disabled, i.e. if all of the * posts are visible in the viewport. - * - * @return {boolean} */ - disabled() { + disabled(): boolean { return this.visible >= this.count(); } /** * Are we currently viewing the end of the discussion? - * - * @return {boolean} */ - viewingEnd() { + viewingEnd(): boolean { // In some cases, such as if we've stickied a post, an event post // may have been added / removed. This means that `this.visibleEnd` // and`this.count()` will be out of sync by 1 post, but we are still @@ -370,19 +349,8 @@ class PostStreamState { /** * Make sure that the given index is not outside of the possible range of * indexes in the discussion. - * - * @param {number} index */ - sanitizeIndex(index) { + sanitizeIndex(index: number) { return Math.max(0, Math.min(this.count(), Math.floor(index))); } } - -/** - * The number of posts to load per page. - * - * @type {number} - */ -PostStreamState.loadCount = 20; - -export default PostStreamState; From 43fbc6ab12eb5015098c5ebd56c5484e94c5700e Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 13 Mar 2022 03:35:47 -0400 Subject: [PATCH 18/41] chore(core): rebuild typings --- .../core/js/dist-typings/common/Store.d.ts | 4 +- .../common/utils/anchorScroll.d.ts | 4 +- .../forum/states/PostStreamState.d.ts | 113 ++++++------------ 3 files changed, 39 insertions(+), 82 deletions(-) diff --git a/framework/core/js/dist-typings/common/Store.d.ts b/framework/core/js/dist-typings/common/Store.d.ts index 1ab4bc595a..664bd1663b 100644 --- a/framework/core/js/dist-typings/common/Store.d.ts +++ b/framework/core/js/dist-typings/common/Store.d.ts @@ -14,9 +14,9 @@ export interface ApiQueryParamsPlural { include?: string; filter?: { q: string; - [key: string]: string; - }; + } | Record; page?: { + near?: number; offset?: number; number?: number; limit?: number; diff --git a/framework/core/js/dist-typings/common/utils/anchorScroll.d.ts b/framework/core/js/dist-typings/common/utils/anchorScroll.d.ts index f818d25df9..e4be06d69e 100644 --- a/framework/core/js/dist-typings/common/utils/anchorScroll.d.ts +++ b/framework/core/js/dist-typings/common/utils/anchorScroll.d.ts @@ -8,7 +8,7 @@ * position can be anchor to an element that is in or below the viewport, so * the content in the viewport will stay the same. * - * @param {HTMLElement | SVGElement | Element} element The element to anchor the scroll position to. + * @param {string | HTMLElement | SVGElement | Element} element The element to anchor the scroll position to. * @param {() => void} callback The callback to run that will change page content. */ -export default function anchorScroll(element: HTMLElement | SVGElement | Element, callback: () => void): void; +export default function anchorScroll(element: string | HTMLElement | SVGElement | Element, callback: () => void): void; diff --git a/framework/core/js/dist-typings/forum/states/PostStreamState.d.ts b/framework/core/js/dist-typings/forum/states/PostStreamState.d.ts index 6588627b50..8c6a0c1458 100644 --- a/framework/core/js/dist-typings/forum/states/PostStreamState.d.ts +++ b/framework/core/js/dist-typings/forum/states/PostStreamState.d.ts @@ -1,33 +1,44 @@ -export default PostStreamState; -declare class PostStreamState { - constructor(discussion: any, includedPosts?: any[]); +/// +import Discussion from '../../common/models/Discussion'; +import Post from '../../common/models/Post'; +export default class PostStreamState { + /** + * @see https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-337560146 + */ + ['constructor']: typeof PostStreamState; + /** + * The number of posts to load per page. + */ + static loadCount: number; /** * The discussion to display the post stream for. - * - * @type {Discussion} */ discussion: Discussion; /** * Whether or not the infinite-scrolling auto-load functionality is * disabled. - * - * @type {Boolean} */ paused: boolean; - loadPageTimeouts: {}; + loadPageTimeouts: Record; pagesLoading: number; index: number; number: number; /** * The number of posts that are currently visible in the viewport. - * - * @type {Number} */ visible: number; + visibleStart: number; + visibleEnd: number; + animateScroll: boolean; + needsScroll: boolean; + targetPost: { + number: number; + } | { + index: number; + reply?: boolean; + } | null; /** * The description to render on the scrubber. - * - * @type {String} */ description: string; /** @@ -38,147 +49,93 @@ declare class PostStreamState { * onupdate to update itself, but only when needed, as indicated by this * property. * - * @type {Boolean} */ forceUpdateScrubber: boolean; - loadNext: throttle<() => void>; - loadPrevious: throttle<() => void>; + loadPromise: Promise | null; + loadNext: () => void; + loadPrevious: () => void; + constructor(discussion: Discussion, includedPosts?: Post[]); /** * Update the stream so that it loads and includes the latest posts in the * discussion, if the end is being viewed. */ - update(): Promise; - visibleEnd: any; + update(): Promise | Promise; /** * Load and scroll up to the first post in the discussion. - * - * @return {Promise} */ goToFirst(): Promise; /** * Load and scroll down to the last post in the discussion. - * - * @return {Promise} */ goToLast(): Promise; /** * Load and scroll to a post with a certain number. * - * @param {number | string} number The post number to go to. If 'reply', go to the last post and scroll the reply preview into view. - * @param {boolean} [noAnimation] - * @return {Promise} + * @param number The post number to go to. If 'reply', go to the last post and scroll the reply preview into view. */ - goToNumber(number: number | string, noAnimation?: boolean | undefined): Promise; - loadPromise: Promise | undefined; - needsScroll: boolean | undefined; - targetPost: { - number: string | number; - index?: undefined; - } | { - index: number; - number?: undefined; - } | undefined; - animateScroll: boolean | undefined; + goToNumber(number: number | 'reply', noAnimation?: boolean): Promise; /** * Load and scroll to a certain index within the discussion. - * - * @param {number} index - * @param {boolean} [noAnimation] - * @return {Promise} */ - goToIndex(index: number, noAnimation?: boolean | undefined): Promise; + goToIndex(index: number, noAnimation?: boolean): Promise; /** * Clear the stream and load posts near a certain number. Returns a promise. * If the post with the given number is already loaded, the promise will be * resolved immediately. - * - * @param {number} number - * @return {Promise} */ loadNearNumber(number: number): Promise; /** * Clear the stream and load posts near a certain index. A page of posts * surrounding the given index will be loaded. Returns a promise. If the given * index is already loaded, the promise will be resolved immediately. - * - * @param {number} index - * @return {Promise} */ loadNearIndex(index: number): Promise; /** * Load the next page of posts. */ _loadNext(): void; - visibleStart: any; /** * Load the previous page of posts. */ _loadPrevious(): void; /** * Load a page of posts into the stream and redraw. - * - * @param {number} start - * @param {number} end - * @param {boolean} backwards */ loadPage(start: number, end: number, backwards?: boolean): void; /** * Load and inject the specified range of posts into the stream, without * clearing it. - * - * @param {number} start - * @param {number} end - * @return {Promise} */ - loadRange(start: number, end: number): Promise; + loadRange(start: number, end: number): Promise; /** * Set up the stream with the given array of posts. - * - * @param {import('../../common/models/Post').default[]} posts */ - show(posts: import('../../common/models/Post').default[]): void; + show(posts: Post[]): void; /** * Reset the stream so that a specific range of posts is displayed. If a range * is not specified, the first page of posts will be displayed. - * - * @param {number} [start] - * @param {number} [end] */ - reset(start?: number | undefined, end?: number | undefined): void; + reset(start?: number, end?: number): void; /** * Get the visible page of posts. - * - * @return {Post[]} */ - posts(): Post[]; + posts(): (Post | null)[]; /** * Get the total number of posts in the discussion. - * - * @return {number} */ count(): number; /** * Check whether or not the scrubber should be disabled, i.e. if all of the * posts are visible in the viewport. - * - * @return {boolean} */ disabled(): boolean; /** * Are we currently viewing the end of the discussion? - * - * @return {boolean} */ viewingEnd(): boolean; /** * Make sure that the given index is not outside of the possible range of * indexes in the discussion. - * - * @param {number} index */ sanitizeIndex(index: number): number; } -declare namespace PostStreamState { - const loadCount: number; -} -import { throttle } from "throttle-debounce"; From a7f03d2f73de87112fea8e4fe1753b04f5a373fa Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 13 Mar 2022 04:13:32 -0400 Subject: [PATCH 19/41] feat: allow extending app.routes --- extensions/tags/composer.json | 2 +- extensions/tags/js/{admin.js => admin.ts} | 0 extensions/tags/js/{forum.js => forum.ts} | 0 extensions/tags/js/package.json | 12 ++++++++++-- .../js/src/admin/addTagChangePermission.js | 6 +++--- .../tags/js/src/admin/addTagsHomePageOption.js | 4 ++-- .../js/src/admin/addTagsPermissionScope.js | 12 ++++++------ .../tags/js/src/admin/components/TagsPage.js | 8 ++++---- .../tags/js/src/admin/{index.js => index.ts} | 1 + .../tags/js/src/common/helpers/tagIcon.js | 2 +- .../tags/js/src/common/helpers/tagLabel.js | 4 ++-- .../tags/js/src/common/helpers/tagsLabel.js | 2 +- extensions/tags/js/src/common/models/Tag.js | 6 +++--- extensions/tags/js/src/forum/addTagComposer.js | 8 ++++---- extensions/tags/js/src/forum/addTagControl.js | 6 +++--- extensions/tags/js/src/forum/addTagFilter.js | 10 +++++----- extensions/tags/js/src/forum/addTagLabels.js | 6 +++--- extensions/tags/js/src/forum/addTagList.js | 8 ++++---- .../forum/components/DiscussionTaggedPost.js | 2 +- .../src/forum/components/TagDiscussionModal.js | 18 +++++++++--------- .../tags/js/src/forum/components/TagHero.js | 2 +- .../js/src/forum/components/TagLinkButton.js | 6 +++--- .../tags/js/src/forum/components/TagsPage.js | 12 ++++++------ .../tags/js/src/forum/{index.js => index.ts} | 7 ++++--- extensions/tags/js/tsconfig.json | 16 ++++++++++++++++ .../dist-typings/admin/AdminApplication.d.ts | 2 ++ .../core/js/dist-typings/admin/routes.d.ts | 5 +++++ .../dist-typings/forum/ForumApplication.d.ts | 4 ++-- .../core/js/dist-typings/forum/routes.d.ts | 8 ++++++++ .../core/js/src/admin/AdminApplication.ts | 6 +++++- framework/core/js/src/admin/routes.ts | 5 +++++ .../core/js/src/forum/ForumApplication.ts | 4 ++-- framework/core/js/src/forum/routes.ts | 9 +++++++++ 33 files changed, 131 insertions(+), 72 deletions(-) rename extensions/tags/js/{admin.js => admin.ts} (100%) rename extensions/tags/js/{forum.js => forum.ts} (100%) rename extensions/tags/js/src/admin/{index.js => index.ts} (95%) rename extensions/tags/js/src/forum/{index.js => index.ts} (85%) create mode 100644 extensions/tags/js/tsconfig.json diff --git a/extensions/tags/composer.json b/extensions/tags/composer.json index 52abefcec6..c1aa54516c 100644 --- a/extensions/tags/composer.json +++ b/extensions/tags/composer.json @@ -54,7 +54,7 @@ "gitConf": true, "githubActions": true, "prettier": false, - "typescript": false, + "typescript": true, "bundlewatch": false, "backendTesting": true, "editorConfig": true, diff --git a/extensions/tags/js/admin.js b/extensions/tags/js/admin.ts similarity index 100% rename from extensions/tags/js/admin.js rename to extensions/tags/js/admin.ts diff --git a/extensions/tags/js/forum.js b/extensions/tags/js/forum.ts similarity index 100% rename from extensions/tags/js/forum.js rename to extensions/tags/js/forum.ts diff --git a/extensions/tags/js/package.json b/extensions/tags/js/package.json index 8ea5bfe50e..c5d1fc40bd 100644 --- a/extensions/tags/js/package.json +++ b/extensions/tags/js/package.json @@ -8,11 +8,19 @@ "scripts": { "dev": "webpack --mode development --watch", "build": "webpack --mode production", - "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", + "build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && 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'", + "check-typings": "tsc --noEmit --emitDeclarationOnly false", + "check-typings-coverage": "typescript-coverage-report" }, "devDependencies": { "flarum-webpack-config": "^2.0.0", "webpack": "^5.65.0", - "webpack-cli": "^4.9.1" + "webpack-cli": "^4.9.1", + "flarum-tsconfig": "^1.0.2", + "typescript": "^4.5.4", + "typescript-coverage-report": "^0.6.1" } } diff --git a/extensions/tags/js/src/admin/addTagChangePermission.js b/extensions/tags/js/src/admin/addTagChangePermission.js index d715f148b7..4939f2e6b6 100644 --- a/extensions/tags/js/src/admin/addTagChangePermission.js +++ b/extensions/tags/js/src/admin/addTagChangePermission.js @@ -1,6 +1,6 @@ -import { extend } from 'flarum/extend'; -import PermissionGrid from 'flarum/components/PermissionGrid'; -import SettingDropdown from 'flarum/components/SettingDropdown'; +import { extend } from 'flarum/common/extend'; +import PermissionGrid from 'flarum/admin/components/PermissionGrid'; +import SettingDropdown from 'flarum/admin/components/SettingDropdown'; export default function() { extend(PermissionGrid.prototype, 'startItems', items => { diff --git a/extensions/tags/js/src/admin/addTagsHomePageOption.js b/extensions/tags/js/src/admin/addTagsHomePageOption.js index 1d94383142..550ad12d09 100644 --- a/extensions/tags/js/src/admin/addTagsHomePageOption.js +++ b/extensions/tags/js/src/admin/addTagsHomePageOption.js @@ -1,5 +1,5 @@ -import { extend } from 'flarum/extend'; -import BasicsPage from 'flarum/components/BasicsPage'; +import { extend } from 'flarum/common/extend'; +import BasicsPage from 'flarum/admin/components/BasicsPage'; export default function() { extend(BasicsPage.prototype, 'homePageItems', items => { diff --git a/extensions/tags/js/src/admin/addTagsPermissionScope.js b/extensions/tags/js/src/admin/addTagsPermissionScope.js index b08a85dd5a..247f3353e4 100644 --- a/extensions/tags/js/src/admin/addTagsPermissionScope.js +++ b/extensions/tags/js/src/admin/addTagsPermissionScope.js @@ -1,9 +1,9 @@ -import { extend, override } from 'flarum/extend'; -import PermissionGrid from 'flarum/components/PermissionGrid'; -import PermissionDropdown from 'flarum/components/PermissionDropdown'; -import Dropdown from 'flarum/components/Dropdown'; -import Button from 'flarum/components/Button'; -import LoadingIndicator from 'flarum/components/LoadingIndicator'; +import { extend, override } from 'flarum/common/extend'; +import PermissionGrid from 'flarum/admin/components/PermissionGrid'; +import PermissionDropdown from 'flarum/admin/components/PermissionDropdown'; +import Dropdown from 'flarum/common/components/Dropdown'; +import Button from 'flarum/common/components/Button'; +import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import tagLabel from '../common/helpers/tagLabel'; import tagIcon from '../common/helpers/tagIcon'; diff --git a/extensions/tags/js/src/admin/components/TagsPage.js b/extensions/tags/js/src/admin/components/TagsPage.js index d44f23e9f5..142fd21930 100644 --- a/extensions/tags/js/src/admin/components/TagsPage.js +++ b/extensions/tags/js/src/admin/components/TagsPage.js @@ -1,9 +1,9 @@ import sortable from 'sortablejs'; -import ExtensionPage from 'flarum/components/ExtensionPage'; -import Button from 'flarum/components/Button'; -import LoadingIndicator from 'flarum/components/LoadingIndicator'; -import withAttr from 'flarum/utils/withAttr'; +import ExtensionPage from 'flarum/admin/components/ExtensionPage'; +import Button from 'flarum/common/components/Button'; +import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; +import withAttr from 'flarum/common/utils/withAttr'; import EditTagModal from './EditTagModal'; import tagIcon from '../../common/helpers/tagIcon'; diff --git a/extensions/tags/js/src/admin/index.js b/extensions/tags/js/src/admin/index.ts similarity index 95% rename from extensions/tags/js/src/admin/index.js rename to extensions/tags/js/src/admin/index.ts index 4c146ae188..24bfac0e22 100644 --- a/extensions/tags/js/src/admin/index.js +++ b/extensions/tags/js/src/admin/index.ts @@ -1,3 +1,4 @@ +import app from 'flarum/admin/app'; import Tag from '../common/models/Tag'; import addTagsPermissionScope from './addTagsPermissionScope'; import addTagPermission from './addTagPermission'; diff --git a/extensions/tags/js/src/common/helpers/tagIcon.js b/extensions/tags/js/src/common/helpers/tagIcon.js index 9b39720c64..c15430a502 100644 --- a/extensions/tags/js/src/common/helpers/tagIcon.js +++ b/extensions/tags/js/src/common/helpers/tagIcon.js @@ -1,4 +1,4 @@ -import classList from 'flarum/utils/classList'; +import classList from 'flarum/common/utils/classList'; export default function tagIcon(tag, attrs = {}, settings = {}) { const hasIcon = tag && tag.icon(); diff --git a/extensions/tags/js/src/common/helpers/tagLabel.js b/extensions/tags/js/src/common/helpers/tagLabel.js index 3f34c1ba2d..8b5df2ae04 100644 --- a/extensions/tags/js/src/common/helpers/tagLabel.js +++ b/extensions/tags/js/src/common/helpers/tagLabel.js @@ -1,5 +1,5 @@ -import extract from 'flarum/utils/extract'; -import Link from 'flarum/components/Link'; +import extract from 'flarum/common/utils/extract'; +import Link from 'flarum/common/components/Link'; import tagIcon from './tagIcon'; export default function tagLabel(tag, attrs = {}) { diff --git a/extensions/tags/js/src/common/helpers/tagsLabel.js b/extensions/tags/js/src/common/helpers/tagsLabel.js index 680427696a..370e66cd14 100644 --- a/extensions/tags/js/src/common/helpers/tagsLabel.js +++ b/extensions/tags/js/src/common/helpers/tagsLabel.js @@ -1,4 +1,4 @@ -import extract from 'flarum/utils/extract'; +import extract from 'flarum/common/utils/extract'; import tagLabel from './tagLabel'; import sortTags from '../utils/sortTags'; diff --git a/extensions/tags/js/src/common/models/Tag.js b/extensions/tags/js/src/common/models/Tag.js index c046607046..258b640d30 100644 --- a/extensions/tags/js/src/common/models/Tag.js +++ b/extensions/tags/js/src/common/models/Tag.js @@ -1,6 +1,6 @@ -import Model from 'flarum/Model'; -import mixin from 'flarum/utils/mixin'; -import computed from 'flarum/utils/computed'; +import Model from 'flarum/common/Model'; +import mixin from 'flarum/common/utils/mixin'; +import computed from 'flarum/common/utils/computed'; export default class Tag extends mixin(Model, { name: Model.attribute('name'), diff --git a/extensions/tags/js/src/forum/addTagComposer.js b/extensions/tags/js/src/forum/addTagComposer.js index 4cf48cb90d..e5546e2e62 100644 --- a/extensions/tags/js/src/forum/addTagComposer.js +++ b/extensions/tags/js/src/forum/addTagComposer.js @@ -1,7 +1,7 @@ -import { extend, override } from 'flarum/extend'; -import IndexPage from 'flarum/components/IndexPage'; -import DiscussionComposer from 'flarum/components/DiscussionComposer'; -import classList from 'flarum/utils/classList'; +import { extend, override } from 'flarum/common/extend'; +import IndexPage from 'flarum/forum/components/IndexPage'; +import DiscussionComposer from 'flarum/forum/components/DiscussionComposer'; +import classList from 'flarum/common/utils/classList'; import TagDiscussionModal from './components/TagDiscussionModal'; import tagsLabel from '../common/helpers/tagsLabel'; diff --git a/extensions/tags/js/src/forum/addTagControl.js b/extensions/tags/js/src/forum/addTagControl.js index 94e024f897..c6941cf32d 100644 --- a/extensions/tags/js/src/forum/addTagControl.js +++ b/extensions/tags/js/src/forum/addTagControl.js @@ -1,6 +1,6 @@ -import { extend } from 'flarum/extend'; -import DiscussionControls from 'flarum/utils/DiscussionControls'; -import Button from 'flarum/components/Button'; +import { extend } from 'flarum/common/extend'; +import DiscussionControls from 'flarum/forum/utils/DiscussionControls'; +import Button from 'flarum/common/components/Button'; import TagDiscussionModal from './components/TagDiscussionModal'; diff --git a/extensions/tags/js/src/forum/addTagFilter.js b/extensions/tags/js/src/forum/addTagFilter.js index 9bd489aa38..299806b7bc 100644 --- a/extensions/tags/js/src/forum/addTagFilter.js +++ b/extensions/tags/js/src/forum/addTagFilter.js @@ -1,8 +1,8 @@ -import { extend, override } from 'flarum/extend'; -import IndexPage from 'flarum/components/IndexPage'; -import DiscussionListState from 'flarum/states/DiscussionListState'; -import GlobalSearchState from 'flarum/states/GlobalSearchState'; -import classList from 'flarum/utils/classList'; +import { extend, override } from 'flarum/common/extend'; +import IndexPage from 'flarum/forum/components/IndexPage'; +import DiscussionListState from 'flarum/forum/states/DiscussionListState'; +import GlobalSearchState from 'flarum/forum/states/GlobalSearchState'; +import classList from 'flarum/common/utils/classList'; import TagHero from './components/TagHero'; diff --git a/extensions/tags/js/src/forum/addTagLabels.js b/extensions/tags/js/src/forum/addTagLabels.js index 2da6fb2f74..2857df31fe 100644 --- a/extensions/tags/js/src/forum/addTagLabels.js +++ b/extensions/tags/js/src/forum/addTagLabels.js @@ -1,6 +1,6 @@ -import { extend } from 'flarum/extend'; -import DiscussionListItem from 'flarum/components/DiscussionListItem'; -import DiscussionHero from 'flarum/components/DiscussionHero'; +import { extend } from 'flarum/common/extend'; +import DiscussionListItem from 'flarum/forum/components/DiscussionListItem'; +import DiscussionHero from 'flarum/forum/components/DiscussionHero'; import tagsLabel from '../common/helpers/tagsLabel'; import sortTags from '../common/utils/sortTags'; diff --git a/extensions/tags/js/src/forum/addTagList.js b/extensions/tags/js/src/forum/addTagList.js index 0d54badd68..0648f9ef91 100644 --- a/extensions/tags/js/src/forum/addTagList.js +++ b/extensions/tags/js/src/forum/addTagList.js @@ -1,7 +1,7 @@ -import { extend } from 'flarum/extend'; -import IndexPage from 'flarum/components/IndexPage'; -import Separator from 'flarum/components/Separator'; -import LinkButton from 'flarum/components/LinkButton'; +import { extend } from 'flarum/common/extend'; +import IndexPage from 'flarum/forum/components/IndexPage'; +import Separator from 'flarum/common/components/Separator'; +import LinkButton from 'flarum/common/components/LinkButton'; import TagLinkButton from './components/TagLinkButton'; import TagsPage from './components/TagsPage'; diff --git a/extensions/tags/js/src/forum/components/DiscussionTaggedPost.js b/extensions/tags/js/src/forum/components/DiscussionTaggedPost.js index 0320c5c6a2..bf8b2f3159 100644 --- a/extensions/tags/js/src/forum/components/DiscussionTaggedPost.js +++ b/extensions/tags/js/src/forum/components/DiscussionTaggedPost.js @@ -1,4 +1,4 @@ -import EventPost from 'flarum/components/EventPost'; +import EventPost from 'flarum/forum/components/EventPost'; import tagsLabel from '../../common/helpers/tagsLabel'; export default class DiscussionTaggedPost extends EventPost { diff --git a/extensions/tags/js/src/forum/components/TagDiscussionModal.js b/extensions/tags/js/src/forum/components/TagDiscussionModal.js index 59c6a73b85..1d580f7214 100644 --- a/extensions/tags/js/src/forum/components/TagDiscussionModal.js +++ b/extensions/tags/js/src/forum/components/TagDiscussionModal.js @@ -1,12 +1,12 @@ -import Modal from 'flarum/components/Modal'; -import DiscussionPage from 'flarum/components/DiscussionPage'; -import Button from 'flarum/components/Button'; -import LoadingIndicator from 'flarum/components/LoadingIndicator'; -import highlight from 'flarum/helpers/highlight'; -import classList from 'flarum/utils/classList'; -import extractText from 'flarum/utils/extractText'; -import KeyboardNavigatable from 'flarum/utils/KeyboardNavigatable'; -import Stream from 'flarum/utils/Stream'; +import Modal from 'flarum/common/components/Modal'; +import DiscussionPage from 'flarum/forum/components/DiscussionPage'; +import Button from 'flarum/common/components/Button'; +import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; +import highlight from 'flarum/common/helpers/highlight'; +import classList from 'flarum/common/utils/classList'; +import extractText from 'flarum/common/utils/extractText'; +import KeyboardNavigatable from 'flarum/forum/utils/KeyboardNavigatable'; +import Stream from 'flarum/common/utils/Stream'; import tagLabel from '../../common/helpers/tagLabel'; import tagIcon from '../../common/helpers/tagIcon'; diff --git a/extensions/tags/js/src/forum/components/TagHero.js b/extensions/tags/js/src/forum/components/TagHero.js index 6be76b925d..bd2b899a0c 100644 --- a/extensions/tags/js/src/forum/components/TagHero.js +++ b/extensions/tags/js/src/forum/components/TagHero.js @@ -1,4 +1,4 @@ -import Component from 'flarum/Component'; +import Component from 'flarum/common/Component'; import tagIcon from '../../common/helpers/tagIcon'; export default class TagHero extends Component { diff --git a/extensions/tags/js/src/forum/components/TagLinkButton.js b/extensions/tags/js/src/forum/components/TagLinkButton.js index 0cec0d3a55..9fb2f8b146 100644 --- a/extensions/tags/js/src/forum/components/TagLinkButton.js +++ b/extensions/tags/js/src/forum/components/TagLinkButton.js @@ -1,6 +1,6 @@ -import Link from 'flarum/components/Link'; -import LinkButton from 'flarum/components/LinkButton'; -import classList from 'flarum/utils/classList'; +import Link from 'flarum/common/components/Link'; +import LinkButton from 'flarum/common/components/LinkButton'; +import classList from 'flarum/common/utils/classList'; import tagIcon from '../../common/helpers/tagIcon'; export default class TagLinkButton extends LinkButton { diff --git a/extensions/tags/js/src/forum/components/TagsPage.js b/extensions/tags/js/src/forum/components/TagsPage.js index 172732c828..c3bc1cb39e 100755 --- a/extensions/tags/js/src/forum/components/TagsPage.js +++ b/extensions/tags/js/src/forum/components/TagsPage.js @@ -1,9 +1,9 @@ -import Page from 'flarum/components/Page'; -import IndexPage from 'flarum/components/IndexPage'; -import Link from 'flarum/components/Link'; -import LoadingIndicator from 'flarum/components/LoadingIndicator'; -import listItems from 'flarum/helpers/listItems'; -import humanTime from 'flarum/helpers/humanTime'; +import Page from 'flarum/common/components/Page'; +import IndexPage from 'flarum/forum/components/IndexPage'; +import Link from 'flarum/common/components/Link'; +import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; +import listItems from 'flarum/common/helpers/listItems'; +import humanTime from 'flarum/common/helpers/humanTime'; import tagIcon from '../../common/helpers/tagIcon'; import tagLabel from '../../common/helpers/tagLabel'; diff --git a/extensions/tags/js/src/forum/index.js b/extensions/tags/js/src/forum/index.ts similarity index 85% rename from extensions/tags/js/src/forum/index.js rename to extensions/tags/js/src/forum/index.ts index efe9722c27..08540697b5 100644 --- a/extensions/tags/js/src/forum/index.js +++ b/extensions/tags/js/src/forum/index.ts @@ -1,6 +1,7 @@ -import Model from 'flarum/Model'; -import Discussion from 'flarum/models/Discussion'; -import IndexPage from 'flarum/components/IndexPage'; +import app from 'flarum/forum/app'; +import Model from 'flarum/common/Model'; +import Discussion from 'flarum/common/models/Discussion'; +import IndexPage from 'flarum/forum/components/IndexPage'; import Tag from '../common/models/Tag'; import TagsPage from './components/TagsPage'; diff --git a/extensions/tags/js/tsconfig.json b/extensions/tags/js/tsconfig.json new file mode 100644 index 0000000000..ee0d5ef5a1 --- /dev/null +++ b/extensions/tags/js/tsconfig.json @@ -0,0 +1,16 @@ +{ + // 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/flarum/core/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/*"] + } + } +} diff --git a/framework/core/js/dist-typings/admin/AdminApplication.d.ts b/framework/core/js/dist-typings/admin/AdminApplication.d.ts index 7de254148b..05f98124dc 100644 --- a/framework/core/js/dist-typings/admin/AdminApplication.d.ts +++ b/framework/core/js/dist-typings/admin/AdminApplication.d.ts @@ -1,3 +1,4 @@ +import { AdminRoutes } from './routes'; import Application from '../common/Application'; import ExtensionData from './utils/ExtensionData'; export declare type Extension = { @@ -52,6 +53,7 @@ export default class AdminApplication extends Application { total: number; }>; }; + route: typeof Application.prototype.route & AdminRoutes; constructor(); /** * @inheritdoc diff --git a/framework/core/js/dist-typings/admin/routes.d.ts b/framework/core/js/dist-typings/admin/routes.d.ts index 435fb5a4cb..cb0608a4aa 100644 --- a/framework/core/js/dist-typings/admin/routes.d.ts +++ b/framework/core/js/dist-typings/admin/routes.d.ts @@ -1,4 +1,9 @@ import AdminApplication from './AdminApplication'; +/** + * Helper functions to generate URLs to admin pages. + */ +export interface AdminRoutes { +} /** * The `routes` initializer defines the forum app's routes. */ diff --git a/framework/core/js/dist-typings/forum/ForumApplication.d.ts b/framework/core/js/dist-typings/forum/ForumApplication.d.ts index 2aaf1fca98..58c54774f5 100644 --- a/framework/core/js/dist-typings/forum/ForumApplication.d.ts +++ b/framework/core/js/dist-typings/forum/ForumApplication.d.ts @@ -1,6 +1,6 @@ import History from './utils/History'; import Pane from './utils/Pane'; -import { makeRouteHelpers } from './routes'; +import { ForumRoutes } from './routes'; import Application from '../common/Application'; import NotificationListState from './states/NotificationListState'; import GlobalSearchState from './states/GlobalSearchState'; @@ -55,7 +55,7 @@ export default class ForumApplication extends Application { * is used in the index page and the slideout pane. */ discussions: DiscussionListState; - route: typeof Application.prototype.route & ReturnType; + route: typeof Application.prototype.route & ForumRoutes; constructor(); /** * @inheritdoc diff --git a/framework/core/js/dist-typings/forum/routes.d.ts b/framework/core/js/dist-typings/forum/routes.d.ts index d7d153388a..82c67cf69a 100644 --- a/framework/core/js/dist-typings/forum/routes.d.ts +++ b/framework/core/js/dist-typings/forum/routes.d.ts @@ -2,6 +2,14 @@ import ForumApplication from './ForumApplication'; import Discussion from '../common/models/Discussion'; import Post from '../common/models/Post'; import User from '../common/models/User'; +/** + * Helper functions to generate URLs to form pages. + */ +export interface ForumRoutes { + discussion: (discussion: Discussion, near?: number) => string; + post: (post: Post) => string; + user: (user: User) => string; +} /** * The `routes` initializer defines the forum app's routes. */ diff --git a/framework/core/js/src/admin/AdminApplication.ts b/framework/core/js/src/admin/AdminApplication.ts index 0b24f12101..24f05ca5ed 100644 --- a/framework/core/js/src/admin/AdminApplication.ts +++ b/framework/core/js/src/admin/AdminApplication.ts @@ -1,6 +1,6 @@ import HeaderPrimary from './components/HeaderPrimary'; import HeaderSecondary from './components/HeaderSecondary'; -import routes from './routes'; +import routes, { AdminRoutes } from './routes'; import Application from '../common/Application'; import Navigation from '../common/components/Navigation'; import AdminNav from './components/AdminNav'; @@ -64,10 +64,14 @@ export default class AdminApplication extends Application { modelStatistics: Record; }; + route: typeof Application.prototype.route & AdminRoutes; + constructor() { super(); routes(this); + + this.route = (Object.getPrototypeOf(Object.getPrototypeOf(this)) as Application).route.bind(this) } /** diff --git a/framework/core/js/src/admin/routes.ts b/framework/core/js/src/admin/routes.ts index 6cdda32f3d..87271c88d8 100644 --- a/framework/core/js/src/admin/routes.ts +++ b/framework/core/js/src/admin/routes.ts @@ -8,6 +8,11 @@ import UserListPage from './components/UserListPage'; import ExtensionPage from './components/ExtensionPage'; import ExtensionPageResolver from './resolvers/ExtensionPageResolver'; +/** + * Helper functions to generate URLs to admin pages. + */ +export interface AdminRoutes {} + /** * The `routes` initializer defines the forum app's routes. */ diff --git a/framework/core/js/src/forum/ForumApplication.ts b/framework/core/js/src/forum/ForumApplication.ts index e8350ab502..ccac9dafde 100644 --- a/framework/core/js/src/forum/ForumApplication.ts +++ b/framework/core/js/src/forum/ForumApplication.ts @@ -10,7 +10,7 @@ import Composer from './components/Composer'; import DiscussionRenamedNotification from './components/DiscussionRenamedNotification'; import CommentPost from './components/CommentPost'; import DiscussionRenamedPost from './components/DiscussionRenamedPost'; -import routes, { makeRouteHelpers } from './routes'; +import routes, { ForumRoutes, makeRouteHelpers } from './routes'; import alertEmailConfirmation from './utils/alertEmailConfirmation'; import Application from '../common/Application'; import Navigation from '../common/components/Navigation'; @@ -76,7 +76,7 @@ export default class ForumApplication extends Application { */ discussions: DiscussionListState = new DiscussionListState({}); - route: typeof Application.prototype.route & ReturnType; + route: typeof Application.prototype.route & ForumRoutes; constructor() { super(); diff --git a/framework/core/js/src/forum/routes.ts b/framework/core/js/src/forum/routes.ts index fca44220d5..43b61bc72f 100644 --- a/framework/core/js/src/forum/routes.ts +++ b/framework/core/js/src/forum/routes.ts @@ -10,6 +10,15 @@ import Discussion from '../common/models/Discussion'; import Post from '../common/models/Post'; import User from '../common/models/User'; +/** + * Helper functions to generate URLs to form pages. + */ +export interface ForumRoutes { + discussion: (discussion: Discussion, near?: number) => string; + post: (post: Post) => string; + user: (user: User) => string; +} + /** * The `routes` initializer defines the forum app's routes. */ From f0783cb58797b6b0c034ed2a3e4bcc40eabddb4e Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 13:26:04 -0400 Subject: [PATCH 20/41] fix: more flexible typings for highlight.ts --- framework/core/js/src/common/helpers/highlight.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/core/js/src/common/helpers/highlight.tsx b/framework/core/js/src/common/helpers/highlight.tsx index c4ad455743..e63fa65ad4 100644 --- a/framework/core/js/src/common/helpers/highlight.tsx +++ b/framework/core/js/src/common/helpers/highlight.tsx @@ -10,12 +10,12 @@ import { truncate } from '../utils/string'; * @param [length] The number of characters to truncate the string to. * The string will be truncated surrounding the first match. */ -export default function highlight(string: string, phrase: string | RegExp, length?: number): Mithril.Vnode | string { +export default function highlight(string: string, phrase?: string | RegExp, length?: number): Mithril.Vnode | string { if (!phrase && !length) return string; // Convert the word phrase into a global regular expression (if it isn't // already) so we can search the string for matched. - const regexp = phrase instanceof RegExp ? phrase : new RegExp(phrase, 'gi'); + const regexp = phrase instanceof RegExp ? phrase : new RegExp(phrase ?? '', 'gi'); let highlighted = string; let start = 0; From 63d32738bff86d76163d17eac7a2c7c6bf7f449c Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 13:26:27 -0400 Subject: [PATCH 21/41] fix: use primitive `number` type for Discussion typings --- framework/core/js/src/common/models/Discussion.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/js/src/common/models/Discussion.tsx b/framework/core/js/src/common/models/Discussion.tsx index 53517cdbe7..15d8febbd6 100644 --- a/framework/core/js/src/common/models/Discussion.tsx +++ b/framework/core/js/src/common/models/Discussion.tsx @@ -42,7 +42,7 @@ export default class Discussion extends Model { return Model.attribute('commentCount').call(this); } replyCount() { - return computed('commentCount', (commentCount) => Math.max(0, ((commentCount as number) ?? 0) - 1)).call(this); + return computed('commentCount', (commentCount) => Math.max(0, ((commentCount as number) ?? 0) - 1)).call(this); } posts() { return Model.hasMany('posts').call(this); From 8e602f64be22408982880e9517d15b1534e22004 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 13:39:54 -0400 Subject: [PATCH 22/41] fix: convert DiscussionListItem to TypeScript --- ...sionListItem.js => DiscussionListItem.tsx} | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) rename framework/core/js/src/forum/components/{DiscussionListItem.js => DiscussionListItem.tsx} (83%) diff --git a/framework/core/js/src/forum/components/DiscussionListItem.js b/framework/core/js/src/forum/components/DiscussionListItem.tsx similarity index 83% rename from framework/core/js/src/forum/components/DiscussionListItem.js rename to framework/core/js/src/forum/components/DiscussionListItem.tsx index 337681b94c..4f5db09723 100644 --- a/framework/core/js/src/forum/components/DiscussionListItem.js +++ b/framework/core/js/src/forum/components/DiscussionListItem.tsx @@ -1,5 +1,5 @@ import app from '../../forum/app'; -import Component from '../../common/Component'; +import Component, { ComponentAttrs } from '../../common/Component'; import Link from '../../common/components/Link'; import avatar from '../../common/helpers/avatar'; import listItems from '../../common/helpers/listItems'; @@ -17,26 +17,31 @@ import classList from '../../common/utils/classList'; import DiscussionPage from './DiscussionPage'; import escapeRegExp from '../../common/utils/escapeRegExp'; import Tooltip from '../../common/components/Tooltip'; +import Discussion from '../../common/models/Discussion'; +import Mithril from 'mithril'; +import { DiscussionListParams } from '../states/DiscussionListState'; + +export interface IDiscussionListItemAttrs extends ComponentAttrs { + discussion: Discussion; + params: DiscussionListParams; +} /** * The `DiscussionListItem` component shows a single discussion in the * discussion list. - * - * ### Attrs - * - * - `discussion` - * - `params` */ -export default class DiscussionListItem extends Component { - oninit(vnode) { +export default class DiscussionListItem extends Component { + /** + * Ensures that the discussion will not be redrawn + * unless new data comes in. + */ + subtree!: SubtreeRetainer; + + highlightRegExp?: RegExp; + + oninit(vnode: Mithril.Vnode) { super.oninit(vnode); - /** - * Set up a subtree retainer so that the discussion will not be redrawn - * unless new data comes in. - * - * @type {SubtreeRetainer} - */ this.subtree = new SubtreeRetainer( () => this.attrs.discussion.freshness, () => { @@ -76,7 +81,7 @@ export default class DiscussionListItem extends Component { const phrase = escapeRegExp(this.attrs.params.q); this.highlightRegExp = new RegExp(phrase + '|' + phrase.trim().replace(/\s+/g, '|'), 'gi'); } else { - jumpTo = Math.min(discussion.lastPostNumber(), (discussion.lastReadPostNumber() || 0) + 1); + jumpTo = Math.min(discussion.lastPostNumber() ?? 0, (discussion.lastReadPostNumber() || 0) + 1); } return ( @@ -105,7 +110,7 @@ export default class DiscussionListItem extends Component { position="right" > - {avatar(user, { title: '' })} + {avatar(user || null, { title: '' })} @@ -121,29 +126,27 @@ export default class DiscussionListItem extends Component { ); } - oncreate(vnode) { + oncreate(vnode: Mithril.VnodeDOM) { super.oncreate(vnode); // If we're on a touch device, set up the discussion row to be slidable. // This allows the user to drag the row to either side of the screen to // reveal controls. if ('ontouchstart' in window) { - const slidableInstance = slidable(this.$()); + const slidableInstance = slidable(this.element); this.$('.DiscussionListItem-controls').on('hidden.bs.dropdown', () => slidableInstance.reset()); } } - onbeforeupdate(vnode, old) { - super.onbeforeupdate(vnode, old); + onbeforeupdate(vnode: Mithril.VnodeDOM) { + super.onbeforeupdate(vnode); return this.subtree.needsRebuild(); } /** * Determine whether or not the discussion is currently being viewed. - * - * @return {boolean} */ active() { return app.current.matches(DiscussionPage, { discussion: this.attrs.discussion }); @@ -153,11 +156,9 @@ export default class DiscussionListItem extends Component { * Determine whether or not information about who started the discussion * should be displayed instead of information about the most recent reply to * the discussion. - * - * @return {boolean} */ showFirstPost() { - return ['newest', 'oldest'].indexOf(this.attrs.params.sort) !== -1; + return ['newest', 'oldest'].includes(this.attrs.params.sort ?? ''); } /** @@ -185,17 +186,15 @@ export default class DiscussionListItem extends Component { /** * Build an item list of info for a discussion listing. By default this is * just the first/last post indicator. - * - * @return {ItemList} */ - infoItems() { - const items = new ItemList(); + infoItems(): ItemList { + const items = new ItemList(); if (this.attrs.params.q) { const post = this.attrs.discussion.mostRelevantPost() || this.attrs.discussion.firstPost(); if (post && post.contentType() === 'comment') { - const excerpt = highlight(post.contentPlain(), this.highlightRegExp, 175); + const excerpt = highlight(post.contentPlain() ?? '', this.highlightRegExp, 175); items.add('excerpt', excerpt, -100); } } else { From 8e3f0d09c1cace52ed25af0b43d2719e0e8514ee Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 13:57:11 -0400 Subject: [PATCH 23/41] chore: rebuild core typings --- .../common/helpers/highlight.d.ts | 2 +- .../common/models/Discussion.d.ts | 2 +- .../forum/components/DiscussionListItem.d.ts | 43 ++++++++----------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/framework/core/js/dist-typings/common/helpers/highlight.d.ts b/framework/core/js/dist-typings/common/helpers/highlight.d.ts index 60fa6ceaba..93cf0aaa77 100644 --- a/framework/core/js/dist-typings/common/helpers/highlight.d.ts +++ b/framework/core/js/dist-typings/common/helpers/highlight.d.ts @@ -8,4 +8,4 @@ import type Mithril from 'mithril'; * @param [length] The number of characters to truncate the string to. * The string will be truncated surrounding the first match. */ -export default function highlight(string: string, phrase: string | RegExp, length?: number): Mithril.Vnode | string; +export default function highlight(string: string, phrase?: string | RegExp, length?: number): Mithril.Vnode | string; diff --git a/framework/core/js/dist-typings/common/models/Discussion.d.ts b/framework/core/js/dist-typings/common/models/Discussion.d.ts index 199ebe5572..1396732ea1 100644 --- a/framework/core/js/dist-typings/common/models/Discussion.d.ts +++ b/framework/core/js/dist-typings/common/models/Discussion.d.ts @@ -14,7 +14,7 @@ export default class Discussion extends Model { lastPost(): false | Post | null; lastPostNumber(): number | null | undefined; commentCount(): number | undefined; - replyCount(): Number; + replyCount(): number; posts(): false | (Post | undefined)[]; mostRelevantPost(): false | Post | null; lastReadAt(): Date | null | undefined; diff --git a/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts b/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts index 89d2417c3b..7accd11e2f 100644 --- a/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts +++ b/framework/core/js/dist-typings/forum/components/DiscussionListItem.d.ts @@ -1,41 +1,39 @@ +import Component, { ComponentAttrs } from '../../common/Component'; +import ItemList from '../../common/utils/ItemList'; +import SubtreeRetainer from '../../common/utils/SubtreeRetainer'; +import Discussion from '../../common/models/Discussion'; +import Mithril from 'mithril'; +import { DiscussionListParams } from '../states/DiscussionListState'; +export interface IDiscussionListItemAttrs extends ComponentAttrs { + discussion: Discussion; + params: DiscussionListParams; +} /** * The `DiscussionListItem` component shows a single discussion in the * discussion list. - * - * ### Attrs - * - * - `discussion` - * - `params` */ -export default class DiscussionListItem extends Component { - constructor(); - oninit(vnode: any): void; +export default class DiscussionListItem extends Component { /** - * Set up a subtree retainer so that the discussion will not be redrawn + * Ensures that the discussion will not be redrawn * unless new data comes in. - * - * @type {SubtreeRetainer} */ - subtree: SubtreeRetainer | undefined; + subtree: SubtreeRetainer; + highlightRegExp?: RegExp; + oninit(vnode: Mithril.Vnode): void; elementAttrs(): { className: string; }; view(): JSX.Element; - highlightRegExp: RegExp | undefined; - oncreate(vnode: any): void; - onbeforeupdate(vnode: any, old: any): boolean; + oncreate(vnode: Mithril.VnodeDOM): void; + onbeforeupdate(vnode: Mithril.VnodeDOM): boolean; /** * Determine whether or not the discussion is currently being viewed. - * - * @return {boolean} */ active(): boolean; /** * Determine whether or not information about who started the discussion * should be displayed instead of information about the most recent reply to * the discussion. - * - * @return {boolean} */ showFirstPost(): boolean; /** @@ -52,12 +50,7 @@ export default class DiscussionListItem extends Component} */ - infoItems(): ItemList; + infoItems(): ItemList; replyCountItem(): JSX.Element; } -import Component from "../../common/Component"; -import SubtreeRetainer from "../../common/utils/SubtreeRetainer"; -import ItemList from "../../common/utils/ItemList"; From 29c0753473e03e5ad5c2701e64229a3e4c06fe28 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 14:22:56 -0400 Subject: [PATCH 24/41] fix: final pusher type fixes --- extensions/pusher/js/src/forum/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/extensions/pusher/js/src/forum/index.ts b/extensions/pusher/js/src/forum/index.ts index b81102505d..ca70012761 100644 --- a/extensions/pusher/js/src/forum/index.ts +++ b/extensions/pusher/js/src/forum/index.ts @@ -6,7 +6,8 @@ import DiscussionPage from 'flarum/forum/components/DiscussionPage'; import IndexPage from 'flarum/forum/components/IndexPage'; import Button from 'flarum/common/components/Button'; import ItemList from 'flarum/common/utils/ItemList'; -import { Children, VnodeDOM } from 'mithril'; +import { Children } from 'mithril'; +import Tag from 'flarum/tags/common/models/Tag'; export type PusherBinding = { channels: { @@ -47,14 +48,15 @@ app.initializers.add('flarum-pusher', () => { app.pusher.then((binding: PusherBinding) => { 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(); if (!params.q && !params.sort && !params.filter) { if (params.tags) { - const tag = app.store.getBy('tags', 'slug', params.tags); + const tag = app.store.getBy('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); From 1b62e30977357fd3601b2ca81f4a2e5eef0bb5da Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 14:23:57 -0400 Subject: [PATCH 25/41] feat: start tags TypeScript conversion --- extensions/tags/js/src/@types/shims.d.ts | 21 ++++++ extensions/tags/js/src/common/models/Tag.js | 31 -------- extensions/tags/js/src/common/models/Tag.ts | 71 +++++++++++++++++++ extensions/tags/js/src/forum/index.ts | 8 +-- .../tags/js/src/forum/states/TagListState.js | 20 ------ .../tags/js/src/forum/states/TagListState.ts | 23 ++++++ extensions/tags/js/tsconfig.json | 7 +- 7 files changed, 125 insertions(+), 56 deletions(-) create mode 100644 extensions/tags/js/src/@types/shims.d.ts delete mode 100644 extensions/tags/js/src/common/models/Tag.js create mode 100644 extensions/tags/js/src/common/models/Tag.ts delete mode 100644 extensions/tags/js/src/forum/states/TagListState.js create mode 100644 extensions/tags/js/src/forum/states/TagListState.ts diff --git a/extensions/tags/js/src/@types/shims.d.ts b/extensions/tags/js/src/@types/shims.d.ts new file mode 100644 index 0000000000..50a1fb04df --- /dev/null +++ b/extensions/tags/js/src/@types/shims.d.ts @@ -0,0 +1,21 @@ +import Tag from "../common/models/Tag"; +import 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; + } +} diff --git a/extensions/tags/js/src/common/models/Tag.js b/extensions/tags/js/src/common/models/Tag.js deleted file mode 100644 index 258b640d30..0000000000 --- a/extensions/tags/js/src/common/models/Tag.js +++ /dev/null @@ -1,31 +0,0 @@ -import Model from 'flarum/common/Model'; -import mixin from 'flarum/common/utils/mixin'; -import computed from 'flarum/common/utils/computed'; - -export default class Tag extends mixin(Model, { - name: Model.attribute('name'), - slug: Model.attribute('slug'), - description: Model.attribute('description'), - - color: Model.attribute('color'), - backgroundUrl: Model.attribute('backgroundUrl'), - backgroundMode: Model.attribute('backgroundMode'), - icon: Model.attribute('icon'), - - position: Model.attribute('position'), - parent: Model.hasOne('parent'), - children: Model.hasMany('children'), - defaultSort: Model.attribute('defaultSort'), - isChild: Model.attribute('isChild'), - isHidden: Model.attribute('isHidden'), - - discussionCount: Model.attribute('discussionCount'), - lastPostedAt: Model.attribute('lastPostedAt', Model.transformDate), - lastPostedDiscussion: Model.hasOne('lastPostedDiscussion'), - - isRestricted: Model.attribute('isRestricted'), - canStartDiscussion: Model.attribute('canStartDiscussion'), - canAddToDiscussion: Model.attribute('canAddToDiscussion'), - - isPrimary: computed('position', 'parent', (position, parent) => position !== null && parent === false) -}) {} diff --git a/extensions/tags/js/src/common/models/Tag.ts b/extensions/tags/js/src/common/models/Tag.ts new file mode 100644 index 0000000000..0147a9722b --- /dev/null +++ b/extensions/tags/js/src/common/models/Tag.ts @@ -0,0 +1,71 @@ +import computed from 'flarum/common/utils/computed'; +import Model from 'flarum/common/Model'; +import Discussion from 'flarum/common/models/Discussion'; + +export default class Tag extends Model { + name() { + return Model.attribute('name').call(this); + } + slug() { + return Model.attribute('slug').call(this); + } + description() { + return Model.attribute('description').call(this); + } + + color() { + return Model.attribute('color').call(this); + } + backgroundUrl() { + return Model.attribute('backgroundUrl').call(this); + } + backgroundMode() { + return Model.attribute('backgroundMode').call(this); + } + icon() { + return Model.attribute('icon').call(this); + } + + position() { + return Model.attribute('position').call(this); + } + parent() { + return Model.hasOne('parent').call(this); + } + children() { + return Model.hasMany('children').call(this); + } + defaultSort() { + return Model.attribute('defaultSort').call(this); + } + isChild() { + return Model.attribute('isChild').call(this); + } + isHidden() { + return Model.attribute('isHidden').call(this); + } + + discussionCount() { + return Model.attribute('discussionCount').call(this); + } + lastPostedAt() { + return Model.attribute('lastPostedAt', Model.transformDate).call(this); + } + lastPostedDiscussion() { + return Model.hasOne('lastPostedDiscussion').call(this); + } + + isRestricted() { + return Model.attribute('isRestricted').call(this); + } + canStartDiscussion() { + return Model.attribute('canStartDiscussion').call(this); + } + canAddToDiscussion() { + return Model.attribute('canAddToDiscussion').call(this); + } + + isPrimary() { + return computed('position', 'parent', (position, parent) => position !== null && parent === false).call(this); + } +} diff --git a/extensions/tags/js/src/forum/index.ts b/extensions/tags/js/src/forum/index.ts index 08540697b5..f69709f04d 100644 --- a/extensions/tags/js/src/forum/index.ts +++ b/extensions/tags/js/src/forum/index.ts @@ -15,11 +15,11 @@ import addTagLabels from './addTagLabels'; import addTagControl from './addTagControl'; import addTagComposer from './addTagComposer'; -app.initializers.add('flarum-tags', function(app) { +app.initializers.add('flarum-tags', function() { app.routes.tags = {path: '/tags', component: TagsPage }; app.routes.tag = {path: '/t/:tags', component: IndexPage }; - app.route.tag = tag => app.route('tag', {tags: tag.slug()}); + app.route.tag = (tag: Tag) => app.route('tag', {tags: tag.slug()}); app.postComponents.discussionTagged = DiscussionTaggedPost; @@ -27,8 +27,8 @@ app.initializers.add('flarum-tags', function(app) { app.tagList = new TagListState(); - Discussion.prototype.tags = Model.hasMany('tags'); - Discussion.prototype.canTag = Model.attribute('canTag'); + Discussion.prototype.tags = Model.hasMany('tags'); + Discussion.prototype.canTag = Model.attribute('canTag'); addTagList(); addTagFilter(); diff --git a/extensions/tags/js/src/forum/states/TagListState.js b/extensions/tags/js/src/forum/states/TagListState.js deleted file mode 100644 index 3fcac1128b..0000000000 --- a/extensions/tags/js/src/forum/states/TagListState.js +++ /dev/null @@ -1,20 +0,0 @@ -export default class TagListState { - constructor() { - this.loadedIncludes = new Set(); - } - - async load(includes = []) { - const unloadedIncludes = includes.filter(include => !this.loadedIncludes.has(include)); - - if (unloadedIncludes.length === 0) { - return Promise.resolve(app.store.all('tags')); - } - - return app.store - .find('tags', { include: unloadedIncludes.join(',') }) - .then(val => { - unloadedIncludes.forEach(include => this.loadedIncludes.add(include)); - return val; - }); - } -} \ No newline at end of file diff --git a/extensions/tags/js/src/forum/states/TagListState.ts b/extensions/tags/js/src/forum/states/TagListState.ts new file mode 100644 index 0000000000..c6acef851a --- /dev/null +++ b/extensions/tags/js/src/forum/states/TagListState.ts @@ -0,0 +1,23 @@ +import app from "flarum/forum/app"; +import Tag from "../../common/models/Tag"; + +export default class TagListState { + loadedIncludes = new Set(); + + async load(includes = []): Promise { + const unloadedIncludes = includes.filter( + (include) => !this.loadedIncludes.has(include) + ); + + if (unloadedIncludes.length === 0) { + return Promise.resolve(app.store.all("tags")); + } + + return app.store + .find("tags", { include: unloadedIncludes.join(",") }) + .then((val) => { + unloadedIncludes.forEach((include) => this.loadedIncludes.add(include)); + return val; + }); + } +} diff --git a/extensions/tags/js/tsconfig.json b/extensions/tags/js/tsconfig.json index ee0d5ef5a1..161d73aa0b 100644 --- a/extensions/tags/js/tsconfig.json +++ b/extensions/tags/js/tsconfig.json @@ -10,7 +10,12 @@ "declarationDir": "./dist-typings", "baseUrl": ".", "paths": { - "flarum/*": ["../vendor/flarum/core/js/dist-typings/*"] + "flarum/*": ["../vendor/flarum/core/js/dist-typings/*"], + // TODO: remove after export registry system implemented + // Without this, the old-style `@flarum/core` import is resolved to + // source code in flarum/core instead of the dist typings. + // This causes an inaccurate "duplicate export" error. + "@flarum/core/*": ["../vendor/flarum/core/js/dist-typings/*"], } } } From a75d3697b2d734fa81ee5d88ffe32f378d0d47d8 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 14:24:40 -0400 Subject: [PATCH 26/41] fix: require-dev tags in pusher for CI TypeScript purposes. --- extensions/pusher/composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/pusher/composer.json b/extensions/pusher/composer.json index dc274ffe93..f8e79f17b4 100644 --- a/extensions/pusher/composer.json +++ b/extensions/pusher/composer.json @@ -22,6 +22,9 @@ "flarum/core": "^1.2", "pusher/pusher-php-server": "^2.2" }, + "require-dev": { + "flarum/tags": "^1.0" + }, "autoload": { "psr-4": { "Flarum\\Pusher\\": "src/" From 0f1fe5739e036643609982952657bb5900fe5ac7 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 14:51:56 -0400 Subject: [PATCH 27/41] chore(core): format --- framework/core/js/src/admin/AdminApplication.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/js/src/admin/AdminApplication.ts b/framework/core/js/src/admin/AdminApplication.ts index 24f05ca5ed..a824d594a2 100644 --- a/framework/core/js/src/admin/AdminApplication.ts +++ b/framework/core/js/src/admin/AdminApplication.ts @@ -71,7 +71,7 @@ export default class AdminApplication extends Application { routes(this); - this.route = (Object.getPrototypeOf(Object.getPrototypeOf(this)) as Application).route.bind(this) + this.route = (Object.getPrototypeOf(Object.getPrototypeOf(this)) as Application).route.bind(this); } /** From 7608b32d8a7850d34760a44c9886a947f12a057a Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 14:52:14 -0400 Subject: [PATCH 28/41] chore(tags): build dist typings --- .../tags/js/dist-typings/@types/shims.d.ts | 21 +++++++++ .../admin/addTagChangePermission.d.ts | 1 + .../dist-typings/admin/addTagPermission.d.ts | 1 + .../admin/addTagsHomePageOption.d.ts | 1 + .../admin/addTagsPermissionScope.d.ts | 1 + .../tags/js/dist-typings/admin/compat.d.ts | 21 +++++++++ .../admin/components/EditTagModal.d.ts | 34 ++++++++++++++ .../admin/components/TagsPage.d.ts | 10 +++++ .../tags/js/dist-typings/admin/index.d.ts | 1 + .../tags/js/dist-typings/common/compat.d.ts | 13 ++++++ .../dist-typings/common/helpers/tagIcon.d.ts | 1 + .../dist-typings/common/helpers/tagLabel.d.ts | 1 + .../common/helpers/tagsLabel.d.ts | 1 + .../tags/js/dist-typings/common/index.d.ts | 0 .../js/dist-typings/common/models/Tag.d.ts | 24 ++++++++++ .../dist-typings/common/utils/sortTags.d.ts | 1 + .../js/dist-typings/forum/addTagComposer.d.ts | 1 + .../js/dist-typings/forum/addTagControl.d.ts | 1 + .../js/dist-typings/forum/addTagFilter.d.ts | 1 + .../js/dist-typings/forum/addTagLabels.d.ts | 1 + .../js/dist-typings/forum/addTagList.d.ts | 1 + .../tags/js/dist-typings/forum/compat.d.ts | 31 +++++++++++++ .../components/DiscussionTaggedPost.d.ts | 9 ++++ .../forum/components/TagDiscussionModal.d.ts | 44 +++++++++++++++++++ .../forum/components/TagHero.d.ts | 5 +++ .../forum/components/TagLinkButton.d.ts | 5 +++ .../forum/components/TagsPage.d.ts | 9 ++++ .../forum/components/ToggleButton.d.ts | 8 ++++ .../tags/js/dist-typings/forum/index.d.ts | 1 + .../forum/states/TagListState.d.ts | 5 +++ .../forum/utils/getSelectableTags.d.ts | 1 + 31 files changed, 255 insertions(+) create mode 100644 extensions/tags/js/dist-typings/@types/shims.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/addTagChangePermission.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/addTagPermission.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/addTagsHomePageOption.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/addTagsPermissionScope.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/compat.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/components/EditTagModal.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/components/TagsPage.d.ts create mode 100644 extensions/tags/js/dist-typings/admin/index.d.ts create mode 100644 extensions/tags/js/dist-typings/common/compat.d.ts create mode 100644 extensions/tags/js/dist-typings/common/helpers/tagIcon.d.ts create mode 100644 extensions/tags/js/dist-typings/common/helpers/tagLabel.d.ts create mode 100644 extensions/tags/js/dist-typings/common/helpers/tagsLabel.d.ts create mode 100644 extensions/tags/js/dist-typings/common/index.d.ts create mode 100644 extensions/tags/js/dist-typings/common/models/Tag.d.ts create mode 100644 extensions/tags/js/dist-typings/common/utils/sortTags.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/addTagComposer.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/addTagControl.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/addTagFilter.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/addTagLabels.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/addTagList.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/compat.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/components/DiscussionTaggedPost.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/components/TagDiscussionModal.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/components/TagHero.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/components/TagLinkButton.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/components/TagsPage.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/components/ToggleButton.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/index.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/states/TagListState.d.ts create mode 100644 extensions/tags/js/dist-typings/forum/utils/getSelectableTags.d.ts diff --git a/extensions/tags/js/dist-typings/@types/shims.d.ts b/extensions/tags/js/dist-typings/@types/shims.d.ts new file mode 100644 index 0000000000..50a1fb04df --- /dev/null +++ b/extensions/tags/js/dist-typings/@types/shims.d.ts @@ -0,0 +1,21 @@ +import Tag from "../common/models/Tag"; +import 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; + } +} diff --git a/extensions/tags/js/dist-typings/admin/addTagChangePermission.d.ts b/extensions/tags/js/dist-typings/admin/addTagChangePermission.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/addTagChangePermission.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/admin/addTagPermission.d.ts b/extensions/tags/js/dist-typings/admin/addTagPermission.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/addTagPermission.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/admin/addTagsHomePageOption.d.ts b/extensions/tags/js/dist-typings/admin/addTagsHomePageOption.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/addTagsHomePageOption.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/admin/addTagsPermissionScope.d.ts b/extensions/tags/js/dist-typings/admin/addTagsPermissionScope.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/addTagsPermissionScope.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/admin/compat.d.ts b/extensions/tags/js/dist-typings/admin/compat.d.ts new file mode 100644 index 0000000000..76470a0a5b --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/compat.d.ts @@ -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"; diff --git a/extensions/tags/js/dist-typings/admin/components/EditTagModal.d.ts b/extensions/tags/js/dist-typings/admin/components/EditTagModal.d.ts new file mode 100644 index 0000000000..ef27fa56a9 --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/components/EditTagModal.d.ts @@ -0,0 +1,34 @@ +/// +/** + * The `EditTagModal` component shows a modal dialog which allows the user + * to create or edit a tag. + */ +export default class EditTagModal extends Modal { + constructor(); + oninit(vnode: any): void; + tag: any; + name: Stream | undefined; + slug: Stream | undefined; + description: Stream | undefined; + color: Stream | undefined; + icon: Stream | undefined; + isHidden: Stream | undefined; + primary: Stream | undefined; + title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray | import("mithril").Vnode; + content(): JSX.Element; + fields(): ItemList; + 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"; diff --git a/extensions/tags/js/dist-typings/admin/components/TagsPage.d.ts b/extensions/tags/js/dist-typings/admin/components/TagsPage.d.ts new file mode 100644 index 0000000000..03c36f2948 --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/components/TagsPage.d.ts @@ -0,0 +1,10 @@ +export default class TagsPage extends ExtensionPage { + 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"; diff --git a/extensions/tags/js/dist-typings/admin/index.d.ts b/extensions/tags/js/dist-typings/admin/index.d.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/extensions/tags/js/dist-typings/admin/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/extensions/tags/js/dist-typings/common/compat.d.ts b/extensions/tags/js/dist-typings/common/compat.d.ts new file mode 100644 index 0000000000..f17759d885 --- /dev/null +++ b/extensions/tags/js/dist-typings/common/compat.d.ts @@ -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"; diff --git a/extensions/tags/js/dist-typings/common/helpers/tagIcon.d.ts b/extensions/tags/js/dist-typings/common/helpers/tagIcon.d.ts new file mode 100644 index 0000000000..66027f27d6 --- /dev/null +++ b/extensions/tags/js/dist-typings/common/helpers/tagIcon.d.ts @@ -0,0 +1 @@ +export default function tagIcon(tag: any, attrs?: {}, settings?: {}): JSX.Element; diff --git a/extensions/tags/js/dist-typings/common/helpers/tagLabel.d.ts b/extensions/tags/js/dist-typings/common/helpers/tagLabel.d.ts new file mode 100644 index 0000000000..43fa8ef30b --- /dev/null +++ b/extensions/tags/js/dist-typings/common/helpers/tagLabel.d.ts @@ -0,0 +1 @@ +export default function tagLabel(tag: any, attrs?: {}): import("mithril").Vnode; diff --git a/extensions/tags/js/dist-typings/common/helpers/tagsLabel.d.ts b/extensions/tags/js/dist-typings/common/helpers/tagsLabel.d.ts new file mode 100644 index 0000000000..99c0bc04ef --- /dev/null +++ b/extensions/tags/js/dist-typings/common/helpers/tagsLabel.d.ts @@ -0,0 +1 @@ +export default function tagsLabel(tags: any, attrs?: {}): JSX.Element; diff --git a/extensions/tags/js/dist-typings/common/index.d.ts b/extensions/tags/js/dist-typings/common/index.d.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/extensions/tags/js/dist-typings/common/models/Tag.d.ts b/extensions/tags/js/dist-typings/common/models/Tag.d.ts new file mode 100644 index 0000000000..166d4f8fd2 --- /dev/null +++ b/extensions/tags/js/dist-typings/common/models/Tag.d.ts @@ -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; +} diff --git a/extensions/tags/js/dist-typings/common/utils/sortTags.d.ts b/extensions/tags/js/dist-typings/common/utils/sortTags.d.ts new file mode 100644 index 0000000000..09d040d442 --- /dev/null +++ b/extensions/tags/js/dist-typings/common/utils/sortTags.d.ts @@ -0,0 +1 @@ +export default function sortTags(tags: any): any; diff --git a/extensions/tags/js/dist-typings/forum/addTagComposer.d.ts b/extensions/tags/js/dist-typings/forum/addTagComposer.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/addTagComposer.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/forum/addTagControl.d.ts b/extensions/tags/js/dist-typings/forum/addTagControl.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/addTagControl.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/forum/addTagFilter.d.ts b/extensions/tags/js/dist-typings/forum/addTagFilter.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/addTagFilter.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/forum/addTagLabels.d.ts b/extensions/tags/js/dist-typings/forum/addTagLabels.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/addTagLabels.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/forum/addTagList.d.ts b/extensions/tags/js/dist-typings/forum/addTagList.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/addTagList.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/tags/js/dist-typings/forum/compat.d.ts b/extensions/tags/js/dist-typings/forum/compat.d.ts new file mode 100644 index 0000000000..5a681414df --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/compat.d.ts @@ -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"; diff --git a/extensions/tags/js/dist-typings/forum/components/DiscussionTaggedPost.d.ts b/extensions/tags/js/dist-typings/forum/components/DiscussionTaggedPost.d.ts new file mode 100644 index 0000000000..9dceb98487 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/components/DiscussionTaggedPost.d.ts @@ -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"; diff --git a/extensions/tags/js/dist-typings/forum/components/TagDiscussionModal.d.ts b/extensions/tags/js/dist-typings/forum/components/TagDiscussionModal.d.ts new file mode 100644 index 0000000000..0734bb6b6e --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/components/TagDiscussionModal.d.ts @@ -0,0 +1,44 @@ +export default class TagDiscussionModal extends Modal { + constructor(); + oninit(vnode: any): void; + tagsLoading: boolean | undefined; + selected: any[] | undefined; + filter: Stream | 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; + getCurrentNumericIndex(): number; + getItem(index: any): JQuery; + 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"; diff --git a/extensions/tags/js/dist-typings/forum/components/TagHero.d.ts b/extensions/tags/js/dist-typings/forum/components/TagHero.d.ts new file mode 100644 index 0000000000..037294867e --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/components/TagHero.d.ts @@ -0,0 +1,5 @@ +export default class TagHero extends Component { + constructor(); + view(): JSX.Element; +} +import Component from "flarum/common/Component"; diff --git a/extensions/tags/js/dist-typings/forum/components/TagLinkButton.d.ts b/extensions/tags/js/dist-typings/forum/components/TagLinkButton.d.ts new file mode 100644 index 0000000000..4fb8241022 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/components/TagLinkButton.d.ts @@ -0,0 +1,5 @@ +export default class TagLinkButton extends LinkButton { + static initAttrs(attrs: any): void; + view(vnode: any): JSX.Element; +} +import LinkButton from "flarum/common/components/LinkButton"; diff --git a/extensions/tags/js/dist-typings/forum/components/TagsPage.d.ts b/extensions/tags/js/dist-typings/forum/components/TagsPage.d.ts new file mode 100644 index 0000000000..95fa0863b7 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/components/TagsPage.d.ts @@ -0,0 +1,9 @@ +export default class TagsPage extends Page { + constructor(); + oninit(vnode: any): void; + tags: any; + loading: boolean | undefined; + view(): JSX.Element; + oncreate(vnode: any): void; +} +import Page from "flarum/common/components/Page"; diff --git a/extensions/tags/js/dist-typings/forum/components/ToggleButton.d.ts b/extensions/tags/js/dist-typings/forum/components/ToggleButton.d.ts new file mode 100644 index 0000000000..9b32efb143 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/components/ToggleButton.d.ts @@ -0,0 +1,8 @@ +/** + * @TODO move to core + */ +export default class ToggleButton extends Component { + constructor(); + view(vnode: any): JSX.Element; +} +import Component from "flarum/common/Component"; diff --git a/extensions/tags/js/dist-typings/forum/index.d.ts b/extensions/tags/js/dist-typings/forum/index.d.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/extensions/tags/js/dist-typings/forum/states/TagListState.d.ts b/extensions/tags/js/dist-typings/forum/states/TagListState.d.ts new file mode 100644 index 0000000000..de8862ed1b --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/states/TagListState.d.ts @@ -0,0 +1,5 @@ +import Tag from "../../common/models/Tag"; +export default class TagListState { + loadedIncludes: Set; + load(includes?: never[]): Promise; +} diff --git a/extensions/tags/js/dist-typings/forum/utils/getSelectableTags.d.ts b/extensions/tags/js/dist-typings/forum/utils/getSelectableTags.d.ts new file mode 100644 index 0000000000..72d9f471ab --- /dev/null +++ b/extensions/tags/js/dist-typings/forum/utils/getSelectableTags.d.ts @@ -0,0 +1 @@ +export default function getSelectableTags(discussion: any): any; From a277e332605e808c32c431dd1103638d317e7fad Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 15:02:56 -0400 Subject: [PATCH 29/41] feat(pusher): use dist types from tags. --- extensions/pusher/js/tsconfig.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/pusher/js/tsconfig.json b/extensions/pusher/js/tsconfig.json index ee0d5ef5a1..5fe83152f6 100644 --- a/extensions/pusher/js/tsconfig.json +++ b/extensions/pusher/js/tsconfig.json @@ -4,13 +4,14 @@ // 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/flarum/core/js/dist-typings/@types/**/*", "@types/**/*"], + "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/*": ["../vendor/flarum/core/js/dist-typings/*"], + "flarum/tags/*": ["../vendor/flarum/tags/js/dist-typings/*"] } } } From 3e4f4d270f6bb9668f72688e82a22a7d180214f3 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 15:30:54 -0400 Subject: [PATCH 30/41] feat: convert flags to TypeScript --- extensions/flags/composer.json | 2 +- extensions/flags/js/{admin.js => admin.ts} | 0 extensions/flags/js/{forum.js => forum.ts} | 0 extensions/flags/js/package.json | 11 +++----- extensions/flags/js/src/@types/shims.d.ts | 22 ++++++++++++++++ .../flags/js/src/admin/{index.js => index.ts} | 0 .../flags/js/src/forum/{index.js => index.ts} | 5 ++-- extensions/flags/js/src/forum/models/Flag.js | 15 ----------- extensions/flags/js/src/forum/models/Flag.ts | 25 +++++++++++++++++++ extensions/flags/js/tsconfig.json | 17 +++++++++++++ 10 files changed, 72 insertions(+), 25 deletions(-) rename extensions/flags/js/{admin.js => admin.ts} (100%) rename extensions/flags/js/{forum.js => forum.ts} (100%) create mode 100644 extensions/flags/js/src/@types/shims.d.ts rename extensions/flags/js/src/admin/{index.js => index.ts} (100%) rename extensions/flags/js/src/forum/{index.js => index.ts} (81%) delete mode 100644 extensions/flags/js/src/forum/models/Flag.js create mode 100644 extensions/flags/js/src/forum/models/Flag.ts create mode 100644 extensions/flags/js/tsconfig.json diff --git a/extensions/flags/composer.json b/extensions/flags/composer.json index e866a8fb32..1e64aac3a2 100644 --- a/extensions/flags/composer.json +++ b/extensions/flags/composer.json @@ -49,7 +49,7 @@ "gitConf": true, "githubActions": true, "prettier": true, - "typescript": false, + "typescript": true, "bundlewatch": false, "backendTesting": true, "editorConfig": true, diff --git a/extensions/flags/js/admin.js b/extensions/flags/js/admin.ts similarity index 100% rename from extensions/flags/js/admin.js rename to extensions/flags/js/admin.ts diff --git a/extensions/flags/js/forum.js b/extensions/flags/js/forum.ts similarity index 100% rename from extensions/flags/js/forum.js rename to extensions/flags/js/forum.ts diff --git a/extensions/flags/js/package.json b/extensions/flags/js/package.json index 6444c9c23d..498480bd88 100644 --- a/extensions/flags/js/package.json +++ b/extensions/flags/js/package.json @@ -3,12 +3,8 @@ "name": "@flarum/flags", "version": "0.0.0", "prettier": "@flarum/prettier-config", - "dependencies": { - "@flarum/prettier-config": "^1.0.0", - "flarum-webpack-config": "^1.0.0", - "flarum-tsconfig": "^1.0.2" - }, "devDependencies": { + "@types/mithril": "^2.0.8", "prettier": "^2.5.1", "flarum-webpack-config": "^2.0.0", "webpack": "^5.65.0", @@ -25,8 +21,9 @@ "format-check": "prettier --check src", "analyze": "cross-env ANALYZER=true yarn run build", "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 && tsc && yarn run post-build-typings", "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'" } } diff --git a/extensions/flags/js/src/@types/shims.d.ts b/extensions/flags/js/src/@types/shims.d.ts new file mode 100644 index 0000000000..6fd28d4222 --- /dev/null +++ b/extensions/flags/js/src/@types/shims.d.ts @@ -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; + } +} diff --git a/extensions/flags/js/src/admin/index.js b/extensions/flags/js/src/admin/index.ts similarity index 100% rename from extensions/flags/js/src/admin/index.js rename to extensions/flags/js/src/admin/index.ts diff --git a/extensions/flags/js/src/forum/index.js b/extensions/flags/js/src/forum/index.ts similarity index 81% rename from extensions/flags/js/src/forum/index.js rename to extensions/flags/js/src/forum/index.ts index 5551715feb..f59f009852 100644 --- a/extensions/flags/js/src/forum/index.js +++ b/extensions/flags/js/src/forum/index.ts @@ -9,8 +9,8 @@ import addFlagsDropdown from './addFlagsDropdown'; import addFlagsToPosts from './addFlagsToPosts'; app.initializers.add('flarum-flags', () => { - app.store.models.posts.prototype.flags = Model.hasMany('flags'); - app.store.models.posts.prototype.canFlag = Model.attribute('canFlag'); + Post.prototype.flags = Model.hasMany('flags'); + Post.prototype.canFlag = Model.attribute('canFlag'); app.store.models.flags = Flag; @@ -26,5 +26,6 @@ app.initializers.add('flarum-flags', () => { // Expose compat API import flagsCompat from './compat'; import { compat } from '@flarum/core/forum'; +import Post from 'flarum/common/models/Post'; Object.assign(compat, flagsCompat); diff --git a/extensions/flags/js/src/forum/models/Flag.js b/extensions/flags/js/src/forum/models/Flag.js deleted file mode 100644 index afe9468426..0000000000 --- a/extensions/flags/js/src/forum/models/Flag.js +++ /dev/null @@ -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; diff --git a/extensions/flags/js/src/forum/models/Flag.ts b/extensions/flags/js/src/forum/models/Flag.ts new file mode 100644 index 0000000000..c00f16e8da --- /dev/null +++ b/extensions/flags/js/src/forum/models/Flag.ts @@ -0,0 +1,25 @@ +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() { + return Model.attribute('type').call(this); + } + reason() { + return Model.attribute('reason').call(this); + } + reasonDetail() { + return Model.attribute('reasonDetail').call(this); + } + createdAt() { + return Model.attribute('createdAt', Model.transformDate).call(this); + } + + post() { + return Model.hasOne('post').call(this); + } + user() { + return Model.hasOne('user').call(this); + } +} diff --git a/extensions/flags/js/tsconfig.json b/extensions/flags/js/tsconfig.json new file mode 100644 index 0000000000..c24c740318 --- /dev/null +++ b/extensions/flags/js/tsconfig.json @@ -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/*"] + } + } +} From 5d92c7636d5661618e137c6ba923a452cd7d6320 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 15:31:08 -0400 Subject: [PATCH 31/41] chore(flags): generate dist typings --- .../flags/js/dist-typings/@types/shims.d.ts | 22 +++++++++++++++++++ .../flags/js/dist-typings/admin/index.d.ts | 1 + .../js/dist-typings/forum/addFlagControl.d.ts | 1 + .../dist-typings/forum/addFlagsDropdown.d.ts | 1 + .../dist-typings/forum/addFlagsToPosts.d.ts | 1 + .../flags/js/dist-typings/forum/compat.d.ts | 19 ++++++++++++++++ .../forum/components/FlagList.d.ts | 7 ++++++ .../forum/components/FlagPostModal.d.ts | 15 +++++++++++++ .../forum/components/FlagsDropdown.d.ts | 7 ++++++ .../forum/components/FlagsPage.d.ts | 9 ++++++++ .../flags/js/dist-typings/forum/index.d.ts | 1 + .../js/dist-typings/forum/models/Flag.d.ts | 11 ++++++++++ .../forum/states/FlagListState.d.ts | 16 ++++++++++++++ 13 files changed, 111 insertions(+) create mode 100644 extensions/flags/js/dist-typings/@types/shims.d.ts create mode 100644 extensions/flags/js/dist-typings/admin/index.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/addFlagControl.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/addFlagsDropdown.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/addFlagsToPosts.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/compat.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/components/FlagList.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/components/FlagPostModal.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/components/FlagsDropdown.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/components/FlagsPage.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/index.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/models/Flag.d.ts create mode 100644 extensions/flags/js/dist-typings/forum/states/FlagListState.d.ts diff --git a/extensions/flags/js/dist-typings/@types/shims.d.ts b/extensions/flags/js/dist-typings/@types/shims.d.ts new file mode 100644 index 0000000000..6fd28d4222 --- /dev/null +++ b/extensions/flags/js/dist-typings/@types/shims.d.ts @@ -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; + } +} diff --git a/extensions/flags/js/dist-typings/admin/index.d.ts b/extensions/flags/js/dist-typings/admin/index.d.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/extensions/flags/js/dist-typings/admin/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/extensions/flags/js/dist-typings/forum/addFlagControl.d.ts b/extensions/flags/js/dist-typings/forum/addFlagControl.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/addFlagControl.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/flags/js/dist-typings/forum/addFlagsDropdown.d.ts b/extensions/flags/js/dist-typings/forum/addFlagsDropdown.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/addFlagsDropdown.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/flags/js/dist-typings/forum/addFlagsToPosts.d.ts b/extensions/flags/js/dist-typings/forum/addFlagsToPosts.d.ts new file mode 100644 index 0000000000..f77c13ef18 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/addFlagsToPosts.d.ts @@ -0,0 +1 @@ +export default function _default(): void; diff --git a/extensions/flags/js/dist-typings/forum/compat.d.ts b/extensions/flags/js/dist-typings/forum/compat.d.ts new file mode 100644 index 0000000000..5098b68b90 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/compat.d.ts @@ -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"; diff --git a/extensions/flags/js/dist-typings/forum/components/FlagList.d.ts b/extensions/flags/js/dist-typings/forum/components/FlagList.d.ts new file mode 100644 index 0000000000..e79c0a961f --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/components/FlagList.d.ts @@ -0,0 +1,7 @@ +export default class FlagList extends Component { + constructor(); + oninit(vnode: any): void; + state: any; + view(): JSX.Element; +} +import Component from "flarum/common/Component"; diff --git a/extensions/flags/js/dist-typings/forum/components/FlagPostModal.d.ts b/extensions/flags/js/dist-typings/forum/components/FlagPostModal.d.ts new file mode 100644 index 0000000000..4708f038c6 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/components/FlagPostModal.d.ts @@ -0,0 +1,15 @@ +/// +export default class FlagPostModal extends Modal { + constructor(); + oninit(vnode: any): void; + success: boolean | undefined; + reason: Stream | undefined; + reasonDetail: Stream | undefined; + title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray; + content(): JSX.Element; + flagReasons(): ItemList; + 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"; diff --git a/extensions/flags/js/dist-typings/forum/components/FlagsDropdown.d.ts b/extensions/flags/js/dist-typings/forum/components/FlagsDropdown.d.ts new file mode 100644 index 0000000000..87af955e12 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/components/FlagsDropdown.d.ts @@ -0,0 +1,7 @@ +export default class FlagsDropdown { + static initAttrs(attrs: any): void; + getMenu(): JSX.Element; + goToRoute(): void; + getUnreadCount(): any; + getNewCount(): unknown; +} diff --git a/extensions/flags/js/dist-typings/forum/components/FlagsPage.d.ts b/extensions/flags/js/dist-typings/forum/components/FlagsPage.d.ts new file mode 100644 index 0000000000..b9521b27e1 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/components/FlagsPage.d.ts @@ -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; +} diff --git a/extensions/flags/js/dist-typings/forum/index.d.ts b/extensions/flags/js/dist-typings/forum/index.d.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/extensions/flags/js/dist-typings/forum/models/Flag.d.ts b/extensions/flags/js/dist-typings/forum/models/Flag.d.ts new file mode 100644 index 0000000000..2329a38285 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/models/Flag.d.ts @@ -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; +} diff --git a/extensions/flags/js/dist-typings/forum/states/FlagListState.d.ts b/extensions/flags/js/dist-typings/forum/states/FlagListState.d.ts new file mode 100644 index 0000000000..a15e963a75 --- /dev/null +++ b/extensions/flags/js/dist-typings/forum/states/FlagListState.d.ts @@ -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; +} From 21cc0d74d66e80b790677ae67004cd5b661d718e Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 15:31:46 -0400 Subject: [PATCH 32/41] fix(akismet): last type errors --- extensions/akismet/js/src/forum/index.ts | 2 +- extensions/akismet/js/tsconfig.json | 5 +-- yarn.lock | 45 +++++++----------------- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/extensions/akismet/js/src/forum/index.ts b/extensions/akismet/js/src/forum/index.ts index bc19777581..7b3a31b5de 100644 --- a/extensions/akismet/js/src/forum/index.ts +++ b/extensions/akismet/js/src/forum/index.ts @@ -12,7 +12,7 @@ app.initializers.add('flarum-akismet', () => { if (items.has('approve')) { const flags = post.flags(); - if (flags && flags.some((flag) => flag.type() === 'akismet')) { + if (flags && flags.some((flag) => flag?.type() === 'akismet')) { 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'); diff --git a/extensions/akismet/js/tsconfig.json b/extensions/akismet/js/tsconfig.json index ee0d5ef5a1..510f42a005 100644 --- a/extensions/akismet/js/tsconfig.json +++ b/extensions/akismet/js/tsconfig.json @@ -4,13 +4,14 @@ // 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/flarum/core/js/dist-typings/@types/**/*", "@types/**/*"], + "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/*": ["../vendor/flarum/core/js/dist-typings/*"], + "flarum/flags/*": ["../vendor/flarum/flags/js/dist-typings/*"] } } } diff --git a/yarn.lock b/yarn.lock index f789f17d4f..ef1decfed9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,7 +30,7 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.0.tgz#86850b8597ea6962089770952075dcaabb8dba34" integrity sha512-392byTlpGWXMv4FbyWw3sAZ/FrW/DrwqLGXpy0mbyNe9Taqv1mg9yON5/o0cnr8XYCkFTZbC1eV+c+LAROgrng== -"@babel/core@^7.14.3", "@babel/core@^7.16.0": +"@babel/core@^7.16.0": version "7.17.5" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.5.tgz#6cd2e836058c28f06a4ca8ee7ed955bbf37c8225" integrity sha512-/BBMw4EvjmyquN5O+t5eh0+YqB3XXJkYD2cjKpYtWOfFy4lQ4UozNSmxAcWT8r2XtZs0ewG+zrfsqeR15i1ajA== @@ -306,7 +306,7 @@ "@babel/helper-remap-async-to-generator" "^7.16.8" "@babel/plugin-syntax-async-generators" "^7.8.4" -"@babel/plugin-proposal-class-properties@^7.13.0", "@babel/plugin-proposal-class-properties@^7.16.0", "@babel/plugin-proposal-class-properties@^7.16.7": +"@babel/plugin-proposal-class-properties@^7.16.0", "@babel/plugin-proposal-class-properties@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz#925cad7b3b1a2fcea7e59ecc8eb5954f961f91b0" integrity sha512-IobU0Xme31ewjYOShSIqd/ZGM/r/cuOz2z0MDbNrhF5FW+ZVgi0f2lyeoj9KFPDOAqsYxmLWZte1WOwlvY9aww== @@ -399,7 +399,7 @@ "@babel/helper-skip-transparent-expression-wrappers" "^7.16.0" "@babel/plugin-syntax-optional-chaining" "^7.8.3" -"@babel/plugin-proposal-private-methods@^7.13.0", "@babel/plugin-proposal-private-methods@^7.16.0", "@babel/plugin-proposal-private-methods@^7.16.11": +"@babel/plugin-proposal-private-methods@^7.16.0", "@babel/plugin-proposal-private-methods@^7.16.11": version "7.16.11" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz#e8df108288555ff259f4527dbe84813aac3a1c50" integrity sha512-F/2uAkPlXDr8+BHpZvo19w3hLFKge+k75XUprE6jaqKxjGkSYcK+4c+bup5PdW/7W/Rpjwql7FTVEDW+fRAQsw== @@ -700,7 +700,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.16.7" -"@babel/plugin-transform-object-assign@^7.12.13", "@babel/plugin-transform-object-assign@^7.16.0": +"@babel/plugin-transform-object-assign@^7.16.0": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.16.7.tgz#5fe08d63dccfeb6a33aa2638faf98e5c584100f8" integrity sha512-R8mawvm3x0COTJtveuoqZIjNypn2FjfvXZr4pSQ8VhEFBuQGBz4XhHasZtHXjgXU4XptZ4HtGof3NoYc93ZH9Q== @@ -743,7 +743,7 @@ dependencies: "@babel/plugin-transform-react-jsx" "^7.16.7" -"@babel/plugin-transform-react-jsx@^7.14.3", "@babel/plugin-transform-react-jsx@^7.16.0", "@babel/plugin-transform-react-jsx@^7.16.7": +"@babel/plugin-transform-react-jsx@^7.16.0", "@babel/plugin-transform-react-jsx@^7.16.7": version "7.17.3" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.17.3.tgz#eac1565da176ccb1a715dae0b4609858808008c1" integrity sha512-9tjBm4O07f7mzKSIlEmPdiE6ub7kfIe6Cd+w+oQebpATfTQMAgW+YOuWxogbKVTulA+MEO7byMeIUtQ1z+z+ZQ== @@ -776,7 +776,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.16.7" -"@babel/plugin-transform-runtime@^7.14.3", "@babel/plugin-transform-runtime@^7.16.0": +"@babel/plugin-transform-runtime@^7.16.0": version "7.17.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.17.0.tgz#0a2e08b5e2b2d95c4b1d3b3371a2180617455b70" integrity sha512-fr7zPWnKXNc1xoHfrIU9mN/4XKX4VLZ45Q+oMhfsYIaHvg7mHgmhfOy/ckRWqDK7XF3QDigRpkh5DKq6+clE8A== @@ -848,7 +848,7 @@ "@babel/helper-create-regexp-features-plugin" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7" -"@babel/preset-env@^7.14.2", "@babel/preset-env@^7.16.0": +"@babel/preset-env@^7.16.0": version "7.16.11" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.11.tgz#5dd88fd885fae36f88fd7c8342475c9f0abe2982" integrity sha512-qcmWG8R7ZW6WBRPZK//y+E3Cli151B20W1Rv7ln27vuPaXU/8TKms6jFdiJtF7UDTxcrb7mZd88tAeK9LjdT8g== @@ -939,7 +939,7 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" -"@babel/preset-react@^7.13.13", "@babel/preset-react@^7.16.0": +"@babel/preset-react@^7.16.0": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.16.7.tgz#4c18150491edc69c183ff818f9f2aecbe5d93852" integrity sha512-fWpyI8UM/HE6DfPBzD8LnhQ/OcH8AgTaqcqP2nGOXEUV+VKBR5JRN9hCk9ai+zQQ57vtm9oWeXguBCPNUjytgA== @@ -951,7 +951,7 @@ "@babel/plugin-transform-react-jsx-development" "^7.16.7" "@babel/plugin-transform-react-pure-annotations" "^7.16.7" -"@babel/preset-typescript@^7.13.0", "@babel/preset-typescript@^7.16.0": +"@babel/preset-typescript@^7.16.0": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.16.7.tgz#ab114d68bb2020afc069cd51b37ff98a046a70b9" integrity sha512-WbVEmgXdIyvzB77AQjGBEyYPZx+8tTsO50XtfozQrkW8QB2rLJpH2lgx0TRw5EJrBxOZQ+wCcyPVQvS8tjEHpQ== @@ -960,7 +960,7 @@ "@babel/helper-validator-option" "^7.16.7" "@babel/plugin-transform-typescript" "^7.16.7" -"@babel/runtime@^7.1.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.14.0", "@babel/runtime@^7.16.0", "@babel/runtime@^7.8.4": +"@babel/runtime@^7.1.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.16.0", "@babel/runtime@^7.8.4": version "7.17.2" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941" integrity sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw== @@ -1385,7 +1385,7 @@ axios@^0.24.0: dependencies: follow-redirects "^1.14.4" -babel-loader@^8.2.2, babel-loader@^8.2.3: +babel-loader@^8.2.3: version "8.2.3" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.3.tgz#8986b40f1a64cacfcb4b8429320085ef68b1342d" integrity sha512-n4Zeta8NC3QAsuyiizu0GkmRcQ6clkV9WFUnUf1iXP//IeSKbWjofW3UHyZVwlOB4y039YQKefawyTn64Zwbuw== @@ -1880,25 +1880,6 @@ find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" -flarum-webpack-config@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/flarum-webpack-config/-/flarum-webpack-config-1.0.0.tgz#daf76829d1a71d1af61b5ab6c98e6c61aa6f1b1a" - integrity sha512-T+olIRaIVetPJMP8xlbMnp7tzT/d/ZWI6Mr7twRBdsKbKO7dpKS2+fjnKL6QqNYgOLElT/TWrRSbTp7EiL1yXA== - dependencies: - "@babel/core" "^7.14.3" - "@babel/plugin-proposal-class-properties" "^7.13.0" - "@babel/plugin-proposal-private-methods" "^7.13.0" - "@babel/plugin-transform-object-assign" "^7.12.13" - "@babel/plugin-transform-react-jsx" "^7.14.3" - "@babel/plugin-transform-runtime" "^7.14.3" - "@babel/preset-env" "^7.14.2" - "@babel/preset-react" "^7.13.13" - "@babel/preset-typescript" "^7.13.0" - "@babel/runtime" "^7.14.0" - babel-loader "^8.2.2" - typescript "^4.3.2" - webpack-bundle-analyzer "^4.4.2" - focus-trap@^6.7.1: version "6.7.3" resolved "https://registry.yarnpkg.com/focus-trap/-/focus-trap-6.7.3.tgz#b5dc195b49c90001f08a63134471d1e6dd381ddd" @@ -3101,7 +3082,7 @@ typescript-coverage-report@^0.6.1: semantic-ui-react "^0.88.2" type-coverage-core "^2.17.2" -typescript@^4.3.2, typescript@^4.4.4, typescript@^4.5.4: +typescript@^4.4.4, typescript@^4.5.4: version "4.6.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== @@ -3164,7 +3145,7 @@ watchpack@^2.3.1: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" -webpack-bundle-analyzer@^4.4.2, webpack-bundle-analyzer@^4.5.0: +webpack-bundle-analyzer@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.5.0.tgz#1b0eea2947e73528754a6f9af3e91b2b6e0f79d5" integrity sha512-GUMZlM3SKwS8Z+CKeIFx7CVoHn3dXFcUAjT/dcZQQmfSZGvitPfMob2ipjai7ovFFqPvTqkEZ/leL4O0YOdAYQ== From eb01ab4ede1d7bfbd736c26b1da5b9704b972b75 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 15:32:30 -0400 Subject: [PATCH 33/41] chore: update .yarn-integrity --- node_modules/.yarn-integrity | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity index 0096c3edde..a17a13ba5a 100644 --- a/node_modules/.yarn-integrity +++ b/node_modules/.yarn-integrity @@ -78,6 +78,7 @@ "@types/mithril@^2.0.7", "@types/mithril@^2.0.8", "@types/mithril@^2.0.8", + "@types/mithril@^2.0.8", "@types/punycode@^2.1.0", "@types/pusher-js@^5.1.0", "@types/textarea-caret@^3.0.1", @@ -103,8 +104,9 @@ "flarum-tsconfig@^1.0.2", "flarum-tsconfig@^1.0.2", "flarum-tsconfig@^1.0.2", + "flarum-tsconfig@^1.0.2", "flarum-webpack-config@2.0.0", - "flarum-webpack-config@^1.0.0", + "flarum-webpack-config@^2.0.0", "flarum-webpack-config@^2.0.0", "flarum-webpack-config@^2.0.0", "flarum-webpack-config@^2.0.0", @@ -161,6 +163,7 @@ "typescript-coverage-report@^0.6.1", "typescript-coverage-report@^0.6.1", "typescript-coverage-report@^0.6.1", + "typescript-coverage-report@^0.6.1", "typescript@^4.4.4", "typescript@^4.5.4", "typescript@^4.5.4", @@ -170,6 +173,7 @@ "typescript@^4.5.4", "typescript@^4.5.4", "typescript@^4.5.4", + "typescript@^4.5.4", "webpack-bundle-analyzer@^4.5.0", "webpack-cli@^4.9.1", "webpack-cli@^4.9.1", @@ -220,7 +224,6 @@ "@babel/compat-data@^7.16.4": "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.0.tgz#86850b8597ea6962089770952075dcaabb8dba34", "@babel/compat-data@^7.16.8": "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.0.tgz#86850b8597ea6962089770952075dcaabb8dba34", "@babel/compat-data@^7.17.0": "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.0.tgz#86850b8597ea6962089770952075dcaabb8dba34", - "@babel/core@^7.14.3": "https://registry.yarnpkg.com/@babel/core/-/core-7.17.5.tgz#6cd2e836058c28f06a4ca8ee7ed955bbf37c8225", "@babel/core@^7.16.0": "https://registry.yarnpkg.com/@babel/core/-/core-7.17.5.tgz#6cd2e836058c28f06a4ca8ee7ed955bbf37c8225", "@babel/generator@^7.17.3": "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.3.tgz#a2c30b0c4f89858cb87050c3ffdfd36bdf443200", "@babel/helper-annotate-as-pure@^7.16.7": "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862", @@ -265,7 +268,6 @@ "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz#4eda6d6c2a0aa79c70fa7b6da67763dfe2141050", "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.7.tgz#cc001234dfc139ac45f6bcf801866198c8c72ff9", "@babel/plugin-proposal-async-generator-functions@^7.16.8": "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz#3bdd1ebbe620804ea9416706cd67d60787504bc8", - "@babel/plugin-proposal-class-properties@^7.13.0": "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz#925cad7b3b1a2fcea7e59ecc8eb5954f961f91b0", "@babel/plugin-proposal-class-properties@^7.16.0": "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz#925cad7b3b1a2fcea7e59ecc8eb5954f961f91b0", "@babel/plugin-proposal-class-properties@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz#925cad7b3b1a2fcea7e59ecc8eb5954f961f91b0", "@babel/plugin-proposal-class-static-block@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.17.6.tgz#164e8fd25f0d80fa48c5a4d1438a6629325ad83c", @@ -278,7 +280,6 @@ "@babel/plugin-proposal-object-rest-spread@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.17.3.tgz#d9eb649a54628a51701aef7e0ea3d17e2b9dd390", "@babel/plugin-proposal-optional-catch-binding@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.7.tgz#c623a430674ffc4ab732fd0a0ae7722b67cb74cf", "@babel/plugin-proposal-optional-chaining@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.7.tgz#7cd629564724816c0e8a969535551f943c64c39a", - "@babel/plugin-proposal-private-methods@^7.13.0": "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz#e8df108288555ff259f4527dbe84813aac3a1c50", "@babel/plugin-proposal-private-methods@^7.16.0": "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz#e8df108288555ff259f4527dbe84813aac3a1c50", "@babel/plugin-proposal-private-methods@^7.16.11": "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz#e8df108288555ff259f4527dbe84813aac3a1c50", "@babel/plugin-proposal-private-property-in-object@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.7.tgz#b0b8cef543c2c3d57e59e2c611994861d46a3fce", @@ -321,20 +322,17 @@ "@babel/plugin-transform-modules-umd@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz#23dad479fa585283dbd22215bff12719171e7618", "@babel/plugin-transform-named-capturing-groups-regex@^7.16.8": "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.8.tgz#7f860e0e40d844a02c9dcf9d84965e7dfd666252", "@babel/plugin-transform-new-target@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.7.tgz#9967d89a5c243818e0800fdad89db22c5f514244", - "@babel/plugin-transform-object-assign@^7.12.13": "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.16.7.tgz#5fe08d63dccfeb6a33aa2638faf98e5c584100f8", "@babel/plugin-transform-object-assign@^7.16.0": "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.16.7.tgz#5fe08d63dccfeb6a33aa2638faf98e5c584100f8", "@babel/plugin-transform-object-super@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.7.tgz#ac359cf8d32cf4354d27a46867999490b6c32a94", "@babel/plugin-transform-parameters@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.7.tgz#a1721f55b99b736511cb7e0152f61f17688f331f", "@babel/plugin-transform-property-literals@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.7.tgz#2dadac85155436f22c696c4827730e0fe1057a55", "@babel/plugin-transform-react-display-name@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.16.7.tgz#7b6d40d232f4c0f550ea348593db3b21e2404340", "@babel/plugin-transform-react-jsx-development@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.16.7.tgz#43a00724a3ed2557ed3f276a01a929e6686ac7b8", - "@babel/plugin-transform-react-jsx@^7.14.3": "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.17.3.tgz#eac1565da176ccb1a715dae0b4609858808008c1", "@babel/plugin-transform-react-jsx@^7.16.0": "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.17.3.tgz#eac1565da176ccb1a715dae0b4609858808008c1", "@babel/plugin-transform-react-jsx@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.17.3.tgz#eac1565da176ccb1a715dae0b4609858808008c1", "@babel/plugin-transform-react-pure-annotations@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.16.7.tgz#232bfd2f12eb551d6d7d01d13fe3f86b45eb9c67", "@babel/plugin-transform-regenerator@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.16.7.tgz#9e7576dc476cb89ccc5096fff7af659243b4adeb", "@babel/plugin-transform-reserved-words@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.7.tgz#1d798e078f7c5958eec952059c460b220a63f586", - "@babel/plugin-transform-runtime@^7.14.3": "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.17.0.tgz#0a2e08b5e2b2d95c4b1d3b3371a2180617455b70", "@babel/plugin-transform-runtime@^7.16.0": "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.17.0.tgz#0a2e08b5e2b2d95c4b1d3b3371a2180617455b70", "@babel/plugin-transform-shorthand-properties@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz#e8549ae4afcf8382f711794c0c7b6b934c5fbd2a", "@babel/plugin-transform-spread@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.7.tgz#a303e2122f9f12e0105daeedd0f30fb197d8ff44", @@ -344,16 +342,12 @@ "@babel/plugin-transform-typescript@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.16.8.tgz#591ce9b6b83504903fa9dd3652c357c2ba7a1ee0", "@babel/plugin-transform-unicode-escapes@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.7.tgz#da8717de7b3287a2c6d659750c964f302b31ece3", "@babel/plugin-transform-unicode-regex@^7.16.7": "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.7.tgz#0f7aa4a501198976e25e82702574c34cfebe9ef2", - "@babel/preset-env@^7.14.2": "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.11.tgz#5dd88fd885fae36f88fd7c8342475c9f0abe2982", "@babel/preset-env@^7.16.0": "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.11.tgz#5dd88fd885fae36f88fd7c8342475c9f0abe2982", "@babel/preset-modules@^0.1.5": "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.5.tgz#ef939d6e7f268827e1841638dc6ff95515e115d9", - "@babel/preset-react@^7.13.13": "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.16.7.tgz#4c18150491edc69c183ff818f9f2aecbe5d93852", "@babel/preset-react@^7.16.0": "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.16.7.tgz#4c18150491edc69c183ff818f9f2aecbe5d93852", - "@babel/preset-typescript@^7.13.0": "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.16.7.tgz#ab114d68bb2020afc069cd51b37ff98a046a70b9", "@babel/preset-typescript@^7.16.0": "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.16.7.tgz#ab114d68bb2020afc069cd51b37ff98a046a70b9", "@babel/runtime@^7.1.2": "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941", "@babel/runtime@^7.11.2": "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941", - "@babel/runtime@^7.14.0": "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941", "@babel/runtime@^7.16.0": "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941", "@babel/runtime@^7.8.4": "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941", "@babel/template@^7.16.7": "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155", @@ -434,7 +428,6 @@ "ansi-styles@^3.2.1": "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d", "ansi-styles@^4.1.0": "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937", "axios@^0.24.0": "https://registry.yarnpkg.com/axios/-/axios-0.24.0.tgz#804e6fa1e4b9c5288501dd9dff56a7a0940d20d6", - "babel-loader@^8.2.2": "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.3.tgz#8986b40f1a64cacfcb4b8429320085ef68b1342d", "babel-loader@^8.2.3": "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.3.tgz#8986b40f1a64cacfcb4b8429320085ef68b1342d", "babel-plugin-dynamic-import-node@^2.3.3": "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3", "babel-plugin-polyfill-corejs2@^0.3.0": "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz#440f1b70ccfaabc6b676d196239b138f8a2cfba5", @@ -519,7 +512,6 @@ "find-cache-dir@^3.3.1": "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b", "find-up@^4.0.0": "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19", "find-up@^4.1.0": "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19", - "flarum-webpack-config@^1.0.0": "https://registry.yarnpkg.com/flarum-webpack-config/-/flarum-webpack-config-1.0.0.tgz#daf76829d1a71d1af61b5ab6c98e6c61aa6f1b1a", "focus-trap@^6.7.1": "https://registry.yarnpkg.com/focus-trap/-/focus-trap-6.7.3.tgz#b5dc195b49c90001f08a63134471d1e6dd381ddd", "follow-redirects@^1.14.4": "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7", "frappe-charts@^1.6.2": "https://registry.yarnpkg.com/frappe-charts/-/frappe-charts-1.6.2.tgz#4671a943a8606e5020180fa65c8ea1835c510baf", @@ -738,7 +730,6 @@ "type-fest@^0.8.1": "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d", "typed-styles@^0.0.7": "https://registry.yarnpkg.com/typed-styles/-/typed-styles-0.0.7.tgz#93392a008794c4595119ff62dde6809dbc40a3d9", "typescript-coverage-report@^0.6.1": "https://registry.yarnpkg.com/typescript-coverage-report/-/typescript-coverage-report-0.6.4.tgz#3a7a7724c0f27de50d2a0708c7b7b7088bed2055", - "typescript@^4.3.2": "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4", "typescript@^4.4.4": "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4", "typescript@^4.5.4": "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4", "unicode-canonical-property-names-ecmascript@^2.0.0": "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc", @@ -752,7 +743,6 @@ "warning@^4.0.2": "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3", "warning@^4.0.3": "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3", "watchpack@^2.3.1": "https://registry.yarnpkg.com/watchpack/-/watchpack-2.3.1.tgz#4200d9447b401156eeca7767ee610f8809bc9d25", - "webpack-bundle-analyzer@^4.4.2": "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.5.0.tgz#1b0eea2947e73528754a6f9af3e91b2b6e0f79d5", "webpack-bundle-analyzer@^4.5.0": "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.5.0.tgz#1b0eea2947e73528754a6f9af3e91b2b6e0f79d5", "webpack-cli@^4.9.1": "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.9.2.tgz#77c1adaea020c3f9e2db8aad8ea78d235c83659d", "webpack-merge@^5.7.3": "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61", From d80f79dbc471b1a4497ec1b7b242a928586b4469 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 14 Mar 2022 17:19:30 -0400 Subject: [PATCH 34/41] 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. --- .github/workflows/flarum-akismet-frontend.yml | 1 + .github/workflows/flarum-approval-frontend.yml | 1 + .github/workflows/flarum-core-frontend.yml | 1 + .github/workflows/flarum-embed-frontend.yml | 1 + .github/workflows/flarum-emoji-frontend.yml | 1 + .github/workflows/flarum-flags-frontend.yml | 3 ++- .github/workflows/flarum-likes-frontend.yml | 1 + .github/workflows/flarum-lock-frontend.yml | 1 + .github/workflows/flarum-markdown-frontend.yml | 1 + .github/workflows/flarum-mentions-frontend.yml | 1 + .github/workflows/flarum-nicknames-frontend.yml | 1 + .github/workflows/flarum-package-manager-frontend.yml | 1 + .github/workflows/flarum-pusher-frontend.yml | 1 + .github/workflows/flarum-statistics-frontend.yml | 1 + .github/workflows/flarum-sticky-frontend.yml | 1 + .github/workflows/flarum-subscriptions-frontend.yml | 1 + .github/workflows/flarum-suspend-frontend.yml | 1 + extensions/akismet/.gitattributes | 1 + extensions/approval/.gitattributes | 1 + extensions/bbcode/.gitattributes | 1 + extensions/embed/.gitattributes | 1 + extensions/emoji/.gitattributes | 1 + extensions/flags/.gitattributes | 1 + extensions/lang-english/.gitattributes | 1 + extensions/likes/.gitattributes | 1 + extensions/lock/.gitattributes | 1 + extensions/markdown/.gitattributes | 1 + extensions/mentions/.gitattributes | 1 + extensions/nicknames/.gitattributes | 1 + extensions/package-manager/.gitattributes | 1 + extensions/pusher/.gitattributes | 1 + extensions/statistics/.gitattributes | 1 + extensions/sticky/.gitattributes | 1 + extensions/subscriptions/.gitattributes | 1 + extensions/suspend/.gitattributes | 1 + framework/core/.gitattributes | 1 + 36 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/flarum-akismet-frontend.yml b/.github/workflows/flarum-akismet-frontend.yml index 2c377c52e4..12dd509d8d 100755 --- a/.github/workflows/flarum-akismet-frontend.yml +++ b/.github/workflows/flarum-akismet-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/akismet js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-approval-frontend.yml b/.github/workflows/flarum-approval-frontend.yml index 3853d14db1..8898340466 100755 --- a/.github/workflows/flarum-approval-frontend.yml +++ b/.github/workflows/flarum-approval-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/approval js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-core-frontend.yml b/.github/workflows/flarum-core-frontend.yml index dab8f64217..43090c411c 100755 --- a/.github/workflows/flarum-core-frontend.yml +++ b/.github/workflows/flarum-core-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./framework/core js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-embed-frontend.yml b/.github/workflows/flarum-embed-frontend.yml index 9b201edf2e..e51582a7f6 100755 --- a/.github/workflows/flarum-embed-frontend.yml +++ b/.github/workflows/flarum-embed-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/embed js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-emoji-frontend.yml b/.github/workflows/flarum-emoji-frontend.yml index b8c1e4e675..4d1dc28660 100755 --- a/.github/workflows/flarum-emoji-frontend.yml +++ b/.github/workflows/flarum-emoji-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/emoji js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-flags-frontend.yml b/.github/workflows/flarum-flags-frontend.yml index 195b078cbd..156c001601 100755 --- a/.github/workflows/flarum-flags-frontend.yml +++ b/.github/workflows/flarum-flags-frontend.yml @@ -12,11 +12,12 @@ jobs: with: enable_bundlewatch: false enable_prettier: true - enable_typescript: false + enable_typescript: true frontend_directory: ./extensions/flags/js backend_directory: ./extensions/flags js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-likes-frontend.yml b/.github/workflows/flarum-likes-frontend.yml index 2ad80c3349..bf17a0414c 100755 --- a/.github/workflows/flarum-likes-frontend.yml +++ b/.github/workflows/flarum-likes-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/likes js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-lock-frontend.yml b/.github/workflows/flarum-lock-frontend.yml index 4d44f38fbb..cdf281bfc2 100755 --- a/.github/workflows/flarum-lock-frontend.yml +++ b/.github/workflows/flarum-lock-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/lock js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-markdown-frontend.yml b/.github/workflows/flarum-markdown-frontend.yml index 5d3580c306..8e3688f884 100755 --- a/.github/workflows/flarum-markdown-frontend.yml +++ b/.github/workflows/flarum-markdown-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/markdown js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-mentions-frontend.yml b/.github/workflows/flarum-mentions-frontend.yml index 137125ab5c..b0c0f9dbe9 100755 --- a/.github/workflows/flarum-mentions-frontend.yml +++ b/.github/workflows/flarum-mentions-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/mentions js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-nicknames-frontend.yml b/.github/workflows/flarum-nicknames-frontend.yml index fc0f153063..e26e7d92de 100755 --- a/.github/workflows/flarum-nicknames-frontend.yml +++ b/.github/workflows/flarum-nicknames-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/nicknames js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-package-manager-frontend.yml b/.github/workflows/flarum-package-manager-frontend.yml index 74c5da28d4..ef2abe2d9c 100755 --- a/.github/workflows/flarum-package-manager-frontend.yml +++ b/.github/workflows/flarum-package-manager-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/package-manager js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-pusher-frontend.yml b/.github/workflows/flarum-pusher-frontend.yml index 953caf0531..b4bcef49ce 100755 --- a/.github/workflows/flarum-pusher-frontend.yml +++ b/.github/workflows/flarum-pusher-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/pusher js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-statistics-frontend.yml b/.github/workflows/flarum-statistics-frontend.yml index 2f8f3c6fd5..e39e685ab3 100755 --- a/.github/workflows/flarum-statistics-frontend.yml +++ b/.github/workflows/flarum-statistics-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/statistics js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-sticky-frontend.yml b/.github/workflows/flarum-sticky-frontend.yml index e53db47786..6f1eba871a 100755 --- a/.github/workflows/flarum-sticky-frontend.yml +++ b/.github/workflows/flarum-sticky-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/sticky js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-subscriptions-frontend.yml b/.github/workflows/flarum-subscriptions-frontend.yml index 122f6c58f9..79d8357871 100755 --- a/.github/workflows/flarum-subscriptions-frontend.yml +++ b/.github/workflows/flarum-subscriptions-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/subscriptions js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/.github/workflows/flarum-suspend-frontend.yml b/.github/workflows/flarum-suspend-frontend.yml index 56b3c141b8..3842de0abc 100755 --- a/.github/workflows/flarum-suspend-frontend.yml +++ b/.github/workflows/flarum-suspend-frontend.yml @@ -18,5 +18,6 @@ jobs: backend_directory: ./extensions/suspend js_package_manager: yarn main_git_branch: main + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/extensions/akismet/.gitattributes b/extensions/akismet/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/akismet/.gitattributes +++ b/extensions/akismet/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/approval/.gitattributes b/extensions/approval/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/approval/.gitattributes +++ b/extensions/approval/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/bbcode/.gitattributes b/extensions/bbcode/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/bbcode/.gitattributes +++ b/extensions/bbcode/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/embed/.gitattributes b/extensions/embed/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/embed/.gitattributes +++ b/extensions/embed/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/emoji/.gitattributes b/extensions/emoji/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/emoji/.gitattributes +++ b/extensions/emoji/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/flags/.gitattributes b/extensions/flags/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/flags/.gitattributes +++ b/extensions/flags/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/lang-english/.gitattributes b/extensions/lang-english/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/lang-english/.gitattributes +++ b/extensions/lang-english/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/likes/.gitattributes b/extensions/likes/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/likes/.gitattributes +++ b/extensions/likes/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/lock/.gitattributes b/extensions/lock/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/lock/.gitattributes +++ b/extensions/lock/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/markdown/.gitattributes b/extensions/markdown/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/markdown/.gitattributes +++ b/extensions/markdown/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/mentions/.gitattributes b/extensions/mentions/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/mentions/.gitattributes +++ b/extensions/mentions/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/nicknames/.gitattributes b/extensions/nicknames/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/nicknames/.gitattributes +++ b/extensions/nicknames/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/package-manager/.gitattributes b/extensions/package-manager/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/package-manager/.gitattributes +++ b/extensions/package-manager/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/pusher/.gitattributes b/extensions/pusher/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/pusher/.gitattributes +++ b/extensions/pusher/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/statistics/.gitattributes b/extensions/statistics/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/statistics/.gitattributes +++ b/extensions/statistics/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/sticky/.gitattributes b/extensions/sticky/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/sticky/.gitattributes +++ b/extensions/sticky/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/subscriptions/.gitattributes b/extensions/subscriptions/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/subscriptions/.gitattributes +++ b/extensions/subscriptions/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/extensions/suspend/.gitattributes b/extensions/suspend/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/extensions/suspend/.gitattributes +++ b/extensions/suspend/.gitattributes @@ -12,6 +12,7 @@ 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 diff --git a/framework/core/.gitattributes b/framework/core/.gitattributes index b9a08e27dd..638a3ba897 100644 --- a/framework/core/.gitattributes +++ b/framework/core/.gitattributes @@ -12,6 +12,7 @@ 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 From 3ddec0a955e2f3166503cce5c26a19be55a4619c Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Fri, 18 Mar 2022 14:09:06 -0400 Subject: [PATCH 35/41] chore: use type imports --- .gitattributes | 20 +++++++++++++++++++ extensions/akismet/.gitattributes | 20 ------------------- extensions/akismet/js/src/forum/index.ts | 6 +++--- extensions/approval/.gitattributes | 20 ------------------- extensions/bbcode/.gitattributes | 20 ------------------- extensions/embed/.gitattributes | 20 ------------------- extensions/emoji/.gitattributes | 20 ------------------- extensions/flags/.gitattributes | 20 ------------------- extensions/flags/js/src/forum/models/Flag.ts | 4 ++-- extensions/lang-english/.gitattributes | 20 ------------------- extensions/likes/.gitattributes | 20 ------------------- extensions/lock/.gitattributes | 20 ------------------- extensions/markdown/.gitattributes | 20 ------------------- extensions/mentions/.gitattributes | 20 ------------------- extensions/nicknames/.gitattributes | 20 ------------------- extensions/package-manager/.gitattributes | 20 ------------------- extensions/pusher/.gitattributes | 20 ------------------- extensions/pusher/js/src/forum/index.ts | 4 ++-- extensions/statistics/.gitattributes | 20 ------------------- extensions/sticky/.gitattributes | 20 ------------------- extensions/subscriptions/.gitattributes | 20 ------------------- extensions/suspend/.gitattributes | 20 ------------------- extensions/tags/.gitattributes | 19 ------------------ .../tags/js/dist-typings/@types/shims.d.ts | 4 ++-- extensions/tags/js/src/@types/shims.d.ts | 4 ++-- extensions/tags/js/src/common/models/Tag.ts | 2 +- .../tags/js/src/forum/states/TagListState.ts | 2 +- framework/core/.gitattributes | 20 ------------------- .../dist-typings/admin/AdminApplication.d.ts | 2 +- .../js/src/admin/components/DashboardPage.tsx | 2 +- .../src/admin/components/DashboardWidget.tsx | 2 +- .../core/js/src/forum/ForumApplication.ts | 6 +++--- .../forum/components/DiscussionListItem.tsx | 6 +++--- .../DiscussionRenamedNotification.tsx | 4 ++-- .../js/src/forum/components/Notification.tsx | 4 ++-- .../core/js/src/forum/components/Post.tsx | 4 ++-- framework/core/js/src/forum/routes.ts | 4 ++-- .../js/src/forum/states/PostStreamState.ts | 4 ++-- js-packages/tsconfig/.gitattributes | 16 --------------- js-packages/webpack-config/.gitattributes | 3 --- php-packages/testing/.gitattributes | 15 -------------- 41 files changed, 52 insertions(+), 465 deletions(-) create mode 100644 .gitattributes delete mode 100644 extensions/akismet/.gitattributes delete mode 100644 extensions/approval/.gitattributes delete mode 100644 extensions/bbcode/.gitattributes delete mode 100644 extensions/embed/.gitattributes delete mode 100644 extensions/emoji/.gitattributes delete mode 100644 extensions/flags/.gitattributes delete mode 100644 extensions/lang-english/.gitattributes delete mode 100644 extensions/likes/.gitattributes delete mode 100644 extensions/lock/.gitattributes delete mode 100644 extensions/markdown/.gitattributes delete mode 100644 extensions/mentions/.gitattributes delete mode 100644 extensions/nicknames/.gitattributes delete mode 100644 extensions/package-manager/.gitattributes delete mode 100644 extensions/pusher/.gitattributes delete mode 100644 extensions/statistics/.gitattributes delete mode 100644 extensions/sticky/.gitattributes delete mode 100644 extensions/subscriptions/.gitattributes delete mode 100644 extensions/suspend/.gitattributes delete mode 100644 extensions/tags/.gitattributes delete mode 100644 framework/core/.gitattributes delete mode 100644 js-packages/tsconfig/.gitattributes delete mode 100644 js-packages/webpack-config/.gitattributes delete mode 100644 php-packages/testing/.gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..73949706c0 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/extensions/akismet/.gitattributes b/extensions/akismet/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/akismet/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/akismet/js/src/forum/index.ts b/extensions/akismet/js/src/forum/index.ts index 7b3a31b5de..5ed66325c7 100644 --- a/extensions/akismet/js/src/forum/index.ts +++ b/extensions/akismet/js/src/forum/index.ts @@ -1,11 +1,11 @@ import { extend, override } from 'flarum/common/extend'; 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 CommentPost from 'flarum/forum/components/CommentPost'; -import ItemList from 'flarum/common/utils/ItemList'; -import Post from 'flarum/common/models/Post'; -import Mithril from 'mithril'; +import type Mithril from 'mithril'; app.initializers.add('flarum-akismet', () => { extend(PostControls, 'destructiveControls', function (items: ItemList, post: Post) { diff --git a/extensions/approval/.gitattributes b/extensions/approval/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/approval/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/bbcode/.gitattributes b/extensions/bbcode/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/bbcode/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/embed/.gitattributes b/extensions/embed/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/embed/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/emoji/.gitattributes b/extensions/emoji/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/emoji/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/flags/.gitattributes b/extensions/flags/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/flags/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/flags/js/src/forum/models/Flag.ts b/extensions/flags/js/src/forum/models/Flag.ts index c00f16e8da..1ebbe35816 100644 --- a/extensions/flags/js/src/forum/models/Flag.ts +++ b/extensions/flags/js/src/forum/models/Flag.ts @@ -1,6 +1,6 @@ import Model from 'flarum/common/Model'; -import Post from 'flarum/common/models/Post'; -import User from 'flarum/common/models/User'; +import type Post from 'flarum/common/models/Post'; +import type User from 'flarum/common/models/User'; export default class Flag extends Model { type() { diff --git a/extensions/lang-english/.gitattributes b/extensions/lang-english/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/lang-english/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/likes/.gitattributes b/extensions/likes/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/likes/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/lock/.gitattributes b/extensions/lock/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/lock/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/markdown/.gitattributes b/extensions/markdown/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/markdown/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/mentions/.gitattributes b/extensions/mentions/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/mentions/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/nicknames/.gitattributes b/extensions/nicknames/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/nicknames/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/package-manager/.gitattributes b/extensions/package-manager/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/package-manager/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/pusher/.gitattributes b/extensions/pusher/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/pusher/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/pusher/js/src/forum/index.ts b/extensions/pusher/js/src/forum/index.ts index ca70012761..5391fbec92 100644 --- a/extensions/pusher/js/src/forum/index.ts +++ b/extensions/pusher/js/src/forum/index.ts @@ -6,8 +6,8 @@ import DiscussionPage from 'flarum/forum/components/DiscussionPage'; import IndexPage from 'flarum/forum/components/IndexPage'; import Button from 'flarum/common/components/Button'; import ItemList from 'flarum/common/utils/ItemList'; -import { Children } from 'mithril'; -import Tag from 'flarum/tags/common/models/Tag'; +import type { Children } from 'mithril'; +import type Tag from 'flarum/tags/common/models/Tag'; export type PusherBinding = { channels: { diff --git a/extensions/statistics/.gitattributes b/extensions/statistics/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/statistics/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/sticky/.gitattributes b/extensions/sticky/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/sticky/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/subscriptions/.gitattributes b/extensions/subscriptions/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/subscriptions/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/suspend/.gitattributes b/extensions/suspend/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/extensions/suspend/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/extensions/tags/.gitattributes b/extensions/tags/.gitattributes deleted file mode 100644 index b9a08e27dd..0000000000 --- a/extensions/tags/.gitattributes +++ /dev/null @@ -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 diff --git a/extensions/tags/js/dist-typings/@types/shims.d.ts b/extensions/tags/js/dist-typings/@types/shims.d.ts index 50a1fb04df..1a41c76a3b 100644 --- a/extensions/tags/js/dist-typings/@types/shims.d.ts +++ b/extensions/tags/js/dist-typings/@types/shims.d.ts @@ -1,5 +1,5 @@ -import Tag from "../common/models/Tag"; -import TagListState from "../forum/states/TagListState"; +import type Tag from "../common/models/Tag"; +import type TagListState from "../forum/states/TagListState"; declare module 'flarum/forum/routes' { export interface ForumRoutes { diff --git a/extensions/tags/js/src/@types/shims.d.ts b/extensions/tags/js/src/@types/shims.d.ts index 50a1fb04df..1a41c76a3b 100644 --- a/extensions/tags/js/src/@types/shims.d.ts +++ b/extensions/tags/js/src/@types/shims.d.ts @@ -1,5 +1,5 @@ -import Tag from "../common/models/Tag"; -import TagListState from "../forum/states/TagListState"; +import type Tag from "../common/models/Tag"; +import type TagListState from "../forum/states/TagListState"; declare module 'flarum/forum/routes' { export interface ForumRoutes { diff --git a/extensions/tags/js/src/common/models/Tag.ts b/extensions/tags/js/src/common/models/Tag.ts index 0147a9722b..d68c8698ec 100644 --- a/extensions/tags/js/src/common/models/Tag.ts +++ b/extensions/tags/js/src/common/models/Tag.ts @@ -1,6 +1,6 @@ import computed from 'flarum/common/utils/computed'; import Model from 'flarum/common/Model'; -import Discussion from 'flarum/common/models/Discussion'; +import type Discussion from 'flarum/common/models/Discussion'; export default class Tag extends Model { name() { diff --git a/extensions/tags/js/src/forum/states/TagListState.ts b/extensions/tags/js/src/forum/states/TagListState.ts index c6acef851a..43d220875a 100644 --- a/extensions/tags/js/src/forum/states/TagListState.ts +++ b/extensions/tags/js/src/forum/states/TagListState.ts @@ -1,5 +1,5 @@ import app from "flarum/forum/app"; -import Tag from "../../common/models/Tag"; +import type Tag from "../../common/models/Tag"; export default class TagListState { loadedIncludes = new Set(); diff --git a/framework/core/.gitattributes b/framework/core/.gitattributes deleted file mode 100644 index 638a3ba897..0000000000 --- a/framework/core/.gitattributes +++ /dev/null @@ -1,20 +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/* -diff -js/dist-typings/* linguist-generated -js/yarn.lock -diff -js/package-lock.json -diff - -* text=auto eol=lf diff --git a/framework/core/js/dist-typings/admin/AdminApplication.d.ts b/framework/core/js/dist-typings/admin/AdminApplication.d.ts index 05f98124dc..5cc65c7e4c 100644 --- a/framework/core/js/dist-typings/admin/AdminApplication.d.ts +++ b/framework/core/js/dist-typings/admin/AdminApplication.d.ts @@ -1,4 +1,4 @@ -import { AdminRoutes } from './routes'; +import type { AdminRoutes } from './routes'; import Application from '../common/Application'; import ExtensionData from './utils/ExtensionData'; export declare type Extension = { diff --git a/framework/core/js/src/admin/components/DashboardPage.tsx b/framework/core/js/src/admin/components/DashboardPage.tsx index f4fa48c036..59ecd5cf20 100644 --- a/framework/core/js/src/admin/components/DashboardPage.tsx +++ b/framework/core/js/src/admin/components/DashboardPage.tsx @@ -3,7 +3,7 @@ import StatusWidget from './StatusWidget'; import ExtensionsWidget from './ExtensionsWidget'; import ItemList from '../../common/utils/ItemList'; import AdminPage from './AdminPage'; -import { Children } from 'mithril'; +import type { Children } from 'mithril'; export default class DashboardPage extends AdminPage { headerInfo() { diff --git a/framework/core/js/src/admin/components/DashboardWidget.tsx b/framework/core/js/src/admin/components/DashboardWidget.tsx index 62d116ed06..792f505485 100644 --- a/framework/core/js/src/admin/components/DashboardWidget.tsx +++ b/framework/core/js/src/admin/components/DashboardWidget.tsx @@ -1,4 +1,4 @@ -import { Children, Vnode } from 'mithril'; +import type { Children, Vnode } from 'mithril'; import Component, { ComponentAttrs } from '../../common/Component'; export interface IDashboardWidgetAttrs extends ComponentAttrs {} diff --git a/framework/core/js/src/forum/ForumApplication.ts b/framework/core/js/src/forum/ForumApplication.ts index ccac9dafde..8b30f7b595 100644 --- a/framework/core/js/src/forum/ForumApplication.ts +++ b/framework/core/js/src/forum/ForumApplication.ts @@ -22,9 +22,9 @@ import isSafariMobile from './utils/isSafariMobile'; import type Notification from './components/Notification'; import type Post from './components/Post'; -import Discussion from '../common/models/Discussion'; -import NotificationModel from '../common/models/Notification'; -import PostModel from '../common/models/Post'; +import type Discussion from '../common/models/Discussion'; +import type NotificationModel from '../common/models/Notification'; +import type PostModel from '../common/models/Post'; import extractText from '../common/utils/extractText'; export default class ForumApplication extends Application { diff --git a/framework/core/js/src/forum/components/DiscussionListItem.tsx b/framework/core/js/src/forum/components/DiscussionListItem.tsx index 4f5db09723..20e2946c82 100644 --- a/framework/core/js/src/forum/components/DiscussionListItem.tsx +++ b/framework/core/js/src/forum/components/DiscussionListItem.tsx @@ -17,9 +17,9 @@ import classList from '../../common/utils/classList'; import DiscussionPage from './DiscussionPage'; import escapeRegExp from '../../common/utils/escapeRegExp'; import Tooltip from '../../common/components/Tooltip'; -import Discussion from '../../common/models/Discussion'; -import Mithril from 'mithril'; -import { DiscussionListParams } from '../states/DiscussionListState'; +import type Discussion from '../../common/models/Discussion'; +import type Mithril from 'mithril'; +import type { DiscussionListParams } from '../states/DiscussionListState'; export interface IDiscussionListItemAttrs extends ComponentAttrs { discussion: Discussion; diff --git a/framework/core/js/src/forum/components/DiscussionRenamedNotification.tsx b/framework/core/js/src/forum/components/DiscussionRenamedNotification.tsx index 37d96e6fb6..1c1cc9dd0f 100644 --- a/framework/core/js/src/forum/components/DiscussionRenamedNotification.tsx +++ b/framework/core/js/src/forum/components/DiscussionRenamedNotification.tsx @@ -1,4 +1,4 @@ -import Discussion from '../../common/models/Discussion'; +import type Discussion from '../../common/models/Discussion'; import app from '../../forum/app'; import Notification from './Notification'; @@ -31,6 +31,6 @@ export default class DiscussionRenamedNotification extends Notification { } excerpt() { - return ''; + return null; } } diff --git a/framework/core/js/src/forum/components/Notification.tsx b/framework/core/js/src/forum/components/Notification.tsx index 4a45b01173..a0acdac33e 100644 --- a/framework/core/js/src/forum/components/Notification.tsx +++ b/framework/core/js/src/forum/components/Notification.tsx @@ -1,5 +1,5 @@ import app from '../../forum/app'; -import NotificationModel from '../../common/models/Notification'; +import type NotificationModel from '../../common/models/Notification'; import Component, { ComponentAttrs } from '../../common/Component'; import avatar from '../../common/helpers/avatar'; import icon from '../../common/helpers/icon'; @@ -7,7 +7,7 @@ import humanTime from '../../common/helpers/humanTime'; import Button from '../../common/components/Button'; import Link from '../../common/components/Link'; import classList from '../../common/utils/classList'; -import Mithril from 'mithril'; +import type Mithril from 'mithril'; export interface INotificationAttrs extends ComponentAttrs { notification: NotificationModel; diff --git a/framework/core/js/src/forum/components/Post.tsx b/framework/core/js/src/forum/components/Post.tsx index e29560d338..a9683216a9 100644 --- a/framework/core/js/src/forum/components/Post.tsx +++ b/framework/core/js/src/forum/components/Post.tsx @@ -5,9 +5,9 @@ import Dropdown from '../../common/components/Dropdown'; import PostControls from '../utils/PostControls'; import listItems from '../../common/helpers/listItems'; import ItemList from '../../common/utils/ItemList'; -import PostModel from '../../common/models/Post'; +import type PostModel from '../../common/models/Post'; import LoadingIndicator from '../../common/components/LoadingIndicator'; -import Mithril from 'mithril'; +import type Mithril from 'mithril'; export interface IPostAttrs extends ComponentAttrs { post: PostModel; diff --git a/framework/core/js/src/forum/routes.ts b/framework/core/js/src/forum/routes.ts index 43b61bc72f..497a89b863 100644 --- a/framework/core/js/src/forum/routes.ts +++ b/framework/core/js/src/forum/routes.ts @@ -7,8 +7,8 @@ import SettingsPage from './components/SettingsPage'; import NotificationsPage from './components/NotificationsPage'; import DiscussionPageResolver from './resolvers/DiscussionPageResolver'; import Discussion from '../common/models/Discussion'; -import Post from '../common/models/Post'; -import User from '../common/models/User'; +import type Post from '../common/models/Post'; +import type User from '../common/models/User'; /** * Helper functions to generate URLs to form pages. diff --git a/framework/core/js/src/forum/states/PostStreamState.ts b/framework/core/js/src/forum/states/PostStreamState.ts index 0eb83f100c..0a3a713003 100644 --- a/framework/core/js/src/forum/states/PostStreamState.ts +++ b/framework/core/js/src/forum/states/PostStreamState.ts @@ -1,8 +1,8 @@ import app from '../../forum/app'; import { throttle } from 'throttle-debounce'; import anchorScroll from '../../common/utils/anchorScroll'; -import Discussion from '../../common/models/Discussion'; -import Post from '../../common/models/Post'; +import type Discussion from '../../common/models/Discussion'; +import type Post from '../../common/models/Post'; export default class PostStreamState { /** diff --git a/js-packages/tsconfig/.gitattributes b/js-packages/tsconfig/.gitattributes deleted file mode 100644 index 2828cc8990..0000000000 --- a/js-packages/tsconfig/.gitattributes +++ /dev/null @@ -1,16 +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 - -* text=auto eol=lf diff --git a/js-packages/webpack-config/.gitattributes b/js-packages/webpack-config/.gitattributes deleted file mode 100644 index fc939a7570..0000000000 --- a/js-packages/webpack-config/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored -/.yarn/releases/** binary -/.yarn/plugins/** binary diff --git a/php-packages/testing/.gitattributes b/php-packages/testing/.gitattributes deleted file mode 100644 index 61036520ce..0000000000 --- a/php-packages/testing/.gitattributes +++ /dev/null @@ -1,15 +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 - -* text=auto eol=lf From af3e293c7aeeeea7b0062a8ac104f84cebbb1cc5 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Fri, 18 Mar 2022 14:42:28 -0400 Subject: [PATCH 36/41] fix: broader gitattributes --- .gitattributes | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitattributes b/.gitattributes index 73949706c0..71b028f4d2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,20 +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 +**/.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 +**/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 +**/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 From f9ad98e23cf8493cde754dc9b6be9e4ce400b4e1 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Fri, 18 Mar 2022 15:10:58 -0400 Subject: [PATCH 37/41] chore: run flarum-cli audit infra --monorepo --fix --- .github/workflows/flarum-tags-frontend.yml | 2 +- extensions/akismet/js/package.json | 2 +- extensions/flags/js/package.json | 2 +- extensions/package-manager/js/package.json | 2 +- extensions/pusher/js/package.json | 2 +- extensions/statistics/js/package.json | 2 +- extensions/tags/js/package.json | 2 +- extensions/tags/js/src/common/{index.js => index.ts} | 0 framework/core/js/package.json | 2 +- 9 files changed, 8 insertions(+), 8 deletions(-) rename extensions/tags/js/src/common/{index.js => index.ts} (100%) diff --git a/.github/workflows/flarum-tags-frontend.yml b/.github/workflows/flarum-tags-frontend.yml index e7aa25345f..39cb26556a 100755 --- a/.github/workflows/flarum-tags-frontend.yml +++ b/.github/workflows/flarum-tags-frontend.yml @@ -12,7 +12,7 @@ jobs: with: enable_bundlewatch: false enable_prettier: false - enable_typescript: false + enable_typescript: true frontend_directory: ./extensions/tags/js backend_directory: ./extensions/tags diff --git a/extensions/akismet/js/package.json b/extensions/akismet/js/package.json index 2a12c82f5c..837e21151f 100644 --- a/extensions/akismet/js/package.json +++ b/extensions/akismet/js/package.json @@ -12,7 +12,7 @@ "check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings-coverage": "typescript-coverage-report", "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'" }, "devDependencies": { diff --git a/extensions/flags/js/package.json b/extensions/flags/js/package.json index 498480bd88..4219f312d4 100644 --- a/extensions/flags/js/package.json +++ b/extensions/flags/js/package.json @@ -21,7 +21,7 @@ "format-check": "prettier --check src", "analyze": "cross-env ANALYZER=true yarn run build", "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-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'" diff --git a/extensions/package-manager/js/package.json b/extensions/package-manager/js/package.json index 032630b9b9..6978f7a99f 100755 --- a/extensions/package-manager/js/package.json +++ b/extensions/package-manager/js/package.json @@ -21,7 +21,7 @@ "ci": "yarn install --immutable --immutable-cache", "analyze": "cross-env ANALYZER=true yarn run build", "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-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'" diff --git a/extensions/pusher/js/package.json b/extensions/pusher/js/package.json index edc74736f9..0dfc7cdbcc 100644 --- a/extensions/pusher/js/package.json +++ b/extensions/pusher/js/package.json @@ -10,7 +10,7 @@ "format": "prettier --write src", "format-check": "prettier --check src", "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-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'" diff --git a/extensions/statistics/js/package.json b/extensions/statistics/js/package.json index f6a144394c..e1df51a54c 100644 --- a/extensions/statistics/js/package.json +++ b/extensions/statistics/js/package.json @@ -24,7 +24,7 @@ "format-check": "prettier --check src", "analyze": "cross-env ANALYZER=true yarn run build", "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-coverage": "typescript-coverage-report", "ci": "yarn install --immutable --immutable-cache", diff --git a/extensions/tags/js/package.json b/extensions/tags/js/package.json index c5d1fc40bd..7ecdab55f0 100644 --- a/extensions/tags/js/package.json +++ b/extensions/tags/js/package.json @@ -10,7 +10,7 @@ "build": "webpack --mode production", "analyze": "cross-env ANALYZER=true yarn run build", "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'", "check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings-coverage": "typescript-coverage-report" diff --git a/extensions/tags/js/src/common/index.js b/extensions/tags/js/src/common/index.ts similarity index 100% rename from extensions/tags/js/src/common/index.js rename to extensions/tags/js/src/common/index.ts diff --git a/framework/core/js/package.json b/framework/core/js/package.json index c038f2eda6..259d242ea6 100644 --- a/framework/core/js/package.json +++ b/framework/core/js/package.json @@ -44,7 +44,7 @@ "format": "prettier --write src", "format-check": "prettier --check src", "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'", "check-typings": "tsc --noEmit --emitDeclarationOnly false", "check-typings-coverage": "typescript-coverage-report" From e95f7f4b43ff3e4bb98df91ce47b0de2dcf98e02 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Fri, 18 Mar 2022 15:49:10 -0400 Subject: [PATCH 38/41] feat: make `app.data` typings extensible --- .../dist-typings/admin/AdminApplication.d.ts | 19 +++++++-------- .../js/dist-typings/common/Application.d.ts | 23 ++++++++++--------- .../dist-typings/forum/ForumApplication.d.ts | 11 +++++---- .../core/js/src/admin/AdminApplication.ts | 14 ++++++----- framework/core/js/src/common/Application.tsx | 18 ++++++++------- .../core/js/src/forum/ForumApplication.ts | 6 ++++- 6 files changed, 52 insertions(+), 39 deletions(-) diff --git a/framework/core/js/dist-typings/admin/AdminApplication.d.ts b/framework/core/js/dist-typings/admin/AdminApplication.d.ts index 5cc65c7e4c..018e59b962 100644 --- a/framework/core/js/dist-typings/admin/AdminApplication.d.ts +++ b/framework/core/js/dist-typings/admin/AdminApplication.d.ts @@ -1,5 +1,5 @@ -import type { AdminRoutes } from './routes'; -import Application from '../common/Application'; +import { AdminRoutes } from './routes'; +import Application, { ApplicationData } from '../common/Application'; import ExtensionData from './utils/ExtensionData'; export declare type Extension = { id: string; @@ -26,6 +26,13 @@ export declare type Extension = { }; }; }; +export interface AdminApplicationData extends ApplicationData { + extensions: Record; + settings: Record; + modelStatistics: Record; +} export default class AdminApplication extends Application { extensionData: ExtensionData; extensionCategories: { @@ -46,13 +53,7 @@ export default class AdminApplication extends Application { * * @inheritdoc */ - data: Application['data'] & { - extensions: Record; - settings: Record; - modelStatistics: Record; - }; + data: AdminApplicationData; route: typeof Application.prototype.route & AdminRoutes; constructor(); /** diff --git a/framework/core/js/dist-typings/common/Application.d.ts b/framework/core/js/dist-typings/common/Application.d.ts index c057a44ede..632bace88d 100644 --- a/framework/core/js/dist-typings/common/Application.d.ts +++ b/framework/core/js/dist-typings/common/Application.d.ts @@ -91,6 +91,17 @@ export interface RouteResolver): Mithril.Children; } +export interface ApplicationData { + apiDocument: ApiPayload | null; + locale: string; + locales: Record; + resources: SavedModelData[]; + session: { + userId: number; + csrfToken: string; + }; + [key: string]: unknown; +} /** * The `App` class provides a container for an application, as well as various * utilities for the rest of the app to use. @@ -166,17 +177,7 @@ export default class Application { * An object that manages the state of the navigation drawer. */ drawer: Drawer; - data: { - apiDocument: ApiPayload | null; - locale: string; - locales: Record; - resources: SavedModelData[]; - session: { - userId: number; - csrfToken: string; - }; - [key: string]: unknown; - }; + data: ApplicationData; private _title; private _titleCount; private set title(value); diff --git a/framework/core/js/dist-typings/forum/ForumApplication.d.ts b/framework/core/js/dist-typings/forum/ForumApplication.d.ts index 58c54774f5..79a24cec6f 100644 --- a/framework/core/js/dist-typings/forum/ForumApplication.d.ts +++ b/framework/core/js/dist-typings/forum/ForumApplication.d.ts @@ -1,16 +1,18 @@ import History from './utils/History'; import Pane from './utils/Pane'; import { ForumRoutes } from './routes'; -import Application from '../common/Application'; +import Application, { ApplicationData } 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'; -import Discussion from '../common/models/Discussion'; -import NotificationModel from '../common/models/Notification'; -import PostModel from '../common/models/Post'; +import type Discussion from '../common/models/Discussion'; +import type NotificationModel from '../common/models/Notification'; +import type PostModel from '../common/models/Post'; +export interface ForumApplicationData extends ApplicationData { +} export default class ForumApplication extends Application { /** * A map of notification types to their components. @@ -56,6 +58,7 @@ export default class ForumApplication extends Application { */ discussions: DiscussionListState; route: typeof Application.prototype.route & ForumRoutes; + data: ForumApplicationData; constructor(); /** * @inheritdoc diff --git a/framework/core/js/src/admin/AdminApplication.ts b/framework/core/js/src/admin/AdminApplication.ts index a824d594a2..62fa121b54 100644 --- a/framework/core/js/src/admin/AdminApplication.ts +++ b/framework/core/js/src/admin/AdminApplication.ts @@ -1,7 +1,7 @@ import HeaderPrimary from './components/HeaderPrimary'; import HeaderSecondary from './components/HeaderSecondary'; import routes, { AdminRoutes } from './routes'; -import Application from '../common/Application'; +import Application, { ApplicationData } from '../common/Application'; import Navigation from '../common/components/Navigation'; import AdminNav from './components/AdminNav'; import ExtensionData from './utils/ExtensionData'; @@ -32,6 +32,12 @@ export type Extension = { }; }; +export interface AdminApplicationData extends ApplicationData { + extensions: Record; + settings: Record; + modelStatistics: Record; +} + export default class AdminApplication extends Application { extensionData = new ExtensionData(); @@ -58,11 +64,7 @@ export default class AdminApplication extends Application { * @inheritdoc */ - data!: Application['data'] & { - extensions: Record; - settings: Record; - modelStatistics: Record; - }; + data!: AdminApplicationData; route: typeof Application.prototype.route & AdminRoutes; diff --git a/framework/core/js/src/common/Application.tsx b/framework/core/js/src/common/Application.tsx index 4e54308b32..8d1827b245 100644 --- a/framework/core/js/src/common/Application.tsx +++ b/framework/core/js/src/common/Application.tsx @@ -123,6 +123,15 @@ export interface RouteResolver< render?(this: this, vnode: Mithril.Vnode): Mithril.Children; } +export interface ApplicationData { + apiDocument: ApiPayload | null; + locale: string; + locales: Record; + resources: SavedModelData[]; + session: { userId: number; csrfToken: string }; + [key: string]: unknown; +}; + /** * The `App` class provides a container for an application, as well as various * utilities for the rest of the app to use. @@ -218,14 +227,7 @@ export default class Application { */ drawer!: Drawer; - data!: { - apiDocument: ApiPayload | null; - locale: string; - locales: Record; - resources: SavedModelData[]; - session: { userId: number; csrfToken: string }; - [key: string]: unknown; - }; + data!: ApplicationData; private _title: string = ''; private _titleCount: number = 0; diff --git a/framework/core/js/src/forum/ForumApplication.ts b/framework/core/js/src/forum/ForumApplication.ts index 8b30f7b595..e5329b33be 100644 --- a/framework/core/js/src/forum/ForumApplication.ts +++ b/framework/core/js/src/forum/ForumApplication.ts @@ -12,7 +12,7 @@ import CommentPost from './components/CommentPost'; import DiscussionRenamedPost from './components/DiscussionRenamedPost'; import routes, { ForumRoutes, makeRouteHelpers } from './routes'; import alertEmailConfirmation from './utils/alertEmailConfirmation'; -import Application from '../common/Application'; +import Application, { ApplicationData } from '../common/Application'; import Navigation from '../common/components/Navigation'; import NotificationListState from './states/NotificationListState'; import GlobalSearchState from './states/GlobalSearchState'; @@ -27,6 +27,8 @@ import type NotificationModel from '../common/models/Notification'; import type PostModel from '../common/models/Post'; import extractText from '../common/utils/extractText'; +export interface ForumApplicationData extends ApplicationData {} + export default class ForumApplication extends Application { /** * A map of notification types to their components. @@ -78,6 +80,8 @@ export default class ForumApplication extends Application { route: typeof Application.prototype.route & ForumRoutes; + data!: ForumApplicationData; + constructor() { super(); From a4c875c3369d3b3b7c49d862208e4a89db41fe79 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 19 Mar 2022 17:28:12 -0400 Subject: [PATCH 39/41] chore(core): format --- framework/core/js/src/common/Application.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/js/src/common/Application.tsx b/framework/core/js/src/common/Application.tsx index 8d1827b245..6dd4fe9228 100644 --- a/framework/core/js/src/common/Application.tsx +++ b/framework/core/js/src/common/Application.tsx @@ -130,7 +130,7 @@ export interface ApplicationData { resources: SavedModelData[]; session: { userId: number; csrfToken: string }; [key: string]: unknown; -}; +} /** * The `App` class provides a container for an application, as well as various From e0b20d410fb7b1c473f84b7ade76494e54ed0ca1 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 20 Mar 2022 22:13:17 -0400 Subject: [PATCH 40/41] chore: boost tags TypeScript coverage --- .../utils/{sortTags.js => sortTags.tsx} | 10 +- ...cussionModal.js => TagDiscussionModal.tsx} | 115 ++++++++++-------- .../tags/js/src/forum/states/TagListState.ts | 2 +- 3 files changed, 73 insertions(+), 54 deletions(-) rename extensions/tags/js/src/common/utils/{sortTags.js => sortTags.tsx} (81%) rename extensions/tags/js/src/forum/components/{TagDiscussionModal.js => TagDiscussionModal.tsx} (77%) diff --git a/extensions/tags/js/src/common/utils/sortTags.js b/extensions/tags/js/src/common/utils/sortTags.tsx similarity index 81% rename from extensions/tags/js/src/common/utils/sortTags.js rename to extensions/tags/js/src/common/utils/sortTags.tsx index 84462e8806..7d9090f70f 100644 --- a/extensions/tags/js/src/common/utils/sortTags.js +++ b/extensions/tags/js/src/common/utils/sortTags.tsx @@ -1,4 +1,6 @@ -export default function sortTags(tags) { +import Tag from "../models/Tag"; + +export default function sortTags(tags: Tag[]) { return tags.slice(0).sort((a, b) => { const aPos = a.position(); const bPos = b.position(); @@ -25,16 +27,16 @@ export default function sortTags(tags) { // If they are both child tags, then we will compare the positions of their // parents. else if (aParent && bParent) - return aParent.position() - bParent.position(); + return aParent.position()! - bParent.position()!; // If we are comparing a child tag with its parent, then we let the parent // come first. If we are comparing an unrelated parent/child, then we // compare both of the parents. else if (aParent) - return aParent === b ? 1 : aParent.position() - bPos; + return aParent === b ? 1 : aParent.position()! - bPos; else if (bParent) - return bParent === a ? -1 : aPos - bParent.position(); + return bParent === a ? -1 : aPos - bParent.position()!; return 0; }); diff --git a/extensions/tags/js/src/forum/components/TagDiscussionModal.js b/extensions/tags/js/src/forum/components/TagDiscussionModal.tsx similarity index 77% rename from extensions/tags/js/src/forum/components/TagDiscussionModal.js rename to extensions/tags/js/src/forum/components/TagDiscussionModal.tsx index 1d580f7214..814522e8e8 100644 --- a/extensions/tags/js/src/forum/components/TagDiscussionModal.js +++ b/extensions/tags/js/src/forum/components/TagDiscussionModal.tsx @@ -1,4 +1,6 @@ -import Modal from 'flarum/common/components/Modal'; +import app from 'flarum/forum/app'; +import type Mithril from 'mithril'; +import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal'; import DiscussionPage from 'flarum/forum/components/DiscussionPage'; import Button from 'flarum/common/components/Button'; import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; @@ -7,31 +9,43 @@ import classList from 'flarum/common/utils/classList'; import extractText from 'flarum/common/utils/extractText'; import KeyboardNavigatable from 'flarum/forum/utils/KeyboardNavigatable'; import Stream from 'flarum/common/utils/Stream'; +import Discussion from 'flarum/common/models/Discussion'; import tagLabel from '../../common/helpers/tagLabel'; import tagIcon from '../../common/helpers/tagIcon'; import sortTags from '../../common/utils/sortTags'; import getSelectableTags from '../utils/getSelectableTags'; import ToggleButton from './ToggleButton'; +import Tag from '../../common/models/Tag'; -export default class TagDiscussionModal extends Modal { - oninit(vnode) { - super.oninit(vnode); +export interface TagDiscussionModalAttrs extends IInternalModalAttrs { + discussion?: Discussion; + selectedTags?: Tag[]; + onsubmit?: (tags: Tag[]) => {}; +} + +export default class TagDiscussionModal extends Modal { + tagsLoading = true; - this.tagsLoading = true; + selected: Tag[] = []; + filter = Stream(''); + focused = false; - this.selected = []; - this.filter = Stream(''); - this.focused = false; + minPrimary = app.forum.attribute('minPrimaryTags'); + maxPrimary = app.forum.attribute('maxPrimaryTags'); + minSecondary = app.forum.attribute('minSecondaryTags'); + maxSecondary = app.forum.attribute('maxSecondaryTags'); - this.minPrimary = app.forum.attribute('minPrimaryTags'); - this.maxPrimary = app.forum.attribute('maxPrimaryTags'); - this.minSecondary = app.forum.attribute('minSecondaryTags'); - this.maxSecondary = app.forum.attribute('maxSecondaryTags'); + bypassReqs = false; - this.bypassReqs = false; + navigator = new KeyboardNavigatable(); + + tags?: Tag[]; + + selectedTag?: Tag; + oninit(vnode: Mithril.Vnode) { + super.oninit(vnode); - this.navigator = new KeyboardNavigatable(); this.navigator .onUp(() => this.setIndex(this.getCurrentNumericIndex() - 1, true)) .onDown(() => this.setIndex(this.getCurrentNumericIndex() + 1, true)) @@ -41,15 +55,17 @@ export default class TagDiscussionModal extends Modal { app.tagList.load(['parent']).then(() => { this.tagsLoading = false; - this.tags = sortTags(getSelectableTags(this.attrs.discussion)); + const tags = sortTags(getSelectableTags(this.attrs.discussion)); + this.tags = tags; + const discussionTags = this.attrs.discussion?.tags() if (this.attrs.selectedTags) { this.attrs.selectedTags.map(this.addTag.bind(this)); - } else if (this.attrs.discussion) { - this.attrs.discussion.tags().map(this.addTag.bind(this)); + } else if (discussionTags) { + discussionTags.forEach(tag => tag && this.addTag(tag)); } - this.index = this.tags[0].id(); + this.selectedTag = tags[0]; m.redraw(); }); @@ -65,10 +81,8 @@ export default class TagDiscussionModal extends Modal { /** * Add the given tag to the list of selected tags. - * - * @param {Tag} tag */ - addTag(tag) { + addTag(tag: Tag) { if (!tag.canStartDiscussion()) return; // If this tag has a parent, we'll also need to add the parent tag to the @@ -85,10 +99,8 @@ export default class TagDiscussionModal extends Modal { /** * Remove the given tag from the list of selected tags. - * - * @param {Tag} tag */ - removeTag(tag) { + removeTag(tag: Tag) { const index = this.selected.indexOf(tag); if (index !== -1) { this.selected.splice(index, 1); @@ -111,7 +123,7 @@ export default class TagDiscussionModal extends Modal { : app.translator.trans('flarum-tags.forum.choose_tags.title'); } - getInstruction(primaryCount, secondaryCount) { + getInstruction(primaryCount: number, secondaryCount: number) { if (this.bypassReqs) { return ''; } @@ -128,7 +140,7 @@ export default class TagDiscussionModal extends Modal { } content() { - if (this.tagsLoading) { + if (this.tagsLoading || !this.tags) { return ; } @@ -141,7 +153,7 @@ export default class TagDiscussionModal extends Modal { // makes it impossible to select a child if its parent hasn't been selected. tags = tags.filter(tag => { const parent = tag.parent(); - return parent === false || this.selected.includes(parent); + return parent !== null && (parent === false || this.selected.includes(parent)); }); // If the number of selected primary/secondary tags is at the maximum, then @@ -160,7 +172,7 @@ export default class TagDiscussionModal extends Modal { tags = tags.filter(tag => tag.name().substr(0, filter.length).toLowerCase() === filter); } - if (!tags.includes(this.index)) this.index = tags[0]; + if (!this.selectedTag || !tags.includes(this.selectedTag)) this.selectedTag = tags[0]; const inputWidth = Math.max(extractText(this.getInstruction(primaryCount, secondaryCount)).length, this.filter().length); @@ -201,7 +213,7 @@ export default class TagDiscussionModal extends Modal {
    {tags - .filter(tag => filter || !tag.parent() || this.selected.includes(tag.parent())) + .filter(tag => filter || !tag.parent() || this.selected.includes(tag.parent() as Tag)) .map(tag => (
  • this.index = tag} + onmouseover={() => this.selectedTag = tag} onclick={this.toggleTag.bind(this, tag)} > {tagIcon(tag)} @@ -239,7 +251,7 @@ export default class TagDiscussionModal extends Modal { ]; } - meetsRequirements(primaryCount, secondaryCount) { + meetsRequirements(primaryCount: number, secondaryCount: number) { if (this.bypassReqs) { return true; } @@ -247,7 +259,10 @@ export default class TagDiscussionModal extends Modal { return primaryCount >= this.minPrimary && secondaryCount >= this.minSecondary; } - toggleTag(tag) { + toggleTag(tag: Tag) { + // Won't happen, needed for type safety. + if (!this.tags) return; + if (this.selected.includes(tag)) { this.removeTag(tag); } else { @@ -256,22 +271,22 @@ export default class TagDiscussionModal extends Modal { if (this.filter()) { this.filter(''); - this.index = this.tags[0]; + this.selectedTag = this.tags[0]; } this.onready(); } - select(e) { + select(e: KeyboardEvent) { // Ctrl + Enter submits the selection, just Enter completes the current entry - if (e.metaKey || e.ctrlKey || this.selected.includes(this.index)) { + if (e.metaKey || e.ctrlKey || this.selectedTag && this.selected.includes(this.selectedTag)) { if (this.selected.length) { // The DOM submit method doesn't emit a `submit event, so we // simulate a manual submission so our `onsubmit` logic is run. this.$('button[type="submit"]').click(); } - } else { - this.getItem(this.index)[0].dispatchEvent(new Event('click')); + } else if (this.selectedTag) { + this.getItem(this.selectedTag)[0].dispatchEvent(new Event('click')); } } @@ -280,16 +295,18 @@ export default class TagDiscussionModal extends Modal { } getCurrentNumericIndex() { + if (!this.selectedTag) return -1; + return this.selectableItems().index( - this.getItem(this.index) + this.getItem(this.selectedTag) ); } - getItem(index) { - return this.selectableItems().filter(`[data-index="${index.id()}"]`); + getItem(selectedTag: Tag) { + return this.selectableItems().filter(`[data-index="${selectedTag.id()}"]`); } - setIndex(index, scrollToItem) { + setIndex(index: number, scrollToItem: boolean) { const $items = this.selectableItems(); const $dropdown = $items.parent(); @@ -301,16 +318,16 @@ export default class TagDiscussionModal extends Modal { const $item = $items.eq(index); - this.index = app.store.getById('tags', $item.attr('data-index')); + this.selectedTag = app.store.getById('tags', $item.attr('data-index')!); m.redraw(); if (scrollToItem) { - const dropdownScroll = $dropdown.scrollTop(); - const dropdownTop = $dropdown.offset().top; - const dropdownBottom = dropdownTop + $dropdown.outerHeight(); - const itemTop = $item.offset().top; - const itemBottom = itemTop + $item.outerHeight(); + const dropdownScroll = $dropdown.scrollTop()!; + const dropdownTop = $dropdown.offset()!.top; + const dropdownBottom = dropdownTop + $dropdown.outerHeight()!; + const itemTop = $item.offset()!.top; + const itemBottom = itemTop + $item.outerHeight()!; let scrollTop; if (itemTop < dropdownTop) { @@ -325,7 +342,7 @@ export default class TagDiscussionModal extends Modal { } } - onsubmit(e) { + onsubmit(e: SubmitEvent) { e.preventDefault(); const discussion = this.attrs.discussion; diff --git a/extensions/tags/js/src/forum/states/TagListState.ts b/extensions/tags/js/src/forum/states/TagListState.ts index 43d220875a..990e58e324 100644 --- a/extensions/tags/js/src/forum/states/TagListState.ts +++ b/extensions/tags/js/src/forum/states/TagListState.ts @@ -4,7 +4,7 @@ import type Tag from "../../common/models/Tag"; export default class TagListState { loadedIncludes = new Set(); - async load(includes = []): Promise { + async load(includes: string[] = []): Promise { const unloadedIncludes = includes.filter( (include) => !this.loadedIncludes.has(include) ); From c59ab2d0b79a8e9ff4c9916fa75511854f491cb5 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 20 Mar 2022 23:15:48 -0400 Subject: [PATCH 41/41] fix(tags): further increase type coverage. --- extensions/tags/js/src/@types/shims.d.ts | 17 ++++++++ ...ionScope.js => addTagsPermissionScope.tsx} | 8 +++- .../{EditTagModal.js => EditTagModal.tsx} | 41 ++++++++++++++----- .../{addTagFilter.js => addTagFilter.tsx} | 28 +++++++++---- framework/core/js/src/common/Model.ts | 10 ++++- framework/core/js/src/common/Store.ts | 6 +-- .../src/forum/states/DiscussionListState.ts | 2 +- 7 files changed, 87 insertions(+), 25 deletions(-) rename extensions/tags/js/src/admin/{addTagsPermissionScope.js => addTagsPermissionScope.tsx} (91%) rename extensions/tags/js/src/admin/components/{EditTagModal.js => EditTagModal.tsx} (78%) rename extensions/tags/js/src/forum/{addTagFilter.js => addTagFilter.tsx} (78%) diff --git a/extensions/tags/js/src/@types/shims.d.ts b/extensions/tags/js/src/@types/shims.d.ts index 1a41c76a3b..6c784bb31f 100644 --- a/extensions/tags/js/src/@types/shims.d.ts +++ b/extensions/tags/js/src/@types/shims.d.ts @@ -19,3 +19,20 @@ declare module 'flarum/common/models/Discussion' { canTag: () => boolean | undefined; } } + +declare module 'flarum/forum/components/IndexPage' { + export default interface IndexPage { + currentActiveTag?: Tag; + currentTagLoading?: boolean; + currentTag: () => Tag | undefined; + } +} + +declare module 'flarum/admin/components/PermissionGrid' { + export interface PermissionConfig { + tagScoped?: boolean; + } + export default interface PermissionGrid { + loading?: boolean; + } +} diff --git a/extensions/tags/js/src/admin/addTagsPermissionScope.js b/extensions/tags/js/src/admin/addTagsPermissionScope.tsx similarity index 91% rename from extensions/tags/js/src/admin/addTagsPermissionScope.js rename to extensions/tags/js/src/admin/addTagsPermissionScope.tsx index 247f3353e4..e9596a8345 100644 --- a/extensions/tags/js/src/admin/addTagsPermissionScope.js +++ b/extensions/tags/js/src/admin/addTagsPermissionScope.tsx @@ -1,3 +1,4 @@ +import app from 'flarum/admin/app'; import { extend, override } from 'flarum/common/extend'; import PermissionGrid from 'flarum/admin/components/PermissionGrid'; import PermissionDropdown from 'flarum/admin/components/PermissionDropdown'; @@ -8,6 +9,7 @@ import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import tagLabel from '../common/helpers/tagLabel'; import tagIcon from '../common/helpers/tagIcon'; import sortTags from '../common/utils/sortTags'; +import Tag from '../common/models/Tag'; export default function() { extend(PermissionGrid.prototype, 'oninit', function () { @@ -15,7 +17,7 @@ export default function() { }) extend(PermissionGrid.prototype, 'oncreate', function () { - app.store.find('tags').then(() => { + app.store.find('tags', {}).then(() => { this.loading = false; m.redraw(); @@ -51,6 +53,8 @@ export default function() { label: tagLabel(tag), onremove: () => tag.save({isRestricted: false}), render: item => { + if ('setting' in item) return ''; + if (item.permission === 'viewForum' || item.permission === 'startDiscussion' || (item.permission && item.permission.indexOf('discussion.') === 0 && item.tagScoped !== false) @@ -67,7 +71,7 @@ export default function() { }); extend(PermissionGrid.prototype, 'scopeControlItems', items => { - const tags = sortTags(app.store.all('tags').filter(tag => !tag.isRestricted())); + const tags = sortTags(app.store.all('tags').filter(tag => !tag.isRestricted())); if (tags.length) { items.add('tag', diff --git a/extensions/tags/js/src/admin/components/EditTagModal.js b/extensions/tags/js/src/admin/components/EditTagModal.tsx similarity index 78% rename from extensions/tags/js/src/admin/components/EditTagModal.js rename to extensions/tags/js/src/admin/components/EditTagModal.tsx index d61c23efe9..f33025ed7b 100644 --- a/extensions/tags/js/src/admin/components/EditTagModal.js +++ b/extensions/tags/js/src/admin/components/EditTagModal.tsx @@ -1,5 +1,5 @@ import app from 'flarum/admin/app'; -import Modal from 'flarum/common/components/Modal'; +import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal'; import Button from 'flarum/common/components/Button'; import ColorPreviewInput from 'flarum/common/components/ColorPreviewInput'; import ItemList from 'flarum/common/utils/ItemList'; @@ -7,13 +7,32 @@ import { slug } from 'flarum/common/utils/string'; import Stream from 'flarum/common/utils/Stream'; import tagLabel from '../../common/helpers/tagLabel'; +import type Mithril from 'mithril'; +import type Tag from '../../common/models/Tag'; +import extractText from 'flarum/common/utils/extractText'; +import { ModelIdentifier } from 'flarum/common/Model'; + +export interface EditTagModalAttrs extends IInternalModalAttrs { + primary?: boolean; + model?: Tag; +} /** * The `EditTagModal` component shows a modal dialog which allows the user * to create or edit a tag. */ -export default class EditTagModal extends Modal { - oninit(vnode) { +export default class EditTagModal extends Modal { + tag!: Tag; + + name!: Stream; + slug!: Stream; + description!: Stream; + color!: Stream; + icon!: Stream; + isHidden!: Stream; + primary!: Stream; + + oninit(vnode: Mithril.Vnode) { super.oninit(vnode); this.tag = this.attrs.model || app.store.createRecord('tags'); @@ -52,9 +71,10 @@ export default class EditTagModal extends Modal { items.add('name',
    - { - this.name(e.target.value); - this.slug(slug(e.target.value)); + { + const target = e.target as HTMLInputElement; + this.name(target.value); + this.slug(slug(target.value)); }} />
    , 50); @@ -118,7 +138,7 @@ export default class EditTagModal extends Modal { }; } - onsubmit(e) { + onsubmit(e: SubmitEvent) { e.preventDefault(); this.loading = true; @@ -132,13 +152,14 @@ export default class EditTagModal extends Modal { } delete() { - if (confirm(app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_confirmation'))) { - const children = app.store.all('tags').filter(tag => tag.parent() === this.tag); + if (confirm(extractText(app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_confirmation')))) { + const children = app.store.all('tags').filter(tag => tag.parent() === this.tag); this.tag.delete().then(() => { children.forEach(tag => tag.pushData({ attributes: { isChild: false }, - relationships: { parent: null } + // @deprecated. Temporary hack for type safety, remove before v1.3. + relationships: { parent: null as any as [] } })); m.redraw(); }); diff --git a/extensions/tags/js/src/forum/addTagFilter.js b/extensions/tags/js/src/forum/addTagFilter.tsx similarity index 78% rename from extensions/tags/js/src/forum/addTagFilter.js rename to extensions/tags/js/src/forum/addTagFilter.tsx index 299806b7bc..7d7b2f8d2b 100644 --- a/extensions/tags/js/src/forum/addTagFilter.js +++ b/extensions/tags/js/src/forum/addTagFilter.tsx @@ -1,3 +1,5 @@ +import app from 'flarum/forum/app'; +import type Mithril from 'mithril'; import { extend, override } from 'flarum/common/extend'; import IndexPage from 'flarum/forum/components/IndexPage'; import DiscussionListState from 'flarum/forum/states/DiscussionListState'; @@ -5,8 +7,10 @@ import GlobalSearchState from 'flarum/forum/states/GlobalSearchState'; import classList from 'flarum/common/utils/classList'; import TagHero from './components/TagHero'; +import Tag from '../common/models/Tag'; +import { ComponentAttrs } from 'flarum/common/Component'; -const findTag = slug => app.store.all('tags').find(tag => tag.slug().localeCompare(slug, undefined, { sensitivity: 'base' }) === 0); +const findTag = (slug: string) => app.store.all('tags').find(tag => tag.slug().localeCompare(slug, undefined, { sensitivity: 'base' }) === 0); export default function() { IndexPage.prototype.currentTag = function() { @@ -45,6 +49,8 @@ export default function() { this.currentActiveTag = tag; return this.currentActiveTag; } + + return; }; // If currently viewing a tag, insert a tag hero at the top of the view. @@ -56,7 +62,7 @@ export default function() { return original(); }); - extend(IndexPage.prototype, 'view', function(vdom) { + extend(IndexPage.prototype, 'view', function(vdom: Mithril.Vnode) { const tag = this.currentTag(); if (tag) vdom.attrs.className += ' IndexPage--tag'+tag.id(); @@ -78,7 +84,7 @@ export default function() { if (tag) { const color = tag.color(); const canStartDiscussion = tag.canStartDiscussion() || !app.session.user; - const newDiscussion = items.get('newDiscussion'); + const newDiscussion = items.get('newDiscussion') as Mithril.Vnode; if (color) { newDiscussion.attrs.className = classList([newDiscussion.attrs.className, 'Button--tagColored']); @@ -97,16 +103,22 @@ export default function() { }); // Translate that parameter into a gambit appended to the search query. - extend(DiscussionListState.prototype, 'requestParams', function(params) { - params.include.push('tags', 'tags.parent'); + extend(DiscussionListState.prototype, 'requestParams', function(this: DiscussionListState, params) { + if (typeof params.include === 'string') { + params.include = [params.include]; + } else { + params.include?.push('tags', 'tags.parent'); + } if (this.params.tags) { - params.filter.tag = this.params.tags; + const filter = params.filter ?? {}; + filter.tag = this.params.tags; // TODO: replace this with a more robust system. - const q = params.filter.q; + const q = filter.q; if (q) { - params.filter.q = `${q} tag:${this.params.tags}`; + filter.q = `${q} tag:${this.params.tags}`; } + params.filter = filter } }); } diff --git a/framework/core/js/src/common/Model.ts b/framework/core/js/src/common/Model.ts index 1912ed6859..2a6e5b6978 100644 --- a/framework/core/js/src/common/Model.ts +++ b/framework/core/js/src/common/Model.ts @@ -34,7 +34,7 @@ export interface SavedModelData { export type ModelData = UnsavedModelData | SavedModelData; export interface SaveRelationships { - [relationship: string]: Model | Model[]; + [relationship: string]: null | Model | Model[]; } export interface SaveAttributes { @@ -137,6 +137,12 @@ export default abstract class Model { for (const r in data.relationships) { const relationship = data.relationships[r]; + if (relationship === null) { + delete relationships[r]; + delete data.relationships[r]; + continue; + } + let identifier: ModelRelationships[string]; if (relationship instanceof Model) { identifier = { data: Model.getIdentifier(relationship) }; @@ -197,6 +203,8 @@ export default abstract class Model { for (const key in attributes.relationships) { const model = attributes.relationships[key]; + if (model === null) continue; + data.relationships[key] = { data: model instanceof Array ? model.map(Model.getIdentifier) : Model.getIdentifier(model), }; diff --git a/framework/core/js/src/common/Store.ts b/framework/core/js/src/common/Store.ts index 77b8c81116..65fd4b6934 100644 --- a/framework/core/js/src/common/Store.ts +++ b/framework/core/js/src/common/Store.ts @@ -147,8 +147,8 @@ export default class Store { /** * Make a request to the API to find record(s) of a specific type. */ - async find(type: string, params: ApiQueryParamsSingle): Promise>; - async find(type: string, params: ApiQueryParamsPlural): Promise>; + async find(type: string, params?: ApiQueryParamsSingle): Promise>; + async find(type: string, params?: ApiQueryParamsPlural): Promise>; async find( type: string, id: string, @@ -163,7 +163,7 @@ export default class Store { ): Promise>; async find( type: string, - idOrParams: string | string[] | ApiQueryParams, + idOrParams: undefined | string | string[] | ApiQueryParams, query: ApiQueryParams = {}, options: ApiQueryRequestOptions ? ApiPayloadPlural : ApiPayloadSingle> = {} ): Promise>> { diff --git a/framework/core/js/src/forum/states/DiscussionListState.ts b/framework/core/js/src/forum/states/DiscussionListState.ts index 8621561b3d..d81267042e 100644 --- a/framework/core/js/src/forum/states/DiscussionListState.ts +++ b/framework/core/js/src/forum/states/DiscussionListState.ts @@ -1,7 +1,7 @@ import app from '../../forum/app'; import PaginatedListState, { Page, PaginatedListParams, PaginatedListRequestParams } from '../../common/states/PaginatedListState'; import Discussion from '../../common/models/Discussion'; -import { ApiQueryParamsPlural, ApiResponsePlural } from '../../common/Store'; +import { ApiResponsePlural } from '../../common/Store'; export interface DiscussionListParams extends PaginatedListParams { sort?: string;