@nominalso/vibe-bridge 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.
@@ -8,7 +8,9 @@
8
8
  npm install @nominalso/vibe-bridge
9
9
  ```
10
10
 
11
- Bundles `posthog-js` (its only runtime dependency) for host-enabled in-iframe session recording. Ships ESM + CJS with self-contained TypeScript types.
11
+ Ships ESM + CJS with self-contained TypeScript types. `posthog-js` is an **optional dependency** used only for host-enabled in-iframe session recording (the SDK no-ops gracefully if it's absent).
12
+
13
+ **Safe to import anywhere.** The package draws a clean server/client boundary, so `import { VibeAppBridge } from '@nominalso/vibe-bridge'` is safe from an SSR entry, a React Server Component, or an edge/Worker runtime: importing has no side effects, `new VibeAppBridge()` is pure, and the browser is only needed when a method actually runs (calling one outside a browser throws `BridgeError` code `'SERVER_ENVIRONMENT'`). You do **not** need `createClientOnlyFn`, dynamic `import()`, or `typeof window` guards — just construct in a client component and `connect()` in an effect. See the README's "Safe to import anywhere" and "Common recipes" sections.
12
14
 
13
15
  ## Minimal app
14
16
 
package/llms.txt CHANGED
@@ -1,9 +1,11 @@
1
1
  # @nominalso/vibe-bridge
2
2
 
3
- > Iframe-side TypeScript SDK for building Nominal Vibe Apps — standalone browser apps (often built with Lovable) embedded in the Nominal platform via a cross-origin iframe. Connects the app to its Nominal host over a typed postMessage protocol: read Nominal data, submit Close-Management task outputs, upload files, keep deep-link routing in sync, and (when the host enables it) record the in-iframe session to PostHog. Browser-only; bundles posthog-js as its only runtime dependency.
3
+ > Iframe-side TypeScript SDK for building Nominal Vibe Apps — standalone browser apps (often built with Lovable) embedded in the Nominal platform via a cross-origin iframe. Connects the app to its Nominal host over a typed postMessage protocol: read Nominal data, submit Close-Management task outputs, upload files, keep deep-link routing in sync, and (when the host enables it) record the in-iframe session to PostHog. Methods run in the browser, but the package is safe to import from anywhere — SSR, React Server Components, and edge/Worker runtimes — with a clean server/client boundary; posthog-js is an optional dependency.
4
4
 
5
5
  The integration is always the same: `new VibeAppBridge()` (no config — `parentOrigin` is optional and the bridge auto-detects the embedding Nominal host; pass it only to pin explicitly or to allow preview origins), `await bridge.connect()` once (it returns the tenant/user `ContextPayload`), then call any of the ~46 typed data methods, `upload(file, options)`, or `postTaskOutput(...)`. Tear down with `bridge.destroy()`. The only write path into Nominal is `postTaskOutput`. Session recording auto-initializes on `connect()` only when the host sends a `posthog` block with `enabled: true`; emit custom events with `bridge.track(event, properties?)` (a no-op until then).
6
6
 
7
+ Server/client boundary: importing and `new VibeAppBridge()` are side-effect-free and safe during SSR / in a React Server Component / in a Worker; the browser is only required when a method actually runs (calling one without a `window` throws `BridgeError` code `SERVER_ENVIRONMENT`). RSC / Worker / edge runtimes resolve to a server-safe stub via `react-server`/`worker`/`workerd`/`edge-light`/`deno` export conditions, while plain Node and jsdom/happy-dom test runners (Vitest/Jest) get the real, self-guarding build; the client build is marked `'use client'`. No `createClientOnlyFn`, dynamic `import()`, or `typeof window` guards are needed. The error classes are import-safe from any environment; detect them with `BridgeError.isBridgeError(err)` / `HttpBridgeError.isHttpBridgeError(err)`.
8
+
7
9
  ## Docs
8
10
 
9
11
  - [README](./README.md): install, quickstart, full API, common mistakes, and the operation catalog.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nominalso/vibe-bridge",
3
- "version": "0.5.0",
4
- "description": "Iframe-side SDK for building Nominal Vibe Apps — connects an embedded app to its Nominal host over a typed postMessage bridge (context, data fetch, file upload, subroute deep-linking).",
3
+ "version": "0.6.0",
4
+ "description": "Iframe-side SDK for building Nominal Vibe Apps — connects an embedded app to its Nominal host over a typed postMessage bridge (context, data fetch, file upload, subroute deep-linking). Safe to import from SSR, React Server Components, and edge/Worker runtimes.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://github.com/nominalso/vibe-apps-sdk#readme",
7
7
  "bugs": {
@@ -13,16 +13,33 @@
13
13
  "directory": "packages/bridge"
14
14
  },
15
15
  "type": "module",
16
+ "sideEffects": false,
17
+ "types": "./dist/index.d.ts",
18
+ "main": "./dist/index.browser.cjs",
16
19
  "exports": {
17
20
  ".": {
18
21
  "types": "./dist/index.d.ts",
19
- "import": "./dist/index.js",
20
- "require": "./dist/index.cjs"
21
- }
22
+ "react-server": "./dist/index.server.js",
23
+ "workerd": "./dist/index.server.js",
24
+ "worker": "./dist/index.server.js",
25
+ "edge-light": "./dist/index.server.js",
26
+ "deno": "./dist/index.server.js",
27
+ "browser": {
28
+ "import": "./dist/index.browser.js",
29
+ "require": "./dist/index.browser.cjs"
30
+ },
31
+ "default": {
32
+ "import": "./dist/index.browser.js",
33
+ "require": "./dist/index.browser.cjs"
34
+ }
35
+ },
36
+ "./server": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.server.js",
39
+ "require": "./dist/index.server.cjs"
40
+ },
41
+ "./package.json": "./package.json"
22
42
  },
23
- "main": "./dist/index.cjs",
24
- "module": "./dist/index.js",
25
- "types": "./dist/index.d.ts",
26
43
  "files": [
27
44
  "dist",
28
45
  "docs",
@@ -33,36 +50,16 @@
33
50
  "registry": "https://registry.npmjs.org/",
34
51
  "access": "public"
35
52
  },
36
- "dependencies": {
53
+ "optionalDependencies": {
37
54
  "posthog-js": "^1.393.5"
38
55
  },
39
56
  "devDependencies": {
40
57
  "@nominalso/vibe-api-types": "0.0.1",
41
58
  "@nominalso/vibe-protocol-types": "0.0.1"
42
59
  },
43
- "tsup": {
44
- "entry": [
45
- "src/index.ts"
46
- ],
47
- "format": [
48
- "cjs",
49
- "esm"
50
- ],
51
- "noExternal": [
52
- "@nominalso/vibe-protocol-types",
53
- "@nominalso/vibe-api-types"
54
- ],
55
- "dts": {
56
- "resolve": [
57
- "@nominalso/vibe-protocol-types",
58
- "@nominalso/vibe-api-types"
59
- ]
60
- },
61
- "clean": true
62
- },
63
60
  "scripts": {
64
61
  "clean": "rm -rf dist node_modules",
65
- "build": "tsup",
62
+ "build": "rm -rf dist && tsup",
66
63
  "lint": "eslint src",
67
64
  "typecheck": "tsc --noEmit",
68
65
  "test": "vitest run"