@granite-js/react-native 0.1.23-next.5 → 0.1.23-next.7

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
@@ -1,5 +1,35 @@
1
1
  # @granite-js/react-native
2
2
 
3
+ ## 0.1.23-next.7
4
+
5
+ ### Patch Changes
6
+
7
+ - fix
8
+ - Updated dependencies
9
+ - @granite-js/plugin-core@0.1.23-next.7
10
+ - @granite-js/style-utils@0.1.23-next.7
11
+ - @granite-js/lottie@0.1.23-next.7
12
+ - @granite-js/native@0.1.23-next.7
13
+ - @granite-js/image@0.1.23-next.7
14
+ - @granite-js/mpack@0.1.23-next.7
15
+ - @granite-js/jest@0.1.23-next.7
16
+ - @granite-js/cli@0.1.23-next.7
17
+
18
+ ## 0.1.23-next.6
19
+
20
+ ### Patch Changes
21
+
22
+ - test
23
+ - Updated dependencies
24
+ - @granite-js/plugin-core@0.1.23-next.6
25
+ - @granite-js/style-utils@0.1.23-next.6
26
+ - @granite-js/lottie@0.1.23-next.6
27
+ - @granite-js/native@0.1.23-next.6
28
+ - @granite-js/image@0.1.23-next.6
29
+ - @granite-js/mpack@0.1.23-next.6
30
+ - @granite-js/jest@0.1.23-next.6
31
+ - @granite-js/cli@0.1.23-next.6
32
+
3
33
  ## 0.1.23-next.5
4
34
 
5
35
  ### Patch Changes
@@ -18,7 +18,7 @@
18
18
  * }
19
19
  * ```
20
20
  */
21
- declare function closeView(): Promise<void | undefined>;
21
+ declare function closeView(): Promise<void>;
22
22
 
23
23
  /**
24
24
  * @public
@@ -25,12 +25,9 @@ __export(async_bridges_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(async_bridges_exports);
27
27
 
28
- // src/native-modules/natives/GraniteModule.ts
29
- var import_react_native = require("react-native");
30
- var GraniteModule = import_react_native.TurboModuleRegistry.get("GraniteModule");
31
- if (!GraniteModule) {
32
- console.warn("[GraniteModule] is not registered");
33
- }
28
+ // src/native-modules/natives/GraniteModule.brick.ts
29
+ var import_brick_module = require("brick-module");
30
+ var GraniteModule = import_brick_module.BrickModule.get("GraniteModule");
34
31
 
35
32
  // src/native-modules/natives/closeView.ts
36
33
  async function closeView() {
@@ -38,9 +35,9 @@ async function closeView() {
38
35
  }
39
36
 
40
37
  // src/native-modules/natives/openURL.ts
41
- var import_react_native2 = require("react-native");
38
+ var import_react_native = require("react-native");
42
39
  function openURL(url) {
43
- return import_react_native2.Linking.openURL(url);
40
+ return import_react_native.Linking.openURL(url);
44
41
  }
45
42
  // Annotate the CommonJS export names for ESM import in node:
46
43
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  GraniteModule
3
- } from "./chunk-2PYPIQMA.mjs";
3
+ } from "./chunk-OWDLSIVX.mjs";
4
4
 
5
5
  // src/native-modules/natives/closeView.ts
6
6
  async function closeView() {
@@ -0,0 +1,7 @@
1
+ // src/native-modules/natives/GraniteModule.brick.ts
2
+ import { BrickModule } from "brick-module";
3
+ var GraniteModule = BrickModule.get("GraniteModule");
4
+
5
+ export {
6
+ GraniteModule
7
+ };
@@ -24,16 +24,13 @@ __export(constant_bridges_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(constant_bridges_exports);
26
26
 
27
- // src/native-modules/natives/GraniteModule.ts
28
- var import_react_native = require("react-native");
29
- var GraniteModule = import_react_native.TurboModuleRegistry.get("GraniteModule");
30
- if (!GraniteModule) {
31
- console.warn("[GraniteModule] is not registered");
32
- }
27
+ // src/native-modules/natives/GraniteModule.brick.ts
28
+ var import_brick_module = require("brick-module");
29
+ var GraniteModule = import_brick_module.BrickModule.get("GraniteModule");
33
30
 
34
31
  // src/native-modules/natives/getSchemeUri.ts
35
32
  function getSchemeUri() {
36
- return GraniteModule?.schemeUri ?? "unknown";
33
+ return GraniteModule.schemeUri;
37
34
  }
38
35
  // Annotate the CommonJS export names for ESM import in node:
39
36
  0 && (module.exports = {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  GraniteModule
3
- } from "./chunk-2PYPIQMA.mjs";
3
+ } from "./chunk-OWDLSIVX.mjs";
4
4
 
5
5
  // src/native-modules/natives/getSchemeUri.ts
6
6
  function getSchemeUri() {
7
- return GraniteModule?.schemeUri ?? "unknown";
7
+ return GraniteModule.schemeUri;
8
8
  }
9
9
  export {
10
10
  getSchemeUri
@@ -0,0 +1,10 @@
1
+ import { BrickModuleSpec } from 'brick-module';
2
+ interface GraniteModuleSpec extends BrickModuleSpec {
3
+ readonly moduleName: 'GraniteModule';
4
+ closeView(): Promise<void>;
5
+ schemeUri: string;
6
+ }
7
+ export declare const GraniteModule: GraniteModuleSpec & {
8
+ addEventListener<TEvent = unknown>(eventName: never, listener: (event: TEvent) => void): () => void;
9
+ };
10
+ export {};
@@ -18,4 +18,4 @@
18
18
  * }
19
19
  * ```
20
20
  */
21
- export declare function closeView(): Promise<void | undefined>;
21
+ export declare function closeView(): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
- export declare function CanGoBackGuard({ children, canGoBack, onBack, setIosSwipeGestureEnabled, }: {
2
+ export declare function CanGoBackGuard({ children, canGoBack, onBack, isInitialScreen, setIosSwipeGestureEnabled, }: {
3
3
  canGoBack: boolean;
4
+ isInitialScreen: boolean;
4
5
  children: ReactNode;
5
6
  onBack?: () => void;
6
7
  setIosSwipeGestureEnabled?: ({ isEnabled }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granite-js/react-native",
3
- "version": "0.1.23-next.5",
3
+ "version": "0.1.23-next.7",
4
4
  "description": "The Granite Framework",
5
5
  "bin": {
6
6
  "granite": "./bin/cli.js"
@@ -86,7 +86,7 @@
86
86
  "@babel/core": "^7.24.9",
87
87
  "@babel/preset-env": "^7.24.8",
88
88
  "@babel/preset-typescript": "^7.24.7",
89
- "@granite-js/native": "0.1.23-next.5",
89
+ "@granite-js/native": "0.1.23-next.7",
90
90
  "@testing-library/dom": "^10.4.0",
91
91
  "@testing-library/react": "^16.1.0",
92
92
  "@types/babel__core": "^7",
@@ -94,6 +94,7 @@
94
94
  "@types/node": "^22.10.2",
95
95
  "@types/react": "npm:19.1.0",
96
96
  "@vitest/coverage-v8": "^2.1.8",
97
+ "brick-module": "^0.1.12",
97
98
  "esbuild": "0.25.9",
98
99
  "eslint": "^9.7.0",
99
100
  "jsdom": "^25.0.1",
@@ -104,19 +105,20 @@
104
105
  "vitest": "^2.1.8"
105
106
  },
106
107
  "peerDependencies": {
107
- "@granite-js/native": "0.1.23-next.5",
108
+ "@granite-js/native": "0.1.23-next.7",
108
109
  "@types/react": "*",
110
+ "brick-module": "*",
109
111
  "react": "*",
110
112
  "react-native": "*"
111
113
  },
112
114
  "dependencies": {
113
- "@granite-js/cli": "0.1.23-next.5",
114
- "@granite-js/image": "0.1.23-next.5",
115
- "@granite-js/jest": "0.1.23-next.5",
116
- "@granite-js/lottie": "0.1.23-next.5",
117
- "@granite-js/mpack": "0.1.23-next.5",
118
- "@granite-js/plugin-core": "0.1.23-next.5",
119
- "@granite-js/style-utils": "0.1.23-next.5",
115
+ "@granite-js/cli": "0.1.23-next.7",
116
+ "@granite-js/image": "0.1.23-next.7",
117
+ "@granite-js/jest": "0.1.23-next.7",
118
+ "@granite-js/lottie": "0.1.23-next.7",
119
+ "@granite-js/mpack": "0.1.23-next.7",
120
+ "@granite-js/plugin-core": "0.1.23-next.7",
121
+ "@granite-js/style-utils": "0.1.23-next.7",
120
122
  "es-toolkit": "^1.39.8",
121
123
  "react-native-url-polyfill": "1.3.0"
122
124
  }
@@ -0,0 +1,10 @@
1
+ import { BrickModule, BrickModuleSpec } from 'brick-module';
2
+
3
+ interface GraniteModuleSpec extends BrickModuleSpec {
4
+ readonly moduleName: 'GraniteModule';
5
+
6
+ closeView(): Promise<void>;
7
+ schemeUri: string;
8
+ }
9
+
10
+ export const GraniteModule = BrickModule.get<GraniteModuleSpec>('GraniteModule');
@@ -1,4 +1,4 @@
1
- import { GraniteModule } from './GraniteModule';
1
+ import { GraniteModule } from './GraniteModule.brick';
2
2
 
3
3
  /**
4
4
  * @public
@@ -1,4 +1,4 @@
1
- import { GraniteModule } from './GraniteModule';
1
+ import { GraniteModule } from './GraniteModule.brick';
2
2
 
3
3
  /**
4
4
  * @public
@@ -23,5 +23,5 @@ import { GraniteModule } from './GraniteModule';
23
23
  * ```
24
24
  */
25
25
  export function getSchemeUri() {
26
- return GraniteModule?.schemeUri ?? 'unknown';
26
+ return GraniteModule.schemeUri;
27
27
  }
@@ -7,7 +7,7 @@ import {
7
7
  RouteProp,
8
8
  } from '@granite-js/native/@react-navigation/native';
9
9
  import { NativeStackNavigationOptions } from '@granite-js/native/@react-navigation/native-stack';
10
- import { ComponentProps, ComponentType, Fragment, PropsWithChildren, ReactElement, useCallback } from 'react';
10
+ import { ComponentProps, ComponentType, Fragment, PropsWithChildren, ReactElement, useCallback, useState } from 'react';
11
11
  import { InitialProps } from '..';
12
12
  import { closeView } from '../native-modules';
13
13
  import { BackButton } from './components/BackButton';
@@ -163,9 +163,23 @@ export function Router({
163
163
  [canGoBack, defaultScreenOption, headerLeft]
164
164
  );
165
165
 
166
+ const [isInitialScreen, setIsInitialScreen] = useState(true);
167
+
166
168
  return (
167
- <NavigationContainer ref={navigationRef} {...navigationContainerProps} linking={linkingOptions}>
168
- <CanGoBackGuard canGoBack={canGoBack} onBack={onBack} setIosSwipeGestureEnabled={setIosSwipeGestureEnabled}>
169
+ <NavigationContainer
170
+ onStateChange={(state) => {
171
+ setIsInitialScreen(state ? state?.index === 0 : true);
172
+ }}
173
+ ref={navigationRef}
174
+ {...navigationContainerProps}
175
+ linking={linkingOptions}
176
+ >
177
+ <CanGoBackGuard
178
+ canGoBack={canGoBack}
179
+ isInitialScreen={isInitialScreen}
180
+ onBack={onBack}
181
+ setIosSwipeGestureEnabled={setIosSwipeGestureEnabled}
182
+ >
169
183
  <Container {...initialProps}>
170
184
  <StackNavigator.Navigator initialRouteName={initialRouteName} screenOptions={screenOptions}>
171
185
  {Screens}
@@ -1,20 +1,19 @@
1
1
  import { ReactNode, useEffect } from 'react';
2
2
  import { BackHandler } from 'react-native';
3
- import { useIsInitialScreen } from '../hooks/useIsInitialScreen';
4
3
 
5
4
  export function CanGoBackGuard({
6
5
  children,
7
6
  canGoBack,
8
7
  onBack,
8
+ isInitialScreen,
9
9
  setIosSwipeGestureEnabled,
10
10
  }: {
11
11
  canGoBack: boolean;
12
+ isInitialScreen: boolean;
12
13
  children: ReactNode;
13
14
  onBack?: () => void;
14
15
  setIosSwipeGestureEnabled?: ({ isEnabled }: { isEnabled: boolean }) => void;
15
16
  }) {
16
- const isInitialScreen = useIsInitialScreen();
17
-
18
17
  const shouldBlockGoingBack = !canGoBack;
19
18
 
20
19
  useEffect(() => {
@@ -1,11 +0,0 @@
1
- import { TurboModule, TurboModuleRegistry } from 'react-native';
2
-
3
- interface GraniteModuleSpec extends TurboModule {
4
- closeView: () => void;
5
- schemeUri: string;
6
- }
7
-
8
- export const GraniteModule = TurboModuleRegistry.get<GraniteModuleSpec>('GraniteModule');
9
- if (!GraniteModule) {
10
- console.warn('[GraniteModule] is not registered');
11
- }