Commit c91cbf0e authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Move `listener-collection.js` to `src/shared`

`src/shared/port-rpc.js` depended on
`src/annotation/util/listener-collection.js`. Files in the `src/shared`
folder should not have dependencies on `src/annotation`.

`ListenerCollection` is a very general utility and the placement in
`src/shared` seems correct.

I took the opportunity to reorder the imports according to our
conventions.
parent 8384de22
import { render } from 'preact'; import { render } from 'preact';
import Buckets from './components/Buckets';
import { ListenerCollection } from '../shared/listener-collection';
import Buckets from './components/Buckets';
import { anchorBuckets } from './util/buckets'; import { anchorBuckets } from './util/buckets';
import { ListenerCollection } from './util/listener-collection';
/** /**
* @typedef BucketBarOptions * @typedef BucketBarOptions
......
import { Adder } from './adder'; import { ListenerCollection } from '../shared/listener-collection';
import { CrossFrame } from './cross-frame';
import { HTMLIntegration } from './integrations/html';
import { PDFIntegration } from './integrations/pdf';
import { Adder } from './adder';
import { TextRange } from './anchoring/text-range'; import { TextRange } from './anchoring/text-range';
import { CrossFrame } from './cross-frame';
import { import {
getHighlightsContainingNode, getHighlightsContainingNode,
highlightRange, highlightRange,
...@@ -12,10 +11,11 @@ import { ...@@ -12,10 +11,11 @@ import {
setHighlightsFocused, setHighlightsFocused,
setHighlightsVisible, setHighlightsVisible,
} from './highlighter'; } from './highlighter';
import { HTMLIntegration } from './integrations/html';
import { PDFIntegration } from './integrations/pdf';
import * as rangeUtil from './range-util'; import * as rangeUtil from './range-util';
import { SelectionObserver } from './selection-observer'; import { SelectionObserver } from './selection-observer';
import { normalizeURI } from './util/url'; import { normalizeURI } from './util/url';
import { ListenerCollection } from './util/listener-collection';
/** /**
* @typedef {import('./util/emitter').EventBus} EventBus * @typedef {import('./util/emitter').EventBus} EventBus
......
import debounce from 'lodash.debounce'; import debounce from 'lodash.debounce';
import { render } from 'preact'; import { render } from 'preact';
import { ListenerCollection } from '../../shared/listener-collection';
import { import {
RenderingStates, RenderingStates,
anchor, anchor,
...@@ -10,7 +11,6 @@ import { ...@@ -10,7 +11,6 @@ import {
import { isInPlaceholder, removePlaceholder } from '../anchoring/placeholder'; import { isInPlaceholder, removePlaceholder } from '../anchoring/placeholder';
import WarningBanner from '../components/WarningBanner'; import WarningBanner from '../components/WarningBanner';
import { createShadowRoot } from '../util/shadow-root'; import { createShadowRoot } from '../util/shadow-root';
import { ListenerCollection } from '../util/listener-collection';
import { offsetRelativeTo, scrollElement } from '../util/scroll'; import { offsetRelativeTo, scrollElement } from '../util/scroll';
import { PDFMetadata } from './pdf-metadata'; import { PDFMetadata } from './pdf-metadata';
......
import { ListenerCollection } from './util/listener-collection'; import { ListenerCollection } from '../shared/listener-collection';
/** /**
* Return the current selection or `null` if there is no selection or it is empty. * Return the current selection or `null` if there is no selection or it is empty.
......
import Hammer from 'hammerjs'; import Hammer from 'hammerjs';
import events from '../shared/bridge-events';
import { ListenerCollection } from '../shared/listener-collection';
import annotationCounts from './annotation-counts'; import annotationCounts from './annotation-counts';
import sidebarTrigger from './sidebar-trigger'; import BucketBar from './bucket-bar';
import { createSidebarConfig } from './config/sidebar'; import { createSidebarConfig } from './config/sidebar';
import events from '../shared/bridge-events';
import features from './features'; import features from './features';
import sidebarTrigger from './sidebar-trigger';
import { ToolbarController } from './toolbar'; import { ToolbarController } from './toolbar';
import { createShadowRoot } from './util/shadow-root'; import { createShadowRoot } from './util/shadow-root';
import BucketBar from './bucket-bar';
import { ListenerCollection } from './util/listener-collection';
/** /**
* @typedef {import('./guest').default} Guest * @typedef {import('./guest').default} Guest
......
import { ListenerCollection } from '../annotator/util/listener-collection'; import { ListenerCollection } from './listener-collection';
/* /*
This module was adapted from `index.js` in https://github.com/substack/frame-rpc. This module was adapted from `index.js` in https://github.com/substack/frame-rpc.
......
import { ListenerCollection } from '../../util/listener-collection'; import { ListenerCollection } from '../listener-collection';
describe('ListenerCollection', () => { describe('ListenerCollection', () => {
let listeners; let listeners;
......
import { useEffect, useLayoutEffect, useMemo, useState } from 'preact/hooks'; import { useEffect, useLayoutEffect, useMemo, useState } from 'preact/hooks';
import debounce from 'lodash.debounce'; import debounce from 'lodash.debounce';
import { useStoreProxy } from '../store/use-store'; import { ListenerCollection } from '../../shared/listener-collection';
import { isHighlight } from '../helpers/annotation-metadata'; import { isHighlight } from '../helpers/annotation-metadata';
import { getElementHeightWithMargins } from '../util/dom';
import { import {
calculateVisibleThreads, calculateVisibleThreads,
THREAD_DIMENSION_DEFAULTS, THREAD_DIMENSION_DEFAULTS,
} from '../helpers/visible-threads'; } from '../helpers/visible-threads';
import { useStoreProxy } from '../store/use-store';
import { getElementHeightWithMargins } from '../util/dom';
import ThreadCard from './ThreadCard'; import ThreadCard from './ThreadCard';
import { ListenerCollection } from '../../annotator/util/listener-collection';
/** @typedef {import('../helpers/build-thread').Thread} Thread */ /** @typedef {import('../helpers/build-thread').Thread} Thread */
......
import { ListenerCollection } from '../../annotator/util/listener-collection'; import { ListenerCollection } from '../../shared/listener-collection';
/** /**
* Watch for changes in the size (`clientWidth` and `clientHeight`) of * Watch for changes in the size (`clientWidth` and `clientHeight`) of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment