@nominalso/vibe-host 0.5.0 → 0.6.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.
package/dist/index.cjs CHANGED
@@ -27,7 +27,7 @@ __export(index_exports, {
27
27
  module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // package.json
30
- var version = "0.5.0";
30
+ var version = "0.6.0";
31
31
 
32
32
  // ../protocol-types/dist/index.js
33
33
  function normalizeSubroute(subroute) {
@@ -58,20 +58,46 @@ function isBridgeMessage(data) {
58
58
  if (CORRELATED_KINDS_SET.has(d.kind) && typeof d.requestId !== "string") return false;
59
59
  return true;
60
60
  }
61
+ var BRIDGE_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@nominalso/vibe-bridge:BridgeError");
62
+ var HTTP_BRIDGE_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@nominalso/vibe-bridge:HttpBridgeError");
61
63
  var BridgeError = class extends Error {
62
64
  constructor(code, message) {
63
65
  super(message);
64
66
  this.code = code;
65
67
  this.name = "BridgeError";
66
68
  }
69
+ /**
70
+ * Cross-realm-safe type guard. Prefer this over `instanceof BridgeError` when
71
+ * an error may have been thrown by a differently-built copy of the SDK (e.g.
72
+ * server bundle vs client bundle) — it matches on a process-global brand
73
+ * rather than class identity.
74
+ */
75
+ static isBridgeError(err) {
76
+ return typeof err === "object" && err !== null && err[BRIDGE_ERROR_BRAND] === true;
77
+ }
67
78
  };
79
+ Object.defineProperty(BridgeError.prototype, BRIDGE_ERROR_BRAND, {
80
+ value: true,
81
+ enumerable: false
82
+ });
68
83
  var HttpBridgeError = class extends BridgeError {
69
84
  constructor(status, message) {
70
85
  super("REQUEST_FAILED", message);
71
86
  this.status = status;
72
87
  this.name = "HttpBridgeError";
73
88
  }
89
+ /**
90
+ * Cross-realm-safe type guard (see {@link BridgeError.isBridgeError}). Returns
91
+ * `true` only for `HttpBridgeError` instances, not plain `BridgeError`s.
92
+ */
93
+ static isHttpBridgeError(err) {
94
+ return typeof err === "object" && err !== null && err[HTTP_BRIDGE_ERROR_BRAND] === true;
95
+ }
74
96
  };
97
+ Object.defineProperty(HttpBridgeError.prototype, HTTP_BRIDGE_ERROR_BRAND, {
98
+ value: true,
99
+ enumerable: false
100
+ });
75
101
  function isOriginPattern(entry) {
76
102
  return entry.includes("*");
77
103
  }