refactor: organize source web and tests by business module
This commit is contained in:
1 parent
9854d2d5c2
commit
2aed328774
113 files changed
+189
-183
No files matched your search
@@ -1,18 +0,0 @@
|
||||
'use strict';
|
||||
const path=require('node:path');
|
||||
// Public renderer assets only; managed files never pass through this resolver.
|
||||
const embedRoot=path.dirname(require.resolve('@embedpdf/snippet'));
|
||||
const photoRoot=path.dirname(require.resolve('photoswipe'));
|
||||
const fixed={
|
||||
'/vendor/docx/docx-preview.js':require.resolve('docx-preview'),
|
||||
'/vendor/jszip/jszip.min.js':require.resolve('jszip/dist/jszip.min.js'),
|
||||
'/vendor/exceljs/exceljs.min.js':require.resolve('exceljs/dist/exceljs.min.js')
|
||||
};
|
||||
function previewAsset(route){
|
||||
let file=fixed[route];
|
||||
const embed=/^\/vendor\/embedpdf\/([\w.-]+\.(?:js|wasm))$/.exec(route),photo=/^\/vendor\/photoswipe\/(photoswipe(?:-lightbox)?\.esm\.js|photoswipe\.css)$/.exec(route);
|
||||
if(embed)file=path.join(embedRoot,embed[1]);if(photo)file=path.join(photoRoot,photo[1]);if(!file)return null;
|
||||
return {path:file,type:file.endsWith('.wasm')?'application/wasm':file.endsWith('.css')?'text/css':'text/javascript',binary:file.endsWith('.wasm'),preview:true};
|
||||
}
|
||||
const PREVIEW_CSP="default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data: blob:; connect-src 'self' blob:; worker-src 'self' blob:; frame-ancestors 'self'; base-uri 'none'; form-action 'none'; object-src 'none'";
|
||||
module.exports={previewAsset,PREVIEW_CSP};
|
||||
Reference in new issue
Block a user