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

Automatic type substitution of `Object` for `object`

I used these commands (Mac version):

```
% ag -0 -l '@.+Object' | xargs -0 sed -ri '' -e '/@/s/(.*{.*)Object(.*})/\1object\2/'
% ag -0 -l '@.+object\.' | xargs -0 sed -ri '' -e '/@/s/object\.</Record</'
% ag -0 -l '@.+object<' | xargs -0 sed -ri '' -e '/@/s/object</Record</'
```
parent 6108e4b4
......@@ -23,7 +23,7 @@ const TEMPLATE_PATH = `${__dirname}/templates/`;
/**
* Render client config and script embed
*
* @param {Object} context
* @param {object} context
*/
function renderScript(context) {
const scriptTemplate = `
......
......@@ -239,8 +239,8 @@ let isFirstBuild = true;
* Generates the `build/boot.js` script which serves as the entry point for
* the Hypothesis client.
*
* @param {Object} manifest - Manifest mapping asset paths to cache-busted URLs
* @param {Object} options - Options for generating the boot script
* @param {object} manifest - Manifest mapping asset paths to cache-busted URLs
* @param {object} options - Options for generating the boot script
*/
function generateBootScript(manifest, { usingDevServer = false } = {}) {
const { version } = require('./package.json');
......
......@@ -73,7 +73,7 @@ function jsdocComment(lines) {
* JSDoc `@typedef` comment.
*
* @param {string} componentName
* @param {Object} An `ObjectExpression` AST node
* @param {object} An `ObjectExpression` AST node
*/
function jsdocTypedefFromPropTypes(componentName, objectExpression) {
const props = [];
......
......@@ -64,7 +64,7 @@ function nearestPositionedAncestor(el) {
* @typedef AdderOptions
* @prop {() => any} onAnnotate - Callback invoked when "Annotate" button is clicked
* @prop {() => any} onHighlight - Callback invoked when "Highlight" button is clicked
* @prop {(annotations: Object[]) => any} onShowAnnotations -
* @prop {(annotations: object[]) => any} onShowAnnotations -
* Callback invoked when "Show" button is clicked
*
* @typedef {import('../types/annotator').Destroyable} Destroyable
......@@ -130,7 +130,7 @@ export class Adder {
* a "Show" button appears in the toolbar. Clicking the button calls the
* `onShowAnnotations` callback with the current value of `annotationsForSelection`.
*
* @type {Object[]}
* @type {object[]}
*/
this.annotationsForSelection = [];
......
......@@ -6,7 +6,7 @@ import { RangeAnchor, TextPositionAnchor, TextQuoteAnchor } from './types';
/**
* @param {RangeAnchor|TextPositionAnchor|TextQuoteAnchor} anchor
* @param {Object} [options]
* @param {object} [options]
* @param {number} [options.hint]
*/
async function querySelector(anchor, options = {}) {
......@@ -22,7 +22,7 @@ async function querySelector(anchor, options = {}) {
*
* @param {Element} root - The root element of the anchoring context.
* @param {Selector[]} selectors - The selectors to try.
* @param {Object} [options]
* @param {object} [options]
* @param {number} [options.hint]
*/
export function anchor(root, selectors, options = {}) {
......
......@@ -73,7 +73,7 @@ function textMatchScore(text, str) {
*
* @param {string} text - Document text to search
* @param {string} quote - String to find within `text`
* @param {Object} context -
* @param {object} context -
* Context in which the quote originally appeared. This is used to choose the
* best match.
* @param {string} [context.prefix] - Expected text before the quote
......
......@@ -18,7 +18,7 @@ import { TextQuoteAnchor } from './types';
/**
* @typedef PdfTextRange
* @prop {number} pageIndex
* @prop {Object} anchor
* @prop {object} anchor
* @prop {number} anchor.start - Start character offset within the page's text
* @prop {number} anchor.end - End character offset within the page's text
*/
......
......@@ -37,7 +37,7 @@ function findNode(context, query) {
* Resolve a serialized description of a range into a Range object.
*
* @param {Element} root
* @param {Object} descriptor
* @param {object} descriptor
*/
function toRange(root, descriptor) {
let startNode;
......
......@@ -137,7 +137,7 @@ export class TextPosition {
* Offsets at the boundary between two nodes are resolved to the start of the
* node that begins at the boundary.
*
* @param {Object} [options]
* @param {object} [options]
* @param {RESOLVE_FORWARDS|RESOLVE_BACKWARDS} [options.direction] -
* Specifies in which direction to search for the nearest text node if
* `this.offset` is `0` and `this.element` has no text. If not specified
......
......@@ -158,7 +158,7 @@ export class TextQuoteAnchor {
/**
* @param {Element} root - A root element from which to anchor.
* @param {string} exact
* @param {Object} context
* @param {object} context
* @param {string} [context.prefix]
* @param {string} [context.suffix]
*/
......
......@@ -4,7 +4,7 @@ import { SvgIcon } from '@hypothesis/frontend-shared';
import { useShortcut } from '../../shared/shortcut';
/**
* @param {Object} props
* @param {object} props
* @param {number} [props.badgeCount]
* @param {string} [props.icon]
* @param {string} props.label
......
......@@ -13,7 +13,7 @@ import { findClosestOffscreenAnchor } from '../util/buckets';
* A left-pointing indicator button that, when hovered or clicked, highlights
* or selects associated annotations.
*
* @param {Object} props
* @param {object} props
* @param {Bucket} props.bucket
* @param {(annotations: AnnotationData[], toggle: boolean) => any} props.onSelectAnnotations
*/
......@@ -50,7 +50,7 @@ function BucketButton({ bucket, onSelectAnnotations }) {
* An up- or down-pointing button that will scroll to the next closest bucket
* of annotations in the given direction.
*
* @param {Object} props
* @param {object} props
* @param {Bucket} props.bucket
* @param {'up'|'down'} props.direction
* @param {(a: Anchor) => void} props.scrollToAnchor - Callback invoked to
......@@ -82,7 +82,7 @@ function NavigationBucketButton({ bucket, direction, scrollToAnchor }) {
* A list of buckets, including up and down navigation (when applicable) and
* on-screen buckets
*
* @param {Object} props
* @param {object} props
* @param {Bucket} props.above
* @param {Bucket} props.below
* @param {Bucket[]} props.buckets
......
import { SvgIcon } from '@hypothesis/frontend-shared';
/**
* @param {Object} props
* @param {object} props
* @param {import("preact").Ref<HTMLButtonElement>} [props.buttonRef]
* @param {boolean} [props.expanded]
* @param {string} [props.className]
......
/**
* @typedef HypothesisWindowProps
* @prop {() => Object} [hypothesisConfig] - Function that returns configuration
* @prop {() => object} [hypothesisConfig] - Function that returns configuration
* for the Hypothesis client
*/
......@@ -19,7 +19,7 @@
* If there's no window.hypothesisConfig() function then return {}.
*
* @param {Window & HypothesisWindowProps} window_ - The window to search for a hypothesisConfig() function
* @return {Object} - Any config settings returned by hypothesisConfig()
* @return {object} - Any config settings returned by hypothesisConfig()
*
*/
export default function configFuncSettingsFrom(window_) {
......
......@@ -14,7 +14,7 @@ import { urlFromLinkTag } from './url-from-link-tag';
* @prop {string} sidebarAppUrl
* @prop {string} notebookAppUrl
* @prop {(name: string, options?: Object) => (string|null)} hostPageSetting
* @prop {(name: string, options?: object) => (string|null)} hostPageSetting
*/
/**
......
......@@ -32,12 +32,12 @@ import { normalizeURI } from '../util/url';
* @typedef HTMLDocumentMetadata
* @prop {string} title
* @prop {Link[]} link
* @prop {Object.<string, string[]>} dc
* @prop {Object.<string, string[]>} eprints
* @prop {Object.<string, string[]>} facebook
* @prop {Object.<string, string[]>} highwire
* @prop {Object.<string, string[]>} prism
* @prop {Object.<string, string[]>} twitter
* @prop {Record<string, string[]>} dc
* @prop {Record<string, string[]>} eprints
* @prop {Record<string, string[]>} facebook
* @prop {Record<string, string[]>} highwire
* @prop {Record<string, string[]>} prism
* @prop {Record<string, string[]>} twitter
* @prop {string} [favicon]
* @prop {string} [documentFingerprint]
*/
......@@ -115,10 +115,10 @@ export class HTMLMetadata {
* @param {string} prefix
* @param {string} attribute
* @param {string} delimiter
* @return {Object.<string,string[]>}
* @return {Record<string,string[]>}
*/
_getMetaTags(prefix, attribute, delimiter) {
/** @type {Object.<string,string[]>} */
/** @type {Record<string,string[]>} */
const tags = {};
for (let meta of Array.from(this.document.querySelectorAll('meta'))) {
const name = meta.getAttribute(attribute);
......
......@@ -9,7 +9,7 @@ class FakeMetadata {
/**
* Initialize the metadata dictionary.
*
* @param {Object} metadata - A key/value dictionary of metadata fields.
* @param {object} metadata - A key/value dictionary of metadata fields.
*/
constructor(metadata) {
this._metadata = metadata;
......@@ -69,7 +69,7 @@ class FakePDFViewerApplication {
* when a document fails to load.
*
* @param {string} url - Fake PDF URL
* @param {Object} options -
* @param {object} options -
* Options to simulate APIs of different versions of PDF.js.
*
* @prop {boolean} domEvents - Whether events are emitted on the DOM
......
......@@ -5,7 +5,7 @@ const SIDEBAR_TRIGGER_BTN_ATTR = 'data-hypothesis-trigger';
* trigger data attribute.
*
* @param {Element} rootEl - The DOM element which contains the trigger elements.
* @param {Object} showFn - Function which shows the sidebar.
* @param {object} showFn - Function which shows the sidebar.
*/
export default function trigger(rootEl, showFn) {
......
......@@ -14,7 +14,7 @@ const commonPolyfills = [
/**
* @typedef SidebarAppConfig
* @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative
* @prop {Object.<string,string>} manifest -
* @prop {Record<string,string>} manifest -
* A mapping from canonical asset path to cache-busted asset path
* @prop {string} apiUrl
*/
......@@ -24,7 +24,7 @@ const commonPolyfills = [
* @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative
* @prop {string} notebookAppUrl - The URL of the sidebar's notebook
* @prop {string} sidebarAppUrl - The URL of the sidebar's HTML page
* @prop {Object.<string,string>} manifest -
* @prop {Record<string,string>} manifest -
* A mapping from canonical asset path to cache-busted asset path
*/
......
......@@ -4,7 +4,7 @@ import { options } from 'preact';
* Setup workarounds for setting certain HTML element properties or attributes
* in some browsers.
*
* @param {Object} _options - Test seam
* @param {object} _options - Test seam
*/
export function setupBrowserFixes(_options = options) {
let needsDirAutoFix = false;
......
......@@ -44,7 +44,7 @@ export function toInteger(value) {
* Returns either the value if its an object or an empty object
*
* @param {any} value - initial value
* @return {Object}
* @return {object}
*/
export function toObject(value) {
if (typeof value === 'object' && value !== null) {
......
......@@ -10,7 +10,7 @@ import { applyTheme } from '../helpers/theme';
* @typedef InlineControlsProps
* @prop {boolean} isCollapsed
* @prop {(collapsed: boolean) => any} setCollapsed
* @prop {Object} [linkStyle]
* @prop {object} [linkStyle]
*/
/**
......@@ -44,7 +44,7 @@ const noop = () => {};
/**
* @typedef ExcerptProps
* @prop {Object} [children]
* @prop {object} [children]
* @prop {boolean} [inlineControls] - If `true`, the excerpt provides internal
* controls to expand and collapse the content. If `false`, the caller sets
* the collapsed state via the `collapse` prop. When using inline controls,
......@@ -61,7 +61,7 @@ const noop = () => {};
* @prop {(collapsed: boolean) => void} [onToggleCollapsed] - When `inlineControls` is `false`, this
* function is called when the user requests to expand the content by clicking a
* zone at the bottom of the container.
* @prop {Object} [settings] - Used for theming.
* @prop {object} [settings] - Used for theming.
*/
/**
......@@ -120,7 +120,7 @@ function Excerpt({
const isCollapsed = inlineControls ? collapsedByInlineControls : collapse;
const isExpandable = isOverflowing && isCollapsed;
/** @type {Object} */
/** @type {object} */
const contentStyle = {};
if (contentHeight !== 0) {
contentStyle['max-height'] = isExpandable ? collapsedHeight : contentHeight;
......
......@@ -16,7 +16,7 @@ import VersionInfo from './VersionInfo';
/**
* External link "tabs" inside of the help panel.
*
* @param {Object} props
* @param {object} props
* @param {string} props.linkText - What the tab's link should say
* @param {string} props.url - Where the tab's link should go
*/
......
......@@ -94,7 +94,7 @@ function handleToolbarCommand(command, inputEl) {
/**
* @typedef ToolbarButtonProps
* @prop {Object} buttonRef
* @prop {object} buttonRef
* @prop {boolean} [disabled]
* @prop {string} [iconName]
* @prop {string} [label]
......@@ -374,10 +374,10 @@ function Toolbar({ isPreviewing, onCommand, onTogglePreview }) {
/**
* @typedef MarkdownEditorProps
* @prop {string} label - An accessible label for the input field.
* @prop {Object.<string,string>} [textStyle] -
* @prop {Record<string,string>} [textStyle] -
* Additional CSS properties to apply to the input field and rendered preview
* @prop {string} [text] - The markdown text to edit.
* @prop {(a?: Object<'text', string>) => void} [onEditText]
* @prop {(a?: Record<'text', string>) => void} [onEditText]
* - Callback invoked with `{ text }` object when user edits text.
* TODO: Simplify this callback to take just a string rather than an object once the
* parent component is converted to Preact.
......
......@@ -7,9 +7,9 @@ import renderMarkdown from '../render-markdown';
/**
* @typedef MarkdownViewProps
* @prop {string} markdown - The string of markdown to display
* @prop {Object.<string,string>} [textStyle] -
* @prop {Record<string,string>} [textStyle] -
* Additional CSS properties to apply to the rendered markdown
* @prop {Object.<string,boolean>} [textClass] -
* @prop {Record<string,boolean>} [textClass] -
* Map of classes to apply to the container of the rendered markdown
*/
......
......@@ -32,8 +32,8 @@ let ignoreNextClick = false;
* Additional CSS class for the arrow caret at the edge of the menu content that "points"
* toward the menu's toggle button. This can be used to adjust the position of that caret
* respective to the toggle button.
* @prop {Object|string} [label] - Label element for the toggle button that hides and shows the menu.
* @prop {Object} [children] -
* @prop {object|string} [label] - Label element for the toggle button that hides and shows the menu.
* @prop {object} [children] -
* Menu items and sections to display in the content area of the menu. These are typically
* `MenuSection` and `MenuItem` components, but other custom content is also allowed.
* @prop {boolean} [containerPositioned] -
......
......@@ -37,7 +37,7 @@ import Slider from './Slider';
* @prop {(e: Event) => any} [onClick] - Callback to invoke when the menu item is clicked.
* @prop {(e: Event) => any} [onToggleSubmenu] -
* Callback when the user clicks on the toggle to change the expanded state of the menu.
* @prop {Object} [submenu] -
* @prop {object} [submenu] -
* Contents of the submenu for this item. This is typically a list of `MenuItem` components
* with the `isSubmenuItem` prop set to `true`, but can include other content as well.
* The submenu is only rendered if `isSubmenuVisible` is `true`.
......
......@@ -10,7 +10,7 @@ function isElementVisible(element) {
* @prop {string} [className]
* @prop {(e: KeyboardEvent) => any} [closeMenu] - Callback when the menu is closed via keyboard input
* @prop {boolean} [visible] - When true`, sets focus on the first item in the list
* @prop {Object} children - Array of nodes which may contain <MenuItems> or any nodes
* @prop {object} children - Array of nodes which may contain <MenuItems> or any nodes
*/
/**
......
......@@ -5,7 +5,7 @@ import { toChildArray } from 'preact';
/**
* @typedef MenuSectionProps
* @prop {string} [heading] - Heading displayed at the top of the menu.
* @prop {Object} children - Menu items to display in this section.
* @prop {object} children - Menu items to display in this section.
*/
/**
......
......@@ -12,7 +12,7 @@ import { withServices } from '../service-context';
/**
* @typedef TabProps
* @prop {Object} children - Child components.
* @prop {object} children - Child components.
* @prop {number} count - The total annotations for this tab.
* @prop {boolean} isSelected - Is this tab currently selected?
* @prop {boolean} isWaitingToAnchor - Are there any annotations still waiting to anchor?
......
......@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
/**
* @typedef SliderProps
* @prop {Object} [children] - The slideable content to hide or reveal.
* @prop {object} [children] - The slideable content to hide or reveal.
* @prop {boolean} visible - Whether the content should be visible or not.
*/
......
......@@ -76,7 +76,7 @@ function ToastMessage({ message, onDismiss }) {
/**
* @typedef ToastMessagesProps
* @prop {Object} toastMessenger - Injected service
* @prop {object} toastMessenger - Injected service
*/
/**
......
......@@ -28,7 +28,7 @@ import MenuSection from './MenuSection';
* @typedef UserMenuProps
* @prop {AuthStateLoggedIn} auth - object representing authenticated user and auth status
* @prop {() => any} onLogout - onClick callback for the "log out" button
* @prop {Object} bridge
* @prop {object} bridge
* @prop {MergedConfig} settings
*/
......
......@@ -20,7 +20,7 @@ export default function useRootThread() {
const filters = store.getFilterValues();
const threadState = useMemo(() => {
/** @type {Object.<string,string>} */
/** @type {Record<string,string>} */
return {
annotations,
route,
......
......@@ -84,9 +84,9 @@ function fetchConfigFromAncestorFrame(origin, window_ = window) {
* synchronously in the query string. However it can also be retrieved from
* an ancestor of the embedding frame. See tests for more details.
*
* @param {Object} appConfig - Settings rendered into `app.html` by the h service.
* @param {object} appConfig - Settings rendered into `app.html` by the h service.
* @param {Window} window_ - Test seam.
* @return {Promise<Object>} - The merged settings.
* @return {Promise<object>} - The merged settings.
*/
function fetchConfigLegacy(appConfig, window_ = window) {
const hostPageConfig = hostConfig(window_);
......@@ -105,9 +105,9 @@ function fetchConfigLegacy(appConfig, window_ = window) {
/**
* Merge client configuration from h service with config from the hash fragment.
*
* @param {Object} appConfig - App config settings rendered into `app.html` by the h service.
* @param {Object} hostPageConfig - App configuration specified by the embedding frame.
* @return {Object} - The merged settings.
* @param {object} appConfig - App config settings rendered into `app.html` by the h service.
* @param {object} hostPageConfig - App configuration specified by the embedding frame.
* @return {object} - The merged settings.
*/
function fetchConfigEmbed(appConfig, hostPageConfig) {
const mergedConfig = {
......@@ -125,10 +125,10 @@ function fetchConfigEmbed(appConfig, hostPageConfig) {
* Use this method to retrieve the config asynchronously from a parent
* frame via RPC. See tests for more details.
*
* @param {Object} appConfig - Settings rendered into `app.html` by the h service.
* @param {object} appConfig - Settings rendered into `app.html` by the h service.
* @param {Window} parentFrame - Frame to send call to.
* @param {string} origin - Origin filter for `window.postMessage` call.
* @return {Promise<Object>} - The merged settings.
* @return {Promise<object>} - The merged settings.
*/
async function fetchConfigRpc(appConfig, parentFrame, origin) {
const remoteConfig = await postMessageJsonRpc.call(
......@@ -156,11 +156,11 @@ async function fetchConfigRpc(appConfig, parentFrame, origin) {
* fill in the `groups` value(s) later when its ready. This helps speed
* up the loading process.
*
* @param {Object} config - The configuration object to mutate. This should
* @param {object} config - The configuration object to mutate. This should
* already have the `services` value
* @param {function} rpcCall - RPC method
* (method, args, timeout) => Promise
* @return {Promise<Object>} - The mutated settings
* @return {Promise<object>} - The mutated settings
*/
async function fetchGroupsAsync(config, rpcCall) {
if (Array.isArray(config.services)) {
......
......@@ -6,8 +6,8 @@ let preStartQueue = [];
/**
* Return the mapped methods that can be called remotely via this server.
*
* @param {Object} store - The global store
* @return {Object}
* @param {object} store - The global store
* @return {object}
*/
const registeredMethods = store => {
return {
......
......@@ -66,7 +66,7 @@ function hasPathToRoot(threads, id, ancestorId) {
/**
* Link the thread's annotation to its parent
* @param {Object.<string,Thread>} threads
* @param {Record<string,Thread>} threads
* @param {string} id
* @param {string[]} [parents] - ids of parent annotations, from the
* annotation's `references` field. Immediate parent is last entry.
......@@ -111,7 +111,7 @@ function setParent(threads, id, parents = []) {
* @return {Thread} - The input annotations threaded into a tree structure.
*/
function threadAnnotations(annotations) {
/** @type {Object.<string,Thread>} */
/** @type {Record<string,Thread>} */
const threads = {};
// Create a `Thread` for each annotation
......@@ -228,7 +228,7 @@ function hasVisibleChildren(thread) {
/**
* @typedef BuildThreadOptions
* @prop {Object.<string, boolean>} expanded - Map of thread id => expansion state
* @prop {Record<string, boolean>} expanded - Map of thread id => expansion state
* @prop {string[]} forcedVisible - List of $tags of annotations that have
* been explicitly expanded by the user, even if they don't
* match current filters
......
......@@ -11,7 +11,7 @@ const DEFAULT_ORG_ID = '__default__';
* Generate consistent object keys for organizations so that they
* may be sorted
*
* @param {Object} organization
* @param {object} organization
* @return {String}
*/
function orgKey(organization) {
......@@ -26,7 +26,7 @@ function orgKey(organization) {
* groups Array.
*
* @param {Group} group
* @param {Object} organization
* @param {object} organization
* @return undefined - organization is mutated in place
*/
function addGroup(group, organization) {
......@@ -46,7 +46,7 @@ function addGroup(group, organization) {
* their appropriate "parent" organizations.
*
* @param {Array<Group>} groups
* @return {Object} - A collection of all unique organizations, containing
* @return {object} - A collection of all unique organizations, containing
* their groups. Keyed by each org's "orgKey"
*/
function organizations(groups) {
......@@ -81,7 +81,7 @@ function organizations(groups) {
* organization).
*
* @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) {
const orgs = organizations(groups);
......
......@@ -55,7 +55,7 @@ function filter(thread, keys) {
* which do not match `keys`.
*
* @param {Array<Annotation>} fixture - List of annotations to thread
* @param {Object?} opts - Options to pass to buildThread()
* @param {object?} opts - Options to pass to buildThread()
* @param {Array<string>?} keys - List of keys to keep in the output
*/
function createThread(fixture, options, keys) {
......
......@@ -17,7 +17,7 @@ const supportedThemeProperties = {
* Subset of the config from the host page which includes theme configuration.
*
* @typedef Settings
* @prop {Object.<ThemeProperty,string>} [branding]
* @prop {Record<ThemeProperty,string>} [branding]
*/
/**
......@@ -40,7 +40,7 @@ const supportedThemeProperties = {
* Which of the supported theme properties should have applied rules in the `style`
* object
* @param {Settings} settings
* @return {Object.<string,string>} - Object that can be passed as the `style` prop
* @return {Record<string,string>} - Object that can be passed as the `style` prop
*
* @example
* let themeProperties = ['accentColor', 'ctaTextColor', 'foo'];
......@@ -54,7 +54,7 @@ const supportedThemeProperties = {
* applyTheme(themeProperties, settings); // -> { color: '#ffc '}
*/
export function applyTheme(themeProperties, settings) {
/** @type {Object.<string,string>} */
/** @type {Record<string,string>} */
const style = {};
if (!settings.branding) {
return style;
......
......@@ -13,10 +13,10 @@ import { sorters } from './thread-sorters';
/**
* @typedef ThreadState
* @prop {Annotation[]} annotations
* @prop {Object} selection
* @prop {Object<string,boolean>} selection.expanded
* @prop {object} selection
* @prop {Record<string,boolean>} selection.expanded
* @prop {string|null} selection.filterQuery
* @prop {Object<string,string>} selection.filters
* @prop {Record<string,string>} selection.filters
* @prop {string[]} selection.forcedVisible
* @prop {string[]} selection.selected
* @prop {string} selection.sortKey
......
......@@ -7,14 +7,14 @@
/**
* An object representing document metadata.
*
* @typedef {Object} DocMetadata
* @typedef {object} DocMetadata
* @prop {string=} documentFingerprint - Optional PDF fingerprint for current document
*/
/**
* An object representing document info.
*
* @typedef {Object} DocumentInfo
* @typedef {object} DocumentInfo
* @prop {string=} [uri] - Current document URL
* @prop {DocMetadata} [metadata] - Document metadata
*/
......
......@@ -112,7 +112,7 @@ class BinaryOpFilter {
* value: a function to extract to facet value for the annotation.
* match: a function to check if the extracted value matches the facet value
*
* @type {Object.<string,Checker>}
* @type {Record<string,Checker>}
*/
const fieldMatchers = {
quote: {
......@@ -154,7 +154,7 @@ const fieldMatchers = {
* Filters a set of annotations.
*
* @param {Annotation[]} annotations
* @param {Object} filters - Faceted filter generated by
* @param {object} filters - Faceted filter generated by
* `generateFacetedFilter`.
* @return {string[]} IDs of matching annotations.
*/
......
......@@ -18,11 +18,11 @@ export const THREAD_DIMENSION_DEFAULTS = {
* estimating which of the threads are within or near the viewport.
*
* @param {Thread[]} threads - List of threads in the order they appear
* @param {Object} threadHeights - Map of thread ID to measured height
* @param {object} threadHeights - Map of thread ID to measured height
* @param {number} scrollPos - Vertical scroll offset of scrollable container
* @param {number} windowHeight -
* Height of the visible area of the scrollable container.
* @param {Object} options - Dimensional overrides (in px) for defaults
* @param {object} options - Dimensional overrides (in px) for defaults
*/
export function calculateVisibleThreads(
threads,
......
......@@ -155,7 +155,7 @@ function youTubeEmbed(id, link) {
* contain a single capture group which matches the video ID within the path.
* @param {(videoId: string) => string} iframeUrlGenerator -
* Generate the URL for an embedded video iframe from a video ID
* @param {Object} [options]
* @param {object} [options]
* @param {number} [options.aspectRatio]
* @return {(link: HTMLAnchorElement) => HTMLElement|null}
*/
......@@ -393,7 +393,7 @@ function replaceLinkWithEmbed(link) {
* embeds of the same media.
*
* @param {HTMLElement} element
* @param {Object} options
* @param {object} options
* @param {string} [options.className] -
* Class name to apply to embed containers. An important function of this class is to set
* the width of the embed.
......
......@@ -48,7 +48,7 @@ function defaultPageSize(index) {
export class SearchClient extends TinyEmitter {
/**
* @param {(query: SearchQuery) => Promise<SearchResult>} searchFn - Function for querying the search API
* @param {Object} options
* @param {object} options
* @param {(index: number) => number} [options.getPageSize] -
* Callback that returns the page size to use when fetching the index'th
* page of results. Callers can vary this to balance the latency of
......
......@@ -114,7 +114,7 @@ export function withServices(Component, serviceNames) {
* context of custom hooks.
*
* @param {string} service - Name of the service to look up
* @return {Object}
* @return {object}
*/
export function useService(service) {
const injector = useContext(ServiceContext);
......
......@@ -100,7 +100,7 @@ export class AnnotationsService {
* Create a draft for it unless it's a highlight and clear other empty
* drafts out of the way.
*
* @param {Object} annotationData
* @param {object} annotationData
* @param {Date} now
*/
create(annotationData, now = new Date()) {
......@@ -177,7 +177,7 @@ export class AnnotationsService {
/**
* Create a reply to `annotation` by the user `userid` and add to the store.
*
* @param {Object} annotation
* @param {object} annotation
* @param {string} userid
*/
reply(annotation, userid) {
......
......@@ -14,7 +14,7 @@
* @typedef Filter
* @prop {string} match_policy - TODO: Remove this, the backend doesn't use it any more.
* @prop {FilterClause[]} clauses
* @prop {Object} actions - TODO: Remove this, the backend doesn't use it any more.
* @prop {object} actions - TODO: Remove this, the backend doesn't use it any more.
* @prop {boolean} [actions.create]
* @prop {boolean} [actions.update]
* @prop {boolean} [actions.delete]
......
......@@ -220,7 +220,7 @@ export class StreamerService {
*
* If the service has already connected this does nothing.
*
* @param {Object} [options]
* @param {object} [options]
* @param {boolean} [options.applyUpdatesImmediately] - true if pending updates should be applied immediately
* @return {Promise<void>} Promise which resolves once the WebSocket connection
* process has started.
......
......@@ -36,7 +36,7 @@ describe('APIService', () => {
* @param {number|null} status -
* Expected HTTP status. If `null` then the call to `fetch` will reject with
* the content of `body` as the error message.
* @param {Object|string} body - Expected response body or error message
* @param {object|string} body - Expected response body or error message
*/
function expectCall(
method,
......
......@@ -8,7 +8,7 @@ const MESSAGE_DISMISS_DELAY = 500;
/**
* Additional control over the display of a particular message.
*
* @typedef {Object} MessageOptions
* @typedef {object} MessageOptions
* @prop {boolean} [autoDismiss=true] - Whether the toast message automatically disappears.
* @prop {string} [moreInfoURL=''] - Optional URL for users to visit for "more info"
*/
......
......@@ -68,10 +68,10 @@ function findByTag(annotations, tag) {
* `annotation` may either be new (unsaved) or a persisted annotation retrieved
* from the service.
*
* @param {Object} annotation
* @param {object} annotation
* @param {string} tag - The `$tag` value that should be used for this
* if it doesn't have a `$tag` already
* @return {Object} - annotation with local (`$*`) fields set
* @return {object} - annotation with local (`$*`) fields set
*/
function initializeAnnotation(annotation, tag) {
let orphan = annotation.$orphan;
......
......@@ -46,7 +46,7 @@ import { createStoreModule } from '../create-store';
*/
/**
* @typedef {Object.<FilterKey, FilterOption>} Filters
* @typedef {Record<FilterKey, FilterOption>} Filters
*/
/**
......@@ -265,7 +265,7 @@ function getFilter(state, filterName) {
const getFilterValues = createSelector(
state => getFilters(state),
allFilters => {
/** @type {Object.<string,string>} */
/** @type {Record<string,string>} */
const filterValues = {};
Object.keys(allFilters).forEach(
filterKey => (filterValues[filterKey] = allFilters[filterKey].value)
......
......@@ -89,7 +89,7 @@ const actions = actionTypes(reducers);
* Record pending updates representing changes on the server that the client
* has been notified about but has not yet applied.
*
* @param {Object} args
* @param {object} args
* @param {Annotation[]} [args.updatedAnnotations]
* @param {Annotation[]} [args.deletedAnnotations]
*/
......@@ -153,7 +153,7 @@ function clearPendingUpdates() {
* Return added or updated annotations received via the WebSocket
* which have not been applied to the local state.
*
* @return {Object.<string, Annotation>}
* @return {Record<string, Annotation>}
*/
function pendingUpdates(state) {
return state.pendingUpdates;
......@@ -163,7 +163,7 @@ function pendingUpdates(state) {
* Return IDs of annotations which have been deleted on the server but not
* yet removed from the local state.
*
* @return {Object.<string, Annotation>}
* @return {Record<string, Annotation>}
*/
function pendingDeletions(state) {
return state.pendingDeletions;
......
......@@ -38,7 +38,7 @@ const actions = actionTypes(reducers);
* Change the active route.
*
* @param {string} name - Name of the route to activate. See `initialState` for possible values
* @param {Object.<string,string>} params - Parameters associated with the route
* @param {Record<string,string>} params - Parameters associated with the route
*/
function changeRoute(name, params = {}) {
return {
......
......@@ -10,7 +10,7 @@
/**
* @typedef SelectionState
* @prop {Object<string,boolean>} expanded
* @prop {Record<string,boolean>} expanded
* @prop {string[]} forcedVisible
* @prop {string[]} selected
* @prop {string} sortKey
......@@ -303,7 +303,7 @@ function toggleSelectedAnnotations(toggleIds) {
/**
* Retrieve map of expanded/collapsed annotations (threads)
*
* @return {Object<string,boolean>}
* @return {Record<string,boolean>}
*/
function expandedMap(state) {
return state.expanded;
......
......@@ -82,7 +82,7 @@ function updateMessage(message) {
* Retrieve a message by `id`
*
* @param {string} id
* @return {Object|undefined}
* @return {object|undefined}
*/
function getMessage(state, id) {
return state.messages.find(message => message.id === id);
......@@ -91,7 +91,7 @@ function getMessage(state, id) {
/**
* Retrieve all current messages
*
* @return {Object[]}
* @return {object[]}
*/
function getMessages(state) {
return state.messages;
......
......@@ -3,7 +3,7 @@
/**
* Return an object where each key in `updateFns` is mapped to the key itself.
*
* @template {Object.<string,Function>} T
* @template {Record<string,Function>} T
* @param {T} reducers - Object containing reducer functions
* @return {{ [index in keyof T]: string }}
*/
......@@ -81,7 +81,7 @@ export function bindSelectors(namespaces, getState) {
* which reads values from a Redux store, returns non-null.
*
* @template T
* @param {Object} store - Redux store
* @param {object} store - Redux store
* @param {(s: Store) => T|null} selector - Function which returns a value from the
* store if the criteria is met or `null` otherwise.
* @return {Promise<T>}
......
......@@ -6,10 +6,10 @@ import * as redux from 'redux';
* Unlike a real store, this has a `setState()` method that can be used to
* set the state directly.
*
* @param {Object} initialState - Initial state for the store
* @param {Object} methods - A set of additional properties to mixin to the
* @param {object} initialState - Initial state for the store
* @param {object} methods - A set of additional properties to mixin to the
* returned store.
* @return {Object} Redux store
* @return {object} Redux store
*/
export default function fakeStore(initialState, methods) {
function update(state, action) {
......
......@@ -21,10 +21,10 @@ export function countIf(ary, predicate) {
* to `true`.
*
* @param {string[]} arr
* @return {Object<string,true>}
* @return {Record<string,true>}
*/
export function toTrueMap(arr) {
const obj = /** @type {Object<string,true>} */ ({});
const obj = /** @type {Record<string,true>} */ ({});
arr.forEach(key => (obj[key] = true));
return obj;
}
......@@ -33,7 +33,7 @@ export function toTrueMap(arr) {
* Utility function that returns all of the properties of an object whose
* value is `true`.
*
* @param {Object} obj
* @param {object} obj
* @return {string[]}
*/
export function trueKeys(obj) {
......
......@@ -25,8 +25,8 @@ function deepFreeze(object) {
/**
* Prevent accidental mutations to `object` or any of its fields in debug builds.
*
* @param {Object} object
* @return {Object} Returns the input object
* @param {object} object
* @return {object} Returns the input object
*/
export default function immutable(object) {
if (process.env.NODE_ENV === 'production') {
......
......@@ -86,10 +86,10 @@ function tokenize(searchText) {
* Parse a search query into a map of search field to term.
*
* @param {string} searchText
* @return {Object.<string,string[]>}
* @return {Record<string,string[]>}
*/
export function toObject(searchText) {
/** @type {Object.<string,string[]>} */
/** @type {Record<string,string[]>} */
const obj = {};
const backendFilter = f => (f === 'tag' ? 'tags' : f);
......@@ -136,7 +136,7 @@ export function toObject(searchText) {
*
* @param {string} searchText - Filter query to parse
* @param {FocusFilter} focusFilters - Additional filter terms to mix in
* @return {Object.<string,Facet>}
* @return {Record<string,Facet>}
*/
export function generateFacetedFilter(searchText, focusFilters = {}) {
let terms;
......
......@@ -38,7 +38,7 @@ const rejects = async (promiseResult, errorMessage) => {
* Patches the assert object with additional custom helper methods
* defined in this module.
*
* @param {Object} assert - global assertion object.
* @param {object} assert - global assertion object.
*/
export function patch(assert) {
assert.rejects = rejects;
......
......@@ -119,18 +119,18 @@
/**
* @typedef DocumentMetadata
* @prop {string} title
* @prop {Object[]} link
* @prop {object[]} link
* @prop {string} [link.rel]
* @prop {string} [link.type]
* @prop {string} link.href
*
* // HTML only.
* @prop {Object.<string, string[]>} [dc]
* @prop {Object.<string, string[]>} [eprints]
* @prop {Object.<string, string[]>} [facebook]
* @prop {Object.<string, string[]>} [highwire]
* @prop {Object.<string, string[]>} [prism]
* @prop {Object.<string, string[]>} [twitter]
* @prop {Record<string, string[]>} [dc]
* @prop {Record<string, string[]>} [eprints]
* @prop {Record<string, string[]>} [facebook]
* @prop {Record<string, string[]>} [highwire]
* @prop {Record<string, string[]>} [prism]
* @prop {Record<string, string[]>} [twitter]
* @prop {string} [favicon]
*
* // HTML + PDF.
......
......@@ -79,10 +79,10 @@
* @prop {string} user
* @prop {boolean} hidden
*
* @prop {Object} document
* @prop {object} document
* @prop {string} document.title
*
* @prop {Object} permissions
* @prop {object} permissions
* @prop {string[]} permissions.read
* @prop {string[]} permissions.update
* @prop {string[]} permissions.delete
......@@ -91,16 +91,16 @@
* The Hypothesis API structure allows for multiple targets, but the current
* h server only allows for one target per annotation.
*
* @prop {Object} [moderation]
* @prop {object} [moderation]
* @prop {number} moderation.flagCount
*
* @prop {Object} links
* @prop {object} links
* @prop {string} [links.incontext] - A "bouncer" URL to the annotation in
* context on its target document
* @prop {string} [links.html] - An `h`-website URL to view the annotation
* by itself
*
* @prop {Object} [user_info]
* @prop {object} [user_info]
* @prop {string|null} user_info.display_name
*
* // Properties not present on API objects, but added by utilities in the client.
......@@ -112,10 +112,10 @@
/**
* @typedef Profile
* @prop {string|null} userid
* @prop {Object} preferences
* @prop {object} preferences
* @prop {boolean} [preferences.show_sidebar_tutorial]
* @prop {Object.<string, boolean>} features
* @prop {Object} [user_info]
* @prop {Record<string, boolean>} features
* @prop {object} [user_info]
* @prop {string|null} user_info.display_name
*
* @prop {unknown} [groups] - Deprecated.
......@@ -147,7 +147,7 @@
* @prop {Organization} organization - nb. This field is nullable in the API, but
* we assign a default organization on the client.
* @prop {GroupScopes|null} scopes
* @prop {Object} links
* @prop {object} links
* @prop {string} [links.html]
*
* // Properties not present on API objects, but added by utilities in the client.
......
......@@ -73,7 +73,7 @@
* @prop {string} [appType] - Method used to load the client
* @prop {boolean} [openSidebar] - Whether to open the sidebar on the initial load
* @prop {boolean} [showHighlights] - Whether to show highlights
* @prop {Object} [branding] -
* @prop {object} [branding] -
* Theme properties (fonts, colors etc.)
* @prop {boolean} [enableExperimentalNewNoteButton] -
* Whether to show the "New note" button on the "Page Notes" tab
......
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