spana-test 0.2.0 → 0.4.0

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 (138) hide show
  1. package/README.md +47 -12
  2. package/dist/accessibility-audit-RS3VIWRT.js +140 -0
  3. package/dist/accessibility-audit-RS3VIWRT.js.map +1 -0
  4. package/dist/agent/index.d.ts +8 -26
  5. package/dist/agent/index.js +12 -15
  6. package/dist/{allure-PTTVORQ6.js → allure-RNMEYTXS.js} +42 -2
  7. package/dist/allure-RNMEYTXS.js.map +1 -0
  8. package/dist/{android-PAPJJWVN.js → android-GFW6OXPQ.js} +16 -2
  9. package/dist/appium-server-66GVUL24.js +119 -0
  10. package/dist/appium-server-66GVUL24.js.map +1 -0
  11. package/dist/baseline-manager-5TIUCNP5.js +38 -0
  12. package/dist/baseline-manager-5TIUCNP5.js.map +1 -0
  13. package/dist/chunk-3J4NG7JU.js +80 -0
  14. package/dist/chunk-3J4NG7JU.js.map +1 -0
  15. package/dist/{chunk-MRH7SK52.js → chunk-3TRMQCUT.js} +3 -2
  16. package/dist/chunk-3TRMQCUT.js.map +1 -0
  17. package/dist/chunk-5245YBLL.js +127 -0
  18. package/dist/chunk-5245YBLL.js.map +1 -0
  19. package/dist/{chunk-L7MFJF46.js → chunk-7VOWF42B.js} +29 -5
  20. package/dist/chunk-7VOWF42B.js.map +1 -0
  21. package/dist/{chunk-GZK22EIE.js → chunk-EWIR2GVV.js} +54 -1
  22. package/dist/chunk-EWIR2GVV.js.map +1 -0
  23. package/dist/{chunk-P7JQRLP4.js → chunk-FJAJ4YNC.js} +14 -2
  24. package/dist/chunk-FJAJ4YNC.js.map +1 -0
  25. package/dist/chunk-IHVZKQQW.js +24 -0
  26. package/dist/chunk-IHVZKQQW.js.map +1 -0
  27. package/dist/{chunk-S4R4OR7T.js → chunk-KYPLYRKW.js} +67 -72
  28. package/dist/chunk-KYPLYRKW.js.map +1 -0
  29. package/dist/{chunk-YBZCOQXJ.js → chunk-LC3QJIHY.js} +196 -67
  30. package/dist/chunk-LC3QJIHY.js.map +1 -0
  31. package/dist/{chunk-WQ4GXUUE.js → chunk-MCT4DYDK.js} +353 -84
  32. package/dist/chunk-MCT4DYDK.js.map +1 -0
  33. package/dist/chunk-OBCFACUW.js +28 -0
  34. package/dist/chunk-OBCFACUW.js.map +1 -0
  35. package/dist/{chunk-AEKDFFPJ.js → chunk-PZYZ4O6D.js} +16 -5
  36. package/dist/chunk-PZYZ4O6D.js.map +1 -0
  37. package/dist/{chunk-SFBRFB2N.js → chunk-S5JNNDXS.js} +62 -12
  38. package/dist/chunk-S5JNNDXS.js.map +1 -0
  39. package/dist/{chunk-VNYF5BHX.js → chunk-X2TJP7LB.js} +1 -3
  40. package/dist/{chunk-S2XNAKSO.js → chunk-YAV6KBSW.js} +564 -333
  41. package/dist/chunk-YAV6KBSW.js.map +1 -0
  42. package/dist/{chunk-3YR4GUGE.js → chunk-YGHDMA6D.js} +65 -70
  43. package/dist/chunk-YGHDMA6D.js.map +1 -0
  44. package/dist/cli.js +40 -25
  45. package/dist/cli.js.map +1 -1
  46. package/dist/{compiler-74VGKZO6.js → compiler-X6WTFMYF.js} +15 -7
  47. package/dist/compiler-X6WTFMYF.js.map +1 -0
  48. package/dist/config-loader-QM72GKEL.js +9 -0
  49. package/dist/{console-XWKUTP3D.js → console-7UW7VROK.js} +71 -1
  50. package/dist/console-7UW7VROK.js.map +1 -0
  51. package/dist/{discover-KZKXHZZA.js → discover-CAQY6EG6.js} +5 -4
  52. package/dist/doctor-command-YGQPO7GH.js +71 -0
  53. package/dist/doctor-command-YGQPO7GH.js.map +1 -0
  54. package/dist/flow-thjUxXXx.d.ts +168 -0
  55. package/dist/gherkin/steps.d.ts +2 -2
  56. package/dist/{html-GE6Q4DCG.js → html-F3X3XPSX.js} +78 -7
  57. package/dist/html-F3X3XPSX.js.map +1 -0
  58. package/dist/index.d.ts +4 -8
  59. package/dist/index.js +4 -4
  60. package/dist/index.js.map +1 -1
  61. package/dist/{init-command-GVMRXIMY.js → init-command-U66XCM66.js} +19 -34
  62. package/dist/init-command-U66XCM66.js.map +1 -0
  63. package/dist/init-flow-command-PR7J5FBM.js +37 -0
  64. package/dist/init-flow-command-PR7J5FBM.js.map +1 -0
  65. package/dist/{installer-YZJ4DV3F.js → installer-PVBSX7UC.js} +3 -4
  66. package/dist/{ios-ZW6XVNLG.js → ios-JPK43TFZ.js} +11 -4
  67. package/dist/json-JMRPUVY2.js +20 -0
  68. package/dist/json-JMRPUVY2.js.map +1 -0
  69. package/dist/machine-6H25TRTU.js +16 -0
  70. package/dist/{provider-A57C3MU6.js → provider-YIPU5K42.js} +2 -2
  71. package/dist/{runner-UXNHVVGG.js → runner-6HK62Q7B.js} +2 -2
  72. package/dist/screenshot-compare-JFHH2WR4.js +75 -0
  73. package/dist/screenshot-compare-JFHH2WR4.js.map +1 -0
  74. package/dist/{server-W7OA3DDN.js → server-PZBRGU7P.js} +362 -55
  75. package/dist/server-PZBRGU7P.js.map +1 -0
  76. package/dist/session-2MZVGYAC.js +17 -0
  77. package/dist/{coordinator-BbUjvvnX.d.ts → storybook-pBOPe_1D.d.ts} +101 -33
  78. package/dist/{studio-command-6VHTHDUK.js → studio-command-YDWQOMRX.js} +2 -2
  79. package/dist/{test-command-AHMOZLV4.js → test-command-B2VLWGDK.js} +945 -565
  80. package/dist/test-command-B2VLWGDK.js.map +1 -0
  81. package/dist/{validator-35624P7S.js → validator-HZ2A3NEI.js} +3 -6
  82. package/dist/validator-HZ2A3NEI.js.map +1 -0
  83. package/package.json +6 -1
  84. package/studio-dist/assets/index-C-Io44gy.js +193 -0
  85. package/studio-dist/assets/index-DfM9lK4p.css +1 -0
  86. package/studio-dist/index.html +2 -2
  87. package/dist/allure-PTTVORQ6.js.map +0 -1
  88. package/dist/chunk-3YR4GUGE.js.map +0 -1
  89. package/dist/chunk-AEKDFFPJ.js.map +0 -1
  90. package/dist/chunk-BF37W5EG.js +0 -125
  91. package/dist/chunk-BF37W5EG.js.map +0 -1
  92. package/dist/chunk-EXLUY7KT.js +0 -21
  93. package/dist/chunk-EXLUY7KT.js.map +0 -1
  94. package/dist/chunk-FNDOEMOL.js +0 -62
  95. package/dist/chunk-FNDOEMOL.js.map +0 -1
  96. package/dist/chunk-GZK22EIE.js.map +0 -1
  97. package/dist/chunk-HWFDXIXR.js +0 -183
  98. package/dist/chunk-HWFDXIXR.js.map +0 -1
  99. package/dist/chunk-IJIASIX5.js +0 -314
  100. package/dist/chunk-IJIASIX5.js.map +0 -1
  101. package/dist/chunk-L7MFJF46.js.map +0 -1
  102. package/dist/chunk-MRH7SK52.js.map +0 -1
  103. package/dist/chunk-P7JQRLP4.js.map +0 -1
  104. package/dist/chunk-S2XNAKSO.js.map +0 -1
  105. package/dist/chunk-S4R4OR7T.js.map +0 -1
  106. package/dist/chunk-SFBRFB2N.js.map +0 -1
  107. package/dist/chunk-WBU34APM.js +0 -38
  108. package/dist/chunk-WBU34APM.js.map +0 -1
  109. package/dist/chunk-WQ4GXUUE.js.map +0 -1
  110. package/dist/chunk-YBZCOQXJ.js.map +0 -1
  111. package/dist/compiler-74VGKZO6.js.map +0 -1
  112. package/dist/config-loader-BJJ3IJJ7.js +0 -9
  113. package/dist/console-XWKUTP3D.js.map +0 -1
  114. package/dist/doctor-command-T2UX5RV5.js +0 -732
  115. package/dist/doctor-command-T2UX5RV5.js.map +0 -1
  116. package/dist/flow-BUC9Mf8W.d.ts +0 -128
  117. package/dist/html-GE6Q4DCG.js.map +0 -1
  118. package/dist/init-command-GVMRXIMY.js.map +0 -1
  119. package/dist/init-flow-command-R76AXF4Z.js +0 -34
  120. package/dist/init-flow-command-R76AXF4Z.js.map +0 -1
  121. package/dist/json-KS67BZYU.js +0 -39
  122. package/dist/json-KS67BZYU.js.map +0 -1
  123. package/dist/server-W7OA3DDN.js.map +0 -1
  124. package/dist/session-TMNOKYLG.js +0 -17
  125. package/dist/test-command-AHMOZLV4.js.map +0 -1
  126. package/studio-dist/assets/index-DC6DIXfl.js +0 -188
  127. package/studio-dist/assets/index-DDKsnBwD.css +0 -1
  128. /package/dist/{android-PAPJJWVN.js.map → android-GFW6OXPQ.js.map} +0 -0
  129. /package/dist/{chunk-VNYF5BHX.js.map → chunk-X2TJP7LB.js.map} +0 -0
  130. /package/dist/{config-loader-BJJ3IJJ7.js.map → config-loader-QM72GKEL.js.map} +0 -0
  131. /package/dist/{discover-KZKXHZZA.js.map → discover-CAQY6EG6.js.map} +0 -0
  132. /package/dist/{installer-YZJ4DV3F.js.map → installer-PVBSX7UC.js.map} +0 -0
  133. /package/dist/{ios-ZW6XVNLG.js.map → ios-JPK43TFZ.js.map} +0 -0
  134. /package/dist/{provider-A57C3MU6.js.map → machine-6H25TRTU.js.map} +0 -0
  135. /package/dist/{runner-UXNHVVGG.js.map → provider-YIPU5K42.js.map} +0 -0
  136. /package/dist/{session-TMNOKYLG.js.map → runner-6HK62Q7B.js.map} +0 -0
  137. /package/dist/{validator-35624P7S.js.map → session-2MZVGYAC.js.map} +0 -0
  138. /package/dist/{studio-command-6VHTHDUK.js.map → studio-command-YDWQOMRX.js.map} +0 -0
@@ -19,34 +19,25 @@ var TextMismatchError = class extends Schema.TaggedError()(
19
19
  }
20
20
  ) {
21
21
  };
22
- var TimeoutError = class extends Schema.TaggedError()(
23
- "TimeoutError",
24
- {
25
- message: Schema.String,
26
- operation: Schema.String,
27
- timeoutMs: Schema.Number
28
- }
29
- ) {
22
+ var TimeoutError = class extends Schema.TaggedError()("TimeoutError", {
23
+ message: Schema.String,
24
+ operation: Schema.String,
25
+ timeoutMs: Schema.Number
26
+ }) {
30
27
  };
31
- var WaitTimeoutError = class extends Schema.TaggedError()(
32
- "WaitTimeoutError",
33
- {
34
- message: Schema.String,
35
- selector: Schema.Unknown,
36
- timeoutMs: Schema.Number
37
- }
38
- ) {
28
+ var WaitTimeoutError = class extends Schema.TaggedError()("WaitTimeoutError", {
29
+ message: Schema.String,
30
+ selector: Schema.Unknown,
31
+ timeoutMs: Schema.Number
32
+ }) {
39
33
  };
40
- var DriverError = class extends Schema.TaggedError()(
41
- "DriverError",
42
- {
43
- message: Schema.String,
44
- command: Schema.optional(Schema.String),
45
- exitCode: Schema.optional(Schema.Number),
46
- stdout: Schema.optional(Schema.String),
47
- stderr: Schema.optional(Schema.String)
48
- }
49
- ) {
34
+ var DriverError = class extends Schema.TaggedError()("DriverError", {
35
+ message: Schema.String,
36
+ command: Schema.optional(Schema.String),
37
+ exitCode: Schema.optional(Schema.Number),
38
+ stdout: Schema.optional(Schema.String),
39
+ stderr: Schema.optional(Schema.String)
40
+ }) {
50
41
  };
51
42
  var DeviceDisconnectedError = class extends Schema.TaggedError()(
52
43
  "DeviceDisconnectedError",
@@ -57,14 +48,11 @@ var DeviceDisconnectedError = class extends Schema.TaggedError()(
57
48
  }
58
49
  ) {
59
50
  };
60
- var AppCrashedError = class extends Schema.TaggedError()(
61
- "AppCrashedError",
62
- {
63
- message: Schema.String,
64
- appId: Schema.optional(Schema.String),
65
- platform: Schema.optional(Schema.String)
66
- }
67
- ) {
51
+ var AppCrashedError = class extends Schema.TaggedError()("AppCrashedError", {
52
+ message: Schema.String,
53
+ appId: Schema.optional(Schema.String),
54
+ platform: Schema.optional(Schema.String)
55
+ }) {
68
56
  };
69
57
  var AppNotInstalledError = class extends Schema.TaggedError()(
70
58
  "AppNotInstalledError",
@@ -75,13 +63,10 @@ var AppNotInstalledError = class extends Schema.TaggedError()(
75
63
  }
76
64
  ) {
77
65
  };
78
- var FlowSyntaxError = class extends Schema.TaggedError()(
79
- "FlowSyntaxError",
80
- {
81
- message: Schema.String,
82
- filePath: Schema.String
83
- }
84
- ) {
66
+ var FlowSyntaxError = class extends Schema.TaggedError()("FlowSyntaxError", {
67
+ message: Schema.String,
68
+ filePath: Schema.String
69
+ }) {
85
70
  };
86
71
  var DeviceNotFoundError = class extends Schema.TaggedError()(
87
72
  "DeviceNotFoundError",
@@ -92,29 +77,26 @@ var DeviceNotFoundError = class extends Schema.TaggedError()(
92
77
  }
93
78
  ) {
94
79
  };
95
- var ConfigError = class extends Schema.TaggedError()(
96
- "ConfigError",
97
- {
98
- message: Schema.String,
99
- filePath: Schema.optional(Schema.String)
100
- }
101
- ) {
80
+ var ConfigError = class extends Schema.TaggedError()("ConfigError", {
81
+ message: Schema.String,
82
+ filePath: Schema.optional(Schema.String)
83
+ }) {
102
84
  };
103
85
 
104
86
  // src/schemas/selector.ts
105
87
  import { Schema as Schema2 } from "effect";
106
- var TestIDSelector = Schema2.Struct({ testID: Schema2.String });
107
- var TextSelector = Schema2.Struct({ text: Schema2.String });
108
- var AccessibilityLabelSelector = Schema2.Struct({ accessibilityLabel: Schema2.String });
109
- var PointSelector = Schema2.Struct({
88
+ var _TestIDSelectorSchema = Schema2.Struct({ testID: Schema2.String });
89
+ var _TextSelectorSchema = Schema2.Struct({ text: Schema2.String });
90
+ var _AccessibilityLabelSelectorSchema = Schema2.Struct({ accessibilityLabel: Schema2.String });
91
+ var _PointSelectorSchema = Schema2.Struct({
110
92
  point: Schema2.Struct({ x: Schema2.Number, y: Schema2.Number })
111
93
  });
112
- var Selector = Schema2.Union(
94
+ var SelectorSchema = Schema2.Union(
113
95
  Schema2.String,
114
- TestIDSelector,
115
- TextSelector,
116
- AccessibilityLabelSelector,
117
- PointSelector
96
+ _TestIDSelectorSchema,
97
+ _TextSelectorSchema,
98
+ _AccessibilityLabelSelectorSchema,
99
+ _PointSelectorSchema
118
100
  );
119
101
  function isRelativeSelector(sel) {
120
102
  return typeof sel === "object" && sel !== null && "selector" in sel;
@@ -627,6 +609,334 @@ function createCoordinator(driver, config) {
627
609
  yield* driver.back();
628
610
  yield* afterMutation();
629
611
  });
612
+ const scaleGesture = (methodName, selector, opts) => Effect3.gen(function* () {
613
+ const element = yield* waitForActionElement(
614
+ driver,
615
+ selector,
616
+ parse,
617
+ { ...defaults, ...opts },
618
+ cache
619
+ );
620
+ const { x, y } = centerOf(element);
621
+ const scale = opts?.scale ?? 0.5;
622
+ const duration = opts?.duration ?? 1500;
623
+ const fn = methodName === "pinch" ? driver.pinch : driver.zoom;
624
+ if (!fn) {
625
+ return yield* new DriverError({
626
+ message: `${methodName}() is only supported on mobile platforms (Android/iOS)`
627
+ });
628
+ }
629
+ yield* fn.call(driver, x, y, scale, duration);
630
+ yield* afterMutation();
631
+ });
632
+ const assertEnabledState = (selector, expectedEnabled, opts) => Effect3.gen(function* () {
633
+ const element = yield* waitForElement(
634
+ driver,
635
+ selector,
636
+ parse,
637
+ { ...defaults, ...opts },
638
+ cache
639
+ );
640
+ const isEnabled = element.enabled !== false;
641
+ if (isEnabled !== expectedEnabled) {
642
+ const state = expectedEnabled ? "enabled" : "disabled";
643
+ const actual = expectedEnabled ? "disabled" : "enabled";
644
+ return yield* new TextMismatchError({
645
+ message: `Expected element to be ${state} but it is ${actual} \u2014 selector: ${formatSelector(selector)}`,
646
+ expected: state,
647
+ actual,
648
+ selector
649
+ });
650
+ }
651
+ });
652
+ const createAssertions = () => ({
653
+ assertVisible: (selector, opts) => waitForElement(driver, selector, parse, { ...defaults, ...opts }, cache),
654
+ assertHidden: (selector, opts) => waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }, cache),
655
+ assertText: (selector, expected, opts) => pollUntilMatch(
656
+ selector,
657
+ opts,
658
+ (el) => ({ matched: el.text === expected, actual: el.text }),
659
+ (actual, timeout) => ({
660
+ message: `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
661
+ expected
662
+ })
663
+ ),
664
+ assertContainsText: (selector, expected, opts) => pollUntilMatch(
665
+ selector,
666
+ opts,
667
+ (el) => {
668
+ const actual = el.text ?? "";
669
+ return {
670
+ matched: actual.toLowerCase().includes(expected.toLowerCase()),
671
+ actual: el.text
672
+ };
673
+ },
674
+ (actual, timeout) => ({
675
+ message: `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
676
+ expected
677
+ })
678
+ ),
679
+ assertEnabled: (selector, opts) => assertEnabledState(selector, true, opts),
680
+ assertDisabled: (selector, opts) => assertEnabledState(selector, false, opts),
681
+ getText: (selector, opts) => Effect3.gen(function* () {
682
+ const element = yield* waitForElement(
683
+ driver,
684
+ selector,
685
+ parse,
686
+ { ...defaults, ...opts },
687
+ cache
688
+ );
689
+ return element.text ?? "";
690
+ }),
691
+ isElementEnabled: (selector, opts) => Effect3.gen(function* () {
692
+ const element = yield* waitForElement(
693
+ driver,
694
+ selector,
695
+ parse,
696
+ { ...defaults, ...opts },
697
+ cache
698
+ );
699
+ return element.enabled !== false;
700
+ }),
701
+ assertValue: (selector, expected, opts) => {
702
+ const expectedStr = String(expected);
703
+ return pollUntilMatch(
704
+ selector,
705
+ opts,
706
+ (el) => {
707
+ const actual = el.value ?? "";
708
+ return { matched: actual === expectedStr, actual };
709
+ },
710
+ (actual, timeout) => ({
711
+ message: `Expected value "${expectedStr}" but got "${actual ?? "(no value)"}" after ${timeout}ms`,
712
+ expected: expectedStr
713
+ })
714
+ );
715
+ },
716
+ assertAttribute: (selector, name, expectedValue, opts) => pollUntilMatch(
717
+ selector,
718
+ opts,
719
+ (el) => {
720
+ const actual = el.attributes?.[name];
721
+ if (expectedValue === void 0) {
722
+ return { matched: actual !== void 0, actual };
723
+ }
724
+ return { matched: actual === expectedValue, actual };
725
+ },
726
+ (actual, timeout) => expectedValue === void 0 ? {
727
+ message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
728
+ expected: name
729
+ } : {
730
+ message: `Expected attribute "${name}" to be "${expectedValue}" but got "${actual ?? "(not found)"}" after ${timeout}ms`,
731
+ expected: expectedValue
732
+ }
733
+ ),
734
+ assertMatchesText: (selector, pattern, opts) => pollUntilMatch(
735
+ selector,
736
+ opts,
737
+ (el) => {
738
+ const actual = el.text ?? "";
739
+ return { matched: pattern.test(actual), actual };
740
+ },
741
+ (actual, timeout) => ({
742
+ message: `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
743
+ expected: String(pattern)
744
+ })
745
+ ),
746
+ getAttribute: (selector, name, opts) => Effect3.gen(function* () {
747
+ const element = yield* waitForElement(
748
+ driver,
749
+ selector,
750
+ parse,
751
+ { ...defaults, ...opts },
752
+ cache
753
+ );
754
+ return element.attributes?.[name];
755
+ }),
756
+ assertScreenshot: (selector, name, flowFilePath, flowName, platform, options) => Effect3.gen(function* () {
757
+ const { resolveBaselinePath, readBaseline, writeBaseline } = yield* Effect3.promise(
758
+ () => import("./baseline-manager-5TIUCNP5.js")
759
+ );
760
+ const { cropToElement, applyMask, compareScreenshots } = yield* Effect3.promise(
761
+ () => import("./screenshot-compare-JFHH2WR4.js")
762
+ );
763
+ const raw = yield* driver.takeScreenshot();
764
+ let screenshotBuf;
765
+ if (selector !== void 0) {
766
+ const element = yield* waitForElement(driver, selector, parse, { ...defaults }, cache);
767
+ screenshotBuf = yield* Effect3.promise(() => cropToElement(raw, element.bounds));
768
+ } else {
769
+ screenshotBuf = Buffer.from(raw);
770
+ }
771
+ const baselinePath = resolveBaselinePath(
772
+ flowFilePath,
773
+ flowName,
774
+ platform,
775
+ name,
776
+ options.baselinesDir
777
+ );
778
+ if (options.updateBaselines) {
779
+ yield* Effect3.promise(() => Promise.resolve(writeBaseline(baselinePath, screenshotBuf)));
780
+ return;
781
+ }
782
+ const existing = readBaseline(baselinePath);
783
+ if (existing === null) {
784
+ yield* Effect3.promise(() => Promise.resolve(writeBaseline(baselinePath, screenshotBuf)));
785
+ return;
786
+ }
787
+ let actualBuf = screenshotBuf;
788
+ if (options.mask && options.mask.length > 0) {
789
+ actualBuf = yield* Effect3.promise(() => applyMask(screenshotBuf, options.mask));
790
+ }
791
+ const result = compareScreenshots(existing, actualBuf, {
792
+ threshold: options.threshold,
793
+ maxDiffPixelRatio: options.maxDiffPixelRatio
794
+ });
795
+ if (!result.match) {
796
+ const { writeFileSync, mkdirSync } = yield* Effect3.promise(() => import("fs"));
797
+ const { join } = yield* Effect3.promise(() => import("path"));
798
+ const outDir = options.outputDir ?? config.outputDir ?? "spana-output";
799
+ mkdirSync(outDir, { recursive: true });
800
+ const safeFlowName = flowName.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-|-$/g, "");
801
+ const prefix = join(outDir, `${safeFlowName}-${platform}-${name}`);
802
+ writeFileSync(`${prefix}-expected.png`, existing);
803
+ writeFileSync(`${prefix}-actual.png`, actualBuf);
804
+ if (result.diffImage) {
805
+ writeFileSync(`${prefix}-diff.png`, result.diffImage);
806
+ }
807
+ const detail = result.sizeMismatch ? "image dimensions differ" : `${result.diffPixelCount} differing pixels (ratio: ${(result.diffPixelRatio * 100).toFixed(2)}%)`;
808
+ return yield* new DriverError({
809
+ message: `Screenshot mismatch for "${name}": ${detail}. Expected: ${prefix}-expected.png, Actual: ${prefix}-actual.png${result.diffImage ? `, Diff: ${prefix}-diff.png` : ""}`
810
+ });
811
+ }
812
+ }),
813
+ assertAccessibilityLabel: (selector, expected, opts) => pollUntilMatch(
814
+ selector,
815
+ opts,
816
+ (el) => {
817
+ const label = el.accessibilityLabel;
818
+ if (expected === void 0) {
819
+ return { matched: label !== void 0 && label.length > 0, actual: label };
820
+ }
821
+ return { matched: label === expected, actual: label };
822
+ },
823
+ (actual, timeout) => expected === void 0 ? {
824
+ message: `Expected element to have a non-empty accessibilityLabel but got "${actual ?? "(none)"}" after ${timeout}ms`,
825
+ expected: "(non-empty)"
826
+ } : {
827
+ message: `Expected accessibilityLabel "${expected}" but got "${actual ?? "(none)"}" after ${timeout}ms`,
828
+ expected
829
+ }
830
+ ),
831
+ assertFocusable: (selector, platform, opts) => Effect3.gen(function* () {
832
+ const { isFocusable } = yield* Effect3.promise(
833
+ () => import("./accessibility-audit-RS3VIWRT.js")
834
+ );
835
+ yield* pollUntilMatch(
836
+ selector,
837
+ opts,
838
+ (el) => {
839
+ const focusable = isFocusable(el, {
840
+ platform
841
+ });
842
+ return { matched: focusable, actual: focusable ? "focusable" : "not focusable" };
843
+ },
844
+ (actual, timeout) => ({
845
+ message: `Expected element to be focusable but it was "${actual ?? "not focusable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
846
+ expected: "focusable"
847
+ })
848
+ );
849
+ }),
850
+ assertRole: (selector, expectedRole, platform, opts) => Effect3.gen(function* () {
851
+ const { normalizeRole } = yield* Effect3.promise(
852
+ () => import("./accessibility-audit-RS3VIWRT.js")
853
+ );
854
+ yield* pollUntilMatch(
855
+ selector,
856
+ opts,
857
+ (el) => {
858
+ const actual = normalizeRole(
859
+ platform,
860
+ el.elementType ?? "",
861
+ el.attributes ?? {}
862
+ );
863
+ return { matched: actual === expectedRole, actual };
864
+ },
865
+ (actual, timeout) => ({
866
+ message: `Expected role "${expectedRole}" but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
867
+ expected: expectedRole
868
+ })
869
+ );
870
+ }),
871
+ assertMinTouchTarget: (selector, minSize, opts) => pollUntilMatch(
872
+ selector,
873
+ opts,
874
+ (el) => {
875
+ const { width, height } = el.bounds;
876
+ const passed = width >= minSize && height >= minSize;
877
+ const actual = `${width}x${height}`;
878
+ return { matched: passed, actual };
879
+ },
880
+ (actual, timeout) => ({
881
+ message: `Expected touch target to be at least ${minSize}x${minSize}px but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
882
+ expected: `${minSize}x${minSize}`
883
+ })
884
+ ),
885
+ assertAccessibilityAudit: (platform, options = {}) => Effect3.gen(function* () {
886
+ if (platform !== "web") {
887
+ return yield* new DriverError({
888
+ message: `assertAccessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
889
+ });
890
+ }
891
+ const { readFileSync } = yield* Effect3.promise(() => import("fs"));
892
+ const { createRequire } = yield* Effect3.promise(() => import("module"));
893
+ const require2 = createRequire(import.meta.url);
894
+ const axePath = require2.resolve("axe-core/axe.js");
895
+ const axeSource = readFileSync(axePath, "utf-8");
896
+ const { filterViolations, formatViolationSummary } = yield* Effect3.promise(
897
+ () => import("./accessibility-audit-RS3VIWRT.js")
898
+ );
899
+ const axeContext = {};
900
+ if (options.targetSelector) {
901
+ axeContext["include"] = [[options.targetSelector]];
902
+ }
903
+ if (options.excludeSelectors && options.excludeSelectors.length > 0) {
904
+ axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
905
+ }
906
+ const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
907
+ const axeOptions = {};
908
+ if (options.rules && options.rules.length > 0) {
909
+ const rulesConfig = {};
910
+ for (const r of options.rules) rulesConfig[r] = { enabled: true };
911
+ axeOptions["rules"] = rulesConfig;
912
+ }
913
+ const script = `
914
+ (function() {
915
+ ${axeSource}
916
+ return axe.run(${serializedContext}, ${JSON.stringify(axeOptions)});
917
+ })()
918
+ `;
919
+ const axeResult = yield* driver.evaluate(script);
920
+ const violations = axeResult.violations.map((v) => ({
921
+ ruleId: v.id,
922
+ severity: v.impact ?? "minor",
923
+ description: v.description,
924
+ helpUrl: v.helpUrl,
925
+ wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
926
+ elements: v.nodes.map((n) => ({
927
+ selector: n.target.join(", "),
928
+ html: n.html,
929
+ failureSummary: n.failureSummary
930
+ }))
931
+ }));
932
+ const minSeverity = options.severity ?? "serious";
933
+ const filtered = filterViolations(violations, minSeverity);
934
+ if (filtered.length > 0) {
935
+ const summary = formatViolationSummary(filtered);
936
+ return yield* new DriverError({ message: summary });
937
+ }
938
+ })
939
+ });
630
940
  return {
631
941
  tap: (selector, opts) => Effect3.gen(function* () {
632
942
  const element = yield* waitForActionElement(
@@ -776,44 +1086,8 @@ function createCoordinator(driver, config) {
776
1086
  timeoutMs: totalTimeout
777
1087
  });
778
1088
  }),
779
- pinch: (selector, opts) => Effect3.gen(function* () {
780
- const element = yield* waitForActionElement(
781
- driver,
782
- selector,
783
- parse,
784
- { ...defaults, ...opts },
785
- cache
786
- );
787
- const { x, y } = centerOf(element);
788
- const scale = opts?.scale ?? 0.5;
789
- const duration = opts?.duration ?? 1500;
790
- if (!driver.pinch) {
791
- return yield* new DriverError({
792
- message: "pinch() is only supported on mobile platforms (Android/iOS)"
793
- });
794
- }
795
- yield* driver.pinch(x, y, scale, duration);
796
- yield* afterMutation();
797
- }),
798
- zoom: (selector, opts) => Effect3.gen(function* () {
799
- const element = yield* waitForActionElement(
800
- driver,
801
- selector,
802
- parse,
803
- { ...defaults, ...opts },
804
- cache
805
- );
806
- const { x, y } = centerOf(element);
807
- const scale = opts?.scale ?? 0.5;
808
- const duration = opts?.duration ?? 1500;
809
- if (!driver.zoom) {
810
- return yield* new DriverError({
811
- message: "zoom() is only supported on mobile platforms (Android/iOS)"
812
- });
813
- }
814
- yield* driver.zoom(x, y, scale, duration);
815
- yield* afterMutation();
816
- }),
1089
+ pinch: (selector, opts) => scaleGesture("pinch", selector, opts),
1090
+ zoom: (selector, opts) => scaleGesture("zoom", selector, opts),
817
1091
  multiTouch: (sequences) => Effect3.gen(function* () {
818
1092
  if (!driver.multiTouch) {
819
1093
  return yield* new DriverError({
@@ -823,265 +1097,222 @@ function createCoordinator(driver, config) {
823
1097
  yield* driver.multiTouch(sequences);
824
1098
  yield* afterMutation();
825
1099
  }),
826
- assertVisible: (selector, opts) => waitForElement(driver, selector, parse, { ...defaults, ...opts }, cache),
827
- assertHidden: (selector, opts) => waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }, cache),
828
- assertText: (selector, expected, opts) => pollUntilMatch(
829
- selector,
830
- opts,
831
- (el) => ({ matched: el.text === expected, actual: el.text }),
832
- (actual, timeout) => ({
833
- message: `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
834
- expected
835
- })
836
- ),
837
- assertContainsText: (selector, expected, opts) => pollUntilMatch(
838
- selector,
839
- opts,
840
- (el) => {
841
- const actual = el.text ?? "";
842
- return {
843
- matched: actual.toLowerCase().includes(expected.toLowerCase()),
844
- actual: el.text
845
- };
846
- },
847
- (actual, timeout) => ({
848
- message: `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
849
- expected
850
- })
851
- ),
852
- assertEnabled: (selector, opts) => Effect3.gen(function* () {
853
- const element = yield* waitForElement(
854
- driver,
855
- selector,
856
- parse,
857
- { ...defaults, ...opts },
858
- cache
859
- );
860
- if (element.enabled === false) {
861
- return yield* new TextMismatchError({
862
- message: `Expected element to be enabled but it is disabled \u2014 selector: ${formatSelector(selector)}`,
863
- expected: "enabled",
864
- actual: "disabled",
865
- selector
866
- });
867
- }
868
- }),
869
- assertDisabled: (selector, opts) => Effect3.gen(function* () {
870
- const element = yield* waitForElement(
871
- driver,
872
- selector,
873
- parse,
874
- { ...defaults, ...opts },
875
- cache
876
- );
877
- if (element.enabled !== false) {
878
- return yield* new TextMismatchError({
879
- message: `Expected element to be disabled but it is enabled \u2014 selector: ${formatSelector(selector)}`,
880
- expected: "disabled",
881
- actual: "enabled",
882
- selector
883
- });
884
- }
885
- }),
886
- getText: (selector, opts) => Effect3.gen(function* () {
887
- const element = yield* waitForElement(
888
- driver,
889
- selector,
890
- parse,
891
- { ...defaults, ...opts },
892
- cache
893
- );
894
- return element.text ?? "";
895
- }),
896
- isElementEnabled: (selector, opts) => Effect3.gen(function* () {
897
- const element = yield* waitForElement(
898
- driver,
899
- selector,
900
- parse,
901
- { ...defaults, ...opts },
902
- cache
903
- );
904
- return element.enabled !== false;
905
- }),
906
- assertValue: (selector, expected, opts) => {
907
- const expectedStr = String(expected);
908
- return pollUntilMatch(
909
- selector,
910
- opts,
911
- (el) => {
912
- const actual = el.value ?? "";
913
- return { matched: actual === expectedStr, actual };
914
- },
915
- (actual, timeout) => ({
916
- message: `Expected value "${expectedStr}" but got "${actual ?? "(no value)"}" after ${timeout}ms`,
917
- expected: expectedStr
918
- })
919
- );
1100
+ ...createAssertions()
1101
+ };
1102
+ }
1103
+
1104
+ // src/api/storybook.ts
1105
+ function assertSafeStorybookToken(group, key, value) {
1106
+ if (/[;:=]/.test(key)) {
1107
+ throw new DriverError({
1108
+ message: `openStory() ${group} key "${key}" contains unsupported Storybook query characters (;, :, =).`
1109
+ });
1110
+ }
1111
+ if (typeof value === "string" && /[;:]/.test(value)) {
1112
+ throw new DriverError({
1113
+ message: `openStory() ${group}.${key} contains unsupported Storybook query characters (; or :).`
1114
+ });
1115
+ }
1116
+ }
1117
+ function encodeStorybookValue(value) {
1118
+ if (value === null) {
1119
+ return "!null";
1120
+ }
1121
+ return String(value);
1122
+ }
1123
+ function encodeStorybookEntries(group, entries) {
1124
+ if (!entries) {
1125
+ return void 0;
1126
+ }
1127
+ const pairs = Object.entries(entries);
1128
+ if (pairs.length === 0) {
1129
+ return void 0;
1130
+ }
1131
+ return pairs.map(([key, value]) => {
1132
+ assertSafeStorybookToken(group, key, value);
1133
+ return `${key}:${encodeStorybookValue(value)}`;
1134
+ }).join(";");
1135
+ }
1136
+ function buildStorybookUrl(storyId, options, runtime) {
1137
+ const trimmedStoryId = storyId.trim();
1138
+ if (!trimmedStoryId) {
1139
+ throw new DriverError({ message: "openStory() requires a non-empty Storybook story ID." });
1140
+ }
1141
+ const baseUrl = options?.baseUrl ?? runtime.storybook?.url ?? runtime.appBaseUrl;
1142
+ if (!baseUrl) {
1143
+ throw new DriverError({
1144
+ message: "openStory() requires apps.web.url, execution.web.storybook.url, or options.baseUrl."
1145
+ });
1146
+ }
1147
+ let url;
1148
+ try {
1149
+ url = new URL(runtime.storybook?.iframePath ?? "/iframe.html", baseUrl);
1150
+ } catch (error) {
1151
+ throw new DriverError({
1152
+ message: `openStory() could not build a Storybook URL from "${baseUrl}": ${error instanceof Error ? error.message : String(error)}`
1153
+ });
1154
+ }
1155
+ url.searchParams.set("id", trimmedStoryId);
1156
+ url.searchParams.set("viewMode", options?.viewMode ?? "story");
1157
+ const args = encodeStorybookEntries("args", options?.args);
1158
+ if (args) {
1159
+ url.searchParams.set("args", args);
1160
+ }
1161
+ const globals = encodeStorybookEntries("globals", options?.globals);
1162
+ if (globals) {
1163
+ url.searchParams.set("globals", globals);
1164
+ }
1165
+ return url.toString();
1166
+ }
1167
+
1168
+ // src/drivers/playwright-parser.ts
1169
+ function rawNodeToElement(node) {
1170
+ const children = node.children && node.children.length > 0 ? node.children.map(rawNodeToElement) : void 0;
1171
+ return {
1172
+ ...node.id !== void 0 ? { id: node.id } : {},
1173
+ ...node.text !== void 0 ? { text: node.text } : {},
1174
+ ...node.value !== void 0 ? { value: node.value } : {},
1175
+ ...node.accessibilityLabel !== void 0 ? { accessibilityLabel: node.accessibilityLabel } : {},
1176
+ // Use role as elementType when present, otherwise fall back to HTML tag name
1177
+ ...node.role !== void 0 ? { elementType: node.role } : node.tag !== void 0 ? { elementType: node.tag } : {},
1178
+ bounds: {
1179
+ x: node.bounds.x,
1180
+ y: node.bounds.y,
1181
+ width: node.bounds.width,
1182
+ height: node.bounds.height
920
1183
  },
921
- assertAttribute: (selector, name, expectedValue, opts) => pollUntilMatch(
922
- selector,
923
- opts,
924
- (el) => {
925
- const actual = el.attributes?.[name];
926
- if (expectedValue === void 0) {
927
- return { matched: actual !== void 0, actual };
928
- }
929
- return { matched: actual === expectedValue, actual };
930
- },
931
- (actual, timeout) => expectedValue === void 0 ? {
932
- message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
933
- expected: name
934
- } : {
935
- message: `Expected attribute "${name}" to be "${expectedValue}" but got "${actual ?? "(not found)"}" after ${timeout}ms`,
936
- expected: expectedValue
937
- }
938
- ),
939
- assertMatchesText: (selector, pattern, opts) => pollUntilMatch(
940
- selector,
941
- opts,
942
- (el) => {
943
- const actual = el.text ?? "";
944
- return { matched: pattern.test(actual), actual };
945
- },
946
- (actual, timeout) => ({
947
- message: `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
948
- expected: String(pattern)
949
- })
950
- ),
951
- getAttribute: (selector, name, opts) => Effect3.gen(function* () {
952
- const element = yield* waitForElement(
953
- driver,
954
- selector,
955
- parse,
956
- { ...defaults, ...opts },
957
- cache
958
- );
959
- return element.attributes?.[name];
960
- })
1184
+ ...node.enabled !== void 0 ? { enabled: node.enabled } : {},
1185
+ ...node.visible !== void 0 ? { visible: node.visible } : {},
1186
+ ...node.clickable !== void 0 ? { clickable: node.clickable } : {},
1187
+ ...node.attributes !== void 0 ? { attributes: node.attributes } : {},
1188
+ ...children !== void 0 ? { children } : {}
961
1189
  };
962
1190
  }
1191
+ function parseWebHierarchy(json) {
1192
+ const raw = JSON.parse(json);
1193
+ return rawNodeToElement(raw);
1194
+ }
963
1195
 
964
1196
  // src/drivers/raw-driver.ts
965
1197
  import { Context, Effect as Effect4 } from "effect";
966
1198
  var RawDriver = class extends Context.Tag("RawDriver")() {
967
1199
  };
968
- function appendDriverLog(logs, message) {
969
- logs.push(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}`);
1200
+
1201
+ // src/drivers/launch-options.ts
1202
+ function mergeRecord(base, override) {
1203
+ if (!base && !override) return void 0;
1204
+ return { ...base, ...override };
970
1205
  }
971
- function wrapLoggedMethod(logs, methodName, fn) {
972
- return (...args) => {
973
- const startedAt = Date.now();
974
- appendDriverLog(logs, `${methodName} started`);
975
- return fn(...args).pipe(
976
- Effect4.tap(
977
- () => Effect4.sync(() => {
978
- appendDriverLog(logs, `${methodName} succeeded (${Date.now() - startedAt}ms)`);
979
- })
980
- ),
981
- Effect4.tapError(
982
- (error) => Effect4.sync(() => {
983
- appendDriverLog(
984
- logs,
985
- `${methodName} failed (${Date.now() - startedAt}ms): ${error.message}`
986
- );
987
- })
988
- )
989
- );
990
- };
1206
+ function stringifyLaunchValue(value) {
1207
+ if (typeof value === "string") return value;
1208
+ if (typeof value === "number" || typeof value === "boolean" || value == null) {
1209
+ return String(value);
1210
+ }
1211
+ return JSON.stringify(value);
1212
+ }
1213
+ function splitLocale(locale) {
1214
+ if (!locale) return {};
1215
+ const [language, ...rest] = locale.split(/[-_]/).filter(Boolean);
1216
+ if (!language || rest.length === 0) {
1217
+ return {};
1218
+ }
1219
+ return { language, remainder: rest.join("_") };
991
1220
  }
992
- function wrapOptionalMethod(logs, methodName, fn) {
993
- return fn ? wrapLoggedMethod(logs, methodName, fn) : void 0;
1221
+ function resolveAndroidDeviceState(deviceState) {
1222
+ if (!deviceState) return {};
1223
+ const split = splitLocale(deviceState.locale);
1224
+ return {
1225
+ language: deviceState.language ?? split.language,
1226
+ locale: split.remainder ?? deviceState.locale,
1227
+ timeZone: deviceState.timeZone
1228
+ };
994
1229
  }
995
- function wrapEvaluateMethod(logs, fn) {
996
- return (script, ...args) => wrapLoggedMethod(logs, "evaluate", fn)(script, ...args);
1230
+ function resolveIOSDeviceState(deviceState) {
1231
+ if (!deviceState) return {};
1232
+ const split = splitLocale(deviceState.locale);
1233
+ const language = deviceState.language ?? split.language;
1234
+ const locale = deviceState.locale && split.remainder && language ? `${language}_${split.remainder}` : deviceState.locale && !split.remainder && language ? `${language}_${deviceState.locale}` : deviceState.locale?.replaceAll("-", "_");
1235
+ return {
1236
+ language,
1237
+ locale,
1238
+ timeZone: deviceState.timeZone
1239
+ };
997
1240
  }
998
- function withBufferedDriverLogs(driver) {
999
- const logs = [];
1241
+ function mergeLaunchOptions(base, override) {
1242
+ if (!base && !override) return void 0;
1000
1243
  return {
1001
- ...driver,
1002
- beginFlow: (flowName) => {
1003
- logs.length = 0;
1004
- appendDriverLog(logs, `beginFlow ${flowName}`);
1005
- const startedAt = Date.now();
1006
- const effect = driver.beginFlow ? driver.beginFlow(flowName) : Effect4.void;
1007
- return effect.pipe(
1008
- Effect4.tap(
1009
- () => Effect4.sync(() => {
1010
- appendDriverLog(logs, `beginFlow ready (${Date.now() - startedAt}ms)`);
1011
- })
1012
- ),
1013
- Effect4.tapError(
1014
- (error) => Effect4.sync(() => {
1015
- appendDriverLog(
1016
- logs,
1017
- `beginFlow failed (${Date.now() - startedAt}ms): ${error.message}`
1018
- );
1019
- })
1020
- )
1244
+ ...base,
1245
+ ...override,
1246
+ launchArguments: mergeRecord(base?.launchArguments, override?.launchArguments),
1247
+ deviceState: mergeRecord(base?.deviceState, override?.deviceState)
1248
+ };
1249
+ }
1250
+ function hasLaunchDeviceState(deviceState) {
1251
+ return Boolean(deviceState?.language || deviceState?.locale || deviceState?.timeZone);
1252
+ }
1253
+ function deviceStateToAppiumCapabilities(platform, deviceState) {
1254
+ const normalizedState = platform === "android" ? resolveAndroidDeviceState(deviceState) : resolveIOSDeviceState(deviceState);
1255
+ if (!normalizedState.language && !normalizedState.locale && !normalizedState.timeZone) return {};
1256
+ if (platform === "android") {
1257
+ const hasLanguage = Boolean(normalizedState.language);
1258
+ const hasLocale = Boolean(normalizedState.locale);
1259
+ if (hasLanguage !== hasLocale) {
1260
+ throw new Error(
1261
+ "Appium Android deviceState requires both language and locale when either is provided."
1021
1262
  );
1022
- },
1023
- getDriverLogs: () => Effect4.succeed([...logs]),
1024
- dumpHierarchy: wrapLoggedMethod(logs, "dumpHierarchy", driver.dumpHierarchy),
1025
- tapAtCoordinate: wrapLoggedMethod(logs, "tapAtCoordinate", driver.tapAtCoordinate),
1026
- doubleTapAtCoordinate: wrapLoggedMethod(
1027
- logs,
1028
- "doubleTapAtCoordinate",
1029
- driver.doubleTapAtCoordinate
1030
- ),
1031
- longPressAtCoordinate: wrapLoggedMethod(
1032
- logs,
1033
- "longPressAtCoordinate",
1034
- driver.longPressAtCoordinate
1035
- ),
1036
- swipe: wrapLoggedMethod(logs, "swipe", driver.swipe),
1037
- pinch: wrapOptionalMethod(logs, "pinch", driver.pinch),
1038
- zoom: wrapOptionalMethod(logs, "zoom", driver.zoom),
1039
- multiTouch: wrapOptionalMethod(logs, "multiTouch", driver.multiTouch),
1040
- inputText: wrapLoggedMethod(logs, "inputText", driver.inputText),
1041
- pressKey: wrapLoggedMethod(logs, "pressKey", driver.pressKey),
1042
- hideKeyboard: wrapLoggedMethod(logs, "hideKeyboard", driver.hideKeyboard),
1043
- takeScreenshot: wrapLoggedMethod(logs, "takeScreenshot", driver.takeScreenshot),
1044
- getDeviceInfo: wrapLoggedMethod(logs, "getDeviceInfo", driver.getDeviceInfo),
1045
- launchApp: wrapLoggedMethod(logs, "launchApp", driver.launchApp),
1046
- stopApp: wrapLoggedMethod(logs, "stopApp", driver.stopApp),
1047
- killApp: wrapLoggedMethod(logs, "killApp", driver.killApp),
1048
- clearAppState: wrapLoggedMethod(logs, "clearAppState", driver.clearAppState),
1049
- openLink: wrapLoggedMethod(logs, "openLink", driver.openLink),
1050
- back: wrapLoggedMethod(logs, "back", driver.back),
1051
- evaluate: wrapEvaluateMethod(logs, driver.evaluate),
1052
- getContexts: wrapOptionalMethod(logs, "getContexts", driver.getContexts),
1053
- getCurrentContext: wrapOptionalMethod(logs, "getCurrentContext", driver.getCurrentContext),
1054
- setContext: wrapOptionalMethod(logs, "setContext", driver.setContext),
1055
- mockNetwork: wrapOptionalMethod(logs, "mockNetwork", driver.mockNetwork),
1056
- blockNetwork: wrapOptionalMethod(logs, "blockNetwork", driver.blockNetwork),
1057
- clearNetworkMocks: wrapOptionalMethod(logs, "clearNetworkMocks", driver.clearNetworkMocks),
1058
- setNetworkConditions: wrapOptionalMethod(
1059
- logs,
1060
- "setNetworkConditions",
1061
- driver.setNetworkConditions
1062
- ),
1063
- saveCookies: wrapOptionalMethod(logs, "saveCookies", driver.saveCookies),
1064
- loadCookies: wrapOptionalMethod(logs, "loadCookies", driver.loadCookies),
1065
- saveAuthState: wrapOptionalMethod(logs, "saveAuthState", driver.saveAuthState),
1066
- loadAuthState: wrapOptionalMethod(logs, "loadAuthState", driver.loadAuthState),
1067
- downloadFile: wrapOptionalMethod(logs, "downloadFile", driver.downloadFile),
1068
- uploadFile: wrapOptionalMethod(logs, "uploadFile", driver.uploadFile),
1069
- newTab: wrapOptionalMethod(logs, "newTab", driver.newTab),
1070
- switchToTab: wrapOptionalMethod(logs, "switchToTab", driver.switchToTab),
1071
- closeTab: wrapOptionalMethod(logs, "closeTab", driver.closeTab),
1072
- getTabIds: wrapOptionalMethod(logs, "getTabIds", driver.getTabIds),
1073
- getConsoleLogs: wrapOptionalMethod(logs, "getConsoleLogs", driver.getConsoleLogs),
1074
- getJSErrors: wrapOptionalMethod(logs, "getJSErrors", driver.getJSErrors),
1075
- getHAR: wrapOptionalMethod(logs, "getHAR", driver.getHAR)
1263
+ }
1264
+ }
1265
+ const capabilities = {};
1266
+ if (normalizedState.language) {
1267
+ capabilities["appium:language"] = normalizedState.language;
1268
+ }
1269
+ if (normalizedState.locale) {
1270
+ capabilities["appium:locale"] = normalizedState.locale;
1271
+ }
1272
+ if (normalizedState.timeZone) {
1273
+ capabilities[platform === "ios" ? "appium:appTimeZone" : "appium:timeZone"] = normalizedState.timeZone;
1274
+ }
1275
+ return capabilities;
1276
+ }
1277
+ function buildIOSLaunchConfiguration(options) {
1278
+ if (!options) return void 0;
1279
+ const argumentsList = [];
1280
+ const environment = {};
1281
+ const normalizedState = resolveIOSDeviceState(options.deviceState);
1282
+ if (normalizedState.language) {
1283
+ argumentsList.push("-AppleLanguages", `(${normalizedState.language})`);
1284
+ }
1285
+ if (normalizedState.locale) {
1286
+ argumentsList.push("-AppleLocale", normalizedState.locale);
1287
+ }
1288
+ if (options.launchArguments) {
1289
+ for (const [key, value] of Object.entries(options.launchArguments)) {
1290
+ argumentsList.push(`-${key}`, stringifyLaunchValue(value));
1291
+ }
1292
+ }
1293
+ if (normalizedState.timeZone) {
1294
+ environment.TZ = normalizedState.timeZone;
1295
+ }
1296
+ if (argumentsList.length === 0 && Object.keys(environment).length === 0) {
1297
+ return void 0;
1298
+ }
1299
+ return {
1300
+ arguments: argumentsList.length > 0 ? argumentsList : void 0,
1301
+ environment: Object.keys(environment).length > 0 ? environment : void 0
1076
1302
  };
1077
1303
  }
1078
1304
 
1079
1305
  export {
1080
1306
  DriverError,
1307
+ mergeLaunchOptions,
1308
+ hasLaunchDeviceState,
1309
+ deviceStateToAppiumCapabilities,
1310
+ buildIOSLaunchConfiguration,
1081
1311
  splitGraphemes,
1082
1312
  flattenElements,
1083
1313
  waitForElement,
1084
1314
  createCoordinator,
1085
- withBufferedDriverLogs
1315
+ buildStorybookUrl,
1316
+ parseWebHierarchy
1086
1317
  };
1087
- //# sourceMappingURL=chunk-S2XNAKSO.js.map
1318
+ //# sourceMappingURL=chunk-YAV6KBSW.js.map