diff --git a/packages/frontend/editor-ui/src/app/composables/useDebugInfo.test.ts b/packages/frontend/editor-ui/src/app/composables/useDebugInfo.test.ts index ae256c5b2d6..57ca5faa159 100644 --- a/packages/frontend/editor-ui/src/app/composables/useDebugInfo.test.ts +++ b/packages/frontend/editor-ui/src/app/composables/useDebugInfo.test.ts @@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'; import { useDebugInfo } from './useDebugInfo'; import type { RootStoreState } from '@n8n/stores/useRootStore'; import type { useSettingsStore as useSettingsStoreType } from '@/app/stores/settings.store'; -import type { RecursivePartial } from '@/type-utils'; +import type { RecursivePartial } from '@/app/types/utils'; vi.mock('@n8n/stores/useRootStore', () => ({ useRootStore: (): Partial => ({ diff --git a/packages/frontend/editor-ui/src/type-utils.d.ts b/packages/frontend/editor-ui/src/app/types/utils.ts similarity index 100% rename from packages/frontend/editor-ui/src/type-utils.d.ts rename to packages/frontend/editor-ui/src/app/types/utils.ts diff --git a/packages/frontend/editor-ui/src/shims-vue.d.ts b/packages/frontend/editor-ui/src/shims-global.d.ts similarity index 53% rename from packages/frontend/editor-ui/src/shims-vue.d.ts rename to packages/frontend/editor-ui/src/shims-global.d.ts index ada7a1aea3d..ac4ae461652 100644 --- a/packages/frontend/editor-ui/src/shims-vue.d.ts +++ b/packages/frontend/editor-ui/src/shims-global.d.ts @@ -1,4 +1,12 @@ +/// +/// + import 'vue-router'; +import type { VNode, ComponentPublicInstance } from 'vue'; +import type { PartialDeep } from 'type-fest'; +import type { ExternalHooks } from '@/app/types/externalHooks'; +import type { FrontendSettings } from '@n8n/api-types'; +import type { Plugin as PrettierPlugin } from 'prettier'; import type { I18nClass } from '@n8n/i18n'; import type { Route, Router, RouteLocation } from 'vue-router'; import type { Telemetry } from '@/app/plugins/telemetry'; @@ -6,9 +14,63 @@ import type { VIEWS } from '@/app/constants'; import type { IPermissions } from '@/Interface'; import type { MiddlewareOptions, RouterMiddlewareType } from '@/app/types/router'; +/** + * File types + */ + +declare module '*.json'; +declare module '*.svg'; +declare module '*.png'; +declare module '*.jpg'; +declare module '*.jpeg'; +declare module '*.gif'; +declare module '*.webp'; + +declare module '*?raw' { + const content: string; + export default content; +} + +/** + * Global + */ + +declare global { + interface ImportMeta { + env: { + DEV: boolean; + PROD: boolean; + NODE_ENV: 'development' | 'production'; + VUE_APP_URL_BASE_API: string; + VUE_SCAN: boolean; + }; + } + + interface Window { + BASE_PATH: string; + REST_ENDPOINT: string; + n8nExternalHooks?: PartialDeep; + preventNodeViewBeforeUnload?: boolean; + maxPinnedDataSize?: number; + } + + namespace JSX { + interface Element extends VNode {} + interface ElementClass extends ComponentPublicInstance {} + interface IntrinsicElements { + [elem: string]: any; + } + } + + interface Array { + findLast(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T; + } +} + export {}; /** + * Vue Runtime * @docs https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties */ @@ -28,6 +90,7 @@ declare module '@vue/runtime-core' { } /** + * Vue Router * @docs https://router.vuejs.org/guide/advanced/meta */ diff --git a/packages/frontend/editor-ui/src/shims-modules.d.ts b/packages/frontend/editor-ui/src/shims-modules.d.ts index ff3351fa157..89f51225bef 100644 --- a/packages/frontend/editor-ui/src/shims-modules.d.ts +++ b/packages/frontend/editor-ui/src/shims-modules.d.ts @@ -4,23 +4,6 @@ declare module 'vue-agile'; -/** - * File types - */ - -declare module '*.json'; -declare module '*.svg'; -declare module '*.png'; -declare module '*.jpg'; -declare module '*.jpeg'; -declare module '*.gif'; -declare module '*.webp'; - -declare module '*?raw' { - const content: string; - export default content; -} - declare module 'v3-infinite-loading' { import { Plugin, DefineComponent } from 'vue'; @@ -37,3 +20,130 @@ declare module 'v3-infinite-loading' { export default InfiniteLoading; } + +declare module 'vue-virtual-scroller' { + import { + type ObjectEmitsOptions, + type PublicProps, + type SetupContext, + type SlotsType, + type VNode, + } from 'vue'; + + interface RecycleScrollerProps { + items: readonly T[]; + direction?: 'vertical' | 'horizontal'; + itemSize?: number | null; + gridItems?: number; + itemSecondarySize?: number; + minItemSize?: number; + sizeField?: string; + typeField?: string; + keyField?: keyof T; + pageMode?: boolean; + prerender?: number; + buffer?: number; + emitUpdate?: boolean; + updateInterval?: number; + listClass?: string; + itemClass?: string; + listTag?: string; + itemTag?: string; + } + + interface DynamicScrollerProps extends RecycleScrollerProps { + minItemSize: number; + } + + interface RecycleScrollerEmitOptions extends ObjectEmitsOptions { + resize: () => void; + visible: () => void; + hidden: () => void; + update: ( + startIndex: number, + endIndex: number, + visibleStartIndex: number, + visibleEndIndex: number, + ) => void; + 'scroll-start': () => void; + 'scroll-end': () => void; + } + + interface RecycleScrollerSlotProps { + item: T; + index: number; + active: boolean; + } + + interface RecycleScrollerSlots { + default(slotProps: RecycleScrollerSlotProps): unknown; + before(): unknown; + empty(): unknown; + after(): unknown; + } + + export interface RecycleScrollerInstance { + getScroll(): { start: number; end: number }; + scrollToItem(index: number): void; + scrollToPosition(position: number): void; + } + + export const RecycleScroller: ( + props: RecycleScrollerProps & PublicProps, + ctx?: SetupContext>>, + expose?: (exposed: RecycleScrollerInstance) => void, + ) => VNode & { + __ctx?: { + props: RecycleScrollerProps & PublicProps; + expose(exposed: RecycleScrollerInstance): void; + slots: RecycleScrollerSlots; + }; + }; + + export const DynamicScroller: ( + props: DynamicScrollerProps & PublicProps, + ctx?: SetupContext>>, + expose?: (exposed: RecycleScrollerInstance) => void, + ) => VNode & { + __ctx?: { + props: DynamicScrollerProps & PublicProps; + expose(exposed: RecycleScrollerInstance): void; + slots: RecycleScrollerSlots; + }; + }; + + interface DynamicScrollerItemProps { + item: T; + active: boolean; + sizeDependencies?: unknown[]; + watchData?: boolean; + tag?: string; + emitResize?: boolean; + onResize?: () => void; + } + + interface DynamicScrollerItemEmitOptions extends ObjectEmitsOptions { + resize: () => void; + } + + export const DynamicScrollerItem: ( + props: DynamicScrollerItemProps & PublicProps, + ctx?: SetupContext, + ) => VNode; + + export function IdState(options?: { idProp?: (value: any) => unknown }): unknown; +} + +declare module 'prettier/plugins/estree' { + const plugin: PrettierPlugin; + export = plugin; + export default plugin; +} + +declare module 'virtual:node-popularity-data' { + const data: Array<{ + id: string; + popularity: number; + }>; + export default data; +} diff --git a/packages/frontend/editor-ui/src/shims.d.ts b/packages/frontend/editor-ui/src/shims.d.ts deleted file mode 100644 index 75f5b428a12..00000000000 --- a/packages/frontend/editor-ui/src/shims.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/// -/// - -import type { VNode, ComponentPublicInstance } from 'vue'; -import type { PartialDeep } from 'type-fest'; -import type { ExternalHooks } from '@/app/types/externalHooks'; -import type { FrontendSettings } from '@n8n/api-types'; -import type { Plugin as PrettierPlugin } from 'prettier'; - -export {}; - -declare global { - interface ImportMeta { - env: { - DEV: boolean; - PROD: boolean; - NODE_ENV: 'development' | 'production'; - VUE_APP_URL_BASE_API: string; - VUE_SCAN: boolean; - }; - } - - interface Window { - BASE_PATH: string; - REST_ENDPOINT: string; - n8nExternalHooks?: PartialDeep; - preventNodeViewBeforeUnload?: boolean; - maxPinnedDataSize?: number; - } - - namespace JSX { - interface Element extends VNode {} - interface ElementClass extends ComponentPublicInstance {} - interface IntrinsicElements { - [elem: string]: any; - } - } - - interface Array { - findLast(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T; - } -} - -declare module 'prettier/plugins/estree' { - const plugin: PrettierPlugin; - export = plugin; - export default plugin; -} diff --git a/packages/frontend/editor-ui/src/vite-virtual-nodes-popularity.d.ts b/packages/frontend/editor-ui/src/vite-virtual-nodes-popularity.d.ts deleted file mode 100644 index aed387a82ae..00000000000 --- a/packages/frontend/editor-ui/src/vite-virtual-nodes-popularity.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -declare module 'virtual:node-popularity-data' { - const data: Array<{ - id: string; - popularity: number; - }>; - export default data; -} diff --git a/packages/frontend/editor-ui/src/vue-virtual-scroller.d.ts b/packages/frontend/editor-ui/src/vue-virtual-scroller.d.ts deleted file mode 100644 index 1e6ef322aa8..00000000000 --- a/packages/frontend/editor-ui/src/vue-virtual-scroller.d.ts +++ /dev/null @@ -1,112 +0,0 @@ -declare module 'vue-virtual-scroller' { - import { - type ObjectEmitsOptions, - type PublicProps, - type SetupContext, - type SlotsType, - type VNode, - } from 'vue'; - - interface RecycleScrollerProps { - items: readonly T[]; - direction?: 'vertical' | 'horizontal'; - itemSize?: number | null; - gridItems?: number; - itemSecondarySize?: number; - minItemSize?: number; - sizeField?: string; - typeField?: string; - keyField?: keyof T; - pageMode?: boolean; - prerender?: number; - buffer?: number; - emitUpdate?: boolean; - updateInterval?: number; - listClass?: string; - itemClass?: string; - listTag?: string; - itemTag?: string; - } - - interface DynamicScrollerProps extends RecycleScrollerProps { - minItemSize: number; - } - - interface RecycleScrollerEmitOptions extends ObjectEmitsOptions { - resize: () => void; - visible: () => void; - hidden: () => void; - update: ( - startIndex: number, - endIndex: number, - visibleStartIndex: number, - visibleEndIndex: number, - ) => void; - 'scroll-start': () => void; - 'scroll-end': () => void; - } - - interface RecycleScrollerSlotProps { - item: T; - index: number; - active: boolean; - } - - interface RecycleScrollerSlots { - default(slotProps: RecycleScrollerSlotProps): unknown; - before(): unknown; - empty(): unknown; - after(): unknown; - } - - export interface RecycleScrollerInstance { - getScroll(): { start: number; end: number }; - scrollToItem(index: number): void; - scrollToPosition(position: number): void; - } - - export const RecycleScroller: ( - props: RecycleScrollerProps & PublicProps, - ctx?: SetupContext>>, - expose?: (exposed: RecycleScrollerInstance) => void, - ) => VNode & { - __ctx?: { - props: RecycleScrollerProps & PublicProps; - expose(exposed: RecycleScrollerInstance): void; - slots: RecycleScrollerSlots; - }; - }; - - export const DynamicScroller: ( - props: DynamicScrollerProps & PublicProps, - ctx?: SetupContext>>, - expose?: (exposed: RecycleScrollerInstance) => void, - ) => VNode & { - __ctx?: { - props: DynamicScrollerProps & PublicProps; - expose(exposed: RecycleScrollerInstance): void; - slots: RecycleScrollerSlots; - }; - }; - - interface DynamicScrollerItemProps { - item: T; - active: boolean; - sizeDependencies?: unknown[]; - watchData?: boolean; - tag?: string; - emitResize?: boolean; - onResize?: () => void; - } - - interface DynamicScrollerItemEmitOptions extends ObjectEmitsOptions { - resize: () => void; - } - - export const DynamicScrollerItem: ( - props: DynamicScrollerItemProps & PublicProps, - ctx?: SetupContext, - ) => VNode; - - export function IdState(options?: { idProp?: (value: any) => unknown }): unknown; -} diff --git a/packages/frontend/editor-ui/vite.config.mts b/packages/frontend/editor-ui/vite.config.mts index d15f81dd9d5..deea91bdc9c 100644 --- a/packages/frontend/editor-ui/vite.config.mts +++ b/packages/frontend/editor-ui/vite.config.mts @@ -71,7 +71,7 @@ const alias = [ { // For sanitize-html find: 'source-map-js', - replacement: resolve(__dirname, 'src/source-map-js-shim'), + replacement: resolve(__dirname, 'vite/source-map-js-shim'), }, ]; diff --git a/packages/frontend/editor-ui/src/source-map-js-shim.ts b/packages/frontend/editor-ui/vite/source-map-js-shim.ts similarity index 100% rename from packages/frontend/editor-ui/src/source-map-js-shim.ts rename to packages/frontend/editor-ui/vite/source-map-js-shim.ts