mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Make sw.js use LightningFS directly
This commit is contained in:
3 files changed
+9
-85
No files matched your search
@@ -135,7 +135,6 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
srcDoc={previewHtml}
|
||||
className="w-full flex-1 border-0"
|
||||
title="Project Preview"
|
||||
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-modals"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@@ -15,38 +15,6 @@ if ('serviceWorker' in navigator) {
|
||||
try {
|
||||
const registration = await navigator.serviceWorker.register('/sw.js');
|
||||
console.log('SW registered: ', registration);
|
||||
|
||||
// Set up message handler for file requests from service worker
|
||||
navigator.serviceWorker.addEventListener('message', async (event) => {
|
||||
if (event.data.type === 'FILE_REQUEST') {
|
||||
const { messageId, projectId, filePath } = event.data;
|
||||
|
||||
try {
|
||||
// Dynamically import fsManager to avoid circular dependencies
|
||||
const { fsManager } = await import('./lib/fs');
|
||||
const content = await fsManager.readFile(projectId, filePath);
|
||||
|
||||
// Send response back to service worker
|
||||
if (navigator.serviceWorker.controller) {
|
||||
navigator.serviceWorker.controller.postMessage({
|
||||
type: 'FILE_RESPONSE',
|
||||
messageId,
|
||||
content
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to read file for service worker:', error);
|
||||
// Send null response to indicate file not found
|
||||
if (navigator.serviceWorker.controller) {
|
||||
navigator.serviceWorker.controller.postMessage({
|
||||
type: 'FILE_RESPONSE',
|
||||
messageId,
|
||||
content: null
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (registrationError) {
|
||||
console.log('SW registration failed: ', registrationError);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user