Commit e0020c33 authored by Robert Knight's avatar Robert Knight

Convert src/annotator/config to ES modules

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