Make sw.js use LightningFS directly

This commit is contained in:
Alex Gleason committed 2025-07-18 19:08:15 -05:00
1 parent 9a9e0619fb
commit 9eb459e594
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>
) : (
-32
View File
@@ -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);
}