effect-browser 0.3.0-beta.10 → 0.3.0-beta.13

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.
Files changed (50) hide show
  1. package/README.md +39 -11
  2. package/dist/{Browser-S4kvpmqa.mjs → Browser-QiT6Cdn_.mjs} +30 -7
  3. package/dist/Browser-QiT6Cdn_.mjs.map +1 -0
  4. package/dist/Browser.d.mts +3 -1
  5. package/dist/Browser.mjs +1 -1
  6. package/dist/Cdp.mjs +2 -2
  7. package/dist/Chromium.mjs +2 -2
  8. package/dist/Expect.d.mts +1 -1
  9. package/dist/Expect.mjs +2 -2
  10. package/dist/{Frame-BERmf_gM.d.mts → Frame-Di2PxyF7.d.mts} +3 -1
  11. package/dist/Frame.d.mts +1 -1
  12. package/dist/Frame.mjs +2 -0
  13. package/dist/Frame.mjs.map +1 -1
  14. package/dist/Moment.d.mts +1 -1
  15. package/dist/Moment.mjs +1 -1
  16. package/dist/{Page-BlPjfibv.d.mts → Page-B7X6DQUn.d.mts} +2 -2
  17. package/dist/Page.d.mts +1 -1
  18. package/dist/{Plan-BI8XGvDu.d.mts → Plan-BS0jpENY.d.mts} +15 -8
  19. package/dist/{Plan-D1wrJVs8.mjs → Plan-Bl2NM1D5.mjs} +21 -12
  20. package/dist/Plan-Bl2NM1D5.mjs.map +1 -0
  21. package/dist/Plan.d.mts +1 -1
  22. package/dist/Plan.mjs +1 -1
  23. package/dist/Policy.d.mts +1 -1
  24. package/dist/Presentation.d.mts +1 -1
  25. package/dist/Presentation.mjs +1 -1
  26. package/dist/Stage.d.mts +2 -2
  27. package/dist/Stage.mjs +4 -4
  28. package/dist/Stage.mjs.map +1 -1
  29. package/dist/{context-B6xr8nVi.mjs → context-BAjRj7Xo.mjs} +3 -1
  30. package/dist/context-BAjRj7Xo.mjs.map +1 -0
  31. package/dist/index.d.mts +3 -3
  32. package/dist/index.mjs +2 -2
  33. package/dist/{page-B8tUQELg.mjs → page-ZxMhw16l.mjs} +12 -11
  34. package/dist/page-ZxMhw16l.mjs.map +1 -0
  35. package/package.json +1 -1
  36. package/src/Browser.ts +6 -0
  37. package/src/Frame.ts +2 -0
  38. package/src/Plan.ts +26 -15
  39. package/src/Stage.ts +12 -5
  40. package/src/internal/input/settle.ts +8 -3
  41. package/src/internal/page/bridge.ts +6 -1
  42. package/src/internal/page/context.ts +10 -0
  43. package/src/internal/page/identity.ts +35 -0
  44. package/src/internal/page/navigation.ts +21 -15
  45. package/src/internal/pictures/pictures.ts +3 -2
  46. package/src/internal/pictures/transport.ts +2 -1
  47. package/dist/Browser-S4kvpmqa.mjs.map +0 -1
  48. package/dist/Plan-D1wrJVs8.mjs.map +0 -1
  49. package/dist/context-B6xr8nVi.mjs.map +0 -1
  50. package/dist/page-B8tUQELg.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { Plan } from "./Motion.mjs";
2
2
  import { Action, Box, CursorChanged, KeyChanged, Navigated, PageLoaded, PointerPressed, PointerReleased, Subject, SubjectContext, TextInserted, TrackEvent, TrackPerformed, TrackPlanned, WheelScrolled } from "./BrowserEvent.mjs";
3
3
  import { BrowserError, Failed, InvalidRequest, NavigationFailed, NotActionable, NotFound, PolicyTimeout, StaleRef, Timeout } from "./BrowserError.mjs";
4
- import { a as make$19, c as Current, i as failWith, l as make$18, n as contextGone, o as reasonOf, r as decodeWith, s as undispatched } from "./context-B6xr8nVi.mjs";
4
+ import { a as make$19, c as Current, i as failWith, l as make$18, n as contextGone, o as reasonOf, r as decodeWith, s as undispatched } from "./context-BAjRj7Xo.mjs";
5
5
  import { i as redact, n as parse, s as Correlation, t as addresses } from "./url-Cd04Okid.mjs";
6
6
  import { BrowserPaint, CaptureStats, Frame, Image, Screenshot } from "./Frame.mjs";
7
7
  import { _ as evidence, c as State, g as guard, h as ValidatedInputResultSchema, i as InputRequest, l as Text, m as PreparedInputResultSchema, o as Region, p as redacted, r as Found, s as ResolvedTarget, u as Zoom } from "./Page-B5cjaUp5.mjs";
@@ -2219,6 +2219,7 @@ const make$17 = Effect.fnUntraced(function* (page) {
2219
2219
  /** What a frame that arrives now shows: its session, the page's current document and address. */
2220
2220
  const frameTag = () => ({
2221
2221
  session: page.session,
2222
+ connection: page.connection,
2222
2223
  document: documents,
2223
2224
  url
2224
2225
  });
@@ -3162,7 +3163,7 @@ const make$11 = (page, bridge) => {
3162
3163
  });
3163
3164
  /** Wait for the page to settle after input sent since `before`. */
3164
3165
  const settle = (operation, before) => Effect.gen(function* () {
3165
- yield* bridge.evaluate(operation, scriptCall("settle")).pipe(Effect.catchIf(contextGone, () => Effect.void));
3166
+ yield* bridge.evaluate(operation, scriptCall("settle")).pipe(Effect.provideService(Current, void 0), Effect.catchIf(contextGone, () => Effect.void), Effect.onError(() => page.stopLoading));
3166
3167
  while (document() > before.document && parsed < document()) yield* Deferred.await(changed);
3167
3168
  }).pipe(Effect.timeoutOrElse({
3168
3169
  duration: settling$1,
@@ -4234,6 +4235,7 @@ const apart = (page, bridge, source, error, pageScope) => {
4234
4235
  },
4235
4236
  frameTag: () => ({
4236
4237
  session: page.session,
4238
+ connection: page.connection,
4237
4239
  ...tracked.tag()
4238
4240
  })
4239
4241
  };
@@ -4440,7 +4442,7 @@ const millisOf = (input) => Option.match(Duration.fromInput(input), {
4440
4442
  onNone: () => NaN,
4441
4443
  onSome: Duration.toMillis
4442
4444
  });
4443
- const reuse = (page, viewport, capture) => (operation, options) => Effect.gen(function* () {
4445
+ const reuse = (page, bridge, viewport, capture) => (operation, options) => Effect.gen(function* () {
4444
4446
  const maxAge = millisOf(options.maxAge ?? defaultMaxAge);
4445
4447
  if (!(maxAge >= 0)) return yield* failWith(operation, new InvalidRequest({ detail: "maxAge must be a duration of zero or more" }));
4446
4448
  const latest = yield* capture.latest;
@@ -4448,7 +4450,7 @@ const reuse = (page, viewport, capture) => (operation, options) => Effect.gen(fu
4448
4450
  const { activity } = page;
4449
4451
  return Option.filter(latest, (frame) => {
4450
4452
  const earliest = frame.hostTime - frame.timing.uncertaintyMillis;
4451
- return page.now() - earliest <= maxAge && earliest > activity.documentAt && (options.after !== "input" || earliest > activity.inputAt) && frame.width === known?.width && frame.height === known.height;
4453
+ return frame.document === bridge.frameTag().document && page.now() - earliest <= maxAge && earliest > activity.documentAt && (options.after !== "input" || earliest > activity.inputAt) && frame.width === known?.width && frame.height === known.height;
4452
4454
  });
4453
4455
  });
4454
4456
  /** Where a picture came from: a frame the screencast had delivered, or a new screenshot. */
@@ -4471,7 +4473,7 @@ const make$7 = Effect.fnUntraced(function* (page, bridge, viewport) {
4471
4473
  error
4472
4474
  });
4473
4475
  const picture = camera(page, bridge, viewport, capture);
4474
- const reusable = reuse(page, viewport, capture);
4476
+ const reusable = reuse(page, bridge, viewport, capture);
4475
4477
  const screenshots = lane.shared("screenshot", false);
4476
4478
  const frames = lane.shared("frame", false);
4477
4479
  const screenshot = (options = {}) => screenshots(JSON.stringify([
@@ -4858,7 +4860,7 @@ const make$2 = (page, perform, preparePolicy) => {
4858
4860
  return perform(name, {
4859
4861
  target: url,
4860
4862
  input: false
4861
- }, settings.navigationTimeout, preparePolicy(name, { target: url }, [], { destination: url }), (marks) => marks.sent.pipe(Effect.andThen(native(name, run)), Effect.mapError((error) => error.reason._tag === "Failed" && /net::|NS_ERROR|Cannot navigate/i.test(error.reason.detail) ? new BrowserError({
4863
+ }, settings.navigationTimeout, preparePolicy(name, { target: url }, [], { destination: url }), (marks) => marks.sent.pipe(Effect.andThen(native(name, run).pipe(Effect.onError(() => page.stopLoading))), Effect.mapError((error) => error.reason._tag === "Failed" && /net::|NS_ERROR|Cannot navigate/i.test(error.reason.detail) ? new BrowserError({
4862
4864
  operation: name,
4863
4865
  reason: new NavigationFailed({
4864
4866
  url,
@@ -4899,16 +4901,15 @@ const make$2 = (page, perform, preparePolicy) => {
4899
4901
  const onNavigation = () => {
4900
4902
  Deferred.doneUnsafe(navigated, Effect.void);
4901
4903
  };
4902
- yield* Effect.acquireUseRelease(Effect.sync(() => playwright.on("framenavigated", onNavigation)), () => Effect.gen(function* () {
4903
- yield* marks.sent;
4904
+ yield* Effect.acquireUseRelease(Effect.sync(() => playwright.on("framenavigated", onNavigation)), () => marks.sent.pipe(Effect.andThen(Effect.gen(function* () {
4904
4905
  yield* native("back", () => send("Page.navigateToHistoryEntry", { entryId: previous.id }));
4905
4906
  yield* traversingHistory.pipe(Effect.repeat({
4906
4907
  schedule: Schedule.spaced(Duration.millis(50)),
4907
4908
  until: (latest) => latest.entries[latest.currentIndex]?.id !== current.id
4908
4909
  }));
4909
4910
  yield* Deferred.await(navigated);
4910
- }), () => Effect.sync(() => playwright.off("framenavigated", onNavigation)));
4911
- yield* native("back", () => playwright.waitForLoadState("domcontentloaded", { timeout: 0 }));
4911
+ yield* native("back", () => playwright.waitForLoadState("domcontentloaded", { timeout: 0 })).pipe(Effect.provideService(Current, void 0));
4912
+ }).pipe(Effect.onError(() => page.stopLoading)))), () => Effect.sync(() => playwright.off("framenavigated", onNavigation)));
4912
4913
  });
4913
4914
  const goto = (url) => {
4914
4915
  const parsed = parse(url);
@@ -5070,4 +5071,4 @@ const make = Effect.fnUntraced(function* (options) {
5070
5071
  //#endregion
5071
5072
  export { performed as a, pause as i, make as n, mapping as o, viewOf as r, internalsOf as t };
5072
5073
 
5073
- //# sourceMappingURL=page-B8tUQELg.mjs.map
5074
+ //# sourceMappingURL=page-ZxMhw16l.mjs.map