-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
424 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sandboxes": [ | ||
"new", | ||
"react" | ||
], | ||
"node": "16" | ||
} |
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 +1,4 @@ | ||
node_modules | ||
dist | ||
.idea | ||
.build |
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,25 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script> | ||
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script> | ||
<style> | ||
body, html { min-height: 100vh; width: 100%; margin: 0; padding: 0; display: flex; } | ||
</style> | ||
<script src="../dist/index.umd.js"></script> | ||
|
||
<div id="viewer" style="position: relative; display: flex; flex: 1"></div> | ||
|
||
<script> | ||
const el = document.getElementById('viewer'); | ||
window.CodexViewer.create(el, { manifest: 'https://wellcomelibrary.org/iiif/b18035723/manifest' }) | ||
</script> | ||
|
||
</body> | ||
</html> |
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,67 @@ | ||
import react from '@vitejs/plugin-react'; | ||
import chalk from "chalk"; | ||
|
||
export const defaultExternal = [ | ||
'@iiif/vault', | ||
'@iiif/vault-helpers', | ||
'@iiif/parser', | ||
'redux', | ||
'typesafe-actions', | ||
'react', | ||
'react/jsx-runtime', | ||
'react-dom', | ||
'react-use', | ||
'react-use-measure', | ||
'@atlas-viewer/atlas', | ||
'@atlas-viewer/iiif-image-api', | ||
'react-iiif-vault', | ||
'@atlas-viewer/atlas', | ||
]; | ||
|
||
/** | ||
* @param options {{ external: string[]; entry: string; name: string; globalName: string; outDir?: string; react?: boolean; globals: Record<string, string>; react18?: boolean; watch?: boolean }} | ||
*/ | ||
export function defineConfig(options) { | ||
return { | ||
build: { | ||
sourcemap: true, | ||
outDir: options.outDir || `dist/${options.name}`, | ||
lib: { | ||
entry: options.entry, | ||
name: options.globalName, | ||
formats: options.globalName ? ['umd'] : ['es', 'cjs'], | ||
fileName: (format) => { | ||
if (format === 'umd') { | ||
return `index.umd.js`; | ||
} | ||
if (format === 'es') { | ||
return `esm/${options.name}.mjs`; | ||
} | ||
return `${format}/${options.name}.js`; | ||
}, | ||
}, | ||
watch: options.watch, | ||
plugins: [ | ||
options.react ? | ||
options.react18 ? | ||
react({ jsxRuntime: 'automatic', jsxPure: true, }) : | ||
react({ jsxRuntime: 'classic', jsxPure: true, }) | ||
: false, | ||
].filter(Boolean), | ||
rollupOptions: { | ||
treeshake: true, | ||
external: options.react18 ? | ||
[...options.external, 'react-dom/client'] | ||
: options.external, | ||
output: { | ||
globals: options.globals, | ||
inlineDynamicImports: !!options.globalName, | ||
}, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export function buildMsg(name) { | ||
console.log(chalk.grey(`\n\nBuilding ${chalk.blue(name)}\n`)); | ||
} |
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,58 @@ | ||
import { defineConfig } from './base-config.mjs'; | ||
import { build } from 'vite'; | ||
import chalk from 'chalk'; | ||
|
||
(async () => { | ||
|
||
const defaultExternal = [ | ||
'@iiif/vault', | ||
'@iiif/vault-helpers', | ||
'@iiif/parser', | ||
'redux', | ||
'typesafe-actions', | ||
'react', | ||
'react/jsx-runtime', | ||
'react-dom', | ||
'react-use', | ||
'react-use-measure', | ||
'@atlas-viewer/atlas', | ||
'@atlas-viewer/iiif-image-api', | ||
'react-iiif-vault', | ||
]; | ||
|
||
// Main UMD build. | ||
buildMsg('UMD'); | ||
await build( | ||
defineConfig({ | ||
entry: `src/npm.ts`, | ||
name: 'index', | ||
outDir: 'dist', | ||
globalName: 'CodexViewer', | ||
external: ['react', 'react-dom'], | ||
react: true, | ||
globals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
} | ||
}) | ||
); | ||
|
||
buildMsg('Libraries'); | ||
await build( | ||
defineConfig({ | ||
entry: `src/npm.ts`, | ||
name: 'index', | ||
outDir: 'dist/bundle', | ||
external: [...defaultExternal], | ||
react: true, | ||
react18: true, | ||
}) | ||
); | ||
|
||
function buildMsg(name) { | ||
console.log(chalk.grey(`\n\nBuilding ${chalk.blue(name)}\n`)); | ||
} | ||
function listItem(name) { | ||
console.log(chalk.gray(`- ${chalk.green(name)}`)); | ||
} | ||
})(); |
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,77 @@ | ||
import { promises as FS } from "node:fs"; | ||
import chalk from "chalk"; | ||
|
||
const pkgJson = await FS.readFile(`./package.json`); | ||
const pkg = JSON.parse(pkgJson.toString()); | ||
|
||
let _indent = 2; | ||
let _indentBy = 4; | ||
|
||
function logWithIndent(msg) { | ||
console.log(chalk.gray(`${new Array(_indent + 1).fill("").join(" ")}${msg}`)); | ||
} | ||
|
||
async function checkFile(file, description) { | ||
logWithIndent(`${description ? `"${chalk.cyanBright(description)}": ` : ''}${chalk.blue(`"${file}"`)} ${chalk.green(`✓`)} exists`); | ||
await FS.stat(file); | ||
} | ||
|
||
function indent() { | ||
_indent += _indentBy; | ||
} | ||
|
||
function dedent(arr = false) { | ||
_indent -= _indentBy; | ||
logWithIndent(arr ? ']' : '}'); | ||
} | ||
|
||
console.log(chalk.gray(` | ||
Validating ${chalk.blue(`package.json`)} | ||
`)) | ||
|
||
logWithIndent(`{`); | ||
|
||
await checkFile(pkg.main, "main"); | ||
await checkFile(pkg.module, "module"); | ||
await checkFile(pkg.types, "types"); | ||
|
||
const exportKeys = Object.keys(pkg.exports); | ||
logWithIndent(`"exports": {`); | ||
indent(); | ||
for (const exportKey of exportKeys) { | ||
if (typeof pkg.exports[exportKey] === "string") { | ||
await checkFile(pkg.exports[exportKey], exportKey); | ||
continue; | ||
} | ||
logWithIndent(`"${exportKey}": {`); | ||
const variations = Object.keys(pkg.exports[exportKey]); | ||
indent(); | ||
for (const variation of variations) { | ||
await checkFile(pkg.exports[exportKey][variation], variation); | ||
} | ||
dedent(); | ||
} | ||
dedent(); | ||
|
||
|
||
const typesVersionKeys = Object.keys(pkg.typesVersions); | ||
logWithIndent(`"typesVersions": {`); | ||
indent(); | ||
for (const typesVersionKey of typesVersionKeys) { | ||
const variations = Object.keys(pkg.typesVersions[typesVersionKey]); | ||
logWithIndent(`"${typesVersionKey}": {`); | ||
indent(); | ||
for (const variation of variations) { | ||
const listOfTypes = pkg.typesVersions[typesVersionKey][variation]; | ||
logWithIndent(`"${variation}": [`); | ||
indent(); | ||
for (const pathToTypescriptFile of listOfTypes) { | ||
await checkFile(pathToTypescriptFile); | ||
} | ||
dedent(true); | ||
} | ||
dedent(); | ||
} | ||
dedent(); | ||
|
||
console.log(chalk.greenBright(`\n\n ✓ package.json is valid`)); |
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,10 +1,13 @@ | ||
import { GettyViewer } from './GettyViewer'; | ||
import { CodexViewer } from './CodexViewer'; | ||
|
||
export function App() { | ||
// return ( | ||
// <GettyViewer manifest="https://digirati-co-uk.github.io/wunder.json" /> | ||
// <CodexViewer manifest="https://digirati-co-uk.github.io/wunder.json" /> | ||
// ); | ||
return ( | ||
<GettyViewer manifest="https://digirati-co-uk.github.io/florentine-data-exploration/iiif3/vol3.json" initCanvas={324} /> | ||
<CodexViewer | ||
manifest="https://digirati-co-uk.github.io/florentine-data-exploration/iiif3/vol3.json" | ||
initCanvas={324} | ||
/> | ||
); | ||
} |
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
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
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
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
Oops, something went wrong.