@alien_org/react 0.2.3 → 0.2.4

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/dist/index.cjs CHANGED
@@ -6,6 +6,17 @@ let react_jsx_runtime = require("react/jsx-runtime");
6
6
  //#region src/context.tsx
7
7
  const useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
8
8
  const AlienContext = (0, react.createContext)(null);
9
+ const SAFE_AREA_EDGES = [
10
+ "top",
11
+ "right",
12
+ "bottom",
13
+ "left"
14
+ ];
15
+ function setSafeAreaCssVars(insets) {
16
+ if (typeof document === "undefined") return;
17
+ const root = document.documentElement;
18
+ for (const edge of SAFE_AREA_EDGES) root.style.setProperty(`--alien-safe-area-inset-${edge}`, `${insets?.[edge] ?? 0}px`);
19
+ }
9
20
  /**
10
21
  * Provider component that initializes the Alien miniapp context.
11
22
  * Must wrap your app to use Alien hooks.
@@ -45,6 +56,7 @@ function AlienProvider({ children, autoReady = true, interceptLinks = true }) {
45
56
  isBridgeAvailable: bridgeAvailable,
46
57
  ready
47
58
  });
59
+ setSafeAreaCssVars(launchParams?.safeAreaInsets);
48
60
  if (!bridgeAvailable) console.warn("[@alien_org/react] Bridge is not available. Running in dev mode? The SDK will handle errors gracefully, but bridge communication will not work.");
49
61
  }, [ready]);
50
62
  (0, react.useEffect)(() => {
package/dist/index.d.cts CHANGED
@@ -178,6 +178,16 @@ declare const PLATFORMS: readonly ["ios", "android"];
178
178
  * Platform the miniapp is running on.
179
179
  */
180
180
  type Platform = (typeof PLATFORMS)[number];
181
+ /**
182
+ * Safe area insets in CSS pixels, injected by the host app.
183
+ * Accounts for system UI (status bar, notch, home indicator, nav bar).
184
+ */
185
+ interface SafeAreaInsets {
186
+ top: number;
187
+ right: number;
188
+ bottom: number;
189
+ left: number;
190
+ }
181
191
  /**
182
192
  * Launch parameters injected by the host app.
183
193
  */
@@ -190,6 +200,8 @@ interface LaunchParams {
190
200
  hostAppVersion: string | undefined;
191
201
  /** Platform the miniapp is running on */
192
202
  platform: Platform | undefined;
203
+ /** Safe area insets for the webview in CSS pixels */
204
+ safeAreaInsets: SafeAreaInsets | undefined;
193
205
  /**
194
206
  * Custom start parameter injected by host app.
195
207
  * Used for referral codes, campaign tracking, or custom routing.
@@ -470,6 +482,7 @@ declare global {
470
482
  __ALIEN_CONTRACT_VERSION__?: string;
471
483
  __ALIEN_HOST_VERSION__?: string;
472
484
  __ALIEN_PLATFORM__?: string;
485
+ __ALIEN_SAFE_AREA_INSETS__?: SafeAreaInsets;
473
486
  __ALIEN_START_PARAM__?: string;
474
487
  }
475
488
  }
package/dist/index.d.mts CHANGED
@@ -178,6 +178,16 @@ declare const PLATFORMS: readonly ["ios", "android"];
178
178
  * Platform the miniapp is running on.
179
179
  */
180
180
  type Platform = (typeof PLATFORMS)[number];
181
+ /**
182
+ * Safe area insets in CSS pixels, injected by the host app.
183
+ * Accounts for system UI (status bar, notch, home indicator, nav bar).
184
+ */
185
+ interface SafeAreaInsets {
186
+ top: number;
187
+ right: number;
188
+ bottom: number;
189
+ left: number;
190
+ }
181
191
  /**
182
192
  * Launch parameters injected by the host app.
183
193
  */
@@ -190,6 +200,8 @@ interface LaunchParams {
190
200
  hostAppVersion: string | undefined;
191
201
  /** Platform the miniapp is running on */
192
202
  platform: Platform | undefined;
203
+ /** Safe area insets for the webview in CSS pixels */
204
+ safeAreaInsets: SafeAreaInsets | undefined;
193
205
  /**
194
206
  * Custom start parameter injected by host app.
195
207
  * Used for referral codes, campaign tracking, or custom routing.
@@ -470,6 +482,7 @@ declare global {
470
482
  __ALIEN_CONTRACT_VERSION__?: string;
471
483
  __ALIEN_HOST_VERSION__?: string;
472
484
  __ALIEN_PLATFORM__?: string;
485
+ __ALIEN_SAFE_AREA_INSETS__?: SafeAreaInsets;
473
486
  __ALIEN_START_PARAM__?: string;
474
487
  }
475
488
  }
package/dist/index.mjs CHANGED
@@ -6,6 +6,17 @@ import { jsx } from "react/jsx-runtime";
6
6
  //#region src/context.tsx
7
7
  const useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? useLayoutEffect : useEffect;
8
8
  const AlienContext = createContext(null);
9
+ const SAFE_AREA_EDGES = [
10
+ "top",
11
+ "right",
12
+ "bottom",
13
+ "left"
14
+ ];
15
+ function setSafeAreaCssVars(insets) {
16
+ if (typeof document === "undefined") return;
17
+ const root = document.documentElement;
18
+ for (const edge of SAFE_AREA_EDGES) root.style.setProperty(`--alien-safe-area-inset-${edge}`, `${insets?.[edge] ?? 0}px`);
19
+ }
9
20
  /**
10
21
  * Provider component that initializes the Alien miniapp context.
11
22
  * Must wrap your app to use Alien hooks.
@@ -45,6 +56,7 @@ function AlienProvider({ children, autoReady = true, interceptLinks = true }) {
45
56
  isBridgeAvailable: bridgeAvailable,
46
57
  ready
47
58
  });
59
+ setSafeAreaCssVars(launchParams?.safeAreaInsets);
48
60
  if (!bridgeAvailable) console.warn("[@alien_org/react] Bridge is not available. Running in dev mode? The SDK will handle errors gracefully, but bridge communication will not work.");
49
61
  }, [ready]);
50
62
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alien_org/react",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -34,8 +34,8 @@
34
34
  "prepublishOnly": "bun run build"
35
35
  },
36
36
  "dependencies": {
37
- "@alien_org/bridge": "0.2.2",
38
- "@alien_org/contract": "0.2.1"
37
+ "@alien_org/bridge": "0.2.3",
38
+ "@alien_org/contract": "0.2.2"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "^18 || ^19",