@buyingbuddy/react 0.3.1 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -8,7 +8,122 @@ major version is `0`, a breaking change bumps the **minor** version.
8
8
  Entries before 0.3.0 were reconstructed from the repository history when this file was
9
9
  added, so they summarize each release rather than record it at the time.
10
10
 
11
- ## [0.3.0] — unreleased
11
+ ## [0.3.3] — 2026-08-28
12
+
13
+ One change, described two ways, because it fixes two separate symptoms that turned out to
14
+ have a single cause: the provider was deciding the widget runtime had arrived by looking at
15
+ something that is not evidence of it.
16
+
17
+ ### Fixed — widgets no longer mount before the runtime that powers them exists
18
+
19
+ `<BuyingBuddyProvider>` now reports `isLoaded` only once the runtime bundle has actually
20
+ executed. Previously two different shortcuts could report it early:
21
+
22
+ - **The presence of a `<script>` tag** was taken to mean the script behind it had finished
23
+ loading. Under React StrictMode — on by default in the Next.js App Router in development —
24
+ the provider's setup runs twice, and the second run found the first run's tag and declared
25
+ the runtime ready while it was still in flight.
26
+ - **The presence of `window.MBB`** was taken to mean the same thing. The provider creates that
27
+ object itself, before the bundle is even requested, so it is present for the entire download.
28
+
29
+ Widgets consequently rendered into the page before the code that turns them into widgets had
30
+ arrived. They recovered on their own once it did, so the visible symptom was a flash and a
31
+ shift at each widget rather than an error — the kind of thing reported as "the widgets jump
32
+ when the page loads".
33
+
34
+ Readiness is now taken from the runtime itself, and every part of your page that mounts a
35
+ widget waits on the same signal rather than each guessing separately.
36
+
37
+ ### Fixed — a failed script load is reported again in development
38
+
39
+ If the runtime bundle fails to load — an ad blocker, a CSP rule, a corporate proxy, an offline
40
+ client — that failure is logged to the console and readable as `error` from `useBuyingBuddy()`.
41
+
42
+ Both of those already existed, and both were silently inert in development under StrictMode:
43
+ the failure arrived at a listener that the framework's own double-run had already retired, so
44
+ nothing was logged and `error` stayed `null`. A blocked bundle looked exactly like a page with
45
+ no widgets on it. Production builds were unaffected and reported correctly throughout.
46
+
47
+ ```tsx
48
+ const { error } = useBuyingBuddy();
49
+ if (error) return <p>Property search is temporarily unavailable.</p>;
50
+ ```
51
+
52
+ A load that fails can now also be retried by a later mount, rather than the first failure
53
+ standing for the lifetime of the page.
54
+
55
+ ### Fixed — no more hydration mismatch on pages that already carry the classic embed
56
+
57
+ Server-rendered apps (Next.js App Router included) no longer produce
58
+ *"Hydration failed because the server rendered HTML didn't match the client"* when the page
59
+ already has the v5 runtime `<script>` on it — the state a site is in while migrating from the
60
+ script-tag embed to this package, or running both during a transition.
61
+
62
+ The provider's first render on the client now matches what the server produced, and resolves
63
+ to the real state one tick later. Nothing is required of you on upgrade.
64
+
65
+ ## [0.3.2] — 2026-08-22
66
+
67
+ Two changes, released together. Neither has shipped before: 0.3.2 was version-bumped and
68
+ merged on 2026-08-21 but never published, so every install to date has received 0.3.1.
69
+
70
+ ### The package now works in React Server Components frameworks, including the Next.js App Router
71
+
72
+ `BuyingBuddyProvider` and `BuyingBuddyWidget`, and the package entry point, now carry a
73
+ `"use client"` directive.
74
+
75
+ Previously, importing the package the way this README shows it failed an App Router build
76
+ outright with `createContext is not a function`, and `next dev` returned HTTP 500 on every
77
+ route. The documented workaround — a local file re-exporting the package behind your own
78
+ `"use client"` — is no longer necessary. It remains harmless if you already have one.
79
+
80
+ `"use client"` is a React Server Components directive rather than a Next.js one, so bundlers
81
+ that do not understand it ignore it: this is inert for Vite, Create React App and Framer
82
+ consumers, and no change is required on their side.
83
+
84
+ ### Fixed — a failed script load no longer takes your website down with it
85
+
86
+ `<BuyingBuddyProvider>` renders `children` immediately and in every state. Previously it
87
+ withheld them until the runtime script finished loading, and replaced them entirely with its
88
+ own red error box if the script failed.
89
+
90
+ Because every documented install path wraps the whole application in the provider, that
91
+ second behaviour meant a single blocked request to our CDN — an ad blocker, a CSP rule, a
92
+ corporate proxy, an offline client, a CloudFront blip — replaced the customer's entire
93
+ website with an error message. A load failure is now reported rather than rendered: it is
94
+ logged to the console once, and remains readable as `error` from `useBuyingBuddy()` for any
95
+ application that wants to surface it. Widgets already render nothing until the runtime is
96
+ ready, which is the correct degraded state and is unchanged.
97
+
98
+ ```tsx
99
+ const { error } = useBuyingBuddy();
100
+ if (error) return <p>Property search is temporarily unavailable.</p>;
101
+ ```
102
+
103
+ #### Deprecated — `fallback`
104
+
105
+ Nothing is required of you on upgrade, but `fallback` is now accepted and ignored, and will be
106
+ removed in a future release. Delete it when convenient. It is kept in the type meanwhile so
107
+ existing call sites continue to compile.
108
+
109
+ The prop only ever existed to soften the behaviour above: it filled the gap while the provider
110
+ was withholding your page. With the page no longer withheld there is no gap left to fill, and
111
+ the widgets inside it handle their own loading.
112
+
113
+ - The instruction our install guides gave — `fallback={children}` — rendered `children`
114
+ anyway, so removing it changes nothing you can see.
115
+ - If you passed a real loading indicator, it stops appearing. Your page is no longer withheld,
116
+ so there is no longer a moment for it to cover. **TypeScript users see a deprecation marker;
117
+ JavaScript users get no signal**, so check your call sites rather than waiting for a build
118
+ error that will not come.
119
+
120
+ ## [0.3.1] — 2026-08-20
121
+
122
+ - No functional change. Added a data-hosting note to the README, and brought the internal
123
+ version constant back into step with the package version so the `data-bb-react` stamp and
124
+ `window.MBB.reactPackageVersion` report the version that actually built the site.
125
+
126
+ ## [0.3.0] — 2026-08-13
12
127
 
13
128
  ### Removed — breaking
14
129
 
package/README.md CHANGED
@@ -63,7 +63,7 @@ export default function App() {
63
63
  }
64
64
  ```
65
65
 
66
- Replace `account-activation-key` with your `activationKey`. The provider loads the Buying Buddy script for that account once, waits for it to initialize, then renders your widgets. While it loads it renders the `fallback` (nothing, by default).
66
+ Replace `account-activation-key` with your `activationKey`. The provider loads the Buying Buddy script for that account once and makes it available to the widgets inside it. Your own content renders straight away — the provider never withholds it — and each widget appears once the runtime is ready.
67
67
 
68
68
  ## Examples
69
69
 
@@ -127,7 +127,7 @@ import { BuyingBuddyProvider, BuyingBuddyWidget } from "@buyingbuddy/react";
127
127
 
128
128
  export default function Page() {
129
129
  return (
130
- <BuyingBuddyProvider activationKey="account-activation-key" fallback={<p>Loading…</p>}>
130
+ <BuyingBuddyProvider activationKey="account-activation-key">
131
131
  <BuyingBuddyWidget type="SearchResults" />
132
132
  </BuyingBuddyProvider>
133
133
  );
@@ -155,7 +155,7 @@ Loads the Buying Buddy runtime for an account and makes it available to the widg
155
155
  | Prop | Type | Default | Description |
156
156
  |------|------|---------|-------------|
157
157
  | `activationKey` | `string` | — | **Required.** Your Buying Buddy account activation key. |
158
- | `fallback` | `ReactNode` | `null` | Rendered while the script is loading. Not shown on error — see Caveats. |
158
+ | `fallback` | `ReactNode` | — | **Deprecated, no-op since 0.3.2.** Accepted and ignored; safe to delete. The provider no longer withholds `children`, so there is no loading state for it to render in. |
159
159
 
160
160
  ### `<BuyingBuddyWidget>`
161
161
 
@@ -188,7 +188,14 @@ import type {
188
188
  - **Client-side only.** Widgets render in the browser after the script loads — nothing is server-rendered. There's no SSR/streaming output, so the listing content isn't in the initial HTML (relevant for SEO).
189
189
  - **Changing a prop rebuilds the widget.** Changing `type` or `filter` tears down and recreates the underlying `<bb-widget>`, losing in-widget state (map position, scroll, form input).
190
190
  - **The script persists after unmount.** Unmounting the provider does not remove the script or reset the global — remounting reuses the already-loaded runtime. This is intentional.
191
- - **Error UI is built in.** If the runtime script fails to load (network error), the provider renders its own inline error message in place of `children` (and `fallback` is not shown). You can't currently replace the default error UI. Note this only covers script load failure — an unauthorized domain loads fine but renders empty widgets (see Prerequisites).
191
+ - **A script load failure degrades quietly.** If the runtime script fails to load — CDN outage, ad blocker, CSP rule, corporate proxy, offline — your application renders exactly as it otherwise would and the Buying Buddy widgets are simply absent. The provider renders nothing of its own over your page. The failure is logged to the console once, and is readable as `error` from `useBuyingBuddy()` if you want to say something about it yourself:
192
+
193
+ ```tsx
194
+ const { error } = useBuyingBuddy();
195
+ if (error) return <p>Property search is temporarily unavailable.</p>;
196
+ ```
197
+
198
+ Note this covers script load failure only — an unauthorized domain loads fine but renders empty widgets (see Prerequisites).
192
199
  - **ESM-only.** This package ships as ES modules only (no CommonJS build). Use it in a project with ESM/bundler support.
193
200
  - **Pre-release.** This package is `0.x` — the API may change.
194
201
 
@@ -13,6 +13,20 @@ declare global {
13
13
  };
14
14
  }
15
15
  }
16
+ /**
17
+ * Drop all module-level load bookkeeping. For tests only.
18
+ *
19
+ * `BUNDLE_LOADS` and `REPORTED_LOAD_FAILURES` are module singletons that
20
+ * outlive any single render, which is the whole point of them - but it also
21
+ * means a test that removes the injected `<script>` from the DOM has NOT
22
+ * returned the module to a clean state, and the next test reusing that
23
+ * activation key silently joins the previous test's pending promise instead of
24
+ * starting a load of its own.
25
+ *
26
+ * Not exported from `index.ts`, so it is not part of the package's public API:
27
+ * the `exports` map admits the barrel only.
28
+ */
29
+ export declare function __resetBundleStateForTests(): void;
16
30
  /**
17
31
  * Provides the BuyingBuddy runtime context to child components.
18
32
  *
@@ -27,5 +41,5 @@ declare global {
27
41
  * </BuyingBuddyProvider>
28
42
  * ```
29
43
  */
30
- export declare function BuyingBuddyProvider({ activationKey, domain, apiBaseUrl, children, fallback, }: BuyingBuddyProviderProps): import("react").JSX.Element;
44
+ export declare function BuyingBuddyProvider({ activationKey, domain, apiBaseUrl, children, }: BuyingBuddyProviderProps): import("react").JSX.Element;
31
45
  //# sourceMappingURL=BuyingBuddyProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuyingBuddyProvider.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAKjF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,uBAAuB,CAQxD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC7B,UAAU,EAAE,MAAM,CAAC;YACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH;CACF;AAcD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,MAAuB,EACvB,UAAU,EACV,QAAQ,EACR,QAAe,GAChB,EAAE,wBAAwB,+BA4G1B"}
1
+ {"version":3,"file":"BuyingBuddyProvider.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAKjF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,uBAAuB,CAQxD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC7B,UAAU,EAAE,MAAM,CAAC;YACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH;CACF;AA0DD;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAGjD;AA8GD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,MAAuB,EACvB,UAAU,EACV,QAAQ,GAKT,EAAE,wBAAwB,+BA6G1B"}
@@ -1,4 +1,8 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // Required: createContext() runs at module scope below, and in the Next.js App
4
+ // Router every module is a Server Component by default - without this the build
5
+ // fails with "createContext is not a function" and next dev 500s on every route.
2
6
  import { createContext, useContext, useEffect, useState } from "react";
3
7
  import { PKG_VERSION } from "./version";
4
8
  const BuyingBuddyContext = createContext(null);
@@ -13,7 +17,49 @@ export function useBuyingBuddy() {
13
17
  }
14
18
  return ctx;
15
19
  }
16
- const LOADED_ACCOUNTS = new Set();
20
+ /**
21
+ * The custom element the v5 runtime registers. `customElements.define` for this
22
+ * name is an unconditional top-level statement in the bundle, so the definition
23
+ * exists the moment the bundle finishes executing - which makes it the one
24
+ * signal on the page that means "the runtime is really here".
25
+ *
26
+ * It is deliberately NOT `window.MBB`. The provider creates that object itself,
27
+ * below, BEFORE the bundle has even been requested, so `!!window.MBB` is true
28
+ * during the entire CDN round-trip. Treating it as readiness is what produced
29
+ * both defects this module has carried: a widget mounted before the runtime
30
+ * existed, and a first client render that disagreed with the server's.
31
+ */
32
+ const RUNTIME_ELEMENT = "bb-widget";
33
+ /**
34
+ * In-flight (or completed) loads of the runtime bundle, keyed by activation key.
35
+ *
36
+ * A promise rather than a boolean, because "a script tag with this id exists"
37
+ * and "the bundle behind it has executed" are different facts and the gap
38
+ * between them is a whole network round-trip. Every mount awaits this same
39
+ * promise instead of inferring readiness from the tag, so:
40
+ *
41
+ * - `isLoaded` cannot flip before `onload` has actually fired, and
42
+ * - a load failure reaches EVERY waiting mount, not just the one that
43
+ * happened to attach the handlers.
44
+ *
45
+ * The second point is the one that bit us. Under React StrictMode the effect
46
+ * runs twice: run 1 appended the tag and attached the handlers, then its
47
+ * cleanup marked itself cancelled; run 2 found the tag already there and had no
48
+ * handlers of its own. A real `onerror` then landed only on run 1's
49
+ * cancelled-out closure and was discarded, so the console.error and the `error`
50
+ * on the context - both added specifically for this failure - were silently
51
+ * dead in dev, which is exactly where a developer would be looking.
52
+ *
53
+ * The entry is evicted on failure (see `loadRuntimeBundle`) so a later mount
54
+ * can retry rather than inheriting a permanently rejected promise.
55
+ */
56
+ const BUNDLE_LOADS = new Map();
57
+ // Accounts whose runtime bundle has already failed and been reported. The
58
+ // provider logs a load failure once per activation key, not once per attempt:
59
+ // a remount, a React StrictMode double-effect, or a second provider for the
60
+ // same account would otherwise repeat an identical message the developer has
61
+ // already seen and can do nothing further about.
62
+ const REPORTED_LOAD_FAILURES = new Set();
17
63
  /**
18
64
  * The v5 widget runtime, served from the CDN — the exact same bundle every
19
65
  * other official integration (WordPress, Joomla, PHP SDK) loads. Loading it
@@ -22,6 +68,113 @@ const LOADED_ACCOUNTS = new Set();
22
68
  * through CloudFront, not S3 origin.
23
69
  */
24
70
  const MBB_BUNDLE_URL = "https://d2w6u17ngtanmy.cloudfront.net/scripts/my-buying-buddy.5.0.js.gz";
71
+ /**
72
+ * Drop all module-level load bookkeeping. For tests only.
73
+ *
74
+ * `BUNDLE_LOADS` and `REPORTED_LOAD_FAILURES` are module singletons that
75
+ * outlive any single render, which is the whole point of them - but it also
76
+ * means a test that removes the injected `<script>` from the DOM has NOT
77
+ * returned the module to a clean state, and the next test reusing that
78
+ * activation key silently joins the previous test's pending promise instead of
79
+ * starting a load of its own.
80
+ *
81
+ * Not exported from `index.ts`, so it is not part of the package's public API:
82
+ * the `exports` map admits the barrel only.
83
+ */
84
+ export function __resetBundleStateForTests() {
85
+ BUNDLE_LOADS.clear();
86
+ REPORTED_LOAD_FAILURES.clear();
87
+ }
88
+ /**
89
+ * Whether the widget runtime is already executing on this page.
90
+ *
91
+ * True only once the bundle has run, because registering `<bb-widget>` is
92
+ * something only the bundle itself can do. That covers the case the old
93
+ * `!!window.MBB` check was reaching for and getting wrong - a page that already
94
+ * carries the classic `<script>` embed - without the false positives described
95
+ * on `RUNTIME_ELEMENT`.
96
+ */
97
+ function isRuntimeReady() {
98
+ return (typeof window !== "undefined" &&
99
+ typeof window.customElements !== "undefined" &&
100
+ !!window.customElements.get(RUNTIME_ELEMENT));
101
+ }
102
+ /**
103
+ * Load the runtime bundle for an account, at most once concurrently.
104
+ *
105
+ * Returns the same promise to every caller for a given activation key, so a
106
+ * remount - or React StrictMode's deliberate double-invoke - joins the load in
107
+ * progress instead of assuming a tag it did not create has already finished.
108
+ *
109
+ * On failure the entry is evicted and the failed tag removed, so a later mount
110
+ * genuinely retries. Without that, one transient CDN blip would be permanent
111
+ * for the life of the page: the rejected promise would be handed to every
112
+ * subsequent mount, and the dead `<script>` would still be sitting in `<head>`
113
+ * to make the tag-presence check lie about it a second time.
114
+ */
115
+ function loadRuntimeBundle(activationKey, apiBaseUrl) {
116
+ const inFlight = BUNDLE_LOADS.get(activationKey);
117
+ if (inFlight)
118
+ return inFlight;
119
+ const scriptId = `mbb-script-${activationKey}`;
120
+ const load = new Promise((resolve, reject) => {
121
+ // Initialise the MBB global the official-embed way (a single `data.acid`
122
+ // plus the data base URL) BEFORE the bundle executes, so its first data
123
+ // request uses our acid and base URL.
124
+ if (!window.MBB) {
125
+ window.MBB = {
126
+ seo: "false",
127
+ data: { acid: activationKey },
128
+ apiBaseUrl,
129
+ reactPackageVersion: PKG_VERSION,
130
+ };
131
+ }
132
+ // A tag can already exist with no map entry - a hot reload that re-evaluated
133
+ // this module, or a second copy of the package. Prefer adopting it over
134
+ // appending a duplicate: two `<script>` tags for this bundle fail at PARSE
135
+ // time on redeclared top-level classes, which fires `load`, not `error`,
136
+ // and so would be invisible here.
137
+ //
138
+ // But adopt only a tag that can still SPEAK. `load` and `error` are not
139
+ // replayed to a handler attached after they fired, so adopting a tag that
140
+ // has already settled would produce a promise that never settles - and
141
+ // because the map entry is only evicted by the error handler, every later
142
+ // mount for this account would join that same stuck promise. `isLoaded`
143
+ // would stay false, `error` would stay null, and nothing would be logged:
144
+ // the precise silence this whole change exists to remove. The state stamp
145
+ // below is what makes that distinguishable at all, since the DOM exposes no
146
+ // "has this script already finished" flag.
147
+ const existing = document.getElementById(scriptId);
148
+ const spent = existing?.dataset.bbLoad === "failed";
149
+ if (spent)
150
+ existing?.remove();
151
+ const adopted = spent ? null : existing;
152
+ const script = adopted ?? document.createElement("script");
153
+ script.onload = () => {
154
+ script.dataset.bbLoad = "loaded";
155
+ // A later failure is a genuinely new event, so let it be reported again
156
+ // rather than silenced by the once-per-key guard from an earlier one.
157
+ REPORTED_LOAD_FAILURES.delete(activationKey);
158
+ resolve();
159
+ };
160
+ script.onerror = () => {
161
+ script.dataset.bbLoad = "failed";
162
+ BUNDLE_LOADS.delete(activationKey);
163
+ script.remove();
164
+ reject(new Error(`Failed to load BuyingBuddy script for account: ${activationKey}`));
165
+ };
166
+ if (!adopted) {
167
+ script.id = scriptId;
168
+ script.src = MBB_BUNDLE_URL;
169
+ script.async = true;
170
+ script.dataset.bbReact = PKG_VERSION;
171
+ script.dataset.bbLoad = "loading";
172
+ document.head.appendChild(script);
173
+ }
174
+ });
175
+ BUNDLE_LOADS.set(activationKey, load);
176
+ return load;
177
+ }
25
178
  /**
26
179
  * Provides the BuyingBuddy runtime context to child components.
27
180
  *
@@ -36,16 +189,28 @@ const MBB_BUNDLE_URL = "https://d2w6u17ngtanmy.cloudfront.net/scripts/my-buying-
36
189
  * </BuyingBuddyProvider>
37
190
  * ```
38
191
  */
39
- export function BuyingBuddyProvider({ activationKey, domain = "www.mbb2.com", apiBaseUrl, children, fallback = null, }) {
192
+ export function BuyingBuddyProvider({ activationKey, domain = "www.mbb2.com", apiBaseUrl, children,
193
+ // `fallback` is deliberately absent here. It remains on the props type as a
194
+ // deprecated no-op so existing call sites keep compiling, but the provider no
195
+ // longer has a loading state to render, so there is nothing for it to stand
196
+ // in for. See the deprecation note in ./types.
197
+ }) {
40
198
  // Base URL for widget DATA requests. Defaults to the same environment as
41
199
  // `domain`, but can be set independently to point data at another
42
200
  // environment (e.g. a quick prod/preview flip for testing) without changing
43
201
  // which bundle/theme `domain` loads.
44
202
  const resolvedApiBaseUrl = apiBaseUrl ?? `https://${domain}`;
45
- const [isLoaded, setIsLoaded] = useState(() => {
46
- // If already loaded (e.g., script tag in HTML), skip loading
47
- return typeof window !== "undefined" && !!window.MBB;
48
- });
203
+ // Always false on the first render, with no exception for a runtime that is
204
+ // already present. Under SSR the first client render is the HYDRATION render
205
+ // and has to produce what the server produced; the server has no `window`, so
206
+ // it is always false there. Reading a browser global in this initializer -
207
+ // which is what this used to do - is the first cause React itself lists for a
208
+ // hydration mismatch, and it made every widget mount point diverge.
209
+ //
210
+ // The already-loaded case is not lost, only deferred: the effect below sets it
211
+ // synchronously on the first tick after mount, which is precisely the frame
212
+ // hydration needs to have already agreed on.
213
+ const [isLoaded, setIsLoaded] = useState(false);
49
214
  const [error, setError] = useState(null);
50
215
  useEffect(() => {
51
216
  if (typeof window === "undefined")
@@ -74,56 +239,56 @@ export function BuyingBuddyProvider({ activationKey, domain = "www.mbb2.com", ap
74
239
  window.MBB.apiBaseUrl = resolvedApiBaseUrl;
75
240
  window.MBB.reactPackageVersion = PKG_VERSION;
76
241
  }
77
- // Already loaded for this account — nothing more to do.
78
- if (window.MBB && LOADED_ACCOUNTS.has(activationKey)) {
242
+ // The runtime is already executing on this page - a classic `<script>`
243
+ // embed, or a previous mount that finished. Nothing to load, and nothing to
244
+ // wait for, so resolve it synchronously here rather than a tick later: this
245
+ // runs after hydration has already committed, so it costs nothing to
246
+ // correctness and keeps a remount from flashing its widgets away.
247
+ if (isRuntimeReady()) {
79
248
  setIsLoaded(true);
80
249
  return;
81
250
  }
251
+ // Tracks THIS mount only. It gates this component's own state updates and
252
+ // nothing else - deliberately not the shared load's resolution, which is
253
+ // what the previous version conflated. A cancelled mount used to take the
254
+ // whole account's error reporting down with it.
82
255
  let cancelled = false;
83
- const scriptId = `mbb-script-${activationKey}`;
84
- const markLoaded = () => {
256
+ loadRuntimeBundle(activationKey, resolvedApiBaseUrl).then(() => {
257
+ if (!cancelled)
258
+ setIsLoaded(true);
259
+ }, (failure) => {
85
260
  if (cancelled)
86
261
  return;
87
- LOADED_ACCOUNTS.add(activationKey);
88
- setIsLoaded(true);
89
- };
90
- if (document.getElementById(scriptId)) {
91
- // Bundle already requested (prior mount) — treat as loaded.
92
- markLoaded();
93
- }
94
- else {
95
- // Initialise the MBB global the official-embed way (a single `data.acid`
96
- // plus the data base URL) BEFORE the bundle executes, so its first data
97
- // request uses our acid and base URL.
98
- if (!window.MBB) {
99
- window.MBB = {
100
- seo: "false",
101
- data: { acid: activationKey },
102
- apiBaseUrl: resolvedApiBaseUrl,
103
- reactPackageVersion: PKG_VERSION,
104
- };
262
+ // Report, do not render. The provider wraps the host application's
263
+ // whole tree, so anything it renders in place of `children` takes the
264
+ // customer's site down with it - and a blocked CloudFront request is
265
+ // an ordinary event (ad blocker, CSP rule, corporate proxy, offline),
266
+ // not an exceptional one. The correct degraded state is the site
267
+ // intact with the widgets absent, which is what BuyingBuddyWidget's
268
+ // own `if (!isLoaded) return null` already produces.
269
+ if (!REPORTED_LOAD_FAILURES.has(activationKey)) {
270
+ REPORTED_LOAD_FAILURES.add(activationKey);
271
+ console.error(`[@buyingbuddy/react] ${failure.message}`);
105
272
  }
106
- // Load the v5 runtime directly from the CDN.
107
- const script = document.createElement("script");
108
- script.id = scriptId;
109
- script.src = MBB_BUNDLE_URL;
110
- script.async = true;
111
- script.dataset.bbReact = PKG_VERSION;
112
- script.onload = markLoaded;
113
- script.onerror = () => {
114
- if (cancelled)
115
- return;
116
- setError(new Error(`Failed to load BuyingBuddy script for account: ${activationKey}`));
117
- };
118
- document.head.appendChild(script);
119
- }
273
+ // Still surfaced on the context, so a host app that wants to say
274
+ // something about it can read `error` from useBuyingBuddy().
275
+ setError(failure);
276
+ });
120
277
  return () => {
121
- // Don't remove the script (MBB global state is persistent); just stop the
122
- // load handlers from updating state after unmount.
278
+ // Don't remove the script (MBB global state is persistent) and don't
279
+ // cancel the shared load - another mount may still be waiting on it.
280
+ // Only stop THIS mount from setting state after unmount.
123
281
  cancelled = true;
124
282
  };
125
283
  }, [activationKey, domain, resolvedApiBaseUrl]);
126
284
  const value = { isLoaded, error, activationKey };
127
- return (_jsx(BuyingBuddyContext.Provider, { value: value, children: error ? (_jsxs("div", { role: "alert", style: { color: "#b91c1c", padding: "12px", border: "1px solid #fca5a5", borderRadius: "6px", backgroundColor: "#fef2f2", fontFamily: "sans-serif", fontSize: "14px" }, children: [_jsx("strong", { children: "BuyingBuddy Error:" }), " ", error.message] })) : isLoaded ? children : fallback }));
285
+ // `children` renders unconditionally, in every state. The provider is a
286
+ // context boundary, not a gate: it is mounted at the application root by
287
+ // every documented install path, so gating its subtree on a third-party CDN
288
+ // script means one blocked request hides the entire customer site. Widgets
289
+ // gate themselves on `isLoaded` individually, which is the right granularity
290
+ // - and it is why the old `fallback` prop existed only to be handed
291
+ // `children` back, undoing the gate it was introduced to soften.
292
+ return (_jsx(BuyingBuddyContext.Provider, { value: value, children: children }));
128
293
  }
129
294
  //# sourceMappingURL=BuyingBuddyProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuyingBuddyProvider.js","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,kBAAkB,GAAG,aAAa,CAAiC,IAAI,CAAC,CAAC;AAE/E;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC3C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAYD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,cAAc,GAClB,yEAAyE,CAAC;AAE5E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,aAAa,EACb,MAAM,GAAG,cAAc,EACvB,UAAU,EACV,QAAQ,EACR,QAAQ,GAAG,IAAI,GACU;IACzB,yEAAyE;IACzE,kEAAkE;IAClE,4EAA4E;IAC5E,qCAAqC;IACrC,MAAM,kBAAkB,GAAG,UAAU,IAAI,WAAW,MAAM,EAAE,CAAC;IAC7D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC5C,6DA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AAsB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC/C,sBAAsB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAC1C,OAAO,CAAC,KAAK,CAAC,wBAAwB,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3D,CAAC;YACD,iEAAiE;YACjE,6DAA6D;YAC7D,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CACF,CAAC;QAEF,OAAO,GAAG,EAAE;YACV,qEAAqE;YACrE,qEAAqE;YACrE,yDAAyD;YACzD,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEhD,MAAM,KAAK,GAA4B,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IAE1E,wEAAwE;IACxE,yEAAyE;IACzE,4EAA4E;IAC5E,2EAA2E;IAC3E,6EAA6E;IAC7E,oEAAoE;IACpE,iEAAiE;IACjE,OAAO,CACL,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACtC,QAAQ,GACmB,CAC/B,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BuyingBuddyWidget.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyWidget.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,MAAM,EACN,KAAK,EACL,SAAS,EACT,EAAE,EACF,cAAc,GACf,EAAE,sBAAsB;;cAgBY,WAAW,GAAG,IAAI;;;;;;;+DAgDtD"}
1
+ {"version":3,"file":"BuyingBuddyWidget.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyWidget.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,MAAM,EACN,KAAK,EACL,SAAS,EACT,EAAE,EACF,cAAc,GACf,EAAE,sBAAsB;;cAgBY,WAAW,GAAG,IAAI;;;;;;;+DAgDtD"}
@@ -1,3 +1,6 @@
1
+ "use client";
2
+ // Required: this module imports useBuyingBuddy from the provider, so it is a client
3
+ // module for the same reason - see the note in BuyingBuddyProvider.tsx.
1
4
  import { createElement, useCallback, useEffect, useRef } from "react";
2
5
  import { useBuyingBuddy } from "./BuyingBuddyProvider";
3
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"BuyingBuddyWidget.js","sourceRoot":"","sources":["../src/BuyingBuddyWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,IAAI,EACJ,MAAM,EACN,KAAK,EACL,SAAS,EACT,EAAE,EACF,cAAc,GACS;IACvB,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;IAEtC,4EAA4E;IAC5E,8EAA8E;IAC9E,cAAc;IACd,MAAM,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,SAAS,CAAC,GAAG,EAAE;QACb,iBAAiB,CAAC,OAAO,GAAG,cAAc,CAAC;IAC7C,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,wEAAwE;IACxE,8EAA8E;IAC9E,8EAA8E;IAC9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G,KAAK,EAAE,CAAC;IAEjF,8EAA8E;IAC9E,kEAAkE;IAClE,MAAM,GAAG,GAAG,GAAG,IAAI,IAAI,MAAM,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;IAElD,OAAO,aAAa,CAAC,WAAW,EAAE;QAChC,GAAG;QACH,GAAG,EAAE,SAAS;QACd,EAAE;QACF,SAAS;QACT,KAAK,EAAE,WAAW;QAClB,wBAAwB,EAAE,IAAI;QAC9B,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,MAAM;KACtB,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,10 @@
1
+ "use client";
2
+ // The directive is on the barrel AND on both component modules, deliberately.
3
+ // A "use client" barrel alone is usually enough for Next's RSC plugin, but the
4
+ // configuration proven end to end on the Next.js 16 App Router vetting run had it
5
+ // in all three emitted files, so that is what ships. It is an RSC directive, not a
6
+ // Next one: bundlers that do not understand it ignore it, so this is inert for the
7
+ // Vite / CRA / Framer consumers and fixes every RSC framework at once.
1
8
  export { BuyingBuddyProvider, useBuyingBuddy } from "./BuyingBuddyProvider";
2
9
  export { BuyingBuddyWidget } from "./BuyingBuddyWidget";
3
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,8EAA8E;AAC9E,+EAA+E;AAC/E,kFAAkF;AAClF,mFAAmF;AACnF,mFAAmF;AACnF,uEAAuE;AAEvE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -56,11 +56,23 @@ export interface BuyingBuddyProviderProps {
56
56
  * Example: "https://preview.mbb2.com".
57
57
  */
58
58
  apiBaseUrl?: string;
59
- /** Children to render once the script is loaded. */
59
+ /**
60
+ * Your application. Rendered immediately and in every state — the provider
61
+ * never withholds it, including while the runtime script is loading and
62
+ * after a load failure.
63
+ */
60
64
  children: React.ReactNode;
61
65
  /**
62
- * Content to show while the BuyingBuddy script is loading.
63
- * Defaults to null (renders nothing until ready).
66
+ * @deprecated Since 0.3.2 this is accepted and ignored, and it will be
67
+ * removed in a future release. Safe to delete from your call site.
68
+ *
69
+ * It used to hold the place of `children` while the runtime script loaded,
70
+ * back when the provider withheld them. The provider no longer does, so
71
+ * there is no longer a state for it to render in: individual widgets render
72
+ * nothing until the runtime is ready, and everything else on the page —
73
+ * your header, your copy, your other components — is never withheld in the
74
+ * first place. The prop is kept in the type so existing call sites continue
75
+ * to compile.
64
76
  */
65
77
  fallback?: React.ReactNode;
66
78
  }
@@ -70,7 +82,16 @@ export interface BuyingBuddyProviderProps {
70
82
  export interface BuyingBuddyContextValue {
71
83
  /** Whether the MBB script has finished loading. */
72
84
  isLoaded: boolean;
73
- /** Error if the script failed to load. */
85
+ /**
86
+ * Set if the runtime script failed to load — a CDN outage, an ad blocker, a
87
+ * CSP rule, a corporate proxy, or an offline client.
88
+ *
89
+ * The provider does not render anything of its own in this state: your
90
+ * application renders normally and Buying Buddy widgets are simply absent.
91
+ * Read this if you want to say something about it yourself; ignoring it is a
92
+ * perfectly reasonable choice. The failure is also logged to the console
93
+ * once per activation key.
94
+ */
74
95
  error: Error | null;
75
96
  /** The activation key passed to the provider. */
76
97
  activationKey: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,YAAY,GACZ,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,iBAAiB,GACjB,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,YAAY,GACZ,SAAS,GACT,cAAc,GACd,YAAY,GACZ,cAAc,GACd,aAAa,GACb,YAAY,GACZ,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,uCAAuC;IACvC,IAAI,EAAE,qBAAqB,CAAC;IAE5B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gFAAgF;IAChF,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,yBAAyB;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;GAE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nE,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;;;;OASG;IACH,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,iDAAiD;IACjD,aAAa,EAAE,MAAM,CAAC;CACvB"}
package/dist/version.d.ts CHANGED
@@ -14,5 +14,5 @@
14
14
  * there is no bundler `define` to inject it from package.json. `version.test.ts`
15
15
  * asserts the two stay in step, so a bump that misses this file fails the suite.
16
16
  */
17
- export declare const PKG_VERSION = "0.3.1";
17
+ export declare const PKG_VERSION = "0.3.3";
18
18
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -14,5 +14,5 @@
14
14
  * there is no bundler `define` to inject it from package.json. `version.test.ts`
15
15
  * asserts the two stay in step, so a bump that misses this file fails the suite.
16
16
  */
17
- export const PKG_VERSION = "0.3.1";
17
+ export const PKG_VERSION = "0.3.3";
18
18
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buyingbuddy/react",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "IDX MLS real estate integration for React, Next.js, and Framer — property search, map results, listings, lead capture, and CRM via Buying Buddy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,9 +18,10 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "build": "tsc",
21
+ "assert:use-client": "node scripts/assert-use-client.mjs",
21
22
  "dev": "tsc --watch",
22
23
  "test": "vitest run",
23
- "prepublishOnly": "npm run build"
24
+ "prepublishOnly": "npm run build && npm run assert:use-client"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "react": ">=18",