@expo/serve-sim 0.3.3 → 0.3.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/serve-sim",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Evan Bacon",
package/src/middleware.ts CHANGED
@@ -941,13 +941,21 @@ function rawHidSocket(socket: Socket, head: Buffer): HidSocket {
941
941
  closed = true;
942
942
  for (const cb of closeCbs) cb();
943
943
  };
944
- const shutdown = () => {
944
+ const shutdown = (code?: number, reason = "") => {
945
945
  fireClose();
946
- try { socket.end(websocketFrame(0x8, Buffer.alloc(0))); } catch {}
947
- try { socket.destroy(); } catch {}
946
+ const payload = code === undefined ? Buffer.alloc(0) : Buffer.alloc(2 + Buffer.byteLength(reason));
947
+ if (code !== undefined) {
948
+ payload.writeUInt16BE(code);
949
+ payload.write(reason, 2);
950
+ }
951
+ try {
952
+ socket.end(websocketFrame(0x8, payload));
953
+ socket.destroySoon();
954
+ } catch { socket.destroy(); }
948
955
  };
949
956
 
950
957
  const drain = () => {
958
+ if (closed) return;
951
959
  for (;;) {
952
960
  let frame: ParsedWebSocketFrame | null;
953
961
  try {
@@ -1540,8 +1548,6 @@ export interface SimMiddlewareOptions {
1540
1548
  * decides access. Loopback is always allowed.
1541
1549
  */
1542
1550
  corsOrigins?: string[];
1543
- /** @deprecated Use `corsOrigins`. */
1544
- metricsCorsOrigins?: string[];
1545
1551
  frameAncestors?: string[];
1546
1552
  /** Public page the Share button copies instead of this preview's address. */
1547
1553
  shareUrl?: string;
@@ -1717,7 +1723,7 @@ export function simMiddleware(options?: SimMiddlewareOptions): SimMiddleware {
1717
1723
  // can't read this value (it's only injected into the preview page's config).
1718
1724
  const execToken = options?.execToken ?? randomBytes(32).toString("base64url");
1719
1725
  const requirePreviewToken = options?.requirePreviewToken ?? false;
1720
- const corsOrigins = [...(options?.corsOrigins ?? []), ...(options?.metricsCorsOrigins ?? [])];
1726
+ const corsOrigins = [...(options?.corsOrigins ?? [])];
1721
1727
  const frameAncestors = options?.frameAncestors ?? [];
1722
1728
  const shareUrl = options?.shareUrl;
1723
1729
  // The proxied DevTools frontend sits behind the same cookie, so its document needs the policy too.
package/src/native.ts CHANGED
@@ -75,6 +75,7 @@ interface NativeAddon {
75
75
  ) => SimCaptureHandle;
76
76
  axDescribe(udid: string): Promise<string>;
77
77
  axFrontmost(udid: string): Promise<string>;
78
+ axTypeKeyboardCharacter(udid: string, character: string): Promise<boolean>;
78
79
  setHardwareKeyboard(udid: string, enabled: boolean): Promise<boolean>;
79
80
  }
80
81
 
@@ -377,6 +378,10 @@ export function axFrontmostAsync(udid: string): Promise<string> {
377
378
  return load().axFrontmost(udid);
378
379
  }
379
380
 
381
+ export function axTypeKeyboardCharacterAsync(udid: string, character: string): Promise<boolean> {
382
+ return load().axTypeKeyboardCharacter(udid, character);
383
+ }
384
+
380
385
  /**
381
386
  * Connect/disconnect the device's hardware keyboard (⌘⇧K). Disconnecting makes
382
387
  * the guest show its on-screen keyboard. Per-device; resolves true when the