@eazo/sdk 0.11.0 → 0.13.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/PROTOCOL.md +7 -1
- package/README.md +78 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/auth-primitive/EazoAuthClient.js +1 -1
- package/dist/internal/auth-primitive/EazoAuthClient.js.map +1 -1
- package/dist/internal/bridge/protocol.d.ts +6 -0
- package/dist/internal/bridge/protocol.d.ts.map +1 -1
- package/dist/internal/bridge/protocol.js +5 -1
- package/dist/internal/bridge/protocol.js.map +1 -1
- package/dist/internal/capabilities/ai.js +1 -1
- package/dist/internal/capabilities/ai.js.map +1 -1
- package/dist/internal/capabilities/auth.d.ts +10 -5
- package/dist/internal/capabilities/auth.d.ts.map +1 -1
- package/dist/internal/capabilities/auth.js +29 -13
- package/dist/internal/capabilities/auth.js.map +1 -1
- package/dist/internal/capabilities/device.d.ts +0 -1
- package/dist/internal/capabilities/device.d.ts.map +1 -1
- package/dist/internal/capabilities/device.js +2 -6
- package/dist/internal/capabilities/device.js.map +1 -1
- package/dist/internal/capabilities/memory.d.ts +10 -15
- package/dist/internal/capabilities/memory.d.ts.map +1 -1
- package/dist/internal/capabilities/memory.js +9 -26
- package/dist/internal/capabilities/memory.js.map +1 -1
- package/dist/internal/capabilities/notifications.d.ts +41 -0
- package/dist/internal/capabilities/notifications.d.ts.map +1 -0
- package/dist/internal/capabilities/notifications.js +61 -0
- package/dist/internal/capabilities/notifications.js.map +1 -0
- package/dist/internal/capabilities/share.d.ts +4 -2
- package/dist/internal/capabilities/share.d.ts.map +1 -1
- package/dist/internal/capabilities/share.js +13 -9
- package/dist/internal/capabilities/share.js.map +1 -1
- package/dist/internal/capabilities/storage.d.ts +7 -11
- package/dist/internal/capabilities/storage.d.ts.map +1 -1
- package/dist/internal/capabilities/storage.js +5 -13
- package/dist/internal/capabilities/storage.js.map +1 -1
- package/dist/internal/config.d.ts +9 -12
- package/dist/internal/config.d.ts.map +1 -1
- package/dist/internal/config.js +53 -22
- package/dist/internal/config.js.map +1 -1
- package/dist/internal/store.d.ts.map +1 -1
- package/dist/internal/store.js +0 -1
- package/dist/internal/store.js.map +1 -1
- package/dist/react.d.ts +9 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +12 -5
- package/dist/react.js.map +1 -1
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +146 -0
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/memory.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAgCD,eAAO,MAAM,MAAM;IACjB;;;;;;;;;;;;;;;OAeG;yBACwB,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CA0C9D,CAAC"}
|
|
@@ -6,14 +6,7 @@ const protocol_1 = require("../bridge/protocol");
|
|
|
6
6
|
const config_1 = require("../config");
|
|
7
7
|
const env_1 = require("../env");
|
|
8
8
|
const auth_1 = require("./auth");
|
|
9
|
-
|
|
10
|
-
// Helpers
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
/**
|
|
13
|
-
* Detect platform from the runtime environment.
|
|
14
|
-
* Returns "ios" or "android" when running inside the Eazo Mobile WebView,
|
|
15
|
-
* "web" otherwise.
|
|
16
|
-
*/
|
|
9
|
+
/** "ios" / "android" inside the Eazo Mobile WebView, "web" otherwise. */
|
|
17
10
|
function detectPlatform() {
|
|
18
11
|
if (typeof window === "undefined")
|
|
19
12
|
return "web";
|
|
@@ -26,11 +19,9 @@ function detectPlatform() {
|
|
|
26
19
|
return "web";
|
|
27
20
|
}
|
|
28
21
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* a no-op. Failures (NOT_SUPPORTED, TIMEOUT, transport errors) are
|
|
33
|
-
* intentionally swallowed — the HTTP path remains the source of truth.
|
|
22
|
+
* Fire-and-forget side-channel to the mobile host. Never throws, never
|
|
23
|
+
* blocks the HTTP report below — that's the durable record. No-op outside
|
|
24
|
+
* the Eazo Mobile WebView.
|
|
34
25
|
*/
|
|
35
26
|
function notifyMobile(payload) {
|
|
36
27
|
if ((0, env_1.getHost)() !== "eazoMobile")
|
|
@@ -48,19 +39,12 @@ function notifyMobile(payload) {
|
|
|
48
39
|
}
|
|
49
40
|
})();
|
|
50
41
|
}
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
|
-
// Public API
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
42
|
exports.memory = {
|
|
55
43
|
/**
|
|
56
44
|
* Report a user action event to Gum memory service.
|
|
57
45
|
*
|
|
58
|
-
* Requires the user to be authenticated —
|
|
59
|
-
* automatically
|
|
60
|
-
* `NEXT_PUBLIC_EAZO_APP_ID` or set via `auth.configure({ appId })`.
|
|
61
|
-
*
|
|
62
|
-
* `metadata.appid` is automatically set to the app ID when not supplied.
|
|
63
|
-
* `platform` is auto-detected ("ios" / "android" / "web") when not supplied.
|
|
46
|
+
* Requires the user to be authenticated — `x-eazo-session` is forwarded
|
|
47
|
+
* automatically. The app id comes from `<EazoProvider appId>`.
|
|
64
48
|
*
|
|
65
49
|
* @example
|
|
66
50
|
* ```ts
|
|
@@ -75,19 +59,18 @@ exports.memory = {
|
|
|
75
59
|
async reportAction(params) {
|
|
76
60
|
const appId = (0, config_1.getAppId)();
|
|
77
61
|
if (!appId) {
|
|
78
|
-
throw new Error("@eazo/sdk:
|
|
62
|
+
throw new Error("@eazo/sdk: app id not configured. Mount <EazoProvider appId={...}> at the root of your app.");
|
|
79
63
|
}
|
|
80
64
|
const session = await auth_1.auth.getSessionHeader();
|
|
81
65
|
if (!session) {
|
|
82
66
|
throw new Error("@eazo/sdk: user is not authenticated. Call auth.login() before reporting memory actions.");
|
|
83
67
|
}
|
|
84
|
-
//
|
|
68
|
+
// Caller's metadata wins if it sets `appid`; otherwise stamp ours in.
|
|
85
69
|
const metadata = { appid: appId, ...params.metadata };
|
|
86
|
-
// Auto-detect platform when not provided by the caller.
|
|
87
70
|
const platform = params.platform ?? detectPlatform();
|
|
88
71
|
const payload = { ...params, metadata, platform };
|
|
89
72
|
notifyMobile(payload);
|
|
90
|
-
const res = await fetch(`${(0, config_1.
|
|
73
|
+
const res = await fetch(`${(0, config_1.getPlatformApiBase)()}/api/open/gum/action`, {
|
|
91
74
|
method: "POST",
|
|
92
75
|
headers: {
|
|
93
76
|
"Content-Type": "application/json",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/internal/capabilities/memory.ts"],"names":[],"mappings":";;;AAAA,4CAA2D;AAC3D,iDAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/internal/capabilities/memory.ts"],"names":[],"mappings":";;;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9C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,MAAM,QAAQ,GAA4B,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC/E,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,cAAc,EAAE,CAAC;QAErD,MAAM,OAAO,GAAuB,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QAEtE,YAAY,CAAC,OAAO,CAAC,CAAC;QAEtB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAA,2BAAkB,GAAE,sBAAsB,EAAE;YACrE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,cAAc,EAAE,KAAK;gBACrB,gBAAgB,EAAE,OAAO;aAC1B;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,OAAO,GAAG,mCAAmC,GAAG,CAAC,MAAM,EAAE,CAAC;YAC9D,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAA0B,CAAC;gBACtD,IAAI,IAAI,EAAE,OAAO;oBAAE,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC5C,CAAC;YAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface NotificationsSubscriptionResult {
|
|
2
|
+
/**
|
|
3
|
+
* Whether the current user is subscribed to push notifications from this
|
|
4
|
+
* app *after* the call resolves. On the mobile path this reflects the
|
|
5
|
+
* `apps_user.flags & APP_FLAG_SUBSCRIBED_PUSH` bit. On the plain-web path
|
|
6
|
+
* (no host) the SDK returns `{ subscribed: false }` and does not throw,
|
|
7
|
+
* so apps can call `isSubscribed()` from a `useEffect` without crashing
|
|
8
|
+
* during local web development.
|
|
9
|
+
*/
|
|
10
|
+
subscribed: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Per-app push-notification subscription, mediated by the host. The mobile
|
|
14
|
+
* shell (or any host that advertises the `notifications.*` capability) maps
|
|
15
|
+
* these calls onto its `apps-user/toggle-flag` + `apps-user/action/:id`
|
|
16
|
+
* endpoints; the SDK never talks to the platform directly here. That keeps
|
|
17
|
+
* the trust model identical to the existing favorite/like/comment toggles —
|
|
18
|
+
* the host knows which app the user is currently inside and which user is
|
|
19
|
+
* signed in, neither needs to be re-asserted by the embedded app.
|
|
20
|
+
*
|
|
21
|
+
* **Backend publishing** (the path that actually delivers a notification to
|
|
22
|
+
* users) is a different surface — see `@eazo/sdk/server`'s
|
|
23
|
+
* `notifications.publish(...)`. That helper is the one the app's serverless
|
|
24
|
+
* handler calls (signed with `EAZO_PRIVATE_KEY`) when something interesting
|
|
25
|
+
* happens; subscribed users then receive an Expo system push.
|
|
26
|
+
*/
|
|
27
|
+
export declare const notifications: {
|
|
28
|
+
/** Returns the current subscription state without changing it. */
|
|
29
|
+
isSubscribed(): Promise<NotificationsSubscriptionResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Opt the current user into push notifications from this app. Idempotent
|
|
32
|
+
* (re-subscribing returns `{ subscribed: true }` either way). The user
|
|
33
|
+
* still has to have granted system push permission at the OS level for
|
|
34
|
+
* any actual push to arrive — this method does not prompt for it; the
|
|
35
|
+
* mobile host handles permission once at login.
|
|
36
|
+
*/
|
|
37
|
+
subscribe(): Promise<NotificationsSubscriptionResult>;
|
|
38
|
+
/** Opt the current user out. Idempotent. */
|
|
39
|
+
unsubscribe(): Promise<NotificationsSubscriptionResult>;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/notifications.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,+BAA+B;IAC9C;;;;;;;OAOG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa;IACxB,kEAAkE;oBAC5C,OAAO,CAAC,+BAA+B,CAAC;IAI9D;;;;;;OAMG;iBACgB,OAAO,CAAC,+BAA+B,CAAC;IAI3D,4CAA4C;mBACvB,OAAO,CAAC,+BAA+B,CAAC;CAG9D,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notifications = void 0;
|
|
4
|
+
const bootstrap_1 = require("../bootstrap");
|
|
5
|
+
const protocol_1 = require("../bridge/protocol");
|
|
6
|
+
/**
|
|
7
|
+
* Per-app push-notification subscription, mediated by the host. The mobile
|
|
8
|
+
* shell (or any host that advertises the `notifications.*` capability) maps
|
|
9
|
+
* these calls onto its `apps-user/toggle-flag` + `apps-user/action/:id`
|
|
10
|
+
* endpoints; the SDK never talks to the platform directly here. That keeps
|
|
11
|
+
* the trust model identical to the existing favorite/like/comment toggles —
|
|
12
|
+
* the host knows which app the user is currently inside and which user is
|
|
13
|
+
* signed in, neither needs to be re-asserted by the embedded app.
|
|
14
|
+
*
|
|
15
|
+
* **Backend publishing** (the path that actually delivers a notification to
|
|
16
|
+
* users) is a different surface — see `@eazo/sdk/server`'s
|
|
17
|
+
* `notifications.publish(...)`. That helper is the one the app's serverless
|
|
18
|
+
* handler calls (signed with `EAZO_PRIVATE_KEY`) when something interesting
|
|
19
|
+
* happens; subscribed users then receive an Expo system push.
|
|
20
|
+
*/
|
|
21
|
+
exports.notifications = {
|
|
22
|
+
/** Returns the current subscription state without changing it. */
|
|
23
|
+
async isSubscribed() {
|
|
24
|
+
return invoke(protocol_1.NOTIFICATIONS_IS_SUBSCRIBED);
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Opt the current user into push notifications from this app. Idempotent
|
|
28
|
+
* (re-subscribing returns `{ subscribed: true }` either way). The user
|
|
29
|
+
* still has to have granted system push permission at the OS level for
|
|
30
|
+
* any actual push to arrive — this method does not prompt for it; the
|
|
31
|
+
* mobile host handles permission once at login.
|
|
32
|
+
*/
|
|
33
|
+
async subscribe() {
|
|
34
|
+
return invoke(protocol_1.NOTIFICATIONS_SUBSCRIBE);
|
|
35
|
+
},
|
|
36
|
+
/** Opt the current user out. Idempotent. */
|
|
37
|
+
async unsubscribe() {
|
|
38
|
+
return invoke(protocol_1.NOTIFICATIONS_UNSUBSCRIBE);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
async function invoke(fn) {
|
|
42
|
+
const hello = await (0, bootstrap_1.waitForBootstrap)();
|
|
43
|
+
const bridge = (0, bootstrap_1.getBridge)();
|
|
44
|
+
if (hello && bridge?.getStatus().ready) {
|
|
45
|
+
try {
|
|
46
|
+
const result = await bridge.request(fn);
|
|
47
|
+
return { subscribed: !!result?.subscribed };
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (err instanceof protocol_1.BridgeErrorObject &&
|
|
51
|
+
(err.code === "NOT_SUPPORTED" || err.code === "TIMEOUT")) {
|
|
52
|
+
// Web fallback: no host means no push channel. Return a falsey state
|
|
53
|
+
// so apps can render the right UI without special-casing.
|
|
54
|
+
return { subscribed: false };
|
|
55
|
+
}
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { subscribed: false };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/internal/cap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images?: string[];
|
|
11
11
|
/**
|
|
12
|
-
* Optional attribution — the id of the app that originated the
|
|
13
|
-
*
|
|
12
|
+
* Optional attribution override — the id of the app that originated the
|
|
13
|
+
* share. Defaults to the running app's id (`getAppId()`); pass an explicit
|
|
14
|
+
* value only when forwarding a share that originated in a different app.
|
|
15
|
+
* The host uses this to attach an "app mention" pill to the post.
|
|
14
16
|
*/
|
|
15
17
|
sourceAppId?: string;
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/share.ts"],"names":[],"mappings":"AAMA,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB
|
|
1
|
+
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/share.ts"],"names":[],"mappings":"AAMA,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AA4CD,eAAO,MAAM,KAAK;IAChB;;;;;;;;;;;OAWG;mBACkB,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmCrE,CAAC"}
|
|
@@ -9,7 +9,7 @@ const protocol_1 = require("../bridge/protocol");
|
|
|
9
9
|
const store_1 = require("../store");
|
|
10
10
|
const MAX_IMAGES = 4;
|
|
11
11
|
function getShareDownloadUrl() {
|
|
12
|
-
return `${(0, config_1.
|
|
12
|
+
return `${(0, config_1.getPlatformApiBase)()}/`;
|
|
13
13
|
}
|
|
14
14
|
function __resetShareCapability() {
|
|
15
15
|
(0, store_1.setShareUI)({ open: false });
|
|
@@ -65,6 +65,13 @@ exports.share = {
|
|
|
65
65
|
async compose(input) {
|
|
66
66
|
validate(input);
|
|
67
67
|
const payload = normalize(input);
|
|
68
|
+
// Auto-stamp the running app's id when the caller didn't supply an
|
|
69
|
+
// explicit override. Mirrors the same default applied in `memory`.
|
|
70
|
+
if (!payload.sourceAppId) {
|
|
71
|
+
const appId = (0, config_1.getAppId)();
|
|
72
|
+
if (appId)
|
|
73
|
+
payload.sourceAppId = appId;
|
|
74
|
+
}
|
|
68
75
|
const hello = await (0, bootstrap_1.waitForBootstrap)();
|
|
69
76
|
const bridge = (0, bootstrap_1.getBridge)();
|
|
70
77
|
if (hello && bridge?.getStatus().ready) {
|
|
@@ -75,17 +82,14 @@ exports.share = {
|
|
|
75
82
|
return { accepted: result?.accepted ?? true };
|
|
76
83
|
}
|
|
77
84
|
catch (err) {
|
|
78
|
-
|
|
79
|
-
(err.code === "NOT_SUPPORTED" || err.code === "TIMEOUT")
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
85
|
+
const fallbackable = err instanceof protocol_1.BridgeErrorObject &&
|
|
86
|
+
(err.code === "NOT_SUPPORTED" || err.code === "TIMEOUT");
|
|
87
|
+
if (!fallbackable)
|
|
83
88
|
throw err;
|
|
84
|
-
|
|
89
|
+
// fall through to web fallback
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
|
-
//
|
|
88
|
-
// effectful but predictable — apps can detect it via `accepted: false`.
|
|
92
|
+
// Side-effectful but observable: apps detect this branch via `accepted: false`.
|
|
89
93
|
if (typeof document !== "undefined") {
|
|
90
94
|
(0, store_1.setShareUI)({ open: true });
|
|
91
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../../src/internal/capabilities/share.ts"],"names":[],"mappings":";;;AAMA,kDAEC;
|
|
1
|
+
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../../src/internal/capabilities/share.ts"],"names":[],"mappings":";;;AAMA,kDAEC;AA6BD,wDAEC;AAvCD,sCAAyD;AACzD,4CAA2D;AAC3D,iDAAsE;AACtE,oCAAsC;AAEtC,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,SAAgB,mBAAmB;IACjC,OAAO,GAAG,IAAA,2BAAkB,GAAE,GAAG,CAAC;AACpC,CAAC;AA6BD,SAAgB,sBAAsB;IACpC,IAAA,kBAAU,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAwB;IACxC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,4BAAiB,CAAC,cAAc,EAAE,wCAAwC,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzE,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,4BAAiB,CACzB,cAAc,EACd,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YACrC,MAAM,IAAI,4BAAiB,CACzB,cAAc,EACd,iCAAi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E,mEAAmE;QACnE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;YACzB,IAAI,KAAK;gBAAE,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;QACzC,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAA,4BAAgB,GAAE,CAAC;QACvC,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;QAE3B,IAAI,KAAK,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAqB,wBAAa,EAAE,OAAO,CAAC,CAAC;gBAChF,mEAAmE;gBACnE,+CAA+C;gBAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC;YAChD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,YAAY,GAChB,GAAG,YAAY,4BAAiB;oBAChC,CAAC,GAAG,CAAC,IAAI,KAAK,eAAe,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;gBAC3D,IAAI,CAAC,YAAY;oBAAE,MAAM,GAAG,CAAC;gBAC7B,+BAA+B;YACjC,CAAC;QACH,CAAC;QAED,gFAAgF;QAChF,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpC,IAAA,kBAAU,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
export interface StorageCredentials {
|
|
2
|
-
/** Presigned PUT URL —
|
|
2
|
+
/** Presigned PUT URL — issue the request without an auth header. */
|
|
3
3
|
uploadUrl: string;
|
|
4
|
-
/**
|
|
4
|
+
/** Permanent CDN URL for the uploaded object (no expiry). */
|
|
5
5
|
publicUrl: string;
|
|
6
|
-
/** Full S3 object key
|
|
6
|
+
/** Full S3 object key, e.g. `app-contents/{md5(ownerId)}/{path}`. */
|
|
7
7
|
key: string;
|
|
8
8
|
bucket: string;
|
|
9
9
|
region: string;
|
|
10
|
-
/** ISO timestamp
|
|
10
|
+
/** ISO timestamp at which `uploadUrl` expires. */
|
|
11
11
|
expiration: string;
|
|
12
12
|
}
|
|
13
13
|
export interface UploadResult {
|
|
14
|
-
/** Full S3 object key */
|
|
15
14
|
key: string;
|
|
16
|
-
/** Publicly accessible CDN URL */
|
|
17
15
|
url: string;
|
|
18
16
|
}
|
|
19
17
|
export declare const storage: {
|
|
20
18
|
/**
|
|
21
19
|
* Upload a file to Eazo built-in object storage.
|
|
22
20
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* 2. PUTs the file directly to S3 — no platform bandwidth used.
|
|
27
|
-
* 3. Returns the S3 key and a permanent CDN URL.
|
|
21
|
+
* Two-step: requests a presigned PUT URL (tenant-scoped via STS Session
|
|
22
|
+
* Policy), then PUTs directly to S3 — no platform bandwidth in the
|
|
23
|
+
* critical path. Returns the S3 key and a permanent CDN URL.
|
|
28
24
|
*
|
|
29
25
|
* @param path Relative object path, e.g. "todos/123/avatar.png"
|
|
30
26
|
* @param file File or Blob to upload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AA6BD,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;OAUG;iBAEK,MAAM,QACN,IAAI,GAAG,IAAI,YACR;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,YAAY,CAAC;IAiBxB;;;;OAIG;yBACkB,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAG1D,CAAC"}
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.storage = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Internal helpers
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
5
|
async function fetchCredentials(path) {
|
|
9
6
|
const appId = (0, config_1.getAppId)();
|
|
10
7
|
if (!appId) {
|
|
11
|
-
throw new Error("@eazo/sdk:
|
|
8
|
+
throw new Error("@eazo/sdk: app id not configured. Mount <EazoProvider appId={...}> at the root of your app.");
|
|
12
9
|
}
|
|
13
|
-
const res = await fetch(`${(0, config_1.
|
|
10
|
+
const res = await fetch(`${(0, config_1.getPlatformApiBase)()}/api/open/storage-credentials`, {
|
|
14
11
|
method: "POST",
|
|
15
12
|
headers: { "Content-Type": "application/json" },
|
|
16
13
|
body: JSON.stringify({ appId, path }),
|
|
@@ -28,18 +25,13 @@ async function fetchCredentials(path) {
|
|
|
28
25
|
const json = await res.json();
|
|
29
26
|
return json.data;
|
|
30
27
|
}
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
// Public API
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
28
|
exports.storage = {
|
|
35
29
|
/**
|
|
36
30
|
* Upload a file to Eazo built-in object storage.
|
|
37
31
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* 2. PUTs the file directly to S3 — no platform bandwidth used.
|
|
42
|
-
* 3. Returns the S3 key and a permanent CDN URL.
|
|
32
|
+
* Two-step: requests a presigned PUT URL (tenant-scoped via STS Session
|
|
33
|
+
* Policy), then PUTs directly to S3 — no platform bandwidth in the
|
|
34
|
+
* critical path. Returns the S3 key and a permanent CDN URL.
|
|
43
35
|
*
|
|
44
36
|
* @param path Relative object path, e.g. "todos/123/avatar.png"
|
|
45
37
|
* @param file File or Blob to upload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":";;;AAAA,sCAAyD;AAoBzD,KAAK,UAAU,gBAAgB,CAAC,IAAY;IAC1C,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAA,2BAAkB,GAAE,+BAA+B,EAAE;QAC9E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KACtC,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,IAAI,OAAO,GAAG,sCAAsC,GAAG,CAAC,MAAM,EAAE,CAAC;QACjE,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAA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ared runtime configuration
|
|
3
|
-
*
|
|
2
|
+
* Shared runtime configuration. Dependency-free so both bootstrap and
|
|
3
|
+
* capability modules can read/write without circular imports.
|
|
4
4
|
*/
|
|
5
|
+
export declare const DEFAULT_PLATFORM_API_BASE = "https://eazo.ai";
|
|
6
|
+
/** Set by `<EazoProvider appId={...}>`. */
|
|
5
7
|
export declare function setAppId(id: string | null): void;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the configured Eazo app ID. Falls back to
|
|
8
|
-
* NEXT_PUBLIC_EAZO_APP_ID when no explicit override has been set via
|
|
9
|
-
* `auth.configure({ appId })`.
|
|
10
|
-
*/
|
|
8
|
+
/** Explicit value via setAppId, then env-name list, then null. */
|
|
11
9
|
export declare function getAppId(): string | null;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export declare function getApiBase(override?: string): string;
|
|
10
|
+
/** Set from `hello.apiBase` during device-capability bootstrap. */
|
|
11
|
+
export declare function setHostApiBase(url: string | null): void;
|
|
12
|
+
export declare function getPlatformApiBase(override?: string): string;
|
|
13
|
+
export declare function readAppIdFromEnv(): string | null;
|
|
17
14
|
export declare function __resetConfig(): void;
|
|
18
15
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEhD;AAED
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AA8B3D,2CAA2C;AAC3C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEhD;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAGxC;AAED,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEvD;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEhD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAGpC"}
|
package/dist/internal/config.js
CHANGED
|
@@ -1,44 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Shared runtime configuration
|
|
4
|
-
*
|
|
3
|
+
* Shared runtime configuration. Dependency-free so both bootstrap and
|
|
4
|
+
* capability modules can read/write without circular imports.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DEFAULT_PLATFORM_API_BASE = void 0;
|
|
7
8
|
exports.setAppId = setAppId;
|
|
8
9
|
exports.getAppId = getAppId;
|
|
9
|
-
exports.
|
|
10
|
+
exports.setHostApiBase = setHostApiBase;
|
|
11
|
+
exports.getPlatformApiBase = getPlatformApiBase;
|
|
12
|
+
exports.readAppIdFromEnv = readAppIdFromEnv;
|
|
10
13
|
exports.__resetConfig = __resetConfig;
|
|
11
14
|
let appId = null;
|
|
12
|
-
|
|
15
|
+
let hostInjectedApiBase = null;
|
|
16
|
+
exports.DEFAULT_PLATFORM_API_BASE = "https://eazo.ai";
|
|
17
|
+
function readEnvByNames(names) {
|
|
18
|
+
if (typeof process === "undefined" || !process.env)
|
|
19
|
+
return null;
|
|
20
|
+
for (const name of names) {
|
|
21
|
+
const value = process.env[name];
|
|
22
|
+
if (typeof value === "string" && value.length > 0)
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const APP_ID_ENV_NAMES = [
|
|
28
|
+
"EAZO_APP_ID",
|
|
29
|
+
"NEXT_PUBLIC_EAZO_APP_ID",
|
|
30
|
+
"EXPO_PUBLIC_EAZO_APP_ID",
|
|
31
|
+
"VITE_EAZO_APP_ID",
|
|
32
|
+
"PUBLIC_EAZO_APP_ID",
|
|
33
|
+
"REACT_APP_EAZO_APP_ID",
|
|
34
|
+
];
|
|
35
|
+
const API_BASE_ENV_NAMES = [
|
|
36
|
+
"EAZO_API_BASE",
|
|
37
|
+
"EAZO_API_URL",
|
|
38
|
+
"NEXT_PUBLIC_EAZO_API_URL",
|
|
39
|
+
"EXPO_PUBLIC_EAZO_API_URL",
|
|
40
|
+
"VITE_EAZO_API_URL",
|
|
41
|
+
"PUBLIC_EAZO_API_URL",
|
|
42
|
+
"REACT_APP_EAZO_API_URL",
|
|
43
|
+
];
|
|
44
|
+
/** Set by `<EazoProvider appId={...}>`. */
|
|
13
45
|
function setAppId(id) {
|
|
14
46
|
appId = id;
|
|
15
47
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Returns the configured Eazo app ID. Falls back to
|
|
18
|
-
* NEXT_PUBLIC_EAZO_APP_ID when no explicit override has been set via
|
|
19
|
-
* `auth.configure({ appId })`.
|
|
20
|
-
*/
|
|
48
|
+
/** Explicit value via setAppId, then env-name list, then null. */
|
|
21
49
|
function getAppId() {
|
|
22
50
|
if (appId)
|
|
23
51
|
return appId;
|
|
24
|
-
|
|
25
|
-
return process.env.NEXT_PUBLIC_EAZO_APP_ID;
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
52
|
+
return readEnvByNames(APP_ID_ENV_NAMES);
|
|
28
53
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function
|
|
54
|
+
/** Set from `hello.apiBase` during device-capability bootstrap. */
|
|
55
|
+
function setHostApiBase(url) {
|
|
56
|
+
hostInjectedApiBase = url ? url.replace(/\/$/, "") : null;
|
|
57
|
+
}
|
|
58
|
+
function getPlatformApiBase(override) {
|
|
34
59
|
if (override)
|
|
35
60
|
return override.replace(/\/$/, "");
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
if (hostInjectedApiBase)
|
|
62
|
+
return hostInjectedApiBase;
|
|
63
|
+
const fromEnv = readEnvByNames(API_BASE_ENV_NAMES);
|
|
64
|
+
if (fromEnv)
|
|
65
|
+
return fromEnv.replace(/\/$/, "");
|
|
66
|
+
return exports.DEFAULT_PLATFORM_API_BASE;
|
|
67
|
+
}
|
|
68
|
+
function readAppIdFromEnv() {
|
|
69
|
+
return readEnvByNames(APP_ID_ENV_NAMES);
|
|
40
70
|
}
|
|
41
71
|
function __resetConfig() {
|
|
42
72
|
appId = null;
|
|
73
|
+
hostInjectedApiBase = null;
|
|
43
74
|
}
|
|
44
75
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoCH,4BAEC;AAGD,4BAGC;AAGD,wCAEC;AAED,gDAMC;AAED,4CAEC;AAED,sCAGC;AAhED,IAAI,KAAK,GAAkB,IAAI,CAAC;AAChC,IAAI,mBAAmB,GAAkB,IAAI,CAAC;AAEjC,QAAA,yBAAyB,GAAG,iBAAiB,CAAC;AAE3D,SAAS,cAAc,CAAC,KAAwB;IAC9C,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAChE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAClE,C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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/internal/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEpE,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAE3B,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/internal/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEpE,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAE3B,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB;AAuBD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;CACf;AAMD,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,iBAK3B,CAAC;AAKF,eAAO,MAAM,KAAK;mBACD,iBAAiB;yBAGX,iBAAiB;wBAGlB,QAAQ,GAAG,MAAM,IAAI;aAIhC,IAAI;CAId,CAAC;AAOF,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAWvD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAQ7D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAQ7D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAQ7D"}
|
package/dist/internal/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/internal/store.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/internal/store.ts"],"names":[],"mappings":";;;AAqFA,0BAWC;AAED,8BAQC;AAED,gCAQC;AAED,gCAQC;AA3GD,MAAM,YAAY,GAAc;IAC9B,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,KAAK;CACrB,CAAC;AAEF,MAAM,cAAc,GAAkB;IACpC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF,MAAM,gBAAgB,GAAiB;IACrC,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,WAAW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K,EAAE,CAAC;IACpD,MAAM,OAAO,GAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAA+B,CAAC,IAAI,CACnE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CACpC,CAAC;IACF,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,CAAC,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/react.d.ts
CHANGED
|
@@ -3,19 +3,23 @@ import type { EazoState } from "./types";
|
|
|
3
3
|
/**
|
|
4
4
|
* Mounts the SDK runtime. Place once at the root of your React tree.
|
|
5
5
|
*
|
|
6
|
-
* <EazoProvider>
|
|
6
|
+
* <EazoProvider appId={process.env.EAZO_APP_ID}>
|
|
7
7
|
* <App />
|
|
8
8
|
* </EazoProvider>
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* `<EazoProvider>` is how an app's appId reaches every SDK capability
|
|
11
|
+
* (`auth`, `device`, `share`, `storage`, `memory`); every project must
|
|
12
|
+
* pass one. Also mounts the shared login and share UIs so `auth.login()`
|
|
13
|
+
* and `share.compose()` work anywhere in the tree.
|
|
12
14
|
*/
|
|
13
15
|
export declare function EazoProvider(props: {
|
|
14
16
|
children: React.ReactNode;
|
|
17
|
+
/** Eazo app ID. Required. */
|
|
18
|
+
appId: string;
|
|
15
19
|
}): React.ReactElement;
|
|
16
20
|
/**
|
|
17
|
-
* Subscribe to a slice of
|
|
18
|
-
*
|
|
21
|
+
* Subscribe to a slice of state. Re-renders only when the selector's
|
|
22
|
+
* return value changes (Object.is).
|
|
19
23
|
*
|
|
20
24
|
* const user = useEazo(s => s.auth.user);
|
|
21
25
|
* const { platform, locale } = useEazo(s => s.device);
|
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;AAU/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIzC;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,KAAK,CAAC,YAAY,CAuBrB;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,CAkB/D"}
|