|
5 | 5 | * elements live in the renderer; we only attach listeners and forward state |
6 | 6 | * here). Single layer-scoped browser session partition. |
7 | 7 | */ |
8 | | -import * as NodeCrypto from "node:crypto"; |
9 | 8 | import { |
10 | 9 | DesktopPreviewRecordingInputSchema, |
11 | 10 | DESKTOP_PREVIEW_RECORDING_CAPTURE_TRIGGER, |
@@ -49,6 +48,7 @@ import { |
49 | 48 | import * as Cause from "effect/Cause"; |
50 | 49 | import * as Clock from "effect/Clock"; |
51 | 50 | import * as Context from "effect/Context"; |
| 51 | +import * as Crypto from "effect/Crypto"; |
52 | 52 | import * as DateTime from "effect/DateTime"; |
53 | 53 | import * as Deferred from "effect/Deferred"; |
54 | 54 | import * as Effect from "effect/Effect"; |
@@ -643,6 +643,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function |
643 | 643 | const rendererHistory = yield* DesktopRendererHistory.DesktopRendererHistory; |
644 | 644 | const hostPlatform = yield* HostProcessPlatform; |
645 | 645 | const path = yield* Path.Path; |
| 646 | + const crypto = yield* Crypto.Crypto; |
646 | 647 | const parentScope = yield* Scope.Scope; |
647 | 648 | const context = yield* Effect.context<never>(); |
648 | 649 | const runFork = Effect.runForkWith(context); |
@@ -1657,9 +1658,9 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function |
1657 | 1658 | returnByValue: boolean, |
1658 | 1659 | awaitPromise = true, |
1659 | 1660 | ): Effect.Effect<A, PreviewManagerError> => |
1660 | | - Effect.suspend(() => { |
1661 | | - const objectGroup = `t3-evaluation-${NodeCrypto.randomUUID()}`; |
1662 | | - return send("Runtime.evaluate", { |
| 1661 | + Effect.gen(function* () { |
| 1662 | + const objectGroup = `t3-evaluation-${yield* crypto.randomUUIDv4.pipe(Effect.orDie)}`; |
| 1663 | + return yield* send("Runtime.evaluate", { |
1663 | 1664 | expression, |
1664 | 1665 | awaitPromise, |
1665 | 1666 | returnByValue, |
@@ -4186,10 +4187,11 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function |
4186 | 4187 | const context = { operation: "automationPress.awaitNativeKey", tabId, webContentsId: wc.id }; |
4187 | 4188 | const evaluate = (frame: Electron.WebFrameMain, expression: string) => |
4188 | 4189 | attemptPromise(context, () => frame.executeJavaScript(expression)); |
| 4190 | + const receiptId = yield* crypto.randomUUIDv4.pipe(Effect.orDie); |
4189 | 4191 | const { frames, receiptKey } = yield* Effect.acquireRelease( |
4190 | 4192 | attempt(context, () => ({ |
4191 | 4193 | frames: wc.mainFrame.framesInSubtree, |
4192 | | - receiptKey: JSON.stringify(`__t3NativeKey_${NodeCrypto.randomUUID()}`), |
| 4194 | + receiptKey: JSON.stringify(`__t3NativeKey_${receiptId}`), |
4193 | 4195 | })), |
4194 | 4196 | ({ frames, receiptKey }) => |
4195 | 4197 | Effect.forEach( |
@@ -4445,10 +4447,8 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function |
4445 | 4447 | keySequence, |
4446 | 4448 | clipboardData, |
4447 | 4449 | ); |
4448 | | - const selectionKey = yield* encodeJson( |
4449 | | - context, |
4450 | | - `__t3EditingSelection_${NodeCrypto.randomUUID()}`, |
4451 | | - ); |
| 4450 | + const selectionId = yield* crypto.randomUUIDv4.pipe(Effect.orDie); |
| 4451 | + const selectionKey = yield* encodeJson(context, `__t3EditingSelection_${selectionId}`); |
4452 | 4452 | // Editing requires an active document. Preserve the target |
4453 | 4453 | // and selection across focus handlers without focusing the desktop. |
4454 | 4454 | yield* Effect.acquireUseRelease( |
|
0 commit comments