Add a cleanup override for HUDSettingsMenu that detaches its input
receiver in case it is attached (i.e. when using the menu buttons to
open settings or return to main menu).
Remove old Logger class and replace it with a new implementation that
keeps the location of the log calls (for display in devtools). Remove
internals of the old implementation and their one external usage.
Update electron package from 31.3.0 to 37.2.3, with Chromium 138 and
Node.js 22.17. Also follow the electron-packager -> @electron/packager
rename and upgrade the package.
* Handle directories in mod protocol handler
Previously we would return an error about a file not existing, which kinda makes sense, considering a directory isn't a file.
Now with this commit, if the url resolve to a directory, it will return a json array with the relative paths of the file in that directory.
* Make directory index work with ASAR archives
Also fix directory index having higher priority than normal requests and
simplify URL handling.
---------
Co-authored-by: Даниїл Григор'єв <dengr1065@gmail.com>
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.
Remove the behavior of automatically opening developer tools when
launched with --dev command line switch. As --hide-devtools switch is
now unused, remove it as well.
* Fix tsconfig scopes affecting html.js
Since it's quite hard to use a DOM library type there, remove the type
entirely.
* Remove environment variables check
Nothing is using them anymore. It can be added back if needed later.
* Refactor Texture Packer downloading
Refactor local-config.js tasks file into a generic "environment"
category consisting of checking if Java is installed, downloading the
runnable Texture Packer if it's not yet downloaded and copying the local
configuration template; update README accordingly.
* Prepare environment only at postinstall
Remove environment.prepare task from default build pipelines, add a
postinstall script that calls the task, using environment.js as the
gulpfile to speed it up.
* Remove "docs" tasks and types generation script
Remove tasks from docs.js as they are unlikely to do anything meaningful
nowadays. Also remove the buildTypes script as it doesn't work anymore.
A better solution will be provided in the future.
* Simplify some globs
Use additional gulp.src options instead of specifying more or complex
globs.
* Extract built-temp location to a variable
Add the src/js/built-temp directory as a new variable in config.js,
replace all existing references to built-temp with this variable.
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.
Add a --watch command line flag to be used in tandem with --load-mod.
Chokidar is used to detect file updates, and a page reload is triggered
when there are any changes to watched mod files. Only mods loaded via
--load-mod are affected.
This implementation has a minor issue with how cache is cleared -
removing disk cache is a bit too aggressive - but the only alternative I
could find is to use a non-persistent Electron session, which would get
rid of disk cache entirely (this is not a concern).
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.