hackmud-script-manager-ng 0.26.5 → 0.26.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/bin/hsm.d.ts +2 -0
  2. package/bin/hsm.js +493 -0
  3. package/constants.d.ts +2 -0
  4. package/constants.js +3 -0
  5. package/generateTypeDeclaration.d.ts +1 -0
  6. package/generateTypeDeclaration.js +70 -0
  7. package/index.d.ts +16 -0
  8. package/index.js +52 -0
  9. package/package.json +3 -22
  10. package/processScript/index.d.ts +34 -0
  11. package/processScript/index.js +362 -0
  12. package/processScript/minify.d.ts +20 -0
  13. package/processScript/minify.js +431 -0
  14. package/processScript/postprocess.d.ts +1 -0
  15. package/processScript/postprocess.js +21 -0
  16. package/processScript/preprocess.d.ts +11 -0
  17. package/processScript/preprocess.js +107 -0
  18. package/processScript/shared.d.ts +5 -0
  19. package/processScript/shared.js +32 -0
  20. package/processScript/transform.d.ts +24 -0
  21. package/processScript/transform.js +803 -0
  22. package/pull.d.ts +7 -0
  23. package/pull.js +11 -0
  24. package/push.d.ts +42 -0
  25. package/push.js +164 -0
  26. package/syncMacros.d.ts +4 -0
  27. package/syncMacros.js +42 -0
  28. package/watch.d.ts +19 -0
  29. package/watch.js +220 -0
  30. package/.envrc +0 -1
  31. package/.github/FUNDING.yml +0 -14
  32. package/.github/workflows/publish.yml +0 -27
  33. package/.github/workflows/test.yml +0 -18
  34. package/.vscode/settings.json +0 -55
  35. package/CONTRIBUTING.md +0 -68
  36. package/eslint.config.js +0 -81
  37. package/game-scripts-tests/array-rest-works.ts +0 -6
  38. package/game-scripts-tests/this_array_in_object.ts +0 -16
  39. package/game-scripts-tests/this_function_array.ts +0 -9
  40. package/game-scripts-tests/this_in_default_argument.ts +0 -35
  41. package/game-scripts-tests/this_in_lambda_in_object.ts +0 -26
  42. package/pnpm-workspace.yaml +0 -2
  43. package/rollup.config.js +0 -69
  44. package/scripts/dev.sh +0 -3
  45. package/scripts/emit-declarations.sh +0 -3
  46. package/scripts/emit-package-json.js +0 -9
  47. package/scripts/lint.sh +0 -5
  48. package/scripts/package.sh +0 -7
  49. package/scripts/update.sh +0 -4
  50. package/scripts/version-dev.js +0 -14
  51. package/src/bin/hsm.ts +0 -754
  52. package/src/constants.ts +0 -2
  53. package/src/env.d.ts +0 -13
  54. package/src/generateTypeDeclaration.ts +0 -119
  55. package/src/index.ts +0 -13
  56. package/src/processScript/__snapshots__/index.ts.snap +0 -8
  57. package/src/processScript/index.ts +0 -474
  58. package/src/processScript/minify.ts +0 -594
  59. package/src/processScript/postprocess.ts +0 -19
  60. package/src/processScript/preprocess.ts +0 -130
  61. package/src/processScript/shared.ts +0 -33
  62. package/src/processScript/transform.ts +0 -978
  63. package/src/pull.ts +0 -20
  64. package/src/push.ts +0 -200
  65. package/src/syncMacros.ts +0 -53
  66. package/src/tsconfig.json +0 -14
  67. package/src/watch.ts +0 -258
  68. package/tsconfig.json +0 -23
  69. package/vitest.config.ts +0 -19
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hackmud-script-manager-ng",
3
3
  "type": "module",
4
- "version": "0.26.5",
4
+ "version": "0.26.6",
5
5
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
6
6
  "author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
7
7
  "contributors": [
@@ -44,10 +44,6 @@
44
44
  "bin": {
45
45
  "hsm": "bin/hsm.js"
46
46
  },
47
- "engines": {
48
- "node": "^18 || >=20",
49
- "pnpm": "^9 || ^10"
50
- },
51
47
  "peerDependencies": {
52
48
  "typescript": "^5.4.5"
53
49
  },
@@ -95,22 +91,7 @@
95
91
  "rollup": "^4.53.1",
96
92
  "terser": "^5.44.1"
97
93
  },
98
- "devDependencies": {
99
- "@antfu/eslint-config": "^6.2.0",
100
- "@babel/plugin-syntax-typescript": "^7.27.1",
101
- "@paralleldrive/cuid2": "^2.2.2",
102
- "@samual/rollup-config": "0.1.3-858c2de",
103
- "@total-typescript/ts-reset": "^0.6.1",
104
- "@types/babel__core": "^7.20.5",
105
- "@types/babel__generator": "^7.27.0",
106
- "@types/babel__traverse": "^7.28.0",
107
- "@types/node": "~24.10.0",
108
- "@types/semver": "^7.7.1",
109
- "babel-plugin-here": "^1.0.2",
110
- "eslint": "^9.39.1",
111
- "eslint-plugin-format": "^1.0.2",
112
- "semver": "^7.7.3",
113
- "typescript": "5.7.3",
114
- "vitest": "^4.0.8"
94
+ "engines": {
95
+ "node": "^18 || >=20"
115
96
  }
116
97
  }
@@ -0,0 +1,34 @@
1
+ import type { LaxPartial } from "@samual/lib";
2
+ export { minify } from "./minify";
3
+ export { postprocess } from "./postprocess";
4
+ export { preprocess } from "./preprocess";
5
+ export { transform } from "./transform";
6
+ export type ProcessOptions = LaxPartial<{
7
+ /** whether to minify the given code */ minify: boolean;
8
+ /** 11 a-z 0-9 characters */ uniqueId: string;
9
+ /** the user going to be hosting this script (or set to `true` if not yet known) */ scriptUser: string | true;
10
+ filePath: string;
11
+ /** whether to mangle function and class names (defaults to `false`) */ mangleNames: boolean;
12
+ /**
13
+ * when set to `true` forces use of quine cheats
14
+ *
15
+ * when set to `false` forces quine cheats not to be used
16
+ *
17
+ * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
18
+ */
19
+ forceQuineCheats: boolean;
20
+ rootFolderPath: string;
21
+ }> & {
22
+ scriptName: string | true;
23
+ };
24
+ /**
25
+ * Minifies a given script
26
+ * @param code JavaScript or TypeScript code
27
+ * @param options {@link ProcessOptions details}
28
+ */
29
+ export declare function processScript(code: string, { minify: shouldMinify, uniqueId, scriptUser, scriptName, filePath, mangleNames, forceQuineCheats, rootFolderPath }: ProcessOptions): Promise<{
30
+ script: string;
31
+ warnings: {
32
+ message: string;
33
+ }[];
34
+ }>;
@@ -0,0 +1,362 @@
1
+ import { relative, isAbsolute, sep } from "path"
2
+ import ahc5w59yx7outk8kyghgeyuy from "@babel/generator"
3
+ import { parse } from "@babel/parser"
4
+ import rapmj8iontv3ou4pkolc0403 from "@babel/plugin-proposal-decorators"
5
+ import umw1zg85b9qixljmhj0zilxk from "@babel/plugin-proposal-destructuring-private"
6
+ import ezc73v0riw3484aovytwusbo from "@babel/plugin-transform-class-properties"
7
+ import o190urstg86lptn0wy64mpul from "@babel/plugin-transform-class-static-block"
8
+ import ad71g4yuystq3g90nvsxc866 from "@babel/plugin-transform-explicit-resource-management"
9
+ import wneva8uykfhd4eijr2u0e20w from "@babel/plugin-transform-exponentiation-operator"
10
+ import vujla7cbdqwrfz2edvjbww8f from "@babel/plugin-transform-json-strings"
11
+ import m3belydfwqtzhfp9ejwqjc95 from "@babel/plugin-transform-logical-assignment-operators"
12
+ import a3rb7t8rm798v5z7wenszlcw from "@babel/plugin-transform-nullish-coalescing-operator"
13
+ import uvn2k7jq7tfz8j22iww214u8 from "@babel/plugin-transform-numeric-separator"
14
+ import hs3hydw0tve60vro86ut8bsr from "@babel/plugin-transform-object-rest-spread"
15
+ import kql8ck6k2gg569eqdugjqhcp from "@babel/plugin-transform-optional-catch-binding"
16
+ import gbd3m9o9htb27q5e7ahs0tzb from "@babel/plugin-transform-optional-chaining"
17
+ import wao8wj78reawtuu7km7ncttp from "@babel/plugin-transform-private-property-in-object"
18
+ import axasd8k72xrbjbdiw85vhi3i from "@babel/plugin-transform-unicode-sets-regex"
19
+ import w5m3g6w58my4352jqaq8zmhm from "@babel/traverse"
20
+ import t from "@babel/types"
21
+ import rollupPluginAlias from "@rollup/plugin-alias"
22
+ import { babel } from "@rollup/plugin-babel"
23
+ import rollupPluginCommonJS from "@rollup/plugin-commonjs"
24
+ import rollupPluginJSON from "@rollup/plugin-json"
25
+ import rollupPluginNodeResolve from "@rollup/plugin-node-resolve"
26
+ import { assert } from "@samual/lib/assert"
27
+ import prettier from "prettier"
28
+ import { rollup } from "rollup"
29
+ import { supportedExtensions } from "../constants.js"
30
+ import { minify } from "./minify.js"
31
+ import { postprocess } from "./postprocess.js"
32
+ import { preprocess } from "./preprocess.js"
33
+ import { getReferencePathsToGlobal, replaceUnsafeStrings, includesIllegalString } from "./shared.js"
34
+ import { transform } from "./transform.js"
35
+ import "@samual/lib/countHackmudCharacters"
36
+ import "@samual/lib/spliceString"
37
+ import "acorn"
38
+ import "terser"
39
+ import "import-meta-resolve"
40
+ import "@samual/lib/clearObject"
41
+ const generate = ahc5w59yx7outk8kyghgeyuy.default,
42
+ babelPluginProposalDecorators = rapmj8iontv3ou4pkolc0403.default,
43
+ babelPluginProposalDestructuringPrivate = umw1zg85b9qixljmhj0zilxk.default,
44
+ babelPluginTransformClassProperties = ezc73v0riw3484aovytwusbo.default,
45
+ babelPluginTransformClassStaticBlock = o190urstg86lptn0wy64mpul.default,
46
+ babelPluginTransformExplicitResourceManagement = ad71g4yuystq3g90nvsxc866.default,
47
+ babelPluginTransformExponentiationOperator = wneva8uykfhd4eijr2u0e20w.default,
48
+ babelPluginTransformJsonStrings = vujla7cbdqwrfz2edvjbww8f.default,
49
+ babelPluginTransformLogicalAssignmentOperators = m3belydfwqtzhfp9ejwqjc95.default,
50
+ babelPluginTransformNullishCoalescingOperator = a3rb7t8rm798v5z7wenszlcw.default,
51
+ babelPluginTransformNumericSeparator = uvn2k7jq7tfz8j22iww214u8.default,
52
+ babelPluginTransformObjectRestSpread = hs3hydw0tve60vro86ut8bsr.default,
53
+ babelPluginTransformOptionalCatchBinding = kql8ck6k2gg569eqdugjqhcp.default,
54
+ babelPluginTransformOptionalChaining = gbd3m9o9htb27q5e7ahs0tzb.default,
55
+ babelPluginTransformPrivatePropertyInObject = wao8wj78reawtuu7km7ncttp.default,
56
+ babelPluginTransformUnicodeSetsRegex = axasd8k72xrbjbdiw85vhi3i.default,
57
+ traverse = w5m3g6w58my4352jqaq8zmhm.default,
58
+ { format } = prettier
59
+ async function processScript(
60
+ code,
61
+ {
62
+ minify: shouldMinify = !0,
63
+ uniqueId = Math.floor(Math.random() * 2 ** 52)
64
+ .toString(36)
65
+ .padStart(11, "0"),
66
+ scriptUser,
67
+ scriptName,
68
+ filePath,
69
+ mangleNames = !1,
70
+ forceQuineCheats,
71
+ rootFolderPath
72
+ }
73
+ ) {
74
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:82:36")
75
+ const sourceCode = code
76
+ let autocomplete, statedSeclevel
77
+ const autocompleteMatch = /^function\s*\(.+\/\/(?<autocomplete>.+)/.exec(code)
78
+ if (autocompleteMatch) {
79
+ code = "export default " + code
80
+ ;({ autocomplete } = autocompleteMatch.groups)
81
+ } else
82
+ for (const line of code.split("\n")) {
83
+ const comment = /^\s*\/\/(?<commentContent>.+)/.exec(line)
84
+ if (!comment) break
85
+ const commentContent = comment.groups.commentContent.trim()
86
+ if (commentContent.startsWith("@autocomplete ")) autocomplete = commentContent.slice(14).trimStart()
87
+ else if (commentContent.startsWith("@seclevel ")) {
88
+ const seclevelString = commentContent.slice(10).trimStart().toLowerCase()
89
+ switch (seclevelString) {
90
+ case "fullsec":
91
+ case "full":
92
+ case "fs":
93
+ case "4s":
94
+ case "f":
95
+ case "4":
96
+ statedSeclevel = 4
97
+ break
98
+ case "highsec":
99
+ case "high":
100
+ case "hs":
101
+ case "3s":
102
+ case "h":
103
+ case "3":
104
+ statedSeclevel = 3
105
+ break
106
+ case "midsec":
107
+ case "mid":
108
+ case "ms":
109
+ case "2s":
110
+ case "m":
111
+ case "2":
112
+ statedSeclevel = 2
113
+ break
114
+ case "lowsec":
115
+ case "low":
116
+ case "ls":
117
+ case "1s":
118
+ case "l":
119
+ case "1":
120
+ statedSeclevel = 1
121
+ break
122
+ case "nullsec":
123
+ case "null":
124
+ case "ns":
125
+ case "0s":
126
+ case "n":
127
+ case "0":
128
+ statedSeclevel = 0
129
+ break
130
+ default:
131
+ throw Error(`unrecognised seclevel "${seclevelString}"`)
132
+ }
133
+ }
134
+ }
135
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:161:36")
136
+ const plugins = [
137
+ [babelPluginProposalDecorators, { decoratorsBeforeExport: !0 }],
138
+ [babelPluginTransformClassProperties],
139
+ [babelPluginTransformClassStaticBlock],
140
+ [babelPluginTransformPrivatePropertyInObject],
141
+ [babelPluginTransformLogicalAssignmentOperators],
142
+ [babelPluginTransformNumericSeparator],
143
+ [babelPluginTransformNullishCoalescingOperator],
144
+ [babelPluginTransformOptionalChaining],
145
+ [babelPluginTransformOptionalCatchBinding],
146
+ [babelPluginTransformJsonStrings],
147
+ [babelPluginTransformObjectRestSpread],
148
+ [babelPluginTransformExponentiationOperator],
149
+ [babelPluginTransformUnicodeSetsRegex],
150
+ [babelPluginProposalDestructuringPrivate],
151
+ [babelPluginTransformExplicitResourceManagement]
152
+ ]
153
+ let filePathResolved
154
+ if (filePath) {
155
+ filePathResolved = relative(".", filePath)
156
+ if (filePath.endsWith(".ts"))
157
+ plugins.unshift([
158
+ await import("@babel/plugin-transform-typescript").then(module => module.default),
159
+ { allowDeclareFields: !0, optimizeConstEnums: !0 }
160
+ ])
161
+ else {
162
+ const [
163
+ babelPluginProposalDoExpressions,
164
+ babelPluginProposalFunctionBind,
165
+ babelPluginProposalFunctionSent,
166
+ babelPluginProposalPartialApplication,
167
+ babelPluginProposalPipelineOperator,
168
+ babelPluginProposalThrowExpressions,
169
+ babelPluginProposalRecordAndTuple
170
+ ] = await Promise.all([
171
+ import("@babel/plugin-proposal-do-expressions").then(module => module.default),
172
+ import("@babel/plugin-proposal-function-bind").then(module => module.default),
173
+ import("@babel/plugin-proposal-function-sent").then(module => module.default),
174
+ import("@babel/plugin-proposal-partial-application").then(module => module.default),
175
+ import("@babel/plugin-proposal-pipeline-operator").then(module => module.default),
176
+ import("@babel/plugin-proposal-throw-expressions").then(module => module.default),
177
+ import("@babel/plugin-proposal-record-and-tuple").then(module => module.default)
178
+ ])
179
+ plugins.push(
180
+ [babelPluginProposalDoExpressions],
181
+ [babelPluginProposalFunctionBind],
182
+ [babelPluginProposalFunctionSent],
183
+ [babelPluginProposalPartialApplication],
184
+ [babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
185
+ [babelPluginProposalThrowExpressions],
186
+ [babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
187
+ )
188
+ }
189
+ } else {
190
+ filePathResolved = uniqueId + ".ts"
191
+ const [
192
+ babelPluginTransformTypescript,
193
+ babelPluginProposalDoExpressions,
194
+ babelPluginProposalFunctionBind,
195
+ babelPluginProposalFunctionSent,
196
+ babelPluginProposalPartialApplication,
197
+ babelPluginProposalPipelineOperator,
198
+ babelPluginProposalThrowExpressions,
199
+ babelPluginProposalRecordAndTuple
200
+ ] = await Promise.all([
201
+ import("@babel/plugin-transform-typescript").then(module => module.default),
202
+ import("@babel/plugin-proposal-do-expressions").then(module => module.default),
203
+ import("@babel/plugin-proposal-function-bind").then(module => module.default),
204
+ import("@babel/plugin-proposal-function-sent").then(module => module.default),
205
+ import("@babel/plugin-proposal-partial-application").then(module => module.default),
206
+ import("@babel/plugin-proposal-pipeline-operator").then(module => module.default),
207
+ import("@babel/plugin-proposal-throw-expressions").then(module => module.default),
208
+ import("@babel/plugin-proposal-record-and-tuple").then(module => module.default)
209
+ ])
210
+ plugins.push(
211
+ [babelPluginTransformTypescript, { allowDeclareFields: !0, optimizeConstEnums: !0 }],
212
+ [babelPluginProposalDoExpressions],
213
+ [babelPluginProposalFunctionBind],
214
+ [babelPluginProposalFunctionSent],
215
+ [babelPluginProposalPartialApplication],
216
+ [babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
217
+ [babelPluginProposalThrowExpressions],
218
+ [babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
219
+ )
220
+ }
221
+ const bundle = await rollup({
222
+ input: filePathResolved,
223
+ plugins: [
224
+ rollupPluginJSON({ preferConst: !0 }),
225
+ {
226
+ name: "hackmud-script-manager",
227
+ resolveId(source) {
228
+ if (source == filePathResolved) return filePathResolved
229
+ },
230
+ async load(id) {
231
+ if (id == filePathResolved) return (await preprocess(code, { uniqueId })).code
232
+ },
233
+ async transform(code, id) {
234
+ if (id == filePathResolved) return
235
+ if (isAbsolute(id) && !id.includes(`${sep}node_modules${sep}`))
236
+ return (await preprocess(code, { uniqueId })).code
237
+ let program
238
+ traverse(parse(code, { sourceType: "module" }), {
239
+ Program(path) {
240
+ program = path
241
+ path.skip()
242
+ }
243
+ })
244
+ for (const referencePath of getReferencePathsToGlobal("JSON", program))
245
+ "MemberExpression" == referencePath.parentPath.node.type &&
246
+ "Identifier" == referencePath.parentPath.node.property.type &&
247
+ ("parse" == referencePath.parentPath.node.property.name
248
+ ? (referencePath.parentPath.node.property.name = "oparse")
249
+ : "stringify" == referencePath.parentPath.node.property.name &&
250
+ (referencePath.parentPath.node.property.name = "ostringify"))
251
+ return generate(program.node).code
252
+ }
253
+ },
254
+ babel({ babelHelpers: "bundled", plugins, configFile: !1, extensions: supportedExtensions }),
255
+ rollupPluginCommonJS(),
256
+ rollupPluginNodeResolve({ extensions: supportedExtensions }),
257
+ !!rootFolderPath && rollupPluginAlias({ entries: [{ find: /^\//, replacement: rootFolderPath + "/" }] })
258
+ ],
259
+ treeshake: { moduleSideEffects: !1 }
260
+ }),
261
+ seclevelNames = ["NULLSEC", "LOWSEC", "MIDSEC", "HIGHSEC", "FULLSEC"]
262
+ code = (await bundle.generate({})).output[0].code
263
+ const { file, seclevel, warnings } = transform(parse(code, { sourceType: "module" }), sourceCode, {
264
+ uniqueId,
265
+ scriptUser,
266
+ scriptName
267
+ })
268
+ if (null != statedSeclevel && seclevel < statedSeclevel)
269
+ throw Error(
270
+ `detected seclevel ${seclevelNames[seclevel]} is lower than stated seclevel ${seclevelNames[statedSeclevel]}`
271
+ )
272
+ code = generate(file).code
273
+ if (shouldMinify) code = await minify(file, { uniqueId, mangleNames, forceQuineCheats })
274
+ else {
275
+ traverse(file, {
276
+ MemberExpression({ node: memberExpression }) {
277
+ if (!memberExpression.computed) {
278
+ assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:337:60")
279
+ if ("prototype" == memberExpression.property.name) {
280
+ memberExpression.computed = !0
281
+ memberExpression.property = t.stringLiteral("prototype")
282
+ } else if ("__proto__" == memberExpression.property.name) {
283
+ memberExpression.computed = !0
284
+ memberExpression.property = t.stringLiteral("__proto__")
285
+ } else if (includesIllegalString(memberExpression.property.name)) {
286
+ memberExpression.computed = !0
287
+ memberExpression.property = t.stringLiteral(
288
+ replaceUnsafeStrings(uniqueId, memberExpression.property.name)
289
+ )
290
+ }
291
+ }
292
+ },
293
+ VariableDeclarator(path) {
294
+ const renameVariables = lValue => {
295
+ switch (lValue.type) {
296
+ case "Identifier":
297
+ includesIllegalString(lValue.name) &&
298
+ path.scope.rename(
299
+ lValue.name,
300
+ "$" +
301
+ Math.floor(Math.random() * 2 ** 52)
302
+ .toString(36)
303
+ .padStart(11, "0")
304
+ )
305
+ break
306
+ case "ObjectPattern":
307
+ for (const property of lValue.properties) {
308
+ assert("ObjectProperty" == property.type, "src/processScript/index.ts:368:51")
309
+ renameVariables(property.value)
310
+ }
311
+ break
312
+ case "ArrayPattern":
313
+ for (const element of lValue.elements) element && renameVariables(element)
314
+ break
315
+ case "RestElement":
316
+ renameVariables(lValue.argument)
317
+ break
318
+ default:
319
+ throw Error(`unknown lValue type "${lValue.type}"`)
320
+ }
321
+ }
322
+ renameVariables(path.node.id)
323
+ },
324
+ ObjectProperty({ node: objectProperty }) {
325
+ if ("Identifier" == objectProperty.key.type && includesIllegalString(objectProperty.key.name)) {
326
+ objectProperty.key = t.stringLiteral(replaceUnsafeStrings(uniqueId, objectProperty.key.name))
327
+ objectProperty.shorthand = !1
328
+ }
329
+ },
330
+ StringLiteral({ node }) {
331
+ node.value = replaceUnsafeStrings(uniqueId, node.value)
332
+ },
333
+ TemplateLiteral({ node }) {
334
+ for (const templateElement of node.quasis)
335
+ if (templateElement.value.cooked) {
336
+ templateElement.value.cooked = replaceUnsafeStrings(uniqueId, templateElement.value.cooked)
337
+ templateElement.value.raw = templateElement.value.cooked
338
+ .replaceAll("\\", "\\\\")
339
+ .replaceAll("`", "\\`")
340
+ .replaceAll("${", "$\\{")
341
+ } else templateElement.value.raw = replaceUnsafeStrings(uniqueId, templateElement.value.raw)
342
+ },
343
+ RegExpLiteral(path) {
344
+ path.node.pattern = replaceUnsafeStrings(uniqueId, path.node.pattern)
345
+ delete path.node.extra
346
+ }
347
+ })
348
+ code = await format(generate(file, { comments: !1 }).code, {
349
+ parser: "babel",
350
+ arrowParens: "avoid",
351
+ semi: !1,
352
+ trailingComma: "none"
353
+ })
354
+ }
355
+ code = postprocess(code, uniqueId, autocomplete)
356
+ if (includesIllegalString(code))
357
+ throw Error(
358
+ 'you found a weird edge case where I wasn\'t able to replace illegal strings like "SC$", please report thx'
359
+ )
360
+ return { script: code, warnings }
361
+ }
362
+ export { minify, postprocess, preprocess, processScript, transform }
@@ -0,0 +1,20 @@
1
+ import type { File } from "@babel/types";
2
+ import type { LaxPartial } from "@samual/lib";
3
+ type MinifyOptions = LaxPartial<{
4
+ /** 11 a-z 0-9 characters */ uniqueId: string;
5
+ /** whether to mangle function and class names (defaults to `false`) */ mangleNames: boolean;
6
+ /**
7
+ * when set to `true` forces use of quine cheats
8
+ *
9
+ * when set to `false` forces quine cheats not to be used
10
+ *
11
+ * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
12
+ */
13
+ forceQuineCheats: boolean;
14
+ }>;
15
+ /**
16
+ * @param file babel ast node representing a file containing transformed code
17
+ * @param options {@link MinifyOptions details}
18
+ */
19
+ export declare function minify(file: File, { uniqueId, mangleNames, forceQuineCheats }?: MinifyOptions): Promise<string>;
20
+ export {};