Update some webpack dependencies and remove unused ones. Replace
worker-loader with built-in worker loading functionality and remove
default/implied options from the webpack configuration files.
Remove try/catch wrappers that just log and/or rethrow the error, use
the cause chain for rethrows with descriptions. Remove inner try/catch
for mod loading to make errors more obvious.
shapez used to have a nice error handler, but later it was removed. To
help debug game in both development and release cases, add a simple
error handler/screen that displays the error stack trace, lists the
installed mods and shows some build information. It also allows copying
this information to the system clipboard.
Having such an error screen should make mod development easier once the
local mod error handling is removed.
Replace all instances of D() and S() mixins with rem units. Also,
replace deprecated slash division with math.div as suggested by
dart-sass. Finally, remove the mixins as they are no longer used.
Replace --ui-scale inline style on the <html> element with font-size set
to UI scale * 10px and modify SCSS D(...) mixin to use the rem unit
instead of multiplying by var(--ui-scale). This makes it possible to get
rid of mixin hell and makes following UI scale in external stylesheets
(mods) much easier.
Remove some unused classes, mixins and variables, then inline ones that
have just a few usages. Also remove a few redundant properties and
replace align-items: center + justify-items: center with place-items:
center.
Remove lastCanvas/lastContext cache for reusing canvas as creating a new
canvas does not cause performance issue. Additionaly, remove smoothing
classes and buffer registration as they are not used anywhere. Finally,
remove redundant stageDestroyed calls in the InGameState.
Remove globalConfig properties that are not used anywhere, simplify
mobile device detection (mostly unused for normal builds) and merge or
inline config constants where it makes sense.
These files do not describe existing JS types and instead define their
own. Usage of .d.ts extension prevents these types from being emitted
when using emitDeclarationOnly, which affects generation of typings for
mod development.
Not a performance improvement, just something that needed to be done.
Slightly simplifies the structure and removes useless functions
(changing the seed resets the RNG anyway - it is better to create a new
instance instead).
Don't set the non-existent "opaque", "webkitOpaque" and "mozOpaque"
properties on a canvas. Keep using { alpha: false } when initializing
the context, which is the correct way.
Change most, but not all usages. This is mostly to please the linter,
but Object.hasOwn is also slightly shorter, especially when compared to
the proper form, Object.prototype.hasOwnProperty...
Make updateApplicationLanguage load translations asynchronously as
separate chunks in a slightly hacky way. Also implement a workaround for
old translation overrides registry ModInterface API.
Remove things that no longer exist or are covered by built-in TypeScript
libraries. Also switch to webpack-provided types instead of defining
them manually.
Remove polyfill functions for Element, CharacterData and DocumentType
classes, as these methods are all Baseline Widely Available. Also get
rid of redundant IIFE for the Math "polyfills".
This is not a big optimization but an optimization nonetheless. Mostly
based on awesome work by @Xiving. Further work should be done to get
most out of these changes.
While the browser engine can clean up workers automatically, it's a good
idea to terminate them as soon as we don't need those anymore. It's
generally suggested to reuse a single worker for repetitive operations,
but implementing such a system is much harder. In addition, spawning a
new worker for each operation allows (de)compressing multiple blobs in
parallel :)
Implement DefaultCompression class along with a generic interface to
facilitate easy to use compression in a background thread, and make use
of this class in Storage implementation by default.
Does not fix the savegame list bugs. Note that savegame index
serialization happens a few times for some reason, this is out of scope
for this commit though.
Keep track of the storage ID in each renderer Storage instance and pass
it to the IPC bridge. Jobs are dispatched to the relevant handler (only
saves/ for now) and all (de)compression is handled there.
Add dedicated fs-job types to read or write and (de)compress data
from/to the file picked by the user. Remove redundant utility functions
that used web APIs instead.
Make it slightly easier to replace the storage interface used for
app_settings.bin and savegames.bin in case it's ever needed. Savegames
always use app.storage for now, but this should be easier to change as
well.
Also fix a few issues in Electron code. This is not as polished yet, UI
from old mod support was reused for now and is likely broken. Mods can
be loaded, but there isn't much QoL around the support for now.
The linkApp method is removed as it was unused. A getter is used to
ensure best development experience. It can be further improved by adding
a guard for cases where GLOBAL_APP is not set yet.