hackmud-script-manager 0.20.4-0e584dd → 0.20.4-1581594
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/bin/hsm.js +178 -233
- package/env.d.ts +104 -23
- package/generateTypeDeclaration.js +2 -1
- package/index.js +1 -0
- package/package.json +6 -2
- package/processScript/index.js +1 -1
- package/processScript/minify.js +18 -21
- package/processScript/postprocess.d.ts +1 -1
- package/processScript/postprocess.js +3 -3
- package/processScript/preprocess.js +5 -3
- package/processScript/transform.js +53 -40
- package/push.d.ts +9 -1
- package/push.js +33 -11
- package/watch.js +1 -0
package/env.d.ts
CHANGED
@@ -1,9 +1,16 @@
|
|
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
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
|
+
}
|
13
|
+
|
7
14
|
type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
|
8
15
|
accts: ErrorScripts
|
9
16
|
autos: ErrorScripts
|
@@ -26,23 +33,27 @@ interface PlayerMidsec {}
|
|
26
33
|
interface PlayerLowsec {}
|
27
34
|
interface PlayerNullsec {}
|
28
35
|
|
29
|
-
type
|
36
|
+
type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
|
37
|
+
type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
|
38
|
+
type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
|
39
|
+
|
40
|
+
type UpgradeBase = {
|
30
41
|
name: string
|
31
42
|
type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
|
32
43
|
up_class?: -1 | 0 | 1 | 2 | 3
|
33
44
|
tier: 1 | 2 | 3 | 4
|
34
|
-
rarity:
|
45
|
+
rarity: UpgradeRarityNumber
|
35
46
|
i: number
|
36
47
|
loaded: boolean
|
37
48
|
sn: string
|
38
49
|
description: string
|
39
50
|
}
|
40
51
|
|
41
|
-
type Upgrade =
|
52
|
+
type Upgrade = UpgradeBase & Record<string, null | boolean | number | string>
|
42
53
|
|
43
|
-
type
|
54
|
+
type CliUpgrade = Omit<UpgradeBase, `rarity`> & {
|
44
55
|
[x: string]: null | boolean | number | string
|
45
|
-
rarity:
|
56
|
+
rarity: UpgradeRarityString
|
46
57
|
}
|
47
58
|
|
48
59
|
type UsersTopItem<R> = { rank: R, name: string, last_activity: string, balance: string }
|
@@ -140,7 +151,16 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
140
151
|
market: {
|
141
152
|
/** **FULLSEC** */ browse: {
|
142
153
|
(args:
|
143
|
-
{
|
154
|
+
Partial<{
|
155
|
+
seller: string | MongoQuerySelector<string>,
|
156
|
+
listed_before: number | MongoQuerySelector<number>,
|
157
|
+
listed_after: number,
|
158
|
+
cost: number | MongoQuerySelector<number> | string,
|
159
|
+
rarity: UpgradeRarityNumber | MongoQuerySelector<UpgradeRarityNumber>,
|
160
|
+
name: string | MongoQuerySelector<string>
|
161
|
+
} & Omit<{
|
162
|
+
[k in keyof CliUpgrade]: CliUpgrade[k] | MongoQuerySelector<CliUpgrade[k]>
|
163
|
+
}, "rarity">>
|
144
164
|
): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
|
145
165
|
|
146
166
|
<I extends string>(args: { i: I }): {
|
@@ -342,7 +362,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
342
362
|
* const arr = [ 1, 2, 2, 3, 2 ]
|
343
363
|
*
|
344
364
|
* $D(uniq(arr)) // [ 1, 2, 3, 2 ] */
|
345
|
-
uniq: (array: T[]) => T[]
|
365
|
+
uniq: <T>(array: T[]) => T[]
|
346
366
|
|
347
367
|
/** Sorts an array of numbers or number-coercible strings in descending order. */
|
348
368
|
u_sort_num_arr_desc: <T>(array: T[]) => T[]
|
@@ -409,17 +429,17 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
409
429
|
upgrades_of_owner: {
|
410
430
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: { filter?: F, full?: false }): (
|
411
431
|
Omit<
|
412
|
-
Pick<
|
432
|
+
Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
|
413
433
|
keyof F
|
414
434
|
> & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
|
415
435
|
)[] | ScriptFailure
|
416
436
|
|
417
437
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args: { filter?: F, full: true }): (
|
418
|
-
Omit<
|
438
|
+
Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>
|
419
439
|
)[] | ScriptFailure
|
420
440
|
|
421
441
|
<I extends number>(args: { i: I }): (
|
422
|
-
Omit<
|
442
|
+
Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
423
443
|
) | ScriptFailure
|
424
444
|
}
|
425
445
|
|
@@ -496,7 +516,7 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
496
516
|
/** **HIGHSEC** */
|
497
517
|
upgrades: {
|
498
518
|
<I extends number>(args: { i: I }): (
|
499
|
-
Omit<
|
519
|
+
Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
500
520
|
) | ScriptFailure
|
501
521
|
|
502
522
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: {
|
@@ -504,22 +524,22 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
504
524
|
is_script?: true
|
505
525
|
full?: false
|
506
526
|
}): (
|
507
|
-
Omit<Pick<
|
527
|
+
Omit<Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">, keyof F> & F &
|
508
528
|
Record<string, null | boolean | number | string>
|
509
529
|
)[] | ScriptFailure
|
510
530
|
|
511
531
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?:
|
512
532
|
{ filter?: F, is_script?: true, full: true }
|
513
|
-
): (Omit<
|
533
|
+
): (Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>)[] | ScriptFailure
|
514
534
|
|
515
535
|
(args?: { filter?: Partial<Upgrade & { loaded: boolean }>, is_script: false, full?: false }):
|
516
536
|
{ msg: string, upgrades: string[] } | ScriptFailure
|
517
537
|
|
518
538
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(
|
519
539
|
args?: { filter?: F, is_script: false, full: true }
|
520
|
-
): (Omit<
|
540
|
+
): (Omit<UpgradeBase, keyof F | `rarity`> & F & {
|
521
541
|
[x: string]: null | boolean | number | string
|
522
|
-
rarity:
|
542
|
+
rarity: UpgradeRarityString
|
523
543
|
})[] | ScriptFailure
|
524
544
|
}
|
525
545
|
}
|
@@ -699,10 +719,50 @@ type Nullsec = Lowsec & PlayerNullsec & {
|
|
699
719
|
}
|
700
720
|
}
|
701
721
|
|
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
|
+
|
702
726
|
type MongoValue = string | number | boolean | Date | MongoValue[] | { [key: string]: MongoValue } | null
|
703
727
|
|
704
728
|
type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | { [key: string]: MongoCommandValue } |
|
705
|
-
|
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[]
|
739
|
+
}
|
740
|
+
|
741
|
+
type MongoArraySelectors<T extends Array<MongoValue> = Array<MongoValue>> = {
|
742
|
+
$all: T
|
743
|
+
$elemMatch: T
|
744
|
+
$size: number
|
745
|
+
}
|
746
|
+
|
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
|
+
}
|
757
|
+
|
758
|
+
type MongoElementSelectors = {
|
759
|
+
$exists: boolean
|
760
|
+
$type: MongoTypeNumber | MongoTypeString
|
761
|
+
}
|
762
|
+
|
763
|
+
type MongoQuerySelector<T extends MongoValue = MongoValue> = Partial<T extends MongoValue[] ?
|
764
|
+
(MongoArraySelectors<T> & MongoElementSelectors & MongoComparisonSelectors<T>) :
|
765
|
+
(MongoElementSelectors & MongoComparisonSelectors<T>)>
|
706
766
|
|
707
767
|
type Query = { [key: string]: MongoValue | Query } & { _id?: Id, $in?: MongoValue[] }
|
708
768
|
type Projection = Record<string, boolean | 0 | 1>
|
@@ -751,7 +811,7 @@ type Cursor = {
|
|
751
811
|
ObjectId: () => any
|
752
812
|
}
|
753
813
|
|
754
|
-
type
|
814
|
+
type CliContext = {
|
755
815
|
/** The name of the user who is calling the script. */ caller: string
|
756
816
|
/** The name of this script. */ this_script: string
|
757
817
|
/** The number of columns in the caller’s terminal. */ cols: number
|
@@ -759,17 +819,23 @@ type CLIContext = {
|
|
759
819
|
|
760
820
|
/** The name of the script that directly called this script, or null if called on the command line or as a
|
761
821
|
* scriptor. */ calling_script: null
|
822
|
+
is_scriptor?: undefined
|
823
|
+
is_brain?: undefined
|
762
824
|
}
|
763
825
|
|
764
|
-
type SubscriptContext = Replace<
|
826
|
+
type SubscriptContext = Replace<CliContext, {
|
765
827
|
/** The name of the script that directly called this script, or null if called on the command line or as a scriptor.
|
766
828
|
*/
|
767
829
|
calling_script: string
|
768
830
|
}>
|
769
831
|
|
770
|
-
type ScriptorContext =
|
771
|
-
|
772
|
-
|
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
|
+
|
838
|
+
type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
|
773
839
|
|
774
840
|
/** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
|
775
841
|
|
@@ -812,6 +878,8 @@ declare const $0s: typeof $ns
|
|
812
878
|
* } */
|
813
879
|
declare const $s: Nullsec
|
814
880
|
|
881
|
+
type ObjectId = { $oid: string }
|
882
|
+
|
815
883
|
declare const $db: {
|
816
884
|
/** Insert a document or documents into a collection.
|
817
885
|
* @param documents A document or array of documents to insert into the collection. */
|
@@ -905,6 +973,8 @@ declare const $db: {
|
|
905
973
|
signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
|
906
974
|
}
|
907
975
|
}
|
976
|
+
|
977
|
+
ObjectId: () => ObjectId
|
908
978
|
}
|
909
979
|
|
910
980
|
/** Debug Log.
|
@@ -941,7 +1011,7 @@ declare const $FMCL: undefined | true
|
|
941
1011
|
* @example
|
942
1012
|
* if (!$G.dbCache)
|
943
1013
|
* $G.dbCache = $db.f({ whatever: true }).first() */
|
944
|
-
declare const $G: any
|
1014
|
+
declare const $G: Record<string | symbol, any>
|
945
1015
|
|
946
1016
|
/** This contains a JS timestamp (not Date) set immediately before your code begins running.
|
947
1017
|
* @example
|
@@ -990,3 +1060,14 @@ declare const _FULL_SCRIPT_NAME: string
|
|
990
1060
|
*
|
991
1061
|
* In rare cases where it's not known at build time, it's `-1`. */
|
992
1062
|
declare const _SECLEVEL: -1 | 0 | 1 | 2 | 3 | 4
|
1063
|
+
|
1064
|
+
type DeepFreeze<T> = { readonly [P in keyof T]: DeepFreeze<T[P]> }
|
1065
|
+
|
1066
|
+
/** Recursively
|
1067
|
+
* [`Object.freeze()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
|
1068
|
+
* an object and its properties' objects and its properties' objects and so on.
|
1069
|
+
*
|
1070
|
+
* [Official Hackmud Wiki](https://wiki.hackmud.com/scripting/extensions/deep_freeze) */
|
1071
|
+
declare const DEEP_FREEZE: <T>(value: T) => DeepFreeze<T>
|
1072
|
+
|
1073
|
+
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
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hackmud-script-manager",
|
3
|
-
"version": "0.20.4-
|
3
|
+
"version": "0.20.4-1581594",
|
4
4
|
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
5
5
|
"keywords": [
|
6
6
|
"api",
|
@@ -20,7 +20,11 @@
|
|
20
20
|
"homepage": "https://github.com/samualtnorman/hackmud-script-manager#readme",
|
21
21
|
"bugs": "https://github.com/samualtnorman/hackmud-script-manager/issues",
|
22
22
|
"license": "MIT",
|
23
|
-
"author": "Samual Norman",
|
23
|
+
"author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
|
24
|
+
"contributors": [
|
25
|
+
"Daniel Swann (https://github.com/danswann)",
|
26
|
+
"Longboyy"
|
27
|
+
],
|
24
28
|
"main": "index.js",
|
25
29
|
"repository": {
|
26
30
|
"type": "git",
|
package/processScript/index.js
CHANGED
@@ -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)
|
@@ -220,8 +212,10 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
220
212
|
)
|
221
213
|
},
|
222
214
|
StringLiteral(path) {
|
223
|
-
path.node.value
|
224
|
-
|
215
|
+
if (JSON.stringify(path.node.value).includes("\\u00") || path.toString().length < 4) {
|
216
|
+
path.node.value = replaceUnsafeStrings(uniqueId, path.node.value)
|
217
|
+
return
|
218
|
+
}
|
225
219
|
"key" == path.parentKey && "ObjectProperty" == path.parent.type && (path.parent.computed = !0)
|
226
220
|
let jsonValueIndex = jsonValues.indexOf(path.node.value)
|
227
221
|
;-1 == jsonValueIndex && (jsonValueIndex += jsonValues.push(path.node.value))
|
@@ -244,7 +238,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
244
238
|
})
|
245
239
|
await Promise.all(promises)
|
246
240
|
const functionDeclaration = file.program.body[0]
|
247
|
-
assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:
|
241
|
+
assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:354:61")
|
248
242
|
if (jsonValues.length) {
|
249
243
|
hasComment = !0
|
250
244
|
if (1 == jsonValues.length)
|
@@ -256,7 +250,10 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
256
250
|
t.memberExpression(
|
257
251
|
t.taggedTemplateExpression(
|
258
252
|
t.memberExpression(
|
259
|
-
t.callExpression(
|
253
|
+
t.callExpression(
|
254
|
+
t.identifier(`$${uniqueId}$4$SUBSCRIPT$scripts$quine$`),
|
255
|
+
[]
|
256
|
+
),
|
260
257
|
t.identifier("split")
|
261
258
|
),
|
262
259
|
t.templateLiteral([t.templateElement({ raw: "\t", cooked: "\t" }, !0)], [])
|
@@ -280,7 +277,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
280
277
|
t.memberExpression(
|
281
278
|
t.taggedTemplateExpression(
|
282
279
|
t.memberExpression(
|
283
|
-
t.callExpression(t.identifier(`$${uniqueId}$SUBSCRIPT$scripts$quine$`), []),
|
280
|
+
t.callExpression(t.identifier(`$${uniqueId}$4$SUBSCRIPT$scripts$quine$`), []),
|
284
281
|
t.identifier("split")
|
285
282
|
),
|
286
283
|
t.templateLiteral([t.templateElement({ raw: "\t", cooked: "\t" }, !0)], [])
|
@@ -305,7 +302,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
305
302
|
t.memberExpression(
|
306
303
|
t.taggedTemplateExpression(
|
307
304
|
t.memberExpression(
|
308
|
-
t.callExpression(t.identifier(`$${uniqueId}$SUBSCRIPT$scripts$quine$`), []),
|
305
|
+
t.callExpression(t.identifier(`$${uniqueId}$4$SUBSCRIPT$scripts$quine$`), []),
|
309
306
|
t.identifier("split")
|
310
307
|
),
|
311
308
|
t.templateLiteral([t.templateElement({ raw: "\t", cooked: "\t" }, !0)], [])
|
@@ -361,7 +358,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
|
|
361
358
|
)
|
362
359
|
}
|
363
360
|
if (1 == forceQuineCheats) return code
|
364
|
-
assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:
|
361
|
+
assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:485:43")
|
365
362
|
return (
|
366
363
|
countHackmudCharacters(scriptBeforeJSONValueReplacement) <=
|
367
364
|
countHackmudCharacters(code) + Number(hasComment)
|
@@ -377,7 +374,7 @@ function parseObjectExpression(node, o) {
|
|
377
374
|
"Identifier" == property.key.type ||
|
378
375
|
"NumericLiteral" == property.key.type ||
|
379
376
|
"StringLiteral" == property.key.type,
|
380
|
-
"src/processScript/minify.ts:
|
377
|
+
"src/processScript/minify.ts:507:4"
|
381
378
|
)
|
382
379
|
if ("ArrayExpression" == property.value.type) {
|
383
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 }
|