hackmud-script-manager 0.21.1-d4bf990 → 0.21.1-e3e8246

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Hackmud Script Manager
2
+
2
3
  Command made for [Hackmud Scripting Environment](https://github.com/samualtnorman/hackmud-environment), which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
3
4
 
4
5
  Join [our Discord server](https://discord.gg/RSa4Sc6pNA)!
@@ -8,18 +9,22 @@ Join [our Discord server](https://discord.gg/RSa4Sc6pNA)!
8
9
  You can read about how HSM works [in my blog post](https://samual.uk/blog/js-code-transformation-niche-environment/).
9
10
 
10
11
  ## Install
12
+
11
13
  1. [Install Node.js](https://nodejs.org/en/download)
12
14
  2. Run `npm install -g hackmud-script-manager`
13
15
 
14
16
  ## Usage
17
+
15
18
  1. Run `#dir` in game, then `cd` to that folder
16
19
  2. Name your source script file to `<name>.src.js`
17
20
  3. Run `hsm minify <name>.src.js` and it will create a minified script file called `<name>.js`
18
21
 
19
22
  > **NOTE:** If you get an error message that looks like this:
23
+ >
20
24
  > ```
21
25
  > [...]\AppData\Local\pnpm\hsm.ps1 cannot be loaded because running scripts is disabled on this system. [...]
22
26
  > ```
27
+ >
23
28
  > You will need to run `Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser` in PowerShell as an administrator. For more information, see [Microsoft's page about Execution Policies](https://learn.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4).
24
29
 
25
30
  ![image](https://github.com/user-attachments/assets/cc97f8a6-82a4-4a66-9785-accc8d774285)
@@ -27,47 +32,48 @@ You can read about how HSM works [in my blog post](https://samual.uk/blog/js-cod
27
32
  ![image](https://github.com/user-attachments/assets/a59a6ec4-d268-40f7-8ce2-5fbdbcd40c19)
28
33
 
29
34
  ## Features
35
+
30
36
  - Minification
31
- - This includes auto quine cheating.
32
- - Supported types are null, numbers, strings, and JSON compatible objects and arrays.
33
- - Non JSON compatible object keys are quine cheated.
34
- - Member expressions are converted to index notation so the index string can be quine cheated.
35
- - And template literals are converted to string concatenation so the strings can be quine cheated.
36
- - Global variable aliasing.
37
- - Convert function declarations to arrow function assigned to variable hoisted to the top of the block (`function foo() { ... }` -> `let foo = () => ...`).
38
- - Convert `_START` and `_TIMEOUT` to `_ST` and `_TO`.
39
- - Remove unused parameters from the main function expression.
37
+ - This includes auto quine cheating.
38
+ - Supported types are null, numbers, strings, and JSON compatible objects and arrays.
39
+ - Non JSON compatible object keys are quine cheated.
40
+ - Member expressions are converted to index notation so the index string can be quine cheated.
41
+ - And template literals are converted to string concatenation so the strings can be quine cheated.
42
+ - Global variable aliasing.
43
+ - Convert function declarations to arrow function assigned to variable hoisted to the top of the block (`function foo() { ... }` -> `let foo = () => ...`).
44
+ - Convert `_START` and `_TIMEOUT` to `_ST` and `_TO`.
45
+ - Remove unused parameters from the main function expression.
40
46
  - Modern Javascript Syntax and Features
41
- - [Exponentiation Operator](https://babeljs.io/docs/en/babel-plugin-transform-exponentiation-operator), [Object Rest Spread](https://babeljs.io/docs/en/babel-plugin-proposal-object-rest-spread), [Optional Catch Binding](https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding), [JSON strings](https://babeljs.io/docs/en/babel-plugin-proposal-json-strings), [Nullish Coalescing Operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator), [Optional Chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining), [Logical Assignment Operators](https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators), [Numeric Seperators](https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator), [Class Properties](https://babeljs.io/docs/en/babel-plugin-proposal-class-properties), [Class Static Block](https://babeljs.io/docs/en/babel-plugin-proposal-class-static-block), [Private Property `in` Object](https://babeljs.io/docs/en/babel-plugin-proposal-private-property-in-object).
42
- - Bigint literals are converted to `BigInt()` calls.
43
- - Hackmud already supports all modern regular expression features.
47
+ - [Exponentiation Operator](https://babeljs.io/docs/en/babel-plugin-transform-exponentiation-operator), [Object Rest Spread](https://babeljs.io/docs/en/babel-plugin-proposal-object-rest-spread), [Optional Catch Binding](https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding), [JSON strings](https://babeljs.io/docs/en/babel-plugin-proposal-json-strings), [Nullish Coalescing Operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator), [Optional Chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining), [Logical Assignment Operators](https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators), [Numeric Seperators](https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator), [Class Properties](https://babeljs.io/docs/en/babel-plugin-proposal-class-properties), [Class Static Block](https://babeljs.io/docs/en/babel-plugin-proposal-class-static-block), [Private Property `in` Object](https://babeljs.io/docs/en/babel-plugin-proposal-private-property-in-object).
48
+ - Bigint literals are converted to `BigInt()` calls.
49
+ - Hackmud already supports all modern regular expression features.
44
50
  - Future JavaScript Syntax and Features
45
- - Warning: TypeScript doesn't support any of these features and these features may change or not actually make it into JavaScript.
46
- - [Decorators](https://babeljs.io/docs/en/babel-plugin-proposal-decorators), [Do Expressions](https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions), [Function Bind](https://babeljs.io/docs/en/babel-plugin-proposal-function-bind), [Function Sent](https://babeljs.io/docs/en/babel-plugin-proposal-function-sent), [Partial Application](https://babeljs.io/docs/en/babel-plugin-proposal-partial-application), [Pipeline Operator](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator) (using the hack proposal and `%` as the topic token), [Throw Expression](https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions), [Record and Tuple](https://babeljs.io/docs/en/babel-plugin-proposal-record-and-tuple) (hash `#` syntax type).
51
+ - Warning: TypeScript doesn't support any of these features and these features may change or not actually make it into JavaScript.
52
+ - [Decorators](https://babeljs.io/docs/en/babel-plugin-proposal-decorators), [Do Expressions](https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions), [Function Bind](https://babeljs.io/docs/en/babel-plugin-proposal-function-bind), [Function Sent](https://babeljs.io/docs/en/babel-plugin-proposal-function-sent), [Partial Application](https://babeljs.io/docs/en/babel-plugin-proposal-partial-application), [Pipeline Operator](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator) (using the hack proposal and `%` as the topic token), [Throw Expression](https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions), [Record and Tuple](https://babeljs.io/docs/en/babel-plugin-proposal-record-and-tuple) (hash `#` syntax type).
47
53
  - TypeScript Support
48
- - This command/module does **not** do type checking, it simply removes type annotations so you'll need to rely on your IDE or run `tsc` seperatly with `noEmit`.
54
+ - This command/module does **not** do type checking, it simply removes type annotations so you'll need to rely on your IDE or run `tsc` seperatly with `noEmit`.
49
55
  - And “Cool” Unnecessary Features.
50
- - Variables declared outside the main function expression automatically become `#G` global variables.
51
- - Any code outside the function expression will only run once per top level script execution (`#FMCL`).
52
- - Basic seclevel verification.
53
- - Declaring `// @seclevel HIGHSEC` or any other seclevel before all of your code stops you from accidentally using `#ls.` or `#ns.`.
54
- - Import `node_modules` modules into your script using `import { foo } from "bar"` syntax.
55
- - `_SOURCE` is replaced with a string of the source code of the script it's in.
56
- - `_BUILD_DATE` is replaced with a unix timestamp (`Date.now()`) of the build date of the script.
57
- - `_SCRIPT_USER` is replaced with a string of the user the script was pushed to.
58
- - This saves characters compared to `context.this_script.split(".")[0]`.
59
- - `_SCRIPT_SUBNAME` is like `_SCRIPT_USER` but for the name of the script.
60
- - Saves characters compared to `context.this_script.split(".")[1]`.
61
- - `_FULL_SCRIPT_NAME` is replaced with what would be in `context.this_script`.
62
- - Subscript and `#db` methods names are verified.
63
- - 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);`.
64
- - `_SECLEVEL` is replaced with a number (`0` to `4`) representing the seclevel of the script.
56
+ - Variables declared outside the main function expression automatically become `#G` global variables.
57
+ - Any code outside the function expression will only run once per top level script execution (`#FMCL`).
58
+ - Basic seclevel verification.
59
+ - Declaring `// @seclevel HIGHSEC` or any other seclevel before all of your code stops you from accidentally using `#ls.` or `#ns.`.
60
+ - Import `node_modules` modules into your script using `import { foo } from "bar"` syntax.
61
+ - `_SOURCE` is replaced with a string of the source code of the script it's in.
62
+ - `_BUILD_DATE` is replaced with a unix timestamp (`Date.now()`) of the build date of the script.
63
+ - `_SCRIPT_USER` is replaced with a string of the user the script was pushed to.
64
+ - This saves characters compared to `context.this_script.split(".")[0]`.
65
+ - `_SCRIPT_SUBNAME` is like `_SCRIPT_USER` but for the name of the script.
66
+ - Saves characters compared to `context.this_script.split(".")[1]`.
67
+ - `_FULL_SCRIPT_NAME` is replaced with what would be in `context.this_script`.
68
+ - Subscript and `#db` methods names are verified.
69
+ - 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);`.
70
+ - `_SECLEVEL` is replaced with a number (`0` to `4`) representing the seclevel of the script.
65
71
  - And Neat Weird Fixes
66
- - Like `.__proto__` and `.prototype` being converted to `["__proto__"]` and `["prototype"]`.
67
- - Illegal and unsafe strings.
68
- - Appearences of `_SC` and friends are either renamed or have an escape inserted so that script is legal.
69
- - Preprocessor syntax in strings are escaped so hackmud doesn't recognise them as preprocessor syntax.
70
- - 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.
71
- - Classes are actually usable now, this module replaces instances of `this` with a variable referencing what would be `this`.
72
- - `Function.prototype` can be referenced (but only the `.prototype` property, nothing else).
73
- - `Object.getPrototypeOf` and `Object.setPrototypeOf` are replaced with equivalent functions.
72
+ - Like `.__proto__` and `.prototype` being converted to `["__proto__"]` and `["prototype"]`.
73
+ - Illegal and unsafe strings.
74
+ - Appearences of `_SC` and friends are either renamed or have an escape inserted so that script is legal.
75
+ - Preprocessor syntax in strings are escaped so hackmud doesn't recognise them as preprocessor syntax.
76
+ - 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.
77
+ - Classes are actually usable now, this module replaces instances of `this` with a variable referencing what would be `this`.
78
+ - `Function.prototype` can be referenced (but only the `.prototype` property, nothing else).
79
+ - `Object.getPrototypeOf` and `Object.setPrototypeOf` are replaced with equivalent functions.