Commit e0020c33 authored by Robert Knight's avatar Robert Knight

Convert src/annotator/config to ES modules

parent 3f6381db
......@@ -16,7 +16,7 @@
* @return {Object} - Any config settings returned by hypothesisConfig()
*
*/
function configFuncSettingsFrom(window_) {
export default function configFuncSettingsFrom(window_) {
if (!window_.hasOwnProperty('hypothesisConfig')) {
return {};
}
......@@ -30,5 +30,3 @@ function configFuncSettingsFrom(window_) {
return window_.hypothesisConfig();
}
module.exports = configFuncSettingsFrom;
const settingsFrom = require('./settings');
import settingsFrom from './settings';
/**
* Reads the Hypothesis configuration from the environment.
*
* @param {Window} window_ - The Window object to read config from.
*/
function configFrom(window_) {
export default function configFrom(window_) {
const settings = settingsFrom(window_);
return {
annotations: settings.annotations,
......@@ -44,5 +44,3 @@ function configFrom(window_) {
),
};
}
module.exports = configFrom;
......@@ -6,8 +6,6 @@
* website.
*
*/
function isBrowserExtension(app) {
export default function isBrowserExtension(app) {
return !(app.startsWith('http://') || app.startsWith('https://'));
}
module.exports = isBrowserExtension;
const configFuncSettingsFrom = require('./config-func-settings-from');
const isBrowserExtension = require('./is-browser-extension');
const sharedSettings = require('../../shared/settings');
import * as sharedSettings from '../../shared/settings';
function settingsFrom(window_) {
import configFuncSettingsFrom from './config-func-settings-from';
import isBrowserExtension from './is-browser-extension';
export default function settingsFrom(window_) {
const jsonConfigs = sharedSettings.jsonConfigsFrom(window_.document);
const configFuncSettings = configFuncSettingsFrom(window_);
......@@ -214,5 +215,3 @@ function settingsFrom(window_) {
hostPageSetting: hostPageSetting,
};
}
module.exports = settingsFrom;
const configFuncSettingsFrom = require('../config-func-settings-from');
import configFuncSettingsFrom from '../config-func-settings-from';
describe('annotator.config.configFuncSettingsFrom', function() {
const sandbox = sinon.createSandbox();
......
const configFrom = require('../index');
const { $imports } = require('../index');
import configFrom from '../index';
import { $imports } from '../index';
describe('annotator.config.index', function() {
let fakeSettingsFrom;
......
const isBrowserExtension = require('../is-browser-extension');
import isBrowserExtension from '../is-browser-extension';
describe('annotator.config.isBrowserExtension', function() {
[
......
const settingsFrom = require('../settings');
const { $imports } = require('../settings');
import settingsFrom from '../settings';
import { $imports } from '../settings';
describe('annotator.config.settingsFrom', function() {
let fakeConfigFuncSettingsFrom;
......
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