hackmud-script-manager 0.20.4-67aeb81 → 0.20.4-698da0d

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -34,8 +28,8 @@ interface PlayerLowsec {}
34
28
  interface PlayerNullsec {}
35
29
 
36
30
  type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
37
- type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
38
- type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
31
+ type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5
32
+ type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber
39
33
 
40
34
  type UpgradeBase = {
41
35
  name: string
@@ -51,10 +45,8 @@ type UpgradeBase = {
51
45
 
52
46
  type Upgrade = UpgradeBase & Record<string, null | boolean | number | string>
53
47
 
54
- type CliUpgrade = Omit<UpgradeBase, `rarity`> & {
55
- [x: string]: null | boolean | number | string
56
- rarity: UpgradeRarityString
57
- }
48
+ type CliUpgrade = Omit<UpgradeBase, `rarity`> &
49
+ { [k: string]: null | boolean | number | string, rarity: UpgradeRarityString }
58
50
 
59
51
  type UsersTopItem<R> = { rank: R, name: string, last_activity: string, balance: string }
60
52
  type CorpsTopItem<R> = { rank: R, name: string, worth: string }
@@ -132,26 +124,25 @@ type Fullsec = Subscripts & PlayerFullsec & {
132
124
  }
133
125
 
134
126
  escrow: {
135
- /** **FULLSEC** */ charge: (args: {
136
- cost: number | string
137
- is_unlim?: boolean
138
- }) => null | ScriptFailure
139
-
127
+ /** **FULLSEC** */ charge: (args: { cost: number | string, is_unlim?: boolean }) => null | ScriptFailure
140
128
  confirm: never
141
129
  }
142
130
 
143
- gui: {
144
- chats: never
145
- quiet: never
146
- size: never
147
- vfx: never
148
- vol: never
149
- }
131
+ gui: { chats: never, quiet: never, size: never, vfx: never, vol: never }
150
132
 
151
133
  market: {
152
134
  /** **FULLSEC** */ browse: {
153
135
  (args:
154
- Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<CliUpgrade, "rarity">>
136
+ Partial<{
137
+ seller: string | MongoQuerySelector<string>,
138
+ listed_before: number | MongoQuerySelector<number>,
139
+ listed_after: number,
140
+ cost: number | MongoQuerySelector<number> | string,
141
+ rarity: UpgradeRarityNumber | MongoQuerySelector<UpgradeRarityNumber>,
142
+ name: string | MongoQuerySelector<string>
143
+ } & Omit<{
144
+ [k in keyof CliUpgrade]: CliUpgrade[k] | MongoQuerySelector<CliUpgrade[k]>
145
+ }, "rarity">>
155
146
  ): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
156
147
 
157
148
  <I extends string>(args: { i: I }): {
@@ -456,7 +447,10 @@ type Highsec = Fullsec & PlayerHighsec & {
456
447
  /** **HIGHSEC**
457
448
  * @returns GC balance as number if `is_script` is true (default).
458
449
  * @returns GC balance as string if `is_script` is false. */
459
- balance: ((args?: { is_script?: true }) => number) & ((args: { is_script: false }) => string)
450
+ balance: {
451
+ (args?: { is_script?: true }): number
452
+ (args: { is_script: false }): string
453
+ }
460
454
 
461
455
  /** **HIGHSEC**
462
456
  * @returns Transaction history according to filter.
@@ -626,6 +620,9 @@ type Lowsec = Midsec & PlayerLowsec & {
626
620
  (args: { i: number | number[], to: string, memo?: string }): ScriptResponse
627
621
  (args: { sn: string | string[], to: string, memo?: string }): ScriptResponse
628
622
  }
623
+ /** **LOWSEC** */ expose_access_log: (args: { target: string }) => ScriptResponse
624
+ /** **LOWSEC** */ xfer_gc_from: (args: { target: string, amount: number | string }) => ScriptResponse
625
+ /** **LOWSEC** */ expose_balance: (args: { target: string }) => ScriptResponse
629
626
  }
630
627
  }
631
628
 
@@ -710,55 +707,146 @@ type Nullsec = Lowsec & PlayerNullsec & {
710
707
  }
711
708
  }
712
709
 
713
- type MongoValue = string | number | boolean | Date | MongoValue[] | { [key: string]: MongoValue } | null
710
+ // database
711
+ type MongoPrimitive = null | boolean | number | Date | string
712
+ type MongoValue = MongoPrimitive | MongoValue[] | MongoObject
713
+ type MongoObject = { [k: string]: MongoValue, [k: `$${string}`]: never }
714
+ type MongoQueryValue = MongoPrimitive | MongoQueryValue[] | MongoQueryObject
715
+
716
+ type MongoQueryObject =
717
+ { [k: string]: MongoQueryValue, [k: `$${string}`]: MongoValue, $type?: keyof MongoTypeStringsToTypes | (string & {}) }
718
+
719
+ type MongoTypeStringsToTypes = {
720
+ double: number
721
+ string: string
722
+ object: MongoObject
723
+ array: MongoValue[]
724
+ objectId: ObjectId
725
+ bool: boolean
726
+ date: Date
727
+ null: null
728
+ int: number
729
+ long: number
730
+ }
714
731
 
715
- type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | { [key: string]: MongoCommandValue } |
716
- null | undefined
732
+ type MongoTypeString = keyof MongoTypeStringsToTypes
733
+ type MongoTypeNumber = -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 127
734
+ type MongoId = Exclude<MongoPrimitive, null> | MongoObject
735
+ type MongoQueryId = Exclude<MongoPrimitive, null> | MongoQueryObject
736
+ type MongoDocument = MongoObject & { _id?: MongoId }
737
+
738
+ type MongoQueryType<TQuery extends MongoQueryObject> = {
739
+ -readonly [K in keyof TQuery]:
740
+ TQuery[K] extends MongoPrimitive ?
741
+ TQuery[K]
742
+ : TQuery[K] extends { $type: infer TType } ?
743
+ TType extends keyof MongoTypeStringsToTypes ? MongoTypeStringsToTypes[TType] : unknown
744
+ : TQuery[K] extends { $in: (infer TIn)[] } ?
745
+ TIn
746
+ : keyof TQuery[K] extends `$${string}` ?
747
+ unknown
748
+ : TQuery[K] extends { [k: string]: any } ?
749
+ MongoQueryType<TQuery[K]>
750
+ : never
751
+ }
717
752
 
718
- type Query = { [key: string]: MongoValue | Query } & { _id?: Id, $in?: MongoValue[] }
719
- type Projection = Record<string, boolean | 0 | 1>
753
+ type MongoCommandValue = MongoPrimitive | MongoCommandValue[] | { [k: string]: MongoCommandValue }
754
+ type MongoArraySelectors<T extends MongoValue[] = MongoValue[]> = { $all: T, $elemMatch: T, $size: number }
720
755
 
721
- type MongoCommand = MongoCommandValue & Partial<
722
- { $set: Record<string, MongoCommandValue>, $push: Record<string, MongoCommandValue>, $unset: Record<string, ""> }
756
+ type MongoComparisonSelectors<T extends MongoValue = MongoValue> =
757
+ { $eq: T, $gt: T, $gte: T, $in: T[], $lt: T, $lte: T, $ne: T, $nin: T[] }
758
+
759
+ type MongoElementSelectors = { $exists: boolean, $type: MongoTypeNumber | MongoTypeString }
760
+
761
+ type MongoQuerySelector<T extends MongoValue> = Partial<
762
+ T extends []
763
+ ? MongoArraySelectors<T> & MongoElementSelectors & MongoComparisonSelectors<T>
764
+ : MongoElementSelectors & MongoComparisonSelectors<T>
723
765
  >
724
766
 
725
- type Id = string | number | boolean | Date | Record<string, MongoValue>
726
- type MongoDocument = { [key: string]: MongoValue, _id: Id }
767
+ type MongoQuery<T extends MongoObject> = { [K in keyof T]?: T[K] | MongoQuerySelector<T[K]> } & { _id?: MongoId }
768
+ type Projection = Record<string, boolean | 0 | 1>
769
+
770
+ type MongoUpdateOperators<T extends MongoObject> = Partial<{
771
+ /* Universal operators */
772
+ $set: Partial<Record<string, MongoCommandValue> & T>
773
+ $setOnInsert: Partial<Record<string, MongoCommandValue> & T>
774
+ $unset: Partial<Record<string, ""> & T>
775
+
776
+ $rename: Partial<Record<string, string> & { [key in keyof T]: string }>
777
+
778
+ /* Date & number operators */
779
+ $inc: Record<string, number> &
780
+ { [K in keyof T as T[K] extends number | Date ? K : never]?: T[K] extends number ? number : Date }
781
+
782
+ $mul: Record<string, number> & { [K in keyof T as T[K] extends number ? K : never]?: number }
783
+ $min: Record<string, number> & { [K in keyof T as T[K] extends number ? K : never]?: number }
784
+ $max: Record<string, number> & { [K in keyof T as T[K] extends number ? K : never]?: number }
785
+
786
+ /* Array operators */
787
+ $pop: Record<string, -1 | 1> & { [K in keyof T as T[K] extends [] ? K : never]?: -1 | 1 }
788
+
789
+ $push: Record<string, MongoCommandValue> & {
790
+ [K in keyof T as T[K] extends [] ? K : never]?: (T[K] extends (infer U)[] ? U : never)
791
+ | MongoUpdateArrayOperatorModifiers<T[K]>
792
+ }
793
+
794
+ $addToSet: Partial<Record<string, MongoCommandValue> & {
795
+ [K in keyof T as T[K] extends [] ? K : never]: (T[K] extends (infer U)[] ? U : never)
796
+ | MongoUpdateArrayOperatorUniversalModifiers<T[K]>
797
+ }>
798
+
799
+ $pull: Partial<Record<string, MongoCommandValue> & {
800
+ [K in keyof T as T[K] extends [] ? K : never]: (T[K] extends (infer U)[] ? U : never)
801
+ | MongoQuerySelector<T[K]>
802
+ }>
803
+
804
+ $pullAll: Record<string, MongoCommandValue> & { [K in keyof T as T[K] extends [] ? K : never]?: T[K] }
805
+ }>
806
+
807
+ type MongoUpdateArrayOperatorUniversalModifiers<T> = { $each?: T extends [] ? T : T[] }
808
+
809
+ type MongoUpdateArrayOperatorModifiers<T> = MongoUpdateArrayOperatorUniversalModifiers<T> &
810
+ { $position?: number, $slice?: number, $sort?: 1 | -1 }
811
+
812
+ type MongoUpdateCommand<Schema extends MongoObject> = MongoUpdateOperators<Schema>
813
+
727
814
  type SortOrder = { [key: string]: 1 | -1 | SortOrder }
728
815
 
729
- type Cursor = {
730
- /** Returns the first document that satisfies the query. */ first: () => MongoDocument | null
731
- /** Returns an array of documents that satisfy the query. */ array: () => MongoDocument[]
816
+ type Cursor<T> = {
817
+ /** Returns the first document that satisfies the query. */ first: () => T | null
818
+ /** Returns an array of documents that satisfy the query. */ array: () => T[]
732
819
  /** Returns the number of documents that match the query. */ count: () => number
733
820
 
734
821
  /** Returns the first document that satisfies the query. Also makes cursor unusable. */
735
- first_and_close: () => MongoDocument
822
+ first_and_close: () => T
736
823
 
737
824
  /** Returns an array of documents that satisfy the query. Also makes cursor unusable. */
738
- array_and_close: () => MongoDocument[]
825
+ array_and_close: () => T[]
739
826
 
740
827
  /** Returns the number of documents that match the query. Also makes cursor unusable. */
741
828
  count_and_close: () => number
742
829
 
743
830
  /** Run `callback` on each document that satisfied the query. */
744
- each: (callback: (document: MongoDocument) => void) => null
831
+ each: (callback: (document: T) => void) => null
745
832
 
746
833
  /** Returns a new cursor with documents sorted as specified.
747
834
  * A value of 1 sorts the property ascending, and -1 descending.
748
835
  * @param order The way the documents are to be sorted. */
749
- sort: (order?: SortOrder) => Cursor
836
+ sort: (order?: SortOrder) => Cursor<T>
750
837
 
751
838
  /** Returns a new cursor without the first number of documents.
752
839
  * @param count Number of documents to skip. */
753
- skip: (count: number) => Cursor
840
+ skip: (count: number) => Cursor<T>
754
841
 
755
842
  /** Returns a new cursor limited to a number of documents as specified.
756
843
  * @param count Number of documents. */
757
- limit: (count: number) => Cursor
844
+ limit: (count: number) => Cursor<T>
758
845
 
759
- /** @param key The key of the documents. */ distinct: ((key: string) => MongoValue[]) & ((key: "_id") => Id[])
846
+ /** @param key The key of the documents. */ distinct: { (key: string): MongoValue[], (key: "_id"): MongoId[] }
760
847
  /** Make cursor unusable. */ close: () => null
761
848
  NumberLong: (number: number) => number
849
+ // TODO what actually is the type here?
762
850
  ObjectId: () => any
763
851
  }
764
852
 
@@ -769,7 +857,9 @@ type CliContext = {
769
857
  /** The number of rows in the caller’s terminal. */ rows: number
770
858
 
771
859
  /** The name of the script that directly called this script, or null if called on the command line or as a
772
- * scriptor. */ calling_script: null
860
+ * scriptor. */
861
+ calling_script: null
862
+
773
863
  is_scriptor?: undefined
774
864
  is_brain?: undefined
775
865
  }
@@ -780,12 +870,8 @@ type SubscriptContext = Replace<CliContext, {
780
870
  calling_script: string
781
871
  }>
782
872
 
783
- type ScriptorContext =
784
- Replace<CliContext, { /** Whether the script is being run as a scriptor. */ is_scriptor: true }>
785
-
786
- type BrainContext =
787
- Replace<CliContext, { /** Whether the script is being run via a bot brain. */ is_brain: true }>
788
-
873
+ type ScriptorContext = Replace<CliContext, { /** Whether the script is being run as a scriptor. */ is_scriptor: true }>
874
+ type BrainContext = Replace<CliContext, { /** Whether the script is being run via a bot brain. */ is_brain: true }>
789
875
  type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
790
876
 
791
877
  /** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
@@ -822,8 +908,8 @@ declare const $0s: typeof $ns
822
908
 
823
909
  /** Subscript space that can call any script. Uses seclevel provided in comment before script (defaults to NULLSEC)
824
910
  * @example
825
- * // @ seclevel MIDSEC
826
- * // remove the space betwen "@" and "s", there's only a space because otherwise vscode breaks
911
+ * // @​seclevel MIDSEC
912
+ * // note, do NOT copy paste the above line because there is a zero-width space inserted between "@" and "s"
827
913
  * export function script() {
828
914
  * $s.foo.bar() // will be converted to #ms.foo.bar()
829
915
  * } */
@@ -831,99 +917,65 @@ declare const $s: Nullsec
831
917
 
832
918
  type ObjectId = { $oid: string }
833
919
 
920
+ // _id is always returned unless _id: false is passed
921
+ // when anyField: true is given, other fields (except _id) are omitted
922
+
923
+ type MongoProject<TDocument, TProjection> =
924
+ true extends (1 extends TProjection[keyof TProjection] ? true : TProjection[keyof TProjection]) ?
925
+ (TProjection extends { _id: false | 0 } ? {} : { _id: TDocument extends { _id: infer TId } ? TId : MongoId }) &
926
+ {
927
+ [K in
928
+ keyof TDocument as K extends keyof TProjection ? TProjection[K] extends true | 1 ? K : never : never
929
+ ]: TDocument[K]
930
+ } &
931
+ {
932
+ -readonly [K in
933
+ keyof TProjection as TProjection[K] extends true | 1 ? K extends keyof TDocument ? never : K : never
934
+ ]?: MongoValue
935
+ }
936
+ : { [k: string]: MongoValue } & { [K in keyof TDocument as K extends keyof TProjection ? never : K]: TDocument[K] }
937
+
834
938
  declare const $db: {
835
939
  /** Insert a document or documents into a collection.
836
940
  * @param documents A document or array of documents to insert into the collection. */
837
- i: (documents: object | object[]) => {
838
- ok: 1
839
- n: number
840
- opTime: { ts: "Undefined Conversion", t: number }
841
- electionId: "Undefined Conversion"
842
- operationTime: "Undefined Conversion"
843
- $clusterTime: {
844
- clusterTime: "Undefined Conversion"
845
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
846
- }
847
- }
941
+ i: <T extends MongoDocument>(documents: (T & { _id?: MongoId }) | (T & { _id?: MongoId })[]) =>
942
+ { n: number, opTime: { t: number }, ok: 0 | 1 }[]
848
943
 
849
944
  /** Remove documents from a collection.
850
945
  * @param query Specifies deletion criteria using query operators. */
851
- r: (query: Query) => {
852
- ok: 0 | 1
853
- n: number
854
- opTime: { ts: "Undefined Conversion", t: number }
855
- electionId: "Undefined Conversion"
856
- operationTime: "Undefined Conversion"
857
- $clusterTime: {
858
- clusterTime: "Undefined Conversion"
859
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
860
- }
861
- }
946
+ r: <T extends MongoDocument>(query: MongoQuery<T>) => { n: number, opTime: { t: number }, ok: 0 | 1 }[]
862
947
 
863
948
  /** Find documents in a collection or view and returns a cursor to the selected documents.
864
949
  * @param query Specifies deletion criteria using query operators.
865
950
  * @param projection Specifies the fields to return in the documents that match the query filter. */
866
- f: (query?: Query, projection?: Projection) => Cursor
951
+ f: <
952
+ const TQuery extends MongoQueryObject & { _id?: MongoQueryId },
953
+ const TProjection extends { [k: string]: boolean | 0 | 1 } = {}
954
+ >(query: TQuery, projection?: TProjection) => Cursor<MongoProject<MongoQueryType<TQuery>, TProjection>>
867
955
 
868
- /** Update an existing documents in a collection.
956
+ /** Update existing documents in a collection.
869
957
  * @param query Specifies deletion criteria using query operators.
870
958
  * @param command The modifications to apply.
871
959
  * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
872
- u: (query: Query | Query[], command: MongoCommand) => {
873
- ok: 0 | 1
874
- nModified: number
875
- n: number
876
- opTime: { ts: "Undefined Conversion", t: number }
877
- electionId: "Undefined Conversion"
878
- operationTime: "Undefined Conversion"
879
- $clusterTime: {
880
- clusterTime: "Undefined Conversion"
881
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
882
- }
883
- }
960
+ u: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
961
+ { n: number, opTime: { t: number }, ok: 0 | 1, nModified: number }[]
884
962
 
885
963
  /** Updates one document within the collection based on the filter.
886
964
  * @param query Specifies deletion criteria using query operators.
887
965
  * @param command The modifications to apply.
888
966
  * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
889
- u1: (query: Query | Query[], command: MongoCommand) => {
890
- ok: 0 | 1
891
- nModified: number
892
- n: number
893
- opTime: {
894
- ts: "Undefined Conversion"
895
- t: number
896
- }
897
- electionId: "Undefined Conversion"
898
- operationTime: "Undefined Conversion"
899
- $clusterTime: {
900
- clusterTime: "Undefined Conversion"
901
- signature: {
902
- hash: "Undefined Conversion"
903
- keyId: "Undefined Conversion"
904
- }
905
- }
906
- }
967
+ u1: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
968
+ { n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
907
969
 
908
- /** Update or insert or insert document.
970
+ /** Update or insert document.
909
971
  * Same as Update, but if no documents match the query, one document will be inserted based on the properties in
910
972
  * both the query and the command.
911
973
  * The `$setOnInsert` operator is useful to set defaults.
912
974
  * @param query Specifies deletion criteria using query operators.
913
975
  * @param command The modifications to apply.
914
976
  * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
915
- us: (query: Query | Query[], command: MongoCommand) => {
916
- ok: 0 | 1
917
- nModified: number
918
- n: number
919
- opTime: { ts: "Undefined Conversion", t: number }
920
- electionId: "Undefined Conversion"
921
- operationTime: "Undefined Conversion"
922
- $clusterTime: {
923
- clusterTime: "Undefined Conversion"
924
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
925
- }
926
- }
977
+ us: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
978
+ { n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
927
979
 
928
980
  ObjectId: () => ObjectId
929
981
  }
@@ -1,5 +1,6 @@
1
1
  import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
2
2
  import { basename, resolve } from "path"
3
+ import * as PathPosix from "path/posix"
3
4
  async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
4
5
  const users = new Set()
5
6
  if (hackmudPath)
@@ -29,7 +30,7 @@ async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
29
30
  }
30
31
  })
31
32
  )
32
- sourceDirectory = resolve(sourceDirectory)
33
+ sourceDirectory = PathPosix.resolve(sourceDirectory)
33
34
  let o = ""
34
35
  for (const script of wildScripts) o += `type $${script}$ = typeof import("${sourceDirectory}/${script}").default\n`
35
36
  o += "\n"
package/index.js CHANGED
@@ -7,6 +7,7 @@ export { syncMacros } from "./syncMacros.js"
7
7
  export { watch } from "./watch.js"
8
8
  import "@samual/lib/readDirectoryWithStats"
9
9
  import "path"
10
+ import "path/posix"
10
11
  import "@babel/generator"
11
12
  import "@babel/parser"
12
13
  import "@babel/plugin-proposal-decorators"
@@ -45,7 +46,7 @@ import "import-meta-resolve"
45
46
  import "./processScript/transform.js"
46
47
  import "@samual/lib/clearObject"
47
48
  import "@samual/lib/copyFilePersistent"
48
- import "@samual/lib/Cache"
49
+ import "@samual/lib/AutoMap"
49
50
  import "@samual/lib/writeFilePersistent"
50
51
  import "fs/promises"
51
52
  import "chokidar"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.20.4-67aeb81",
3
+ "version": "0.20.4-698da0d",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -31,50 +31,50 @@
31
31
  "url": "https://github.com/samualtnorman/hackmud-script-manager.git"
32
32
  },
33
33
  "dependencies": {
34
- "@babel/generator": "^7.24.4",
35
- "@babel/parser": "^7.24.4",
36
- "@babel/plugin-proposal-decorators": "^7.24.1",
37
- "@babel/plugin-proposal-destructuring-private": "^7.24.1",
38
- "@babel/plugin-proposal-do-expressions": "^7.24.1",
39
- "@babel/plugin-proposal-explicit-resource-management": "^7.24.1",
40
- "@babel/plugin-proposal-function-bind": "^7.24.1",
41
- "@babel/plugin-proposal-function-sent": "^7.24.1",
42
- "@babel/plugin-proposal-partial-application": "^7.24.1",
43
- "@babel/plugin-proposal-pipeline-operator": "^7.24.1",
44
- "@babel/plugin-proposal-record-and-tuple": "^7.24.1",
45
- "@babel/plugin-proposal-throw-expressions": "^7.24.1",
46
- "@babel/plugin-transform-class-properties": "^7.24.1",
47
- "@babel/plugin-transform-class-static-block": "^7.24.4",
48
- "@babel/plugin-transform-exponentiation-operator": "^7.24.1",
49
- "@babel/plugin-transform-json-strings": "^7.24.1",
50
- "@babel/plugin-transform-logical-assignment-operators": "^7.24.1",
51
- "@babel/plugin-transform-nullish-coalescing-operator": "^7.24.1",
52
- "@babel/plugin-transform-numeric-separator": "^7.24.1",
53
- "@babel/plugin-transform-object-rest-spread": "^7.24.1",
54
- "@babel/plugin-transform-optional-catch-binding": "^7.24.1",
55
- "@babel/plugin-transform-optional-chaining": "^7.24.1",
56
- "@babel/plugin-transform-private-property-in-object": "^7.24.1",
57
- "@babel/plugin-transform-typescript": "^7.24.4",
58
- "@babel/plugin-transform-unicode-sets-regex": "^7.24.1",
59
- "@babel/traverse": "^7.24.1",
60
- "@babel/types": "^7.24.0",
34
+ "@babel/generator": "^7.26.2",
35
+ "@babel/parser": "^7.26.2",
36
+ "@babel/plugin-proposal-decorators": "^7.25.9",
37
+ "@babel/plugin-proposal-destructuring-private": "^7.26.0",
38
+ "@babel/plugin-proposal-do-expressions": "^7.25.9",
39
+ "@babel/plugin-proposal-explicit-resource-management": "^7.25.9",
40
+ "@babel/plugin-proposal-function-bind": "^7.25.9",
41
+ "@babel/plugin-proposal-function-sent": "^7.25.9",
42
+ "@babel/plugin-proposal-partial-application": "^7.25.9",
43
+ "@babel/plugin-proposal-pipeline-operator": "^7.25.9",
44
+ "@babel/plugin-proposal-record-and-tuple": "^7.25.9",
45
+ "@babel/plugin-proposal-throw-expressions": "^7.25.9",
46
+ "@babel/plugin-transform-class-properties": "^7.25.9",
47
+ "@babel/plugin-transform-class-static-block": "^7.26.0",
48
+ "@babel/plugin-transform-exponentiation-operator": "^7.25.9",
49
+ "@babel/plugin-transform-json-strings": "^7.25.9",
50
+ "@babel/plugin-transform-logical-assignment-operators": "^7.25.9",
51
+ "@babel/plugin-transform-nullish-coalescing-operator": "^7.25.9",
52
+ "@babel/plugin-transform-numeric-separator": "^7.25.9",
53
+ "@babel/plugin-transform-object-rest-spread": "^7.25.9",
54
+ "@babel/plugin-transform-optional-catch-binding": "^7.25.9",
55
+ "@babel/plugin-transform-optional-chaining": "^7.25.9",
56
+ "@babel/plugin-transform-private-property-in-object": "^7.25.9",
57
+ "@babel/plugin-transform-typescript": "^7.25.9",
58
+ "@babel/plugin-transform-unicode-sets-regex": "^7.25.9",
59
+ "@babel/traverse": "^7.25.9",
60
+ "@babel/types": "^7.26.0",
61
61
  "@bloomberg/record-tuple-polyfill": "^0.0.4",
62
62
  "@rollup/plugin-babel": "^6.0.4",
63
- "@rollup/plugin-commonjs": "^25.0.7",
63
+ "@rollup/plugin-commonjs": "^28.0.1",
64
64
  "@rollup/plugin-json": "^6.1.0",
65
- "@rollup/plugin-node-resolve": "^15.2.3",
66
- "@samual/lib": "0.11.0",
67
- "acorn": "^8.11.3",
65
+ "@rollup/plugin-node-resolve": "^15.3.0",
66
+ "@samual/lib": "^0.13.0",
67
+ "acorn": "^8.14.0",
68
68
  "chalk": "^5.3.0",
69
- "chokidar": "^3.6.0",
70
- "import-meta-resolve": "^4.0.0",
71
- "prettier": "^3.2.5",
69
+ "chokidar": "^4.0.1",
70
+ "import-meta-resolve": "^4.1.0",
71
+ "prettier": "^3.3.3",
72
72
  "proxy-polyfill": "^0.3.2",
73
- "rollup": "^4.16.4",
74
- "terser": "^5.30.4"
73
+ "rollup": "^4.27.4",
74
+ "terser": "^5.36.0"
75
75
  },
76
76
  "peerDependencies": {
77
- "typescript": "5.4.5"
77
+ "typescript": "^5.4.5"
78
78
  },
79
79
  "type": "module",
80
80
  "exports": {
@@ -86,6 +86,6 @@
86
86
  "hsm": "bin/hsm.js"
87
87
  },
88
88
  "engines": {
89
- "node": "^18 || >=20"
89
+ "node": "^18 || ^20 || >=22"
90
90
  }
91
91
  }
@@ -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
  }),
@@ -323,7 +323,7 @@ async function processScript(
323
323
  trailingComma: "none"
324
324
  })
325
325
  }
326
- code = postprocess(code, seclevel, uniqueId)
326
+ code = postprocess(code, uniqueId)
327
327
  if (includesIllegalString(code))
328
328
  throw Error(
329
329
  'you found a weird edge case where I wasn\'t able to replace illegal strings like "SC$", please report thx'