@alepha/react 0.9.3 → 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.
Files changed (37) hide show
  1. package/README.md +46 -0
  2. package/dist/index.browser.js +315 -320
  3. package/dist/index.browser.js.map +1 -1
  4. package/dist/index.cjs +496 -457
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +276 -258
  7. package/dist/index.d.cts.map +1 -1
  8. package/dist/index.d.ts +274 -256
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +494 -460
  11. package/dist/index.js.map +1 -1
  12. package/package.json +13 -10
  13. package/src/components/NestedView.tsx +15 -13
  14. package/src/components/NotFound.tsx +1 -1
  15. package/src/descriptors/$page.ts +16 -4
  16. package/src/errors/Redirection.ts +8 -5
  17. package/src/hooks/useActive.ts +25 -34
  18. package/src/hooks/useAlepha.ts +16 -2
  19. package/src/hooks/useClient.ts +7 -4
  20. package/src/hooks/useInject.ts +4 -1
  21. package/src/hooks/useQueryParams.ts +9 -6
  22. package/src/hooks/useRouter.ts +18 -31
  23. package/src/hooks/useRouterEvents.ts +7 -7
  24. package/src/hooks/useRouterState.ts +8 -20
  25. package/src/hooks/useSchema.ts +10 -15
  26. package/src/hooks/useStore.ts +0 -7
  27. package/src/index.browser.ts +11 -11
  28. package/src/index.shared.ts +2 -3
  29. package/src/index.ts +21 -30
  30. package/src/providers/ReactBrowserProvider.ts +149 -65
  31. package/src/providers/ReactBrowserRouterProvider.ts +132 -0
  32. package/src/providers/{PageDescriptorProvider.ts → ReactPageProvider.ts} +84 -112
  33. package/src/providers/ReactServerProvider.ts +69 -74
  34. package/src/{hooks/RouterHookApi.ts → services/ReactRouter.ts} +44 -54
  35. package/src/contexts/RouterContext.ts +0 -14
  36. package/src/providers/BrowserRouterProvider.ts +0 -155
  37. 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.