1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 08:27:42 +02:00

feat: export registry (#3842)

* feat: registry first iteration

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* feat: improve webpack auto export loader

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: remove `compat` API

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: cleanup

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
Sami Mazouz
2023-06-29 18:57:53 +01:00
committed by GitHub
parent cf70865aa6
commit 016503d8c3
74 changed files with 2206 additions and 1076 deletions

View File

@@ -15,7 +15,7 @@
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/flags/*": ["../../flags/js/dist-typings/*"]
"ext:flarum/flags/*": ["../../flags/js/dist-typings/*"]
}
}
}

View File

@@ -1,19 +0,0 @@
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';
export default {
'flags/addFlagsToPosts': addFlagsToPosts,
'flags/addFlagControl': addFlagControl,
'flags/addFlagsDropdown': addFlagsDropdown,
'flags/models/Flag': Flag,
'flags/components/FlagList': FlagList,
'flags/components/FlagPostModal': FlagPostModal,
'flags/components/FlagsPage': FlagsPage,
'flags/components/FlagsDropdown': FlagsDropdown,
};

View File

@@ -1,5 +1,5 @@
import app from 'flarum/forum/app';
import Page from 'flarum/components/Page';
import Page from 'flarum/common/components/Page';
import FlagList from './FlagList';

View File

@@ -0,0 +1,10 @@
import './addFlagsToPosts';
import './addFlagControl';
import './addFlagsDropdown';
import './models/Flag';
import './components/FlagList';
import './components/FlagPostModal';
import './components/FlagsPage';
import './components/FlagsDropdown';

View File

@@ -15,8 +15,4 @@ app.initializers.add('flarum-flags', () => {
addFlagsToPosts();
});
// Expose compat API
import flagsCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, flagsCompat);
import './forum';

View File

@@ -9,8 +9,7 @@
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/core/js/dist-typings/*"],
"@flarum/core/*": ["../../../framework/core/js/dist-typings/*"]
"flarum/*": ["../../../framework/core/js/dist-typings/*"]
}
}
}

View File

@@ -9,12 +9,7 @@
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/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/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/*": ["../../../framework/core/js/dist-typings/*"]
}
}
}

View File

@@ -9,12 +9,7 @@
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/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/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/*": ["../../../framework/core/js/dist-typings/*"]
}
}
}

View File

@@ -1,31 +0,0 @@
import GroupMentionedNotification from './components/GroupMentionedNotification';
import MentionsUserPage from './components/MentionsUserPage';
import PostMentionedNotification from './components/PostMentionedNotification';
import UserMentionedNotification from './components/UserMentionedNotification';
import AutocompleteDropdown from './fragments/AutocompleteDropdown';
import PostQuoteButton from './fragments/PostQuoteButton';
import getCleanDisplayName from './utils/getCleanDisplayName';
import getMentionText from './utils/getMentionText';
import * as reply from './utils/reply';
import selectedText from './utils/selectedText';
import * as textFormatter from './utils/textFormatter';
import MentionableModel from './mentionables/MentionableModel';
import MentionFormat from './mentionables/formats/MentionFormat';
import Mentionables from './extenders/Mentionables';
export default {
'mentions/components/MentionsUserPage': MentionsUserPage,
'mentions/components/PostMentionedNotification': PostMentionedNotification,
'mentions/components/UserMentionedNotification': UserMentionedNotification,
'mentions/components/GroupMentionedNotification': GroupMentionedNotification,
'mentions/fragments/AutocompleteDropdown': AutocompleteDropdown,
'mentions/fragments/PostQuoteButton': PostQuoteButton,
'mentions/utils/getCleanDisplayName': getCleanDisplayName,
'mentions/utils/getMentionText': getMentionText,
'mentions/utils/reply': reply,
'mentions/utils/selectedText': selectedText,
'mentions/utils/textFormatter': textFormatter,
'mentions/mentionables/MentionableModel': MentionableModel,
'mentions/mentionables/formats/MentionFormat': MentionFormat,
'mentions/extenders/Mentionables': Mentionables,
};

View File

@@ -0,0 +1,14 @@
import './components/GroupMentionedNotification';
import './components/MentionsUserPage';
import './components/PostMentionedNotification';
import './components/UserMentionedNotification';
import './fragments/AutocompleteDropdown';
import './fragments/PostQuoteButton';
import './utils/getCleanDisplayName';
import './utils/getMentionText';
import './utils/reply';
import './utils/selectedText';
import './utils/textFormatter';
import './mentionables/MentionableModel';
import './mentionables/formats/MentionFormat';
import './extenders/Mentionables';

View File

@@ -15,8 +15,6 @@ import UserMentionedNotification from './components/UserMentionedNotification';
import GroupMentionedNotification from './components/GroupMentionedNotification';
import UserPage from 'flarum/forum/components/UserPage';
import LinkButton from 'flarum/common/components/LinkButton';
import User from 'flarum/common/models/User';
import Model from 'flarum/common/Model';
export { default as extend } from './extend';
@@ -90,8 +88,4 @@ app.initializers.add('flarum-mentions', function () {
export * from './utils/textFormatter';
// Expose compat API
import mentionsCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, mentionsCompat);
import './forum';

View File

@@ -1,7 +1,7 @@
import app from 'flarum/forum/app';
import Badge from 'flarum/common/components/Badge';
import highlight from 'flarum/common/helpers/highlight';
import type Tag from 'flarum/tags/common/models/Tag';
import type Tag from 'ext:flarum/tags/common/models/Tag';
import type Mithril from 'mithril';
import MentionableModel from './MentionableModel';
import type HashMentionFormat from './formats/HashMentionFormat';

View File

@@ -10,12 +10,7 @@
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/tags/*": ["../../tags/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/*": ["../../../framework/core/js/dist-typings/*"],
"ext:flarum/tags/*": ["../../tags/js/dist-typings/*"]
}
}
}

View File

@@ -9,12 +9,7 @@
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/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/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/*": ["../../../framework/core/js/dist-typings/*"]
}
}
}

View File

@@ -7,7 +7,7 @@ import IndexPage from 'flarum/forum/components/IndexPage';
import Button from 'flarum/common/components/Button';
import ItemList from 'flarum/common/utils/ItemList';
import type { Children } from 'mithril';
import type Tag from 'flarum/tags/common/models/Tag';
import type Tag from 'ext:flarum/tags/common/models/Tag';
export type PusherBinding = {
channels: {

View File

@@ -10,7 +10,7 @@
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/tags/*": ["../../tags/js/dist-typings/*"]
"ext:flarum/tags/*": ["../../tags/js/dist-typings/*"]
}
}
}

View File

@@ -9,12 +9,7 @@
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/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/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/*": ["../../../framework/core/js/dist-typings/*"]
}
}
}

View File

@@ -10,8 +10,7 @@
"declarationDir": "./dist-typings",
"baseUrl": ".",
"paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"],
"@flarum/core/*": ["../vendor/flarum/core/js/dist-typings/*"]
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"]
}
}
}

View File

@@ -1,4 +1,4 @@
import app from 'flarum/app';
import app from 'flarum/admin/app';
app.initializers.add('flarum-suspend', () => {
app.extensionData.for('flarum-suspend').registerPermission(

View File

@@ -1,13 +0,0 @@
import SuspendUserModal from './components/SuspendUserModal';
import SuspensionInfoModal from './components/SuspensionInfoModal';
import UserSuspendedNotification from './components/UserSuspendedNotification';
import UserUnsuspendedNotification from './components/UserUnsuspendedNotification';
import checkForSuspension from './checkForSuspension';
export default {
'suspend/components/suspendUserModal': SuspendUserModal,
'suspend/components/suspensionInfoModal': SuspensionInfoModal,
'suspend/components/UserSuspendedNotification': UserSuspendedNotification,
'suspend/components/UserUnsuspendedNotification': UserUnsuspendedNotification,
'suspend/checkForSuspension': checkForSuspension,
};

View File

@@ -1,10 +1,10 @@
import app from 'flarum/forum/app';
import Modal from 'flarum/components/Modal';
import Button from 'flarum/components/Button';
import Stream from 'flarum/utils/Stream';
import withAttr from 'flarum/utils/withAttr';
import Modal from 'flarum/common/components/Modal';
import Button from 'flarum/common/components/Button';
import Stream from 'flarum/common/utils/Stream';
import withAttr from 'flarum/common/utils/withAttr';
import ItemList from 'flarum/common/utils/ItemList';
import { getPermanentSuspensionDate } from '../helpers/suspensionHelper';
export default class SuspendUserModal extends Modal {

View File

@@ -1,5 +1,6 @@
import app from 'flarum/forum/app';
import Notification from 'flarum/components/Notification';
import Notification from 'flarum/forum/components/Notification';
import { isPermanentSuspensionDate } from '../helpers/suspensionHelper';
export default class UserSuspendedNotification extends Notification {

View File

@@ -1,5 +1,5 @@
import app from 'flarum/forum/app';
import Notification from 'flarum/components/Notification';
import Notification from 'flarum/forum/components/Notification';
export default class UserUnsuspendedNotification extends Notification {
icon() {

View File

@@ -0,0 +1,6 @@
import './components/SuspendUserModal';
import './components/SuspensionInfoModal';
import './components/UserSuspendedNotification';
import './components/UserUnsuspendedNotification';
import './checkForSuspension';

View File

@@ -1,9 +1,9 @@
import { extend } from 'flarum/extend';
import app from 'flarum/app';
import UserControls from 'flarum/utils/UserControls';
import Button from 'flarum/components/Button';
import Badge from 'flarum/components/Badge';
import User from 'flarum/models/User';
import { extend } from 'flarum/common/extend';
import app from 'flarum/forum/app';
import UserControls from 'flarum/forum/utils/UserControls';
import Button from 'flarum/common/components/Button';
import Badge from 'flarum/common/components/Badge';
import User from 'flarum/common/models/User';
import SuspendUserModal from './components/SuspendUserModal';
import UserSuspendedNotification from './components/UserSuspendedNotification';
@@ -42,8 +42,4 @@ app.initializers.add('flarum-suspend', () => {
checkForSuspension();
});
// Expose compat API
import suspendCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, suspendCompat);
import './forum';

View File

@@ -9,12 +9,7 @@
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/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/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/*": ["../../../framework/core/js/dist-typings/*"]
}
}
}

View File

@@ -0,0 +1,9 @@
import '../common/common';
import './components/TagsPage';
import './components/EditTagModal';
import './addTagsHomePageOption';
import './addTagChangePermission';
import './addTagPermission';
import './addTagsPermissionScope';

View File

@@ -1,17 +0,0 @@
import compat from '../common/compat';
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';
export default Object.assign(compat, {
'tags/addTagsHomePageOption': addTagsHomePageOption,
'tags/addTagChangePermission': addTagChangePermission,
'tags/components/TagsPage': TagsPage,
'tags/components/EditTagModal': EditTagModal,
'tags/addTagPermission': addTagPermission,
'tags/addTagsPermissionScope': addTagsPermissionScope,
});

View File

@@ -21,8 +21,4 @@ app.initializers.add('flarum-tags', (app) => {
addTagSelectionSettingComponent();
});
// Expose compat API
import tagsCompat from './compat';
import { compat } from '@flarum/core/admin';
Object.assign(compat, tagsCompat);
import './admin';

View File

@@ -0,0 +1,11 @@
import './utils/sortTags';
import './models/Tag';
import './helpers/tagsLabel';
import './helpers/tagIcon';
import './helpers/tagLabel';
import './components/TagSelectionModal';
import './states/TagListState';

View File

@@ -1,17 +0,0 @@
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';
import TagSelectionModal from './components/TagSelectionModal';
import TagListState from './states/TagListState';
export default {
'tags/utils/sortTags': sortTags,
'tags/models/Tag': Tag,
'tags/helpers/tagsLabel': tagsLabel,
'tags/helpers/tagIcon': tagIcon,
'tags/helpers/tagLabel': tagLabel,
'tags/components/TagSelectionModal': TagSelectionModal,
'tags/states/TagListState': TagListState,
};

View File

@@ -1,27 +0,0 @@
import compat from '../common/compat';
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';
export default Object.assign(compat, {
'tags/addTagFilter': addTagFilter,
'tags/addTagControl': addTagControl,
'tags/components/TagHero': TagHero,
'tags/components/TagDiscussionModal': TagDiscussionModal,
'tags/components/TagsPage': TagsPage,
'tags/components/DiscussionTaggedPost': DiscussionTaggedPost,
'tags/components/TagLinkButton': TagLinkButton,
'tags/addTagList': addTagList,
'tags/addTagLabels': addTagLabels,
'tags/addTagComposer': addTagComposer,
'tags/utils/getSelectableTags': getSelectableTags,
});

View File

@@ -0,0 +1,15 @@
import '../common/common';
import './utils/getSelectableTags';
import './components/TagHero';
import './components/TagDiscussionModal';
import './components/TagsPage';
import './components/DiscussionTaggedPost';
import './components/TagLinkButton';
import './addTagFilter';
import './addTagControl';
import './addTagList';
import './addTagLabels';
import './addTagComposer';

View File

@@ -20,8 +20,4 @@ app.initializers.add('flarum-tags', function () {
addTagComposer();
});
// Expose compat API
import tagsCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, tagsCompat);
import './forum';

View File

@@ -9,12 +9,7 @@
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/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/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/*": ["../../../framework/core/js/dist-typings/*"]
}
}
}