java frontend (#5097)

# Description of Changes

<!--
Please provide a summary of the changes, including:

- What was changed
- Why the change was made
- Any challenges encountered

Closes #(issue_number)
-->

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.

---------

Co-authored-by: Reece <[email protected]>
Co-authored-by: Reece Browne <[email protected]>
This commit is contained in:
Anthony Stirling
2025-12-02 17:15:29 +00:00
committed by GitHub
co-authored by Reece Reece Browne
parent c3456adc2b
commit c2a63cf425
16 changed files with 483 additions and 34 deletions
+20 -3
View File
@@ -1,7 +1,24 @@
// Base path from Vite config - build-time constant, normalized (no trailing slash)
// When no subpath, use empty string instead of '.' to avoid relative path issues
export const BASE_PATH = (import.meta.env.BASE_URL || '/').replace(/\/$/, '').replace(/^\.$/, '');
// Base path - read from <base> tag at runtime to support dynamic subpaths
// Falls back to Vite's BASE_URL for build-time subpaths
// Normalized: no trailing slash, empty string instead of '.' or '/'
function getBasePath(): string {
// Try to read from <base> tag first (runtime subpath support)
if (typeof document !== 'undefined') {
const baseElement = document.querySelector('base');
if (baseElement) {
const href = baseElement.getAttribute('href');
if (href && href !== '%BASE_URL%') {
return href.replace(/\/$/, '').replace(/^\.$/, '').replace(/^\/$/, '');
}
}
}
// Fall back to Vite's BASE_URL (build-time subpath)
return (import.meta.env.BASE_URL || '/').replace(/\/$/, '').replace(/^\.$/, '').replace(/^\/$/, '');
}
export const BASE_PATH = getBasePath();
// EmbedPDF needs time to remove annotations internally before a recreation runs.
// Without the buffer we occasionally end up with duplicate annotations or stale image data.