@qontinui/ui-bridge-native 0.4.0 → 0.5.1

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.
@@ -1115,6 +1115,14 @@ function createServerHandlers(registry, executor, config) {
1115
1115
  "NOT_SUPPORTED"
1116
1116
  );
1117
1117
  },
1118
+ // Keep-awake (stub — apps should override via setKeepAwakeProvider, which
1119
+ // the provider wires when a keepAwakeProvider prop is supplied)
1120
+ keepAwake: async () => {
1121
+ return error2(
1122
+ "keep-awake not configured. Provide a keepAwakeProvider to UIBridgeNativeProvider.",
1123
+ "NOT_SUPPORTED"
1124
+ );
1125
+ },
1118
1126
  // Meta / Introspection (stub — server constructor overrides with real route table)
1119
1127
  getMethods: async () => {
1120
1128
  return error2("Methods introspection not configured", "NOT_SUPPORTED");
@@ -1788,6 +1796,12 @@ var WS_ROUTES = [
1788
1796
  httpMethods: ["POST"],
1789
1797
  requiresTestHooks: true
1790
1798
  },
1799
+ {
1800
+ pattern: "control/keep-awake",
1801
+ handler: "keepAwake",
1802
+ httpMethods: ["POST"],
1803
+ requiresTestHooks: true
1804
+ },
1791
1805
  // Observability — last-N console errors + network requests. testHooks-gated
1792
1806
  // because patching `console.error` / `fetch` is invasive in production.
1793
1807
  {
@@ -1840,7 +1854,8 @@ var HANDLER_DESCRIPTIONS = {
1840
1854
  getConsoleErrors: "TEST HOOK \u2014 last-N console.error/console.warn entries; ?since=<ms>&limit=<n>",
1841
1855
  getNetworkRequests: "TEST HOOK \u2014 last-N fetch/XHR entries with status + duration; ?since=<ms>&limit=<n>",
1842
1856
  pushModal: "TEST HOOK \u2014 push a modal onto the snapshot.modalStack via the registry ModalDetector",
1843
- dismissModal: "TEST HOOK \u2014 dismiss a modal by id from the snapshot.modalStack via the registry ModalDetector"
1857
+ dismissModal: "TEST HOOK \u2014 dismiss a modal by id from the snapshot.modalStack via the registry ModalDetector",
1858
+ keepAwake: "TEST HOOK \u2014 keep the device screen awake via the injected keepAwakeProvider: body { enabled: boolean, durationMs?: number }"
1844
1859
  };
1845
1860
  var ACTION_REFERENCE = [
1846
1861
  { name: "press", aliases: ["click"], params: "PressActionParams (optional position)" },
@@ -2108,6 +2123,35 @@ var NativeUIBridgeServer = class {
2108
2123
  }
2109
2124
  };
2110
2125
  }
2126
+ /**
2127
+ * Set a keep-awake provider for native screen-wake control.
2128
+ * This enables `control/keep-awake` and arms the auto-arm hook in
2129
+ * handleRequest (every request keeps the screen alive for 60s).
2130
+ */
2131
+ setKeepAwakeProvider(provider) {
2132
+ this.keepAwakeProvider = provider;
2133
+ this.handlers.keepAwake = async (ctx) => {
2134
+ const { enabled, durationMs } = ctx.body ?? {};
2135
+ if (typeof enabled !== "boolean") {
2136
+ return {
2137
+ success: false,
2138
+ error: "enabled must be boolean",
2139
+ code: "INVALID_REQUEST",
2140
+ timestamp: Date.now()
2141
+ };
2142
+ }
2143
+ if (enabled) {
2144
+ provider.request("ui-bridge", typeof durationMs === "number" ? durationMs : void 0);
2145
+ } else {
2146
+ provider.release("ui-bridge");
2147
+ }
2148
+ return {
2149
+ success: true,
2150
+ data: { enabled, durationMs: typeof durationMs === "number" ? durationMs : null },
2151
+ timestamp: Date.now()
2152
+ };
2153
+ };
2154
+ }
2111
2155
  /**
2112
2156
  * Start the HTTP server
2113
2157
  */
@@ -2700,6 +2744,12 @@ var NativeUIBridgeServer = class {
2700
2744
  if (request.method === "OPTIONS") {
2701
2745
  return { status: 204, headers, body: "" };
2702
2746
  }
2747
+ if (this.config.testHooks === true && this.keepAwakeProvider) {
2748
+ try {
2749
+ this.keepAwakeProvider.request("auto-arm", 6e4);
2750
+ } catch {
2751
+ }
2752
+ }
2703
2753
  try {
2704
2754
  const response = await this.routeRequest(request);
2705
2755
  return {