hackmud-script-manager 0.20.4-0e584dd → 0.20.4-23a791c

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Hackmud Script Manager
2
- Command made for [hackmud-environment](https://github.com/samualtnorman/hackmud-environment), which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
2
+ 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
3
 
4
4
  [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R0XN5CX)
5
5
 
package/bin/hsm.js CHANGED
@@ -12,7 +12,7 @@ import { pull } from "../pull.js"
12
12
  import { syncMacros } from "../syncMacros.js"
13
13
  import "@samual/lib/readDirectoryWithStats"
14
14
  import "@samual/lib/copyFilePersistent"
15
- const version = "0.20.4-0e584dd",
15
+ const version = "0.20.4-23a791c",
16
16
  options = new Map(),
17
17
  commands = [],
18
18
  userColours = new Cache(user => {
package/env.d.ts CHANGED
@@ -4,6 +4,17 @@ type ScriptFailure = { ok: false, msg?: string }
4
4
  type ScriptResponse<T = object> = ScriptSuccess<T> | ScriptFailure
5
5
  type ErrorScripts = Record<string, () => ScriptFailure>
6
6
 
7
+ type AllOptional<T> = {
8
+ [K in keyof T]-?: {} extends Pick<T, K> ? true : false
9
+ }[keyof T]
10
+
11
+ type Scriptor<Args = unknown, Ret = unknown> = {
12
+ name: string,
13
+ call: AllOptional<Args> extends true
14
+ ? (args?: Args) => Ret
15
+ : (args: Args) => Ret
16
+ }
17
+
7
18
  type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
8
19
  accts: ErrorScripts
9
20
  autos: ErrorScripts
@@ -26,12 +37,16 @@ interface PlayerMidsec {}
26
37
  interface PlayerLowsec {}
27
38
  interface PlayerNullsec {}
28
39
 
40
+ type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
41
+ type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
42
+ type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
43
+
29
44
  type UpgradeCore = {
30
45
  name: string
31
46
  type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
32
47
  up_class?: -1 | 0 | 1 | 2 | 3
33
48
  tier: 1 | 2 | 3 | 4
34
- rarity: 0 | 1 | 2 | 3 | 4 | 5
49
+ rarity: UpgradeRarityNumber
35
50
  i: number
36
51
  loaded: boolean
37
52
  sn: string
@@ -42,7 +57,7 @@ type Upgrade = UpgradeCore & Record<string, null | boolean | number | string>
42
57
 
43
58
  type CLIUpgrade = Omit<UpgradeCore, `rarity`> & {
44
59
  [x: string]: null | boolean | number | string
45
- rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
60
+ rarity: UpgradeRarityString
46
61
  }
47
62
 
48
63
  type UsersTopItem<R> = { rank: R, name: string, last_activity: string, balance: string }
@@ -140,7 +155,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
140
155
  market: {
141
156
  /** **FULLSEC** */ browse: {
142
157
  (args:
143
- { seller: string, listed_before: number, listed_after: number, cost: number | string } & CLIUpgrade
158
+ Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<CLIUpgrade, "rarity">>
144
159
  ): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
145
160
 
146
161
  <I extends string>(args: { i: I }): {
@@ -519,7 +534,7 @@ type Highsec = Fullsec & PlayerHighsec & {
519
534
  args?: { filter?: F, is_script: false, full: true }
520
535
  ): (Omit<UpgradeCore, keyof F | `rarity`> & F & {
521
536
  [x: string]: null | boolean | number | string
522
- rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
537
+ rarity: UpgradeRarityString
523
538
  })[] | ScriptFailure
524
539
  }
525
540
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.20.4-0e584dd",
3
+ "version": "0.20.4-23a791c",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -20,7 +20,11 @@
20
20
  "homepage": "https://github.com/samualtnorman/hackmud-script-manager#readme",
21
21
  "bugs": "https://github.com/samualtnorman/hackmud-script-manager/issues",
22
22
  "license": "MIT",
23
- "author": "Samual Norman",
23
+ "author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
24
+ "contributors": [
25
+ "Daniel Swann (https://github.com/danswann)",
26
+ "Longboyy"
27
+ ],
24
28
  "main": "index.js",
25
29
  "repository": {
26
30
  "type": "git",
@@ -136,7 +136,8 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
136
136
  const promises = []
137
137
  traverse(file, {
138
138
  FunctionDeclaration(path) {
139
- path.traverse({
139
+ const body = path.get("body")
140
+ body.traverse({
140
141
  Function(path) {
141
142
  "CallExpression" != path.parent.type && "callee" != path.parentKey && path.skip()
142
143
  },
@@ -152,7 +153,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
152
153
  path.replaceWith(t.identifier(`_${uniqueId}_JSON_VALUE_${jsonValues.push(o) - 1}_`))
153
154
  }
154
155
  })
155
- path.traverse({
156
+ body.traverse({
156
157
  TemplateLiteral(path) {
157
158
  if ("TaggedTemplateExpression" == path.parent.type) return
158
159
  const templateLiteral = path.node
@@ -172,7 +173,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
172
173
  },
173
174
  MemberExpression({ node: memberExpression }) {
174
175
  if (!memberExpression.computed) {
175
- assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:259:62")
176
+ assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:261:62")
176
177
  if (!(memberExpression.property.name.length < 3)) {
177
178
  memberExpression.computed = !0
178
179
  memberExpression.property = t.stringLiteral(memberExpression.property.name)
@@ -220,8 +221,10 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
220
221
  )
221
222
  },
222
223
  StringLiteral(path) {
223
- path.node.value = replaceUnsafeStrings(uniqueId, path.node.value)
224
- if (JSON.stringify(path.node.value).includes("\\u00") || path.toString().length < 4) return
224
+ if (JSON.stringify(path.node.value).includes("\\u00") || path.toString().length < 4) {
225
+ path.node.value = replaceUnsafeStrings(uniqueId, path.node.value)
226
+ return
227
+ }
225
228
  "key" == path.parentKey && "ObjectProperty" == path.parent.type && (path.parent.computed = !0)
226
229
  let jsonValueIndex = jsonValues.indexOf(path.node.value)
227
230
  ;-1 == jsonValueIndex && (jsonValueIndex += jsonValues.push(path.node.value))
@@ -244,7 +247,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
244
247
  })
245
248
  await Promise.all(promises)
246
249
  const functionDeclaration = file.program.body[0]
247
- assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:363:61")
250
+ assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:366:61")
248
251
  if (jsonValues.length) {
249
252
  hasComment = !0
250
253
  if (1 == jsonValues.length)
@@ -361,7 +364,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
361
364
  )
362
365
  }
363
366
  if (1 == forceQuineCheats) return code
364
- assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:494:43")
367
+ assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:497:43")
365
368
  return (
366
369
  countHackmudCharacters(scriptBeforeJSONValueReplacement) <=
367
370
  countHackmudCharacters(code) + Number(hasComment)
@@ -377,7 +380,7 @@ function parseObjectExpression(node, o) {
377
380
  "Identifier" == property.key.type ||
378
381
  "NumericLiteral" == property.key.type ||
379
382
  "StringLiteral" == property.key.type,
380
- "src/processScript/minify.ts:516:4"
383
+ "src/processScript/minify.ts:519:4"
381
384
  )
382
385
  if ("ArrayExpression" == property.value.type) {
383
386
  const childArray = []
@@ -631,7 +631,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
631
631
  VariableDeclaration({ node: variableDeclaration }) {
632
632
  "const" == variableDeclaration.kind && (variableDeclaration.kind = "let")
633
633
  },
634
- ThisExpression: path => path.replaceWith(t.identifier("undefined")),
634
+ ThisExpression: path => {
635
+ path.replaceWith(t.identifier("undefined"))
636
+ },
635
637
  BigIntLiteral(path) {
636
638
  const bigIntAsNumber = Number(path.node.value)
637
639
  path.replaceWith(
@@ -661,23 +663,23 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
661
663
  }
662
664
  function processFakeSubscriptObject(fakeSubscriptObjectName) {
663
665
  for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
664
- assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:783:60")
666
+ assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:785:60")
665
667
  assert("Identifier" == referencePath.parent.property.type)
666
668
  assert(
667
669
  "MemberExpression" == referencePath.parentPath.parentPath?.node.type,
668
- "src/processScript/transform.ts:785:81"
670
+ "src/processScript/transform.ts:787:81"
669
671
  )
670
672
  assert(
671
673
  "Identifier" == referencePath.parentPath.parentPath.node.property.type,
672
- "src/processScript/transform.ts:786:83"
674
+ "src/processScript/transform.ts:788:83"
673
675
  )
674
676
  assert(
675
677
  /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parent.property.name),
676
- `src/processScript/transform.ts:790:8 invalid user "${referencePath.parent.property.name}" in subscript`
678
+ `src/processScript/transform.ts:792:8 invalid user "${referencePath.parent.property.name}" in subscript`
677
679
  )
678
680
  assert(
679
681
  /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parentPath.parentPath.node.property.name),
680
- `src/processScript/transform.ts:795:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
682
+ `src/processScript/transform.ts:797:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
681
683
  )
682
684
  if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
683
685
  referencePath.parentPath.parentPath.replaceWith(