hackmud-script-manager 0.20.4-d9a4cf1 → 0.20.4

Sign up to get free protection for your applications and to get access to all the features.
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-d9a4cf1",
15
+ const version = "0.20.4",
16
16
  options = new Map(),
17
17
  commands = [],
18
18
  userColours = new Cache(user => {
package/env.d.ts CHANGED
@@ -1,20 +1,9 @@
1
- type Replace<T, R> = Omit<T, Extract<keyof R, keyof T>> & R
1
+ type Replace<A, B> = Omit<A, keyof B> & B
2
2
  type ScriptSuccess<T = object> = { ok: true } & T
3
3
  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
-
18
7
  type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
19
8
  accts: ErrorScripts
20
9
  autos: ErrorScripts
@@ -37,16 +26,12 @@ interface PlayerMidsec {}
37
26
  interface PlayerLowsec {}
38
27
  interface PlayerNullsec {}
39
28
 
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
-
44
29
  type UpgradeCore = {
45
30
  name: string
46
31
  type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
47
32
  up_class?: -1 | 0 | 1 | 2 | 3
48
33
  tier: 1 | 2 | 3 | 4
49
- rarity: UpgradeRarityNumber
34
+ rarity: 0 | 1 | 2 | 3 | 4 | 5
50
35
  i: number
51
36
  loaded: boolean
52
37
  sn: string
@@ -57,7 +42,7 @@ type Upgrade = UpgradeCore & Record<string, null | boolean | number | string>
57
42
 
58
43
  type CLIUpgrade = Omit<UpgradeCore, `rarity`> & {
59
44
  [x: string]: null | boolean | number | string
60
- rarity: UpgradeRarityString
45
+ rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
61
46
  }
62
47
 
63
48
  type UsersTopItem<R> = { rank: R, name: string, last_activity: string, balance: string }
@@ -357,7 +342,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
357
342
  * const arr = [ 1, 2, 2, 3, 2 ]
358
343
  *
359
344
  * $D(uniq(arr)) // [ 1, 2, 3, 2 ] */
360
- uniq: (array: T[]) => T[]
345
+ uniq: <T>(array: T[]) => T[]
361
346
 
362
347
  /** Sorts an array of numbers or number-coercible strings in descending order. */
363
348
  u_sort_num_arr_desc: <T>(array: T[]) => T[]
@@ -534,7 +519,7 @@ type Highsec = Fullsec & PlayerHighsec & {
534
519
  args?: { filter?: F, is_script: false, full: true }
535
520
  ): (Omit<UpgradeCore, keyof F | `rarity`> & F & {
536
521
  [x: string]: null | boolean | number | string
537
- rarity: UpgradeRarityString
522
+ rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
538
523
  })[] | ScriptFailure
539
524
  }
540
525
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.20.4-d9a4cf1",
3
+ "version": "0.20.4",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -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)
@@ -246,7 +247,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
246
247
  })
247
248
  await Promise.all(promises)
248
249
  const functionDeclaration = file.program.body[0]
249
- assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:364:61")
250
+ assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:366:61")
250
251
  if (jsonValues.length) {
251
252
  hasComment = !0
252
253
  if (1 == jsonValues.length)
@@ -363,7 +364,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
363
364
  )
364
365
  }
365
366
  if (1 == forceQuineCheats) return code
366
- assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:495:43")
367
+ assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:497:43")
367
368
  return (
368
369
  countHackmudCharacters(scriptBeforeJSONValueReplacement) <=
369
370
  countHackmudCharacters(code) + Number(hasComment)
@@ -379,7 +380,7 @@ function parseObjectExpression(node, o) {
379
380
  "Identifier" == property.key.type ||
380
381
  "NumericLiteral" == property.key.type ||
381
382
  "StringLiteral" == property.key.type,
382
- "src/processScript/minify.ts:517:4"
383
+ "src/processScript/minify.ts:519:4"
383
384
  )
384
385
  if ("ArrayExpression" == property.value.type) {
385
386
  const childArray = []
package/push.js CHANGED
@@ -61,13 +61,15 @@ async function push(
61
61
  ...hackmudFolder
62
62
  .filter(({ stats, name }) => stats.isFile() && name.endsWith(".key"))
63
63
  .map(({ name }) => name.slice(0, -4))
64
- ]),
65
- usersToScriptsToPush = new Cache(_user => new Map()),
64
+ ])
65
+ if (!allUsers.size)
66
+ throw Error("Could not find any users. Either provide the names of your users or log into a user in hackmud.")
67
+ const usersToScriptsToPush = new Cache(_user => new Map()),
66
68
  scriptNamesToUsers = new Cache(_scriptName => new Set())
67
69
  for (const script of scripts) {
68
70
  const [user, scriptName] = script.split(".")
69
- assert(user, "src/push.ts:69:16")
70
- assert(scriptName, "src/push.ts:70:22")
71
+ assert(user, "src/push.ts:72:16")
72
+ assert(scriptName, "src/push.ts:73:22")
71
73
  "*" == user ? scriptNamesToUsers.set(scriptName, allUsers) : scriptNamesToUsers.get(scriptName).add(user)
72
74
  }
73
75
  const sourceFolderFiles = sourceFolder.filter(({ stats }) => stats.isFile()),