hackmud-script-manager 0.20.4-98f20d9 → 0.20.4-9f460e8

Sign up to get free protection for your applications and to get access to all the features.
package/bin/hsm.js CHANGED
@@ -13,7 +13,7 @@ import { syncMacros } from "../syncMacros.js"
13
13
  import "@samual/lib/readDirectoryWithStats"
14
14
  import "path/posix"
15
15
  import "@samual/lib/copyFilePersistent"
16
- const version = "0.20.4-98f20d9",
16
+ const version = "0.20.4-9f460e8",
17
17
  formatOption = name => colourN(`-${1 == name.length ? "" : "-"}${name}`),
18
18
  options = new Map(),
19
19
  commands = [],
package/env.d.ts CHANGED
@@ -3,13 +3,7 @@ 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
-
7
- type AllOptional<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? true : false }[keyof T]
8
-
9
- type Scriptor<Args = unknown, Ret = unknown> = {
10
- name: string
11
- call: AllOptional<Args> extends true ? (args?: Args) => Ret : (args: Args) => Ret
12
- }
6
+ type Scriptor<TArgs extends any[] = any[]> = { name: string, call: (...args: TArgs) => unknown }
13
7
 
14
8
  type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
15
9
  accts: ErrorScripts
@@ -635,6 +629,9 @@ type Lowsec = Midsec & PlayerLowsec & {
635
629
  (args: { i: number | number[], to: string, memo?: string }): ScriptResponse
636
630
  (args: { sn: string | string[], to: string, memo?: string }): ScriptResponse
637
631
  }
632
+ /** **LOWSEC** */ expose_access_log: (args: { target: string }) => ScriptResponse
633
+ /** **LOWSEC** */ xfer_gc_from: (args: { target: string, amount: number | string }) => ScriptResponse
634
+ /** **LOWSEC** */ expose_balance: (args: { target: string }) => ScriptResponse
638
635
  }
639
636
  }
640
637
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.20.4-98f20d9",
3
+ "version": "0.20.4-9f460e8",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -204,6 +204,7 @@ async function processScript(
204
204
  const bundle = await rollup({
205
205
  input: filePathResolved,
206
206
  plugins: [
207
+ rollupPluginJSON({ preferConst: !0 }),
207
208
  {
208
209
  name: "hackmud-script-manager",
209
210
  async transform(code, id) {
@@ -227,8 +228,7 @@ async function processScript(
227
228
  },
228
229
  babel({ babelHelpers: "bundled", plugins, configFile: !1, extensions: supportedExtensions }),
229
230
  rollupPluginCommonJS(),
230
- rollupPluginNodeResolve({ extensions: supportedExtensions }),
231
- rollupPluginJSON()
231
+ rollupPluginNodeResolve({ extensions: supportedExtensions })
232
232
  ],
233
233
  treeshake: { moduleSideEffects: !1 }
234
234
  }),
@@ -629,39 +629,31 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
629
629
  })
630
630
  return { file, seclevel }
631
631
  function createGetFunctionPrototypeNode() {
632
- for (const globalFunction of globalFunctionsUnder7Characters)
633
- if (!program.scope.hasOwnBinding(globalFunction))
634
- return t.memberExpression(
635
- t.memberExpression(t.identifier(globalFunction), t.identifier("constructor")),
636
- t.identifier("prototype")
637
- )
632
+ const name = globalFunctionsUnder7Characters.find(name => !program.scope.hasOwnBinding(name))
638
633
  return t.memberExpression(
639
- t.memberExpression(
640
- t.arrowFunctionExpression([t.identifier("_")], t.identifier("_")),
641
- t.identifier("constructor")
642
- ),
643
- t.identifier("prototype")
634
+ name ? t.identifier(name) : t.arrowFunctionExpression([t.identifier("_")], t.identifier("_")),
635
+ t.identifier("__proto__")
644
636
  )
645
637
  }
646
638
  function processFakeSubscriptObject(fakeSubscriptObjectName, seclevel) {
647
639
  for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
648
- assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:774:60")
640
+ assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:764:60")
649
641
  assert("Identifier" == referencePath.parent.property.type)
650
642
  assert(
651
643
  "MemberExpression" == referencePath.parentPath.parentPath?.node.type,
652
- "src/processScript/transform.ts:776:81"
644
+ "src/processScript/transform.ts:766:81"
653
645
  )
654
646
  assert(
655
647
  "Identifier" == referencePath.parentPath.parentPath.node.property.type,
656
- "src/processScript/transform.ts:777:83"
648
+ "src/processScript/transform.ts:767:83"
657
649
  )
658
650
  assert(
659
651
  /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parent.property.name),
660
- `src/processScript/transform.ts:781:8 invalid user "${referencePath.parent.property.name}" in subscript`
652
+ `src/processScript/transform.ts:771:8 invalid user "${referencePath.parent.property.name}" in subscript`
661
653
  )
662
654
  assert(
663
655
  /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parentPath.parentPath.node.property.name),
664
- `src/processScript/transform.ts:786:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
656
+ `src/processScript/transform.ts:776:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
665
657
  )
666
658
  if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
667
659
  referencePath.parentPath.parentPath.replaceWith(