@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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.5.0";
2
+ var version = "0.6.0";
3
3
 
4
4
  // ../protocol-types/dist/index.js
5
5
  function normalizeSubroute(subroute) {
@@ -30,20 +30,46 @@ function isBridgeMessage(data) {
30
30
  if (CORRELATED_KINDS_SET.has(d.kind) && typeof d.requestId !== "string") return false;
31
31
  return true;
32
32
  }
33
+ var BRIDGE_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@nominalso/vibe-bridge:BridgeError");
34
+ var HTTP_BRIDGE_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@nominalso/vibe-bridge:HttpBridgeError");
33
35
  var BridgeError = class extends Error {
34
36
  constructor(code, message) {
35
37
  super(message);
36
38
  this.code = code;
37
39
  this.name = "BridgeError";
38
40
  }
41
+ /**
42
+ * Cross-realm-safe type guard. Prefer this over `instanceof BridgeError` when
43
+ * an error may have been thrown by a differently-built copy of the SDK (e.g.
44
+ * server bundle vs client bundle) — it matches on a process-global brand
45
+ * rather than class identity.
46
+ */
47
+ static isBridgeError(err) {
48
+ return typeof err === "object" && err !== null && err[BRIDGE_ERROR_BRAND] === true;
49
+ }
39
50
  };
51
+ Object.defineProperty(BridgeError.prototype, BRIDGE_ERROR_BRAND, {
52
+ value: true,
53
+ enumerable: false
54
+ });
40
55
  var HttpBridgeError = class extends BridgeError {
41
56
  constructor(status, message) {
42
57
  super("REQUEST_FAILED", message);
43
58
  this.status = status;
44
59
  this.name = "HttpBridgeError";
45
60
  }
61
+ /**
62
+ * Cross-realm-safe type guard (see {@link BridgeError.isBridgeError}). Returns
63
+ * `true` only for `HttpBridgeError` instances, not plain `BridgeError`s.
64
+ */
65
+ static isHttpBridgeError(err) {
66
+ return typeof err === "object" && err !== null && err[HTTP_BRIDGE_ERROR_BRAND] === true;
67
+ }
46
68
  };
69
+ Object.defineProperty(HttpBridgeError.prototype, HTTP_BRIDGE_ERROR_BRAND, {
70
+ value: true,
71
+ enumerable: false
72
+ });
47
73
  function isOriginPattern(entry) {
48
74
  return entry.includes("*");
49
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nominalso/vibe-host",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Host-side SDK for embedding Nominal Vibe Apps — receives bridge requests over a typed postMessage protocol and dispatches them to Nominal APIs (used by nom-ui).",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://github.com/nominalso/vibe-apps-sdk#readme",