Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
c3e2a91b
Commit
c3e2a91b
authored
Feb 01, 2022
by
Eduardo Sanz García
Committed by
Eduardo
Feb 01, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert the rest of the default export into named exports
parent
b1209d74
Changes
120
Show whitespace changes
Inline
Side-by-side
Showing
120 changed files
with
229 additions
and
227 deletions
+229
-227
index.js
dev-server/ui-playground/index.js
+1
-1
pdf.js
src/annotator/anchoring/pdf.js
+1
-1
fake-pdf-viewer-application.js
src/annotator/anchoring/test/fake-pdf-viewer-application.js
+1
-1
index.js
src/annotator/anchoring/test/html-baselines/index.js
+1
-1
html-test.js
src/annotator/anchoring/test/html-test.js
+1
-1
pdf-test.js
src/annotator/anchoring/test/pdf-test.js
+1
-1
config-func-settings-from.js
src/annotator/config/config-func-settings-from.js
+1
-1
index.js
src/annotator/config/index.js
+1
-1
settings.js
src/annotator/config/settings.js
+2
-2
config-func-settings-from-test.js
src/annotator/config/test/config-func-settings-from-test.js
+1
-1
index-test.js
src/annotator/config/test/index-test.js
+14
-13
settings-test.js
src/annotator/config/test/settings-test.js
+4
-3
features.js
src/annotator/features.js
+1
-1
icons.js
src/annotator/icons.js
+1
-1
index.js
src/annotator/index.js
+2
-2
pdf-test.js
src/annotator/integrations/test/pdf-test.js
+1
-1
sidebar-trigger.js
src/annotator/sidebar-trigger.js
+1
-1
sidebar.js
src/annotator/sidebar.js
+1
-1
features-test.js
src/annotator/test/features-test.js
+1
-1
sidebar-trigger-test.js
src/annotator/test/sidebar-trigger-test.js
+1
-1
index.js
src/boot/index.js
+1
-1
url-template-test.js
src/boot/test/url-template-test.js
+1
-1
url-template.js
src/boot/url-template.js
+1
-1
warn-once-test.js
src/shared/test/warn-once-test.js
+1
-1
warn-once.js
src/shared/warn-once.js
+1
-1
Excerpt.js
src/sidebar/components/Excerpt.js
+1
-1
GroupList.js
src/sidebar/components/GroupList/GroupList.js
+1
-1
GroupList-test.js
src/sidebar/components/GroupList/test/GroupList-test.js
+5
-3
HelpPanel.js
src/sidebar/components/HelpPanel.js
+1
-1
MarkdownView.js
src/sidebar/components/MarkdownView.js
+1
-1
VersionInfo.js
src/sidebar/components/VersionInfo.js
+1
-1
use-root-thread-test.js
src/sidebar/components/hooks/test/use-root-thread-test.js
+4
-3
use-root-thread.js
src/sidebar/components/hooks/use-root-thread.js
+1
-1
Excerpt-test.js
src/sidebar/components/test/Excerpt-test.js
+3
-1
HelpPanel-test.js
src/sidebar/components/test/HelpPanel-test.js
+1
-1
MarkdownView-test.js
src/sidebar/components/test/MarkdownView-test.js
+12
-11
MenuItem-test.js
src/sidebar/components/test/MenuItem-test.js
+1
-2
fetch-config.js
src/sidebar/config/fetch-config.js
+2
-2
get-api-url.js
src/sidebar/config/get-api-url.js
+1
-1
host-config.js
src/sidebar/config/host-config.js
+1
-1
fetch-config-test.js
src/sidebar/config/test/fetch-config-test.js
+13
-13
get-api-url-test.js
src/sidebar/config/test/get-api-url-test.js
+1
-1
host-config-test.js
src/sidebar/config/test/host-config-test.js
+1
-1
cross-origin-rpc.js
src/sidebar/cross-origin-rpc.js
+1
-1
build-thread.js
src/sidebar/helpers/build-thread.js
+1
-1
group-organizations.js
src/sidebar/helpers/group-organizations.js
+2
-2
build-thread-test.js
src/sidebar/helpers/test/build-thread-test.js
+1
-1
group-organizations-test.js
src/sidebar/helpers/test/group-organizations-test.js
+1
-1
thread-annotations-test.js
src/sidebar/helpers/test/thread-annotations-test.js
+4
-5
version-data-test.js
src/sidebar/helpers/test/version-data-test.js
+1
-1
view-filter-test.js
src/sidebar/helpers/test/view-filter-test.js
+1
-1
thread-annotations.js
src/sidebar/helpers/thread-annotations.js
+4
-6
version-data.js
src/sidebar/helpers/version-data.js
+1
-1
view-filter.js
src/sidebar/helpers/view-filter.js
+1
-1
icons.js
src/sidebar/icons.js
+1
-1
index.js
src/sidebar/index.js
+3
-3
render-markdown.js
src/sidebar/render-markdown.js
+1
-1
auth.js
src/sidebar/services/auth.js
+1
-1
streamer.js
src/sidebar/services/streamer.js
+2
-2
auth-test.js
src/sidebar/services/test/auth-test.js
+2
-2
autosave-test.js
src/sidebar/services/test/autosave-test.js
+2
-2
frame-sync-test.js
src/sidebar/services/test/frame-sync-test.js
+2
-2
groups-test.js
src/sidebar/services/test/groups-test.js
+1
-1
persisted-defaults-test.js
src/sidebar/services/test/persisted-defaults-test.js
+1
-1
streamer-test.js
src/sidebar/services/test/streamer-test.js
+2
-2
create-store.js
src/sidebar/store/create-store.js
+1
-1
debug-middleware.js
src/sidebar/store/debug-middleware.js
+1
-1
index.js
src/sidebar/store/index.js
+17
-17
activity.js
src/sidebar/store/modules/activity.js
+1
-1
annotations.js
src/sidebar/store/modules/annotations.js
+2
-2
defaults.js
src/sidebar/store/modules/defaults.js
+1
-1
direct-linked.js
src/sidebar/store/modules/direct-linked.js
+1
-1
drafts.js
src/sidebar/store/modules/drafts.js
+1
-1
filters.js
src/sidebar/store/modules/filters.js
+1
-1
frames.js
src/sidebar/store/modules/frames.js
+1
-1
groups.js
src/sidebar/store/modules/groups.js
+2
-2
links.js
src/sidebar/store/modules/links.js
+1
-1
real-time-updates.js
src/sidebar/store/modules/real-time-updates.js
+4
-4
route.js
src/sidebar/store/modules/route.js
+1
-1
selection.js
src/sidebar/store/modules/selection.js
+1
-1
session.js
src/sidebar/store/modules/session.js
+1
-1
sidebar-panels.js
src/sidebar/store/modules/sidebar-panels.js
+1
-1
activity-test.js
src/sidebar/store/modules/test/activity-test.js
+1
-1
annotations-test.js
src/sidebar/store/modules/test/annotations-test.js
+2
-2
defaults-test.js
src/sidebar/store/modules/test/defaults-test.js
+1
-1
direct-linked-test.js
src/sidebar/store/modules/test/direct-linked-test.js
+1
-1
drafts-test.js
src/sidebar/store/modules/test/drafts-test.js
+4
-4
filters-test.js
src/sidebar/store/modules/test/filters-test.js
+2
-2
frames-test.js
src/sidebar/store/modules/test/frames-test.js
+1
-1
groups-test.js
src/sidebar/store/modules/test/groups-test.js
+3
-3
links-test.js
src/sidebar/store/modules/test/links-test.js
+1
-1
real-time-updates-test.js
src/sidebar/store/modules/test/real-time-updates-test.js
+7
-8
route-test.js
src/sidebar/store/modules/test/route-test.js
+1
-1
selection-test.js
src/sidebar/store/modules/test/selection-test.js
+4
-4
session-test.js
src/sidebar/store/modules/test/session-test.js
+1
-1
sidebar-panels-test.js
src/sidebar/store/modules/test/sidebar-panels-test.js
+1
-1
toast-messages-test.js
src/sidebar/store/modules/test/toast-messages-test.js
+1
-1
viewer-test.js
src/sidebar/store/modules/test/viewer-test.js
+1
-1
toast-messages.js
src/sidebar/store/modules/toast-messages.js
+1
-1
viewer.js
src/sidebar/store/modules/viewer.js
+1
-1
debug-middleware-test.js
src/sidebar/store/test/debug-middleware-test.js
+1
-1
index-test.js
src/sidebar/store/test/index-test.js
+1
-1
util-test.js
src/sidebar/store/test/util-test.js
+2
-2
bootstrap.js
src/sidebar/test/bootstrap.js
+2
-2
cross-origin-rpc-test.js
src/sidebar/test/cross-origin-rpc-test.js
+1
-1
fake-redux-store.js
src/sidebar/test/fake-redux-store.js
+1
-1
fake-window.js
src/sidebar/test/fake-window.js
+1
-1
render-markdown-test.js
src/sidebar/test/render-markdown-test.js
+5
-6
disable-opener-for-external-links.js
src/sidebar/util/disable-opener-for-external-links.js
+1
-1
immutable.js
src/sidebar/util/immutable.js
+1
-1
memoize.js
src/sidebar/util/memoize.js
+1
-1
oauth-client.js
src/sidebar/util/oauth-client.js
+1
-1
observe-element-size.js
src/sidebar/util/observe-element-size.js
+1
-1
sentry.js
src/sidebar/util/sentry.js
+1
-1
disable-opener-for-external-links-test.js
...debar/util/test/disable-opener-for-external-links-test.js
+1
-1
immutable-test.js
src/sidebar/util/test/immutable-test.js
+1
-1
memoize-test.js
src/sidebar/util/test/memoize-test.js
+1
-1
oauth-client-test.js
src/sidebar/util/test/oauth-client-test.js
+2
-2
observe-element-size-test.js
src/sidebar/util/test/observe-element-size-test.js
+1
-1
sentry-test.js
src/sidebar/util/test/sentry-test.js
+1
-1
No files found.
dev-server/ui-playground/index.js
View file @
c3e2a91b
import
{
startApp
}
from
'@hypothesis/frontend-shared/lib/pattern-library'
;
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[]} */
const
extraRoutes
=
[
...
...
src/annotator/anchoring/pdf.js
View file @
c3e2a91b
/* global PDFViewerApplication */
import
warnOnce
from
'../../shared/warn-once'
;
import
{
warnOnce
}
from
'../../shared/warn-once'
;
import
{
matchQuote
}
from
'./match-quote'
;
import
{
createPlaceholder
}
from
'./placeholder'
;
import
{
TextPosition
,
TextRange
}
from
'./text-range'
;
...
...
src/annotator/anchoring/test/fake-pdf-viewer-application.js
View file @
c3e2a91b
...
...
@@ -251,7 +251,7 @@ class FakePDFViewer {
*
* 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
*/
...
...
src/annotator/anchoring/test/html-baselines/index.js
View file @
c3e2a91b
...
...
@@ -27,7 +27,7 @@ import minimalJSON from './minimal.json';
import
wikipediaDoc
from
'./wikipedia-regression-testing.html'
;
import
wikipediaJSON
from
'./wikipedia-regression-testing.json'
;
export
default
[
export
const
htmlBaselines
=
[
{
name
:
'Minimal Document'
,
html
:
minimalDoc
,
...
...
src/annotator/anchoring/test/html-test.js
View file @
c3e2a91b
import
*
as
html
from
'../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`. */
function
textNodes
(
container
)
{
...
...
src/annotator/anchoring/test/pdf-test.js
View file @
c3e2a91b
...
...
@@ -3,7 +3,7 @@ import * as pdfAnchoring from '../pdf';
import
{
matchQuote
}
from
'../match-quote'
;
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`.
...
...
src/annotator/config/config-func-settings-from.js
View file @
c3e2a91b
...
...
@@ -22,7 +22,7 @@
* @return {object} - Any config settings returned by hypothesisConfig()
*
*/
export
default
function
configFuncSettingsFrom
(
window_
)
{
export
function
configFuncSettingsFrom
(
window_
)
{
if
(
!
window_
.
hasOwnProperty
(
'hypothesisConfig'
))
{
return
{};
}
...
...
src/annotator/config/index.js
View file @
c3e2a91b
import
{
isBrowserExtension
}
from
'./is-browser-extension'
;
import
settingsFrom
from
'./settings'
;
import
{
settingsFrom
}
from
'./settings'
;
import
{
toBoolean
}
from
'../../shared/type-coercions'
;
import
{
urlFromLinkTag
}
from
'./url-from-link-tag'
;
...
...
src/annotator/config/settings.js
View file @
c3e2a91b
import
{
parseJsonConfig
}
from
'../../boot/parse-json-config'
;
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'
;
/**
...
...
@@ -20,7 +20,7 @@ import { urlFromLinkTag } from './url-from-link-tag';
/**
* @return {SettingsGetters}
*/
export
default
function
settingsFrom
(
window_
)
{
export
function
settingsFrom
(
window_
)
{
// Prioritize the `window.hypothesisConfig` function over the JSON format
// Via uses `window.hypothesisConfig` and makes it non-configurable and non-writable.
// In addition, Via sets the `ignoreOtherConfiguration` option to prevent configuration merging.
...
...
src/annotator/config/test/config-func-settings-from-test.js
View file @
c3e2a91b
import
configFuncSettingsFrom
from
'../config-func-settings-from'
;
import
{
configFuncSettingsFrom
}
from
'../config-func-settings-from'
;
describe
(
'annotator.config.configFuncSettingsFrom'
,
()
=>
{
const
sandbox
=
sinon
.
createSandbox
();
...
...
src/annotator/config/test/index-test.js
View file @
c3e2a91b
import
{
getConfig
}
from
'../index'
;
import
{
$imports
}
from
'../index'
;
import
{
getConfig
,
$imports
}
from
'../index'
;
describe
(
'annotator/config/index'
,
()
=>
{
let
fakeSettingsFrom
;
...
...
@@ -20,7 +19,7 @@ describe('annotator/config/index', () => {
fakeIsBrowserExtension
=
sinon
.
stub
();
$imports
.
$mock
({
'./settings'
:
fakeSettingsFrom
,
'./settings'
:
{
settingsFrom
:
fakeSettingsFrom
}
,
'./is-browser-extension'
:
{
isBrowserExtension
:
fakeIsBrowserExtension
,
},
...
...
@@ -135,7 +134,8 @@ describe('annotator/config/index', () => {
beforeEach
(()
=>
{
// Remove all fake values
$imports
.
$mock
({
'./settings'
:
sinon
.
stub
().
returns
({
'./settings'
:
{
settingsFrom
:
sinon
.
stub
().
returns
({
hostPageSetting
:
sinon
.
stub
().
returns
(
undefined
),
annotations
:
undefined
,
clientUrl
:
undefined
,
...
...
@@ -145,6 +145,7 @@ describe('annotator/config/index', () => {
sidebarAppUrl
:
undefined
,
query
:
undefined
,
}),
},
});
});
...
...
src/annotator/config/test/settings-test.js
View file @
c3e2a91b
import
settingsFrom
from
'../settings'
;
import
{
$imports
}
from
'../settings'
;
import
{
settingsFrom
,
$imports
}
from
'../settings'
;
describe
(
'annotator/config/settingsFrom'
,
()
=>
{
let
fakeConfigFuncSettingsFrom
;
...
...
@@ -12,7 +11,9 @@ describe('annotator/config/settingsFrom', () => {
fakeParseJsonConfig
=
sinon
.
stub
().
returns
({});
$imports
.
$mock
({
'./config-func-settings-from'
:
fakeConfigFuncSettingsFrom
,
'./config-func-settings-from'
:
{
configFuncSettingsFrom
:
fakeConfigFuncSettingsFrom
,
},
'./url-from-link-tag'
:
{
urlFromLinkTag
:
fakeUrlFromLinkTag
,
},
...
...
src/annotator/features.js
View file @
c3e2a91b
import
warnOnce
from
'../shared/warn-once'
;
import
{
warnOnce
}
from
'../shared/warn-once'
;
let
_features
=
{};
...
...
src/annotator/icons.js
View file @
c3e2a91b
...
...
@@ -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`
* component.
*/
export
default
{
export
const
annotatorIcons
=
{
annotate
:
annotateIcon
,
cancel
,
caution
,
...
...
src/annotator/index.js
View file @
c3e2a91b
...
...
@@ -6,8 +6,8 @@ import 'preact/debug';
// Load icons.
import
{
registerIcons
}
from
'@hypothesis/frontend-shared'
;
import
iconSet
from
'./icons'
;
registerIcons
(
iconSet
);
import
{
annotatorIcons
}
from
'./icons'
;
registerIcons
(
annotatorIcons
);
import
{
PortProvider
}
from
'../shared/messaging'
;
import
{
getConfig
}
from
'./config/index'
;
...
...
src/annotator/integrations/test/pdf-test.js
View file @
c3e2a91b
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
{
createPlaceholder
}
from
'../../anchoring/placeholder'
;
import
{
PDFIntegration
,
isPDF
,
$imports
}
from
'../pdf'
;
...
...
src/annotator/sidebar-trigger.js
View file @
c3e2a91b
...
...
@@ -8,7 +8,7 @@ const SIDEBAR_TRIGGER_BTN_ATTR = 'data-hypothesis-trigger';
* @param {object} showFn - Function which shows the sidebar.
*/
export
default
function
t
rigger
(
rootEl
,
showFn
)
{
export
function
sidebarT
rigger
(
rootEl
,
showFn
)
{
const
triggerElems
=
rootEl
.
querySelectorAll
(
'['
+
SIDEBAR_TRIGGER_BTN_ATTR
+
']'
);
...
...
src/annotator/sidebar.js
View file @
c3e2a91b
...
...
@@ -9,7 +9,7 @@ import { annotationCounts } from './annotation-counts';
import
{
BucketBar
}
from
'./bucket-bar'
;
import
{
createAppConfig
}
from
'./config/app'
;
import
{
features
}
from
'./features'
;
import
sidebarTrigger
from
'./sidebar-trigger'
;
import
{
sidebarTrigger
}
from
'./sidebar-trigger'
;
import
{
ToolbarController
}
from
'./toolbar'
;
import
{
createShadowRoot
}
from
'./util/shadow-root'
;
...
...
src/annotator/test/features-test.js
View file @
c3e2a91b
...
...
@@ -16,7 +16,7 @@ describe('features - annotation layer', () => {
beforeEach
(()
=>
{
fakeWarnOnce
=
sinon
.
stub
();
$imports
.
$mock
({
'../shared/warn-once'
:
fakeWarnOnce
,
'../shared/warn-once'
:
{
warnOnce
:
fakeWarnOnce
}
,
});
features
.
init
({
...
...
src/annotator/test/sidebar-trigger-test.js
View file @
c3e2a91b
import
sidebarTrigger
from
'../sidebar-trigger'
;
import
{
sidebarTrigger
}
from
'../sidebar-trigger'
;
describe
(
'sidebarTrigger'
,
()
=>
{
let
triggerEl1
;
...
...
src/boot/index.js
View file @
c3e2a91b
...
...
@@ -8,7 +8,7 @@
import
{
parseJsonConfig
}
from
'./parse-json-config'
;
import
{
bootHypothesisClient
,
bootSidebarApp
}
from
'./boot'
;
import
processUrlTemplate
from
'./url-template'
;
import
{
processUrlTemplate
}
from
'./url-template'
;
import
{
isBrowserSupported
}
from
'./browser-check'
;
// @ts-ignore - This file is generated before the boot bundle is built.
...
...
src/boot/test/url-template-test.js
View file @
c3e2a91b
import
processUrlTemplate
from
'../url-template'
;
import
{
processUrlTemplate
}
from
'../url-template'
;
describe
(
'processUrlTemplate'
,
()
=>
{
let
fakeDocument
;
...
...
src/boot/url-template.js
View file @
c3e2a91b
...
...
@@ -36,7 +36,7 @@ function currentScriptOrigin(document_ = document) {
* @param {string} url
* @param {Document} document_
*/
export
default
function
processUrlTemplate
(
url
,
document_
=
document
)
{
export
function
processUrlTemplate
(
url
,
document_
=
document
)
{
if
(
url
.
indexOf
(
'{'
)
===
-
1
)
{
// Not a template. This should always be the case in production.
return
url
;
...
...
src/shared/test/warn-once-test.js
View file @
c3e2a91b
import
warnOnce
from
'../warn-once'
;
import
{
warnOnce
}
from
'../warn-once'
;
describe
(
'warnOnce'
,
()
=>
{
beforeEach
(()
=>
{
...
...
src/shared/warn-once.js
View file @
c3e2a91b
...
...
@@ -11,7 +11,7 @@ let shownWarnings = {};
* are concatenated into a string key which is used to determine if the warning
* has been logged before.
*/
export
default
function
warnOnce
(...
args
)
{
export
function
warnOnce
(...
args
)
{
const
key
=
args
.
join
();
if
(
key
in
shownWarnings
)
{
return
;
...
...
src/sidebar/components/Excerpt.js
View file @
c3e2a91b
...
...
@@ -2,7 +2,7 @@ import { LinkButton } from '@hypothesis/frontend-shared';
import
classnames
from
'classnames'
;
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
{
applyTheme
}
from
'../helpers/theme'
;
...
...
src/sidebar/components/GroupList/GroupList.js
View file @
c3e2a91b
...
...
@@ -3,7 +3,7 @@ import { useMemo, useState } from 'preact/hooks';
import
{
serviceConfig
}
from
'../../config/service-config'
;
import
{
isThirdPartyUser
}
from
'../../helpers/account-id'
;
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
{
withServices
}
from
'../../service-context'
;
import
{
useStoreProxy
}
from
'../../store/use-store'
;
...
...
src/sidebar/components/GroupList/test/GroupList-test.js
View file @
c3e2a91b
...
...
@@ -110,10 +110,12 @@ describe('GroupList', () => {
it
(
'sorts groups within each section by organization'
,
()
=>
{
const
testGroups
=
populateGroupSections
();
const
fakeGroup
Organizations
=
groups
=>
const
fakeGroup
sByOrganization
=
groups
=>
groups
.
sort
((
a
,
b
)
=>
a
.
id
.
localeCompare
(
b
.
id
));
$imports
.
$mock
({
'../../helpers/group-organizations'
:
fakeGroupOrganizations
,
'../../helpers/group-organizations'
:
{
groupsByOrganization
:
fakeGroupsByOrganization
,
},
});
const
wrapper
=
createGroupList
();
...
...
@@ -123,7 +125,7 @@ describe('GroupList', () => {
sections
.
forEach
(
section
=>
{
assert
.
deepEqual
(
section
.
prop
(
'groups'
),
fakeGroup
Organizations
(
testGroups
)
fakeGroup
sByOrganization
(
testGroups
)
);
});
});
...
...
src/sidebar/components/HelpPanel.js
View file @
c3e2a91b
...
...
@@ -3,7 +3,7 @@ import { useCallback, useMemo, useState } from 'preact/hooks';
import
{
useStoreProxy
}
from
'../store/use-store'
;
import
{
withServices
}
from
'../service-context'
;
import
VersionData
from
'../helpers/version-data'
;
import
{
VersionData
}
from
'../helpers/version-data'
;
import
SidebarPanel
from
'./SidebarPanel'
;
import
Tutorial
from
'./Tutorial'
;
...
...
src/sidebar/components/MarkdownView.js
View file @
c3e2a91b
...
...
@@ -2,7 +2,7 @@ import classnames from 'classnames';
import
{
useEffect
,
useMemo
,
useRef
}
from
'preact/hooks'
;
import
{
replaceLinksWithEmbeds
}
from
'../media-embedder'
;
import
renderMarkdown
from
'../render-markdown'
;
import
{
renderMathAndMarkdown
as
renderMarkdown
}
from
'../render-markdown'
;
/**
* @typedef MarkdownViewProps
...
...
src/sidebar/components/VersionInfo.js
View file @
c3e2a91b
...
...
@@ -5,7 +5,7 @@ import { withServices } from '../service-context';
/**
* @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
*/
...
...
src/sidebar/components/hooks/test/use-root-thread-test.js
View file @
c3e2a91b
import
{
mount
}
from
'enzyme'
;
import
useRootThread
from
'../use-root-thread'
;
import
{
$imports
}
from
'../use-root-thread'
;
import
useRootThread
,
{
$imports
}
from
'../use-root-thread'
;
describe
(
'sidebar/components/hooks/use-root-thread'
,
()
=>
{
let
fakeStore
;
...
...
@@ -20,7 +19,9 @@ describe('sidebar/components/hooks/use-root-thread', () => {
$imports
.
$mock
({
'../../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
...
...
src/sidebar/components/hooks/use-root-thread.js
View file @
c3e2a91b
import
{
useMemo
}
from
'preact/hooks'
;
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 */
...
...
src/sidebar/components/test/Excerpt-test.js
View file @
c3e2a91b
...
...
@@ -39,7 +39,9 @@ describe('Excerpt', () => {
document
.
body
.
appendChild
(
container
);
$imports
.
$mock
({
'../util/observe-element-size'
:
fakeObserveElementSize
,
'../util/observe-element-size'
:
{
observeElementSize
:
fakeObserveElementSize
,
},
});
});
...
...
src/sidebar/components/test/HelpPanel-test.js
View file @
c3e2a91b
...
...
@@ -41,7 +41,7 @@ describe('HelpPanel', () => {
$imports
.
$mock
(
mockImportedComponents
());
$imports
.
$mock
({
'../store/use-store'
:
{
useStoreProxy
:
()
=>
fakeStore
},
'../helpers/version-data'
:
FakeVersionData
,
'../helpers/version-data'
:
{
VersionData
:
FakeVersionData
}
,
});
});
...
...
src/sidebar/components/test/MarkdownView-test.js
View file @
c3e2a91b
import
{
mount
}
from
'enzyme'
;
import
MarkdownView
from
'../MarkdownView'
;
import
{
$imports
}
from
'../MarkdownView'
;
import
MarkdownView
,
{
$imports
}
from
'../MarkdownView'
;
import
{
checkAccessibility
}
from
'../../../test-util/accessibility'
;
describe
(
'MarkdownView'
,
()
=>
{
let
fake
MediaEmbedder
;
let
fakeRe
nderMarkdown
;
let
fake
RenderMathAndMarkdown
;
let
fakeRe
placeLinksWithEmbeds
;
beforeEach
(()
=>
{
fakeRenderMarkdown
=
markdown
=>
`rendered:
${
markdown
}
`
;
fakeMediaEmbedder
=
{
replaceLinksWithEmbeds
:
sinon
.
stub
(),
};
fakeRenderMathAndMarkdown
=
markdown
=>
`rendered:
${
markdown
}
`
;
fakeReplaceLinksWithEmbeds
=
sinon
.
stub
();
$imports
.
$mock
({
'../render-markdown'
:
fakeRenderMarkdown
,
'../media-embedder'
:
fakeMediaEmbedder
,
'../render-markdown'
:
{
renderMathAndMarkdown
:
fakeRenderMathAndMarkdown
,
},
'../media-embedder'
:
{
replaceLinksWithEmbeds
:
fakeReplaceLinksWithEmbeds
,
},
});
});
...
...
@@ -46,7 +47,7 @@ describe('MarkdownView', () => {
it
(
'replaces links with embeds in rendered output'
,
()
=>
{
const
wrapper
=
mount
(
<
MarkdownView
markdown
=
"**test**"
/>
);
const
rendered
=
wrapper
.
find
(
'.MarkdownView'
).
getDOMNode
();
assert
.
calledWith
(
fake
MediaEmbedder
.
r
eplaceLinksWithEmbeds
,
rendered
,
{
assert
.
calledWith
(
fake
R
eplaceLinksWithEmbeds
,
rendered
,
{
className
:
'MarkdownView__embed'
,
});
});
...
...
src/sidebar/components/test/MenuItem-test.js
View file @
c3e2a91b
import
{
mount
}
from
'enzyme'
;
import
{
act
}
from
'preact/test-utils'
;
import
MenuItem
from
'../MenuItem'
;
import
{
$imports
}
from
'../MenuItem'
;
import
MenuItem
,
{
$imports
}
from
'../MenuItem'
;
import
{
checkAccessibility
}
from
'../../../test-util/accessibility'
;
import
{
mockImportedComponents
}
from
'../../../test-util/mock-imported-components'
;
...
...
src/sidebar/config/fetch-config.js
View file @
c3e2a91b
import
getApiUrl
from
'./get-api-url'
;
import
hostConfig
from
'./host-config'
;
import
{
getApiUrl
}
from
'./get-api-url'
;
import
{
hostPageConfig
as
hostConfig
}
from
'./host-config'
;
import
*
as
postMessageJsonRpc
from
'../util/postmessage-json-rpc'
;
/**
...
...
src/sidebar/config/get-api-url.js
View file @
c3e2a91b
...
...
@@ -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
*
*/
export
default
function
getApiUrl
(
settings
)
{
export
function
getApiUrl
(
settings
)
{
const
service
=
serviceConfig
(
settings
);
if
(
service
)
{
...
...
src/sidebar/config/host-config.js
View file @
c3e2a91b
...
...
@@ -15,7 +15,7 @@ import {
* @param {Window} window
* @return {HostConfig}
*/
export
default
function
hostPageConfig
(
window
)
{
export
function
hostPageConfig
(
window
)
{
const
config
=
parseConfigFragment
(
window
.
location
.
href
);
// Known configuration parameters which we will import from the host page.
...
...
src/sidebar/config/test/fetch-config-test.js
View file @
c3e2a91b
import
{
fetchConfig
,
$imports
}
from
'../fetch-config'
;
describe
(
'sidebar/config/fetch-config'
,
()
=>
{
let
fakeHostConfig
;
let
fakeHost
Page
Config
;
let
fakeJsonRpc
;
let
fakeWindow
;
let
fakeApiUrl
;
let
fakeTopWindow
;
beforeEach
(()
=>
{
fakeHostConfig
=
sinon
.
stub
();
fakeHost
Page
Config
=
sinon
.
stub
();
fakeJsonRpc
=
{
call
:
sinon
.
stub
(),
};
fakeApiUrl
=
sinon
.
stub
().
returns
(
'https://dev.hypothes.is/api/'
);
$imports
.
$mock
({
'./host-config'
:
fakeHostConfig
,
'./host-config'
:
{
hostPageConfig
:
fakeHostPageConfig
}
,
'../util/postmessage-json-rpc'
:
fakeJsonRpc
,
'./get-api-url'
:
fakeApiUrl
,
'./get-api-url'
:
{
getApiUrl
:
fakeApiUrl
}
,
});
// By default, embedder provides no custom config.
fakeHostConfig
.
returns
({});
fakeHost
Page
Config
.
returns
({});
// By default, fetching config from parent frames fails.
fakeJsonRpc
.
call
.
throws
(
new
Error
(
'call() response not set'
));
...
...
@@ -59,7 +59,7 @@ describe('sidebar/config/fetch-config', () => {
it
(
'merges the hostPageConfig onto appConfig and returns the result'
,
async
()
=>
{
// hostPageConfig shall take precedent over appConfig
const
appConfig
=
{
foo
:
'bar'
,
appType
:
'via'
};
fakeHostConfig
.
returns
({
foo
:
'baz'
});
fakeHost
Page
Config
.
returns
({
foo
:
'baz'
});
const
mergedConfig
=
await
fetchConfig
(
appConfig
);
assert
.
deepEqual
(
mergedConfig
,
{
foo
:
'baz'
,
...
...
@@ -79,7 +79,7 @@ describe('sidebar/config/fetch-config', () => {
// exposed to the document itself.
const
expectedTimeout
=
3000
;
beforeEach
(()
=>
{
fakeHostConfig
.
returns
({
fakeHost
Page
Config
.
returns
({
requestConfigFromFrame
:
'https://embedder.com'
,
});
sinon
.
stub
(
console
,
'warn'
);
...
...
@@ -169,7 +169,7 @@ describe('sidebar/config/fetch-config', () => {
// exposed to the document itself.
beforeEach
(()
=>
{
fakeJsonRpc
.
call
.
resolves
({});
fakeHostConfig
.
returns
({
fakeHost
Page
Config
.
returns
({
requestConfigFromFrame
:
{
origin
:
'https://embedder.com'
,
ancestorLevel
:
2
,
...
...
@@ -192,7 +192,7 @@ describe('sidebar/config/fetch-config', () => {
[
0
,
1
,
2
].
forEach
(
level
=>
{
it
(
`finds
${
level
}
'th ancestor window according to how high the level is`
,
async
()
=>
{
fakeHostConfig
.
returns
({
fakeHost
Page
Config
.
returns
({
requestConfigFromFrame
:
{
origin
:
'https://embedder.com'
,
ancestorLevel
:
level
,
...
...
@@ -205,7 +205,7 @@ describe('sidebar/config/fetch-config', () => {
});
it
(
'throws an error when target ancestor exceeds top window'
,
async
()
=>
{
fakeHostConfig
.
returns
({
fakeHost
Page
Config
.
returns
({
requestConfigFromFrame
:
{
origin
:
'https://embedder.com'
,
ancestorLevel
:
10
,
// The top window is only 2 levels high
...
...
@@ -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
()
=>
{
fakeHostConfig
.
returns
({
fakeHost
Page
Config
.
returns
({
requestConfigFromFrame
:
{
origin
:
'https://embedder.com'
,
ancestorLevel
:
2
,
...
...
@@ -306,7 +306,7 @@ describe('sidebar/config/fetch-config', () => {
});
it
(
'missing ancestorLevel'
,
async
()
=>
{
fakeHostConfig
.
returns
({
fakeHost
Page
Config
.
returns
({
requestConfigFromFrame
:
{
origin
:
'https://embedder.com'
,
// missing ancestorLevel
...
...
@@ -319,7 +319,7 @@ describe('sidebar/config/fetch-config', () => {
});
it
(
'missing origin'
,
async
()
=>
{
fakeHostConfig
.
returns
({
fakeHost
Page
Config
.
returns
({
requestConfigFromFrame
:
{
// missing origin
ancestorLevel
:
2
,
...
...
src/sidebar/config/test/get-api-url-test.js
View file @
c3e2a91b
import
getApiUrl
from
'../get-api-url'
;
import
{
getApiUrl
}
from
'../get-api-url'
;
describe
(
'sidebar/config/get-api-url'
,
()
=>
{
context
(
'when there is a service object in settings'
,
()
=>
{
...
...
src/sidebar/config/test/host-config-test.js
View file @
c3e2a91b
import
{
addConfigFragment
}
from
'../../../shared/config-fragment'
;
import
hostPageConfig
from
'../host-config'
;
import
{
hostPageConfig
}
from
'../host-config'
;
function
fakeWindow
(
config
)
{
return
{
...
...
src/sidebar/cross-origin-rpc.js
View file @
c3e2a91b
import
warnOnce
from
'../shared/warn-once'
;
import
{
warnOnce
}
from
'../shared/warn-once'
;
import
{
normalizeGroupIds
}
from
'./helpers/groups'
;
...
...
src/sidebar/helpers/build-thread.js
View file @
c3e2a91b
...
...
@@ -284,7 +284,7 @@ const replySortCompareFn = (a, b) => {
* @return {Thread} - The root thread, whose children are the top-level
* annotations to display.
*/
export
default
function
buildThread
(
annotations
,
options
)
{
export
function
buildThread
(
annotations
,
options
)
{
const
hasSelection
=
options
.
selected
.
length
>
0
;
const
hasForcedVisible
=
options
.
forcedVisible
.
length
>
0
;
...
...
src/sidebar/helpers/group-organizations.js
View file @
c3e2a91b
import
immutable
from
'../util/immutable'
;
import
{
immutable
}
from
'../util/immutable'
;
/**
* @typedef {import('../../types/api').Group} Group
...
...
@@ -83,7 +83,7 @@ function organizations(groups) {
* @param {Array<Group>} groups
* @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
defaultOrganizationGroups
=
[];
const
sortedGroups
=
[];
...
...
src/sidebar/helpers/test/build-thread-test.js
View file @
c3e2a91b
import
buildThread
from
'../build-thread'
;
import
{
buildThread
}
from
'../build-thread'
;
import
*
as
metadata
from
'../../helpers/annotation-metadata'
;
// Fixture with two top level annotations, one note and one reply
...
...
src/sidebar/helpers/test/group-organizations-test.js
View file @
c3e2a91b
import
*
as
orgFixtures
from
'../../test/group-fixtures'
;
import
groupsByOrganization
from
'../group-organizations'
;
import
{
groupsByOrganization
}
from
'../group-organizations'
;
describe
(
'sidebar/helpers/group-organizations'
,
()
=>
{
context
(
'when sorting organizations and their contained groups'
,
()
=>
{
...
...
src/sidebar/helpers/test/thread-annotations-test.js
View file @
c3e2a91b
import
*
as
annotationFixtures
from
'../../test/annotation-fixtures'
;
import
threadAnnotations
from
'../thread-annotations'
;
import
{
threadAnnotations
,
$imports
}
from
'../thread-annotations'
;
import
{
sorters
}
from
'../thread-sorters'
;
import
{
$imports
}
from
'../thread-annotations'
;
import
immutable
from
'../../util/immutable'
;
import
{
immutable
}
from
'../../util/immutable'
;
const
fixtures
=
immutable
({
emptyThread
:
{
...
...
@@ -45,9 +44,9 @@ describe('sidebar/helpers/thread-annotations', () => {
};
$imports
.
$mock
({
'./build-thread'
:
fakeBuildThread
,
'./build-thread'
:
{
buildThread
:
fakeBuildThread
}
,
'../util/search-filter'
:
fakeSearchFilter
,
'./view-filter'
:
fakeFilterAnnotations
,
'./view-filter'
:
{
filterAnnotations
:
fakeFilterAnnotations
}
,
});
});
...
...
src/sidebar/helpers/test/version-data-test.js
View file @
c3e2a91b
import
VersionData
from
'../version-data'
;
import
{
VersionData
}
from
'../version-data'
;
describe
(
'sidebar/helpers/version-data'
,
()
=>
{
let
clock
;
...
...
src/sidebar/helpers/test/view-filter-test.js
View file @
c3e2a91b
import
filterAnnotations
,
{
$imports
}
from
'../view-filter'
;
import
{
filterAnnotations
,
$imports
}
from
'../view-filter'
;
function
isoDateWithAge
(
age
)
{
return
new
Date
(
Date
.
now
()
-
age
*
1000
).
toISOString
();
...
...
src/sidebar/helpers/thread-annotations.js
View file @
c3e2a91b
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
filterAnnotations
from
'./view-filter'
;
import
{
filterAnnotations
}
from
'./view-filter'
;
import
{
shouldShowInTab
}
from
'./tabs'
;
import
{
sorters
}
from
'./thread-sorters'
;
...
...
@@ -71,6 +71,4 @@ function buildRootThread(threadState) {
return
buildThread
(
threadState
.
annotations
,
options
);
}
const
threadAnnotations
=
memoize
(
buildRootThread
);
export
default
threadAnnotations
;
export
const
threadAnnotations
=
memoize
(
buildRootThread
);
src/sidebar/helpers/version-data.js
View file @
c3e2a91b
...
...
@@ -19,7 +19,7 @@
* @prop {DocMetadata} [metadata] - Document metadata
*/
export
default
class
VersionData
{
export
class
VersionData
{
/**
* @param {AuthState} userInfo
* @param {DocumentInfo[]} documentInfo - Metadata for connected frames.
...
...
src/sidebar/helpers/view-filter.js
View file @
c3e2a91b
...
...
@@ -158,7 +158,7 @@ const fieldMatchers = {
* `generateFacetedFilter`.
* @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"
// filters.
const
fieldFilters
=
Object
.
entries
(
filters
)
...
...
src/sidebar/icons.js
View file @
c3e2a91b
...
...
@@ -56,7 +56,7 @@ import pointerIcon from '../images/icons/pointer.svg';
* Set of icons used by the sidebar application via the `SvgIcon`
* component.
*/
export
default
{
export
const
sidebarIcons
=
{
add
:
plus
,
annotate
:
annotateIcon
,
'arrow-left'
:
arrowLeft
,
...
...
src/sidebar/index.js
View file @
c3e2a91b
...
...
@@ -7,7 +7,7 @@ import {
startServer
as
startRPCServer
,
preStartServer
as
preStartRPCServer
,
}
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'
;
// Read settings rendered into sidebar app HTML by service/extension.
...
...
@@ -100,9 +100,9 @@ function setupFrameSync(frameSync, store) {
// Register icons used by the sidebar app (and maybe other assets in future).
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.
import
{
render
}
from
'preact'
;
...
...
src/sidebar/render-markdown.js
View file @
c3e2a91b
...
...
@@ -131,7 +131,7 @@ function insertMath(html, mathBlocks) {
},
html
);
}
export
default
function
renderMathAndMarkdown
(
markdown
)
{
export
function
renderMathAndMarkdown
(
markdown
)
{
// 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
// blocks from the input, render and sanitize the remaining markdown and then
...
...
src/sidebar/services/auth.js
View file @
c3e2a91b
import
{
TinyEmitter
}
from
'tiny-emitter'
;
import
{
serviceConfig
}
from
'../config/service-config'
;
import
OAuthClient
from
'../util/oauth-client'
;
import
{
OAuthClient
}
from
'../util/oauth-client'
;
import
{
resolve
}
from
'../util/url'
;
/**
...
...
src/sidebar/services/streamer.js
View file @
c3e2a91b
import
{
generateHexString
}
from
'../../shared/random'
;
import
warnOnce
from
'../../shared/warn-once'
;
import
{
Socket
}
from
'../websocket'
;
import
{
warnOnce
}
from
'../../shared/warn-once'
;
import
{
watch
}
from
'../util/watch'
;
import
{
Socket
}
from
'../websocket'
;
/**
* `StreamerService` manages the WebSocket connection to the Hypothesis Real-Time
...
...
src/sidebar/services/test/auth-test.js
View file @
c3e2a91b
import
{
Injector
}
from
'../../../shared/injector'
;
import
FakeWindow
from
'../../test/fake-window'
;
import
{
FakeWindow
}
from
'../../test/fake-window'
;
import
{
AuthService
,
$imports
}
from
'../auth'
;
const
DEFAULT_TOKEN_EXPIRES_IN_SECS
=
1000
;
...
...
@@ -87,7 +87,7 @@ describe('AuthService', () => {
fakeWindow
=
new
FakeWindow
();
$imports
.
$mock
({
'../util/oauth-client'
:
FakeOAuthClient
,
'../util/oauth-client'
:
{
OAuthClient
:
FakeOAuthClient
}
,
});
auth
=
new
Injector
()
...
...
src/sidebar/services/test/autosave-test.js
View file @
c3e2a91b
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
{
AutosaveService
,
$imports
}
from
'../autosave'
;
...
...
@@ -14,7 +14,7 @@ describe('AutosaveService', () => {
fakeAnnotationsService
=
{
save
:
sinon
.
stub
().
resolves
()
};
fakeNewHighlights
=
sinon
.
stub
().
returns
([]);
fakeRetryPromiseOperation
=
sinon
.
stub
().
callsFake
(
callback
=>
callback
());
fakeStore
=
createFake
Store
({},
{
newHighlights
:
fakeNewHighlights
});
fakeStore
=
fakeRedux
Store
({},
{
newHighlights
:
fakeNewHighlights
});
$imports
.
$mock
({
'../util/retry'
:
{
...
...
src/sidebar/services/test/frame-sync-test.js
View file @
c3e2a91b
...
...
@@ -2,7 +2,7 @@ import EventEmitter from 'tiny-emitter';
import
{
Injector
}
from
'../../../shared/injector'
;
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
{
FrameSyncService
,
$imports
,
formatAnnot
}
from
'../frame-sync'
;
...
...
@@ -91,7 +91,7 @@ describe('FrameSyncService', () => {
discover
:
sinon
.
stub
().
resolves
(
sidebarPort
),
};
fakeStore
=
createFake
Store
(
fakeStore
=
fakeRedux
Store
(
{
annotations
:
[]
},
{
allAnnotations
()
{
...
...
src/sidebar/services/test/groups-test.js
View file @
c3e2a91b
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'
;
/**
...
...
src/sidebar/services/test/persisted-defaults-test.js
View file @
c3e2a91b
import
fakeReduxStore
from
'../../test/fake-redux-store'
;
import
{
fakeReduxStore
}
from
'../../test/fake-redux-store'
;
import
{
PersistedDefaultsService
}
from
'../persisted-defaults'
;
const
DEFAULT_KEYS
=
{
...
...
src/sidebar/services/test/streamer-test.js
View file @
c3e2a91b
import
EventEmitter
from
'tiny-emitter'
;
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'
;
const
fixtures
=
{
...
...
@@ -129,7 +129,7 @@ describe('StreamerService', () => {
fakeWarnOnce
=
sinon
.
stub
();
$imports
.
$mock
({
'../../shared/warn-once'
:
fakeWarnOnce
,
'../../shared/warn-once'
:
{
warnOnce
:
fakeWarnOnce
}
,
'../websocket'
:
{
Socket
:
FakeSocket
},
});
});
...
...
src/sidebar/store/create-store.js
View file @
c3e2a91b
...
...
@@ -3,7 +3,7 @@
import
*
as
redux
from
'redux'
;
import
thunk
from
'redux-thunk'
;
import
immutable
from
'../util/immutable'
;
import
{
immutable
}
from
'../util/immutable'
;
import
{
createReducer
,
bindSelectors
}
from
'./util'
;
...
...
src/sidebar/store/debug-middleware.js
View file @
c3e2a91b
...
...
@@ -10,7 +10,7 @@
*
* @param {import("redux").Store} store
*/
export
default
function
debugMiddleware
(
store
)
{
export
function
debugMiddleware
(
store
)
{
/* eslint-disable no-console */
let
serial
=
0
;
...
...
src/sidebar/store/index.js
View file @
c3e2a91b
import
{
createStore
}
from
'./create-store'
;
import
debugMiddleware
from
'./debug-middleware'
;
import
activity
from
'./modules/activity'
;
import
annotations
from
'./modules/annotations'
;
import
defaults
from
'./modules/defaults'
;
import
directLinked
from
'./modules/direct-linked'
;
import
drafts
from
'./modules/drafts'
;
import
filters
from
'./modules/filters'
;
import
frames
from
'./modules/frames'
;
import
groups
from
'./modules/groups'
;
import
links
from
'./modules/links'
;
import
realTimeUpdates
from
'./modules/real-time-updates'
;
import
route
from
'./modules/route'
;
import
selection
from
'./modules/selection'
;
import
session
from
'./modules/session'
;
import
sidebarPanels
from
'./modules/sidebar-panels'
;
import
toastMessages
from
'./modules/toast-messages'
;
import
viewer
from
'./modules/viewer'
;
import
{
debugMiddleware
}
from
'./debug-middleware'
;
import
{
activity
}
from
'./modules/activity'
;
import
{
annotations
}
from
'./modules/annotations'
;
import
{
defaults
}
from
'./modules/defaults'
;
import
{
directLinked
}
from
'./modules/direct-linked'
;
import
{
drafts
}
from
'./modules/drafts'
;
import
{
filters
}
from
'./modules/filters'
;
import
{
framesModule
as
frames
}
from
'./modules/frames'
;
import
{
groups
}
from
'./modules/groups'
;
import
{
links
}
from
'./modules/links'
;
import
{
realTimeUpdates
}
from
'./modules/real-time-updates'
;
import
{
routeModule
as
route
}
from
'./modules/route'
;
import
{
selection
}
from
'./modules/selection'
;
import
{
session
}
from
'./modules/session'
;
import
{
sidebarPanels
}
from
'./modules/sidebar-panels'
;
import
{
toastMessages
}
from
'./modules/toast-messages'
;
import
{
viewer
}
from
'./modules/viewer'
;
/**
* @template M
...
...
src/sidebar/store/modules/activity.js
View file @
c3e2a91b
...
...
@@ -190,7 +190,7 @@ function isSavingAnnotation(state, annotation) {
/** @typedef {import('../../../types/api').Annotation} Annotation */
export
default
createStoreModule
(
initialState
,
{
export
const
activity
=
createStoreModule
(
initialState
,
{
reducers
,
namespace
:
'activity'
,
...
...
src/sidebar/store/modules/annotations.js
View file @
c3e2a91b
...
...
@@ -19,7 +19,7 @@ import { countIf, toTrueMap, trueKeys } from '../../util/collections';
import
*
as
util
from
'../util'
;
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`
...
...
@@ -559,7 +559,7 @@ function savedAnnotations(state) {
});
}
export
default
createStoreModule
(
initialState
,
{
export
const
annotations
=
createStoreModule
(
initialState
,
{
namespace
:
'annotations'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/defaults.js
View file @
c3e2a91b
...
...
@@ -49,7 +49,7 @@ function getDefaults(state) {
return
state
;
}
export
default
createStoreModule
(
initialState
,
{
export
const
defaults
=
createStoreModule
(
initialState
,
{
namespace
:
'defaults'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/direct-linked.js
View file @
c3e2a91b
...
...
@@ -142,7 +142,7 @@ function directLinkedGroupFetchFailed(state) {
return
state
.
directLinkedGroupFetchFailed
;
}
export
default
createStoreModule
(
initialState
,
{
export
const
directLinked
=
createStoreModule
(
initialState
,
{
namespace
:
'directLinked'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/drafts.js
View file @
c3e2a91b
...
...
@@ -186,7 +186,7 @@ const unsavedAnnotations = createSelector(
drafts
=>
drafts
.
filter
(
d
=>
!
d
.
annotation
.
id
).
map
(
d
=>
d
.
annotation
)
);
export
default
createStoreModule
(
initialState
,
{
export
const
drafts
=
createStoreModule
(
initialState
,
{
namespace
:
'drafts'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/filters.js
View file @
c3e2a91b
...
...
@@ -279,7 +279,7 @@ function hasAppliedFilter(state) {
return
!!
(
state
.
query
||
Object
.
keys
(
getFilters
(
state
)).
length
);
}
export
default
createStoreModule
(
initialState
,
{
export
const
filters
=
createStoreModule
(
initialState
,
{
namespace
:
'filters'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/frames.js
View file @
c3e2a91b
...
...
@@ -155,7 +155,7 @@ const searchUris = createShallowEqualSelector(
uris
=>
uris
);
export
default
createStoreModule
(
initialState
,
{
export
const
framesModule
=
createStoreModule
(
initialState
,
{
namespace
:
'frames'
,
reducers
,
...
...
src/sidebar/store/modules/groups.js
View file @
c3e2a91b
...
...
@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
import
*
as
util
from
'../util'
;
import
{
createStoreModule
}
from
'../create-store'
;
import
session
from
'./session'
;
import
{
session
}
from
'./session'
;
/**
* @typedef {import('../../../types/api').Group} Group
...
...
@@ -261,7 +261,7 @@ const getCurrentlyViewingGroups = createSelector(
}
);
export
default
createStoreModule
(
initialState
,
{
export
const
groups
=
createStoreModule
(
initialState
,
{
namespace
:
'groups'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/links.js
View file @
c3e2a91b
...
...
@@ -51,7 +51,7 @@ function getLink(state, linkName, params = {}) {
return
url
;
}
export
default
createStoreModule
(
initialState
,
{
export
const
links
=
createStoreModule
(
initialState
,
{
namespace
:
'links'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/real-time-updates.js
View file @
c3e2a91b
...
...
@@ -12,9 +12,9 @@ import { createSelector } from 'reselect';
import
{
createStoreModule
}
from
'../create-store'
;
import
{
actionTypes
}
from
'../util'
;
import
annotations
from
'./annotations'
;
import
groups
from
'./groups'
;
import
route
from
'./route'
;
import
{
annotations
}
from
'./annotations'
;
import
{
groups
}
from
'./groups'
;
import
{
routeModule
as
route
}
from
'./route'
;
const
initialState
=
{
/**
...
...
@@ -193,7 +193,7 @@ function hasPendingDeletion(state, id) {
return
state
.
pendingDeletions
.
hasOwnProperty
(
id
);
}
export
default
createStoreModule
(
initialState
,
{
export
const
realTimeUpdates
=
createStoreModule
(
initialState
,
{
namespace
:
'realTimeUpdates'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/route.js
View file @
c3e2a91b
...
...
@@ -63,7 +63,7 @@ function routeParams(state) {
return
state
.
params
;
}
export
default
createStoreModule
(
initialState
,
{
export
const
routeModule
=
createStoreModule
(
initialState
,
{
namespace
:
'route'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/selection.js
View file @
c3e2a91b
...
...
@@ -381,7 +381,7 @@ const sortKeys = createSelector(
}
);
export
default
createStoreModule
(
initialState
,
{
export
const
selection
=
createStoreModule
(
initialState
,
{
namespace
:
'selection'
,
reducers
,
...
...
src/sidebar/store/modules/session.js
View file @
c3e2a91b
...
...
@@ -117,7 +117,7 @@ function profile(state) {
return
state
.
profile
;
}
export
default
createStoreModule
(
initialState
,
{
export
const
session
=
createStoreModule
(
initialState
,
{
namespace
:
'session'
,
reducers
,
...
...
src/sidebar/store/modules/sidebar-panels.js
View file @
c3e2a91b
...
...
@@ -121,7 +121,7 @@ function isSidebarPanelOpen(state, panelName) {
return
state
.
activePanelName
===
panelName
;
}
export
default
createStoreModule
(
initialState
,
{
export
const
sidebarPanels
=
createStoreModule
(
initialState
,
{
namespace
:
'sidebarPanels'
,
reducers
,
...
...
src/sidebar/store/modules/test/activity-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
activity
from
'../activity'
;
import
{
activity
}
from
'../activity'
;
describe
(
'sidebar/store/modules/activity'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/annotations-test.js
View file @
c3e2a91b
import
*
as
fixtures
from
'../../../test/annotation-fixtures'
;
import
*
as
metadata
from
'../../../helpers/annotation-metadata'
;
import
{
createStore
}
from
'../../create-store'
;
import
annotations
from
'../annotations'
;
import
route
from
'../route'
;
import
{
annotations
}
from
'../annotations'
;
import
{
routeModule
as
route
}
from
'../route'
;
function
createTestStore
()
{
return
createStore
([
annotations
,
route
],
[{}]);
...
...
src/sidebar/store/modules/test/defaults-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
defaults
from
'../defaults'
;
import
{
defaults
}
from
'../defaults'
;
describe
(
'store/modules/defaults'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/direct-linked-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
directLinked
from
'../direct-linked'
;
import
{
directLinked
}
from
'../direct-linked'
;
describe
(
'sidebar/store/modules/direct-linked'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/drafts-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
annotations
from
'../annotations'
;
import
drafts
from
'../drafts'
;
import
{
annotations
}
from
'../annotations'
;
import
{
drafts
}
from
'../drafts'
;
import
{
Draft
}
from
'../drafts'
;
import
selection
from
'../selection'
;
import
immutable
from
'../../../util/immutable'
;
import
{
selection
}
from
'../selection'
;
import
{
immutable
}
from
'../../../util/immutable'
;
const
fixtures
=
immutable
({
draftWithText
:
{
...
...
src/sidebar/store/modules/test/filters-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
filters
from
'../filters'
;
import
selection
from
'../selection'
;
import
{
filters
}
from
'../filters'
;
import
{
selection
}
from
'../selection'
;
describe
(
'sidebar/store/modules/filters'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/frames-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
frames
from
'../frames'
;
import
{
framesModule
as
frames
}
from
'../frames'
;
describe
(
'sidebar/store/modules/frames'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/groups-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
groups
from
'../groups'
;
import
session
from
'../session'
;
import
immutable
from
'../../../util/immutable'
;
import
{
groups
}
from
'../groups'
;
import
{
session
}
from
'../session'
;
import
{
immutable
}
from
'../../../util/immutable'
;
describe
(
'sidebar/store/modules/groups'
,
()
=>
{
const
publicGroup
=
immutable
({
...
...
src/sidebar/store/modules/test/links-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
links
from
'../links'
;
import
{
links
}
from
'../links'
;
describe
(
'sidebar/store/modules/links'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/real-time-updates-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
annotations
from
'../annotations'
;
import
groups
from
'../groups'
;
import
realTimeUpdates
from
'../real-time-updates'
;
import
{
$imports
}
from
'../real-time-updates'
;
import
selection
from
'../selection'
;
import
{
annotations
}
from
'../annotations'
;
import
{
groups
}
from
'../groups'
;
import
{
realTimeUpdates
,
$imports
}
from
'../real-time-updates'
;
import
{
selection
}
from
'../selection'
;
const
{
removeAnnotations
}
=
annotations
.
actionCreators
;
const
{
focusGroup
}
=
groups
.
actionCreators
;
...
...
@@ -38,17 +37,17 @@ describe('sidebar/store/modules/real-time-updates', () => {
$imports
.
$mock
({
'./annotations'
:
{
default
:
{
annotations
:
{
selectors
:
{
annotationExists
:
fakeAnnotationExists
},
},
},
'./groups'
:
{
default
:
{
groups
:
{
selectors
:
{
focusedGroupId
:
fakeFocusedGroupId
},
},
},
'./route'
:
{
default
:
{
routeModule
:
{
selectors
:
{
route
:
fakeRoute
},
},
},
...
...
src/sidebar/store/modules/test/route-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
route
from
'../route'
;
import
{
routeModule
as
route
}
from
'../route'
;
describe
(
'store/modules/route'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/selection-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
annotations
from
'../annotations'
;
import
filters
from
'../filters'
;
import
selection
from
'../selection'
;
import
route
from
'../route'
;
import
{
annotations
}
from
'../annotations'
;
import
{
filters
}
from
'../filters'
;
import
{
selection
}
from
'../selection'
;
import
{
routeModule
as
route
}
from
'../route'
;
import
*
as
fixtures
from
'../../../test/annotation-fixtures'
;
describe
(
'sidebar/store/modules/selection'
,
()
=>
{
...
...
src/sidebar/store/modules/test/session-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
session
from
'../session'
;
import
{
session
}
from
'../session'
;
describe
(
'sidebar/store/modules/session'
,
()
=>
{
let
fakeSettings
;
...
...
src/sidebar/store/modules/test/sidebar-panels-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
sidebarPanels
from
'../sidebar-panels'
;
import
{
sidebarPanels
}
from
'../sidebar-panels'
;
describe
(
'sidebar/store/modules/sidebar-panels'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/toast-messages-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
toastMessages
from
'../toast-messages'
;
import
{
toastMessages
}
from
'../toast-messages'
;
describe
(
'store/modules/toast-messages'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/test/viewer-test.js
View file @
c3e2a91b
import
{
createStore
}
from
'../../create-store'
;
import
viewer
from
'../viewer'
;
import
{
viewer
}
from
'../viewer'
;
describe
(
'store/modules/viewer'
,
()
=>
{
let
store
;
...
...
src/sidebar/store/modules/toast-messages.js
View file @
c3e2a91b
...
...
@@ -112,7 +112,7 @@ function hasMessage(state, type, text) {
});
}
export
default
createStoreModule
(
initialState
,
{
export
const
toastMessages
=
createStoreModule
(
initialState
,
{
namespace
:
'toastMessages'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/modules/viewer.js
View file @
c3e2a91b
...
...
@@ -43,7 +43,7 @@ function hasSidebarOpened(state) {
return
state
.
sidebarHasOpened
;
}
export
default
createStoreModule
(
initialState
,
{
export
const
viewer
=
createStoreModule
(
initialState
,
{
namespace
:
'viewer'
,
reducers
,
actionCreators
:
{
...
...
src/sidebar/store/test/debug-middleware-test.js
View file @
c3e2a91b
...
...
@@ -2,7 +2,7 @@
import
*
as
redux
from
'redux'
;
import
debugMiddleware
from
'../debug-middleware'
;
import
{
debugMiddleware
}
from
'../debug-middleware'
;
function
id
(
state
)
{
return
state
;
...
...
src/sidebar/store/test/index-test.js
View file @
c3e2a91b
import
*
as
annotationFixtures
from
'../../test/annotation-fixtures'
;
import
{
createSidebarStore
}
from
'../index'
;
import
immutable
from
'../../util/immutable'
;
import
{
immutable
}
from
'../../util/immutable'
;
const
defaultAnnotation
=
annotationFixtures
.
defaultAnnotation
;
const
newAnnotation
=
annotationFixtures
.
newAnnotation
;
...
...
src/sidebar/store/test/util-test.js
View file @
c3e2a91b
import
fakeStore
from
'../../test/fake-redux-store'
;
import
{
fakeReduxStore
}
from
'../../test/fake-redux-store'
;
import
*
as
util
from
'../util'
;
...
...
@@ -194,7 +194,7 @@ describe('sidebar/store/util', () => {
let
store
;
beforeEach
(()
=>
{
store
=
fakeStore
({
store
=
fake
Redux
Store
({
fake
:
{
val
:
0
},
});
});
...
...
src/sidebar/test/bootstrap.js
View file @
c3e2a91b
...
...
@@ -16,8 +16,8 @@ configure({ adapter: new Adapter() });
// Make all the icons that are available for use with `SvgIcon` in the actual
// app available in the tests. This enables validation of icon names passed to
// `SvgIcon`.
import
sidebarIcons
from
'../icons'
;
import
annotatorIcons
from
'../../annotator/icons'
;
import
{
sidebarIcons
}
from
'../icons'
;
import
{
annotatorIcons
}
from
'../../annotator/icons'
;
import
{
registerIcons
}
from
'@hypothesis/frontend-shared'
;
registerIcons
({
...
sidebarIcons
,
...
...
src/sidebar/test/cross-origin-rpc-test.js
View file @
c3e2a91b
...
...
@@ -38,7 +38,7 @@ describe('sidebar/cross-origin-rpc', () => {
$imports
.
$mock
({
'./helpers/groups'
:
{
normalizeGroupIds
:
fakeNormalizeGroupIds
},
'../shared/warn-once'
:
fakeWarnOnce
,
'../shared/warn-once'
:
{
warnOnce
:
fakeWarnOnce
}
,
});
});
...
...
src/sidebar/test/fake-redux-store.js
View file @
c3e2a91b
...
...
@@ -11,7 +11,7 @@ import * as redux from 'redux';
* returned store.
* @return {object} Redux store
*/
export
default
function
fake
Store
(
initialState
,
methods
)
{
export
function
fakeRedux
Store
(
initialState
,
methods
)
{
function
update
(
state
,
action
)
{
if
(
action
.
state
)
{
return
Object
.
assign
({},
state
,
action
.
state
);
...
...
src/sidebar/test/fake-window.js
View file @
c3e2a91b
export
default
class
FakeWindow
{
export
class
FakeWindow
{
constructor
()
{
this
.
callbacks
=
[];
...
...
src/sidebar/test/render-markdown-test.js
View file @
c3e2a91b
import
renderMarkdown
from
'../render-markdown'
;
import
{
$imports
}
from
'../render-markdown'
;
import
{
renderMathAndMarkdown
,
$imports
}
from
'../render-markdown'
;
describe
(
'render-markdown'
,
()
=>
{
let
render
;
...
...
@@ -19,7 +18,7 @@ describe('render-markdown', () => {
},
});
render
=
markdown
=>
renderMarkdown
(
markdown
);
render
=
markdown
=>
renderMa
thAndMa
rkdown
(
markdown
);
});
afterEach
(()
=>
{
...
...
@@ -61,21 +60,21 @@ describe('render-markdown', () => {
// library. This is not an extensive test of sanitization behavior, that
// is left to DOMPurify's tests.
assert
.
equal
(
renderMarkdown
(
'one **two** <script>alert("three")</script>'
),
renderMa
thAndMa
rkdown
(
'one **two** <script>alert("three")</script>'
),
'<p>one <strong>two</strong> </p>'
);
});
it
(
'should open links in a new window'
,
()
=>
{
assert
.
equal
(
renderMarkdown
(
'<a href="http://example.com">test</a>'
),
renderMa
thAndMa
rkdown
(
'<a href="http://example.com">test</a>'
),
'<p><a href="http://example.com" target="_blank">test</a></p>'
);
});
it
(
'should render strikethrough'
,
()
=>
{
assert
.
equal
(
renderMarkdown
(
'This is ~~no longer the case~~'
),
renderMa
thAndMa
rkdown
(
'This is ~~no longer the case~~'
),
'<p>This is <del>no longer the case</del></p>'
);
});
...
...
src/sidebar/util/disable-opener-for-external-links.js
View file @
c3e2a91b
...
...
@@ -15,7 +15,7 @@
*
* @param {Element} root - Root element
*/
export
default
function
disableOpenerForExternalLinks
(
root
)
{
export
function
disableOpenerForExternalLinks
(
root
)
{
root
.
addEventListener
(
'click'
,
event
=>
{
const
target
=
/** @type {HTMLElement} */
(
event
.
target
);
...
...
src/sidebar/util/immutable.js
View file @
c3e2a91b
...
...
@@ -28,7 +28,7 @@ function deepFreeze(object) {
* @param {object} object
* @return {object} Returns the input object
*/
export
default
function
immutable
(
object
)
{
export
function
immutable
(
object
)
{
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
return
object
;
}
else
{
...
...
src/sidebar/util/memoize.js
View file @
c3e2a91b
...
...
@@ -10,7 +10,7 @@
* @param {(arg: Arg) => Result} fn
* @return {(arg: Arg) => Result}
*/
export
default
function
memoize
(
fn
)
{
export
function
memoize
(
fn
)
{
if
(
fn
.
length
!==
1
)
{
throw
new
Error
(
'Memoize input must be a function of one argument'
);
}
...
...
src/sidebar/util/oauth-client.js
View file @
c3e2a91b
...
...
@@ -39,7 +39,7 @@ export class TokenError extends Error {
* OAuthClient handles interaction with the annotation service's OAuth
* endpoints.
*/
export
default
class
OAuthClient
{
export
class
OAuthClient
{
/**
* Create a new OAuthClient
*
...
...
src/sidebar/util/observe-element-size.js
View file @
c3e2a91b
...
...
@@ -13,7 +13,7 @@ import { ListenerCollection } from '../../shared/listener-collection';
* element when a change in its size is detected.
* @return {() => void}
*/
export
default
function
observeElementSize
(
element
,
onSizeChanged
)
{
export
function
observeElementSize
(
element
,
onSizeChanged
)
{
if
(
typeof
ResizeObserver
!==
'undefined'
)
{
const
observer
=
new
ResizeObserver
(()
=>
onSizeChanged
(
element
.
clientWidth
,
element
.
clientHeight
)
...
...
src/sidebar/util/sentry.js
View file @
c3e2a91b
...
...
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/browser';
import
{
parseConfigFragment
}
from
'../../shared/config-fragment'
;
import
{
handleErrorsInFrames
}
from
'../../shared/frame-error-capture'
;
import
warnOnce
from
'../../shared/warn-once'
;
import
{
warnOnce
}
from
'../../shared/warn-once'
;
/**
* @typedef SentryConfig
...
...
src/sidebar/util/test/disable-opener-for-external-links-test.js
View file @
c3e2a91b
import
disableOpenerForExternalLinks
from
'../disable-opener-for-external-links'
;
import
{
disableOpenerForExternalLinks
}
from
'../disable-opener-for-external-links'
;
describe
(
'sidebar.util.disable-opener-for-external-links'
,
()
=>
{
let
containerEl
;
...
...
src/sidebar/util/test/immutable-test.js
View file @
c3e2a91b
import
immutable
from
'../immutable'
;
import
{
immutable
}
from
'../immutable'
;
describe
(
'immutable'
,
()
=>
{
it
(
'deeply freezes objects'
,
()
=>
{
...
...
src/sidebar/util/test/memoize-test.js
View file @
c3e2a91b
import
memoize
from
'../memoize'
;
import
{
memoize
}
from
'../memoize'
;
describe
(
'memoize'
,
()
=>
{
let
count
=
0
;
...
...
src/sidebar/util/test/oauth-client-test.js
View file @
c3e2a91b
import
fetchMock
from
'fetch-mock'
;
import
FakeWindow
from
'../../test/fake-window'
;
import
OAuthClient
,
{
TokenError
,
$imports
}
from
'../oauth-client'
;
import
{
FakeWindow
}
from
'../../test/fake-window'
;
import
{
OAuthClient
,
TokenError
,
$imports
}
from
'../oauth-client'
;
const
fixtures
=
{
tokenResponse
:
{
...
...
src/sidebar/util/test/observe-element-size-test.js
View file @
c3e2a91b
import
observeElementSize
from
'../observe-element-size'
;
import
{
observeElementSize
}
from
'../observe-element-size'
;
/**
* Wait for a condition to become true.
...
...
src/sidebar/util/test/sentry-test.js
View file @
c3e2a91b
...
...
@@ -27,7 +27,7 @@ describe('sidebar/util/sentry', () => {
'../../shared/frame-error-capture'
:
{
handleErrorsInFrames
:
fakeHandleErrorsInFrames
,
},
'../../shared/warn-once'
:
fakeWarnOnce
,
'../../shared/warn-once'
:
{
warnOnce
:
fakeWarnOnce
}
,
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment