JSPM

hackmud-script-manager

0.17.0-43cb5e3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 26
  • Score
    100M100P100Q75252F
  • License GPL-3.0-or-later

Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.

Package Exports

  • hackmud-script-manager
  • hackmud-script-manager/bin/hsm
  • hackmud-script-manager/generateTypeDeclaration
  • hackmud-script-manager/index
  • hackmud-script-manager/processScript
  • hackmud-script-manager/processScript/index
  • hackmud-script-manager/processScript/minify
  • hackmud-script-manager/processScript/postprocess
  • hackmud-script-manager/processScript/preprocess
  • hackmud-script-manager/processScript/shared
  • hackmud-script-manager/processScript/transform
  • hackmud-script-manager/pull
  • hackmud-script-manager/push
  • hackmud-script-manager/syncMacros
  • hackmud-script-manager/watch

Readme

Hackmud Script Manager

Test

Command made for hackmud-environment, which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.

Install with npm install hackmud-script-manager -g to make the hsm command available everywhere.

Features

  • 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.
    • converting function foo() { ... } format to let foo = () => ... format.
    • converting references to _START and _TIMEOUT to _ST and _TO.
    • removing unused parameters from main function expression.
  • Modern Javascript Syntax and Features
  • Future JavaScript Syntax and Features
  • TypeScript Support
    • This command/module doesn't actually do any type checking so you'll need to run tsc seperatly with noEmit.
  • And “Cool” Unnecessary Features.
    • Variables declared outside the main function expression automatically become #G global variables.
    • Any code outside the function expression will only run once per top level script execution (#FMCL).
    • Basic seclevel verification.
      • Declaring // @seclevel HIGHSEC or any other seclevel stops you from accidentally using #ls. or #ns..
    • Importing modules into your script.
    • _SOURCE is replaced with string of source code of the script it's in.
    • _BUILD_DATE is replaced with a unix timestamp (Date.now()) of the build date of the script.
    • _SCRIPT_USER is replaced with a string of the user the script was pushed to.
      • This saves characters compared to context.this_script.split(".")[0].
    • _SCRIPT_NAME is like _SCRIPT_USER but the name of the script.
      • Saves characters compared to context.this_script.split(".")[1].
    • _FULL_SCRIPT_NAME is replaced with what would be context.this_script but saves characters.
    • #s. can be used and it'll automatically have the seclevel inserted.
    • Subscript names and db methods 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);.
    • _SECLEVEL is replaced with a number (0 to 4) representing the seclevel of the script.
    • when exports are present in the script, it becomes a script that returns an object of the exported values.
      • _EXPORTS becomes an array of the names of the exported values.
  • And Other Weird Fixes
    • Like .__proto__ and .prototype are converted to ["__proto__"] and ["prototype"].
    • Illegal and unsafe strings.
      • Appearences of _SC and 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 remove from removing half the line of code.
    • Classes are actually usable now, this module replaces instances of this to a variable referencing what would be this.
    • Function.prototype can be referenced (but only the .prototype property, nothing else).
    • Object.getPrototypeOf and Object.setPrototypeOf are replaced with equivalent functions.