Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/low resolution images #658

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions apps/api-server/src/util/react-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ module.exports = `

function checkReactDom() {
if (!hasReactDom && !window.OpenStadReactDOMLoaded) {

console.log ('!hasReactDom && !window.OpenStadReactDOMLoaded');
if (window.OpenStadReactDOMIsLoading) {
console.log ('window.OpenStadReactDOMIsLoading');
document.addEventListener('OpenStadReactDomLoaded', renderWidget);
return;
}
Expand All @@ -35,6 +36,7 @@ module.exports = `

// Get same version of react-dom as react, ensuring we have a xx.x.x format
if (!/18\.\d{1,2}\.\d{1,2}/.test(reactVersion) === false) {
console.log('react version is not 18');
throw new Error('React version 18 is required');
}

Expand All @@ -48,20 +50,25 @@ module.exports = `
}
document.addEventListener('OpenStadReactDomLoaded', renderWidget);
triggerEvent('OpenStadReactDomLoaded');
console.log ('react dom on load');
}
document.body.appendChild(script);
window.OpenStadReactDOMLoaded = true;
} else if (
typeof ReactDOM !== 'undefined' &&
ReactDOM.version.substr(0, 2) !== '18'
) {
console.log ('react dom not version 18');
throw new Error('ReactDOM version 18 is required');
} else {
console.log ('react dom check else');
window.OpenStadReactDOMLoaded = true;

if (typeof window.OpenStadReactDomLoadedEventHasFired === 'undefined' || !window.OpenStadReactDomLoadedEventHasFired) {
console.log ('typeof window.OpenStadReactDomLoadedEventHasFired === undefined || !window.OpenStadReactDomLoadedEventHasFired');
document.addEventListener('OpenStadReactDomLoaded', renderWidget);
} else {
console.log ('else van typeof window.OpenStadReactDomLoadedEventHasFired === undefined || !window.OpenStadReactDomLoadedEventHasFired');
renderWidget();
}
}
Expand All @@ -71,6 +78,7 @@ module.exports = `
const hasReactWithScheduler = hasReact && typeof React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED !== 'undefined' && typeof React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler !== 'undefined' && typeof React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_scheduleCallback !== 'undefined';
const hasReactDom = typeof ReactDOM !== 'undefined';


if ( hasReact && hasReactWithScheduler && hasReactDom ) {
renderWidget();
} else if (!hasReact && !window.OpenStadReactLoaded) {
Expand All @@ -84,22 +92,30 @@ module.exports = `
document.body.appendChild(script);
window.OpenStadReactLoaded = true;
} else if (hasReact && React.version.substr(0, 2) < '18') {
console.log ('react version is not 18');
throw new Error('React version 18 is required');
} else if (hasReact && !hasReactWithScheduler && !window.OpenStadReactLoaded) {
console.log ('hasReact && !hasReactWithScheduler && !window.OpenStadReactLoaded');
console.log ('Loading React 18.3.1 UMD version -- current version is without Scheduler which means React DOM won\\'t load correctly.');

const script = document.createElement('script');
script.src = '${reactJs}';
script.onload = (e) => {
console.log ('react js onload');
checkReactDom();
}

document.body.appendChild(script);
window.OpenStadReactLoaded = true;
} else {
console.log ('react check else');
if (typeof window.OpenStadReactDomLoadedEventHasFired === 'undefined' || !window.OpenStadReactDomLoadedEventHasFired) {
console.log ('typeof window.OpenStadReactDomLoadedEventHasFired === undefined || !window.OpenStadReactDomLoadedEventHasFired');
// React has been loaded by a previous component on the page, render the widget when ReactDOM is loaded
checkReactDom();
} else {
console.log ('else van typeof window.OpenStadReactDomLoadedEventHasFired === undefined || !window.OpenStadReactDomLoadedEventHasFired');
renderWidget();
}
}
`;
`;
35 changes: 26 additions & 9 deletions apps/image-server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const imageMulterConfig = {
}

cb(null, true);
},
limits: {
fileSize: 20 * 1024 * 1024, // 20MB max file size
}
}

Expand Down Expand Up @@ -47,6 +50,11 @@ const imageSteamConfig = {
"cacheArtifacts": process.env.CACHE_ARTIFACTS || true
},
},
"imageLimits": {
"maxInputPixels": 100000000,
"maxWidth": 10000,
"maxHeight": 10000
},
"throttle": {
"ccProcessors": process.env.THROTTLE_CC_PROCESSORS || 4,
"ccPrefetchers": process.env.THROTTLE_CC_PREFETCHER || 20,
Expand All @@ -55,18 +63,27 @@ const imageSteamConfig = {
log: {
errors: true
},
router: {
originalSteps: {
metadata: {
enabled: 'false',
},
"router": {
"originalSteps": {
"resize": {
"width": "10000",
"height": "10000",
"max": "true",
"canGrow": "true"
}
},
hqOriginalSteps: {
metadata: {
enabled: 'false',
},
"hqOriginalSteps": {
"resize": {
"width": "10000",
"height": "10000",
"max": "true",
"canGrow": "true"
}
},
},
processor: {
maxSize: { width: 10000, height: 10000 },
}
};

imageMulterConfig.dest = process.env.IMAGES_DIR || 'images/';
Expand Down
Loading