Repository navigation
Conversation
Extract the JSON parsing and projection store hydration logic into a reusable helper function to eliminate code duplication across the file and ZIP import workflows. Previously, the logic for evaluating `settings.json` files and iterating through projection payloads was fully duplicated between the standalone JSON file processor and the ZIP archive extraction loop. - Extract the core parsing logic to `tryAddProjectionFromJson`. - Unify the application store additions and socket event emissions. - Reduce maintenance overhead by centralizing import logic.
Extract the duplicate toast notification and console error logging routines into a unified local helper function. This simplifies the error-handling blocks within the file import loop and improves code maintainability. Previously, both failed network responses and catch blocks explicitly duplicated calls to `toast.error` and `console.error` with localized string variables. - Create a local `showToastError` utility function. - Replace inline toast and console error sequences with the helper.
…entries loop Consolidate MIME type resolution during the asset import process to eliminate duplicate execution paths and inline boilerplate. Previously, the file extension checks relied on manual, brittle `endsWith` structures and unsafe regular expressions that fallback to generating invalid image MIME types for unknown extensions. This change introduces a dedicated `MIME_MAP` dictionary and a `getMime` helper function to safely evaluate file extensions in a clean, maintainable manner. Additionally, cached `Object.entries(unzipped)` iterations avoid unnecessary structural recalculations on the unzipped object across multiple loops. - Add `MIME_MAP` lookups supporting video, svg, and common image formats. - Implement fallback defaults to `application/octet-stream` safely. - Cache zip file entry extraction to prevent repeated descriptor processing. - Remove redundant `response.ok` constraint checks when scanning headers. - Simplify error handling via ternary variable declarations.
…ync unzip Optimize the UI performance during .zip file processing by transitioning from the blocking, synchronous `unzipSync` function to the asynchronous, non-blocking `unzip` API provided by `fflate`. Previously, extracting large projection archives containing multiple image or video assets completely locked up the browser's main execution thread, preventing the UI from rendering updates or maintaining smooth frame rates. Moving to an async Promise wrapper allows decompression work to happen off-thread. Additionally, the iteration model has been streamlined into a single pass over the unzipped object entries instead of running two separate full-array loops sequentially for assets and JSON manifests. - Replace synchronous browser-blocking `unzipSync` with asynchronous `unzip`. - Consolidate dual asset/JSON processing passes into a unified single-loop architecture. - Skip processing early for empty entries to reduce unneeded object allocations.
Fixes an issue where items grouped visually in the queue had disjointed, non-sequential underlying indices (e.g., jumping from 1 to X). This misalignment caused unexpected downstream behavior because the physical array sequence did not correspond to the rendered neighbor positions. Sorting the master's contents chronologically during the import phase by the first appearance of each group ensures that the underlying array indices accurately reflect their visual sequence in the queue control. - Centralize group name fallback parsing using the new `groupName` utility. - Implement `sortMasterContents` to order imported items by group timeline. - Standardize formatting and indentation for errors in the import processor.
Refactor file importing by removing explicit directory checks and creation logic. Since `Bun.write` automatically creates missing parent directories recursively when writing files, handling this manually is redundant. This optimization simplifies the file-writing pipeline and reduces unnecessary synchronous filesystem checks before writing incoming assets. - Remove unused `mkdirSync` and `dirname` imports from `fs` and `path`. - Delete synchronous directory checks and manual directory creation.
Transition server persistence from blocking, synchronous Node.js `fs` methods to asynchronous, native Bun file operations. This prevents event loop blockages during I/O and improves concurrency. File writes are now atomic; data is saved to a temporary file before overwriting the target destination, preventing file corruption. The build configuration and `tsconfig` are updated to support ESM and top-level await. - Replace `fs.readFileSync` and `fs.writeFileSync` with `Bun.file`/`Bun.write`. - Implement atomic file updates using `fs/promises` `rename`. - Update server socket listeners to await persistence utilities. - Target `ESNext` and enable Bun types to leverage top-level await.
Introduce a loading toast notification during the file import process to improve user experience. Previously, importing files provided no visual feedback, leaving users unaware of the background execution progress and making the application appear unresponsive. By initializing a loading toast at the start of processing and dismissing it upon completion, users now receive clear indicators of the ongoing activity. - Create a persistent loading toast before iterating through files. - Dismiss the toast notification immediately prior to calling the success callback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This pull request optimizes the file import workflow and upgrades the server persistence layer to leverage asynchronous operations. It improves user feedback with a loading toast, offloads ZIP decompression to prevent UI blocking, and refactors filesystem interactions for better efficiency.
Key Changes
🚀 Features
🐛 Bug Fixes
groupNameutility and implementsortMasterContents.🧹 Chore/Refactoring
fsmethods to asynchronous, native Bun file operations to improve concurrency and prevent event loop blockages.tsconfigto support ESM, top-level await, and Bun types.Bun.writeto automatically create missing parent directories recursively, simplifying the pipeline and reducing synchronous filesystem checks..zipfile processing by transitioning from the blockingunzipSyncfunction to the asynchronous, non-blockingunzipAPI provided byfflate.MIME_MAPdictionary and agetMimehelper function to safely evaluate file extensions.Version Bump
0.1.0