obsidian-integration-testing 11.0.0 → 12.0.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 (99) hide show
  1. package/dist/lib/cjs/appium-server-marker.cjs +115 -0
  2. package/dist/lib/cjs/appium-server-marker.d.cts +81 -0
  3. package/dist/lib/cjs/cli.cjs +104 -19
  4. package/dist/lib/cjs/cli.d.cts +16 -8
  5. package/dist/lib/cjs/community-plugin-registry.cjs +52 -0
  6. package/dist/lib/cjs/community-plugin-registry.d.cts +116 -0
  7. package/dist/lib/cjs/context-provider.cjs +12 -1
  8. package/dist/lib/cjs/context-provider.d.cts +26 -3
  9. package/dist/lib/cjs/demo-vault-bootstrap.cjs +148 -0
  10. package/dist/lib/cjs/demo-vault-bootstrap.d.cts +113 -0
  11. package/dist/lib/cjs/demo-vault-populate.cjs +36 -9
  12. package/dist/lib/cjs/demo-vault-populate.d.cts +70 -0
  13. package/dist/lib/cjs/eval-in-obsidian.cjs +1 -1
  14. package/dist/lib/cjs/eval-in-obsidian.d.cts +42 -13
  15. package/dist/lib/cjs/index.cjs +13 -1
  16. package/dist/lib/cjs/index.d.cts +8 -4
  17. package/dist/lib/cjs/installer-asset.cjs +1 -1
  18. package/dist/lib/cjs/installer-asset.d.cts +1 -1
  19. package/dist/lib/cjs/integration-setup-failed-error.cjs +62 -0
  20. package/dist/lib/cjs/integration-setup-failed-error.d.cts +66 -0
  21. package/dist/lib/cjs/jest/global-setup.cjs +2 -2
  22. package/dist/lib/cjs/jest/global-setup.d.cts +5 -1
  23. package/dist/lib/cjs/kill-process-tree.cjs +18 -7
  24. package/dist/lib/cjs/kill-process-tree.d.cts +10 -2
  25. package/dist/lib/cjs/library.cjs +1 -1
  26. package/dist/lib/cjs/mobile-input.cjs +161 -0
  27. package/dist/lib/cjs/mobile-input.d.cts +160 -0
  28. package/dist/lib/cjs/namespace-bootstrap.cjs +92 -9
  29. package/dist/lib/cjs/obsidian-installer.cjs +1 -1
  30. package/dist/lib/cjs/obsidian-metadata.cjs +123 -17
  31. package/dist/lib/cjs/obsidian-metadata.d.cts +17 -6
  32. package/dist/lib/cjs/obsidian-version-switch.cjs +3 -3
  33. package/dist/lib/cjs/release-catalog.cjs +73 -0
  34. package/dist/lib/cjs/release-catalog.d.cts +125 -0
  35. package/dist/lib/cjs/transport-appium.cjs +122 -1
  36. package/dist/lib/cjs/transport-appium.d.cts +51 -0
  37. package/dist/lib/cjs/transport-desktop-cdp.cjs +7 -1
  38. package/dist/lib/cjs/transport-desktop-cdp.d.cts +1 -0
  39. package/dist/lib/cjs/transport-factory.cjs +237 -32
  40. package/dist/lib/cjs/transport-factory.d.cts +10 -1
  41. package/dist/lib/cjs/vitest/global-setup.cjs +13 -7
  42. package/dist/lib/cjs/vitest/global-setup.d.cts +5 -1
  43. package/dist/lib/cjs/vitest/setup.cjs +2 -1
  44. package/dist/lib/cjs/vitest/setup.d.cts +5 -0
  45. package/dist/lib/cjs/vitest/typings.d.cts +6 -4
  46. package/dist/lib/cjs/webview-cdp.cjs +264 -0
  47. package/dist/lib/cjs/webview-cdp.d.cts +152 -0
  48. package/dist/lib/cjs/wedged-appium-server.cjs +113 -0
  49. package/dist/lib/cjs/wedged-appium-server.d.cts +187 -0
  50. package/dist/lib/esm/appium-server-marker.d.mts +81 -0
  51. package/dist/lib/esm/appium-server-marker.mjs +83 -0
  52. package/dist/lib/esm/cli.d.mts +16 -8
  53. package/dist/lib/esm/cli.mjs +110 -19
  54. package/dist/lib/esm/community-plugin-registry.d.mts +116 -0
  55. package/dist/lib/esm/community-plugin-registry.mjs +23 -0
  56. package/dist/lib/esm/context-provider.d.mts +26 -3
  57. package/dist/lib/esm/context-provider.mjs +10 -1
  58. package/dist/lib/esm/demo-vault-bootstrap.d.mts +113 -0
  59. package/dist/lib/esm/demo-vault-bootstrap.mjs +127 -0
  60. package/dist/lib/esm/demo-vault-populate.d.mts +70 -0
  61. package/dist/lib/esm/demo-vault-populate.mjs +33 -8
  62. package/dist/lib/esm/eval-in-obsidian.d.mts +42 -13
  63. package/dist/lib/esm/eval-in-obsidian.mjs +1 -1
  64. package/dist/lib/esm/index.d.mts +8 -4
  65. package/dist/lib/esm/index.mjs +16 -2
  66. package/dist/lib/esm/installer-asset.d.mts +1 -1
  67. package/dist/lib/esm/installer-asset.mjs +1 -1
  68. package/dist/lib/esm/integration-setup-failed-error.d.mts +66 -0
  69. package/dist/lib/esm/integration-setup-failed-error.mjs +38 -0
  70. package/dist/lib/esm/jest/global-setup.d.mts +5 -1
  71. package/dist/lib/esm/jest/global-setup.mjs +2 -2
  72. package/dist/lib/esm/kill-process-tree.d.mts +10 -2
  73. package/dist/lib/esm/kill-process-tree.mjs +16 -6
  74. package/dist/lib/esm/library.mjs +1 -1
  75. package/dist/lib/esm/mobile-input.d.mts +160 -0
  76. package/dist/lib/esm/mobile-input.mjs +132 -0
  77. package/dist/lib/esm/namespace-bootstrap.mjs +95 -9
  78. package/dist/lib/esm/obsidian-installer.mjs +1 -1
  79. package/dist/lib/esm/obsidian-metadata.d.mts +17 -6
  80. package/dist/lib/esm/obsidian-metadata.mjs +123 -17
  81. package/dist/lib/esm/obsidian-version-switch.mjs +3 -3
  82. package/dist/lib/esm/release-catalog.d.mts +125 -0
  83. package/dist/lib/esm/release-catalog.mjs +46 -0
  84. package/dist/lib/esm/transport-appium.d.mts +51 -0
  85. package/dist/lib/esm/transport-appium.mjs +126 -1
  86. package/dist/lib/esm/transport-desktop-cdp.d.mts +1 -0
  87. package/dist/lib/esm/transport-desktop-cdp.mjs +7 -1
  88. package/dist/lib/esm/transport-factory.d.mts +10 -1
  89. package/dist/lib/esm/transport-factory.mjs +249 -35
  90. package/dist/lib/esm/vitest/global-setup.d.mts +5 -1
  91. package/dist/lib/esm/vitest/global-setup.mjs +14 -7
  92. package/dist/lib/esm/vitest/setup.d.mts +5 -0
  93. package/dist/lib/esm/vitest/setup.mjs +3 -1
  94. package/dist/lib/esm/vitest/typings.d.mts +6 -4
  95. package/dist/lib/esm/webview-cdp.d.mts +152 -0
  96. package/dist/lib/esm/webview-cdp.mjs +236 -0
  97. package/dist/lib/esm/wedged-appium-server.d.mts +187 -0
  98. package/dist/lib/esm/wedged-appium-server.mjs +86 -0
  99. package/package.json +2 -1
@@ -0,0 +1,160 @@
1
+ /**
2
+ * @file
3
+ *
4
+ * Translates a mobile trusted-input request into the ordered Chrome DevTools Protocol `Input.*` commands
5
+ * that realize it (see **L39**).
6
+ *
7
+ * Pure and synchronous by design: the WebView connection ({@link WebViewCdpConnection}) sends whatever this
8
+ * returns, so every decision that is worth a test — the touch pair a tap expands into, the dwell a
9
+ * long-press adds, the `rawKeyDown` → `char` → `keyUp` shape a key press mirrors from the desktop twin, the
10
+ * modifier bitmask — lives here rather than inside the transport's I/O path.
11
+ *
12
+ * The request travels renderer → host as JSON (the renderer computes the coordinates, because only it can
13
+ * see the DOM), so both the request and the command shapes are deliberately plain data.
14
+ */
15
+ /**
16
+ * The name of the `Runtime.addBinding` function the host exposes on the page so the renderer can hand it an
17
+ * input request mid-closure.
18
+ *
19
+ * It is passed *into* the serialized bootstrap closure as data rather than referenced from it, because that
20
+ * closure may not read outer scope (**L15**) — so this stays the single definition.
21
+ */
22
+ export declare const MOBILE_INPUT_BINDING_NAME = "__obsidianIntegrationTestingInput";
23
+ /**
24
+ * How long the renderer waits for the host to service one input request before giving up.
25
+ *
26
+ * Generous relative to the work (a tap is two CDP commands; a long-press adds a 600ms dwell): the point is
27
+ * to fail with a legible error rather than hang the closure until the whole run times out. Passed into the
28
+ * bootstrap closure as data, for the same reason as {@link MOBILE_INPUT_BINDING_NAME}.
29
+ */
30
+ export declare const MOBILE_INPUT_TIMEOUT_IN_MILLISECONDS = 15000;
31
+ /**
32
+ * A single Chrome DevTools Protocol command, plus how long to wait before sending it.
33
+ *
34
+ * The delay is carried here rather than applied by the producer so that the whole sequence stays pure
35
+ * data — a test asserts the dwell without waiting for it.
36
+ */
37
+ export interface CdpInputCommand {
38
+ /**
39
+ * Milliseconds to wait before sending this command. Absent means "send immediately".
40
+ *
41
+ * Used only by the long-press dwell.
42
+ */
43
+ readonly delayBeforeInMilliseconds?: number;
44
+ /**
45
+ * The CDP method name, e.g. `Input.dispatchTouchEvent`.
46
+ */
47
+ readonly method: string;
48
+ /**
49
+ * The CDP method parameters.
50
+ */
51
+ readonly params: Record<string, unknown>;
52
+ }
53
+ /**
54
+ * What the renderer hands to the host binding: one request, plus the id to answer it on.
55
+ *
56
+ * The renderer builds this literal inside the serialized bootstrap closure, which cannot import (**L15**),
57
+ * so the shape is declared here and mirrored there. They are one wire format; change them together.
58
+ */
59
+ export interface MobileInputEnvelope {
60
+ /**
61
+ * The request id the renderer is waiting on.
62
+ */
63
+ readonly id: string;
64
+ /**
65
+ * What to inject.
66
+ */
67
+ readonly request: MobileInputRequest;
68
+ }
69
+ /**
70
+ * Anything the renderer can ask the host to inject.
71
+ */
72
+ export type MobileInputRequest = MobileKeyInputRequest | MobilePointerInputRequest;
73
+ /**
74
+ * A trusted key press to inject on mobile.
75
+ */
76
+ export interface MobileKeyInputRequest {
77
+ /**
78
+ * The key to press, in the same spelling the desktop twin takes: either a named key
79
+ * (`Enter`, `Escape`, `Tab`, `Backspace`, `Delete`, an arrow) or a single printable character.
80
+ */
81
+ readonly key: string;
82
+ /**
83
+ * Discriminant.
84
+ */
85
+ readonly kind: 'key';
86
+ /**
87
+ * Modifiers already resolved to their platform-independent lowercase names by the renderer's
88
+ * `toElectronModifiers` — the one mapping a key press and a click share, so `'Mod'` cannot mean two
89
+ * different things (**L17**).
90
+ */
91
+ readonly modifiers: readonly string[];
92
+ }
93
+ /**
94
+ * A trusted pointer gesture to inject on mobile, in CSS pixels within the WebView's own viewport.
95
+ *
96
+ * No device-pixel conversion is involved: CDP takes page coordinates, so `devicePixelRatio` and the
97
+ * WebView's offset under the status bar never enter the picture (they would for native injection).
98
+ */
99
+ export interface MobilePointerInputRequest {
100
+ /**
101
+ * `tap` is the touch analog of a left click; `longPress` is the mobile context-menu gesture, i.e. what a
102
+ * desktop right click means here.
103
+ */
104
+ readonly kind: 'longPress' | 'tap';
105
+ /**
106
+ * See {@link MobileKeyInputRequest.modifiers}.
107
+ */
108
+ readonly modifiers: readonly string[];
109
+ /**
110
+ * The viewport x coordinate, in CSS pixels.
111
+ */
112
+ readonly x: number;
113
+ /**
114
+ * The viewport y coordinate, in CSS pixels.
115
+ */
116
+ readonly y: number;
117
+ }
118
+ /**
119
+ * Builds the expression the host evaluates to answer one input request.
120
+ *
121
+ * Optional chaining throughout: by the time the host answers, the page may have navigated and dropped the
122
+ * namespace, and a `TypeError` inside this evaluate would be reported as an injection failure that already
123
+ * succeeded.
124
+ *
125
+ * @param id - The request id the renderer is waiting on.
126
+ * @param errorMessage - Why the injection failed, when it did. Omit on success.
127
+ * @returns A self-contained expression to pass to `Runtime.evaluate`.
128
+ */
129
+ export declare function buildResolveInputExpression(id: string, errorMessage?: string): string;
130
+ /**
131
+ * The first code point of a non-empty string.
132
+ *
133
+ * `String.prototype.codePointAt` is typed `number | undefined`, so every call site would otherwise carry a
134
+ * `?? fallback` that no input can ever reach — a dead branch under the 100% coverage gate. Throwing here
135
+ * keeps that impossible case in ONE place, where a unit test can reach it directly, instead of spreading
136
+ * unreachable fallbacks (or coverage suppressions) across the module.
137
+ *
138
+ * @param text - A non-empty string.
139
+ * @returns Its first code point.
140
+ * @throws When `text` is empty.
141
+ */
142
+ export declare function codePointOf(text: string): number;
143
+ /**
144
+ * Translates a mobile input request into the ordered CDP commands that realize it.
145
+ *
146
+ * @param request - What the renderer asked the host to inject.
147
+ * @returns The commands to send, in order.
148
+ */
149
+ export declare function toCdpInputCommands(request: MobileInputRequest): CdpInputCommand[];
150
+ /**
151
+ * Folds resolved modifier names into CDP's bitmask.
152
+ *
153
+ * Unknown names are ignored rather than throwing: the renderer's `toElectronModifiers` is exhaustive over
154
+ * Obsidian's `Modifier` union, so an unknown name here would mean the two copies have already drifted, and
155
+ * failing the whole gesture is a worse outcome than pressing it unmodified.
156
+ *
157
+ * @param modifiers - Resolved lowercase modifier names.
158
+ * @returns The CDP modifier bitmask.
159
+ */
160
+ export declare function toCdpModifiers(modifiers: readonly string[]): number;