hackmud-script-manager 0.19.1-27bbd7d → 0.19.1-29fcf72

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/pull.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { copyFilePersistent } from "@samual/lib/copyFilePersistent"
2
2
  import { resolve } from "path"
3
- const pull = async (sourceFolderPath, hackmudPath, script) => {
3
+ async function pull(sourceFolderPath, hackmudPath, script) {
4
4
  const [user, name] = script.split(".")
5
5
  if (!user || !name) throw Error('`script` argument must be in "user.name" format')
6
6
  await copyFilePersistent(
package/push.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { Cache } from "@samual/lib/Cache"
2
2
  import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
3
+ import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
3
4
  import { writeFilePersistent } from "@samual/lib/writeFilePersistent"
4
- import { readdir, readFile } from "fs/promises"
5
- import { resolve, extname, basename } from "path"
5
+ import { readFile } from "fs/promises"
6
+ import { basename, resolve, extname } from "path"
6
7
  import { supportedExtensions } from "./constants.js"
7
8
  import { processScript } from "./processScript/index.js"
8
9
  import "@babel/generator"
@@ -41,11 +42,11 @@ import "./processScript/preprocess.js"
41
42
  import "import-meta-resolve"
42
43
  import "./processScript/transform.js"
43
44
  import "@samual/lib/clearObject"
44
- const push = async (
45
+ async function push(
45
46
  sourceDirectory,
46
47
  hackmudDirectory,
47
48
  { scripts = ["*.*"], onPush = () => {}, minify = !0, mangleNames = !1, forceQuineCheats } = {}
48
- ) => {
49
+ ) {
49
50
  const scriptNamesByUser = new Cache(_user => new Set()),
50
51
  wildScriptUsers = new Set(),
51
52
  wildUserScripts = new Set()
@@ -64,18 +65,20 @@ const push = async (
64
65
  scriptNamesAlreadyPushedByUser = new Cache(_user => new Set())
65
66
  let sourceDirectoryDirents
66
67
  if (wildUserScripts.size || pushEverything) {
67
- const hackmudDirectoryDirents = await readdir(resolve(hackmudDirectory), { withFileTypes: !0 }),
68
- allUsers = new Set([
69
- ...(sourceDirectoryDirents = await readdir(resolve(sourceDirectory), { withFileTypes: !0 }))
70
- .filter(dirent => dirent.isDirectory())
71
- .map(dirent => dirent.name),
72
- ...hackmudDirectoryDirents.filter(dirent => dirent.isDirectory()).map(dirent => dirent.name),
73
- ...hackmudDirectoryDirents
74
- .filter(dirent => dirent.isFile() && dirent.name.endsWith(".key"))
75
- .map(dirent => dirent.name.slice(0, -4)),
76
- ...scriptNamesByUser.keys(),
77
- ...wildScriptUsers
78
- ])
68
+ let hackmudDirectoryEntries
69
+ ;[hackmudDirectoryEntries, sourceDirectoryDirents] = await Promise.all([
70
+ readDirectoryWithStats(hackmudDirectory),
71
+ readDirectoryWithStats(sourceDirectory)
72
+ ])
73
+ const allUsers = new Set([
74
+ ...sourceDirectoryDirents.filter(({ stats }) => stats.isDirectory()).map(({ path }) => basename(path)),
75
+ ...hackmudDirectoryEntries.filter(({ stats }) => stats.isDirectory()).map(({ name }) => name),
76
+ ...hackmudDirectoryEntries
77
+ .filter(({ name, stats }) => stats.isFile() && name.endsWith(".key"))
78
+ .map(({ name }) => name.slice(0, -4)),
79
+ ...scriptNamesByUser.keys(),
80
+ ...wildScriptUsers
81
+ ])
79
82
  if (pushEverything) for (const user of allUsers) wildScriptUsers.add(user)
80
83
  else
81
84
  for (const user of allUsers) {
@@ -85,28 +88,27 @@ const push = async (
85
88
  }
86
89
  await Promise.all(
87
90
  [...wildScriptUsers].map(async user => {
88
- await readdir(resolve(sourceDirectory, user), { withFileTypes: !0 }).then(
89
- async dirents => {
91
+ await readDirectoryWithStats(resolve(sourceDirectory, user)).then(
92
+ async entries => {
90
93
  await Promise.all(
91
- dirents.map(async dirent => {
92
- if (dirent.name.endsWith(".d.ts")) return
93
- const extension = extname(dirent.name)
94
- if (dirent.isFile() && supportedExtensions.includes(extension)) {
95
- const scriptName = basename(dirent.name, extension),
96
- filePath = resolve(sourceDirectory, user, dirent.name),
94
+ entries.map(async ({ stats, name, path }) => {
95
+ if (name.endsWith(".d.ts")) return
96
+ const extension = extname(name)
97
+ if (stats.isFile() && supportedExtensions.includes(extension)) {
98
+ const scriptName = basename(name, extension),
97
99
  { script: minifiedCode } = await processScript(
98
- await readFile(filePath, { encoding: "utf-8" }),
100
+ await readFile(path, { encoding: "utf-8" }),
99
101
  {
100
102
  minify,
101
103
  scriptUser: user,
102
104
  scriptName,
103
- filePath,
105
+ filePath: path,
104
106
  mangleNames,
105
107
  forceQuineCheats
106
108
  }
107
109
  ),
108
110
  info = {
109
- file: `${user}/${dirent.name}`,
111
+ file: `${user}/${name}`,
110
112
  users: [user],
111
113
  minLength: countHackmudCharacters(minifiedCode),
112
114
  error: void 0
@@ -170,12 +172,12 @@ const push = async (
170
172
  )
171
173
  await (wildScriptUsers.size ?
172
174
  Promise.all(
173
- (sourceDirectoryDirents || (await readdir(resolve(sourceDirectory), { withFileTypes: !0 }))).map(
174
- async dirent => {
175
- if (dirent.name.endsWith(".d.ts")) return
176
- const extension = extname(dirent.name)
177
- if (!dirent.isFile() || !supportedExtensions.includes(extension)) return
178
- const scriptName = basename(dirent.name, extension),
175
+ (sourceDirectoryDirents || (await readDirectoryWithStats(sourceDirectory))).map(
176
+ async ({ path, stats, name }) => {
177
+ if (name.endsWith(".d.ts")) return
178
+ const extension = extname(name)
179
+ if (!stats.isFile() || !supportedExtensions.includes(extension)) return
180
+ const scriptName = basename(name, extension),
179
181
  usersToPushTo = [...wildScriptUsers, ...usersByGlobalScriptsToPush.get(scriptName)].filter(
180
182
  user => !scriptNamesAlreadyPushedByUser.get(user).has(scriptName)
181
183
  )
@@ -183,13 +185,17 @@ const push = async (
183
185
  const uniqueID = Math.floor(Math.random() * 2 ** 52)
184
186
  .toString(36)
185
187
  .padStart(11, "0"),
186
- filePath = resolve(sourceDirectory, dirent.name),
187
- { script: minifiedCode } = await processScript(
188
- await readFile(filePath, { encoding: "utf-8" }),
189
- { minify, scriptUser: !0, scriptName, uniqueID, filePath, mangleNames, forceQuineCheats }
190
- ),
188
+ { script: minifiedCode } = await processScript(await readFile(path, { encoding: "utf-8" }), {
189
+ minify,
190
+ scriptUser: !0,
191
+ scriptName,
192
+ uniqueID,
193
+ filePath: path,
194
+ mangleNames,
195
+ forceQuineCheats
196
+ }),
191
197
  info = {
192
- file: dirent.name,
198
+ file: name,
193
199
  users: usersToPushTo,
194
200
  minLength: countHackmudCharacters(minifiedCode),
195
201
  error: void 0
File without changes
@@ -0,0 +1,2 @@
1
+ export declare function generateTypeDeclaration(sourceDirectory: string, hackmudPath?: string): Promise<string>;
2
+ export default generateTypeDeclaration;
@@ -0,0 +1,31 @@
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 = {
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
+ /** the name of this script (or set to `true` if not yet known) */ scriptName: string | true;
11
+ filePath: string;
12
+ /** whether to mangle function and class names (defaults to `false`) */ mangleNames: boolean;
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
+ };
21
+ /** Minifies a given script
22
+ * @param code JavaScript or TypeScript code
23
+ * @param options {@link ProcessOptions details} */
24
+ export declare function processScript(code: string, { minify: shouldMinify, uniqueID, scriptUser, scriptName, filePath, mangleNames, forceQuineCheats }?: LaxPartial<ProcessOptions>): Promise<{
25
+ script: string;
26
+ warnings: {
27
+ message: string;
28
+ line: number;
29
+ }[];
30
+ }>;
31
+ export default processScript;
@@ -0,0 +1,18 @@
1
+ import type { File } from "@babel/types";
2
+ import type { LaxPartial } from "@samual/lib";
3
+ type MinifyOptions = {
4
+ /** 11 a-z 0-9 characters */ uniqueID: string;
5
+ /** whether to mangle function and class names (defaults to `false`) */ mangleNames: boolean;
6
+ /** when set to `true` forces use of quine cheats
7
+ *
8
+ * when set to `false` forces quine cheats not to be used
9
+ *
10
+ * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
11
+ */
12
+ forceQuineCheats: boolean;
13
+ /** the comment inserted after the function signature */ autocomplete: string;
14
+ };
15
+ /** @param file babel ast node representing a file containing transformed code
16
+ * @param options {@link MinifyOptions details} */
17
+ export declare function minify(file: File, { uniqueID, mangleNames, forceQuineCheats, autocomplete }?: LaxPartial<MinifyOptions>): Promise<string>;
18
+ export default minify;
@@ -0,0 +1,9 @@
1
+ export type PreprocessOptions = {
2
+ /** 11 a-z 0-9 characters */ uniqueID: string;
3
+ };
4
+ /** @param code source code for preprocessing
5
+ * @param options {@link PreprocessOptions details} */
6
+ export declare function preprocess(code: string, { uniqueID }?: Partial<PreprocessOptions>): Promise<{
7
+ code: string;
8
+ }>;
9
+ export default preprocess;
@@ -1,5 +1,5 @@
1
1
  import type { NodePath } from "@babel/traverse";
2
2
  import type { Identifier, Program } from "@babel/types";
3
- export declare const getReferencePathsToGlobal: (name: string, program: NodePath<Program>) => NodePath<Identifier>[];
3
+ export declare function getReferencePathsToGlobal(name: string, program: NodePath<Program>): NodePath<Identifier>[];
4
4
  export declare const includesIllegalString: (toCheck: string) => boolean;
5
5
  export declare const replaceUnsafeStrings: (uniqueID: string, toReplace: string) => string;
@@ -0,0 +1,18 @@
1
+ import type { File } from "@babel/types";
2
+ export type TransformOptions = {
3
+ /** 11 a-z 0-9 characters */ uniqueID: string;
4
+ /** the user going to be hosting this script (or set to `true` if not yet known) */ scriptUser: string | true;
5
+ /** the name of this script (or set to `true` if not yet known) */ scriptName: string | true;
6
+ seclevel: number;
7
+ };
8
+ /** transform a given babel `File` to be hackmud compatible
9
+ *
10
+ * (returned File will need `postprocess()`ing)
11
+ * @param file babel ast node representing a file containing preprocessed code
12
+ * @param sourceCode the original untouched source code
13
+ * @param options {@link TransformOptions details} */
14
+ export declare function transform(file: File, sourceCode: string, { uniqueID, scriptUser, scriptName, seclevel }?: Partial<TransformOptions>): {
15
+ file: File;
16
+ seclevel: number;
17
+ };
18
+ export default transform;
package/src/pull.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /** Copies script from hackmud to local source folder.
2
+ * @param sourceFolderPath path to folder containing source files
3
+ * @param hackmudPath path to hackmud directory
4
+ * @param script to pull in `user.name` format */
5
+ export declare function pull(sourceFolderPath: string, hackmudPath: string, script: string): Promise<void>;
6
+ export default pull;
package/src/push.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import type { LaxPartial } from "@samual/lib";
2
+ import type { Info } from ".";
3
+ export type PushOptions = {
4
+ /** whether to do the minify step (defaults to `true`) */ minify: boolean;
5
+ /** whether to mangle function and class names (defaults to `false`) */ mangleNames: boolean;
6
+ /** array of scripts in the format `foo.bar`
7
+ *
8
+ * also accepts wild card (`*`) e.g. `*.bar` or `foo.*`
9
+ *
10
+ * pushes everything by default (`*.*`) */
11
+ scripts: string[];
12
+ /** callback called on script push */ onPush: (info: Info) => void;
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
+ };
21
+ /** Push scripts from a source directory to the hackmud directory.
22
+ *
23
+ * Pushes files directly in the source folder to all users
24
+ * @param sourceDirectory directory containing source code
25
+ * @param hackmudDirectory directory created by hackmud containing user data including scripts
26
+ * @param options {@link PushOptions details}
27
+ * @returns array of info on pushed scripts */
28
+ export declare function push(sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, forceQuineCheats }?: LaxPartial<PushOptions>): Promise<Info[]>;
29
+ export default push;
@@ -1,4 +1,4 @@
1
- export declare const syncMacros: (hackmudPath: string) => Promise<{
1
+ export declare function syncMacros(hackmudPath: string): Promise<{
2
2
  macrosSynced: number;
3
3
  usersSynced: number;
4
4
  }>;
package/src/watch.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { LaxPartial } from "@samual/lib";
2
+ import type { PushOptions } from "./push";
3
+ export type WatchOptions = PushOptions & {
4
+ /** if provided, will write typescript type declarations for all the scripts on every change detected
5
+ *
6
+ * writing the type declarations enables interscript type checking and autocompletetes for the args */
7
+ typeDeclarationPath: string;
8
+ onReady: () => void;
9
+ };
10
+ /** Watches target file or folder for updates and builds and pushes updated file.
11
+ * @param sourceDirectory path to folder containing source files
12
+ * @param hackmudDirectory path to hackmud directory
13
+ * @param options {@link WatchOptions details} and {@link PushOptions more details} */
14
+ export declare function watch(sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, typeDeclarationPath: typeDeclarationPath_, onReady, forceQuineCheats }?: LaxPartial<WatchOptions>): Promise<void>;
15
+ export default watch;
package/syncMacros.js CHANGED
@@ -1,12 +1,13 @@
1
- import { readdir, readFile, stat, writeFile } from "fs/promises"
1
+ import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
2
+ import { readFile, stat, writeFile } from "fs/promises"
2
3
  import { extname, basename, resolve } from "path"
3
- const syncMacros = async hackmudPath => {
4
- const files = await readdir(hackmudPath, { withFileTypes: !0 }),
4
+ async function syncMacros(hackmudPath) {
5
+ const files = await readDirectoryWithStats(hackmudPath),
5
6
  macros = new Map(),
6
7
  users = []
7
8
  await Promise.all(
8
9
  files.map(async file => {
9
- if (file.isFile())
10
+ if (file.stats.isFile())
10
11
  switch (extname(file.name)) {
11
12
  case ".macros":
12
13
  {
package/watch.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Cache } from "@samual/lib/Cache"
2
2
  import { assert } from "@samual/lib/assert"
3
3
  import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
4
+ import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
4
5
  import { writeFilePersistent } from "@samual/lib/writeFilePersistent"
5
6
  import { watch as watch$1 } from "chokidar"
6
- import { readdir, readFile, writeFile } from "fs/promises"
7
+ import { readFile, writeFile } from "fs/promises"
7
8
  import { extname, basename, resolve } from "path"
8
9
  import { supportedExtensions } from "./constants.js"
9
10
  import { generateTypeDeclaration } from "./generateTypeDeclaration.js"
@@ -43,7 +44,7 @@ import "./processScript/preprocess.js"
43
44
  import "import-meta-resolve"
44
45
  import "./processScript/transform.js"
45
46
  import "@samual/lib/clearObject"
46
- const watch = async (
47
+ async function watch(
47
48
  sourceDirectory,
48
49
  hackmudDirectory,
49
50
  {
@@ -55,7 +56,7 @@ const watch = async (
55
56
  onReady,
56
57
  forceQuineCheats
57
58
  } = {}
58
- ) => {
59
+ ) {
59
60
  if (!scripts.length) throw Error("scripts option was an empty array")
60
61
  const scriptNamesToUsers = new Cache(_scriptName => new Set()),
61
62
  wildScriptUsers = new Set(),
@@ -91,26 +92,24 @@ const watch = async (
91
92
  return
92
93
  const scriptNamesToUsersToSkip = new Cache(_scriptName => [])
93
94
  await Promise.all(
94
- (await readdir(sourceDirectory, { withFileTypes: !0 })).map(async dirent => {
95
- if (dirent.isDirectory())
96
- for (const file of await readdir(resolve(sourceDirectory, dirent.name), {
97
- withFileTypes: !0
98
- })) {
99
- if (!file.isFile()) continue
100
- const fileExtension = extname(file.name)
101
- supportedExtensions.includes(fileExtension) &&
102
- scriptNamesToUsersToSkip.get(basename(file.name, fileExtension)).push(dirent.name)
103
- }
95
+ (await readDirectoryWithStats(sourceDirectory)).map(async ({ stats, name, path }) => {
96
+ if (stats.isDirectory())
97
+ for (const child of await readDirectoryWithStats(path))
98
+ if (child.stats.isFile()) {
99
+ const fileExtension = extname(child.name)
100
+ supportedExtensions.includes(fileExtension) &&
101
+ scriptNamesToUsersToSkip.get(basename(child.name, fileExtension)).push(name)
102
+ }
104
103
  })
105
104
  )
106
105
  const usersToPushToSet = new Set()
107
106
  if (pushEverything || wildUserScripts.has(scriptName)) {
108
- for (const dirent of await readdir(resolve(sourceDirectory), { withFileTypes: !0 }))
109
- dirent.isDirectory() && usersToPushToSet.add(dirent.name)
110
- for (const dirent of await readdir(resolve(hackmudDirectory), { withFileTypes: !0 }))
111
- dirent.isDirectory() ?
112
- usersToPushToSet.add(dirent.name)
113
- : dirent.isFile() && dirent.name.endsWith(".key") && usersToPushToSet.add(dirent.name.slice(0, -4))
107
+ for (const { stats, name } of await readDirectoryWithStats(sourceDirectory))
108
+ stats.isDirectory() && usersToPushToSet.add(name)
109
+ for (const { stats, name } of await readDirectoryWithStats(hackmudDirectory))
110
+ stats.isDirectory() ?
111
+ usersToPushToSet.add(name)
112
+ : stats.isFile() && name.endsWith(".key") && usersToPushToSet.add(name.slice(0, -4))
114
113
  for (const users of scriptNamesToUsers.values()) for (const user of users) usersToPushToSet.add(user)
115
114
  }
116
115
  for (const user of wildScriptUsers) usersToPushToSet.add(user)
@@ -136,7 +135,7 @@ const watch = async (
136
135
  forceQuineCheats
137
136
  }))
138
137
  } catch (error) {
139
- assert(error instanceof Error)
138
+ assert(error instanceof Error, "src/watch.ts:141:36")
140
139
  onPush?.({ file: path, users: [], minLength: 0, error })
141
140
  return
142
141
  }
@@ -181,7 +180,7 @@ const watch = async (
181
180
  forceQuineCheats
182
181
  }))
183
182
  } catch (error) {
184
- assert(error instanceof Error)
183
+ assert(error instanceof Error, "src/watch.ts:177:35")
185
184
  onPush?.({ file: path, users: [], minLength: 0, error })
186
185
  return
187
186
  }
@@ -196,7 +195,7 @@ const watch = async (
196
195
  try {
197
196
  await writeFile(typeDeclarationPath, typeDeclaration)
198
197
  } catch (error) {
199
- assert(error instanceof Error)
198
+ assert(error instanceof Error, "src/watch.ts:210:35")
200
199
  if ("EISDIR" != error.code) throw error
201
200
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
202
201
  await writeFile(typeDeclarationPath, typeDeclaration)
@@ -1,2 +0,0 @@
1
- export declare const generateTypeDeclaration: (sourceDirectory: string, hackmudPath?: string) => Promise<string>;
2
- export default generateTypeDeclaration;
@@ -1,40 +0,0 @@
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 = {
7
- /** whether to minify the given code */
8
- minify: boolean;
9
- /** 11 a-z 0-9 characters */
10
- uniqueID: string;
11
- /** the user going to be hosting this script (or set to `true` if not yet known) */
12
- scriptUser: string | true;
13
- /** the name of this script (or set to `true` if not yet known) */
14
- scriptName: string | true;
15
- filePath: string;
16
- /** whether to mangle function and class names (defaults to `false`) */
17
- mangleNames: boolean;
18
- /**
19
- * when set to `true` forces use of quine cheats
20
- *
21
- * when set to `false` forces quine cheats not to be used
22
- *
23
- * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
24
- */
25
- forceQuineCheats: boolean;
26
- };
27
- /**
28
- * Minifies a given script
29
- *
30
- * @param code JavaScript or TypeScript code
31
- * @param options {@link ProcessOptions details}
32
- */
33
- export declare const processScript: (code: string, { minify: shouldMinify, uniqueID, scriptUser, scriptName, filePath, mangleNames, forceQuineCheats }?: LaxPartial<ProcessOptions>) => Promise<{
34
- script: string;
35
- warnings: {
36
- message: string;
37
- line: number;
38
- }[];
39
- }>;
40
- export default processScript;
@@ -1,24 +0,0 @@
1
- import type { File } from "@babel/types";
2
- import type { LaxPartial } from "@samual/lib";
3
- type MinifyOptions = {
4
- /** 11 a-z 0-9 characters */
5
- uniqueID: string;
6
- /** whether to mangle function and class names (defaults to `false`) */
7
- mangleNames: boolean;
8
- /**
9
- * when set to `true` forces use of quine cheats
10
- *
11
- * when set to `false` forces quine cheats not to be used
12
- *
13
- * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
14
- */
15
- forceQuineCheats: boolean;
16
- /** the comment inserted after the function signature */
17
- autocomplete: string;
18
- };
19
- /**
20
- * @param file babel ast node representing a file containing transformed code
21
- * @param options {@link MinifyOptions details}
22
- */
23
- export declare const minify: (file: File, { uniqueID, mangleNames, forceQuineCheats, autocomplete }?: LaxPartial<MinifyOptions>) => Promise<string>;
24
- export default minify;
@@ -1,12 +0,0 @@
1
- export type PreprocessOptions = {
2
- /** 11 a-z 0-9 characters */
3
- uniqueID: string;
4
- };
5
- /**
6
- * @param code source code for preprocessing
7
- * @param options {@link PreprocessOptions details}
8
- */
9
- export declare const preprocess: (code: string, { uniqueID }?: Partial<PreprocessOptions>) => Promise<{
10
- code: string;
11
- }>;
12
- export default preprocess;
@@ -1,24 +0,0 @@
1
- import type { File } from "@babel/types";
2
- export type TransformOptions = {
3
- /** 11 a-z 0-9 characters */
4
- uniqueID: string;
5
- /** the user going to be hosting this script (or set to `true` if not yet known) */
6
- scriptUser: string | true;
7
- /** the name of this script (or set to `true` if not yet known) */
8
- scriptName: string | true;
9
- seclevel: number;
10
- };
11
- /**
12
- * transform a given babel `File` to be hackmud compatible
13
- *
14
- * (returned File will need `postprocess()`ing)
15
- *
16
- * @param file babel ast node representing a file containing preprocessed code
17
- * @param sourceCode the original untouched source code
18
- * @param options {@link TransformOptions details}
19
- */
20
- export declare const transform: (file: File, sourceCode: string, { uniqueID, scriptUser, scriptName, seclevel }?: Partial<TransformOptions>) => {
21
- file: File;
22
- seclevel: number;
23
- };
24
- export default transform;
package/pull.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Copies script from hackmud to local source folder.
3
- *
4
- * @param sourceFolderPath path to folder containing source files
5
- * @param hackmudPath path to hackmud directory
6
- * @param script to pull in `user.name` format
7
- */
8
- export declare const pull: (sourceFolderPath: string, hackmudPath: string, script: string) => Promise<void>;
9
- export default pull;
package/push.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import type { LaxPartial } from "@samual/lib";
2
- import type { Info } from ".";
3
- export type PushOptions = {
4
- /** whether to do the minify step (defaults to `true`) */
5
- minify: boolean;
6
- /** whether to mangle function and class names (defaults to `false`) */
7
- mangleNames: boolean;
8
- /**
9
- * array of scripts in the format `foo.bar`
10
- *
11
- * also accepts wild card (`*`) e.g. `*.bar` or `foo.*`
12
- *
13
- * pushes everything by default (`*.*`)
14
- */
15
- scripts: string[];
16
- /** callback called on script push */
17
- onPush: (info: Info) => void;
18
- /**
19
- * when set to `true` forces use of quine cheats
20
- *
21
- * when set to `false` forces quine cheats not to be used
22
- *
23
- * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
24
- */
25
- forceQuineCheats: boolean;
26
- };
27
- /**
28
- * Push scripts from a source directory to the hackmud directory.
29
- *
30
- * Pushes files directly in the source folder to all users
31
- * @param sourceDirectory directory containing source code
32
- * @param hackmudDirectory directory created by hackmud containing user data including scripts
33
- * @param options {@link PushOptions details}
34
- * @returns array of info on pushed scripts
35
- */
36
- export declare const push: (sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, forceQuineCheats }?: LaxPartial<PushOptions>) => Promise<Info[]>;
37
- export default push;