Skip to content

Commit

Permalink
fix(types): import plugins for module augmentations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
taye committed Nov 5, 2023
1 parent b31ad7a commit 5519d4f
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 38 deletions.
4 changes: 4 additions & 0 deletions packages/@interactjs/actions/drop/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion packages/@interactjs/actions/plugin.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 3 additions & 0 deletions packages/@interactjs/auto-start/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions packages/@interactjs/auto-start/hold.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions packages/@interactjs/auto-start/plugin.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 3 additions & 0 deletions packages/@interactjs/core/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
4 changes: 4 additions & 0 deletions packages/@interactjs/core/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions packages/@interactjs/inertia/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
32 changes: 14 additions & 18 deletions packages/@interactjs/interactjs/index.stub.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)

Expand Down Expand Up @@ -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 _
32 changes: 14 additions & 18 deletions packages/@interactjs/interactjs/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)

Expand Down Expand Up @@ -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 _
5 changes: 5 additions & 0 deletions packages/@interactjs/modifiers/plugin.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions packages/@interactjs/pointer-events/holdRepeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions packages/@interactjs/pointer-events/plugin.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/@interactjs/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 5519d4f

Please sign in to comment.