hackmud-script-manager 0.20.4-c524114 → 0.20.4-cf7622f
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -0
- package/bin/hsm.js +192 -235
- package/env.d.ts +94 -31
- package/generateTypeDeclaration.js +2 -1
- package/index.js +1 -0
- package/package.json +1 -1
- package/processScript/index.js +3 -3
- package/processScript/minify.js +14 -19
- package/processScript/postprocess.d.ts +1 -1
- package/processScript/postprocess.js +3 -3
- package/processScript/preprocess.js +5 -3
- package/processScript/transform.js +68 -91
- package/push.d.ts +9 -1
- package/push.js +33 -11
- package/watch.js +6 -4
package/env.d.ts
CHANGED
@@ -1,19 +1,9 @@
|
|
1
|
-
type Replace<
|
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
|
-
|
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
|
-
}
|
6
|
+
type Scriptor<TArgs extends any[] = any[]> = { name: string, call: (...args: TArgs) => unknown }
|
17
7
|
|
18
8
|
type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
|
19
9
|
accts: ErrorScripts
|
@@ -41,7 +31,7 @@ type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`"
|
|
41
31
|
type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
|
42
32
|
type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
|
43
33
|
|
44
|
-
type
|
34
|
+
type UpgradeBase = {
|
45
35
|
name: string
|
46
36
|
type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
|
47
37
|
up_class?: -1 | 0 | 1 | 2 | 3
|
@@ -53,9 +43,9 @@ type UpgradeCore = {
|
|
53
43
|
description: string
|
54
44
|
}
|
55
45
|
|
56
|
-
type Upgrade =
|
46
|
+
type Upgrade = UpgradeBase & Record<string, null | boolean | number | string>
|
57
47
|
|
58
|
-
type
|
48
|
+
type CliUpgrade = Omit<UpgradeBase, `rarity`> & {
|
59
49
|
[x: string]: null | boolean | number | string
|
60
50
|
rarity: UpgradeRarityString
|
61
51
|
}
|
@@ -155,7 +145,16 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
155
145
|
market: {
|
156
146
|
/** **FULLSEC** */ browse: {
|
157
147
|
(args:
|
158
|
-
Partial<{
|
148
|
+
Partial<{
|
149
|
+
seller: string | MongoQuerySelector<string>,
|
150
|
+
listed_before: number | MongoQuerySelector<number>,
|
151
|
+
listed_after: number,
|
152
|
+
cost: number | MongoQuerySelector<number> | string,
|
153
|
+
rarity: UpgradeRarityNumber | MongoQuerySelector<UpgradeRarityNumber>,
|
154
|
+
name: string | MongoQuerySelector<string>
|
155
|
+
} & Omit<{
|
156
|
+
[k in keyof CliUpgrade]: CliUpgrade[k] | MongoQuerySelector<CliUpgrade[k]>
|
157
|
+
}, "rarity">>
|
159
158
|
): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
|
160
159
|
|
161
160
|
<I extends string>(args: { i: I }): {
|
@@ -357,7 +356,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
357
356
|
* const arr = [ 1, 2, 2, 3, 2 ]
|
358
357
|
*
|
359
358
|
* $D(uniq(arr)) // [ 1, 2, 3, 2 ] */
|
360
|
-
uniq: (array: T[]) => T[]
|
359
|
+
uniq: <T>(array: T[]) => T[]
|
361
360
|
|
362
361
|
/** Sorts an array of numbers or number-coercible strings in descending order. */
|
363
362
|
u_sort_num_arr_desc: <T>(array: T[]) => T[]
|
@@ -424,17 +423,17 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
424
423
|
upgrades_of_owner: {
|
425
424
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: { filter?: F, full?: false }): (
|
426
425
|
Omit<
|
427
|
-
Pick<
|
426
|
+
Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
|
428
427
|
keyof F
|
429
428
|
> & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
|
430
429
|
)[] | ScriptFailure
|
431
430
|
|
432
431
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args: { filter?: F, full: true }): (
|
433
|
-
Omit<
|
432
|
+
Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>
|
434
433
|
)[] | ScriptFailure
|
435
434
|
|
436
435
|
<I extends number>(args: { i: I }): (
|
437
|
-
Omit<
|
436
|
+
Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
438
437
|
) | ScriptFailure
|
439
438
|
}
|
440
439
|
|
@@ -511,7 +510,7 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
511
510
|
/** **HIGHSEC** */
|
512
511
|
upgrades: {
|
513
512
|
<I extends number>(args: { i: I }): (
|
514
|
-
Omit<
|
513
|
+
Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
515
514
|
) | ScriptFailure
|
516
515
|
|
517
516
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: {
|
@@ -519,20 +518,20 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
519
518
|
is_script?: true
|
520
519
|
full?: false
|
521
520
|
}): (
|
522
|
-
Omit<Pick<
|
521
|
+
Omit<Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">, keyof F> & F &
|
523
522
|
Record<string, null | boolean | number | string>
|
524
523
|
)[] | ScriptFailure
|
525
524
|
|
526
525
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?:
|
527
526
|
{ filter?: F, is_script?: true, full: true }
|
528
|
-
): (Omit<
|
527
|
+
): (Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>)[] | ScriptFailure
|
529
528
|
|
530
529
|
(args?: { filter?: Partial<Upgrade & { loaded: boolean }>, is_script: false, full?: false }):
|
531
530
|
{ msg: string, upgrades: string[] } | ScriptFailure
|
532
531
|
|
533
532
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(
|
534
533
|
args?: { filter?: F, is_script: false, full: true }
|
535
|
-
): (Omit<
|
534
|
+
): (Omit<UpgradeBase, keyof F | `rarity`> & F & {
|
536
535
|
[x: string]: null | boolean | number | string
|
537
536
|
rarity: UpgradeRarityString
|
538
537
|
})[] | ScriptFailure
|
@@ -630,6 +629,9 @@ type Lowsec = Midsec & PlayerLowsec & {
|
|
630
629
|
(args: { i: number | number[], to: string, memo?: string }): ScriptResponse
|
631
630
|
(args: { sn: string | string[], to: string, memo?: string }): ScriptResponse
|
632
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
|
633
635
|
}
|
634
636
|
}
|
635
637
|
|
@@ -714,10 +716,50 @@ type Nullsec = Lowsec & PlayerNullsec & {
|
|
714
716
|
}
|
715
717
|
}
|
716
718
|
|
719
|
+
type MongoTypeString = "minKey" | "double" | "string" | "object" | "array" | "binData" | "undefined" | "objectId" |
|
720
|
+
"bool" | "date" | "null" | "regex" | "dbPointer" | "javascript" | "symbol" | "int" | "timestamp" | "long" | "decimal" | "maxKey";
|
721
|
+
type MongoTypeNumber = -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 127;
|
722
|
+
|
717
723
|
type MongoValue = string | number | boolean | Date | MongoValue[] | { [key: string]: MongoValue } | null
|
718
724
|
|
719
725
|
type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | { [key: string]: MongoCommandValue } |
|
720
|
-
|
726
|
+
null | undefined
|
727
|
+
|
728
|
+
/**
|
729
|
+
* Currently unused
|
730
|
+
*/
|
731
|
+
type MongoLogicalSelectors<T extends MongoValue = MongoValue> = {
|
732
|
+
$not: T | MongoComparisonSelectors<T> | MongoLogicalSelectors<T>
|
733
|
+
$nor: T[]
|
734
|
+
$or: T[]
|
735
|
+
$and: T[]
|
736
|
+
}
|
737
|
+
|
738
|
+
type MongoArraySelectors<T extends Array<MongoValue> = Array<MongoValue>> = {
|
739
|
+
$all: T
|
740
|
+
$elemMatch: T
|
741
|
+
$size: number
|
742
|
+
}
|
743
|
+
|
744
|
+
type MongoComparisonSelectors<T extends MongoValue = MongoValue> = {
|
745
|
+
$eq: T
|
746
|
+
$gt: T
|
747
|
+
$gte: T
|
748
|
+
$in: T[]
|
749
|
+
$lt: T
|
750
|
+
$lte: T
|
751
|
+
$ne: T
|
752
|
+
$nin: T[]
|
753
|
+
}
|
754
|
+
|
755
|
+
type MongoElementSelectors = {
|
756
|
+
$exists: boolean
|
757
|
+
$type: MongoTypeNumber | MongoTypeString
|
758
|
+
}
|
759
|
+
|
760
|
+
type MongoQuerySelector<T extends MongoValue = MongoValue> = Partial<T extends MongoValue[] ?
|
761
|
+
(MongoArraySelectors<T> & MongoElementSelectors & MongoComparisonSelectors<T>) :
|
762
|
+
(MongoElementSelectors & MongoComparisonSelectors<T>)>
|
721
763
|
|
722
764
|
type Query = { [key: string]: MongoValue | Query } & { _id?: Id, $in?: MongoValue[] }
|
723
765
|
type Projection = Record<string, boolean | 0 | 1>
|
@@ -766,7 +808,7 @@ type Cursor = {
|
|
766
808
|
ObjectId: () => any
|
767
809
|
}
|
768
810
|
|
769
|
-
type
|
811
|
+
type CliContext = {
|
770
812
|
/** The name of the user who is calling the script. */ caller: string
|
771
813
|
/** The name of this script. */ this_script: string
|
772
814
|
/** The number of columns in the caller’s terminal. */ cols: number
|
@@ -774,17 +816,23 @@ type CLIContext = {
|
|
774
816
|
|
775
817
|
/** The name of the script that directly called this script, or null if called on the command line or as a
|
776
818
|
* scriptor. */ calling_script: null
|
819
|
+
is_scriptor?: undefined
|
820
|
+
is_brain?: undefined
|
777
821
|
}
|
778
822
|
|
779
|
-
type SubscriptContext = Replace<
|
823
|
+
type SubscriptContext = Replace<CliContext, {
|
780
824
|
/** The name of the script that directly called this script, or null if called on the command line or as a scriptor.
|
781
825
|
*/
|
782
826
|
calling_script: string
|
783
827
|
}>
|
784
828
|
|
785
|
-
type ScriptorContext =
|
786
|
-
|
787
|
-
|
829
|
+
type ScriptorContext =
|
830
|
+
Replace<CliContext, { /** Whether the script is being run as a scriptor. */ is_scriptor: true }>
|
831
|
+
|
832
|
+
type BrainContext =
|
833
|
+
Replace<CliContext, { /** Whether the script is being run via a bot brain. */ is_brain: true }>
|
834
|
+
|
835
|
+
type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
|
788
836
|
|
789
837
|
/** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
|
790
838
|
|
@@ -827,6 +875,8 @@ declare const $0s: typeof $ns
|
|
827
875
|
* } */
|
828
876
|
declare const $s: Nullsec
|
829
877
|
|
878
|
+
type ObjectId = { $oid: string }
|
879
|
+
|
830
880
|
declare const $db: {
|
831
881
|
/** Insert a document or documents into a collection.
|
832
882
|
* @param documents A document or array of documents to insert into the collection. */
|
@@ -920,6 +970,8 @@ declare const $db: {
|
|
920
970
|
signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
|
921
971
|
}
|
922
972
|
}
|
973
|
+
|
974
|
+
ObjectId: () => ObjectId
|
923
975
|
}
|
924
976
|
|
925
977
|
/** Debug Log.
|
@@ -956,7 +1008,7 @@ declare const $FMCL: undefined | true
|
|
956
1008
|
* @example
|
957
1009
|
* if (!$G.dbCache)
|
958
1010
|
* $G.dbCache = $db.f({ whatever: true }).first() */
|
959
|
-
declare const $G: any
|
1011
|
+
declare const $G: Record<string | symbol, any>
|
960
1012
|
|
961
1013
|
/** This contains a JS timestamp (not Date) set immediately before your code begins running.
|
962
1014
|
* @example
|
@@ -1005,3 +1057,14 @@ declare const _FULL_SCRIPT_NAME: string
|
|
1005
1057
|
*
|
1006
1058
|
* In rare cases where it's not known at build time, it's `-1`. */
|
1007
1059
|
declare const _SECLEVEL: -1 | 0 | 1 | 2 | 3 | 4
|
1060
|
+
|
1061
|
+
type DeepFreeze<T> = { readonly [P in keyof T]: DeepFreeze<T[P]> }
|
1062
|
+
|
1063
|
+
/** Recursively
|
1064
|
+
* [`Object.freeze()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
|
1065
|
+
* an object and its properties' objects and its properties' objects and so on.
|
1066
|
+
*
|
1067
|
+
* [Official Hackmud Wiki](https://wiki.hackmud.com/scripting/extensions/deep_freeze) */
|
1068
|
+
declare const DEEP_FREEZE: <T>(value: T) => DeepFreeze<T>
|
1069
|
+
|
1070
|
+
declare const _RUN_ID: string
|
@@ -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"
|
package/package.json
CHANGED
package/processScript/index.js
CHANGED
@@ -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,
|
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'
|
package/processScript/minify.js
CHANGED
@@ -43,15 +43,6 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
43
43
|
)
|
44
44
|
}
|
45
45
|
}
|
46
|
-
const hashGReferencePaths = getReferencePathsToGlobal(`$${uniqueId}$GLOBAL$`, program)
|
47
|
-
if (hashGReferencePaths.length > 3) {
|
48
|
-
for (const path of hashGReferencePaths) path.replaceWith(t.identifier(`_${uniqueId}_G_`))
|
49
|
-
mainFunctionPath.node.body.body.unshift(
|
50
|
-
t.variableDeclaration("let", [
|
51
|
-
t.variableDeclarator(t.identifier(`_${uniqueId}_G_`), t.identifier(`$${uniqueId}$GLOBAL$`))
|
52
|
-
])
|
53
|
-
)
|
54
|
-
}
|
55
46
|
const jsonValues = []
|
56
47
|
let scriptBeforeJSONValueReplacement,
|
57
48
|
comment,
|
@@ -61,7 +52,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
61
52
|
traverse(fileBeforeJSONValueReplacement, {
|
62
53
|
MemberExpression({ node: memberExpression }) {
|
63
54
|
if (!memberExpression.computed) {
|
64
|
-
assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:
|
55
|
+
assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:115:60")
|
65
56
|
if ("prototype" == memberExpression.property.name) {
|
66
57
|
memberExpression.computed = !0
|
67
58
|
memberExpression.property = t.identifier(`_${uniqueId}_PROTOTYPE_PROPERTY_`)
|
@@ -136,7 +127,8 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
136
127
|
const promises = []
|
137
128
|
traverse(file, {
|
138
129
|
FunctionDeclaration(path) {
|
139
|
-
path.
|
130
|
+
const body = path.get("body")
|
131
|
+
body.traverse({
|
140
132
|
Function(path) {
|
141
133
|
"CallExpression" != path.parent.type && "callee" != path.parentKey && path.skip()
|
142
134
|
},
|
@@ -152,7 +144,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
152
144
|
path.replaceWith(t.identifier(`_${uniqueId}_JSON_VALUE_${jsonValues.push(o) - 1}_`))
|
153
145
|
}
|
154
146
|
})
|
155
|
-
|
147
|
+
body.traverse({
|
156
148
|
TemplateLiteral(path) {
|
157
149
|
if ("TaggedTemplateExpression" == path.parent.type) return
|
158
150
|
const templateLiteral = path.node
|
@@ -172,7 +164,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
172
164
|
},
|
173
165
|
MemberExpression({ node: memberExpression }) {
|
174
166
|
if (!memberExpression.computed) {
|
175
|
-
assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:
|
167
|
+
assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:249:62")
|
176
168
|
if (!(memberExpression.property.name.length < 3)) {
|
177
169
|
memberExpression.computed = !0
|
178
170
|
memberExpression.property = t.stringLiteral(memberExpression.property.name)
|
@@ -246,7 +238,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
246
238
|
})
|
247
239
|
await Promise.all(promises)
|
248
240
|
const functionDeclaration = file.program.body[0]
|
249
|
-
assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:
|
241
|
+
assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:354:61")
|
250
242
|
if (jsonValues.length) {
|
251
243
|
hasComment = !0
|
252
244
|
if (1 == jsonValues.length)
|
@@ -258,7 +250,10 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
258
250
|
t.memberExpression(
|
259
251
|
t.taggedTemplateExpression(
|
260
252
|
t.memberExpression(
|
261
|
-
t.callExpression(
|
253
|
+
t.callExpression(
|
254
|
+
t.identifier(`$${uniqueId}$4$SUBSCRIPT$scripts$quine$`),
|
255
|
+
[]
|
256
|
+
),
|
262
257
|
t.identifier("split")
|
263
258
|
),
|
264
259
|
t.templateLiteral([t.templateElement({ raw: "\t", cooked: "\t" }, !0)], [])
|
@@ -282,7 +277,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
282
277
|
t.memberExpression(
|
283
278
|
t.taggedTemplateExpression(
|
284
279
|
t.memberExpression(
|
285
|
-
t.callExpression(t.identifier(`$${uniqueId}$SUBSCRIPT$scripts$quine$`), []),
|
280
|
+
t.callExpression(t.identifier(`$${uniqueId}$4$SUBSCRIPT$scripts$quine$`), []),
|
286
281
|
t.identifier("split")
|
287
282
|
),
|
288
283
|
t.templateLiteral([t.templateElement({ raw: "\t", cooked: "\t" }, !0)], [])
|
@@ -307,7 +302,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
307
302
|
t.memberExpression(
|
308
303
|
t.taggedTemplateExpression(
|
309
304
|
t.memberExpression(
|
310
|
-
t.callExpression(t.identifier(`$${uniqueId}$SUBSCRIPT$scripts$quine$`), []),
|
305
|
+
t.callExpression(t.identifier(`$${uniqueId}$4$SUBSCRIPT$scripts$quine$`), []),
|
311
306
|
t.identifier("split")
|
312
307
|
),
|
313
308
|
t.templateLiteral([t.templateElement({ raw: "\t", cooked: "\t" }, !0)], [])
|
@@ -363,7 +358,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
363
358
|
)
|
364
359
|
}
|
365
360
|
if (1 == forceQuineCheats) return code
|
366
|
-
assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:
|
361
|
+
assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:485:43")
|
367
362
|
return (
|
368
363
|
countHackmudCharacters(scriptBeforeJSONValueReplacement) <=
|
369
364
|
countHackmudCharacters(code) + Number(hasComment)
|
@@ -379,7 +374,7 @@ function parseObjectExpression(node, o) {
|
|
379
374
|
"Identifier" == property.key.type ||
|
380
375
|
"NumericLiteral" == property.key.type ||
|
381
376
|
"StringLiteral" == property.key.type,
|
382
|
-
"src/processScript/minify.ts:
|
377
|
+
"src/processScript/minify.ts:507:4"
|
383
378
|
)
|
384
379
|
if ("ArrayExpression" == property.value.type) {
|
385
380
|
const childArray = []
|
@@ -1 +1 @@
|
|
1
|
-
export declare const postprocess: (code: string,
|
1
|
+
export declare const postprocess: (code: string, uniqueId: string) => string;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
const postprocess = (code,
|
1
|
+
const postprocess = (code, uniqueId) =>
|
2
2
|
code
|
3
|
-
.replace(/^function\s
|
3
|
+
.replace(/^function\s*[\w$]+\(/, "function(")
|
4
4
|
.replace(RegExp(`\\$${uniqueId}\\$\\\\(?:\\\\)?\\$SC_DOLLAR\\$`, "g"), "S\\C$")
|
5
5
|
.replace(RegExp(`\\$${uniqueId}\\$\\\\(?:\\\\)?\\$DB_DOLLAR\\$`, "g"), "D\\B$")
|
6
6
|
.replace(RegExp(`\\$${uniqueId}\\$\\\\(?:\\\\)?\\$D\\$`, "g"), "_\\_D_S")
|
7
7
|
.replace(RegExp(`\\$${uniqueId}\\$\\\\(?:\\\\)?\\$FMCL\\$`, "g"), "_\\_FMCL_")
|
8
8
|
.replace(RegExp(`\\$${uniqueId}\\$\\\\(?:\\\\)?\\$G\\$`, "g"), "_\\_G_")
|
9
|
-
.replace(RegExp(`\\$${uniqueId}\\$SUBSCRIPT\\$(\\w+)\\$(\\w+)\\$`, "g"),
|
9
|
+
.replace(RegExp(`\\$${uniqueId}\\$(\\d)\\$SUBSCRIPT\\$(\\w+)\\$(\\w+)\\$`, "g"), "#$1s.$2.$3")
|
10
10
|
.replace(RegExp(`\\$${uniqueId}\\$DEBUG\\$`, "g"), "#D")
|
11
11
|
.replace(RegExp(`\\$${uniqueId}\\$FMCL\\$`, "g"), "#FMCL")
|
12
12
|
.replace(RegExp(`\\$${uniqueId}\\$GLOBAL\\$`, "g"), "#G")
|
@@ -98,8 +98,10 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) {
|
|
98
98
|
t.stringLiteral(resolve("proxy-polyfill/src/proxy.js", import.meta.url).slice(7))
|
99
99
|
)
|
100
100
|
)
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
if (1 == program.node.body.length && "FunctionDeclaration" == program.node.body[0].type)
|
102
|
+
throw Error(
|
103
|
+
"Scripts that only contain a single function declaration are no longer supported.\nPrefix the function declaration with `export default`."
|
104
|
+
)
|
105
|
+
return { code: generate(file).code }
|
104
106
|
}
|
105
107
|
export { preprocess }
|