hackmud-script-manager 0.19.1-cb8d65f → 0.19.1-d57be2a
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/README.md +1 -1
- package/bin/hsm.js +43 -155
- package/{src/generateTypeDeclaration.d.ts → generateTypeDeclaration.d.ts} +0 -1
- package/generateTypeDeclaration.js +1 -1
- package/{src/index.d.ts → index.d.ts} +2 -2
- package/package.json +5 -1
- package/{src/processScript → processScript}/index.d.ts +4 -4
- package/processScript/index.js +8 -8
- package/{src/processScript → processScript}/minify.d.ts +4 -4
- package/processScript/minify.js +6 -6
- package/{src/processScript → processScript}/postprocess.d.ts +0 -1
- package/processScript/postprocess.js +1 -1
- package/{src/processScript → processScript}/preprocess.d.ts +5 -5
- package/processScript/preprocess.js +3 -3
- package/{src/processScript → processScript}/transform.d.ts +5 -4
- package/processScript/transform.js +67 -39
- package/{src/pull.d.ts → pull.d.ts} +0 -1
- package/pull.js +1 -1
- package/{src/push.d.ts → push.d.ts} +5 -6
- package/push.js +84 -215
- package/{src/syncMacros.d.ts → syncMacros.d.ts} +0 -1
- package/syncMacros.js +2 -2
- package/{src/watch.d.ts → watch.d.ts} +3 -4
- package/watch.js +9 -9
- /package/{src/bin → bin}/hsm.d.ts +0 -0
- /package/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/{src/processScript → processScript}/shared.d.ts +0 -0
@@ -1,15 +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 }?:
|
15
|
-
export default watch;
|
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
|
@@ -205,4 +205,4 @@ async function watch(
|
|
205
205
|
watcher.on("add", writeTypeDeclaration)
|
206
206
|
watcher.on("unlink", writeTypeDeclaration)
|
207
207
|
}
|
208
|
-
export { watch
|
208
|
+
export { watch }
|
File without changes
|
File without changes
|
File without changes
|