From 5519d4fd54d8b5caebb9cf1ae3b84894402067db Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Sun, 5 Nov 2023 13:34:43 +0100 Subject: [PATCH] fix(types): import plugins for module augmentations Re: #933 # Conflicts: # packages/@interactjs/arrange/componentUtils.ts # packages/@interactjs/arrange/plugin.ts # packages/@interactjs/interactjs/index.ts # packages/@interactjs/react/plugin.ts # packages/@interactjs/vue/plugin.ts --- packages/@interactjs/actions/drop/plugin.ts | 4 +++ packages/@interactjs/actions/plugin.ts | 2 +- packages/@interactjs/auto-start/base.ts | 3 ++ packages/@interactjs/auto-start/hold.ts | 3 ++ packages/@interactjs/auto-start/plugin.ts | 6 ++++ packages/@interactjs/core/interactions.ts | 3 ++ packages/@interactjs/core/scope.ts | 4 +++ packages/@interactjs/inertia/plugin.ts | 4 +++ packages/@interactjs/interactjs/index.stub.ts | 32 ++++++++----------- packages/@interactjs/interactjs/index.ts | 32 ++++++++----------- packages/@interactjs/modifiers/plugin.ts | 5 +++ .../@interactjs/pointer-events/holdRepeat.ts | 3 ++ packages/@interactjs/pointer-events/plugin.ts | 6 ++++ packages/@interactjs/types/index.ts | 2 +- 14 files changed, 71 insertions(+), 38 deletions(-) diff --git a/packages/@interactjs/actions/drop/plugin.ts b/packages/@interactjs/actions/drop/plugin.ts index 108e5f2c8..043b15e23 100644 --- a/packages/@interactjs/actions/drop/plugin.ts +++ b/packages/@interactjs/actions/drop/plugin.ts @@ -11,8 +11,12 @@ import is from '@interactjs/utils/is' import normalizeListeners from '@interactjs/utils/normalizeListeners' import * as pointerUtils from '@interactjs/utils/pointerUtils' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import '../drag/plugin' + import type { DragEvent } from '../drag/plugin' import drag from '../drag/plugin' +/* eslint-enable import/no-duplicates */ import { DropEvent } from './DropEvent' diff --git a/packages/@interactjs/actions/plugin.ts b/packages/@interactjs/actions/plugin.ts index f629535a9..bf8b57a84 100644 --- a/packages/@interactjs/actions/plugin.ts +++ b/packages/@interactjs/actions/plugin.ts @@ -1,6 +1,6 @@ import type { Scope } from '@interactjs/core/scope' -/* eslint-disable import/no-duplicates */ +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ import './drag/plugin' import './drop/plugin' import './gesture/plugin' diff --git a/packages/@interactjs/auto-start/base.ts b/packages/@interactjs/auto-start/base.ts index f509e7d7f..d17fdfd69 100644 --- a/packages/@interactjs/auto-start/base.ts +++ b/packages/@interactjs/auto-start/base.ts @@ -14,7 +14,10 @@ import extend from '@interactjs/utils/extend' import is from '@interactjs/utils/is' import { copyAction } from '@interactjs/utils/misc' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './InteractableMethods' import InteractableMethods from './InteractableMethods' +/* eslint-enable import/no-duplicates */ declare module '@interactjs/core/InteractStatic' { export interface InteractStatic { diff --git a/packages/@interactjs/auto-start/hold.ts b/packages/@interactjs/auto-start/hold.ts index a3329cf97..dc90584de 100644 --- a/packages/@interactjs/auto-start/hold.ts +++ b/packages/@interactjs/auto-start/hold.ts @@ -1,7 +1,10 @@ import type Interaction from '@interactjs/core/Interaction' import type { Scope, Plugin } from '@interactjs/core/scope' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './base' import basePlugin from './base' +/* eslint-enable */ declare module '@interactjs/core/options' { interface PerActionDefaults { diff --git a/packages/@interactjs/auto-start/plugin.ts b/packages/@interactjs/auto-start/plugin.ts index 00d81e753..62ee77577 100644 --- a/packages/@interactjs/auto-start/plugin.ts +++ b/packages/@interactjs/auto-start/plugin.ts @@ -1,8 +1,14 @@ import type { Scope } from '@interactjs/core/scope' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './base' +import './dragAxis' +import './hold' + import autoStart from './base' import dragAxis from './dragAxis' import hold from './hold' +/* eslint-enable import/no-duplicates */ export default { id: 'auto-start', diff --git a/packages/@interactjs/core/interactions.ts b/packages/@interactjs/core/interactions.ts index b0af89f46..451139684 100644 --- a/packages/@interactjs/core/interactions.ts +++ b/packages/@interactjs/core/interactions.ts @@ -6,7 +6,10 @@ import { nodeContains } from '@interactjs/utils/domUtils' import * as pointerUtils from '@interactjs/utils/pointerUtils' import InteractionBase from './Interaction' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './interactablePreventDefault' import interactablePreventDefault from './interactablePreventDefault' +/* eslint-enable import/no-duplicates */ import type { SearchDetails } from './interactionFinder' import finder from './interactionFinder' diff --git a/packages/@interactjs/core/scope.ts b/packages/@interactjs/core/scope.ts index ff56f6f29..605a76c3c 100644 --- a/packages/@interactjs/core/scope.ts +++ b/packages/@interactjs/core/scope.ts @@ -12,8 +12,12 @@ import { InteractEvent } from './InteractEvent' import { createInteractStatic } from './InteractStatic' import { Interactable as InteractableBase } from './Interactable' import { InteractableSet } from './InteractableSet' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './events' +import './interactions' import events from './events' import interactions from './interactions' +/* eslint-enable import/no-duplicates */ import type { OptionsArg } from './options' import { defaults } from './options' import type { Actions } from './types' diff --git a/packages/@interactjs/inertia/plugin.ts b/packages/@interactjs/inertia/plugin.ts index 44198e63c..398f2e106 100644 --- a/packages/@interactjs/inertia/plugin.ts +++ b/packages/@interactjs/inertia/plugin.ts @@ -2,9 +2,13 @@ import type { Interaction, DoPhaseArg } from '@interactjs/core/Interaction' import type { Scope, SignalArgs, Plugin } from '@interactjs/core/scope' import type { ActionName, Point, PointerEventType } from '@interactjs/core/types' import Modification from '@interactjs/modifiers/Modification' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import '@interactjs/modifiers/base' +import '@interactjs/offset/plugin' import * as modifiers from '@interactjs/modifiers/base' import type { ModifierArg } from '@interactjs/modifiers/types' import offset from '@interactjs/offset/plugin' +/* eslint-enable import/no-duplicates */ import * as dom from '@interactjs/utils/domUtils' import hypot from '@interactjs/utils/hypot' import is from '@interactjs/utils/is' diff --git a/packages/@interactjs/interactjs/index.stub.ts b/packages/@interactjs/interactjs/index.stub.ts index 380c4e5fd..7401706b2 100644 --- a/packages/@interactjs/interactjs/index.stub.ts +++ b/packages/@interactjs/interactjs/index.stub.ts @@ -1,3 +1,16 @@ +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import '@interactjs/actions/plugin' +import '@interactjs/auto-scroll/plugin' +import '@interactjs/auto-start/plugin' +import '@interactjs/core/interactablePreventDefault' +import '@interactjs/dev-tools/plugin' +import '@interactjs/inertia/plugin' +import '@interactjs/interact' +import '@interactjs/modifiers/plugin' +import '@interactjs/offset/plugin' +import '@interactjs/pointer-events/plugin' +import '@interactjs/reflow/plugin' + import actions from '@interactjs/actions/plugin' import autoScroll from '@interactjs/auto-scroll/plugin' import autoStart from '@interactjs/auto-start/plugin' @@ -9,6 +22,7 @@ import modifiers from '@interactjs/modifiers/plugin' import offset from '@interactjs/offset/plugin' import pointerEvents from '@interactjs/pointer-events/plugin' import reflow from '@interactjs/reflow/plugin' +/* eslint-enable import/no-duplicates */ interact.use(interactablePreventDefault) @@ -42,21 +56,3 @@ if (process.env.NODE_ENV !== 'production') { export default interact ;(interact as any).default = interact - -const _ = { - actions, - autoScroll, - autoStart, - interactablePreventDefault, - devTools, - inertia, - interact, - modifiers, - offset, - pointerEvents, - reflow, -} - -// Exported so that the related module augmentations will be referenced in -// generated .d.ts file -export type __internal_plugin_types__ = typeof _ diff --git a/packages/@interactjs/interactjs/index.ts b/packages/@interactjs/interactjs/index.ts index 380c4e5fd..7401706b2 100644 --- a/packages/@interactjs/interactjs/index.ts +++ b/packages/@interactjs/interactjs/index.ts @@ -1,3 +1,16 @@ +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import '@interactjs/actions/plugin' +import '@interactjs/auto-scroll/plugin' +import '@interactjs/auto-start/plugin' +import '@interactjs/core/interactablePreventDefault' +import '@interactjs/dev-tools/plugin' +import '@interactjs/inertia/plugin' +import '@interactjs/interact' +import '@interactjs/modifiers/plugin' +import '@interactjs/offset/plugin' +import '@interactjs/pointer-events/plugin' +import '@interactjs/reflow/plugin' + import actions from '@interactjs/actions/plugin' import autoScroll from '@interactjs/auto-scroll/plugin' import autoStart from '@interactjs/auto-start/plugin' @@ -9,6 +22,7 @@ import modifiers from '@interactjs/modifiers/plugin' import offset from '@interactjs/offset/plugin' import pointerEvents from '@interactjs/pointer-events/plugin' import reflow from '@interactjs/reflow/plugin' +/* eslint-enable import/no-duplicates */ interact.use(interactablePreventDefault) @@ -42,21 +56,3 @@ if (process.env.NODE_ENV !== 'production') { export default interact ;(interact as any).default = interact - -const _ = { - actions, - autoScroll, - autoStart, - interactablePreventDefault, - devTools, - inertia, - interact, - modifiers, - offset, - pointerEvents, - reflow, -} - -// Exported so that the related module augmentations will be referenced in -// generated .d.ts file -export type __internal_plugin_types__ = typeof _ diff --git a/packages/@interactjs/modifiers/plugin.ts b/packages/@interactjs/modifiers/plugin.ts index de7504cfd..5b2605c8c 100644 --- a/packages/@interactjs/modifiers/plugin.ts +++ b/packages/@interactjs/modifiers/plugin.ts @@ -1,8 +1,13 @@ import type { Plugin } from '@interactjs/core/scope' import snappers from '@interactjs/snappers/plugin' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './all' +import './base' + import all from './all' import base from './base' +/* eslint-enable import/no-duplicates */ declare module '@interactjs/core/InteractStatic' { export interface InteractStatic { diff --git a/packages/@interactjs/pointer-events/holdRepeat.ts b/packages/@interactjs/pointer-events/holdRepeat.ts index 9c4ba11db..786391072 100644 --- a/packages/@interactjs/pointer-events/holdRepeat.ts +++ b/packages/@interactjs/pointer-events/holdRepeat.ts @@ -2,7 +2,10 @@ import type Interaction from '@interactjs/core/Interaction' import type { ListenerMap, Scope, SignalArgs, Plugin } from '@interactjs/core/scope' import type PointerEvent from './PointerEvent' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './base' import basePlugin from './base' +/* eslint-enable import/no-duplicates */ declare module '@interactjs/core/Interaction' { interface Interaction { diff --git a/packages/@interactjs/pointer-events/plugin.ts b/packages/@interactjs/pointer-events/plugin.ts index 3ee8baec5..463463474 100644 --- a/packages/@interactjs/pointer-events/plugin.ts +++ b/packages/@interactjs/pointer-events/plugin.ts @@ -1,8 +1,14 @@ import type { Plugin } from '@interactjs/core/scope' +/* eslint-disable import/no-duplicates -- for typescript module augmentations */ +import './base' +import './holdRepeat' +import './interactableTargets' + import * as pointerEvents from './base' import holdRepeat from './holdRepeat' import interactableTargets from './interactableTargets' +/* eslint-enable import/no-duplicates */ const plugin: Plugin = { id: 'pointer-events', diff --git a/packages/@interactjs/types/index.ts b/packages/@interactjs/types/index.ts index 81537b03c..ca28d6220 100644 --- a/packages/@interactjs/types/index.ts +++ b/packages/@interactjs/types/index.ts @@ -3,7 +3,7 @@ import type { InteractEvent as _InteractEvent, EventPhase } from '@interactjs/co import type * as interaction from '@interactjs/core/Interaction' import type { ActionName, ActionProps as _ActionProps } from '@interactjs/core/types' // import module augmentations -import type * as _ from '@interactjs/interactjs' +import '@interactjs/interactjs' export * from '@interactjs/core/types' export type { Plugin } from '@interactjs/core/scope'