@goliapkg/smix 1.0.4 → 1.0.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/Session.ts +20 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goliapkg/smix",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Playwright-shape iOS Simulator / Android emulator UI automation SDK for React Native + Expo + Detox-compatible TypeScript test runners.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0 OR MIT",
package/src/Session.ts CHANGED
@@ -123,6 +123,26 @@ export class Session {
123
123
  return () => this.listeners.delete(listener)
124
124
  }
125
125
 
126
+ /** v1.0.5 §D1 — probe `/session/list` and return `true` iff this
127
+ * session's id is still known to the runner. Consumers wire this
128
+ * after a state transition to `cycling`/`dead` to decide whether
129
+ * to keep the session or reopen. */
130
+ async stillValid(): Promise<boolean> {
131
+ const res = await this.runner.fetch(
132
+ `${this.runner.baseUrl}/session/list`,
133
+ {
134
+ method: 'POST',
135
+ headers: { 'Content-Type': 'application/json' },
136
+ body: '{}',
137
+ },
138
+ )
139
+ if (!res.ok) return false
140
+ const json = (await res.json()) as {
141
+ sessions?: Array<{ sessionId?: string }>
142
+ }
143
+ return (json.sessions ?? []).some((s) => s.sessionId === this.sessionId)
144
+ }
145
+
126
146
  /** v1.0.4 §D14 — instruct the runner to `terminate()` + `launch()`
127
147
  * the session's cached `XCUIApplication` in place. Preserves the
128
148
  * session id and XCUITest binding. Returns wall-clock ms. */