Skip to content

Commit db75121

Browse files
improve watch behavior
1 parent 09aa9d1 commit db75121

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

docs/frida-tools/FridaScript.ts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ declare const watch: {
9898
options?: LoadOptions | undefined
9999
): Effect.Effect<
100100
void,
101-
E | FridaSessionError.FridaSessionError,
101+
FridaSessionError.FridaSessionError,
102102
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript>
103103
>
104104
(
@@ -108,7 +108,7 @@ declare const watch: {
108108
effect: Effect.Effect<A, E, R>
109109
) => Effect.Effect<
110110
void,
111-
E | FridaSessionError.FridaSessionError,
111+
FridaSessionError.FridaSessionError,
112112
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript>
113113
>
114114
}

packages/frida-tools/docs/modules/FridaScript.ts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ declare const watch: {
9898
options?: LoadOptions | undefined
9999
): Effect.Effect<
100100
void,
101-
E | FridaSessionError.FridaSessionError,
101+
FridaSessionError.FridaSessionError,
102102
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript>
103103
>
104104
(
@@ -108,7 +108,7 @@ declare const watch: {
108108
effect: Effect.Effect<A, E, R>
109109
) => Effect.Effect<
110110
void,
111-
E | FridaSessionError.FridaSessionError,
111+
FridaSessionError.FridaSessionError,
112112
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript>
113113
>
114114
}

packages/frida-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@efffrida/frida-tools",
3-
"version": "0.0.19",
3+
"version": "0.0.20",
44
"description": "Frida with effect-ts",
55
"keywords": [
66
"frida.re",

packages/frida-tools/src/FridaScript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export const watch: {
164164
options?: LoadOptions | undefined
165165
): Effect.Effect<
166166
void,
167-
E | FridaSessionError.FridaSessionError,
167+
FridaSessionError.FridaSessionError,
168168
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript>
169169
>;
170170
(
@@ -174,7 +174,7 @@ export const watch: {
174174
effect: Effect.Effect<A, E, R>
175175
) => Effect.Effect<
176176
void,
177-
E | FridaSessionError.FridaSessionError,
177+
FridaSessionError.FridaSessionError,
178178
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript>
179179
>;
180180
} = internal.watch;

packages/frida-tools/src/internal/script.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type * as FridaScript from "../FridaScript.ts";
44
import * as FileSystem from "@effect/platform/FileSystem";
55
import * as Path from "@effect/platform/Path";
66
import * as Cause from "effect/Cause";
7+
import * as Chunk from "effect/Chunk";
78
import * as Context from "effect/Context";
89
import * as Deferred from "effect/Deferred";
910
import * as Effect from "effect/Effect";
@@ -386,7 +387,7 @@ export const watch = Function.dual<
386387
effect: Effect.Effect<A, E, R>
387388
) => Effect.Effect<
388389
void,
389-
E | FridaSessionError.FridaSessionError,
390+
FridaSessionError.FridaSessionError,
390391
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript.FridaScript>
391392
>,
392393
<A, E, R>(
@@ -395,7 +396,7 @@ export const watch = Function.dual<
395396
options?: FridaScript.LoadOptions | undefined
396397
) => Effect.Effect<
397398
void,
398-
E | FridaSessionError.FridaSessionError,
399+
FridaSessionError.FridaSessionError,
399400
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript.FridaScript>
400401
>
401402
>(
@@ -406,7 +407,7 @@ export const watch = Function.dual<
406407
options?: FridaScript.LoadOptions | undefined
407408
): Effect.Effect<
408409
void,
409-
E | FridaSessionError.FridaSessionError,
410+
FridaSessionError.FridaSessionError,
410411
FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript.FridaScript>
411412
> =>
412413
Effect.gen(function* () {
@@ -422,10 +423,21 @@ export const watch = Function.dual<
422423
})
423424
);
424425

425-
const provideFridaScript = Effect.provideServiceEffect(Tag, load(entrypoint, options));
426-
const sink = Sink.forEach((_: void) => provideFridaScript(effect).pipe(Effect.scoped));
426+
const sink = Sink.forEach((event: FileSystem.WatchEvent.Update) =>
427+
Function.pipe(
428+
Effect.logDebug(`reloading ${event.path}`),
429+
Effect.andThen(effect),
430+
Effect.andThen(Effect.logDebug(`script completed`)),
431+
Effect.provideServiceEffect(Tag, load(entrypoint, options)),
432+
Effect.scoped,
433+
Effect.catchAll(Effect.logError),
434+
Effect.catchAllDefect(Effect.logError)
435+
)
436+
);
437+
427438
const stream = fileSystem.watch(pathString).pipe(
428439
Stream.filter((event) => event._tag === "Update"),
440+
Stream.prepend(Chunk.of(FileSystem.WatchEventUpdate({ path: pathString }))),
429441
Stream.mapError(
430442
(cause) =>
431443
new FridaSessionError.FridaSessionError({

packages/rpc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@efffrida/rpc",
3-
"version": "0.0.19",
3+
"version": "0.0.20",
44
"description": "effect rpc-frida",
55
"keywords": [
66
"frida.re",

packages/vitest-pool/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@efffrida/vitest-pool",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "effect frida vitest-pool",
55
"keywords": [
66
"frida.re",

0 commit comments

Comments
 (0)