@granite-js/react-native 3.0.9 → 3.1.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/CHANGELOG.md +13 -0
- package/dist/app/Granite.d.ts +6 -0
- package/package.json +11 -11
- package/src/app/Granite.spec.tsx +22 -0
- package/src/app/Granite.tsx +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @granite-js/react-native
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @granite-js/blur-view@3.1.0
|
|
8
|
+
- @granite-js/brownfield-module@3.1.0
|
|
9
|
+
- @granite-js/cli@3.1.0
|
|
10
|
+
- @granite-js/config@3.1.0
|
|
11
|
+
- @granite-js/jest@3.1.0
|
|
12
|
+
- @granite-js/mpack@3.1.0
|
|
13
|
+
- @granite-js/style-utils@3.1.0
|
|
14
|
+
- @granite-js/video@3.1.0
|
|
15
|
+
|
|
3
16
|
## 3.0.9
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/app/Granite.d.ts
CHANGED
|
@@ -65,6 +65,12 @@ export interface GraniteProps {
|
|
|
65
65
|
* - Back Navigation Control: You can control back navigation events. For example, when a user presses back on a screen, you can show a dialog or close the screen.
|
|
66
66
|
* - Screen Visibility: You can determine whether a screen is visible or hidden from the user. For example, you can use this value to handle specific actions when a user leaves for the home screen.
|
|
67
67
|
*
|
|
68
|
+
* Calling `registerApp` again with an `appName` that is already registered (for example, when a shared runtime
|
|
69
|
+
* evaluates the same service bundle once more) keeps the first `AppRegistry` registration, because `AppRegistry` holds
|
|
70
|
+
* one component per app key, and returns a new app component that renders the container passed to this call. A host
|
|
71
|
+
* that renders the returned component directly (such as a micro-frontend host) therefore renders each evaluation's
|
|
72
|
+
* own app.
|
|
73
|
+
*
|
|
68
74
|
* @example
|
|
69
75
|
*
|
|
70
76
|
* ### Example of creating with the `Granite` component
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/react-native",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "The Granite Framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"granite": "./bin/cli.mjs"
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"@babel/core": "7.28.5",
|
|
92
92
|
"@babel/preset-env": "7.28.5",
|
|
93
93
|
"@babel/preset-typescript": "7.28.5",
|
|
94
|
-
"@granite-js/native": "3.0
|
|
95
|
-
"@granite-js/vitest": "3.0
|
|
94
|
+
"@granite-js/native": "3.1.0",
|
|
95
|
+
"@granite-js/vitest": "3.1.0",
|
|
96
96
|
"@testing-library/dom": "^10.4.0",
|
|
97
97
|
"@testing-library/react": "^16.1.0",
|
|
98
98
|
"@types/babel__core": "^7",
|
|
@@ -121,14 +121,14 @@
|
|
|
121
121
|
"react-native": "*"
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"@granite-js/blur-view": "3.0
|
|
125
|
-
"@granite-js/brownfield-module": "3.0
|
|
126
|
-
"@granite-js/cli": "3.0
|
|
127
|
-
"@granite-js/config": "3.0
|
|
128
|
-
"@granite-js/jest": "3.0
|
|
129
|
-
"@granite-js/mpack": "3.0
|
|
130
|
-
"@granite-js/style-utils": "3.0
|
|
131
|
-
"@granite-js/video": "3.0
|
|
124
|
+
"@granite-js/blur-view": "3.1.0",
|
|
125
|
+
"@granite-js/brownfield-module": "3.1.0",
|
|
126
|
+
"@granite-js/cli": "3.1.0",
|
|
127
|
+
"@granite-js/config": "3.1.0",
|
|
128
|
+
"@granite-js/jest": "3.1.0",
|
|
129
|
+
"@granite-js/mpack": "3.1.0",
|
|
130
|
+
"@granite-js/style-utils": "3.1.0",
|
|
131
|
+
"@granite-js/video": "3.1.0",
|
|
132
132
|
"@standard-schema/spec": "^1.0.0",
|
|
133
133
|
"es-toolkit": "^1.39.8",
|
|
134
134
|
"react-native-url-polyfill": "3.0.0"
|
package/src/app/Granite.spec.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { render } from '@testing-library/react';
|
|
2
2
|
import type { PropsWithChildren } from 'react';
|
|
3
|
+
import { AppRegistry } from 'react-native';
|
|
3
4
|
import { describe, expect, it, vi } from 'vitest';
|
|
4
5
|
import type { InitialProps } from '../initial-props';
|
|
5
6
|
import type { RequireContext } from '../router';
|
|
@@ -70,4 +71,25 @@ describe('Granite.registerApp', () => {
|
|
|
70
71
|
// Then
|
|
71
72
|
expect(visibilityState.value).toBe(false);
|
|
72
73
|
});
|
|
74
|
+
|
|
75
|
+
it('keeps the first AppRegistry registration and returns each call its own app for an app name registered again', () => {
|
|
76
|
+
// Given
|
|
77
|
+
const registerComponent = vi.spyOn(AppRegistry, 'registerComponent');
|
|
78
|
+
function containerOf() {
|
|
79
|
+
return function AppContainer({ children }: PropsWithChildren<InitialProps>) {
|
|
80
|
+
return children;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const appName = 'registered-twice-test';
|
|
84
|
+
|
|
85
|
+
// When
|
|
86
|
+
const First = Granite.registerApp(containerOf(), { appName, context });
|
|
87
|
+
const Second = Granite.registerApp(containerOf(), { appName, context });
|
|
88
|
+
|
|
89
|
+
// Then
|
|
90
|
+
expect(registerComponent.mock.calls.filter(([key]) => key === appName)).toHaveLength(1);
|
|
91
|
+
expect(Second).not.toBe(First);
|
|
92
|
+
expect(AppRegistry.getAppKeys()).toContain(appName);
|
|
93
|
+
registerComponent.mockRestore();
|
|
94
|
+
});
|
|
73
95
|
});
|
package/src/app/Granite.tsx
CHANGED
|
@@ -71,7 +71,8 @@ const createApp = () => {
|
|
|
71
71
|
|
|
72
72
|
function registerComponent(appKey: string, component: React.ComponentType<any>): string {
|
|
73
73
|
if (AppRegistry.getAppKeys().includes(appKey)) {
|
|
74
|
-
//
|
|
74
|
+
// The first registration of an app key stays: AppRegistry holds one component per key. The caller still returns
|
|
75
|
+
// its own component (see `registerApp`). `AppRegistry.registerComponent` returns the app key.
|
|
75
76
|
return appKey;
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -163,6 +164,12 @@ const createApp = () => {
|
|
|
163
164
|
* - Back Navigation Control: You can control back navigation events. For example, when a user presses back on a screen, you can show a dialog or close the screen.
|
|
164
165
|
* - Screen Visibility: You can determine whether a screen is visible or hidden from the user. For example, you can use this value to handle specific actions when a user leaves for the home screen.
|
|
165
166
|
*
|
|
167
|
+
* Calling `registerApp` again with an `appName` that is already registered (for example, when a shared runtime
|
|
168
|
+
* evaluates the same service bundle once more) keeps the first `AppRegistry` registration, because `AppRegistry` holds
|
|
169
|
+
* one component per app key, and returns a new app component that renders the container passed to this call. A host
|
|
170
|
+
* that renders the returned component directly (such as a micro-frontend host) therefore renders each evaluation's
|
|
171
|
+
* own app.
|
|
172
|
+
*
|
|
166
173
|
* @example
|
|
167
174
|
*
|
|
168
175
|
* ### Example of creating with the `Granite` component
|