mirror of
https://github.com/directus/directus.git
synced 2026-02-05 05:44:59 -05:00
Fix extensions (#6377)
* Add support for npm extensions * Allow extensions to import vue from the main app * Bundle app extensions on server startup * Fix return type of useLayoutState * Add shared package * Add extension-sdk package * Add type declaration files to allow deep import of shared package * Add extension loading to shared * Refactor extension loading to use shared package * Remove app bundle newline replacement * Fix extension loading in development * Rename extension entrypoints * Update extension build instructions * Remove vite auto-replacement workaround * Update package-lock.json * Remove newline from generated extension entrypoint * Update package-lock.json * Build shared package as cjs and esm * Move useLayoutState composable to shared * Reverse vite base env check * Share useLayoutState composable through extension-sdk * Update layout docs * Update package versions * Small cleanup * Fix layout docs * Fix imports * Add nickrum to codeowners * Fix typo * Add 'em to vite config too * Fix email Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
committed by
GitHub
parent
1644c6397c
commit
051df415df
@@ -96,7 +96,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, PropType } from 'vue';
|
||||
import { useUserStore } from '@/stores/user';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { Filter } from '@/types';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
|
||||
export default defineComponent({
|
||||
emits: ['update:filters'],
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, ref, computed } from 'vue';
|
||||
import { Preset } from '@/types';
|
||||
import { Preset } from '@directus/shared/types';
|
||||
import { useUserStore, usePresetsStore } from '@/stores';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
@@ -102,8 +102,7 @@ export default defineComponent({
|
||||
|
||||
pageClass.value = attributes?.pageClass;
|
||||
|
||||
// Un-escape zero-width characters to allow breaking up character sequences automatically replaced by vite
|
||||
const htmlString = md.render(markdown).replaceAll('\\u200b', '\u200b');
|
||||
const htmlString = md.render(markdown);
|
||||
|
||||
html.value = htmlString;
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import api from '@/api';
|
||||
import { router } from '@/router';
|
||||
import { usePermissionsStore, useUserStore } from '@/stores';
|
||||
import { getRootPath } from '@/utils/get-root-path';
|
||||
import RouterPass from '@/utils/router-passthrough';
|
||||
import { asyncPool } from '@/utils/async-pool';
|
||||
import { getModules } from './index';
|
||||
import { ModuleConfig } from './types';
|
||||
|
||||
@@ -17,19 +15,11 @@ export async function loadModules(): Promise<void> {
|
||||
const modules: ModuleConfig[] = Object.values(moduleModules).map((module) => module.default);
|
||||
|
||||
try {
|
||||
const customResponse = await api.get('/extensions/modules/');
|
||||
const customModules: string[] = customResponse.data.data || [];
|
||||
const customModules: { default: ModuleConfig[] } = import.meta.env.DEV
|
||||
? await import('@directus-extensions-module')
|
||||
: await import(/* @vite-ignore */ `${getRootPath()}extensions/modules/index.js`);
|
||||
|
||||
await asyncPool(5, customModules, async (moduleName) => {
|
||||
try {
|
||||
const result = await import(/* @vite-ignore */ `${getRootPath()}extensions/modules/${moduleName}/index.js`);
|
||||
|
||||
modules.push(result.default);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`Couldn't load custom module "${moduleName}":`, err);
|
||||
}
|
||||
});
|
||||
modules.push(...customModules.default);
|
||||
} catch {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`Couldn't load custom modules`);
|
||||
|
||||
@@ -10,7 +10,8 @@ import { DisplayConfig } from '@/displays/types';
|
||||
import { getInterfaces } from '@/interfaces';
|
||||
import { InterfaceConfig } from '@/interfaces/types';
|
||||
import { useCollectionsStore, useFieldsStore, useRelationsStore } from '@/stores/';
|
||||
import { Collection, Field, localTypes, Relation, Item } from '@/types';
|
||||
import { Collection, Field, localTypes, Relation } from '@/types';
|
||||
import { Item } from '@directus/shared/types';
|
||||
import { clone, throttle } from 'lodash';
|
||||
import { computed, ComputedRef, nextTick, reactive, watch, WatchStopHandle } from 'vue';
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, ref, reactive } from 'vue';
|
||||
|
||||
import SettingsNavigation from '../../components/navigation.vue';
|
||||
import { Preset, Filter } from '@/types';
|
||||
import { Preset, Filter } from '@directus/shared/types';
|
||||
import api from '@/api';
|
||||
import { useCollectionsStore, usePresetsStore } from '@/stores';
|
||||
import { getLayouts } from '@/layouts';
|
||||
|
||||
Reference in New Issue
Block a user