-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/ProjectMirador/research-a…
…nd-demos into history
- Loading branch information
Showing
32 changed files
with
12,389 additions
and
8,910 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"presets": ["env", "react"] | ||
"presets": ["@babel/preset-env", "@babel/preset-react"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
m3core.umd.js | ||
mirador.min.js | ||
dist/ | ||
config/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
m3core.umd.js | ||
dist/ | ||
|
||
dist/mirador.min.js | ||
.idea |
17 changes: 17 additions & 0 deletions
17
minimal_redux_poc/__tests__/integration/mirador/config_updating_from_instance.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* global miradorInstance */ | ||
|
||
describe('Config updating from instance', () => { | ||
beforeAll(async () => { | ||
await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/'); | ||
}); | ||
it('can modify the config via api', async () => { | ||
await page.evaluate(() => { | ||
const a = miradorInstance.actions.updateConfig({ foo: 'bat' }); | ||
miradorInstance.store.dispatch(a); | ||
}); | ||
const config = await page.evaluate(() => ( | ||
miradorInstance.store.getState().config | ||
)); | ||
await expect(config.foo).toBe('bat'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const url = require('url'); | ||
|
||
// Make sure any symlinks in the project folder are resolved: | ||
// https://github.com/facebook/create-react-app/issues/637 | ||
const appDirectory = fs.realpathSync(process.cwd()); | ||
|
||
/** | ||
* | ||
* @param relativePath | ||
* @returns {string} | ||
*/ | ||
const resolveApp = relativePath => path.resolve(appDirectory, relativePath); | ||
|
||
const envPublicUrl = process.env.PUBLIC_URL; | ||
|
||
/** | ||
* | ||
* @param inputPath | ||
* @param needsSlash | ||
* @returns {*} | ||
*/ | ||
function ensureSlash(inputPath, needsSlash) { | ||
const hasSlash = inputPath.endsWith('/'); | ||
if (hasSlash && !needsSlash) { | ||
return inputPath.substr(0, inputPath.length - 1); | ||
} else if (!hasSlash && needsSlash) { | ||
return `${inputPath}/`; | ||
} else { | ||
return inputPath; | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param appPackageJson | ||
* @returns {string | *} | ||
*/ | ||
const getPublicUrl = appPackageJson => envPublicUrl || require(appPackageJson).homepage; | ||
|
||
/** | ||
* | ||
* @param appPackageJson | ||
* @returns {*} | ||
*/ | ||
function getServedPath(appPackageJson) { | ||
const publicUrl = getPublicUrl(appPackageJson); | ||
const servedUrl = | ||
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); | ||
return ensureSlash(servedUrl, true); | ||
} | ||
|
||
const moduleFileExtensions = [ | ||
'web.mjs', | ||
'mjs', | ||
'web.js', | ||
'js', | ||
'web.ts', | ||
'ts', | ||
'web.tsx', | ||
'tsx', | ||
'json', | ||
'web.jsx', | ||
'jsx', | ||
]; | ||
|
||
/** | ||
* | ||
* @param resolveFn | ||
* @param filePath | ||
* @returns {*} | ||
*/ | ||
const resolveModule = (resolveFn, filePath) => { | ||
const extension = moduleFileExtensions.find(extension => fs.existsSync(resolveFn(`${filePath}.${extension}`))); | ||
|
||
if (extension) { | ||
return resolveFn(`${filePath}.${extension}`); | ||
} | ||
|
||
return resolveFn(`${filePath}.js`); | ||
}; | ||
|
||
module.exports = { | ||
dotenv: resolveApp('.env'), | ||
appPath: resolveApp('.'), | ||
appBuild: resolveApp('build'), | ||
appDist: resolveApp('dist'), | ||
appIndexJs: resolveModule(resolveApp, 'src/index'), | ||
appPackageJson: resolveApp('package.json'), | ||
appSrc: resolveApp('src'), | ||
testsSetup: resolveModule(resolveApp, 'src/setupTests'), | ||
appNodeModules: resolveApp('node_modules'), | ||
publicUrl: getPublicUrl(resolveApp('package.json')), | ||
servedPath: getServedPath(resolveApp('package.json')), | ||
}; | ||
|
||
module.exports.moduleFileExtensions = moduleFileExtensions; |
Oops, something went wrong.