@alepha/react 0.9.2 → 0.9.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/README.md +46 -0
- package/dist/index.browser.js +378 -325
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +570 -458
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +305 -213
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +304 -212
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +567 -460
- package/dist/index.js.map +1 -1
- package/package.json +16 -13
- package/src/components/ErrorViewer.tsx +1 -1
- package/src/components/Link.tsx +4 -24
- package/src/components/NestedView.tsx +20 -9
- package/src/components/NotFound.tsx +5 -2
- package/src/descriptors/$page.ts +86 -12
- package/src/errors/Redirection.ts +13 -0
- package/src/hooks/useActive.ts +28 -30
- package/src/hooks/useAlepha.ts +16 -2
- package/src/hooks/useClient.ts +7 -2
- package/src/hooks/useInject.ts +4 -1
- package/src/hooks/useQueryParams.ts +9 -6
- package/src/hooks/useRouter.ts +18 -30
- package/src/hooks/useRouterEvents.ts +7 -4
- package/src/hooks/useRouterState.ts +8 -20
- package/src/hooks/useSchema.ts +10 -15
- package/src/hooks/useStore.ts +9 -8
- package/src/index.browser.ts +11 -11
- package/src/index.shared.ts +4 -5
- package/src/index.ts +21 -30
- package/src/providers/ReactBrowserProvider.ts +155 -65
- package/src/providers/ReactBrowserRouterProvider.ts +132 -0
- package/src/providers/{PageDescriptorProvider.ts → ReactPageProvider.ts} +164 -112
- package/src/providers/ReactServerProvider.ts +100 -68
- package/src/{hooks/RouterHookApi.ts → services/ReactRouter.ts} +75 -61
- package/src/contexts/RouterContext.ts +0 -14
- package/src/errors/RedirectionError.ts +0 -10
- package/src/providers/BrowserRouterProvider.ts +0 -146
- package/src/providers/ReactBrowserRenderer.ts +0 -93
package/README.md
CHANGED
|
@@ -34,6 +34,52 @@ Main descriptor for defining a React route in the application.
|
|
|
34
34
|
|
|
35
35
|
### Hooks
|
|
36
36
|
|
|
37
|
+
#### useAlepha()
|
|
38
|
+
|
|
39
|
+
Main Alepha hook.
|
|
40
|
+
|
|
41
|
+
It provides access to the Alepha instance within a React component.
|
|
42
|
+
|
|
43
|
+
With Alepha, you can access the core functionalities of the framework:
|
|
44
|
+
|
|
45
|
+
- alepha.state() for state management
|
|
46
|
+
- alepha.inject() for dependency injection
|
|
47
|
+
- alepha.emit() for event handling
|
|
48
|
+
etc...
|
|
49
|
+
|
|
50
|
+
#### useClient()
|
|
51
|
+
|
|
52
|
+
Hook to get a virtual client for the specified scope.
|
|
53
|
+
|
|
54
|
+
It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
|
|
55
|
+
|
|
56
|
+
#### useInject()
|
|
57
|
+
|
|
58
|
+
Hook to inject a service instance.
|
|
59
|
+
It's a wrapper of `useAlepha().inject(service)` with a memoization.
|
|
60
|
+
|
|
61
|
+
#### useQueryParams()
|
|
62
|
+
|
|
63
|
+
Not well tested. Use with caution.
|
|
64
|
+
|
|
65
|
+
#### useRouter()
|
|
66
|
+
|
|
67
|
+
Use this hook to access the React Router instance.
|
|
68
|
+
|
|
69
|
+
You can add a type parameter to specify the type of your application.
|
|
70
|
+
This will allow you to use the router in a typesafe way.
|
|
71
|
+
|
|
72
|
+
class App {
|
|
73
|
+
home = $page();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const router = useRouter<App>();
|
|
77
|
+
router.go("home"); // typesafe
|
|
78
|
+
|
|
79
|
+
#### useRouterEvents()
|
|
80
|
+
|
|
81
|
+
Subscribe to various router events.
|
|
82
|
+
|
|
37
83
|
#### useStore()
|
|
38
84
|
|
|
39
85
|
Hook to access and mutate the Alepha state.
|