hackmud-script-manager 0.19.1-8719c7d → 0.19.1-875bbe4
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/hsm.js +7 -6
- package/env.d.ts +1357 -0
- package/index.d.ts +2 -2
- package/package.json +4 -1
- package/processScript/index.d.ts +4 -3
- package/processScript/index.js +6 -6
- package/processScript/minify.d.ts +3 -3
- package/processScript/preprocess.d.ts +5 -4
- package/processScript/preprocess.js +2 -2
- package/processScript/transform.d.ts +4 -3
- package/processScript/transform.js +38 -37
- package/push.d.ts +5 -5
- package/push.js +83 -214
- package/syncMacros.js +1 -1
- package/typescript.patch +882 -0
- package/watch.d.ts +3 -3
- package/watch.js +8 -8
package/watch.d.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
import type { LaxPartial } from "@samual/lib";
|
2
2
|
import type { PushOptions } from "./push";
|
3
|
-
export type WatchOptions = PushOptions & {
|
3
|
+
export type WatchOptions = PushOptions & LaxPartial<{
|
4
4
|
/** if provided, will write typescript type declarations for all the scripts on every change detected
|
5
5
|
*
|
6
6
|
* writing the type declarations enables interscript type checking and autocompletetes for the args */
|
7
7
|
typeDeclarationPath: string;
|
8
8
|
onReady: () => void;
|
9
|
-
}
|
9
|
+
}>;
|
10
10
|
/** Watches target file or folder for updates and builds and pushes updated file.
|
11
11
|
* @param sourceDirectory path to folder containing source files
|
12
12
|
* @param hackmudDirectory path to hackmud directory
|
13
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 }?:
|
14
|
+
export declare function watch(sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, typeDeclarationPath: typeDeclarationPath_, onReady, forceQuineCheats }?: WatchOptions): Promise<void>;
|
package/watch.js
CHANGED
@@ -116,7 +116,7 @@ async function watch(
|
|
116
116
|
for (const user of scriptNamesToUsers.get(scriptName)) usersToPushToSet.add(user)
|
117
117
|
const usersToPushTo = [...usersToPushToSet].filter(user => !scriptNamesToUsersToSkip.has(user))
|
118
118
|
if (!usersToPushTo.length) {
|
119
|
-
onPush?.({
|
119
|
+
onPush?.({ path, users: [], characterCount: 0, error: Error("no users to push to") })
|
120
120
|
return
|
121
121
|
}
|
122
122
|
const uniqueID = Math.floor(Math.random() * 2 ** 52)
|
@@ -125,7 +125,7 @@ async function watch(
|
|
125
125
|
filePath = resolve(sourceDirectory, path)
|
126
126
|
let minifiedCode
|
127
127
|
try {
|
128
|
-
;({ script: minifiedCode } = await processScript(await readFile(filePath, { encoding: "
|
128
|
+
;({ script: minifiedCode } = await processScript(await readFile(filePath, { encoding: "utf8" }), {
|
129
129
|
minify,
|
130
130
|
scriptUser: !0,
|
131
131
|
scriptName,
|
@@ -136,7 +136,7 @@ async function watch(
|
|
136
136
|
}))
|
137
137
|
} catch (error) {
|
138
138
|
assert(error instanceof Error, "src/watch.ts:141:36")
|
139
|
-
onPush?.({
|
139
|
+
onPush?.({ path, users: [], characterCount: 0, error })
|
140
140
|
return
|
141
141
|
}
|
142
142
|
await Promise.all(
|
@@ -150,9 +150,9 @@ async function watch(
|
|
150
150
|
)
|
151
151
|
)
|
152
152
|
onPush?.({
|
153
|
-
|
153
|
+
path,
|
154
154
|
users: usersToPushTo,
|
155
|
-
|
155
|
+
characterCount: countHackmudCharacters(minifiedCode),
|
156
156
|
error: void 0
|
157
157
|
})
|
158
158
|
return
|
@@ -168,7 +168,7 @@ async function watch(
|
|
168
168
|
)
|
169
169
|
return
|
170
170
|
const filePath = resolve(sourceDirectory, path),
|
171
|
-
sourceCode = await readFile(filePath, { encoding: "
|
171
|
+
sourceCode = await readFile(filePath, { encoding: "utf8" })
|
172
172
|
let script
|
173
173
|
try {
|
174
174
|
;({ script } = await processScript(sourceCode, {
|
@@ -181,11 +181,11 @@ async function watch(
|
|
181
181
|
}))
|
182
182
|
} catch (error) {
|
183
183
|
assert(error instanceof Error, "src/watch.ts:177:35")
|
184
|
-
onPush?.({
|
184
|
+
onPush?.({ path, users: [], characterCount: 0, error })
|
185
185
|
return
|
186
186
|
}
|
187
187
|
await writeFilePersistent(resolve(hackmudDirectory, user, "scripts", scriptName + ".js"), script)
|
188
|
-
onPush?.({
|
188
|
+
onPush?.({ path, users: [user], characterCount: countHackmudCharacters(script), error: void 0 })
|
189
189
|
})
|
190
190
|
onReady && watcher.on("ready", onReady)
|
191
191
|
if (!typeDeclarationPath_) return
|