@codingfrees/uap-device-control 0.2.10 → 0.2.11

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.
@@ -802,7 +802,7 @@ import WebSocket from "ws";
802
802
  // package.json
803
803
  var package_default = {
804
804
  name: "@codingfrees/uap-device-control",
805
- version: "0.2.10",
805
+ version: "0.2.11",
806
806
  description: "Cross-platform outbound UAP Device Control client",
807
807
  type: "module",
808
808
  bin: {
@@ -1957,9 +1957,10 @@ async function runRemote(options) {
1957
1957
  if (options.allowedServices.length && !services) throw new TypeError("native service control is unavailable");
1958
1958
  let refreshSession = () => {
1959
1959
  };
1960
+ const browserRefresh = createRefreshScheduler(() => refreshSession());
1960
1961
  const browserLog = (event) => {
1961
1962
  options.log?.(event);
1962
- if (event.event === "browser.bridge" && ["paired", "unpaired", "connected", "permissions-granted", "permissions-required"].includes(String(event.status))) refreshSession();
1963
+ if (event.event === "browser.bridge" && ["paired", "unpaired", "connected", "permissions-granted", "permissions-required"].includes(String(event.status))) browserRefresh.schedule();
1963
1964
  };
1964
1965
  const browserPort = options.browserPort ?? 18700;
1965
1966
  const browser = options.browserControl === false ? void 0 : await createBrowserBridge(options.stateDirectory, browserPort, browserLog).catch((error) => {
@@ -2019,9 +2020,24 @@ async function runRemote(options) {
2019
2020
  }
2020
2021
  }
2021
2022
  } finally {
2023
+ browserRefresh.close();
2022
2024
  engine.close();
2023
2025
  }
2024
2026
  }
2027
+ function createRefreshScheduler(refresh, delayMs = 100) {
2028
+ let timer;
2029
+ return {
2030
+ schedule() {
2031
+ if (timer) clearTimeout(timer);
2032
+ timer = setTimeout(refresh, delayMs);
2033
+ timer.unref();
2034
+ },
2035
+ close() {
2036
+ if (timer) clearTimeout(timer);
2037
+ timer = void 0;
2038
+ }
2039
+ };
2040
+ }
2025
2041
  function optionalBrowserBridgeFailure(error) {
2026
2042
  if (!error || typeof error !== "object" || !("code" in error)) return false;
2027
2043
  return ["EADDRINUSE", "EACCES", "EAFNOSUPPORT", "EPROTONOSUPPORT"].includes(String(error.code));
@@ -2714,6 +2730,8 @@ function formatCliEvent(event, json2 = false) {
2714
2730
  }
2715
2731
  if (status === "paired") return "\u2705 UAP Browser Extension paired";
2716
2732
  if (status === "connected") return "\u{1F310} UAP Browser Extension connected";
2733
+ if (status === "permissions-granted") return "\u2705 UAP Browser Extension access granted";
2734
+ if (status === "permissions-required") return "\u26A0\uFE0F UAP Browser Extension connected \xB7 browser access required";
2717
2735
  if (status === "unpaired") return "\u{1F50C} UAP Browser Extension unpaired";
2718
2736
  }
2719
2737
  if (event.event === "remote.session") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingfrees/uap-device-control",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Cross-platform outbound UAP Device Control client",
5
5
  "type": "module",
6
6
  "bin": {