miniSphere 5.4.0
miniSphere 5.4.0 is the fifth release in the 5.0 series. This release brings support for the .cjs extension, adds a new strictImports development flag and brings a slew of bug fixes and other enhancements.
important note:
the .tar.gz tarball no longer includes ChakraCore binaries. to get these, first check if your distribution has a ChakraCore dev package available and install it if so; if not, then run sudo make deps from the miniSphere source directory to download the binaries from Microsoft and install them. you should only need to do this once.
What's New?
-
miniSphere and Cell now support the
.cjsfile extension introduced in Node.js v13.2.0. Scripts with this extension are always loaded as CommonJS modules, regardless of whetherrequire()orimportis used. This can be helpful if you need to load a CommonJS module using a relative path, since relativerequire()is not supported in ESM files. -
miniSphere 5.4 adds a new optional
strictImportsflag in thedevelopmentsection ofgame.json. This flag, when enabled, causes SpheRun to enforce that yourimportspecifiers are Oozaru-compatible--in particular, any imports referring to files in the project must include the file extension, such as.js. Like otherdevelopmentflags,strictImportshas no effect in production. -
DirectoryStreamnow includes additionaldepthandextensionproperties on result objects, making it easier to filter directory entries based on those criteria. Keep in mind that since the new properties are part of the experimental API level 3, they will be disabled in retrograde mode. -
Mouse#getEvent()no longer returnsnullin case of an empty queue. Instead it now returns an object whose.eventis set tonullin this case to facilitate safe destructuring of the return value. This might break code that specifically checked for a return value ofnull. The old behavior is being treated as a bug and the change may be backported if necessary, so any code that does this should be updated as soon as possible. -
Several
Querymethods were renamed to align with the corresponding LINQ names. This will inevitably break code that uses these methods; check the changelog for the full list. Note that the Sphere Runtime API is not yet frozen. -
Cell now supports using a directory name for
Tool#stage(). Directories are considered to be permanantly out-of-date, so Cell will always run a tool which claims to build one. This eases things for tools that dynamically determine their sources or create multiple output files, which would often be considered erroneously up-to-date because Cell didn't consider all the files involved. -
To improve sandboxing and ensure out-of-source builds always work correctly, starting with this version, Cell code can no longer write files and directories under
$/. This change might break builds that depend on$/being writable. -
Cell now tracks all files created using
FS.writeFile()as build artifacts. These files will be therefore now be deleted when runningcell clean, even if they have no correspondingTarget.
Full Changelog
- Adds several
Querymethods:apply,call,concat,elementAt,join,memoize,pull,single,skipLast,skipWhile,takeLast,takeWhile, andzip. - Adds
Mouse#positionwhich returns a tuple[x, y]for easy destructuring. - Adds mouse-button activation support to the
consolemodule. - Adds a new
FS.match()API for matching filenames and paths against "glob" patterns such as**/*.js, useful for filteringDirectoryStreamoutput. - Adds new
depthandextensionproperties toDirectoryStreamoutput to make filtering even easier. - Adds support for using a directory as the output of
Tool#stage()in Cell. - Adds support for the
.cjsfile extension to facilitate smoother interop between ESM and CommonJS code. - Adds a
strictImportsmanifest flag to enforce Oozaru-compatible imports. - Improves sandboxing by disabling write access to
$/in Cell code. - Improves Cell build hygiene by tracking files created with
FS.writeFile()as build artifacts and cleaning them as necessary. - Renames
Query#drop()toQuery#skip()for consistency with LINQ. - Renames
Query#reduce()toQuery#aggregate(). - Renames
Query#over()toQuery#selectMany(). - Renames
Query#uniq()toQuery#distinct(). - Fixes a bug where destructuring the return value of
Mouse#getEvent()can throw an error due to beingnull. - Fixes a bug where
Query#any()andQuery#all()can returnundefinedin certain cases instead of a boolean value. - Fixes a bug where
Query#count()can returnnullinstead of0. - Fixes a bug where
require()can't be used to load system modules likesphere-runtime. - Fixes a bug where Cell fails to properly normalize the pathname passed to
Tool#stage(), potentially leading to undesirable behavior later.