Step 5 moves WebPad++ toward a safer deployment model:
- Try local files in
libs/orlibs/vendor/first. - If a local file is missing or fails to load, fall back to the existing free CDN URL.
- Keep very large optional assets, especially OCR language data, explicit instead of silently bundling them.
This keeps normal online use working while giving release builds a clear path to offline support.
The dependency manager now supports localUrls, localStyles, urls, and styles.
Example:
window.defineDependency('qrcodejs', {
label: 'QR Code 產生器',
localUrls: ['libs/vendor/qrcode.min.js'],
urls: [
'https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js',
'https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js'
],
check: () => typeof window.QRCode === 'function'
});The app tries libs/vendor/qrcode.min.js first. If that file is not present, the browser falls back to CDN.
Several scripts that were previously CDN-only now use local-first script tags:
- extra CodeMirror modes: PHP, SQL, Rust, Go
- SQL hint, search, jump-to-line
- JSHint, CSSLint, HTMLHint
- JSZip
- i18next HTTP backend
- Turndown
Direct external startup scripts are intentionally limited to:
- Google Analytics, if kept enabled
- Tailwind CDN, because this project currently uses Tailwind's browser JIT runtime
This means a default online build is not the same as an offline or fully isolated build. See PRIVACY_AND_LIMITATIONS.md for the privacy boundary and RELEASE_CHECKLIST.md for offline release requirements.
The list of local vendor files is stored in:
scripts/vendor-dependencies.jsonDownload the free vendor assets:
npm run vendor:fetchAudit local-first configuration:
npm run vendor:auditFor an offline/release build, require all local vendor files:
npm run vendor:audit:strictTesseract.js itself is now local-first. The OCR language data is different: Chinese tessdata_best files can be large, so this project does not silently bundle them.
Default OCR language paths still use the free Project Naptha tessdata CDN:
https://tessdata.projectnaptha.com/4.0.0https://tessdata.projectnaptha.com/4.0.0_besthttps://tessdata.projectnaptha.com/4.0.0_fast
For a fully offline OCR build, download the needed .traineddata.gz files and override the paths before OCR starts:
<script>
window.WEBCODING_TESSDATA_PATHS = {
standard: 'libs/tessdata/standard',
best: 'libs/tessdata/best',
fast: 'libs/tessdata/fast'
};
</script>Only do this after the corresponding local language files exist; otherwise OCR will fail while loading language data.
When adding a new dependency:
- Add a local path in
libs/vendor/or the appropriatelibs/subfolder. - Add the CDN fallback URL.
- Add the dependency to
scripts/vendor-dependencies.json. - Add a
checkfunction to verify the global object really exists. - Run
npm testandnpm run vendor:audit.