@celljs/react 4.5.1 → 4.6.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.
Files changed (161) hide show
  1. package/README.md +33 -3
  2. package/esm/browser/app/app.d.ts +1 -1
  3. package/esm/browser/error/error-boundary.d.ts +32 -0
  4. package/esm/browser/error/error-boundary.js +38 -0
  5. package/esm/browser/error/error-boundary.js.map +1 -0
  6. package/esm/browser/error/index.d.ts +1 -0
  7. package/esm/browser/error/index.js +2 -0
  8. package/esm/browser/error/index.js.map +1 -0
  9. package/esm/browser/hooks/container-hooks.d.ts +1 -1
  10. package/esm/browser/hooks/container-hooks.js +5 -10
  11. package/esm/browser/hooks/container-hooks.js.map +1 -1
  12. package/esm/browser/hooks/index.d.ts +1 -0
  13. package/esm/browser/hooks/index.js +1 -0
  14. package/esm/browser/hooks/index.js.map +1 -1
  15. package/esm/browser/hooks/rpc-hooks.d.ts +6 -0
  16. package/esm/browser/hooks/rpc-hooks.js +19 -0
  17. package/esm/browser/hooks/rpc-hooks.js.map +1 -0
  18. package/esm/browser/icon/icon.d.ts +2 -1
  19. package/esm/browser/icon/icon.js +7 -6
  20. package/esm/browser/icon/icon.js.map +1 -1
  21. package/esm/browser/index.d.ts +1 -0
  22. package/esm/browser/index.js +1 -0
  23. package/esm/browser/index.js.map +1 -1
  24. package/esm/browser/intl/index.d.ts +1 -0
  25. package/esm/browser/intl/index.js +2 -0
  26. package/esm/browser/intl/index.js.map +1 -0
  27. package/esm/browser/intl/intl-context.d.ts +13 -0
  28. package/esm/browser/{locale/locale-context.js → intl/intl-context.js} +12 -12
  29. package/esm/browser/intl/intl-context.js.map +1 -0
  30. package/esm/browser/layout/layout.d.ts +1 -1
  31. package/esm/browser/locale/index.d.ts +1 -2
  32. package/esm/browser/locale/index.js +1 -2
  33. package/esm/browser/locale/index.js.map +1 -1
  34. package/esm/browser/locale/locale-hooks.d.ts +3 -0
  35. package/esm/browser/locale/locale-hooks.js +15 -0
  36. package/esm/browser/locale/locale-hooks.js.map +1 -0
  37. package/esm/browser/router/file-route-util.js +10 -0
  38. package/esm/browser/router/file-route-util.js.map +1 -1
  39. package/esm/browser/router/router-protocol.d.ts +10 -0
  40. package/esm/browser/router/router-protocol.js.map +1 -1
  41. package/esm/browser/router/router.d.ts +6 -0
  42. package/esm/browser/router/router.js +10 -5
  43. package/esm/browser/router/router.js.map +1 -1
  44. package/esm/browser/shell/shell.d.ts +6 -3
  45. package/esm/browser/shell/shell.js +12 -6
  46. package/esm/browser/shell/shell.js.map +1 -1
  47. package/esm/browser/slot/slot.d.ts +2 -1
  48. package/lib/browser/app/app.d.ts +1 -1
  49. package/lib/browser/app/app.d.ts.map +1 -1
  50. package/lib/browser/error/error-boundary.d.ts +33 -0
  51. package/lib/browser/error/error-boundary.d.ts.map +1 -0
  52. package/lib/browser/error/error-boundary.js +76 -0
  53. package/lib/browser/error/error-boundary.js.map +1 -0
  54. package/lib/browser/error/error-boundary.spec.d.ts +2 -0
  55. package/lib/browser/error/error-boundary.spec.d.ts.map +1 -0
  56. package/lib/browser/error/error-boundary.spec.js +82 -0
  57. package/lib/browser/error/error-boundary.spec.js.map +1 -0
  58. package/lib/browser/error/index.d.ts +2 -0
  59. package/lib/browser/error/index.d.ts.map +1 -0
  60. package/lib/browser/error/index.js +18 -0
  61. package/lib/browser/error/index.js.map +1 -0
  62. package/lib/browser/hooks/container-hooks.d.ts +1 -1
  63. package/lib/browser/hooks/container-hooks.d.ts.map +1 -1
  64. package/lib/browser/hooks/container-hooks.js +4 -9
  65. package/lib/browser/hooks/container-hooks.js.map +1 -1
  66. package/lib/browser/hooks/container-hooks.spec.d.ts.map +1 -1
  67. package/lib/browser/hooks/container-hooks.spec.js +65 -7
  68. package/lib/browser/hooks/container-hooks.spec.js.map +1 -1
  69. package/lib/browser/hooks/index.d.ts +1 -0
  70. package/lib/browser/hooks/index.d.ts.map +1 -1
  71. package/lib/browser/hooks/index.js +1 -0
  72. package/lib/browser/hooks/index.js.map +1 -1
  73. package/lib/browser/hooks/rpc-hooks.d.ts +7 -0
  74. package/lib/browser/hooks/rpc-hooks.d.ts.map +1 -0
  75. package/lib/browser/hooks/rpc-hooks.js +55 -0
  76. package/lib/browser/hooks/rpc-hooks.js.map +1 -0
  77. package/lib/browser/icon/icon.d.ts +2 -1
  78. package/lib/browser/icon/icon.d.ts.map +1 -1
  79. package/lib/browser/icon/icon.js +7 -6
  80. package/lib/browser/icon/icon.js.map +1 -1
  81. package/lib/browser/index.d.ts +1 -0
  82. package/lib/browser/index.d.ts.map +1 -1
  83. package/lib/browser/index.js +1 -0
  84. package/lib/browser/index.js.map +1 -1
  85. package/lib/browser/intl/index.d.ts +2 -0
  86. package/lib/browser/intl/index.d.ts.map +1 -0
  87. package/lib/browser/intl/index.js +18 -0
  88. package/lib/browser/intl/index.js.map +1 -0
  89. package/lib/browser/intl/intl-context.d.ts +14 -0
  90. package/lib/browser/intl/intl-context.d.ts.map +1 -0
  91. package/lib/browser/{locale/locale-context.js → intl/intl-context.js} +14 -13
  92. package/lib/browser/intl/intl-context.js.map +1 -0
  93. package/lib/browser/layout/layout.d.ts +1 -1
  94. package/lib/browser/layout/layout.d.ts.map +1 -1
  95. package/lib/browser/locale/index.d.ts +1 -2
  96. package/lib/browser/locale/index.d.ts.map +1 -1
  97. package/lib/browser/locale/index.js +1 -2
  98. package/lib/browser/locale/index.js.map +1 -1
  99. package/lib/browser/locale/locale-hooks.d.ts +4 -0
  100. package/lib/browser/locale/locale-hooks.d.ts.map +1 -0
  101. package/lib/browser/locale/locale-hooks.js +51 -0
  102. package/lib/browser/locale/locale-hooks.js.map +1 -0
  103. package/lib/browser/router/file-route-util.d.ts.map +1 -1
  104. package/lib/browser/router/file-route-util.js +10 -0
  105. package/lib/browser/router/file-route-util.js.map +1 -1
  106. package/lib/browser/router/file-route-util.spec.js +18 -6
  107. package/lib/browser/router/file-route-util.spec.js.map +1 -1
  108. package/lib/browser/router/router-protocol.d.ts +10 -0
  109. package/lib/browser/router/router-protocol.d.ts.map +1 -1
  110. package/lib/browser/router/router-protocol.js.map +1 -1
  111. package/lib/browser/router/router.d.ts +6 -0
  112. package/lib/browser/router/router.d.ts.map +1 -1
  113. package/lib/browser/router/router.js +10 -4
  114. package/lib/browser/router/router.js.map +1 -1
  115. package/lib/browser/router/router.spec.d.ts +1 -1
  116. package/lib/browser/router/router.spec.d.ts.map +1 -1
  117. package/lib/browser/router/router.spec.js +8 -5
  118. package/lib/browser/router/router.spec.js.map +1 -1
  119. package/lib/browser/shell/shell.d.ts +6 -3
  120. package/lib/browser/shell/shell.d.ts.map +1 -1
  121. package/lib/browser/shell/shell.js +11 -5
  122. package/lib/browser/shell/shell.js.map +1 -1
  123. package/lib/browser/slot/slot.d.ts +2 -1
  124. package/lib/browser/slot/slot.d.ts.map +1 -1
  125. package/lib/package.spec.js +25 -2
  126. package/lib/package.spec.js.map +1 -1
  127. package/package.json +24 -8
  128. package/src/browser/error/error-boundary.spec.tsx +49 -0
  129. package/src/browser/error/error-boundary.tsx +62 -0
  130. package/src/browser/error/index.ts +1 -0
  131. package/src/browser/hooks/container-hooks.spec.tsx +65 -9
  132. package/src/browser/hooks/container-hooks.ts +5 -9
  133. package/src/browser/hooks/index.ts +1 -0
  134. package/src/browser/hooks/rpc-hooks.ts +21 -0
  135. package/src/browser/icon/icon.tsx +7 -6
  136. package/src/browser/index.ts +2 -1
  137. package/src/browser/intl/index.ts +1 -0
  138. package/src/browser/intl/intl-context.tsx +31 -0
  139. package/src/browser/locale/index.ts +1 -2
  140. package/src/browser/locale/locale-hooks.ts +15 -0
  141. package/src/browser/router/file-route-util.spec.tsx +15 -4
  142. package/src/browser/router/file-route-util.ts +12 -0
  143. package/src/browser/router/router-protocol.ts +6 -0
  144. package/src/browser/router/router.spec.tsx +10 -8
  145. package/src/browser/router/router.tsx +13 -6
  146. package/src/browser/shell/shell.tsx +16 -6
  147. package/src/package.spec.ts +22 -3
  148. package/esm/browser/locale/locale-context.d.ts +0 -8
  149. package/esm/browser/locale/locale-context.js.map +0 -1
  150. package/esm/browser/locale/locale-protocol.d.ts +0 -1
  151. package/esm/browser/locale/locale-protocol.js +0 -2
  152. package/esm/browser/locale/locale-protocol.js.map +0 -1
  153. package/lib/browser/locale/locale-context.d.ts +0 -9
  154. package/lib/browser/locale/locale-context.d.ts.map +0 -1
  155. package/lib/browser/locale/locale-context.js.map +0 -1
  156. package/lib/browser/locale/locale-protocol.d.ts +0 -2
  157. package/lib/browser/locale/locale-protocol.d.ts.map +0 -1
  158. package/lib/browser/locale/locale-protocol.js +0 -5
  159. package/lib/browser/locale/locale-protocol.js.map +0 -1
  160. package/src/browser/locale/locale-context.tsx +0 -31
  161. package/src/browser/locale/locale-protocol.ts +0 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ The `fullstack` template of `cell init` is set up with it. `cell dev` serves the
11
11
 
12
12
  ## Pages
13
13
 
14
- Pages are the files of `src/browser/pages/`, each with the page component as default export: `index.tsx` is `/`, `about.tsx` is `/about`, `users/[id].tsx` is `/users/:id`, `[...rest].tsx` matches the rest of the path, and `_layout.tsx` wraps the pages of its directory and below. Names starting with `_` and tests are not pages. The toolchain (`cell dev`, `cell build`) generates the routes (`.cell/generated/frontend/routes.js`, listed by `cell info --json`); each page is a chunk loaded when it is visited. Guide: [Frontend and RPC](https://cell.cellbang.com/guide/frontend).
14
+ Pages are the files of `src/browser/pages/`, each with the page component as default export: `index.tsx` is `/`, `about.tsx` is `/about`, `users/[id].tsx` is `/users/:id`, `[...rest].tsx` matches the rest of the path, `_layout.tsx` wraps the pages of its directory and below, and `_error.tsx` shows when one of them fails. Names starting with `_` and tests are not pages. The toolchain (`cell dev`, `cell build`) generates the routes (`.cell/generated/frontend/routes.js`, listed by `cell info --json`); each page is a chunk loaded when it is visited. Guide: [Frontend and RPC](https://cell.cellbang.com/guide/frontend).
15
15
 
16
16
  ```tsx
17
17
  // src/browser/pages/users/[id].tsx
@@ -36,6 +36,21 @@ Packages, which have no pages directory, add pages and replace parts of the fron
36
36
 
37
37
  Paths are resolved against `react.path` (default `server.path`, `/`).
38
38
 
39
+ ## Errors
40
+
41
+ A page that throws while rendering, or whose code does not load, does not blank the application: an `ErrorBoundary` inside its layout shows the fallback instead, and the page is tried again when the user goes to another path. The fallback is the default export of the nearest `_error.tsx` (in the directory of the page or above), which gets `{ error, reset }` (`ErrorFallbackProps`); without one, `DefaultErrorFallback` shows the message and a button to try again. The shell puts another boundary around the whole application, for errors of layouts and of the fallbacks themselves. React logs the errors to the console.
42
+
43
+ ```tsx
44
+ // src/browser/pages/_error.tsx
45
+ import type { ErrorFallbackProps } from '@celljs/react';
46
+
47
+ export default function PageError({ error, reset }: ErrorFallbackProps) {
48
+ return <p>Could not show this page ({String(error)}). <button onClick={reset}>Retry</button></p>;
49
+ }
50
+ ```
51
+
52
+ `ErrorBoundary` (`fallback`, `resetKey`) is exported for parts of a page.
53
+
39
54
  ## Services in components
40
55
 
41
56
  | Hook | |
@@ -43,8 +58,10 @@ Paths are resolved against `react.path` (default `server.path`, `/`).
43
58
  | `useInject<T>(id)` | A component of the container, resolved once per component instance |
44
59
  | `useValue<T>(key, default?)` | A configuration value, like `@Value(key)` (the frontend only has public keys) |
45
60
  | `useContainer()` | The container itself |
61
+ | `useRpc<T>(id)` | The proxy of a backend service (needs [`@celljs/rpc`](../../packages/rpc)), like `@Autorpc(id)` |
62
+ | `useLocale()` | `[locale, setLocale]`: the locale of `widget.locales` the user selected, and how to change it |
46
63
 
47
- They use the container of `ContainerContext`, which the shell provides; outside of it (a component rendered in its own root), the application's container. In a test, render the component inside `<ContainerContext.Provider value={container}>`; `reactTestModule` (`@celljs/react/lib/browser/test/test-module`) has the components of this package without the shell, which needs a DOM.
64
+ They use the container of `ContainerContext`, which the shell provides; there is no global container, so a component rendered outside the application fails with a message saying so. In a test, render the component inside `<ContainerContext.Provider value={container}>`; `reactTestModule` (`@celljs/react/lib/browser/test/test-module`) has the components of this package without the shell, which needs a DOM.
48
65
 
49
66
  ```tsx
50
67
  function Header() {
@@ -70,4 +87,17 @@ Frontend configuration is evaluated at build time and is visible to anyone who l
70
87
 
71
88
  ## Calling the backend
72
89
 
73
- Use [`@celljs/rpc`](../../packages/rpc): `RpcUtil.get<T>(Id)` returns a typed proxy of a backend service. For other HTTP APIs, use `fetch` or `RestOperations` from [`@celljs/http`](../../packages/http).
90
+ `useRpc<T>(Id)` returns a typed proxy of a backend service of [`@celljs/rpc`](../../packages/rpc); its methods return promises, so call them in an effect or an event handler. For other HTTP APIs, use `fetch` or `RestOperations` from [`@celljs/http`](../../packages/http).
91
+
92
+ ```tsx
93
+ function Greeting() {
94
+ const greetingServer = useRpc<GreetingServer>(GreetingServer);
95
+ const [text, setText] = React.useState('');
96
+ React.useEffect(() => { greetingServer.greet('web').then(setText); }, [greetingServer]);
97
+ return <p>{text}</p>;
98
+ }
99
+ ```
100
+
101
+ ## Translations with react-intl
102
+
103
+ react-intl is optional. To use it, install it and import `@celljs/react/lib/browser/intl` once in `src/browser/module.ts`: its `IntlContext` puts an `IntlProvider` with the messages of the selected locale around the application, so `useIntl()` and `<FormattedMessage>` work in every component.
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
2
  /** The root component: the router inside the `@Context` providers. */
3
- export declare function AppImpl(): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
3
+ export declare function AppImpl(): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
4
4
  export default class {
5
5
  }
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ export interface ErrorFallbackProps {
3
+ /** What the component threw, or why its code could not be loaded. */
4
+ error: unknown;
5
+ /** Renders the children again. */
6
+ reset(): void;
7
+ }
8
+ export interface ErrorBoundaryProps extends React.PropsWithChildren {
9
+ /** What shows instead of the children when they fail; {@link DefaultErrorFallback} by default. */
10
+ fallback?: React.ComponentType<ErrorFallbackProps>;
11
+ /** When it changes (the path of the page), a failed boundary renders its children again. */
12
+ resetKey?: unknown;
13
+ }
14
+ interface ErrorBoundaryState {
15
+ failed: boolean;
16
+ error?: unknown;
17
+ }
18
+ /**
19
+ * Catches the errors of the components below it, rendering or loading (a page chunk that does not
20
+ * load), and shows the fallback instead: one failing page does not blank the application. React logs
21
+ * the error to the console.
22
+ */
23
+ export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
24
+ state: ErrorBoundaryState;
25
+ static getDerivedStateFromError(error: unknown): ErrorBoundaryState;
26
+ componentDidUpdate(previous: ErrorBoundaryProps): void;
27
+ readonly reset: () => void;
28
+ render(): React.ReactNode;
29
+ }
30
+ /** The message of the error and a button to try again. */
31
+ export declare function DefaultErrorFallback({ error, reset }: ErrorFallbackProps): React.JSX.Element;
32
+ export {};
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Catches the errors of the components below it, rendering or loading (a page chunk that does not
4
+ * load), and shows the fallback instead: one failing page does not blank the application. React logs
5
+ * the error to the console.
6
+ */
7
+ export class ErrorBoundary extends React.Component {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.state = { failed: false };
11
+ this.reset = () => this.setState({ failed: false, error: undefined });
12
+ }
13
+ static getDerivedStateFromError(error) {
14
+ return { failed: true, error };
15
+ }
16
+ componentDidUpdate(previous) {
17
+ if (this.state.failed && previous.resetKey !== this.props.resetKey) {
18
+ this.reset();
19
+ }
20
+ }
21
+ render() {
22
+ var _a;
23
+ if (this.state.failed) {
24
+ const Fallback = (_a = this.props.fallback) !== null && _a !== void 0 ? _a : DefaultErrorFallback;
25
+ return React.createElement(Fallback, { error: this.state.error, reset: this.reset });
26
+ }
27
+ return this.props.children;
28
+ }
29
+ }
30
+ /** The message of the error and a button to try again. */
31
+ export function DefaultErrorFallback({ error, reset }) {
32
+ const message = error instanceof Error ? error.message : String(error);
33
+ return (React.createElement("div", { role: "alert", className: "cell-error" },
34
+ React.createElement("p", null, "Something went wrong."),
35
+ React.createElement("pre", null, message),
36
+ React.createElement("button", { type: "button", onClick: reset }, "Try again")));
37
+ }
38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C,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CACH,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,YAAY;QACpC,uDAA4B;QAC5B,iCAAM,OAAO,CAAO;QACpB,gCAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,KAAK,gBAAoB,CACtD,CACT,CAAC;AACN,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './error-boundary.js';
@@ -0,0 +1,2 @@
1
+ export * from './error-boundary.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/error/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  * a test renders a component inside `<ContainerContext.Provider value={container}>`.
6
6
  */
7
7
  export declare const ContainerContext: React.Context<Container | undefined>;
8
- /** The container of {@link ContainerContext}, else the application's (a component rendered in its own root). */
8
+ /** The container of {@link ContainerContext}. */
9
9
  export declare function useContainer(): Container;
10
10
  /** A component of the container, resolved once per component instance (and again if the container changes). */
11
11
  export declare function useInject<T>(id: ComponentId<T>): T;
@@ -1,22 +1,17 @@
1
- import { ConfigProvider, ContainerProvider } from '@celljs/core';
1
+ import { ConfigProvider } from '@celljs/core';
2
2
  import * as React from 'react';
3
3
  /**
4
4
  * The DI container of the components below it. The shell provides the application's container;
5
5
  * a test renders a component inside `<ContainerContext.Provider value={container}>`.
6
6
  */
7
7
  export const ContainerContext = React.createContext(undefined);
8
- /** The container of {@link ContainerContext}, else the application's (a component rendered in its own root). */
8
+ /** The container of {@link ContainerContext}. */
9
9
  export function useContainer() {
10
10
  const container = React.useContext(ContainerContext);
11
- if (container) {
12
- return container;
13
- }
14
- try {
15
- return ContainerProvider.provide();
16
- }
17
- catch (_a) {
18
- throw new Error('No DI container: render the component inside <ContainerContext.Provider value={container}>, or after the application has started.');
11
+ if (!container) {
12
+ throw new Error('No DI container: render the component inside the application, or inside <ContainerContext.Provider value={container}> in a test.');
19
13
  }
14
+ return container;
20
15
  }
21
16
  /** A component of the container, resolved once per component instance (and again if the container changes). */
22
17
  export function useInject(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"container-hooks.js","sourceRoot":"","sources":["../../../src/browser/hooks/container-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAa,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACzF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAAwB,SAAS,CAAC,CAAC;AAEtF,gHAAgH;AAChH,MAAM,UAAU,YAAY;IACxB,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACrD,IAAI,SAAS,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,CAAC;QACD,OAAO,iBAAiB,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;eAAO,CAAC;QACL,MAAM,IAAI,KAAK,CAAC,mIAAmI,CAAC,CAAC;IACzJ,CAAC;AACL,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,SAAS,CAAI,EAAkB;IAC3C,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAI,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,QAAQ,CAAI,GAAW,EAAE,YAAgB;IACrD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAiB,cAAc,CAAC,CAAC,GAAG,CAAI,GAAG,EAAE,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1H,CAAC"}
1
+ {"version":3,"file":"container-hooks.js","sourceRoot":"","sources":["../../../src/browser/hooks/container-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAa,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAAwB,SAAS,CAAC,CAAC;AAEtF,iDAAiD;AACjD,MAAM,UAAU,YAAY;IACxB,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,kIAAkI,CAAC,CAAC;IACxJ,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,SAAS,CAAI,EAAkB;IAC3C,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAI,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,QAAQ,CAAI,GAAW,EAAE,YAAgB;IACrD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAiB,cAAc,CAAC,CAAC,GAAG,CAAI,GAAG,EAAE,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1H,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './container-hooks.js';
2
+ export * from './rpc-hooks.js';
@@ -1,2 +1,3 @@
1
1
  export * from './container-hooks.js';
2
+ export * from './rpc-hooks.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ComponentId } from '@celljs/core';
2
+ /**
3
+ * The proxy of a backend service, as `@Autorpc(id)` injects it: `useRpc<GreetingServer>(GreetingServer)`.
4
+ * Its methods return promises; call them in an effect or an event handler. Needs `@celljs/rpc`.
5
+ */
6
+ export declare function useRpc<T extends object>(id: ComponentId<T>): T;
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { useContainer } from './container-hooks.js';
3
+ // The identifiers of @celljs/rpc (global symbols), so this package does not depend on it.
4
+ const RPC = Symbol.for('@celljs/rpc/RPC');
5
+ const ID_KEY = Symbol.for('@celljs/rpc/ID_KEY');
6
+ /**
7
+ * The proxy of a backend service, as `@Autorpc(id)` injects it: `useRpc<GreetingServer>(GreetingServer)`.
8
+ * Its methods return promises; call them in an effect or an event handler. Needs `@celljs/rpc`.
9
+ */
10
+ export function useRpc(id) {
11
+ const container = useContainer();
12
+ return React.useMemo(() => {
13
+ if (!container.isBound(RPC)) {
14
+ throw new Error('useRpc needs @celljs/rpc: add it to the dependencies of the project.');
15
+ }
16
+ return container.get(RPC, { tags: { [ID_KEY]: id } });
17
+ }, [container, id]);
18
+ }
19
+ //# sourceMappingURL=rpc-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-hooks.js","sourceRoot":"","sources":["../../../src/browser/hooks/rpc-hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,0FAA0F;AAC1F,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAmB,EAAkB;IACvD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;QAC5F,CAAC;QACD,OAAO,SAAS,CAAC,GAAG,CAAI,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;AACxB,CAAC"}
@@ -1 +1,2 @@
1
- export declare function Icon<T>(iconProps: T): JSX.Element;
1
+ import * as React from 'react';
2
+ export declare function Icon<T>(iconProps: T): React.JSX.Element;
@@ -1,16 +1,17 @@
1
1
  import * as React from 'react';
2
- import { ContainerUtil } from '@celljs/core';
3
2
  import { IconResolver } from './icon-protocol.js';
3
+ import { useInject } from '../hooks/index.js';
4
4
  const { useState, useEffect } = React;
5
5
  export function Icon(iconProps) {
6
+ const iconResolver = useInject(IconResolver);
6
7
  const [iconNode, setIconNode] = useState([]);
7
8
  useEffect(() => {
8
- const resolve = async () => {
9
- const iconResolver = ContainerUtil.get(IconResolver);
10
- setIconNode(await iconResolver.resolve(iconProps));
9
+ let current = true;
10
+ iconResolver.resolve(iconProps).then(node => current && setIconNode(node));
11
+ return () => {
12
+ current = false;
11
13
  };
12
- resolve();
13
- }, [JSON.stringify(iconProps)]);
14
+ }, [iconResolver, JSON.stringify(iconProps)]);
14
15
  return (React.createElement(React.Fragment, null, iconNode));
15
16
  }
16
17
  //# sourceMappingURL=icon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/browser/icon/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;AAEtC,MAAM,UAAU,IAAI,CAAI,SAAY;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAkB,EAAE,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;YACvB,MAAM,YAAY,GAAG,aAAa,CAAC,GAAG,CAAkB,YAAY,CAAC,CAAC;YACtE,WAAW,CAAC,MAAM,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC;QACF,OAAO,EAAE,CAAC;IACd,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEhC,OAAO,CAAC,0CAAG,QAAQ,CAAI,CAAC,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/browser/icon/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;AAEtC,MAAM,UAAU,IAAI,CAAI,SAAY;IAChC,MAAM,YAAY,GAAG,SAAS,CAAkB,YAAY,CAAC,CAAC;IAC9D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAkB,EAAE,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3E,OAAO,GAAG,EAAE;YACR,OAAO,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAE9C,OAAO,CAAC,0CAAG,QAAQ,CAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export * from './annotation/index.js';
2
2
  export * from './hooks/index.js';
3
3
  export * from './app/index.js';
4
+ export * from './error/index.js';
4
5
  export * from './layout/index.js';
5
6
  export * from './context/index.js';
6
7
  export * from './router/index.js';
@@ -1,6 +1,7 @@
1
1
  export * from './annotation/index.js';
2
2
  export * from './hooks/index.js';
3
3
  export * from './app/index.js';
4
+ export * from './error/index.js';
4
5
  export * from './layout/index.js';
5
6
  export * from './context/index.js';
6
7
  export * from './router/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './intl-context.js';
@@ -0,0 +1,2 @@
1
+ export * from './intl-context.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/intl/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ export declare const INTL_REACT_CONTEXT_PRIORITY = 3000;
3
+ /**
4
+ * The `IntlProvider` of react-intl around the application, with the messages of the selected locale. Not
5
+ * loaded by default: a project that uses react-intl installs it and imports `@celljs/react/lib/browser/intl`
6
+ * once, in `src/browser/module.ts`.
7
+ */
8
+ export declare function IntlContext({ children }: React.PropsWithChildren): React.JSX.Element;
9
+ export declare namespace IntlContext {
10
+ export { INTL_REACT_CONTEXT_PRIORITY as priority };
11
+ }
12
+ export default class {
13
+ }
@@ -5,31 +5,31 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import * as React from 'react';
8
- import { LOCALE_REACT_CONTEXT_PRIORITY } from './locale-protocol.js';
9
8
  import { IntlProvider } from 'react-intl';
10
9
  import { Logger } from '@celljs/core';
11
- import { LocaleManager } from '@celljs/widget';
12
10
  import { Context } from '../annotation/index.js';
13
11
  import { useInject } from '../hooks/index.js';
14
- export function LocaleContext({ children }) {
15
- const localeManager = useInject(LocaleManager);
12
+ import { useLocale } from '../locale/index.js';
13
+ export const INTL_REACT_CONTEXT_PRIORITY = 3000;
14
+ /**
15
+ * The `IntlProvider` of react-intl around the application, with the messages of the selected locale. Not
16
+ * loaded by default: a project that uses react-intl installs it and imports `@celljs/react/lib/browser/intl`
17
+ * once, in `src/browser/module.ts`.
18
+ */
19
+ export function IntlContext({ children }) {
20
+ const [locale] = useLocale();
16
21
  const logger = useInject(Logger);
17
- const [locale, setLocale] = React.useState(localeManager.currentSubject.value);
18
- React.useEffect(() => {
19
- const subscription = localeManager.currentSubject.subscribe(l => setLocale(l));
20
- return () => subscription.unsubscribe();
21
- }, [localeManager]);
22
22
  return (React.createElement(IntlProvider, { locale: (locale === null || locale === void 0 ? void 0 : locale.lang) || navigator.language || 'en', messages: locale === null || locale === void 0 ? void 0 : locale.messages, onError: err => {
23
23
  if (err.code !== 'MISSING_TRANSLATION') {
24
24
  logger.warn(err);
25
25
  }
26
26
  } }, children));
27
27
  }
28
- LocaleContext.priority = LOCALE_REACT_CONTEXT_PRIORITY;
28
+ IntlContext.priority = INTL_REACT_CONTEXT_PRIORITY;
29
29
  let default_1 = class {
30
30
  };
31
31
  default_1 = __decorate([
32
- Context(LocaleContext)
32
+ Context(IntlContext)
33
33
  ], default_1);
34
34
  export default default_1;
35
- //# sourceMappingURL=locale-context.js.map
35
+ //# sourceMappingURL=intl-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intl-context.js","sourceRoot":"","sources":["../../../src/browser/intl/intl-context.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAA2B;IAC7D,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,SAAS,CAAS,MAAM,CAAC,CAAC;IACzC,OAAO,CACH,oBAAC,YAAY,IAAC,MAAM,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,SAAS,CAAC,QAAQ,IAAI,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE;YACzG,IAAI,GAAG,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;gBACrC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;QACL,CAAC,IACI,QAAQ,CACE,CAAC,CAAC;AACzB,CAAC;AAED,WAAW,CAAC,QAAQ,GAAG,2BAA2B,CAAC;AAGpC,gBAAA;CAAQ,CAAA;AAAR;IADd,OAAO,CAAC,WAAW,CAAC;aACE"}
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  export declare class EmptyLayout extends React.Component<React.PropsWithChildren> {
3
- render(): JSX.Element;
3
+ render(): React.JSX.Element;
4
4
  }
@@ -1,2 +1 @@
1
- export * from './locale-protocol.js';
2
- export * from './locale-context.js';
1
+ export * from './locale-hooks.js';
@@ -1,3 +1,2 @@
1
- export * from './locale-protocol.js';
2
- export * from './locale-context.js';
1
+ export * from './locale-hooks.js';
3
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/locale/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/locale/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Locale } from '@celljs/widget';
2
+ /** The locale the user selected (`widget.locales`), and how to change it; renders again when it changes. */
3
+ export declare function useLocale(): [Locale | undefined, (locale: Locale) => void];
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { LocaleManager } from '@celljs/widget';
3
+ import { useInject } from '../hooks/index.js';
4
+ /** The locale the user selected (`widget.locales`), and how to change it; renders again when it changes. */
5
+ export function useLocale() {
6
+ const localeManager = useInject(LocaleManager);
7
+ const subscribe = React.useCallback((onChange) => {
8
+ const listener = localeManager.onCurrentChanged(onChange);
9
+ return () => listener.dispose();
10
+ }, [localeManager]);
11
+ const locale = React.useSyncExternalStore(subscribe, () => localeManager.current, () => localeManager.current);
12
+ const setLocale = React.useCallback((l) => localeManager.setCurrent(l), [localeManager]);
13
+ return [locale, setLocale];
14
+ }
15
+ //# sourceMappingURL=locale-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-hooks.js","sourceRoot":"","sources":["../../../src/browser/locale/locale-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAU,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,4GAA4G;AAC5G,MAAM,UAAU,SAAS;IACrB,MAAM,aAAa,GAAG,SAAS,CAAgB,aAAa,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,QAAoB,EAAE,EAAE;QACzD,MAAM,QAAQ,GAAG,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC1D,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACpB,MAAM,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/G,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACjG,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  const pages = new Map();
3
3
  const layouts = new Map();
4
+ const errors = new Map();
4
5
  /** Pages of `src/browser/pages` as route metadata: lazy components, so each page is loaded when visited. */
5
6
  export var FileRouteUtil;
6
7
  (function (FileRouteUtil) {
@@ -10,9 +11,18 @@ export var FileRouteUtil;
10
11
  priority: 1000,
11
12
  component: page(route),
12
13
  ...(route.layouts.length ? { layout: layout(route) } : {}),
14
+ ...(route.error ? { errorFallback: errorFallback(route.error) } : {}),
13
15
  };
14
16
  }
15
17
  FileRouteUtil.toMetadata = toMetadata;
18
+ function errorFallback(error) {
19
+ let component = errors.get(error.file);
20
+ if (!component) {
21
+ component = React.lazy(async () => ({ default: componentOf(await error.load(), error.file) }));
22
+ errors.set(error.file, component);
23
+ }
24
+ return component;
25
+ }
16
26
  /** One component per file (and per chain of layouts): React keeps a layout mounted from one page to the next. */
17
27
  function page(route) {
18
28
  let component = pages.get(route.file);
@@ -1 +1 @@
1
- {"version":3,"file":"file-route-util.js","sourceRoot":"","sources":["../../../src/browser/router/file-route-util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,KAAK,GAAG,IAAI,GA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AC,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC1J,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC/B,CAAC,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,SAAgB,WAAW,CAAI,MAAiB,EAAE,IAAY;QAC1D,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC;QACjC,IAAI,OAAO,SAAS,KAAK,UAAU,IAAI,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,CAAC,EAAE,CAAC;YAC3F,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,mGAAmG,CAAC,CAAC;QAChI,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IANe,cAAA,WAAW,cAM1B,CAAA;AACL,CAAC,EArDgB,aAAa,KAAb,aAAa,QAqD7B"}
@@ -1,3 +1,4 @@
1
+ import type { ErrorFallbackProps } from '../error/index.js';
1
2
  export declare const ROUTER: unique symbol;
2
3
  export declare const ROUTE_METADATA: unique symbol;
3
4
  export declare const RouteMetadataProvider: unique symbol;
@@ -9,6 +10,8 @@ export interface RouteMetadata {
9
10
  path?: string;
10
11
  component?: React.ComponentType;
11
12
  layout?: React.ComponentType<React.PropsWithChildren>;
13
+ /** What shows, inside the layout, when the page fails; `DefaultErrorFallback` by default. */
14
+ errorFallback?: React.ComponentType<ErrorFallbackProps>;
12
15
  priority?: number;
13
16
  }
14
17
  export interface RouteMetadataConverter {
@@ -37,4 +40,11 @@ export interface FileRoute {
37
40
  default?: React.ComponentType<React.PropsWithChildren>;
38
41
  }>;
39
42
  }[];
43
+ /** The nearest `_error` file: what shows when the page fails. */
44
+ error?: {
45
+ file: string;
46
+ load(): Promise<{
47
+ default?: React.ComponentType<ErrorFallbackProps>;
48
+ }>;
49
+ };
40
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"router-protocol.js","sourceRoot":"","sources":["../../../src/browser/router/router-protocol.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC"}
1
+ {"version":3,"file":"router-protocol.js","sourceRoot":"","sources":["../../../src/browser/router/router-protocol.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC"}
@@ -1,2 +1,8 @@
1
+ import * as React from 'react';
2
+ import { ErrorBoundary, ErrorFallbackProps } from '../error/index.js';
3
+ /** The boundary of a page, inside its layout: tries the page again when the user goes to another path. */
4
+ export declare function PageErrorBoundary({ fallback, children }: React.PropsWithChildren<{
5
+ fallback?: React.ComponentType<ErrorFallbackProps>;
6
+ }>): React.CElement<import("../index.js").ErrorBoundaryProps, ErrorBoundary>;
1
7
  export default class {
2
8
  }
@@ -6,8 +6,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import * as React from 'react';
8
8
  import { RouteMetadataProvider } from './router-protocol.js';
9
- import { useRoutes, BrowserRouter, HashRouter, MemoryRouter } from 'react-router';
9
+ import { useRoutes, useLocation, BrowserRouter, HashRouter, MemoryRouter } from 'react-router';
10
10
  import { Router } from '../annotation/index.js';
11
+ import { ErrorBoundary } from '../error/index.js';
11
12
  import { useInject, useValue } from '../hooks/index.js';
12
13
  const routerMap = {
13
14
  browser: BrowserRouter,
@@ -23,15 +24,19 @@ function RouterComponent() {
23
24
  const routes = React.useMemo(() => routeMetadataProvider.provide().map(toRouteObject), [routeMetadataProvider]);
24
25
  return React.createElement(routerMap[routerType], {}, React.createElement(Routes, { routes }));
25
26
  }
27
+ /** The boundary of a page, inside its layout: tries the page again when the user goes to another path. */
28
+ export function PageErrorBoundary({ fallback, children }) {
29
+ const { pathname } = useLocation();
30
+ return React.createElement(ErrorBoundary, { fallback, resetKey: pathname }, children);
31
+ }
26
32
  function toRouteObject(metadata) {
27
33
  let element;
28
34
  if (metadata.component) {
29
- element = React.createElement(metadata.component);
35
+ // Pages of src/browser/pages, their layouts and _error files are lazy components.
36
+ element = React.createElement(PageErrorBoundary, { fallback: metadata.errorFallback }, React.createElement(React.Suspense, { fallback: null }, React.createElement(metadata.component)));
30
37
  if (metadata.layout) {
31
- element = React.createElement(metadata.layout, {}, element);
38
+ element = React.createElement(React.Suspense, { fallback: null }, React.createElement(metadata.layout, {}, element));
32
39
  }
33
- // Pages of src/browser/pages and their layouts are lazy components.
34
- element = React.createElement(React.Suspense, { fallback: null }, element);
35
40
  }
36
41
  return {
37
42
  path: metadata.path,
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/browser/router/router.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAiB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;A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AAAR;IADd,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC;aACR"}
@@ -1,6 +1,9 @@
1
- import { ApplicationShell } from '@celljs/core/lib/browser';
1
+ import { AbstractApplicationShell } from '@celljs/core/lib/browser';
2
+ import { Container } from '@celljs/core';
2
3
  import * as React from 'react';
3
- export declare class Shell implements ApplicationShell {
4
+ /** Renders the `@App` component with the container of the application, inside an error boundary. */
5
+ export declare class Shell extends AbstractApplicationShell {
4
6
  protected readonly app: React.ComponentType;
5
- attach(host: HTMLElement): void;
7
+ protected readonly container: Container;
8
+ protected render(host: HTMLElement): void;
6
9
  }