@pylonsync/react 0.3.35 → 0.3.41
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/package.json +3 -3
- package/src/db.ts +15 -2
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.41",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "src/index.ts",
|
|
9
9
|
"types": "src/index.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"check": "tsc -p tsconfig.json --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@pylonsync/sdk": "0.3.
|
|
16
|
-
"@pylonsync/sync": "0.3.
|
|
15
|
+
"@pylonsync/sdk": "0.3.41",
|
|
16
|
+
"@pylonsync/sync": "0.3.41"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": ">=19.0.0"
|
package/src/db.ts
CHANGED
|
@@ -42,9 +42,16 @@ let _started = false;
|
|
|
42
42
|
* import { init } from "@pylonsync/react";
|
|
43
43
|
* init({ baseUrl: "http://localhost:4321" });
|
|
44
44
|
* ```
|
|
45
|
+
*
|
|
46
|
+
* Omitting `baseUrl` in a browser context falls back to
|
|
47
|
+
* `window.location.origin` — the right answer for same-origin
|
|
48
|
+
* deployments (Next.js + Vercel rewrites, embedded SPA). Passing an
|
|
49
|
+
* explicit `baseUrl` always wins. We deliberately do NOT default to
|
|
50
|
+
* `http://localhost:4321` in browsers — that footgun caused production
|
|
51
|
+
* dashboards to fire requests at the engineer's dev port.
|
|
45
52
|
*/
|
|
46
53
|
export function init(config?: Partial<SyncEngineConfig> & { baseUrl?: string }) {
|
|
47
|
-
_sync = createSyncEngine(config?.baseUrl
|
|
54
|
+
_sync = createSyncEngine(config?.baseUrl, config);
|
|
48
55
|
_started = false;
|
|
49
56
|
// Keep the React-side helpers in sync — a single init() should fully
|
|
50
57
|
// namespace this app's storage without a separate configureClient call.
|
|
@@ -56,7 +63,13 @@ export function init(config?: Partial<SyncEngineConfig> & { baseUrl?: string })
|
|
|
56
63
|
|
|
57
64
|
function getSync(): SyncEngine {
|
|
58
65
|
if (!_sync) {
|
|
59
|
-
|
|
66
|
+
// Lazy fallback for callers that never invoked init(). Same
|
|
67
|
+
// resolution rules as init: browser → window.location.origin,
|
|
68
|
+
// SSR → localhost:4321 (the pylon dev default). The browser case
|
|
69
|
+
// is critical: without it a useQuery hook that fires before the
|
|
70
|
+
// app's SyncProvider effect lands would leak `localhost:4321`
|
|
71
|
+
// requests in production.
|
|
72
|
+
_sync = createSyncEngine();
|
|
60
73
|
}
|
|
61
74
|
if (!_started) {
|
|
62
75
|
_started = true;
|