hackmud-script-manager 0.20.4-459d480 → 0.20.4-52a588b

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,21 +124,11 @@ 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: {
@@ -465,7 +447,10 @@ type Highsec = Fullsec & PlayerHighsec & {
465
447
  /** **HIGHSEC**
466
448
  * @returns GC balance as number if `is_script` is true (default).
467
449
  * @returns GC balance as string if `is_script` is false. */
468
- 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
+ }
469
454
 
470
455
  /** **HIGHSEC**
471
456
  * @returns Transaction history according to filter.
@@ -635,6 +620,9 @@ type Lowsec = Midsec & PlayerLowsec & {
635
620
  (args: { i: number | number[], to: string, memo?: string }): ScriptResponse
636
621
  (args: { sn: string | string[], to: string, memo?: string }): ScriptResponse
637
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
638
626
  }
639
627
  }
640
628
 
@@ -719,95 +707,146 @@ type Nullsec = Lowsec & PlayerNullsec & {
719
707
  }
720
708
  }
721
709
 
722
- type MongoTypeString = "minKey" | "double" | "string" | "object" | "array" | "binData" | "undefined" | "objectId" |
723
- "bool" | "date" | "null" | "regex" | "dbPointer" | "javascript" | "symbol" | "int" | "timestamp" | "long" | "decimal" | "maxKey";
724
- type MongoTypeNumber = -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 127;
725
-
726
- type MongoValue = string | number | boolean | Date | MongoValue[] | { [key: string]: MongoValue } | null
727
-
728
- type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | { [key: string]: MongoCommandValue } |
729
- null | undefined
730
-
731
- /**
732
- * Currently unused
733
- */
734
- type MongoLogicalSelectors<T extends MongoValue = MongoValue> = {
735
- $not: T | MongoComparisonSelectors<T> | MongoLogicalSelectors<T>
736
- $nor: T[]
737
- $or: T[]
738
- $and: T[]
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
739
730
  }
740
731
 
741
- type MongoArraySelectors<T extends Array<MongoValue> = Array<MongoValue>> = {
742
- $all: T
743
- $elemMatch: T
744
- $size: number
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
745
751
  }
746
752
 
747
- type MongoComparisonSelectors<T extends MongoValue = MongoValue> = {
748
- $eq: T
749
- $gt: T
750
- $gte: T
751
- $in: T[]
752
- $lt: T
753
- $lte: T
754
- $ne: T
755
- $nin: T[]
756
- }
753
+ type MongoCommandValue = MongoPrimitive | MongoCommandValue[] | { [k: string]: MongoCommandValue }
754
+ type MongoArraySelectors<T extends MongoValue[] = MongoValue[]> = { $all: T, $elemMatch: T, $size: number }
757
755
 
758
- type MongoElementSelectors = {
759
- $exists: boolean
760
- $type: MongoTypeNumber | MongoTypeString
761
- }
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 }
762
760
 
763
- type MongoQuerySelector<T extends MongoValue = MongoValue> = Partial<T extends MongoValue[] ?
764
- (MongoArraySelectors<T> & MongoElementSelectors & MongoComparisonSelectors<T>) :
765
- (MongoElementSelectors & MongoComparisonSelectors<T>)>
761
+ type MongoQuerySelector<T extends MongoValue> = Partial<
762
+ T extends []
763
+ ? MongoArraySelectors<T> & MongoElementSelectors & MongoComparisonSelectors<T>
764
+ : MongoElementSelectors & MongoComparisonSelectors<T>
765
+ >
766
766
 
767
- type Query = { [key: string]: MongoValue | Query } & { _id?: Id, $in?: MongoValue[] }
767
+ type MongoQuery<T extends MongoObject> = { [K in keyof T]?: T[K] | MongoQuerySelector<T[K]> } & { _id?: MongoId }
768
768
  type Projection = Record<string, boolean | 0 | 1>
769
769
 
770
- type MongoCommand = MongoCommandValue & Partial<
771
- { $set: Record<string, MongoCommandValue>, $push: Record<string, MongoCommandValue>, $unset: Record<string, ""> }
772
- >
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>
773
813
 
774
- type Id = string | number | boolean | Date | Record<string, MongoValue>
775
- type MongoDocument = { [key: string]: MongoValue, _id: Id }
776
814
  type SortOrder = { [key: string]: 1 | -1 | SortOrder }
777
815
 
778
- type Cursor = {
779
- /** Returns the first document that satisfies the query. */ first: () => MongoDocument | null
780
- /** 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[]
781
819
  /** Returns the number of documents that match the query. */ count: () => number
782
820
 
783
821
  /** Returns the first document that satisfies the query. Also makes cursor unusable. */
784
- first_and_close: () => MongoDocument
822
+ first_and_close: () => T
785
823
 
786
824
  /** Returns an array of documents that satisfy the query. Also makes cursor unusable. */
787
- array_and_close: () => MongoDocument[]
825
+ array_and_close: () => T[]
788
826
 
789
827
  /** Returns the number of documents that match the query. Also makes cursor unusable. */
790
828
  count_and_close: () => number
791
829
 
792
830
  /** Run `callback` on each document that satisfied the query. */
793
- each: (callback: (document: MongoDocument) => void) => null
831
+ each: (callback: (document: T) => void) => null
794
832
 
795
833
  /** Returns a new cursor with documents sorted as specified.
796
834
  * A value of 1 sorts the property ascending, and -1 descending.
797
835
  * @param order The way the documents are to be sorted. */
798
- sort: (order?: SortOrder) => Cursor
836
+ sort: (order?: SortOrder) => Cursor<T>
799
837
 
800
838
  /** Returns a new cursor without the first number of documents.
801
839
  * @param count Number of documents to skip. */
802
- skip: (count: number) => Cursor
840
+ skip: (count: number) => Cursor<T>
803
841
 
804
842
  /** Returns a new cursor limited to a number of documents as specified.
805
843
  * @param count Number of documents. */
806
- limit: (count: number) => Cursor
844
+ limit: (count: number) => Cursor<T>
807
845
 
808
- /** @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[] }
809
847
  /** Make cursor unusable. */ close: () => null
810
848
  NumberLong: (number: number) => number
849
+ // TODO what actually is the type here?
811
850
  ObjectId: () => any
812
851
  }
813
852
 
@@ -818,7 +857,9 @@ type CliContext = {
818
857
  /** The number of rows in the caller’s terminal. */ rows: number
819
858
 
820
859
  /** The name of the script that directly called this script, or null if called on the command line or as a
821
- * scriptor. */ calling_script: null
860
+ * scriptor. */
861
+ calling_script: null
862
+
822
863
  is_scriptor?: undefined
823
864
  is_brain?: undefined
824
865
  }
@@ -829,12 +870,8 @@ type SubscriptContext = Replace<CliContext, {
829
870
  calling_script: string
830
871
  }>
831
872
 
832
- type ScriptorContext =
833
- Replace<CliContext, { /** Whether the script is being run as a scriptor. */ is_scriptor: true }>
834
-
835
- type BrainContext =
836
- Replace<CliContext, { /** Whether the script is being run via a bot brain. */ is_brain: true }>
837
-
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 }>
838
875
  type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
839
876
 
840
877
  /** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
@@ -871,8 +908,8 @@ declare const $0s: typeof $ns
871
908
 
872
909
  /** Subscript space that can call any script. Uses seclevel provided in comment before script (defaults to NULLSEC)
873
910
  * @example
874
- * // @ seclevel MIDSEC
875
- * // 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"
876
913
  * export function script() {
877
914
  * $s.foo.bar() // will be converted to #ms.foo.bar()
878
915
  * } */
@@ -880,99 +917,65 @@ declare const $s: Nullsec
880
917
 
881
918
  type ObjectId = { $oid: string }
882
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
+
883
938
  declare const $db: {
884
939
  /** Insert a document or documents into a collection.
885
940
  * @param documents A document or array of documents to insert into the collection. */
886
- i: (documents: object | object[]) => {
887
- ok: 1
888
- n: number
889
- opTime: { ts: "Undefined Conversion", t: number }
890
- electionId: "Undefined Conversion"
891
- operationTime: "Undefined Conversion"
892
- $clusterTime: {
893
- clusterTime: "Undefined Conversion"
894
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
895
- }
896
- }
941
+ i: <T extends MongoDocument>(documents: (T & { _id?: MongoId }) | (T & { _id?: MongoId })[]) =>
942
+ { n: number, opTime: { t: number }, ok: 0 | 1 }[]
897
943
 
898
944
  /** Remove documents from a collection.
899
945
  * @param query Specifies deletion criteria using query operators. */
900
- r: (query: Query) => {
901
- ok: 0 | 1
902
- n: number
903
- opTime: { ts: "Undefined Conversion", t: number }
904
- electionId: "Undefined Conversion"
905
- operationTime: "Undefined Conversion"
906
- $clusterTime: {
907
- clusterTime: "Undefined Conversion"
908
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
909
- }
910
- }
946
+ r: <T extends MongoDocument>(query: MongoQuery<T>) => { n: number, opTime: { t: number }, ok: 0 | 1 }[]
911
947
 
912
948
  /** Find documents in a collection or view and returns a cursor to the selected documents.
913
949
  * @param query Specifies deletion criteria using query operators.
914
950
  * @param projection Specifies the fields to return in the documents that match the query filter. */
915
- 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>>
916
955
 
917
- /** Update an existing documents in a collection.
956
+ /** Update existing documents in a collection.
918
957
  * @param query Specifies deletion criteria using query operators.
919
958
  * @param command The modifications to apply.
920
959
  * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
921
- u: (query: Query | Query[], command: MongoCommand) => {
922
- ok: 0 | 1
923
- nModified: number
924
- n: number
925
- opTime: { ts: "Undefined Conversion", t: number }
926
- electionId: "Undefined Conversion"
927
- operationTime: "Undefined Conversion"
928
- $clusterTime: {
929
- clusterTime: "Undefined Conversion"
930
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
931
- }
932
- }
960
+ u: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
961
+ { n: number, opTime: { t: number }, ok: 0 | 1, nModified: number }[]
933
962
 
934
963
  /** Updates one document within the collection based on the filter.
935
964
  * @param query Specifies deletion criteria using query operators.
936
965
  * @param command The modifications to apply.
937
966
  * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
938
- u1: (query: Query | Query[], command: MongoCommand) => {
939
- ok: 0 | 1
940
- nModified: number
941
- n: number
942
- opTime: {
943
- ts: "Undefined Conversion"
944
- t: number
945
- }
946
- electionId: "Undefined Conversion"
947
- operationTime: "Undefined Conversion"
948
- $clusterTime: {
949
- clusterTime: "Undefined Conversion"
950
- signature: {
951
- hash: "Undefined Conversion"
952
- keyId: "Undefined Conversion"
953
- }
954
- }
955
- }
967
+ u1: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
968
+ { n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
956
969
 
957
- /** Update or insert or insert document.
970
+ /** Update or insert document.
958
971
  * Same as Update, but if no documents match the query, one document will be inserted based on the properties in
959
972
  * both the query and the command.
960
973
  * The `$setOnInsert` operator is useful to set defaults.
961
974
  * @param query Specifies deletion criteria using query operators.
962
975
  * @param command The modifications to apply.
963
976
  * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
964
- us: (query: Query | Query[], command: MongoCommand) => {
965
- ok: 0 | 1
966
- nModified: number
967
- n: number
968
- opTime: { ts: "Undefined Conversion", t: number }
969
- electionId: "Undefined Conversion"
970
- operationTime: "Undefined Conversion"
971
- $clusterTime: {
972
- clusterTime: "Undefined Conversion"
973
- signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
974
- }
975
- }
977
+ us: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
978
+ { n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
976
979
 
977
980
  ObjectId: () => ObjectId
978
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-459d480",
3
+ "version": "0.20.4-52a588b",
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'