@eazo/sdk 0.16.0 → 0.17.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/README.md +2 -38
- package/dist/internal/runtime-provider.d.ts +10 -0
- package/dist/internal/runtime-provider.d.ts.map +1 -0
- package/dist/internal/runtime-provider.js +97 -0
- package/dist/internal/runtime-provider.js.map +1 -0
- package/dist/react.d.ts +9 -16
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +15 -58
- package/dist/react.js.map +1 -1
- package/dist/react.server.d.ts +1 -7
- package/dist/react.server.d.ts.map +1 -1
- package/dist/react.server.js +12 -16
- package/dist/react.server.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +2 -0
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,6 @@ await auth.logout()
|
|
|
61
61
|
auth.fetchSocialConnections() // SocialConnection[]
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
The SDK reads its app id from the environment (`NEXT_PUBLIC_EAZO_APP_ID`, `EAZO_APP_ID`, `EXPO_PUBLIC_EAZO_APP_ID`). If you need to inject it programmatically — for example in a Next.js layout that resolves the value at SSR — pass it to `<EazoProvider appId={...}>`.
|
|
65
64
|
|
|
66
65
|
#### `auth.login()` — unified login flow
|
|
67
66
|
|
|
@@ -172,41 +171,6 @@ export async function POST() {
|
|
|
172
171
|
}
|
|
173
172
|
```
|
|
174
173
|
|
|
175
|
-
The appId is a deployment-time constant, not a per-call argument. **Convention: set `EAZO_APP_ID`** (one name, no framework prefix). The recommended way to thread it into the SDK on the client side is through the `<EazoProvider appId={...}>` prop, populated from a Server Component:
|
|
176
|
-
|
|
177
|
-
```tsx
|
|
178
|
-
// app/layout.tsx (Server Component — Next.js App Router)
|
|
179
|
-
import { EazoProvider } from "@eazo/sdk/react";
|
|
180
|
-
|
|
181
|
-
export default function RootLayout({ children }) {
|
|
182
|
-
return (
|
|
183
|
-
<html>
|
|
184
|
-
<body>
|
|
185
|
-
<EazoProvider appId={process.env.EAZO_APP_ID}>
|
|
186
|
-
{children}
|
|
187
|
-
</EazoProvider>
|
|
188
|
-
</body>
|
|
189
|
-
</html>
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
```sh
|
|
195
|
-
# .env
|
|
196
|
-
EAZO_APP_ID=iVW3asOFoOvYr9sl
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
That's it — one canonical name, no `NEXT_PUBLIC_` alias required.
|
|
200
|
-
|
|
201
|
-
For frameworks without a Server Component layer (Vite, plain Webpack apps, etc.) call `setAppId(...)` at app startup with whatever value you've sourced (env, runtime config endpoint, etc.):
|
|
202
|
-
|
|
203
|
-
```ts
|
|
204
|
-
import { setAppId } from "@eazo/sdk";
|
|
205
|
-
setAppId(import.meta.env.VITE_EAZO_APP_ID);
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
If neither path is convenient, the SDK also reads any of these env vars as a fallback (priority top-down): `EAZO_APP_ID`, `NEXT_PUBLIC_EAZO_APP_ID`, `EXPO_PUBLIC_EAZO_APP_ID`, `VITE_EAZO_APP_ID`, `PUBLIC_EAZO_APP_ID`, `REACT_APP_EAZO_APP_ID`. The framework prefixes are kept for backward compatibility — new projects should prefer the prop or `setAppId()`.
|
|
209
|
-
|
|
210
174
|
`audience` defaults to `"subscribers"` (v1's only value).
|
|
211
175
|
|
|
212
176
|
Throws `EazoNotificationPublishError` on platform-level errors (`code` 401 = bad JWT, 403 = appId doesn't belong to your key, 413 = >5,000 subscribers, etc.).
|
|
@@ -245,6 +209,6 @@ App code never branches on environment — the capability API is the same on bot
|
|
|
245
209
|
|
|
246
210
|
| Variable | Required | Used by |
|
|
247
211
|
|---|---|---|
|
|
248
|
-
| `EAZO_APP_ID` | yes |
|
|
249
|
-
| `EAZO_PLATFORM_API_BASE` | optional |
|
|
212
|
+
| `EAZO_APP_ID` | yes | App ID; auto-resolved by `<EazoProvider>`. |
|
|
213
|
+
| `EAZO_PLATFORM_API_BASE` | optional | Override the Eazo platform base URL (defaults to `https://eazo.ai`). |
|
|
250
214
|
| `EAZO_PRIVATE_KEY` | server | `requireAuth`, `notifications.publish` |
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PublicAppInfo } from "./banner-ui/app-info";
|
|
3
|
+
export declare const MountedContext: React.Context<boolean>;
|
|
4
|
+
export declare function _EazoRuntimeProvider(props: {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
appId: string;
|
|
7
|
+
apiBase: string | null;
|
|
8
|
+
initialAppInfo: PublicAppInfo | null;
|
|
9
|
+
}): React.ReactElement;
|
|
10
|
+
//# sourceMappingURL=runtime-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-provider.d.ts","sourceRoot":"","sources":["../../src/internal/runtime-provider.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAW1D,eAAO,MAAM,cAAc,wBAA6B,CAAC;AAEzD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,cAAc,EAAE,aAAa,GAAG,IAAI,CAAC;CACtC,GAAG,KAAK,CAAC,YAAY,CA+FrB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.MountedContext = void 0;
|
|
38
|
+
exports._EazoRuntimeProvider = _EazoRuntimeProvider;
|
|
39
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
40
|
+
// Internal runtime provider — receives the resolved `appId` / `apiBase` /
|
|
41
|
+
// `initialAppInfo` as required props and mounts the SDK runtime. The
|
|
42
|
+
// public `EazoProvider` in `react.tsx` / `react.server.tsx` resolves
|
|
43
|
+
// these values from env (and prefetches `PublicAppInfo` on the server)
|
|
44
|
+
// and forwards them here. Keeping this layer separate is what lets the
|
|
45
|
+
// public `EazoProvider` expose a zero-prop API while still passing the
|
|
46
|
+
// SSR-resolved values across the server/client boundary via React props.
|
|
47
|
+
const React = __importStar(require("react"));
|
|
48
|
+
const banner_ui_1 = require("./banner-ui");
|
|
49
|
+
const initial_info_1 = require("./banner-ui/initial-info");
|
|
50
|
+
const styles_1 = require("./banner-ui/styles");
|
|
51
|
+
const bootstrap_1 = require("./bootstrap");
|
|
52
|
+
const auth_1 = require("./capabilities/auth");
|
|
53
|
+
const device_1 = require("./capabilities/device");
|
|
54
|
+
const config_1 = require("./config");
|
|
55
|
+
const env_1 = require("./env");
|
|
56
|
+
const login_ui_1 = require("./login-ui");
|
|
57
|
+
const share_ui_1 = require("./share-ui");
|
|
58
|
+
exports.MountedContext = React.createContext(false);
|
|
59
|
+
function _EazoRuntimeProvider(props) {
|
|
60
|
+
(0, config_1.setAppId)(props.appId);
|
|
61
|
+
// Setter ignores null/empty — calling unconditionally keeps the
|
|
62
|
+
// "clear on Provider unmount with apiBase removed" semantics simple.
|
|
63
|
+
(0, config_1.setHostApiBase)(props.apiBase);
|
|
64
|
+
(0, initial_info_1.setInitialAppInfo)(props.initialAppInfo);
|
|
65
|
+
// Inject the banner-ui stylesheet eagerly (before EazoBrandBanner mounts)
|
|
66
|
+
// so the `.eazo-app-area` wrapper has its `display: contents`/active
|
|
67
|
+
// styles ready on first paint. Banner-ui re-injects the same sheet on
|
|
68
|
+
// its own mount; ensureBannerStylesInjected is idempotent via STYLE_ID.
|
|
69
|
+
// The function self-gates on `getHost() === "web"` internally, so in
|
|
70
|
+
// mobile WebView / iframe hosts this is a no-op — no banner CSS ever
|
|
71
|
+
// lands in `document.head`.
|
|
72
|
+
if (typeof document !== "undefined") {
|
|
73
|
+
(0, styles_1.ensureBannerStylesInjected)();
|
|
74
|
+
}
|
|
75
|
+
// Detect the runtime host so banner-related React components don't
|
|
76
|
+
// even mount in mobile WebView / iframe. `null` until the post-mount
|
|
77
|
+
// effect resolves it; treat null as "render the banner UI" so SSR
|
|
78
|
+
// and the first client render emit the same JSX (no hydration mismatch).
|
|
79
|
+
// After the effect resolves on the client:
|
|
80
|
+
// - web: `host === "web"` → banner UI stays mounted
|
|
81
|
+
// - other: `host === "eazoMobile" | "embeddedIframe"` → unmounts.
|
|
82
|
+
//
|
|
83
|
+
// Banner UI components are SIBLINGS of the .eazo-app-area wrapper, so
|
|
84
|
+
// unmounting them does NOT affect host children — children stay at the
|
|
85
|
+
// same JSX position throughout, no remount.
|
|
86
|
+
const [host, setHost] = React.useState(null);
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
// Starting the bridge is idempotent; capability access may have already done so.
|
|
89
|
+
(0, bootstrap_1.getBridge)();
|
|
90
|
+
void (0, auth_1._bootstrapAuth)();
|
|
91
|
+
void (0, device_1._bootstrapDevice)();
|
|
92
|
+
setHost((0, env_1.getHost)());
|
|
93
|
+
}, []);
|
|
94
|
+
const showBannerUI = host === null || host === "web";
|
|
95
|
+
return ((0, jsx_runtime_1.jsxs)(exports.MountedContext.Provider, { value: true, children: [(0, jsx_runtime_1.jsx)("div", { className: "eazo-app-area", children: (0, jsx_runtime_1.jsx)("div", { className: "eazo-app-area-scroller", children: props.children }) }), showBannerUI && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(banner_ui_1.EazoBrandBanner, {}), (0, jsx_runtime_1.jsx)(login_ui_1.LoginUI, {}), (0, jsx_runtime_1.jsx)(share_ui_1.ShareDownloadModal, {})] }))] }));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=runtime-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-provider.js","sourceRoot":"","sources":["../../src/internal/runtime-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bb,oDAoGC;;AA5HD,0EA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AAE,EAAE,CAAC,CAAC;IACP,MAAM,YAAY,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC;IAErD,OAAO,CACL,wBAAC,sBAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,aA2ClC,gCAAK,SAAS,EAAC,eAAe,YAC5B,gCAAK,SAAS,EAAC,wBAAwB,YAAE,KAAK,CAAC,QAAQ,GAAO,GAC1D,EACL,YAAY,IAAI,CACf,6DACE,uBAAC,2BAAe,KAAG,EACnB,uBAAC,kBAAO,KAAG,EACX,uBAAC,6BAAkB,KAAG,IACrB,CACJ,IACuB,CAC3B,CAAC;AACJ,CAAC"}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type { PublicAppInfo } from "./internal/banner-ui/app-info";
|
|
3
2
|
import type { EazoState } from "./types";
|
|
4
3
|
/**
|
|
5
4
|
* Mounts the SDK runtime. Place once at the root of your React tree.
|
|
6
5
|
*
|
|
7
|
-
* <EazoProvider
|
|
6
|
+
* <EazoProvider>
|
|
8
7
|
* <App />
|
|
9
8
|
* </EazoProvider>
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Zero-config: the SDK auto-reads `EAZO_APP_ID` (and
|
|
11
|
+
* `EAZO_PLATFORM_API_BASE` when set) from env. For non-RSC frameworks
|
|
12
|
+
* set a framework-prefixed alias (`NEXT_PUBLIC_EAZO_APP_ID`,
|
|
13
|
+
* `EXPO_PUBLIC_EAZO_APP_ID`, …) or call `setAppId(...)` at startup.
|
|
14
14
|
*
|
|
15
|
-
* Under Next.js App Router
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `PublicAppInfo` — host code doesn't need to plumb either.
|
|
15
|
+
* Under Next.js App Router this resolves to the server variant
|
|
16
|
+
* (`react.server.tsx`), which prefetches the handoff `PublicAppInfo`
|
|
17
|
+
* during SSR and forwards everything to the runtime via internal props.
|
|
19
18
|
*/
|
|
20
|
-
export declare function EazoProvider(
|
|
19
|
+
export declare function EazoProvider({ children, }: {
|
|
21
20
|
children: React.ReactNode;
|
|
22
|
-
/** Eazo app ID. Required. */
|
|
23
|
-
appId: string;
|
|
24
|
-
/** Optional override. Defaults to `EAZO_PLATFORM_API_BASE` from env, then `https://eazo.ai`. */
|
|
25
|
-
apiBase?: string | null;
|
|
26
|
-
/** Pre-fetched `PublicAppInfo`. When set, skips the client-side fetch + skeleton. */
|
|
27
|
-
initialAppInfo?: PublicAppInfo | null;
|
|
28
21
|
}): React.ReactElement;
|
|
29
22
|
/**
|
|
30
23
|
* Subscribe to a slice of state. Re-renders only when the selector's
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,GAAG,KAAK,CAAC,YAAY,CAgBrB;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,CAkB/D"}
|
package/dist/react.js
CHANGED
|
@@ -37,74 +37,31 @@ exports.EazoProvider = EazoProvider;
|
|
|
37
37
|
exports.useEazo = useEazo;
|
|
38
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
39
|
const React = __importStar(require("react"));
|
|
40
|
-
const banner_ui_1 = require("./internal/banner-ui");
|
|
41
|
-
const initial_info_1 = require("./internal/banner-ui/initial-info");
|
|
42
|
-
const styles_1 = require("./internal/banner-ui/styles");
|
|
43
|
-
const bootstrap_1 = require("./internal/bootstrap");
|
|
44
|
-
const auth_1 = require("./internal/capabilities/auth");
|
|
45
|
-
const device_1 = require("./internal/capabilities/device");
|
|
46
40
|
const config_1 = require("./internal/config");
|
|
47
|
-
const
|
|
48
|
-
const login_ui_1 = require("./internal/login-ui");
|
|
49
|
-
const share_ui_1 = require("./internal/share-ui");
|
|
41
|
+
const runtime_provider_1 = require("./internal/runtime-provider");
|
|
50
42
|
const store_1 = require("./internal/store");
|
|
51
|
-
const MountedContext = React.createContext(false);
|
|
52
43
|
/**
|
|
53
44
|
* Mounts the SDK runtime. Place once at the root of your React tree.
|
|
54
45
|
*
|
|
55
|
-
* <EazoProvider
|
|
46
|
+
* <EazoProvider>
|
|
56
47
|
* <App />
|
|
57
48
|
* </EazoProvider>
|
|
58
49
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
50
|
+
* Zero-config: the SDK auto-reads `EAZO_APP_ID` (and
|
|
51
|
+
* `EAZO_PLATFORM_API_BASE` when set) from env. For non-RSC frameworks
|
|
52
|
+
* set a framework-prefixed alias (`NEXT_PUBLIC_EAZO_APP_ID`,
|
|
53
|
+
* `EXPO_PUBLIC_EAZO_APP_ID`, …) or call `setAppId(...)` at startup.
|
|
62
54
|
*
|
|
63
|
-
* Under Next.js App Router
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* `PublicAppInfo` — host code doesn't need to plumb either.
|
|
55
|
+
* Under Next.js App Router this resolves to the server variant
|
|
56
|
+
* (`react.server.tsx`), which prefetches the handoff `PublicAppInfo`
|
|
57
|
+
* during SSR and forwards everything to the runtime via internal props.
|
|
67
58
|
*/
|
|
68
|
-
function EazoProvider(
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
function EazoProvider({ children, }) {
|
|
60
|
+
const appId = (0, config_1.readAppIdFromEnv)();
|
|
61
|
+
if (!appId) {
|
|
62
|
+
throw new Error("@eazo/sdk: EAZO_APP_ID is not set. Add it to .env (or a framework-prefixed variant for SPA bundlers).");
|
|
71
63
|
}
|
|
72
|
-
(0,
|
|
73
|
-
// Setter ignores null/empty — calling unconditionally keeps the
|
|
74
|
-
// "clear on Provider unmount with apiBase removed" semantics simple.
|
|
75
|
-
(0, config_1.setHostApiBase)(props.apiBase ?? null);
|
|
76
|
-
(0, initial_info_1.setInitialAppInfo)(props.initialAppInfo ?? null);
|
|
77
|
-
// Inject the banner-ui stylesheet eagerly (before EazoBrandBanner mounts)
|
|
78
|
-
// so the `.eazo-app-area` wrapper has its `display: contents`/active
|
|
79
|
-
// styles ready on first paint. Banner-ui re-injects the same sheet on
|
|
80
|
-
// its own mount; ensureBannerStylesInjected is idempotent via STYLE_ID.
|
|
81
|
-
// The function self-gates on `getHost() === "web"` internally, so in
|
|
82
|
-
// mobile WebView / iframe hosts this is a no-op — no banner CSS ever
|
|
83
|
-
// lands in `document.head`.
|
|
84
|
-
if (typeof document !== "undefined") {
|
|
85
|
-
(0, styles_1.ensureBannerStylesInjected)();
|
|
86
|
-
}
|
|
87
|
-
// Detect the runtime host so banner-related React components don't
|
|
88
|
-
// even mount in mobile WebView / iframe. `null` until the post-mount
|
|
89
|
-
// effect resolves it; treat null as "render the banner UI" so SSR
|
|
90
|
-
// and the first client render emit the same JSX (no hydration mismatch).
|
|
91
|
-
// After the effect resolves on the client:
|
|
92
|
-
// - web: `host === "web"` → banner UI stays mounted
|
|
93
|
-
// - other: `host === "eazoMobile" | "embeddedIframe"` → unmounts.
|
|
94
|
-
//
|
|
95
|
-
// Banner UI components are SIBLINGS of the .eazo-app-area wrapper, so
|
|
96
|
-
// unmounting them does NOT affect host children — children stay at the
|
|
97
|
-
// same JSX position throughout, no remount.
|
|
98
|
-
const [host, setHost] = React.useState(null);
|
|
99
|
-
React.useEffect(() => {
|
|
100
|
-
// Starting the bridge is idempotent; capability access may have already done so.
|
|
101
|
-
(0, bootstrap_1.getBridge)();
|
|
102
|
-
void (0, auth_1._bootstrapAuth)();
|
|
103
|
-
void (0, device_1._bootstrapDevice)();
|
|
104
|
-
setHost((0, env_1.getHost)());
|
|
105
|
-
}, []);
|
|
106
|
-
const showBannerUI = host === null || host === "web";
|
|
107
|
-
return ((0, jsx_runtime_1.jsxs)(MountedContext.Provider, { value: true, children: [(0, jsx_runtime_1.jsx)("div", { className: "eazo-app-area", children: (0, jsx_runtime_1.jsx)("div", { className: "eazo-app-area-scroller", children: props.children }) }), showBannerUI && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(banner_ui_1.EazoBrandBanner, {}), (0, jsx_runtime_1.jsx)(login_ui_1.LoginUI, {}), (0, jsx_runtime_1.jsx)(share_ui_1.ShareDownloadModal, {})] }))] }));
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)(runtime_provider_1._EazoRuntimeProvider, { appId: appId, apiBase: (0, config_1.readApiBaseFromEnv)(), initialAppInfo: null, children: children }));
|
|
108
65
|
}
|
|
109
66
|
/**
|
|
110
67
|
* Subscribe to a slice of state. Re-renders only when the selector's
|
|
@@ -114,7 +71,7 @@ function EazoProvider(props) {
|
|
|
114
71
|
* const { platform, locale } = useEazo(s => s.device);
|
|
115
72
|
*/
|
|
116
73
|
function useEazo(selector) {
|
|
117
|
-
const mounted = React.useContext(MountedContext);
|
|
74
|
+
const mounted = React.useContext(runtime_provider_1.MountedContext);
|
|
118
75
|
if (process.env.NODE_ENV !== "production" && !mounted) {
|
|
119
76
|
console.warn("[@eazo/sdk] useEazo() called without <EazoProvider>. Mount it at the root of your app.");
|
|
120
77
|
}
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;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AE,WAAW,EAAE,iBAAiB,CAAC,CAAC;AACrF,CAAC"}
|
package/dist/react.server.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export { useEazo } from "./react";
|
|
3
|
-
export declare function EazoProvider(
|
|
3
|
+
export declare function EazoProvider({ children, }: {
|
|
4
4
|
children: React.ReactNode;
|
|
5
|
-
/** Eazo app ID. Required. */
|
|
6
|
-
appId: string;
|
|
7
|
-
/** Optional override. Defaults to `EAZO_PLATFORM_API_BASE` from env. */
|
|
8
|
-
apiBase?: string | null;
|
|
9
|
-
/** Pre-resolved `PublicAppInfo`. When set, skips the in-Provider fetch. */
|
|
10
|
-
initialAppInfo?: import("./internal/banner-ui/app-info").PublicAppInfo | null;
|
|
11
5
|
}): Promise<React.ReactElement>;
|
|
12
6
|
//# sourceMappingURL=react.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.server.d.ts","sourceRoot":"","sources":["../src/react.server.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.server.d.ts","sourceRoot":"","sources":["../src/react.server.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AA+BlC,wBAAsB,YAAY,CAAC,EACjC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CA0B9B"}
|
package/dist/react.server.js
CHANGED
|
@@ -36,11 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.useEazo = void 0;
|
|
37
37
|
exports.EazoProvider = EazoProvider;
|
|
38
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
-
const react_1 = require("./react");
|
|
40
39
|
const app_info_1 = require("./internal/banner-ui/app-info");
|
|
41
40
|
const config_1 = require("./internal/config");
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const runtime_provider_1 = require("./internal/runtime-provider");
|
|
42
|
+
var react_1 = require("./react");
|
|
43
|
+
Object.defineProperty(exports, "useEazo", { enumerable: true, get: function () { return react_1.useEazo; } });
|
|
44
44
|
// `EazoMobile/` is injected by `AppViewerFallback.tsx`; `wv` covers
|
|
45
45
|
// generic RN WebViews on Android and some iOS builds. False positives
|
|
46
46
|
// just fall back to the client-side fetch, same as pre-SSR behavior.
|
|
@@ -68,23 +68,19 @@ async function getRequestUserAgent() {
|
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
async function EazoProvider(
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
async function EazoProvider({ children, }) {
|
|
72
|
+
const appId = (0, config_1.readAppIdFromEnv)();
|
|
73
|
+
if (!appId) {
|
|
74
|
+
throw new Error("@eazo/sdk: EAZO_APP_ID is not set. Add it to .env so the SDK can resolve the host app.");
|
|
74
75
|
}
|
|
75
|
-
const apiBase =
|
|
76
|
+
const apiBase = (0, config_1.readApiBaseFromEnv)();
|
|
76
77
|
// Skip the prefetch inside Eazo Mobile WebView — the handoff overlay
|
|
77
78
|
// is `getHost()`-gated and never renders there.
|
|
78
79
|
let initialAppInfo = null;
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
const ua = await getRequestUserAgent();
|
|
81
|
+
if (!isMobileWebViewUserAgent(ua)) {
|
|
82
|
+
initialAppInfo = await (0, app_info_1.fetchPublicAppInfo)(appId, { apiBase });
|
|
81
83
|
}
|
|
82
|
-
|
|
83
|
-
const ua = await getRequestUserAgent();
|
|
84
|
-
if (!isMobileWebViewUserAgent(ua)) {
|
|
85
|
-
initialAppInfo = await (0, app_info_1.fetchPublicAppInfo)(props.appId, { apiBase });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return ((0, jsx_runtime_1.jsx)(react_1.EazoProvider, { appId: props.appId, apiBase: apiBase, initialAppInfo: initialAppInfo, children: props.children }));
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)(runtime_provider_1._EazoRuntimeProvider, { appId: appId, apiBase: apiBase, initialAppInfo: initialAppInfo, children: children }));
|
|
89
85
|
}
|
|
90
86
|
//# sourceMappingURL=react.server.js.map
|
package/dist/react.server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.server.js","sourceRoot":"","sources":["../src/react.server.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"react.server.js","sourceRoot":"","sources":["../src/react.server.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,oCA8BC;;AAjED,4DAAmE;AACnE,8CAAyE;AACzE,kEAAmE;AAEnE,iCAAkC;AAAzB,gGAAA,OAAO,OAAA;AAEhB,oEAAoE;AACpE,sEAAsE;AACtE,qEAAqE;AACrE,MAAM,yBAAyB,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAE3E,SAAS,wBAAwB,CAAC,EAA6B;IAC7D,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IACtB,KAAK,MAAM,MAAM,IAAI,yBAAyB,EAAE,CAAC;QAC/C,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,wEAAwE;AACxE,qEAAqE;AACrE,2BAA2B;AAC3B,KAAK,UAAU,mBAAmB;IAChC,IAAI,CAAC;QACH,uEAAuE;QACvE,MAAM,aAAa,GAAG,CAAC,wDAAa,cAAc,GAAC,CAElD,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;QACrD,OAAO,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,YAAY,CAAC,EACjC,QAAQ,GAGT;IACC,MAAM,KAAK,GAAG,IAAA,yBAAgB,GAAE,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,IAAA,2BAAkB,GAAE,CAAC;IAErC,qEAAqE;IACrE,gDAAgD;IAChD,IAAI,cAAc,GAAiE,IAAI,CAAC;IACxF,MAAM,EAAE,GAAG,MAAM,mBAAmB,EAAE,CAAC;IACvC,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC,EAAE,CAAC;QAClC,cAAc,GAAG,MAAM,IAAA,6BAAkB,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,CACL,uBAAC,uCAAoB,IACnB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,YAE7B,QAAQ,GACY,CACxB,CAAC;AACJ,CAAC"}
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH,wBAAgB,UAAU,IAAI,IAAI,CAcjC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAG7D"}
|
package/dist/testing.js
CHANGED
|
@@ -6,6 +6,7 @@ const bootstrap_1 = require("./internal/bootstrap");
|
|
|
6
6
|
const auth_1 = require("./internal/capabilities/auth");
|
|
7
7
|
const device_1 = require("./internal/capabilities/device");
|
|
8
8
|
const share_1 = require("./internal/capabilities/share");
|
|
9
|
+
const config_1 = require("./internal/config");
|
|
9
10
|
const store_1 = require("./internal/store");
|
|
10
11
|
/**
|
|
11
12
|
* Test helpers. NOT for production code paths.
|
|
@@ -18,6 +19,7 @@ function __resetSDK() {
|
|
|
18
19
|
(0, device_1.__resetDeviceCapability)();
|
|
19
20
|
(0, share_1.__resetShareCapability)();
|
|
20
21
|
(0, bootstrap_1.__resetBootstrap)();
|
|
22
|
+
(0, config_1.__resetConfig)();
|
|
21
23
|
store_1.store.reset();
|
|
22
24
|
if (typeof window !== "undefined") {
|
|
23
25
|
try {
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":";;AAcA,gCAcC;AAMD,sDAGC;AArCD,oDAAwD;AACxD,uDAAqE;AACrE,2DAAyE;AACzE,yDAAuE;AACvE,8CAAkD;AAClD,4CAAyC;AAEzC;;;;;GAKG;AAEH,SAAgB,UAAU;IACxB,IAAA,4BAAqB,GAAE,CAAC;IACxB,IAAA,gCAAuB,GAAE,CAAC;IAC1B,IAAA,8BAAsB,GAAE,CAAC;IACzB,IAAA,4BAAgB,GAAE,CAAC;IACnB,IAAA,sBAAa,GAAE,CAAC;IAChB,aAAK,CAAC,KAAK,EAAE,CAAC;IACd,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,QAAiB;IACrD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,MAAM,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
package/package.json
CHANGED