Command made for Hackmud Scripting Environment, which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
Join our Discord server!
You can read about how HSM works in my blog post.
- Install Node.js
- Run npm install -g hackmud-script-manager
- Run #dirin game, thencdto that folder
- Name your source script file to <name>.src.js
- Run hsm minify <name>.src.jsand it will create a minified script file called<name>.js
NOTE: If you get an error message that looks like this:
[...]\AppData\Local\pnpm\hsm.ps1 cannot be loaded because running scripts is disabled on this system. [...]You will need to run
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUserin PowerShell as an administrator. For more information, see Microsoft's page about Execution Policies.
- Minification
- This includes auto quine cheating.
- Supported types are null, numbers, strings, and JSON compatible objects and arrays.
- Non JSON compatible object keys are quine cheated.
- Member expressions are converted to index notation so the index string can be quine cheated.
- And template literals are converted to string concatenation so the strings can be quine cheated.
 
- Global variable aliasing.
- Convert function declarations to arrow function assigned to variable hoisted to the top of the block (function foo() { ... }->let foo = () => ...).
- Convert _STARTand_TIMEOUTto_STand_TO.
- Remove unused parameters from the main function expression.
 
- This includes auto quine cheating.
- Modern Javascript Syntax and Features
- Exponentiation Operator, Object Rest Spread, Optional Catch Binding, JSON strings, Nullish Coalescing Operator, Optional Chaining, Logical Assignment Operators, Numeric Seperators, Class Properties, Class Static Block, Private Property inObject.
- Bigint literals are converted to BigInt()calls.
- Hackmud already supports all modern regular expression features.
 
- Exponentiation Operator, Object Rest Spread, Optional Catch Binding, JSON strings, Nullish Coalescing Operator, Optional Chaining, Logical Assignment Operators, Numeric Seperators, Class Properties, Class Static Block, Private Property 
- Future JavaScript Syntax and Features
- Warning: TypeScript doesn't support any of these features and these features may change or not actually make it into JavaScript.
- Decorators, Do Expressions, Function Bind, Function Sent, Partial Application, Pipeline Operator (using the hack proposal and %as the topic token), Throw Expression, Record and Tuple (hash#syntax type).
 
- TypeScript Support
- This command/module does not do type checking, it simply removes type annotations so you'll need to rely on your IDE or run tscseperatly withnoEmit.
 
- This command/module does not do type checking, it simply removes type annotations so you'll need to rely on your IDE or run 
- And “Cool” Unnecessary Features.
- Variables declared outside the main function expression automatically become #Gglobal variables.
- Any code outside the function expression will only run once per top level script execution (#FMCL).
- Basic seclevel verification.
- Declaring // @seclevel HIGHSECor any other seclevel before all of your code stops you from accidentally using#ls.or#ns..
 
- Declaring 
- Import node_modulesmodules into your script usingimport { foo } from "bar"syntax.
- _SOURCEis replaced with a string of the source code of the script it's in.
- _BUILD_DATEis replaced with a unix timestamp (- Date.now()) of the build date of the script.
- _SCRIPT_USERis replaced with a string of the user the script was pushed to.- This saves characters compared to context.this_script.split(".")[0].
 
- This saves characters compared to 
- _SCRIPT_SUBNAMEis like- _SCRIPT_USERbut for the name of the script.- Saves characters compared to context.this_script.split(".")[1].
 
- Saves characters compared to 
- _FULL_SCRIPT_NAMEis replaced with what would be in- context.this_script.
- Subscript and #dbmethods names are verified.
- All references to preprocessor syntax functions not being called are turned into arrow function wrappers e.g. let debug = #D;->let debug = v => #D(v);.
- _SECLEVELis replaced with a number (- 0to- 4) representing the seclevel of the script.
 
- Variables declared outside the main function expression automatically become 
- And Neat Weird Fixes
- Like .__proto__and.prototypebeing converted to["__proto__"]and["prototype"].
- Illegal and unsafe strings.
- Appearences of _SCand friends are either renamed or have an escape inserted so that script is legal.
- Preprocessor syntax in strings are escaped so hackmud doesn't recognise them as preprocessor syntax.
- And appearences of //in strings and regexes have a backslash inserted between to stop hackmud's overagressive comment remover from removing half the line of code.
 
- Appearences of 
- Classes are actually usable now, this module replaces instances of thiswith a variable referencing what would bethis.
- Function.prototypecan be referenced (but only the- .prototypeproperty, nothing else).
- Object.getPrototypeOfand- Object.setPrototypeOfare replaced with equivalent functions.
 
- Like 


