hackmud-script-manager-ng 0.26.5 → 0.26.7

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.
Files changed (70) hide show
  1. package/bin/hsm.d.ts +2 -0
  2. package/bin/hsm.js +493 -0
  3. package/constants.d.ts +2 -0
  4. package/constants.js +3 -0
  5. package/env.d.ts +10 -0
  6. package/generateTypeDeclaration.d.ts +1 -0
  7. package/generateTypeDeclaration.js +70 -0
  8. package/index.d.ts +16 -0
  9. package/index.js +52 -0
  10. package/package.json +3 -22
  11. package/processScript/index.d.ts +34 -0
  12. package/processScript/index.js +362 -0
  13. package/processScript/minify.d.ts +20 -0
  14. package/processScript/minify.js +431 -0
  15. package/processScript/postprocess.d.ts +1 -0
  16. package/processScript/postprocess.js +21 -0
  17. package/processScript/preprocess.d.ts +11 -0
  18. package/processScript/preprocess.js +107 -0
  19. package/processScript/shared.d.ts +5 -0
  20. package/processScript/shared.js +32 -0
  21. package/processScript/transform.d.ts +24 -0
  22. package/processScript/transform.js +803 -0
  23. package/pull.d.ts +7 -0
  24. package/pull.js +11 -0
  25. package/push.d.ts +42 -0
  26. package/push.js +164 -0
  27. package/syncMacros.d.ts +4 -0
  28. package/syncMacros.js +42 -0
  29. package/watch.d.ts +19 -0
  30. package/watch.js +220 -0
  31. package/.envrc +0 -1
  32. package/.github/FUNDING.yml +0 -14
  33. package/.github/workflows/publish.yml +0 -27
  34. package/.github/workflows/test.yml +0 -18
  35. package/.vscode/settings.json +0 -55
  36. package/CONTRIBUTING.md +0 -68
  37. package/eslint.config.js +0 -81
  38. package/game-scripts-tests/array-rest-works.ts +0 -6
  39. package/game-scripts-tests/this_array_in_object.ts +0 -16
  40. package/game-scripts-tests/this_function_array.ts +0 -9
  41. package/game-scripts-tests/this_in_default_argument.ts +0 -35
  42. package/game-scripts-tests/this_in_lambda_in_object.ts +0 -26
  43. package/pnpm-workspace.yaml +0 -2
  44. package/rollup.config.js +0 -69
  45. package/scripts/dev.sh +0 -3
  46. package/scripts/emit-declarations.sh +0 -3
  47. package/scripts/emit-package-json.js +0 -9
  48. package/scripts/lint.sh +0 -5
  49. package/scripts/package.sh +0 -7
  50. package/scripts/update.sh +0 -4
  51. package/scripts/version-dev.js +0 -14
  52. package/src/bin/hsm.ts +0 -754
  53. package/src/constants.ts +0 -2
  54. package/src/env.d.ts +0 -13
  55. package/src/generateTypeDeclaration.ts +0 -119
  56. package/src/index.ts +0 -13
  57. package/src/processScript/__snapshots__/index.ts.snap +0 -8
  58. package/src/processScript/index.ts +0 -474
  59. package/src/processScript/minify.ts +0 -594
  60. package/src/processScript/postprocess.ts +0 -19
  61. package/src/processScript/preprocess.ts +0 -130
  62. package/src/processScript/shared.ts +0 -33
  63. package/src/processScript/transform.ts +0 -978
  64. package/src/pull.ts +0 -20
  65. package/src/push.ts +0 -200
  66. package/src/syncMacros.ts +0 -53
  67. package/src/tsconfig.json +0 -14
  68. package/src/watch.ts +0 -258
  69. package/tsconfig.json +0 -23
  70. package/vitest.config.ts +0 -19
package/CONTRIBUTING.md DELETED
@@ -1,68 +0,0 @@
1
- # Contributing Guide
2
-
3
- If you get stuck, message me on discord `@samualn`.
4
-
5
- ## Requirements
6
-
7
- - [Git](https://git-scm.com/)
8
- - **Windows:** Make sure you install Git Bash with it
9
- - [Clone this repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
10
- - [PNPM](https://pnpm.io/)
11
- - **Optional:** [`direnv`](https://direnv.net/)
12
-
13
- ## Linux Users
14
-
15
- 1. Open this cloned repository in a terminal
16
- 2. Run `pnpm install`
17
- 3. Modify your `PATH`
18
- - If you have `direnv`, run `direnv allow` if you havn't already
19
- - Otherwise run `export PATH=$PWD/node_modules/.bin:$PATH`
20
- 4. Run `scripts/package.sh` to compile everything and build the NPM package in `dist`
21
-
22
- ## Windows Users
23
-
24
- 1. Open this cloned repository in Git Bash
25
- 2. Run `pnpm install`
26
- 3. Run `export PATH=$PWD/node_modules/.bin:$PATH`
27
- 4. Run `scripts/package.sh` to compile everything and build the NPM package in `dist`
28
-
29
- ## Tips and Tricks
30
-
31
- Run `./rollup.config.js` to only recompile.
32
-
33
- ### Run the Development Version of HSM
34
-
35
- You can run the development version of HSM by running `node dist/bin/hsm.js`. You can pass it arguments just like you normally would e.g. `node dist/bin/hsm.js --version`.
36
-
37
- ### Install the Development Version of the NPM Package in Another Project
38
-
39
- In the other project (e.g. testing with Hackmud Scripting Environment) run `pnpm add ~/path/to/hackmud-script-manager/dist`.
40
-
41
- ## Tests
42
-
43
- Tests can be run by running `vitest run` (assuming you have followed above setup instructions).
44
-
45
- There is currently not enforcement on writing unit tests but if you are going to, the test you write MUST be failing.
46
- You CANNOT add passing tests. If you are also writing a fix for a new test, ensure that the fix is in a seperate commit
47
- AFTER the commit the test is added in. This ensures that someone else can checkout the commit with the newly added test
48
- and verify that it is failing, checkout the commit where the fix is implemented, and verify that the test is now
49
- passing.
50
-
51
- The files in the `game-scripts-test/` folder are the input for testing `processScript()`. They are read by the vitest
52
- block at the bottom of `src/processScript/index.ts` where they are transformed and evaluated. Support for testing
53
- subscripts and other preprocessor-related stuff is not yet implemented. If one of these tests is failing, you will see
54
- the path outputed like so:
55
-
56
- ```
57
- ❯ src/processScript/index.ts (1 test | 1 failed) 6ms
58
- × game-scripts-tests/this_function_array.ts 6ms
59
- → expected undefined to be [ [Function] ] // Object.is equality
60
- ```
61
-
62
- Notice `game-scripts-tests/this_function_array.ts`.
63
-
64
- The naming convention uses underscores instead of dashes as if it was the name of a real hackmud script (which cannot
65
- contain dashes).
66
-
67
- If you need to know what the test scripts look like after being transformed, look for a symbol named
68
- `DEBUG_LOG_PROCESSED_SCRIPTS` in this project and set it to `true`.
package/eslint.config.js DELETED
@@ -1,81 +0,0 @@
1
- import antfu from "@antfu/eslint-config"
2
-
3
- export default antfu(
4
- {
5
- formatters: true,
6
- stylistic: { indent: "tab", quotes: "backtick" },
7
- rules: {
8
- "style/member-delimiter-style": "off",
9
- "style/comma-dangle": [ "error", "never" ],
10
- "style/array-bracket-spacing": [ "error", "always" ],
11
- "unicorn/prefer-node-protocol": "off",
12
- "unicorn/throw-new-error": "off",
13
- "jsonc/array-bracket-spacing": [ "error", "always" ],
14
- "unicorn/new-for-builtins": "off",
15
- eqeqeq: "off",
16
- "style/quote-props": [ "error", "as-needed" ],
17
- "style/brace-style": [ "error", "1tbs" ],
18
- "antfu/curly": "off",
19
- "style/operator-linebreak": [ "error", "after", { overrides: { ":": "before" } } ],
20
- "style/arrow-parens": [ "error", "as-needed" ],
21
- "style/new-parens": [ "error", "never" ],
22
- "antfu/consistent-list-newline": "off",
23
- "antfu/top-level-function": "off",
24
- "no-cond-assign": [ "error", "except-parens" ],
25
- "style/multiline-ternary": "off",
26
- "antfu/no-top-level-await": "off",
27
- "node/prefer-global/process": [ "error", "always" ],
28
- "ts/consistent-type-definitions": [ "error", "type" ],
29
- "unicorn/prefer-number-properties": "off",
30
- "style/indent": [ "error", "tab", { SwitchCase: 1, ignoredNodes: [ "ConditionalExpression" ] } ],
31
- "style/indent-binary-ops": "off",
32
- "yaml/flow-mapping-curly-spacing": [ "error", "always" ],
33
- "yaml/flow-sequence-bracket-spacing": [ "error", "always" ],
34
- "yaml/quotes": [ "error", { prefer: "double" } ],
35
- "yaml/indent": [ "error", 2, { indentBlockSequences: false } ],
36
- "style/padding-line-between-statements": [
37
- "error",
38
- { blankLine: "always", prev: "multiline-const", next: "*" },
39
- { blankLine: "always", prev: "*", next: "multiline-const" },
40
- { blankLine: "always", prev: "multiline-export", next: "*" },
41
- { blankLine: "always", prev: "*", next: "multiline-export" },
42
- { blankLine: "always", prev: "multiline-expression", next: "*" },
43
- { blankLine: "always", prev: "*", next: "multiline-expression" },
44
- { blankLine: "always", prev: "multiline-let", next: "*" },
45
- { blankLine: "always", prev: "*", next: "multiline-let" },
46
- { blankLine: "always", prev: "block-like", next: "*" },
47
- { blankLine: "always", prev: "*", next: "block-like" },
48
- { blankLine: "always", prev: "do", next: "*" },
49
- { blankLine: "always", prev: "*", next: "do" },
50
- { blankLine: "always", prev: "export", next: "*" },
51
- { blankLine: "always", prev: "*", next: "export" },
52
- { blankLine: "always", prev: "for", next: "*" },
53
- { blankLine: "always", prev: "*", next: "for" },
54
- { blankLine: "always", prev: "function", next: "*" },
55
- { blankLine: "always", prev: "*", next: "function" },
56
- { blankLine: "always", prev: "if", next: "*" },
57
- { blankLine: "always", prev: "*", next: "if" },
58
- { blankLine: "always", prev: "let", next: "*" },
59
- { blankLine: "always", prev: "*", next: "let" },
60
- { blankLine: "always", prev: "const", next: "*" },
61
- { blankLine: "always", prev: "*", next: "const" },
62
- { blankLine: "always", prev: "import", next: "*" },
63
- { blankLine: "always", prev: "*", next: "import" },
64
- { blankLine: "never", prev: "singleline-const", next: "singleline-const" },
65
- { blankLine: "never", prev: "singleline-let", next: "singleline-let" },
66
- { blankLine: "never", prev: "singleline-let", next: "singleline-const" },
67
- { blankLine: "never", prev: "singleline-const", next: "singleline-let" },
68
- { blankLine: "never", prev: "singleline-export", next: "singleline-export" },
69
- { blankLine: "never", prev: "import", next: "import" },
70
- { blankLine: "any", prev: "case", next: "case" }
71
- ]
72
- },
73
- languageOptions: { parserOptions: { ecmaVersion: "latest" } }
74
- },
75
- {
76
- files: [ "**/*.js" ],
77
- rules: {
78
- "style/quotes": [ "error", "double" ]
79
- }
80
- }
81
- )
@@ -1,6 +0,0 @@
1
- export default ({ expect }: typeof import('vitest')) => {
2
- const array = [ 1, 2, 3, 4, 5 ]
3
- const [ x, ...rest ] = array;
4
- expect(x).toBe(1)
5
- expect(rest).toStrictEqual([ 2, 3, 4, 5 ])
6
- }
@@ -1,16 +0,0 @@
1
- export default ({ expect }: typeof import('vitest')) => {
2
- const test = {
3
- 0: `test[0]`,
4
- foo: [
5
- function () {
6
- return this[0]
7
- }
8
- ],
9
- bar() {
10
- return this
11
- }
12
- }
13
-
14
- expect(test.foo[0]!()).toBe(test.foo[0])
15
- expect(test.bar()).toBe(test)
16
- }
@@ -1,9 +0,0 @@
1
- export default ({ expect }: typeof import('vitest')) => {
2
- const array = [
3
- function (this: any) {
4
- return this
5
- }
6
- ]
7
-
8
- expect(array[0]!()).toBe(array)
9
- }
@@ -1,35 +0,0 @@
1
- export default ({ expect }: typeof import('vitest')) => {
2
- class Foo {
3
- declare foo: number
4
-
5
- constructor() {
6
- this.foo = 1
7
- }
8
-
9
- bar() {
10
- return 2
11
- }
12
-
13
- baz(a = this.foo, b = this.bar()) {
14
- return a + b
15
- }
16
- }
17
-
18
- const obj = {
19
- foo: 1,
20
- bar() {
21
- return 2
22
- },
23
- baz(a = this.foo, b = this.bar()) {
24
- return a + b
25
- }
26
- }
27
-
28
- const foo = (new Foo)
29
-
30
- expect(foo.baz(3, 4)).toBe(7) // Is this the real life?
31
- expect(foo.baz()).toBe(3) // Is this just fantasy?
32
-
33
- expect(obj.baz(3, 4)).toBe(7) // Caught in a landslide
34
- expect(obj.baz()).toBe(3) // No escape from reality
35
- }
@@ -1,26 +0,0 @@
1
- // Since this is the thing being tested, we need to disable the ESLint rule instead.
2
- /* eslint-disable object-shorthand */
3
-
4
- export default ({ expect }: typeof import('vitest')) => {
5
- const myObject = {
6
- a: 0,
7
- b: function () {
8
- this.a++
9
- return this.a
10
- },
11
- c: function (value: number = this.a) {
12
- this.a = value + 1
13
- },
14
- d: function ({ value = this.a }: { value?: number }) {
15
- this.a = value + 1
16
- }
17
- }
18
-
19
- expect(myObject.a).toBe(0)
20
- myObject.b()
21
- expect(myObject.a).toBe(1)
22
- myObject.c()
23
- expect(myObject.a).toBe(2)
24
- myObject.d({})
25
- expect(myObject.a).toBe(3)
26
- }
@@ -1,2 +0,0 @@
1
- onlyBuiltDependencies:
2
- - esbuild
package/rollup.config.js DELETED
@@ -1,69 +0,0 @@
1
- #!node_modules/.bin/rollup --config
2
- import t from "@babel/types"
3
- import { createId as cuid2 } from "@paralleldrive/cuid2"
4
- import { assert } from "@samual/lib/assert"
5
- import { rollupConfig } from "@samual/rollup-config"
6
-
7
- const isModuleBroken = (/** @type {string} */ name) =>
8
- name == "@babel/traverse" || name == "@babel/generator" || name.startsWith("@babel/plugin-")
9
-
10
- export default rollupConfig({
11
- babelOptions: {
12
- plugins: [
13
- {
14
- name: "babel-has-broken-exports",
15
- visitor: {
16
- ImportDefaultSpecifier(path) {
17
- const importDeclarationPath = path.parentPath
18
-
19
- assert(importDeclarationPath.isImportDeclaration())
20
-
21
- if (!isModuleBroken(importDeclarationPath.node.source.value))
22
- return
23
-
24
- const specifierName = path.node.local.name
25
- const specifierNewName = cuid2()
26
-
27
- path.node.local.name = specifierNewName
28
-
29
- importDeclarationPath.insertAfter(t.variableDeclaration("const", [
30
- t.variableDeclarator(
31
- t.identifier(specifierName),
32
- t.memberExpression(t.identifier(specifierNewName), t.identifier("default"))
33
- )
34
- ]))
35
- },
36
- CallExpression(path) {
37
- if (path.node.callee.type != "Import" || ((path.node.arguments[0]?.type != "StringLiteral" ||
38
- !isModuleBroken(path.node.arguments[0].value)
39
- ) && (path.node.arguments[0]?.type != "TemplateLiteral" ||
40
- !path.node.arguments[0].quasis[0] ||
41
- !isModuleBroken(path.node.arguments[0].quasis[0].value.raw)
42
- )))
43
- return
44
-
45
- path.replaceWith(t.callExpression(
46
- t.memberExpression(
47
- path.node,
48
- t.identifier("then")
49
- ),
50
- [
51
- t.arrowFunctionExpression(
52
- [
53
- t.identifier("module")
54
- ],
55
- t.memberExpression(
56
- t.identifier("module"),
57
- t.identifier("default")
58
- )
59
- )
60
- ]
61
- ))
62
-
63
- path.skip()
64
- }
65
- }
66
- }
67
- ]
68
- }
69
- })
package/scripts/dev.sh DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/sh
2
- set -ex
3
- ./rollup.config.js --watch
@@ -1,3 +0,0 @@
1
- #!/bin/sh
2
- set -ex
3
- npx tsc --project src --declaration --emitDeclarationOnly --noEmit false --outDir dist
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- import { mkdirSync as makeDirectorySync, writeFileSync } from "fs"
3
- import packageJson_ from "../package.json" with { type: "json" }
4
-
5
- const { private: _, devDependencies, engines: { pnpm, ...engines }, ...packageJson } = packageJson_
6
-
7
- makeDirectorySync("dist", { recursive: true })
8
- writeFileSync("dist/package.json", JSON.stringify({ ...packageJson, engines }, undefined, "\t"))
9
- process.exit()
package/scripts/lint.sh DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
- set -ex
3
- npx tsc
4
- npx tsc --project src
5
- npx eslint
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
- set -ex
3
- rm -rf dist
4
- ./rollup.config.js
5
- scripts/emit-declarations.sh
6
- scripts/emit-package-json.js
7
- cp LICENSE README.md env.d.ts dist
package/scripts/update.sh DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- set -ex
3
- pnpm update --latest !@types/node
4
- pnpm update @types/node
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from "child_process"
3
- import * as semver from "semver"
4
- import packageConfig from "../package.json" with { type: "json" }
5
-
6
- const hash = spawnSync("git", [ "rev-parse", "--short", "HEAD" ], { encoding: "utf8" }).stdout.trim()
7
-
8
- spawnSync(
9
- "pnpm",
10
- [ "version", `${semver.inc(/** @type {any} */ (packageConfig).version || "0.0.0", "patch")}-${hash}` ],
11
- { stdio: "inherit" }
12
- )
13
-
14
- process.exit()