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

Convert the rest of the default export into named exports

parent b1209d74
import { startApp } from '@hypothesis/frontend-shared/lib/pattern-library'; import { startApp } from '@hypothesis/frontend-shared/lib/pattern-library';
import ButtonPatterns from './components/ButtonPatterns'; import ButtonPatterns from './components/ButtonPatterns';
import sidebarIcons from '../../src/sidebar/icons'; import { sidebarIcons } from '../../src/sidebar/icons';
/** @type {import('@hypothesis/frontend-shared/lib/pattern-library').PlaygroundRoute[]} */ /** @type {import('@hypothesis/frontend-shared/lib/pattern-library').PlaygroundRoute[]} */
const extraRoutes = [ const extraRoutes = [
......
/* global PDFViewerApplication */ /* global PDFViewerApplication */
import warnOnce from '../../shared/warn-once'; import { warnOnce } from '../../shared/warn-once';
import { matchQuote } from './match-quote'; import { matchQuote } from './match-quote';
import { createPlaceholder } from './placeholder'; import { createPlaceholder } from './placeholder';
import { TextPosition, TextRange } from './text-range'; import { TextPosition, TextRange } from './text-range';
......
...@@ -251,7 +251,7 @@ class FakePDFViewer { ...@@ -251,7 +251,7 @@ class FakePDFViewer {
* *
* The original is defined at https://github.com/mozilla/pdf.js/blob/master/web/app.js * The original is defined at https://github.com/mozilla/pdf.js/blob/master/web/app.js
*/ */
export default class FakePDFViewerApplication { export class FakePDFViewerApplication {
/** /**
* @param {Options} options * @param {Options} options
*/ */
......
...@@ -27,7 +27,7 @@ import minimalJSON from './minimal.json'; ...@@ -27,7 +27,7 @@ import minimalJSON from './minimal.json';
import wikipediaDoc from './wikipedia-regression-testing.html'; import wikipediaDoc from './wikipedia-regression-testing.html';
import wikipediaJSON from './wikipedia-regression-testing.json'; import wikipediaJSON from './wikipedia-regression-testing.json';
export default [ export const htmlBaselines = [
{ {
name: 'Minimal Document', name: 'Minimal Document',
html: minimalDoc, html: minimalDoc,
......
import * as html from '../html'; import * as html from '../html';
import fixture from './html-anchoring-fixture.html'; import fixture from './html-anchoring-fixture.html';
import htmlBaselines from './html-baselines'; import { htmlBaselines } from './html-baselines';
/** Return all text node children of `container`. */ /** Return all text node children of `container`. */
function textNodes(container) { function textNodes(container) {
......
...@@ -3,7 +3,7 @@ import * as pdfAnchoring from '../pdf'; ...@@ -3,7 +3,7 @@ import * as pdfAnchoring from '../pdf';
import { matchQuote } from '../match-quote'; import { matchQuote } from '../match-quote';
import { TextRange } from '../text-range'; import { TextRange } from '../text-range';
import FakePDFViewerApplication from './fake-pdf-viewer-application'; import { FakePDFViewerApplication } from './fake-pdf-viewer-application';
/** /**
* Return a DOM Range which refers to the specified `text` in `container`. * Return a DOM Range which refers to the specified `text` in `container`.
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* @return {object} - Any config settings returned by hypothesisConfig() * @return {object} - Any config settings returned by hypothesisConfig()
* *
*/ */
export default function configFuncSettingsFrom(window_) { export function configFuncSettingsFrom(window_) {
if (!window_.hasOwnProperty('hypothesisConfig')) { if (!window_.hasOwnProperty('hypothesisConfig')) {
return {}; return {};
} }
......
import { isBrowserExtension } from './is-browser-extension'; import { isBrowserExtension } from './is-browser-extension';
import settingsFrom from './settings'; import { settingsFrom } from './settings';
import { toBoolean } from '../../shared/type-coercions'; import { toBoolean } from '../../shared/type-coercions';
import { urlFromLinkTag } from './url-from-link-tag'; import { urlFromLinkTag } from './url-from-link-tag';
......
import { parseJsonConfig } from '../../boot/parse-json-config'; import { parseJsonConfig } from '../../boot/parse-json-config';
import { toBoolean } from '../../shared/type-coercions'; import { toBoolean } from '../../shared/type-coercions';
import configFuncSettingsFrom from './config-func-settings-from'; import { configFuncSettingsFrom } from './config-func-settings-from';
import { urlFromLinkTag } from './url-from-link-tag'; import { urlFromLinkTag } from './url-from-link-tag';
/** /**
...@@ -20,7 +20,7 @@ import { urlFromLinkTag } from './url-from-link-tag'; ...@@ -20,7 +20,7 @@ import { urlFromLinkTag } from './url-from-link-tag';
/** /**
* @return {SettingsGetters} * @return {SettingsGetters}
*/ */
export default function settingsFrom(window_) { export function settingsFrom(window_) {
// Prioritize the `window.hypothesisConfig` function over the JSON format // Prioritize the `window.hypothesisConfig` function over the JSON format
// Via uses `window.hypothesisConfig` and makes it non-configurable and non-writable. // Via uses `window.hypothesisConfig` and makes it non-configurable and non-writable.
// In addition, Via sets the `ignoreOtherConfiguration` option to prevent configuration merging. // In addition, Via sets the `ignoreOtherConfiguration` option to prevent configuration merging.
......
import configFuncSettingsFrom from '../config-func-settings-from'; import { configFuncSettingsFrom } from '../config-func-settings-from';
describe('annotator.config.configFuncSettingsFrom', () => { describe('annotator.config.configFuncSettingsFrom', () => {
const sandbox = sinon.createSandbox(); const sandbox = sinon.createSandbox();
......
import { getConfig } from '../index'; import { getConfig, $imports } from '../index';
import { $imports } from '../index';
describe('annotator/config/index', () => { describe('annotator/config/index', () => {
let fakeSettingsFrom; let fakeSettingsFrom;
...@@ -20,7 +19,7 @@ describe('annotator/config/index', () => { ...@@ -20,7 +19,7 @@ describe('annotator/config/index', () => {
fakeIsBrowserExtension = sinon.stub(); fakeIsBrowserExtension = sinon.stub();
$imports.$mock({ $imports.$mock({
'./settings': fakeSettingsFrom, './settings': { settingsFrom: fakeSettingsFrom },
'./is-browser-extension': { './is-browser-extension': {
isBrowserExtension: fakeIsBrowserExtension, isBrowserExtension: fakeIsBrowserExtension,
}, },
...@@ -135,7 +134,8 @@ describe('annotator/config/index', () => { ...@@ -135,7 +134,8 @@ describe('annotator/config/index', () => {
beforeEach(() => { beforeEach(() => {
// Remove all fake values // Remove all fake values
$imports.$mock({ $imports.$mock({
'./settings': sinon.stub().returns({ './settings': {
settingsFrom: sinon.stub().returns({
hostPageSetting: sinon.stub().returns(undefined), hostPageSetting: sinon.stub().returns(undefined),
annotations: undefined, annotations: undefined,
clientUrl: undefined, clientUrl: undefined,
...@@ -145,6 +145,7 @@ describe('annotator/config/index', () => { ...@@ -145,6 +145,7 @@ describe('annotator/config/index', () => {
sidebarAppUrl: undefined, sidebarAppUrl: undefined,
query: undefined, query: undefined,
}), }),
},
}); });
}); });
......
import settingsFrom from '../settings'; import { settingsFrom, $imports } from '../settings';
import { $imports } from '../settings';
describe('annotator/config/settingsFrom', () => { describe('annotator/config/settingsFrom', () => {
let fakeConfigFuncSettingsFrom; let fakeConfigFuncSettingsFrom;
...@@ -12,7 +11,9 @@ describe('annotator/config/settingsFrom', () => { ...@@ -12,7 +11,9 @@ describe('annotator/config/settingsFrom', () => {
fakeParseJsonConfig = sinon.stub().returns({}); fakeParseJsonConfig = sinon.stub().returns({});
$imports.$mock({ $imports.$mock({
'./config-func-settings-from': fakeConfigFuncSettingsFrom, './config-func-settings-from': {
configFuncSettingsFrom: fakeConfigFuncSettingsFrom,
},
'./url-from-link-tag': { './url-from-link-tag': {
urlFromLinkTag: fakeUrlFromLinkTag, urlFromLinkTag: fakeUrlFromLinkTag,
}, },
......
import warnOnce from '../shared/warn-once'; import { warnOnce } from '../shared/warn-once';
let _features = {}; let _features = {};
......
...@@ -20,7 +20,7 @@ import pointerIcon from '../images/icons/pointer.svg'; ...@@ -20,7 +20,7 @@ import pointerIcon from '../images/icons/pointer.svg';
* Set of icons used by the annotator part of the application via the `SvgIcon` * Set of icons used by the annotator part of the application via the `SvgIcon`
* component. * component.
*/ */
export default { export const annotatorIcons = {
annotate: annotateIcon, annotate: annotateIcon,
cancel, cancel,
caution, caution,
......
...@@ -6,8 +6,8 @@ import 'preact/debug'; ...@@ -6,8 +6,8 @@ import 'preact/debug';
// Load icons. // Load icons.
import { registerIcons } from '@hypothesis/frontend-shared'; import { registerIcons } from '@hypothesis/frontend-shared';
import iconSet from './icons'; import { annotatorIcons } from './icons';
registerIcons(iconSet); registerIcons(annotatorIcons);
import { PortProvider } from '../shared/messaging'; import { PortProvider } from '../shared/messaging';
import { getConfig } from './config/index'; import { getConfig } from './config/index';
......
import { delay } from '../../../test-util/wait'; import { delay } from '../../../test-util/wait';
import FakePDFViewerApplication from '../../anchoring/test/fake-pdf-viewer-application'; import { FakePDFViewerApplication } from '../../anchoring/test/fake-pdf-viewer-application';
import { RenderingStates } from '../../anchoring/pdf'; import { RenderingStates } from '../../anchoring/pdf';
import { createPlaceholder } from '../../anchoring/placeholder'; import { createPlaceholder } from '../../anchoring/placeholder';
import { PDFIntegration, isPDF, $imports } from '../pdf'; import { PDFIntegration, isPDF, $imports } from '../pdf';
......
...@@ -8,7 +8,7 @@ const SIDEBAR_TRIGGER_BTN_ATTR = 'data-hypothesis-trigger'; ...@@ -8,7 +8,7 @@ const SIDEBAR_TRIGGER_BTN_ATTR = 'data-hypothesis-trigger';
* @param {object} showFn - Function which shows the sidebar. * @param {object} showFn - Function which shows the sidebar.
*/ */
export default function trigger(rootEl, showFn) { export function sidebarTrigger(rootEl, showFn) {
const triggerElems = rootEl.querySelectorAll( const triggerElems = rootEl.querySelectorAll(
'[' + SIDEBAR_TRIGGER_BTN_ATTR + ']' '[' + SIDEBAR_TRIGGER_BTN_ATTR + ']'
); );
......
...@@ -9,7 +9,7 @@ import { annotationCounts } from './annotation-counts'; ...@@ -9,7 +9,7 @@ import { annotationCounts } from './annotation-counts';
import { BucketBar } from './bucket-bar'; import { BucketBar } from './bucket-bar';
import { createAppConfig } from './config/app'; import { createAppConfig } from './config/app';
import { features } from './features'; import { features } from './features';
import sidebarTrigger from './sidebar-trigger'; 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';
......
...@@ -16,7 +16,7 @@ describe('features - annotation layer', () => { ...@@ -16,7 +16,7 @@ describe('features - annotation layer', () => {
beforeEach(() => { beforeEach(() => {
fakeWarnOnce = sinon.stub(); fakeWarnOnce = sinon.stub();
$imports.$mock({ $imports.$mock({
'../shared/warn-once': fakeWarnOnce, '../shared/warn-once': { warnOnce: fakeWarnOnce },
}); });
features.init({ features.init({
......
import sidebarTrigger from '../sidebar-trigger'; import { sidebarTrigger } from '../sidebar-trigger';
describe('sidebarTrigger', () => { describe('sidebarTrigger', () => {
let triggerEl1; let triggerEl1;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import { parseJsonConfig } from './parse-json-config'; import { parseJsonConfig } from './parse-json-config';
import { bootHypothesisClient, bootSidebarApp } from './boot'; import { bootHypothesisClient, bootSidebarApp } from './boot';
import processUrlTemplate from './url-template'; import { processUrlTemplate } from './url-template';
import { isBrowserSupported } from './browser-check'; import { isBrowserSupported } from './browser-check';
// @ts-ignore - This file is generated before the boot bundle is built. // @ts-ignore - This file is generated before the boot bundle is built.
......
import processUrlTemplate from '../url-template'; import { processUrlTemplate } from '../url-template';
describe('processUrlTemplate', () => { describe('processUrlTemplate', () => {
let fakeDocument; let fakeDocument;
......
...@@ -36,7 +36,7 @@ function currentScriptOrigin(document_ = document) { ...@@ -36,7 +36,7 @@ function currentScriptOrigin(document_ = document) {
* @param {string} url * @param {string} url
* @param {Document} document_ * @param {Document} document_
*/ */
export default function processUrlTemplate(url, document_ = document) { export function processUrlTemplate(url, document_ = document) {
if (url.indexOf('{') === -1) { if (url.indexOf('{') === -1) {
// Not a template. This should always be the case in production. // Not a template. This should always be the case in production.
return url; return url;
......
import warnOnce from '../warn-once'; import { warnOnce } from '../warn-once';
describe('warnOnce', () => { describe('warnOnce', () => {
beforeEach(() => { beforeEach(() => {
......
...@@ -11,7 +11,7 @@ let shownWarnings = {}; ...@@ -11,7 +11,7 @@ let shownWarnings = {};
* are concatenated into a string key which is used to determine if the warning * are concatenated into a string key which is used to determine if the warning
* has been logged before. * has been logged before.
*/ */
export default function warnOnce(...args) { export function warnOnce(...args) {
const key = args.join(); const key = args.join();
if (key in shownWarnings) { if (key in shownWarnings) {
return; return;
......
...@@ -2,7 +2,7 @@ import { LinkButton } from '@hypothesis/frontend-shared'; ...@@ -2,7 +2,7 @@ import { LinkButton } from '@hypothesis/frontend-shared';
import classnames from 'classnames'; import classnames from 'classnames';
import { useCallback, useLayoutEffect, useRef, useState } from 'preact/hooks'; import { useCallback, useLayoutEffect, useRef, useState } from 'preact/hooks';
import observeElementSize from '../util/observe-element-size'; import { observeElementSize } from '../util/observe-element-size';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
import { applyTheme } from '../helpers/theme'; import { applyTheme } from '../helpers/theme';
......
...@@ -3,7 +3,7 @@ import { useMemo, useState } from 'preact/hooks'; ...@@ -3,7 +3,7 @@ import { useMemo, useState } from 'preact/hooks';
import { serviceConfig } from '../../config/service-config'; import { serviceConfig } from '../../config/service-config';
import { isThirdPartyUser } from '../../helpers/account-id'; import { isThirdPartyUser } from '../../helpers/account-id';
import { orgName } from '../../helpers/group-list-item-common'; import { orgName } from '../../helpers/group-list-item-common';
import groupsByOrganization from '../../helpers/group-organizations'; import { groupsByOrganization } from '../../helpers/group-organizations';
import { isThirdPartyService } from '../../helpers/is-third-party-service'; import { isThirdPartyService } from '../../helpers/is-third-party-service';
import { withServices } from '../../service-context'; import { withServices } from '../../service-context';
import { useStoreProxy } from '../../store/use-store'; import { useStoreProxy } from '../../store/use-store';
......
...@@ -110,10 +110,12 @@ describe('GroupList', () => { ...@@ -110,10 +110,12 @@ describe('GroupList', () => {
it('sorts groups within each section by organization', () => { it('sorts groups within each section by organization', () => {
const testGroups = populateGroupSections(); const testGroups = populateGroupSections();
const fakeGroupOrganizations = groups => const fakeGroupsByOrganization = groups =>
groups.sort((a, b) => a.id.localeCompare(b.id)); groups.sort((a, b) => a.id.localeCompare(b.id));
$imports.$mock({ $imports.$mock({
'../../helpers/group-organizations': fakeGroupOrganizations, '../../helpers/group-organizations': {
groupsByOrganization: fakeGroupsByOrganization,
},
}); });
const wrapper = createGroupList(); const wrapper = createGroupList();
...@@ -123,7 +125,7 @@ describe('GroupList', () => { ...@@ -123,7 +125,7 @@ describe('GroupList', () => {
sections.forEach(section => { sections.forEach(section => {
assert.deepEqual( assert.deepEqual(
section.prop('groups'), section.prop('groups'),
fakeGroupOrganizations(testGroups) fakeGroupsByOrganization(testGroups)
); );
}); });
}); });
......
...@@ -3,7 +3,7 @@ import { useCallback, useMemo, useState } from 'preact/hooks'; ...@@ -3,7 +3,7 @@ import { useCallback, useMemo, useState } from 'preact/hooks';
import { useStoreProxy } from '../store/use-store'; import { useStoreProxy } from '../store/use-store';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
import VersionData from '../helpers/version-data'; import { VersionData } from '../helpers/version-data';
import SidebarPanel from './SidebarPanel'; import SidebarPanel from './SidebarPanel';
import Tutorial from './Tutorial'; import Tutorial from './Tutorial';
......
...@@ -2,7 +2,7 @@ import classnames from 'classnames'; ...@@ -2,7 +2,7 @@ import classnames from 'classnames';
import { useEffect, useMemo, useRef } from 'preact/hooks'; import { useEffect, useMemo, useRef } from 'preact/hooks';
import { replaceLinksWithEmbeds } from '../media-embedder'; import { replaceLinksWithEmbeds } from '../media-embedder';
import renderMarkdown from '../render-markdown'; import { renderMathAndMarkdown as renderMarkdown } from '../render-markdown';
/** /**
* @typedef MarkdownViewProps * @typedef MarkdownViewProps
......
...@@ -5,7 +5,7 @@ import { withServices } from '../service-context'; ...@@ -5,7 +5,7 @@ import { withServices } from '../service-context';
/** /**
* @typedef VersionInfoProps * @typedef VersionInfoProps
* @prop {import('../helpers/version-data').default} versionData - Object with version information * @prop {import('../helpers/version-data').VersionData} versionData - Object with version information
* @prop {import('../services/toast-messenger').ToastMessengerService} toastMessenger * @prop {import('../services/toast-messenger').ToastMessengerService} toastMessenger
*/ */
......
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import useRootThread from '../use-root-thread'; import useRootThread, { $imports } from '../use-root-thread';
import { $imports } from '../use-root-thread';
describe('sidebar/components/hooks/use-root-thread', () => { describe('sidebar/components/hooks/use-root-thread', () => {
let fakeStore; let fakeStore;
...@@ -20,7 +19,9 @@ describe('sidebar/components/hooks/use-root-thread', () => { ...@@ -20,7 +19,9 @@ describe('sidebar/components/hooks/use-root-thread', () => {
$imports.$mock({ $imports.$mock({
'../../store/use-store': { useStoreProxy: () => fakeStore }, '../../store/use-store': { useStoreProxy: () => fakeStore },
'../../helpers/thread-annotations': fakeThreadAnnotations, '../../helpers/thread-annotations': {
threadAnnotations: fakeThreadAnnotations,
},
}); });
// Mount a dummy component to be able to use the `useRootThread` hook // Mount a dummy component to be able to use the `useRootThread` hook
......
import { useMemo } from 'preact/hooks'; import { useMemo } from 'preact/hooks';
import { useStoreProxy } from '../../store/use-store'; import { useStoreProxy } from '../../store/use-store';
import threadAnnotations from '../../helpers/thread-annotations'; import { threadAnnotations } from '../../helpers/thread-annotations';
/** @typedef {import('../../helpers/build-thread').Thread} Thread */ /** @typedef {import('../../helpers/build-thread').Thread} Thread */
......
...@@ -39,7 +39,9 @@ describe('Excerpt', () => { ...@@ -39,7 +39,9 @@ describe('Excerpt', () => {
document.body.appendChild(container); document.body.appendChild(container);
$imports.$mock({ $imports.$mock({
'../util/observe-element-size': fakeObserveElementSize, '../util/observe-element-size': {
observeElementSize: fakeObserveElementSize,
},
}); });
}); });
......
...@@ -41,7 +41,7 @@ describe('HelpPanel', () => { ...@@ -41,7 +41,7 @@ describe('HelpPanel', () => {
$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
$imports.$mock({ $imports.$mock({
'../store/use-store': { useStoreProxy: () => fakeStore }, '../store/use-store': { useStoreProxy: () => fakeStore },
'../helpers/version-data': FakeVersionData, '../helpers/version-data': { VersionData: FakeVersionData },
}); });
}); });
......
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import MarkdownView from '../MarkdownView'; import MarkdownView, { $imports } from '../MarkdownView';
import { $imports } from '../MarkdownView';
import { checkAccessibility } from '../../../test-util/accessibility'; import { checkAccessibility } from '../../../test-util/accessibility';
describe('MarkdownView', () => { describe('MarkdownView', () => {
let fakeMediaEmbedder; let fakeRenderMathAndMarkdown;
let fakeRenderMarkdown; let fakeReplaceLinksWithEmbeds;
beforeEach(() => { beforeEach(() => {
fakeRenderMarkdown = markdown => `rendered:${markdown}`; fakeRenderMathAndMarkdown = markdown => `rendered:${markdown}`;
fakeMediaEmbedder = { fakeReplaceLinksWithEmbeds = sinon.stub();
replaceLinksWithEmbeds: sinon.stub(),
};
$imports.$mock({ $imports.$mock({
'../render-markdown': fakeRenderMarkdown, '../render-markdown': {
'../media-embedder': fakeMediaEmbedder, renderMathAndMarkdown: fakeRenderMathAndMarkdown,
},
'../media-embedder': {
replaceLinksWithEmbeds: fakeReplaceLinksWithEmbeds,
},
}); });
}); });
...@@ -46,7 +47,7 @@ describe('MarkdownView', () => { ...@@ -46,7 +47,7 @@ describe('MarkdownView', () => {
it('replaces links with embeds in rendered output', () => { it('replaces links with embeds in rendered output', () => {
const wrapper = mount(<MarkdownView markdown="**test**" />); const wrapper = mount(<MarkdownView markdown="**test**" />);
const rendered = wrapper.find('.MarkdownView').getDOMNode(); const rendered = wrapper.find('.MarkdownView').getDOMNode();
assert.calledWith(fakeMediaEmbedder.replaceLinksWithEmbeds, rendered, { assert.calledWith(fakeReplaceLinksWithEmbeds, rendered, {
className: 'MarkdownView__embed', className: 'MarkdownView__embed',
}); });
}); });
......
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import { act } from 'preact/test-utils'; import { act } from 'preact/test-utils';
import MenuItem from '../MenuItem'; import MenuItem, { $imports } from '../MenuItem';
import { $imports } from '../MenuItem';
import { checkAccessibility } from '../../../test-util/accessibility'; import { checkAccessibility } from '../../../test-util/accessibility';
import { mockImportedComponents } from '../../../test-util/mock-imported-components'; import { mockImportedComponents } from '../../../test-util/mock-imported-components';
......
import getApiUrl from './get-api-url'; import { getApiUrl } from './get-api-url';
import hostConfig from './host-config'; import { hostPageConfig as hostConfig } from './host-config';
import * as postMessageJsonRpc from '../util/postmessage-json-rpc'; import * as postMessageJsonRpc from '../util/postmessage-json-rpc';
/** /**
......
...@@ -8,7 +8,7 @@ import { serviceConfig } from './service-config'; ...@@ -8,7 +8,7 @@ import { serviceConfig } from './service-config';
* @throws {Error} If the settings has a service but the service doesn't have an apiUrl * @throws {Error} If the settings has a service but the service doesn't have an apiUrl
* *
*/ */
export default function getApiUrl(settings) { export function getApiUrl(settings) {
const service = serviceConfig(settings); const service = serviceConfig(settings);
if (service) { if (service) {
......
...@@ -15,7 +15,7 @@ import { ...@@ -15,7 +15,7 @@ import {
* @param {Window} window * @param {Window} window
* @return {HostConfig} * @return {HostConfig}
*/ */
export default function hostPageConfig(window) { export function hostPageConfig(window) {
const config = parseConfigFragment(window.location.href); const config = parseConfigFragment(window.location.href);
// Known configuration parameters which we will import from the host page. // Known configuration parameters which we will import from the host page.
......
import { fetchConfig, $imports } from '../fetch-config'; import { fetchConfig, $imports } from '../fetch-config';
describe('sidebar/config/fetch-config', () => { describe('sidebar/config/fetch-config', () => {
let fakeHostConfig; let fakeHostPageConfig;
let fakeJsonRpc; let fakeJsonRpc;
let fakeWindow; let fakeWindow;
let fakeApiUrl; let fakeApiUrl;
let fakeTopWindow; let fakeTopWindow;
beforeEach(() => { beforeEach(() => {
fakeHostConfig = sinon.stub(); fakeHostPageConfig = sinon.stub();
fakeJsonRpc = { fakeJsonRpc = {
call: sinon.stub(), call: sinon.stub(),
}; };
fakeApiUrl = sinon.stub().returns('https://dev.hypothes.is/api/'); fakeApiUrl = sinon.stub().returns('https://dev.hypothes.is/api/');
$imports.$mock({ $imports.$mock({
'./host-config': fakeHostConfig, './host-config': { hostPageConfig: fakeHostPageConfig },
'../util/postmessage-json-rpc': fakeJsonRpc, '../util/postmessage-json-rpc': fakeJsonRpc,
'./get-api-url': fakeApiUrl, './get-api-url': { getApiUrl: fakeApiUrl },
}); });
// By default, embedder provides no custom config. // By default, embedder provides no custom config.
fakeHostConfig.returns({}); fakeHostPageConfig.returns({});
// By default, fetching config from parent frames fails. // By default, fetching config from parent frames fails.
fakeJsonRpc.call.throws(new Error('call() response not set')); fakeJsonRpc.call.throws(new Error('call() response not set'));
...@@ -59,7 +59,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -59,7 +59,7 @@ describe('sidebar/config/fetch-config', () => {
it('merges the hostPageConfig onto appConfig and returns the result', async () => { it('merges the hostPageConfig onto appConfig and returns the result', async () => {
// hostPageConfig shall take precedent over appConfig // hostPageConfig shall take precedent over appConfig
const appConfig = { foo: 'bar', appType: 'via' }; const appConfig = { foo: 'bar', appType: 'via' };
fakeHostConfig.returns({ foo: 'baz' }); fakeHostPageConfig.returns({ foo: 'baz' });
const mergedConfig = await fetchConfig(appConfig); const mergedConfig = await fetchConfig(appConfig);
assert.deepEqual(mergedConfig, { assert.deepEqual(mergedConfig, {
foo: 'baz', foo: 'baz',
...@@ -79,7 +79,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -79,7 +79,7 @@ describe('sidebar/config/fetch-config', () => {
// exposed to the document itself. // exposed to the document itself.
const expectedTimeout = 3000; const expectedTimeout = 3000;
beforeEach(() => { beforeEach(() => {
fakeHostConfig.returns({ fakeHostPageConfig.returns({
requestConfigFromFrame: 'https://embedder.com', requestConfigFromFrame: 'https://embedder.com',
}); });
sinon.stub(console, 'warn'); sinon.stub(console, 'warn');
...@@ -169,7 +169,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -169,7 +169,7 @@ describe('sidebar/config/fetch-config', () => {
// exposed to the document itself. // exposed to the document itself.
beforeEach(() => { beforeEach(() => {
fakeJsonRpc.call.resolves({}); fakeJsonRpc.call.resolves({});
fakeHostConfig.returns({ fakeHostPageConfig.returns({
requestConfigFromFrame: { requestConfigFromFrame: {
origin: 'https://embedder.com', origin: 'https://embedder.com',
ancestorLevel: 2, ancestorLevel: 2,
...@@ -192,7 +192,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -192,7 +192,7 @@ describe('sidebar/config/fetch-config', () => {
[0, 1, 2].forEach(level => { [0, 1, 2].forEach(level => {
it(`finds ${level}'th ancestor window according to how high the level is`, async () => { it(`finds ${level}'th ancestor window according to how high the level is`, async () => {
fakeHostConfig.returns({ fakeHostPageConfig.returns({
requestConfigFromFrame: { requestConfigFromFrame: {
origin: 'https://embedder.com', origin: 'https://embedder.com',
ancestorLevel: level, ancestorLevel: level,
...@@ -205,7 +205,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -205,7 +205,7 @@ describe('sidebar/config/fetch-config', () => {
}); });
it('throws an error when target ancestor exceeds top window', async () => { it('throws an error when target ancestor exceeds top window', async () => {
fakeHostConfig.returns({ fakeHostPageConfig.returns({
requestConfigFromFrame: { requestConfigFromFrame: {
origin: 'https://embedder.com', origin: 'https://embedder.com',
ancestorLevel: 10, // The top window is only 2 levels high ancestorLevel: 10, // The top window is only 2 levels high
...@@ -279,7 +279,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -279,7 +279,7 @@ describe('sidebar/config/fetch-config', () => {
}); });
it('creates a merged config and also adds back the `group` value from the host config', async () => { it('creates a merged config and also adds back the `group` value from the host config', async () => {
fakeHostConfig.returns({ fakeHostPageConfig.returns({
requestConfigFromFrame: { requestConfigFromFrame: {
origin: 'https://embedder.com', origin: 'https://embedder.com',
ancestorLevel: 2, ancestorLevel: 2,
...@@ -306,7 +306,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -306,7 +306,7 @@ describe('sidebar/config/fetch-config', () => {
}); });
it('missing ancestorLevel', async () => { it('missing ancestorLevel', async () => {
fakeHostConfig.returns({ fakeHostPageConfig.returns({
requestConfigFromFrame: { requestConfigFromFrame: {
origin: 'https://embedder.com', origin: 'https://embedder.com',
// missing ancestorLevel // missing ancestorLevel
...@@ -319,7 +319,7 @@ describe('sidebar/config/fetch-config', () => { ...@@ -319,7 +319,7 @@ describe('sidebar/config/fetch-config', () => {
}); });
it('missing origin', async () => { it('missing origin', async () => {
fakeHostConfig.returns({ fakeHostPageConfig.returns({
requestConfigFromFrame: { requestConfigFromFrame: {
// missing origin // missing origin
ancestorLevel: 2, ancestorLevel: 2,
......
import getApiUrl from '../get-api-url'; import { getApiUrl } from '../get-api-url';
describe('sidebar/config/get-api-url', () => { describe('sidebar/config/get-api-url', () => {
context('when there is a service object in settings', () => { context('when there is a service object in settings', () => {
......
import { addConfigFragment } from '../../../shared/config-fragment'; import { addConfigFragment } from '../../../shared/config-fragment';
import hostPageConfig from '../host-config'; import { hostPageConfig } from '../host-config';
function fakeWindow(config) { function fakeWindow(config) {
return { return {
......
import warnOnce from '../shared/warn-once'; import { warnOnce } from '../shared/warn-once';
import { normalizeGroupIds } from './helpers/groups'; import { normalizeGroupIds } from './helpers/groups';
......
...@@ -284,7 +284,7 @@ const replySortCompareFn = (a, b) => { ...@@ -284,7 +284,7 @@ const replySortCompareFn = (a, b) => {
* @return {Thread} - The root thread, whose children are the top-level * @return {Thread} - The root thread, whose children are the top-level
* annotations to display. * annotations to display.
*/ */
export default function buildThread(annotations, options) { export function buildThread(annotations, options) {
const hasSelection = options.selected.length > 0; const hasSelection = options.selected.length > 0;
const hasForcedVisible = options.forcedVisible.length > 0; const hasForcedVisible = options.forcedVisible.length > 0;
......
import immutable from '../util/immutable'; import { immutable } from '../util/immutable';
/** /**
* @typedef {import('../../types/api').Group} Group * @typedef {import('../../types/api').Group} Group
...@@ -83,7 +83,7 @@ function organizations(groups) { ...@@ -83,7 +83,7 @@ function organizations(groups) {
* @param {Array<Group>} groups * @param {Array<Group>} groups
* @return {Array<object>} - groups sorted by which organization they're in * @return {Array<object>} - groups sorted by which organization they're in
*/ */
export default function groupsByOrganization(groups) { export function groupsByOrganization(groups) {
const orgs = organizations(groups); const orgs = organizations(groups);
const defaultOrganizationGroups = []; const defaultOrganizationGroups = [];
const sortedGroups = []; const sortedGroups = [];
......
import buildThread from '../build-thread'; import { buildThread } from '../build-thread';
import * as metadata from '../../helpers/annotation-metadata'; import * as metadata from '../../helpers/annotation-metadata';
// Fixture with two top level annotations, one note and one reply // Fixture with two top level annotations, one note and one reply
......
import * as orgFixtures from '../../test/group-fixtures'; import * as orgFixtures from '../../test/group-fixtures';
import groupsByOrganization from '../group-organizations'; import { groupsByOrganization } from '../group-organizations';
describe('sidebar/helpers/group-organizations', () => { describe('sidebar/helpers/group-organizations', () => {
context('when sorting organizations and their contained groups', () => { context('when sorting organizations and their contained groups', () => {
......
import * as annotationFixtures from '../../test/annotation-fixtures'; import * as annotationFixtures from '../../test/annotation-fixtures';
import threadAnnotations from '../thread-annotations'; import { threadAnnotations, $imports } from '../thread-annotations';
import { sorters } from '../thread-sorters'; import { sorters } from '../thread-sorters';
import { $imports } from '../thread-annotations'; import { immutable } from '../../util/immutable';
import immutable from '../../util/immutable';
const fixtures = immutable({ const fixtures = immutable({
emptyThread: { emptyThread: {
...@@ -45,9 +44,9 @@ describe('sidebar/helpers/thread-annotations', () => { ...@@ -45,9 +44,9 @@ describe('sidebar/helpers/thread-annotations', () => {
}; };
$imports.$mock({ $imports.$mock({
'./build-thread': fakeBuildThread, './build-thread': { buildThread: fakeBuildThread },
'../util/search-filter': fakeSearchFilter, '../util/search-filter': fakeSearchFilter,
'./view-filter': fakeFilterAnnotations, './view-filter': { filterAnnotations: fakeFilterAnnotations },
}); });
}); });
......
import VersionData from '../version-data'; import { VersionData } from '../version-data';
describe('sidebar/helpers/version-data', () => { describe('sidebar/helpers/version-data', () => {
let clock; let clock;
......
import filterAnnotations, { $imports } from '../view-filter'; import { filterAnnotations, $imports } from '../view-filter';
function isoDateWithAge(age) { function isoDateWithAge(age) {
return new Date(Date.now() - age * 1000).toISOString(); return new Date(Date.now() - age * 1000).toISOString();
......
import buildThread from './build-thread'; import { buildThread } from './build-thread';
import memoize from '../util/memoize'; import { memoize } from '../util/memoize';
import { generateFacetedFilter } from '../util/search-filter'; import { generateFacetedFilter } from '../util/search-filter';
import filterAnnotations from './view-filter'; import { filterAnnotations } from './view-filter';
import { shouldShowInTab } from './tabs'; import { shouldShowInTab } from './tabs';
import { sorters } from './thread-sorters'; import { sorters } from './thread-sorters';
...@@ -71,6 +71,4 @@ function buildRootThread(threadState) { ...@@ -71,6 +71,4 @@ function buildRootThread(threadState) {
return buildThread(threadState.annotations, options); return buildThread(threadState.annotations, options);
} }
const threadAnnotations = memoize(buildRootThread); export const threadAnnotations = memoize(buildRootThread);
export default threadAnnotations;
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* @prop {DocMetadata} [metadata] - Document metadata * @prop {DocMetadata} [metadata] - Document metadata
*/ */
export default class VersionData { export class VersionData {
/** /**
* @param {AuthState} userInfo * @param {AuthState} userInfo
* @param {DocumentInfo[]} documentInfo - Metadata for connected frames. * @param {DocumentInfo[]} documentInfo - Metadata for connected frames.
......
...@@ -158,7 +158,7 @@ const fieldMatchers = { ...@@ -158,7 +158,7 @@ const fieldMatchers = {
* `generateFacetedFilter`. * `generateFacetedFilter`.
* @return {string[]} IDs of matching annotations. * @return {string[]} IDs of matching annotations.
*/ */
export default function filterAnnotations(annotations, filters) { export function filterAnnotations(annotations, filters) {
// Convert the input filter object into a filter tree, expanding "any" // Convert the input filter object into a filter tree, expanding "any"
// filters. // filters.
const fieldFilters = Object.entries(filters) const fieldFilters = Object.entries(filters)
......
...@@ -56,7 +56,7 @@ import pointerIcon from '../images/icons/pointer.svg'; ...@@ -56,7 +56,7 @@ import pointerIcon from '../images/icons/pointer.svg';
* Set of icons used by the sidebar application via the `SvgIcon` * Set of icons used by the sidebar application via the `SvgIcon`
* component. * component.
*/ */
export default { export const sidebarIcons = {
add: plus, add: plus,
annotate: annotateIcon, annotate: annotateIcon,
'arrow-left': arrowLeft, 'arrow-left': arrowLeft,
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
startServer as startRPCServer, startServer as startRPCServer,
preStartServer as preStartRPCServer, preStartServer as preStartRPCServer,
} from './cross-origin-rpc.js'; } from './cross-origin-rpc.js';
import disableOpenerForExternalLinks from './util/disable-opener-for-external-links'; import { disableOpenerForExternalLinks } from './util/disable-opener-for-external-links';
import * as sentry from './util/sentry'; import * as sentry from './util/sentry';
// Read settings rendered into sidebar app HTML by service/extension. // Read settings rendered into sidebar app HTML by service/extension.
...@@ -100,9 +100,9 @@ function setupFrameSync(frameSync, store) { ...@@ -100,9 +100,9 @@ function setupFrameSync(frameSync, store) {
// Register icons used by the sidebar app (and maybe other assets in future). // Register icons used by the sidebar app (and maybe other assets in future).
import { registerIcons } from '@hypothesis/frontend-shared'; import { registerIcons } from '@hypothesis/frontend-shared';
import iconSet from './icons'; import { sidebarIcons } from './icons';
registerIcons(iconSet); registerIcons(sidebarIcons);
// The entry point component for the app. // The entry point component for the app.
import { render } from 'preact'; import { render } from 'preact';
......
...@@ -131,7 +131,7 @@ function insertMath(html, mathBlocks) { ...@@ -131,7 +131,7 @@ function insertMath(html, mathBlocks) {
}, html); }, html);
} }
export default function renderMathAndMarkdown(markdown) { export function renderMathAndMarkdown(markdown) {
// KaTeX takes care of escaping its input, so we want to avoid passing its // KaTeX takes care of escaping its input, so we want to avoid passing its
// output through the HTML sanitizer. Therefore we first extract the math // output through the HTML sanitizer. Therefore we first extract the math
// blocks from the input, render and sanitize the remaining markdown and then // blocks from the input, render and sanitize the remaining markdown and then
......
import { TinyEmitter } from 'tiny-emitter'; import { TinyEmitter } from 'tiny-emitter';
import { serviceConfig } from '../config/service-config'; import { serviceConfig } from '../config/service-config';
import OAuthClient from '../util/oauth-client'; import { OAuthClient } from '../util/oauth-client';
import { resolve } from '../util/url'; import { resolve } from '../util/url';
/** /**
......
import { generateHexString } from '../../shared/random'; import { generateHexString } from '../../shared/random';
import warnOnce from '../../shared/warn-once'; import { warnOnce } from '../../shared/warn-once';
import { Socket } from '../websocket';
import { watch } from '../util/watch'; import { watch } from '../util/watch';
import { Socket } from '../websocket';
/** /**
* `StreamerService` manages the WebSocket connection to the Hypothesis Real-Time * `StreamerService` manages the WebSocket connection to the Hypothesis Real-Time
......
import { Injector } from '../../../shared/injector'; import { Injector } from '../../../shared/injector';
import FakeWindow from '../../test/fake-window'; import { FakeWindow } from '../../test/fake-window';
import { AuthService, $imports } from '../auth'; import { AuthService, $imports } from '../auth';
const DEFAULT_TOKEN_EXPIRES_IN_SECS = 1000; const DEFAULT_TOKEN_EXPIRES_IN_SECS = 1000;
...@@ -87,7 +87,7 @@ describe('AuthService', () => { ...@@ -87,7 +87,7 @@ describe('AuthService', () => {
fakeWindow = new FakeWindow(); fakeWindow = new FakeWindow();
$imports.$mock({ $imports.$mock({
'../util/oauth-client': FakeOAuthClient, '../util/oauth-client': { OAuthClient: FakeOAuthClient },
}); });
auth = new Injector() auth = new Injector()
......
import * as annotationFixtures from '../../test/annotation-fixtures'; import * as annotationFixtures from '../../test/annotation-fixtures';
import createFakeStore from '../../test/fake-redux-store'; import { fakeReduxStore } from '../../test/fake-redux-store';
import { waitFor } from '../../../test-util/wait'; import { waitFor } from '../../../test-util/wait';
import { AutosaveService, $imports } from '../autosave'; import { AutosaveService, $imports } from '../autosave';
...@@ -14,7 +14,7 @@ describe('AutosaveService', () => { ...@@ -14,7 +14,7 @@ describe('AutosaveService', () => {
fakeAnnotationsService = { save: sinon.stub().resolves() }; fakeAnnotationsService = { save: sinon.stub().resolves() };
fakeNewHighlights = sinon.stub().returns([]); fakeNewHighlights = sinon.stub().returns([]);
fakeRetryPromiseOperation = sinon.stub().callsFake(callback => callback()); fakeRetryPromiseOperation = sinon.stub().callsFake(callback => callback());
fakeStore = createFakeStore({}, { newHighlights: fakeNewHighlights }); fakeStore = fakeReduxStore({}, { newHighlights: fakeNewHighlights });
$imports.$mock({ $imports.$mock({
'../util/retry': { '../util/retry': {
......
...@@ -2,7 +2,7 @@ import EventEmitter from 'tiny-emitter'; ...@@ -2,7 +2,7 @@ import EventEmitter from 'tiny-emitter';
import { Injector } from '../../../shared/injector'; import { Injector } from '../../../shared/injector';
import * as annotationFixtures from '../../test/annotation-fixtures'; import * as annotationFixtures from '../../test/annotation-fixtures';
import createFakeStore from '../../test/fake-redux-store'; import { fakeReduxStore } from '../../test/fake-redux-store';
import { delay } from '../../../test-util/wait'; import { delay } from '../../../test-util/wait';
import { FrameSyncService, $imports, formatAnnot } from '../frame-sync'; import { FrameSyncService, $imports, formatAnnot } from '../frame-sync';
...@@ -91,7 +91,7 @@ describe('FrameSyncService', () => { ...@@ -91,7 +91,7 @@ describe('FrameSyncService', () => {
discover: sinon.stub().resolves(sidebarPort), discover: sinon.stub().resolves(sidebarPort),
}; };
fakeStore = createFakeStore( fakeStore = fakeReduxStore(
{ annotations: [] }, { annotations: [] },
{ {
allAnnotations() { allAnnotations() {
......
import { delay, waitFor } from '../../../test-util/wait'; import { delay, waitFor } from '../../../test-util/wait';
import fakeReduxStore from '../../test/fake-redux-store'; import { fakeReduxStore } from '../../test/fake-redux-store';
import { GroupsService, $imports } from '../groups'; import { GroupsService, $imports } from '../groups';
/** /**
......
import fakeReduxStore from '../../test/fake-redux-store'; import { fakeReduxStore } from '../../test/fake-redux-store';
import { PersistedDefaultsService } from '../persisted-defaults'; import { PersistedDefaultsService } from '../persisted-defaults';
const DEFAULT_KEYS = { const DEFAULT_KEYS = {
......
import EventEmitter from 'tiny-emitter'; import EventEmitter from 'tiny-emitter';
import { delay } from '../../../test-util/wait'; import { delay } from '../../../test-util/wait';
import fakeReduxStore from '../../test/fake-redux-store'; import { fakeReduxStore } from '../../test/fake-redux-store';
import { StreamerService, $imports } from '../streamer'; import { StreamerService, $imports } from '../streamer';
const fixtures = { const fixtures = {
...@@ -129,7 +129,7 @@ describe('StreamerService', () => { ...@@ -129,7 +129,7 @@ describe('StreamerService', () => {
fakeWarnOnce = sinon.stub(); fakeWarnOnce = sinon.stub();
$imports.$mock({ $imports.$mock({
'../../shared/warn-once': fakeWarnOnce, '../../shared/warn-once': { warnOnce: fakeWarnOnce },
'../websocket': { Socket: FakeSocket }, '../websocket': { Socket: FakeSocket },
}); });
}); });
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import * as redux from 'redux'; import * as redux from 'redux';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
import immutable from '../util/immutable'; import { immutable } from '../util/immutable';
import { createReducer, bindSelectors } from './util'; import { createReducer, bindSelectors } from './util';
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* @param {import("redux").Store} store * @param {import("redux").Store} store
*/ */
export default function debugMiddleware(store) { export function debugMiddleware(store) {
/* eslint-disable no-console */ /* eslint-disable no-console */
let serial = 0; let serial = 0;
......
import { createStore } from './create-store'; import { createStore } from './create-store';
import debugMiddleware from './debug-middleware'; import { debugMiddleware } from './debug-middleware';
import activity from './modules/activity'; import { activity } from './modules/activity';
import annotations from './modules/annotations'; import { annotations } from './modules/annotations';
import defaults from './modules/defaults'; import { defaults } from './modules/defaults';
import directLinked from './modules/direct-linked'; import { directLinked } from './modules/direct-linked';
import drafts from './modules/drafts'; import { drafts } from './modules/drafts';
import filters from './modules/filters'; import { filters } from './modules/filters';
import frames from './modules/frames'; import { framesModule as frames } from './modules/frames';
import groups from './modules/groups'; import { groups } from './modules/groups';
import links from './modules/links'; import { links } from './modules/links';
import realTimeUpdates from './modules/real-time-updates'; import { realTimeUpdates } from './modules/real-time-updates';
import route from './modules/route'; import { routeModule as route } from './modules/route';
import selection from './modules/selection'; import { selection } from './modules/selection';
import session from './modules/session'; import { session } from './modules/session';
import sidebarPanels from './modules/sidebar-panels'; import { sidebarPanels } from './modules/sidebar-panels';
import toastMessages from './modules/toast-messages'; import { toastMessages } from './modules/toast-messages';
import viewer from './modules/viewer'; import { viewer } from './modules/viewer';
/** /**
* @template M * @template M
......
...@@ -190,7 +190,7 @@ function isSavingAnnotation(state, annotation) { ...@@ -190,7 +190,7 @@ function isSavingAnnotation(state, annotation) {
/** @typedef {import('../../../types/api').Annotation} Annotation */ /** @typedef {import('../../../types/api').Annotation} Annotation */
export default createStoreModule(initialState, { export const activity = createStoreModule(initialState, {
reducers, reducers,
namespace: 'activity', namespace: 'activity',
......
...@@ -19,7 +19,7 @@ import { countIf, toTrueMap, trueKeys } from '../../util/collections'; ...@@ -19,7 +19,7 @@ import { countIf, toTrueMap, trueKeys } from '../../util/collections';
import * as util from '../util'; import * as util from '../util';
import { createStoreModule } from '../create-store'; import { createStoreModule } from '../create-store';
import route from './route'; import { routeModule as route } from './route';
/** /**
* Return a copy of `current` with all matching annotations in `annotations` * Return a copy of `current` with all matching annotations in `annotations`
...@@ -559,7 +559,7 @@ function savedAnnotations(state) { ...@@ -559,7 +559,7 @@ function savedAnnotations(state) {
}); });
} }
export default createStoreModule(initialState, { export const annotations = createStoreModule(initialState, {
namespace: 'annotations', namespace: 'annotations',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -49,7 +49,7 @@ function getDefaults(state) { ...@@ -49,7 +49,7 @@ function getDefaults(state) {
return state; return state;
} }
export default createStoreModule(initialState, { export const defaults = createStoreModule(initialState, {
namespace: 'defaults', namespace: 'defaults',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -142,7 +142,7 @@ function directLinkedGroupFetchFailed(state) { ...@@ -142,7 +142,7 @@ function directLinkedGroupFetchFailed(state) {
return state.directLinkedGroupFetchFailed; return state.directLinkedGroupFetchFailed;
} }
export default createStoreModule(initialState, { export const directLinked = createStoreModule(initialState, {
namespace: 'directLinked', namespace: 'directLinked',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -186,7 +186,7 @@ const unsavedAnnotations = createSelector( ...@@ -186,7 +186,7 @@ const unsavedAnnotations = createSelector(
drafts => drafts.filter(d => !d.annotation.id).map(d => d.annotation) drafts => drafts.filter(d => !d.annotation.id).map(d => d.annotation)
); );
export default createStoreModule(initialState, { export const drafts = createStoreModule(initialState, {
namespace: 'drafts', namespace: 'drafts',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -279,7 +279,7 @@ function hasAppliedFilter(state) { ...@@ -279,7 +279,7 @@ function hasAppliedFilter(state) {
return !!(state.query || Object.keys(getFilters(state)).length); return !!(state.query || Object.keys(getFilters(state)).length);
} }
export default createStoreModule(initialState, { export const filters = createStoreModule(initialState, {
namespace: 'filters', namespace: 'filters',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -155,7 +155,7 @@ const searchUris = createShallowEqualSelector( ...@@ -155,7 +155,7 @@ const searchUris = createShallowEqualSelector(
uris => uris uris => uris
); );
export default createStoreModule(initialState, { export const framesModule = createStoreModule(initialState, {
namespace: 'frames', namespace: 'frames',
reducers, reducers,
......
...@@ -3,7 +3,7 @@ import { createSelector } from 'reselect'; ...@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
import * as util from '../util'; import * as util from '../util';
import { createStoreModule } from '../create-store'; import { createStoreModule } from '../create-store';
import session from './session'; import { session } from './session';
/** /**
* @typedef {import('../../../types/api').Group} Group * @typedef {import('../../../types/api').Group} Group
...@@ -261,7 +261,7 @@ const getCurrentlyViewingGroups = createSelector( ...@@ -261,7 +261,7 @@ const getCurrentlyViewingGroups = createSelector(
} }
); );
export default createStoreModule(initialState, { export const groups = createStoreModule(initialState, {
namespace: 'groups', namespace: 'groups',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -51,7 +51,7 @@ function getLink(state, linkName, params = {}) { ...@@ -51,7 +51,7 @@ function getLink(state, linkName, params = {}) {
return url; return url;
} }
export default createStoreModule(initialState, { export const links = createStoreModule(initialState, {
namespace: 'links', namespace: 'links',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -12,9 +12,9 @@ import { createSelector } from 'reselect'; ...@@ -12,9 +12,9 @@ import { createSelector } from 'reselect';
import { createStoreModule } from '../create-store'; import { createStoreModule } from '../create-store';
import { actionTypes } from '../util'; import { actionTypes } from '../util';
import annotations from './annotations'; import { annotations } from './annotations';
import groups from './groups'; import { groups } from './groups';
import route from './route'; import { routeModule as route } from './route';
const initialState = { const initialState = {
/** /**
...@@ -193,7 +193,7 @@ function hasPendingDeletion(state, id) { ...@@ -193,7 +193,7 @@ function hasPendingDeletion(state, id) {
return state.pendingDeletions.hasOwnProperty(id); return state.pendingDeletions.hasOwnProperty(id);
} }
export default createStoreModule(initialState, { export const realTimeUpdates = createStoreModule(initialState, {
namespace: 'realTimeUpdates', namespace: 'realTimeUpdates',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -63,7 +63,7 @@ function routeParams(state) { ...@@ -63,7 +63,7 @@ function routeParams(state) {
return state.params; return state.params;
} }
export default createStoreModule(initialState, { export const routeModule = createStoreModule(initialState, {
namespace: 'route', namespace: 'route',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -381,7 +381,7 @@ const sortKeys = createSelector( ...@@ -381,7 +381,7 @@ const sortKeys = createSelector(
} }
); );
export default createStoreModule(initialState, { export const selection = createStoreModule(initialState, {
namespace: 'selection', namespace: 'selection',
reducers, reducers,
......
...@@ -117,7 +117,7 @@ function profile(state) { ...@@ -117,7 +117,7 @@ function profile(state) {
return state.profile; return state.profile;
} }
export default createStoreModule(initialState, { export const session = createStoreModule(initialState, {
namespace: 'session', namespace: 'session',
reducers, reducers,
......
...@@ -121,7 +121,7 @@ function isSidebarPanelOpen(state, panelName) { ...@@ -121,7 +121,7 @@ function isSidebarPanelOpen(state, panelName) {
return state.activePanelName === panelName; return state.activePanelName === panelName;
} }
export default createStoreModule(initialState, { export const sidebarPanels = createStoreModule(initialState, {
namespace: 'sidebarPanels', namespace: 'sidebarPanels',
reducers, reducers,
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import activity from '../activity'; import { activity } from '../activity';
describe('sidebar/store/modules/activity', () => { describe('sidebar/store/modules/activity', () => {
let store; let store;
......
import * as fixtures from '../../../test/annotation-fixtures'; import * as fixtures from '../../../test/annotation-fixtures';
import * as metadata from '../../../helpers/annotation-metadata'; import * as metadata from '../../../helpers/annotation-metadata';
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import annotations from '../annotations'; import { annotations } from '../annotations';
import route from '../route'; import { routeModule as route } from '../route';
function createTestStore() { function createTestStore() {
return createStore([annotations, route], [{}]); return createStore([annotations, route], [{}]);
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import defaults from '../defaults'; import { defaults } from '../defaults';
describe('store/modules/defaults', () => { describe('store/modules/defaults', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import directLinked from '../direct-linked'; import { directLinked } from '../direct-linked';
describe('sidebar/store/modules/direct-linked', () => { describe('sidebar/store/modules/direct-linked', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import annotations from '../annotations'; import { annotations } from '../annotations';
import drafts from '../drafts'; import { drafts } from '../drafts';
import { Draft } from '../drafts'; import { Draft } from '../drafts';
import selection from '../selection'; import { selection } from '../selection';
import immutable from '../../../util/immutable'; import { immutable } from '../../../util/immutable';
const fixtures = immutable({ const fixtures = immutable({
draftWithText: { draftWithText: {
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import filters from '../filters'; import { filters } from '../filters';
import selection from '../selection'; import { selection } from '../selection';
describe('sidebar/store/modules/filters', () => { describe('sidebar/store/modules/filters', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import frames from '../frames'; import { framesModule as frames } from '../frames';
describe('sidebar/store/modules/frames', () => { describe('sidebar/store/modules/frames', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import groups from '../groups'; import { groups } from '../groups';
import session from '../session'; import { session } from '../session';
import immutable from '../../../util/immutable'; import { immutable } from '../../../util/immutable';
describe('sidebar/store/modules/groups', () => { describe('sidebar/store/modules/groups', () => {
const publicGroup = immutable({ const publicGroup = immutable({
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import links from '../links'; import { links } from '../links';
describe('sidebar/store/modules/links', () => { describe('sidebar/store/modules/links', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import annotations from '../annotations'; import { annotations } from '../annotations';
import groups from '../groups'; import { groups } from '../groups';
import realTimeUpdates from '../real-time-updates'; import { realTimeUpdates, $imports } from '../real-time-updates';
import { $imports } from '../real-time-updates'; import { selection } from '../selection';
import selection from '../selection';
const { removeAnnotations } = annotations.actionCreators; const { removeAnnotations } = annotations.actionCreators;
const { focusGroup } = groups.actionCreators; const { focusGroup } = groups.actionCreators;
...@@ -38,17 +37,17 @@ describe('sidebar/store/modules/real-time-updates', () => { ...@@ -38,17 +37,17 @@ describe('sidebar/store/modules/real-time-updates', () => {
$imports.$mock({ $imports.$mock({
'./annotations': { './annotations': {
default: { annotations: {
selectors: { annotationExists: fakeAnnotationExists }, selectors: { annotationExists: fakeAnnotationExists },
}, },
}, },
'./groups': { './groups': {
default: { groups: {
selectors: { focusedGroupId: fakeFocusedGroupId }, selectors: { focusedGroupId: fakeFocusedGroupId },
}, },
}, },
'./route': { './route': {
default: { routeModule: {
selectors: { route: fakeRoute }, selectors: { route: fakeRoute },
}, },
}, },
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import route from '../route'; import { routeModule as route } from '../route';
describe('store/modules/route', () => { describe('store/modules/route', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import annotations from '../annotations'; import { annotations } from '../annotations';
import filters from '../filters'; import { filters } from '../filters';
import selection from '../selection'; import { selection } from '../selection';
import route from '../route'; import { routeModule as route } from '../route';
import * as fixtures from '../../../test/annotation-fixtures'; import * as fixtures from '../../../test/annotation-fixtures';
describe('sidebar/store/modules/selection', () => { describe('sidebar/store/modules/selection', () => {
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import session from '../session'; import { session } from '../session';
describe('sidebar/store/modules/session', () => { describe('sidebar/store/modules/session', () => {
let fakeSettings; let fakeSettings;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import sidebarPanels from '../sidebar-panels'; import { sidebarPanels } from '../sidebar-panels';
describe('sidebar/store/modules/sidebar-panels', () => { describe('sidebar/store/modules/sidebar-panels', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import toastMessages from '../toast-messages'; import { toastMessages } from '../toast-messages';
describe('store/modules/toast-messages', () => { describe('store/modules/toast-messages', () => {
let store; let store;
......
import { createStore } from '../../create-store'; import { createStore } from '../../create-store';
import viewer from '../viewer'; import { viewer } from '../viewer';
describe('store/modules/viewer', () => { describe('store/modules/viewer', () => {
let store; let store;
......
...@@ -112,7 +112,7 @@ function hasMessage(state, type, text) { ...@@ -112,7 +112,7 @@ function hasMessage(state, type, text) {
}); });
} }
export default createStoreModule(initialState, { export const toastMessages = createStoreModule(initialState, {
namespace: 'toastMessages', namespace: 'toastMessages',
reducers, reducers,
actionCreators: { actionCreators: {
......
...@@ -43,7 +43,7 @@ function hasSidebarOpened(state) { ...@@ -43,7 +43,7 @@ function hasSidebarOpened(state) {
return state.sidebarHasOpened; return state.sidebarHasOpened;
} }
export default createStoreModule(initialState, { export const viewer = createStoreModule(initialState, {
namespace: 'viewer', namespace: 'viewer',
reducers, reducers,
actionCreators: { actionCreators: {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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