hackmud-script-manager 0.20.4-c524114 → 0.20.4-d4996d7

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.
package/env.d.ts CHANGED
@@ -1,18 +1,14 @@
1
- type Replace<T, R> = Omit<T, Extract<keyof R, keyof T>> & R
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> = {
8
- [K in keyof T]-?: {} extends Pick<T, K> ? true : false
9
- }[keyof T]
7
+ type AllOptional<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? true : false }[keyof T]
10
8
 
11
9
  type Scriptor<Args = unknown, Ret = unknown> = {
12
- name: string,
13
- call: AllOptional<Args> extends true
14
- ? (args?: Args) => Ret
15
- : (args: Args) => Ret
10
+ name: string
11
+ call: AllOptional<Args> extends true ? (args?: Args) => Ret : (args: Args) => Ret
16
12
  }
17
13
 
18
14
  type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
@@ -41,7 +37,7 @@ type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`"
41
37
  type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
42
38
  type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
43
39
 
44
- type UpgradeCore = {
40
+ type UpgradeBase = {
45
41
  name: string
46
42
  type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
47
43
  up_class?: -1 | 0 | 1 | 2 | 3
@@ -53,9 +49,9 @@ type UpgradeCore = {
53
49
  description: string
54
50
  }
55
51
 
56
- type Upgrade = UpgradeCore & Record<string, null | boolean | number | string>
52
+ type Upgrade = UpgradeBase & Record<string, null | boolean | number | string>
57
53
 
58
- type CLIUpgrade = Omit<UpgradeCore, `rarity`> & {
54
+ type CliUpgrade = Omit<UpgradeBase, `rarity`> & {
59
55
  [x: string]: null | boolean | number | string
60
56
  rarity: UpgradeRarityString
61
57
  }
@@ -155,7 +151,16 @@ type Fullsec = Subscripts & PlayerFullsec & {
155
151
  market: {
156
152
  /** **FULLSEC** */ browse: {
157
153
  (args:
158
- Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<CLIUpgrade, "rarity">>
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">>
159
164
  ): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
160
165
 
161
166
  <I extends string>(args: { i: I }): {
@@ -357,7 +362,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
357
362
  * const arr = [ 1, 2, 2, 3, 2 ]
358
363
  *
359
364
  * $D(uniq(arr)) // [ 1, 2, 3, 2 ] */
360
- uniq: (array: T[]) => T[]
365
+ uniq: <T>(array: T[]) => T[]
361
366
 
362
367
  /** Sorts an array of numbers or number-coercible strings in descending order. */
363
368
  u_sort_num_arr_desc: <T>(array: T[]) => T[]
@@ -424,17 +429,17 @@ type Fullsec = Subscripts & PlayerFullsec & {
424
429
  upgrades_of_owner: {
425
430
  <F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: { filter?: F, full?: false }): (
426
431
  Omit<
427
- Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
432
+ Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
428
433
  keyof F
429
434
  > & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
430
435
  )[] | ScriptFailure
431
436
 
432
437
  <F extends Partial<Upgrade & { loaded: boolean }> = object>(args: { filter?: F, full: true }): (
433
- Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>
438
+ Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>
434
439
  )[] | ScriptFailure
435
440
 
436
441
  <I extends number>(args: { i: I }): (
437
- Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
442
+ Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
438
443
  ) | ScriptFailure
439
444
  }
440
445
 
@@ -511,7 +516,7 @@ type Highsec = Fullsec & PlayerHighsec & {
511
516
  /** **HIGHSEC** */
512
517
  upgrades: {
513
518
  <I extends number>(args: { i: I }): (
514
- Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
519
+ Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
515
520
  ) | ScriptFailure
516
521
 
517
522
  <F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: {
@@ -519,20 +524,20 @@ type Highsec = Fullsec & PlayerHighsec & {
519
524
  is_script?: true
520
525
  full?: false
521
526
  }): (
522
- Omit<Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">, keyof F> & F &
527
+ Omit<Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">, keyof F> & F &
523
528
  Record<string, null | boolean | number | string>
524
529
  )[] | ScriptFailure
525
530
 
526
531
  <F extends Partial<Upgrade & { loaded: boolean }> = object>(args?:
527
532
  { filter?: F, is_script?: true, full: true }
528
- ): (Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>)[] | ScriptFailure
533
+ ): (Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>)[] | ScriptFailure
529
534
 
530
535
  (args?: { filter?: Partial<Upgrade & { loaded: boolean }>, is_script: false, full?: false }):
531
536
  { msg: string, upgrades: string[] } | ScriptFailure
532
537
 
533
538
  <F extends Partial<Upgrade & { loaded: boolean }> = object>(
534
539
  args?: { filter?: F, is_script: false, full: true }
535
- ): (Omit<UpgradeCore, keyof F | `rarity`> & F & {
540
+ ): (Omit<UpgradeBase, keyof F | `rarity`> & F & {
536
541
  [x: string]: null | boolean | number | string
537
542
  rarity: UpgradeRarityString
538
543
  })[] | ScriptFailure
@@ -714,10 +719,50 @@ type Nullsec = Lowsec & PlayerNullsec & {
714
719
  }
715
720
  }
716
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
+
717
726
  type MongoValue = string | number | boolean | Date | MongoValue[] | { [key: string]: MongoValue } | null
718
727
 
719
728
  type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | { [key: string]: MongoCommandValue } |
720
- null | undefined
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>)>
721
766
 
722
767
  type Query = { [key: string]: MongoValue | Query } & { _id?: Id, $in?: MongoValue[] }
723
768
  type Projection = Record<string, boolean | 0 | 1>
@@ -766,7 +811,7 @@ type Cursor = {
766
811
  ObjectId: () => any
767
812
  }
768
813
 
769
- type CLIContext = {
814
+ type CliContext = {
770
815
  /** The name of the user who is calling the script. */ caller: string
771
816
  /** The name of this script. */ this_script: string
772
817
  /** The number of columns in the caller’s terminal. */ cols: number
@@ -774,17 +819,23 @@ type CLIContext = {
774
819
 
775
820
  /** The name of the script that directly called this script, or null if called on the command line or as a
776
821
  * scriptor. */ calling_script: null
822
+ is_scriptor?: undefined
823
+ is_brain?: undefined
777
824
  }
778
825
 
779
- type SubscriptContext = Replace<CLIContext, {
826
+ type SubscriptContext = Replace<CliContext, {
780
827
  /** The name of the script that directly called this script, or null if called on the command line or as a scriptor.
781
828
  */
782
829
  calling_script: string
783
830
  }>
784
831
 
785
- type ScriptorContext = CLIContext & { /** Whether the script is being run as a scriptor. */ is_scriptor: true }
786
- type BrainContext = CLIContext & { /** Whether the script is being run via a bot brain. */ is_brain: true }
787
- type Context = CLIContext | SubscriptContext | ScriptorContext | BrainContext
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
788
839
 
789
840
  /** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
790
841
 
@@ -827,6 +878,8 @@ declare const $0s: typeof $ns
827
878
  * } */
828
879
  declare const $s: Nullsec
829
880
 
881
+ type ObjectId = { $oid: string }
882
+
830
883
  declare const $db: {
831
884
  /** Insert a document or documents into a collection.
832
885
  * @param documents A document or array of documents to insert into the collection. */
@@ -920,6 +973,8 @@ declare const $db: {
920
973
  signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
921
974
  }
922
975
  }
976
+
977
+ ObjectId: () => ObjectId
923
978
  }
924
979
 
925
980
  /** Debug Log.
@@ -956,7 +1011,7 @@ declare const $FMCL: undefined | true
956
1011
  * @example
957
1012
  * if (!$G.dbCache)
958
1013
  * $G.dbCache = $db.f({ whatever: true }).first() */
959
- declare const $G: any
1014
+ declare const $G: Record<string | symbol, any>
960
1015
 
961
1016
  /** This contains a JS timestamp (not Date) set immediately before your code begins running.
962
1017
  * @example
@@ -1005,3 +1060,14 @@ declare const _FULL_SCRIPT_NAME: string
1005
1060
  *
1006
1061
  * In rare cases where it's not known at build time, it's `-1`. */
1007
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-c524114",
3
+ "version": "0.20.4-d4996d7",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -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'
@@ -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:127:60")
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.traverse({
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
- path.traverse({
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:259:62")
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:364:61")
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(t.identifier(`$${uniqueId}$SUBSCRIPT$scripts$quine$`), []),
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:495:43")
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:517:4"
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, seclevel: number, uniqueId: string) => string;
1
+ export declare const postprocess: (code: string, uniqueId: string) => string;
@@ -1,12 +1,12 @@
1
- const postprocess = (code, seclevel, uniqueId) =>
1
+ const postprocess = (code, uniqueId) =>
2
2
  code
3
- .replace(/^function\s*\w+\(/, "function(")
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"), `#${"nlmhf"[seclevel]}s.$1.$2`)
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
- return 1 == program.node.body.length && "FunctionDeclaration" == program.node.body[0].type ?
102
- { code: "export default " + generate(file).code }
103
- : { code: generate(file).code }
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 }