@jfdevelops/react-layout 2.0.0 → 2.2.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 (97) hide show
  1. package/dist/create-config/create-defined-resource-layout.cjs +14 -5
  2. package/dist/create-config/create-defined-resource-layout.cjs.map +1 -1
  3. package/dist/create-config/create-defined-resource-layout.d.cts +8 -6
  4. package/dist/create-config/create-defined-resource-layout.d.cts.map +1 -1
  5. package/dist/create-config/create-defined-resource-layout.d.mts +8 -6
  6. package/dist/create-config/create-defined-resource-layout.d.mts.map +1 -1
  7. package/dist/create-config/create-defined-resource-layout.mjs +14 -5
  8. package/dist/create-config/create-defined-resource-layout.mjs.map +1 -1
  9. package/dist/create-config/define-layout.cjs +69 -21
  10. package/dist/create-config/define-layout.cjs.map +1 -1
  11. package/dist/create-config/define-layout.d.cts +9 -8
  12. package/dist/create-config/define-layout.d.cts.map +1 -1
  13. package/dist/create-config/define-layout.d.mts +9 -8
  14. package/dist/create-config/define-layout.d.mts.map +1 -1
  15. package/dist/create-config/define-layout.mjs +72 -24
  16. package/dist/create-config/define-layout.mjs.map +1 -1
  17. package/dist/create-config/for-resources/create-component.d.cts +30 -24
  18. package/dist/create-config/for-resources/create-component.d.cts.map +1 -1
  19. package/dist/create-config/for-resources/create-component.d.mts +30 -24
  20. package/dist/create-config/for-resources/create-component.d.mts.map +1 -1
  21. package/dist/create-config/for-resources/create-for-resources.cjs +27 -6
  22. package/dist/create-config/for-resources/create-for-resources.cjs.map +1 -1
  23. package/dist/create-config/for-resources/create-for-resources.mjs +27 -6
  24. package/dist/create-config/for-resources/create-for-resources.mjs.map +1 -1
  25. package/dist/create-config/for-resources/scoped-layout.d.cts +2 -2
  26. package/dist/create-config/for-resources/scoped-layout.d.cts.map +1 -1
  27. package/dist/create-config/for-resources/scoped-layout.d.mts +2 -2
  28. package/dist/create-config/for-resources/scoped-layout.d.mts.map +1 -1
  29. package/dist/create-config/for-resources/scoped-render.cjs +38 -4
  30. package/dist/create-config/for-resources/scoped-render.cjs.map +1 -1
  31. package/dist/create-config/for-resources/scoped-render.d.cts +8 -1
  32. package/dist/create-config/for-resources/scoped-render.d.cts.map +1 -1
  33. package/dist/create-config/for-resources/scoped-render.d.mts +8 -1
  34. package/dist/create-config/for-resources/scoped-render.d.mts.map +1 -1
  35. package/dist/create-config/for-resources/scoped-render.mjs +38 -4
  36. package/dist/create-config/for-resources/scoped-render.mjs.map +1 -1
  37. package/dist/create-config/index.d.cts +1 -1
  38. package/dist/create-config/index.d.mts +1 -1
  39. package/dist/create-config/inspection.cjs +23 -1
  40. package/dist/create-config/inspection.cjs.map +1 -1
  41. package/dist/create-config/inspection.mjs +24 -3
  42. package/dist/create-config/inspection.mjs.map +1 -1
  43. package/dist/create-config/lazy-resource-layout.cjs +4 -4
  44. package/dist/create-config/lazy-resource-layout.cjs.map +1 -1
  45. package/dist/create-config/lazy-resource-layout.d.cts +1 -1
  46. package/dist/create-config/lazy-resource-layout.d.cts.map +1 -1
  47. package/dist/create-config/lazy-resource-layout.d.mts +1 -1
  48. package/dist/create-config/lazy-resource-layout.d.mts.map +1 -1
  49. package/dist/create-config/lazy-resource-layout.mjs +4 -4
  50. package/dist/create-config/lazy-resource-layout.mjs.map +1 -1
  51. package/dist/create-config/render-state-context.cjs +24 -0
  52. package/dist/create-config/render-state-context.cjs.map +1 -0
  53. package/dist/create-config/render-state-context.mjs +22 -0
  54. package/dist/create-config/render-state-context.mjs.map +1 -0
  55. package/dist/create-config/render-state.cjs +1 -0
  56. package/dist/create-config/render-state.cjs.map +1 -1
  57. package/dist/create-config/render-state.d.cts +26 -15
  58. package/dist/create-config/render-state.d.cts.map +1 -1
  59. package/dist/create-config/render-state.d.mts +26 -15
  60. package/dist/create-config/render-state.d.mts.map +1 -1
  61. package/dist/create-config/render-state.mjs +1 -0
  62. package/dist/create-config/render-state.mjs.map +1 -1
  63. package/dist/create-config/state-composable.cjs +4 -2
  64. package/dist/create-config/state-composable.cjs.map +1 -1
  65. package/dist/create-config/state-composable.d.cts.map +1 -1
  66. package/dist/create-config/state-composable.d.mts.map +1 -1
  67. package/dist/create-config/state-composable.mjs +4 -2
  68. package/dist/create-config/state-composable.mjs.map +1 -1
  69. package/dist/index.d.cts +3 -2
  70. package/dist/index.d.mts +3 -2
  71. package/dist/lazy/create-lazy-loader.cjs +30 -9
  72. package/dist/lazy/create-lazy-loader.cjs.map +1 -1
  73. package/dist/lazy/create-lazy-loader.mjs +31 -10
  74. package/dist/lazy/create-lazy-loader.mjs.map +1 -1
  75. package/dist/lazy/create-render-state.cjs +59 -0
  76. package/dist/lazy/create-render-state.cjs.map +1 -0
  77. package/dist/lazy/create-render-state.d.cts +33 -0
  78. package/dist/lazy/create-render-state.d.cts.map +1 -0
  79. package/dist/lazy/create-render-state.d.mts +33 -0
  80. package/dist/lazy/create-render-state.d.mts.map +1 -0
  81. package/dist/lazy/create-render-state.mjs +59 -0
  82. package/dist/lazy/create-render-state.mjs.map +1 -0
  83. package/dist/lazy/lazy-boundary.cjs +14 -6
  84. package/dist/lazy/lazy-boundary.cjs.map +1 -1
  85. package/dist/lazy/lazy-boundary.mjs +14 -6
  86. package/dist/lazy/lazy-boundary.mjs.map +1 -1
  87. package/dist/lazy/types.cjs.map +1 -1
  88. package/dist/lazy/types.d.cts +7 -6
  89. package/dist/lazy/types.d.cts.map +1 -1
  90. package/dist/lazy/types.d.mts +7 -6
  91. package/dist/lazy/types.d.mts.map +1 -1
  92. package/dist/lazy/types.mjs.map +1 -1
  93. package/package.json +4 -4
  94. package/dist/lazy/create-error-component.cjs +0 -17
  95. package/dist/lazy/create-error-component.cjs.map +0 -1
  96. package/dist/lazy/create-error-component.mjs +0 -16
  97. package/dist/lazy/create-error-component.mjs.map +0 -1
@@ -1,3 +1,4 @@
1
+ const require_render_state_context = require('../create-config/render-state-context.cjs');
1
2
  const require_lazy_resource_error = require('../errors/lazy-resource-error.cjs');
2
3
  let react = require("react");
3
4
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -25,10 +26,13 @@ var LazyErrorBoundary = class extends react.Component {
25
26
  if (!this.state.failed) return this.props.children;
26
27
  const { ErrorComponent, resource } = this.props;
27
28
  if (!require_lazy_resource_error.isLazyResourceError(this.state.error) || !ErrorComponent) throw this.state.error;
28
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorComponent, {
29
- error: this.state.error,
30
- retry: this.retry,
31
- resource
29
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_render_state_context.RenderStateFallback, {
30
+ state: "Error",
31
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorComponent, {
32
+ error: this.state.error,
33
+ retry: this.retry,
34
+ resource
35
+ })
32
36
  });
33
37
  }
34
38
  };
@@ -36,6 +40,7 @@ var LazyErrorBoundary = class extends react.Component {
36
40
  function LazyBoundary({ loader, member, resource, fallback, ErrorComponent, componentProps, onMount, map }) {
37
41
  const [, rerender] = (0, react.useReducer)((value) => value + 1, 0);
38
42
  (0, react.useEffect)(() => onMount?.(), [onMount]);
43
+ const Current = loader.component(member, map);
39
44
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LazyErrorBoundary, {
40
45
  resource,
41
46
  ErrorComponent,
@@ -44,8 +49,11 @@ function LazyBoundary({ loader, member, resource, fallback, ErrorComponent, comp
44
49
  rerender();
45
50
  },
46
51
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
47
- fallback,
48
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(loader.component(member, map), { ...componentProps })
52
+ fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_render_state_context.RenderStateFallback, {
53
+ state: "Loading",
54
+ children: fallback
55
+ }),
56
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Current, { ...componentProps })
49
57
  })
50
58
  });
51
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-boundary.cjs","names":["Component","isLazyResourceError","Suspense"],"sources":["../../src/lazy/lazy-boundary.tsx"],"sourcesContent":["import {\n Component,\n Suspense,\n useEffect,\n useReducer,\n type ReactNode,\n} from 'react';\nimport { isLazyResourceError } from '../errors/lazy-resource-error';\nimport type { LazyResourceErrorComponent } from './types';\nimport type { LazyLoader } from './create-lazy-loader';\n\ntype BoundaryProps = {\n children: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n resource: string;\n onRetry: () => void;\n};\n\nclass LazyErrorBoundary extends Component<\n BoundaryProps,\n { failed: boolean; error?: unknown }\n> {\n state = { failed: false, error: undefined as unknown };\n static getDerivedStateFromError(error: unknown) {\n return { failed: true, error };\n }\n retry = () => {\n this.props.onRetry();\n this.setState({ failed: false, error: undefined });\n };\n render() {\n if (!this.state.failed) return this.props.children;\n const { ErrorComponent, resource } = this.props;\n if (!isLazyResourceError(this.state.error) || !ErrorComponent)\n throw this.state.error;\n return (\n <ErrorComponent\n error={this.state.error}\n retry={this.retry}\n resource={resource}\n />\n );\n }\n}\n\n/** Shared loading, typed error handling and retry for all lazy components. */\nexport function LazyBoundary({\n loader,\n member,\n resource,\n fallback,\n ErrorComponent,\n componentProps,\n onMount,\n map,\n}: {\n loader: LazyLoader<any>;\n member?: PropertyKey;\n map?: (selected: any) => React.ComponentType<any>;\n resource: string;\n fallback?: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n componentProps: Record<string, unknown>;\n onMount?: () => (() => void) | undefined;\n}) {\n const [, rerender] = useReducer((value) => value + 1, 0);\n useEffect(() => onMount?.(), [onMount]);\n const Current = loader.component(member, map);\n return (\n <LazyErrorBoundary\n resource={resource}\n ErrorComponent={ErrorComponent}\n onRetry={() => {\n loader.reset();\n rerender();\n }}\n >\n <Suspense fallback={fallback}>\n <Current {...componentProps} />\n </Suspense>\n </LazyErrorBoundary>\n );\n}\n"],"mappings":";;;;;AAkBA,IAAM,oBAAN,cAAgCA,gBAG9B;CACA,QAAQ;EAAE,QAAQ;EAAO,OAAO;CAAqB;CACrD,OAAO,yBAAyB,OAAgB;EAC9C,OAAO;GAAE,QAAQ;GAAM;EAAM;CAC/B;CACA,cAAc;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS;GAAE,QAAQ;GAAO,OAAO;EAAU,CAAC;CACnD;CACA,SAAS;EACP,IAAI,CAAC,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;EAC1C,MAAM,EAAE,gBAAgB,aAAa,KAAK;EAC1C,IAAI,CAACC,gDAAoB,KAAK,MAAM,KAAK,KAAK,CAAC,gBAC7C,MAAM,KAAK,MAAM;EACnB,OACE,2CAAC,gBAAD;GACE,OAAO,KAAK,MAAM;GAClB,OAAO,KAAK;GACF;EACX;CAEL;AACF;;AAGA,SAAgB,aAAa,EAC3B,QACA,QACA,UACA,UACA,gBACA,gBACA,SACA,OAUC;CACD,MAAM,GAAG,mCAAwB,UAAU,QAAQ,GAAG,CAAC;CACvD,2BAAgB,UAAU,GAAG,CAAC,OAAO,CAAC;CAEtC,OACE,2CAAC,mBAAD;EACY;EACM;EAChB,eAAe;GACb,OAAO,MAAM;GACb,SAAS;EACX;YAEA,2CAACC,gBAAD;GAAoB;aAClB,2CAXU,OAAO,UAAU,QAAQ,GAW5B,GAAP,EAAS,GAAI,eAAiB;EACtB;CACO;AAEvB"}
1
+ {"version":3,"file":"lazy-boundary.cjs","names":["Component","isLazyResourceError","RenderStateFallback","Suspense"],"sources":["../../src/lazy/lazy-boundary.tsx"],"sourcesContent":["import { RenderStateFallback } from '../create-config/render-state-context';\nimport {\n Component,\n Suspense,\n useEffect,\n useReducer,\n type ReactNode,\n} from 'react';\nimport { isLazyResourceError } from '../errors/lazy-resource-error';\nimport type { LazyResourceErrorComponent } from './types';\nimport type { LazyLoader } from './create-lazy-loader';\n\ntype BoundaryProps = {\n children: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n resource: string;\n onRetry: () => void;\n};\n\nclass LazyErrorBoundary extends Component<\n BoundaryProps,\n { failed: boolean; error?: unknown }\n> {\n state = { failed: false, error: undefined as unknown };\n static getDerivedStateFromError(error: unknown) {\n return { failed: true, error };\n }\n retry = () => {\n this.props.onRetry();\n this.setState({ failed: false, error: undefined });\n };\n render() {\n if (!this.state.failed) return this.props.children;\n const { ErrorComponent, resource } = this.props;\n if (!isLazyResourceError(this.state.error) || !ErrorComponent)\n throw this.state.error;\n return (\n <RenderStateFallback state=\"Error\">\n <ErrorComponent\n error={this.state.error}\n retry={this.retry}\n resource={resource}\n />\n </RenderStateFallback>\n );\n }\n}\n\n/** Shared loading, typed error handling and retry for all lazy components. */\nexport function LazyBoundary({\n loader,\n member,\n resource,\n fallback,\n ErrorComponent,\n componentProps,\n onMount,\n map,\n}: {\n loader: LazyLoader<any>;\n member?: PropertyKey;\n map?: (selected: any) => React.ComponentType<any>;\n resource: string;\n fallback?: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n componentProps: Record<string, unknown>;\n onMount?: () => (() => void) | undefined;\n}) {\n const [, rerender] = useReducer((value) => value + 1, 0);\n useEffect(() => onMount?.(), [onMount]);\n const Current = loader.component(member, map);\n return (\n <LazyErrorBoundary\n resource={resource}\n ErrorComponent={ErrorComponent}\n onRetry={() => {\n loader.reset();\n rerender();\n }}\n >\n <Suspense fallback={\n <RenderStateFallback state=\"Loading\">{fallback}</RenderStateFallback>\n }>\n <Current {...componentProps} />\n </Suspense>\n </LazyErrorBoundary>\n );\n}\n"],"mappings":";;;;;;AAmBA,IAAM,oBAAN,cAAgCA,gBAG9B;CACA,QAAQ;EAAE,QAAQ;EAAO,OAAO;CAAqB;CACrD,OAAO,yBAAyB,OAAgB;EAC9C,OAAO;GAAE,QAAQ;GAAM;EAAM;CAC/B;CACA,cAAc;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS;GAAE,QAAQ;GAAO,OAAO;EAAU,CAAC;CACnD;CACA,SAAS;EACP,IAAI,CAAC,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;EAC1C,MAAM,EAAE,gBAAgB,aAAa,KAAK;EAC1C,IAAI,CAACC,gDAAoB,KAAK,MAAM,KAAK,KAAK,CAAC,gBAC7C,MAAM,KAAK,MAAM;EACnB,OACE,2CAACC,kDAAD;GAAqB,OAAM;aACzB,2CAAC,gBAAD;IACE,OAAO,KAAK,MAAM;IAClB,OAAO,KAAK;IACF;GACX;EACkB;CAEzB;AACF;;AAGA,SAAgB,aAAa,EAC3B,QACA,QACA,UACA,UACA,gBACA,gBACA,SACA,OAUC;CACD,MAAM,GAAG,mCAAwB,UAAU,QAAQ,GAAG,CAAC;CACvD,2BAAgB,UAAU,GAAG,CAAC,OAAO,CAAC;CACtC,MAAM,UAAU,OAAO,UAAU,QAAQ,GAAG;CAC5C,OACE,2CAAC,mBAAD;EACY;EACM;EAChB,eAAe;GACb,OAAO,MAAM;GACb,SAAS;EACX;YAEA,2CAACC,gBAAD;GAAU,UACR,2CAACD,kDAAD;IAAqB,OAAM;cAAW;GAA8B;aAEpE,2CAAC,SAAD,EAAS,GAAI,eAAiB;EACtB;CACO;AAEvB"}
@@ -1,3 +1,4 @@
1
+ import { RenderStateFallback } from "../create-config/render-state-context.mjs";
1
2
  import { isLazyResourceError } from "../errors/lazy-resource-error.mjs";
2
3
  import { Component, Suspense, useEffect, useReducer } from "react";
3
4
  import { jsx } from "react/jsx-runtime";
@@ -25,10 +26,13 @@ var LazyErrorBoundary = class extends Component {
25
26
  if (!this.state.failed) return this.props.children;
26
27
  const { ErrorComponent, resource } = this.props;
27
28
  if (!isLazyResourceError(this.state.error) || !ErrorComponent) throw this.state.error;
28
- return /* @__PURE__ */ jsx(ErrorComponent, {
29
- error: this.state.error,
30
- retry: this.retry,
31
- resource
29
+ return /* @__PURE__ */ jsx(RenderStateFallback, {
30
+ state: "Error",
31
+ children: /* @__PURE__ */ jsx(ErrorComponent, {
32
+ error: this.state.error,
33
+ retry: this.retry,
34
+ resource
35
+ })
32
36
  });
33
37
  }
34
38
  };
@@ -36,6 +40,7 @@ var LazyErrorBoundary = class extends Component {
36
40
  function LazyBoundary({ loader, member, resource, fallback, ErrorComponent, componentProps, onMount, map }) {
37
41
  const [, rerender] = useReducer((value) => value + 1, 0);
38
42
  useEffect(() => onMount?.(), [onMount]);
43
+ const Current = loader.component(member, map);
39
44
  return /* @__PURE__ */ jsx(LazyErrorBoundary, {
40
45
  resource,
41
46
  ErrorComponent,
@@ -44,8 +49,11 @@ function LazyBoundary({ loader, member, resource, fallback, ErrorComponent, comp
44
49
  rerender();
45
50
  },
46
51
  children: /* @__PURE__ */ jsx(Suspense, {
47
- fallback,
48
- children: /* @__PURE__ */ jsx(loader.component(member, map), { ...componentProps })
52
+ fallback: /* @__PURE__ */ jsx(RenderStateFallback, {
53
+ state: "Loading",
54
+ children: fallback
55
+ }),
56
+ children: /* @__PURE__ */ jsx(Current, { ...componentProps })
49
57
  })
50
58
  });
51
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-boundary.mjs","names":[],"sources":["../../src/lazy/lazy-boundary.tsx"],"sourcesContent":["import {\n Component,\n Suspense,\n useEffect,\n useReducer,\n type ReactNode,\n} from 'react';\nimport { isLazyResourceError } from '../errors/lazy-resource-error';\nimport type { LazyResourceErrorComponent } from './types';\nimport type { LazyLoader } from './create-lazy-loader';\n\ntype BoundaryProps = {\n children: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n resource: string;\n onRetry: () => void;\n};\n\nclass LazyErrorBoundary extends Component<\n BoundaryProps,\n { failed: boolean; error?: unknown }\n> {\n state = { failed: false, error: undefined as unknown };\n static getDerivedStateFromError(error: unknown) {\n return { failed: true, error };\n }\n retry = () => {\n this.props.onRetry();\n this.setState({ failed: false, error: undefined });\n };\n render() {\n if (!this.state.failed) return this.props.children;\n const { ErrorComponent, resource } = this.props;\n if (!isLazyResourceError(this.state.error) || !ErrorComponent)\n throw this.state.error;\n return (\n <ErrorComponent\n error={this.state.error}\n retry={this.retry}\n resource={resource}\n />\n );\n }\n}\n\n/** Shared loading, typed error handling and retry for all lazy components. */\nexport function LazyBoundary({\n loader,\n member,\n resource,\n fallback,\n ErrorComponent,\n componentProps,\n onMount,\n map,\n}: {\n loader: LazyLoader<any>;\n member?: PropertyKey;\n map?: (selected: any) => React.ComponentType<any>;\n resource: string;\n fallback?: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n componentProps: Record<string, unknown>;\n onMount?: () => (() => void) | undefined;\n}) {\n const [, rerender] = useReducer((value) => value + 1, 0);\n useEffect(() => onMount?.(), [onMount]);\n const Current = loader.component(member, map);\n return (\n <LazyErrorBoundary\n resource={resource}\n ErrorComponent={ErrorComponent}\n onRetry={() => {\n loader.reset();\n rerender();\n }}\n >\n <Suspense fallback={fallback}>\n <Current {...componentProps} />\n </Suspense>\n </LazyErrorBoundary>\n );\n}\n"],"mappings":";;;;;AAkBA,IAAM,oBAAN,cAAgC,UAG9B;CACA,QAAQ;EAAE,QAAQ;EAAO,OAAO;CAAqB;CACrD,OAAO,yBAAyB,OAAgB;EAC9C,OAAO;GAAE,QAAQ;GAAM;EAAM;CAC/B;CACA,cAAc;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS;GAAE,QAAQ;GAAO,OAAO;EAAU,CAAC;CACnD;CACA,SAAS;EACP,IAAI,CAAC,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;EAC1C,MAAM,EAAE,gBAAgB,aAAa,KAAK;EAC1C,IAAI,CAAC,oBAAoB,KAAK,MAAM,KAAK,KAAK,CAAC,gBAC7C,MAAM,KAAK,MAAM;EACnB,OACE,oBAAC,gBAAD;GACE,OAAO,KAAK,MAAM;GAClB,OAAO,KAAK;GACF;EACX;CAEL;AACF;;AAGA,SAAgB,aAAa,EAC3B,QACA,QACA,UACA,UACA,gBACA,gBACA,SACA,OAUC;CACD,MAAM,GAAG,YAAY,YAAY,UAAU,QAAQ,GAAG,CAAC;CACvD,gBAAgB,UAAU,GAAG,CAAC,OAAO,CAAC;CAEtC,OACE,oBAAC,mBAAD;EACY;EACM;EAChB,eAAe;GACb,OAAO,MAAM;GACb,SAAS;EACX;YAEA,oBAAC,UAAD;GAAoB;aAClB,oBAXU,OAAO,UAAU,QAAQ,GAW5B,GAAP,EAAS,GAAI,eAAiB;EACtB;CACO;AAEvB"}
1
+ {"version":3,"file":"lazy-boundary.mjs","names":[],"sources":["../../src/lazy/lazy-boundary.tsx"],"sourcesContent":["import { RenderStateFallback } from '../create-config/render-state-context';\nimport {\n Component,\n Suspense,\n useEffect,\n useReducer,\n type ReactNode,\n} from 'react';\nimport { isLazyResourceError } from '../errors/lazy-resource-error';\nimport type { LazyResourceErrorComponent } from './types';\nimport type { LazyLoader } from './create-lazy-loader';\n\ntype BoundaryProps = {\n children: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n resource: string;\n onRetry: () => void;\n};\n\nclass LazyErrorBoundary extends Component<\n BoundaryProps,\n { failed: boolean; error?: unknown }\n> {\n state = { failed: false, error: undefined as unknown };\n static getDerivedStateFromError(error: unknown) {\n return { failed: true, error };\n }\n retry = () => {\n this.props.onRetry();\n this.setState({ failed: false, error: undefined });\n };\n render() {\n if (!this.state.failed) return this.props.children;\n const { ErrorComponent, resource } = this.props;\n if (!isLazyResourceError(this.state.error) || !ErrorComponent)\n throw this.state.error;\n return (\n <RenderStateFallback state=\"Error\">\n <ErrorComponent\n error={this.state.error}\n retry={this.retry}\n resource={resource}\n />\n </RenderStateFallback>\n );\n }\n}\n\n/** Shared loading, typed error handling and retry for all lazy components. */\nexport function LazyBoundary({\n loader,\n member,\n resource,\n fallback,\n ErrorComponent,\n componentProps,\n onMount,\n map,\n}: {\n loader: LazyLoader<any>;\n member?: PropertyKey;\n map?: (selected: any) => React.ComponentType<any>;\n resource: string;\n fallback?: ReactNode;\n ErrorComponent?: LazyResourceErrorComponent;\n componentProps: Record<string, unknown>;\n onMount?: () => (() => void) | undefined;\n}) {\n const [, rerender] = useReducer((value) => value + 1, 0);\n useEffect(() => onMount?.(), [onMount]);\n const Current = loader.component(member, map);\n return (\n <LazyErrorBoundary\n resource={resource}\n ErrorComponent={ErrorComponent}\n onRetry={() => {\n loader.reset();\n rerender();\n }}\n >\n <Suspense fallback={\n <RenderStateFallback state=\"Loading\">{fallback}</RenderStateFallback>\n }>\n <Current {...componentProps} />\n </Suspense>\n </LazyErrorBoundary>\n );\n}\n"],"mappings":";;;;;;AAmBA,IAAM,oBAAN,cAAgC,UAG9B;CACA,QAAQ;EAAE,QAAQ;EAAO,OAAO;CAAqB;CACrD,OAAO,yBAAyB,OAAgB;EAC9C,OAAO;GAAE,QAAQ;GAAM;EAAM;CAC/B;CACA,cAAc;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS;GAAE,QAAQ;GAAO,OAAO;EAAU,CAAC;CACnD;CACA,SAAS;EACP,IAAI,CAAC,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;EAC1C,MAAM,EAAE,gBAAgB,aAAa,KAAK;EAC1C,IAAI,CAAC,oBAAoB,KAAK,MAAM,KAAK,KAAK,CAAC,gBAC7C,MAAM,KAAK,MAAM;EACnB,OACE,oBAAC,qBAAD;GAAqB,OAAM;aACzB,oBAAC,gBAAD;IACE,OAAO,KAAK,MAAM;IAClB,OAAO,KAAK;IACF;GACX;EACkB;CAEzB;AACF;;AAGA,SAAgB,aAAa,EAC3B,QACA,QACA,UACA,UACA,gBACA,gBACA,SACA,OAUC;CACD,MAAM,GAAG,YAAY,YAAY,UAAU,QAAQ,GAAG,CAAC;CACvD,gBAAgB,UAAU,GAAG,CAAC,OAAO,CAAC;CACtC,MAAM,UAAU,OAAO,UAAU,QAAQ,GAAG;CAC5C,OACE,oBAAC,mBAAD;EACY;EACM;EAChB,eAAe;GACb,OAAO,MAAM;GACb,SAAS;EACX;YAEA,oBAAC,UAAD;GAAU,UACR,oBAAC,qBAAD;IAAqB,OAAM;cAAW;GAA8B;aAEpE,oBAAC,SAAD,EAAS,GAAI,eAAiB;EACtB;CACO;AAEvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../src/lazy/types.ts"],"sourcesContent":["import type { ComponentType, ReactNode } from 'react';\nimport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\nimport type {\n LazyResourceError,\n LazyResourceErrorMap,\n} from '../errors/lazy-resource-error';\n\nexport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\n\n/** Options shared by lazy layouts, render states, and scoped content. */\nexport type LazyOptions<\n Module extends Record<string, unknown> = Record<string, unknown>,\n> = {\n load: () => Promise<Module>;\n fallback?: ReactNode;\n};\n\nexport type LazyHandle = {\n preload(): Promise<void>;\n readonly status: LoadStatus;\n};\n\nexport type LazyResourceErrorProps<Resource = string> = {\n error: LazyResourceError;\n retry: () => void;\n resource: Resource;\n};\n\nexport type LazyResourceErrorComponent<Resource = string> = ComponentType<\n LazyResourceErrorProps<Resource>\n>;\nexport type LazyResourceLoadingComponent<Resource = string> = ComponentType<{\n resource: Resource;\n}>;\nexport type LazyResourceStates<Resource = string> = {\n Error?: LazyResourceErrorComponent<Resource>;\n Loading?: LazyResourceLoadingComponent<Resource>;\n};\n\nexport type LazyErrorHandlers<Resource, Custom extends object = {}> = {\n [Code in LazyResourceError['code']]?: (\n props: Custom &\n Omit<LazyResourceErrorProps<Resource>, 'error'> & {\n error: LazyResourceErrorMap[Code];\n },\n ) => ReactNode;\n} & {\n fallback?: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode;\n};\n\nexport type CreateLazyErrorComponent<Resource> = {\n <Custom extends object = {}>(\n render: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n <Custom extends object = {}>(\n handlers: LazyErrorHandlers<Resource, Custom>,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n};\n\n/** Internal factory defaults propagated to layouts without publishing metadata. */\nexport const lazyDefaultsSymbol = Symbol('lazyDefaults');\n\nexport const lazyStatesSymbol = Symbol('lazyStates');\n"],"mappings":";;;AA4DA,MAAa,qBAAqB,OAAO,cAAc;AAEvD,MAAa,mBAAmB,OAAO,YAAY"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/lazy/types.ts"],"sourcesContent":["import type { ComponentType, ReactNode } from 'react';\nimport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\nimport type {\n LazyResourceError,\n LazyResourceErrorMap,\n} from '../errors/lazy-resource-error';\n\nexport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\n\n/** Options shared by lazy layouts, render states, and scoped content. */\nexport type LazyOptions<\n Module extends Record<string, unknown> = Record<string, unknown>,\n> = {\n load: () => Promise<Module>;\n fallback?: ReactNode;\n};\n\nexport type LazyHandle = {\n preload(): Promise<void>;\n readonly status: LoadStatus;\n};\n\nexport type LazyResourceErrorProps<Resource = string> = {\n error: LazyResourceError;\n retry: () => void;\n resource: Resource;\n};\n\nexport type LazyResourceErrorComponent<Resource = string> = ComponentType<\n LazyResourceErrorProps<Resource>\n>;\nexport type LazyResourceLoadingComponent<Resource = string> = ComponentType<{\n resource: Resource;\n}>;\nexport type LazyResourceStates<Resource = string> = {\n Error?: LazyResourceErrorComponent<Resource>;\n Loading?: LazyResourceLoadingComponent<Resource>;\n};\n\ntype ErrorHandlerContext<Context> = [Context] extends [never]\n ? []\n : [context: Context];\n\nexport type LazyErrorHandlers<\n Resource,\n Custom extends object = {},\n Context = never,\n> = {\n [Code in LazyResourceError['code']]?: (\n props: Custom &\n Omit<LazyResourceErrorProps<Resource>, 'error'> & {\n error: LazyResourceErrorMap[Code];\n },\n ...context: ErrorHandlerContext<Context>\n ) => ReactNode;\n} & {\n fallback?: (\n props: Custom & LazyResourceErrorProps<Resource>,\n ...context: ErrorHandlerContext<Context>\n ) => ReactNode;\n};\n\nexport type CreateLazyErrorComponent<Resource, Context = never> = {\n <Custom extends object = {}>(\n render: (\n props: Custom & LazyResourceErrorProps<Resource>,\n ...context: ErrorHandlerContext<Context>\n ) => ReactNode,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n <Custom extends object = {}>(\n handlers: LazyErrorHandlers<Resource, Custom, Context>,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n};\n\n/** Internal factory defaults propagated to layouts without publishing metadata. */\nexport const lazyDefaultsSymbol = Symbol('lazyDefaults');\n\nexport const lazyStatesSymbol = Symbol('lazyStates');\n"],"mappings":";;;AA2EA,MAAa,qBAAqB,OAAO,cAAc;AAEvD,MAAa,mBAAmB,OAAO,YAAY"}
@@ -25,14 +25,15 @@ type LazyResourceStates<Resource = string> = {
25
25
  Error?: LazyResourceErrorComponent<Resource>;
26
26
  Loading?: LazyResourceLoadingComponent<Resource>;
27
27
  };
28
- type LazyErrorHandlers<Resource, Custom extends object = {}> = { [Code in LazyResourceError['code']]?: (props: Custom & Omit<LazyResourceErrorProps<Resource>, 'error'> & {
28
+ type ErrorHandlerContext<Context> = [Context] extends [never] ? [] : [context: Context];
29
+ type LazyErrorHandlers<Resource, Custom extends object = {}, Context = never> = { [Code in LazyResourceError['code']]?: (props: Custom & Omit<LazyResourceErrorProps<Resource>, 'error'> & {
29
30
  error: LazyResourceErrorMap[Code];
30
- }) => ReactNode } & {
31
- fallback?: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode;
31
+ }, ...context: ErrorHandlerContext<Context>) => ReactNode } & {
32
+ fallback?: (props: Custom & LazyResourceErrorProps<Resource>, ...context: ErrorHandlerContext<Context>) => ReactNode;
32
33
  };
33
- type CreateLazyErrorComponent<Resource> = {
34
- <Custom extends object = {}>(render: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
35
- <Custom extends object = {}>(handlers: LazyErrorHandlers<Resource, Custom>): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
34
+ type CreateLazyErrorComponent<Resource, Context = never> = {
35
+ <Custom extends object = {}>(render: (props: Custom & LazyResourceErrorProps<Resource>, ...context: ErrorHandlerContext<Context>) => ReactNode): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
36
+ <Custom extends object = {}>(handlers: LazyErrorHandlers<Resource, Custom, Context>): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
36
37
  };
37
38
  //#endregion
38
39
  export { CreateLazyErrorComponent, LazyErrorHandlers, LazyHandle, LazyOptions, LazyResourceErrorComponent, LazyResourceErrorProps, LazyResourceLoadingComponent, LazyResourceStates, type LoadStatus$1 as LoadStatus };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/lazy/types.ts"],"mappings":";;;;;;KAUY,WAAA,gBACK,MAAA,oBAA0B,MAAA;EAEzC,IAAA,QAAY,OAAA,CAAQ,MAAA;EACpB,QAAA,GAAW,SAAA;AAAA;AAAA,KAGD,UAAA;EACV,OAAA,IAAW,OAAA;EAAA,SACF,MAAA,EAAQ,UAAU;AAAA;AAAA,KAGjB,sBAAA;EACV,KAAA,EAAO,iBAAA;EACP,KAAA;EACA,QAAA,EAAU,QAAQ;AAAA;AAAA,KAGR,0BAAA,sBAAgD,aAAA,CAC1D,sBAAA,CAAuB,QAAA;AAAA,KAEb,4BAAA,sBAAkD,aAAa;EACzE,QAAA,EAAU,QAAA;AAAA;AAAA,KAEA,kBAAA;EACV,KAAA,GAAQ,0BAAA,CAA2B,QAAA;EACnC,OAAA,GAAU,4BAAA,CAA6B,QAAA;AAAA;AAAA,KAG7B,iBAAA,oDACD,iBAAA,aACP,KAAA,EAAO,MAAA,GACL,IAAA,CAAK,sBAAA,CAAuB,QAAA;EAC1B,KAAA,EAAO,oBAAA,CAAqB,IAAA;AAAA,MAE7B,SAAA;EAEL,QAAA,IAAY,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MAAc,SAAA;AAAA;AAAA,KAGvD,wBAAA;EAAA,6BAER,MAAA,GAAS,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MAAc,SAAA,GAC7D,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;EAAA,6BAE/C,QAAA,EAAU,iBAAA,CAAkB,QAAA,EAAU,MAAA,IACrC,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;AAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/lazy/types.ts"],"mappings":";;;;;;KAUY,WAAA,gBACK,MAAA,oBAA0B,MAAA;EAEzC,IAAA,QAAY,OAAA,CAAQ,MAAA;EACpB,QAAA,GAAW,SAAA;AAAA;AAAA,KAGD,UAAA;EACV,OAAA,IAAW,OAAA;EAAA,SACF,MAAA,EAAQ,UAAU;AAAA;AAAA,KAGjB,sBAAA;EACV,KAAA,EAAO,iBAAA;EACP,KAAA;EACA,QAAA,EAAU,QAAQ;AAAA;AAAA,KAGR,0BAAA,sBAAgD,aAAA,CAC1D,sBAAA,CAAuB,QAAA;AAAA,KAEb,4BAAA,sBAAkD,aAAa;EACzE,QAAA,EAAU,QAAA;AAAA;AAAA,KAEA,kBAAA;EACV,KAAA,GAAQ,0BAAA,CAA2B,QAAA;EACnC,OAAA,GAAU,4BAAA,CAA6B,QAAA;AAAA;AAAA,KAGpC,mBAAA,aAAgC,OAAA,0BAEhC,OAAA,EAAS,OAAO;AAAA,KAET,iBAAA,qEAKD,iBAAA,aACP,KAAA,EAAO,MAAA,GACL,IAAA,CAAK,sBAAA,CAAuB,QAAA;EAC1B,KAAA,EAAO,oBAAA,CAAqB,IAAA;AAAA,MAE7B,OAAA,EAAS,mBAAA,CAAoB,OAAA,MAC7B,SAAA;EAEL,QAAA,IACE,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MACpC,OAAA,EAAS,mBAAA,CAAoB,OAAA,MAC7B,SAAA;AAAA;AAAA,KAGK,wBAAA;EAAA,6BAER,MAAA,GACE,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MACpC,OAAA,EAAS,mBAAA,CAAoB,OAAA,MAC7B,SAAA,GACJ,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;EAAA,6BAE/C,QAAA,EAAU,iBAAA,CAAkB,QAAA,EAAU,MAAA,EAAQ,OAAA,IAC7C,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;AAAA"}
@@ -25,14 +25,15 @@ type LazyResourceStates<Resource = string> = {
25
25
  Error?: LazyResourceErrorComponent<Resource>;
26
26
  Loading?: LazyResourceLoadingComponent<Resource>;
27
27
  };
28
- type LazyErrorHandlers<Resource, Custom extends object = {}> = { [Code in LazyResourceError['code']]?: (props: Custom & Omit<LazyResourceErrorProps<Resource>, 'error'> & {
28
+ type ErrorHandlerContext<Context> = [Context] extends [never] ? [] : [context: Context];
29
+ type LazyErrorHandlers<Resource, Custom extends object = {}, Context = never> = { [Code in LazyResourceError['code']]?: (props: Custom & Omit<LazyResourceErrorProps<Resource>, 'error'> & {
29
30
  error: LazyResourceErrorMap[Code];
30
- }) => ReactNode } & {
31
- fallback?: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode;
31
+ }, ...context: ErrorHandlerContext<Context>) => ReactNode } & {
32
+ fallback?: (props: Custom & LazyResourceErrorProps<Resource>, ...context: ErrorHandlerContext<Context>) => ReactNode;
32
33
  };
33
- type CreateLazyErrorComponent<Resource> = {
34
- <Custom extends object = {}>(render: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
35
- <Custom extends object = {}>(handlers: LazyErrorHandlers<Resource, Custom>): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
34
+ type CreateLazyErrorComponent<Resource, Context = never> = {
35
+ <Custom extends object = {}>(render: (props: Custom & LazyResourceErrorProps<Resource>, ...context: ErrorHandlerContext<Context>) => ReactNode): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
36
+ <Custom extends object = {}>(handlers: LazyErrorHandlers<Resource, Custom, Context>): ComponentType<Custom & LazyResourceErrorProps<Resource>>;
36
37
  };
37
38
  //#endregion
38
39
  export { CreateLazyErrorComponent, LazyErrorHandlers, LazyHandle, LazyOptions, LazyResourceErrorComponent, LazyResourceErrorProps, LazyResourceLoadingComponent, LazyResourceStates, type LoadStatus$1 as LoadStatus };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/lazy/types.ts"],"mappings":";;;;;;KAUY,WAAA,gBACK,MAAA,oBAA0B,MAAA;EAEzC,IAAA,QAAY,OAAA,CAAQ,MAAA;EACpB,QAAA,GAAW,SAAA;AAAA;AAAA,KAGD,UAAA;EACV,OAAA,IAAW,OAAA;EAAA,SACF,MAAA,EAAQ,UAAU;AAAA;AAAA,KAGjB,sBAAA;EACV,KAAA,EAAO,iBAAA;EACP,KAAA;EACA,QAAA,EAAU,QAAQ;AAAA;AAAA,KAGR,0BAAA,sBAAgD,aAAA,CAC1D,sBAAA,CAAuB,QAAA;AAAA,KAEb,4BAAA,sBAAkD,aAAa;EACzE,QAAA,EAAU,QAAA;AAAA;AAAA,KAEA,kBAAA;EACV,KAAA,GAAQ,0BAAA,CAA2B,QAAA;EACnC,OAAA,GAAU,4BAAA,CAA6B,QAAA;AAAA;AAAA,KAG7B,iBAAA,oDACD,iBAAA,aACP,KAAA,EAAO,MAAA,GACL,IAAA,CAAK,sBAAA,CAAuB,QAAA;EAC1B,KAAA,EAAO,oBAAA,CAAqB,IAAA;AAAA,MAE7B,SAAA;EAEL,QAAA,IAAY,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MAAc,SAAA;AAAA;AAAA,KAGvD,wBAAA;EAAA,6BAER,MAAA,GAAS,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MAAc,SAAA,GAC7D,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;EAAA,6BAE/C,QAAA,EAAU,iBAAA,CAAkB,QAAA,EAAU,MAAA,IACrC,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;AAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/lazy/types.ts"],"mappings":";;;;;;KAUY,WAAA,gBACK,MAAA,oBAA0B,MAAA;EAEzC,IAAA,QAAY,OAAA,CAAQ,MAAA;EACpB,QAAA,GAAW,SAAA;AAAA;AAAA,KAGD,UAAA;EACV,OAAA,IAAW,OAAA;EAAA,SACF,MAAA,EAAQ,UAAU;AAAA;AAAA,KAGjB,sBAAA;EACV,KAAA,EAAO,iBAAA;EACP,KAAA;EACA,QAAA,EAAU,QAAQ;AAAA;AAAA,KAGR,0BAAA,sBAAgD,aAAA,CAC1D,sBAAA,CAAuB,QAAA;AAAA,KAEb,4BAAA,sBAAkD,aAAa;EACzE,QAAA,EAAU,QAAA;AAAA;AAAA,KAEA,kBAAA;EACV,KAAA,GAAQ,0BAAA,CAA2B,QAAA;EACnC,OAAA,GAAU,4BAAA,CAA6B,QAAA;AAAA;AAAA,KAGpC,mBAAA,aAAgC,OAAA,0BAEhC,OAAA,EAAS,OAAO;AAAA,KAET,iBAAA,qEAKD,iBAAA,aACP,KAAA,EAAO,MAAA,GACL,IAAA,CAAK,sBAAA,CAAuB,QAAA;EAC1B,KAAA,EAAO,oBAAA,CAAqB,IAAA;AAAA,MAE7B,OAAA,EAAS,mBAAA,CAAoB,OAAA,MAC7B,SAAA;EAEL,QAAA,IACE,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MACpC,OAAA,EAAS,mBAAA,CAAoB,OAAA,MAC7B,SAAA;AAAA;AAAA,KAGK,wBAAA;EAAA,6BAER,MAAA,GACE,KAAA,EAAO,MAAA,GAAS,sBAAA,CAAuB,QAAA,MACpC,OAAA,EAAS,mBAAA,CAAoB,OAAA,MAC7B,SAAA,GACJ,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;EAAA,6BAE/C,QAAA,EAAU,iBAAA,CAAkB,QAAA,EAAU,MAAA,EAAQ,OAAA,IAC7C,aAAA,CAAc,MAAA,GAAS,sBAAA,CAAuB,QAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../../src/lazy/types.ts"],"sourcesContent":["import type { ComponentType, ReactNode } from 'react';\nimport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\nimport type {\n LazyResourceError,\n LazyResourceErrorMap,\n} from '../errors/lazy-resource-error';\n\nexport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\n\n/** Options shared by lazy layouts, render states, and scoped content. */\nexport type LazyOptions<\n Module extends Record<string, unknown> = Record<string, unknown>,\n> = {\n load: () => Promise<Module>;\n fallback?: ReactNode;\n};\n\nexport type LazyHandle = {\n preload(): Promise<void>;\n readonly status: LoadStatus;\n};\n\nexport type LazyResourceErrorProps<Resource = string> = {\n error: LazyResourceError;\n retry: () => void;\n resource: Resource;\n};\n\nexport type LazyResourceErrorComponent<Resource = string> = ComponentType<\n LazyResourceErrorProps<Resource>\n>;\nexport type LazyResourceLoadingComponent<Resource = string> = ComponentType<{\n resource: Resource;\n}>;\nexport type LazyResourceStates<Resource = string> = {\n Error?: LazyResourceErrorComponent<Resource>;\n Loading?: LazyResourceLoadingComponent<Resource>;\n};\n\nexport type LazyErrorHandlers<Resource, Custom extends object = {}> = {\n [Code in LazyResourceError['code']]?: (\n props: Custom &\n Omit<LazyResourceErrorProps<Resource>, 'error'> & {\n error: LazyResourceErrorMap[Code];\n },\n ) => ReactNode;\n} & {\n fallback?: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode;\n};\n\nexport type CreateLazyErrorComponent<Resource> = {\n <Custom extends object = {}>(\n render: (props: Custom & LazyResourceErrorProps<Resource>) => ReactNode,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n <Custom extends object = {}>(\n handlers: LazyErrorHandlers<Resource, Custom>,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n};\n\n/** Internal factory defaults propagated to layouts without publishing metadata. */\nexport const lazyDefaultsSymbol = Symbol('lazyDefaults');\n\nexport const lazyStatesSymbol = Symbol('lazyStates');\n"],"mappings":";;AA4DA,MAAa,qBAAqB,OAAO,cAAc;AAEvD,MAAa,mBAAmB,OAAO,YAAY"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../../src/lazy/types.ts"],"sourcesContent":["import type { ComponentType, ReactNode } from 'react';\nimport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\nimport type {\n LazyResourceError,\n LazyResourceErrorMap,\n} from '../errors/lazy-resource-error';\n\nexport type { LoadStatus } from '@jfdevelops/react-layout-devtools-core';\n\n/** Options shared by lazy layouts, render states, and scoped content. */\nexport type LazyOptions<\n Module extends Record<string, unknown> = Record<string, unknown>,\n> = {\n load: () => Promise<Module>;\n fallback?: ReactNode;\n};\n\nexport type LazyHandle = {\n preload(): Promise<void>;\n readonly status: LoadStatus;\n};\n\nexport type LazyResourceErrorProps<Resource = string> = {\n error: LazyResourceError;\n retry: () => void;\n resource: Resource;\n};\n\nexport type LazyResourceErrorComponent<Resource = string> = ComponentType<\n LazyResourceErrorProps<Resource>\n>;\nexport type LazyResourceLoadingComponent<Resource = string> = ComponentType<{\n resource: Resource;\n}>;\nexport type LazyResourceStates<Resource = string> = {\n Error?: LazyResourceErrorComponent<Resource>;\n Loading?: LazyResourceLoadingComponent<Resource>;\n};\n\ntype ErrorHandlerContext<Context> = [Context] extends [never]\n ? []\n : [context: Context];\n\nexport type LazyErrorHandlers<\n Resource,\n Custom extends object = {},\n Context = never,\n> = {\n [Code in LazyResourceError['code']]?: (\n props: Custom &\n Omit<LazyResourceErrorProps<Resource>, 'error'> & {\n error: LazyResourceErrorMap[Code];\n },\n ...context: ErrorHandlerContext<Context>\n ) => ReactNode;\n} & {\n fallback?: (\n props: Custom & LazyResourceErrorProps<Resource>,\n ...context: ErrorHandlerContext<Context>\n ) => ReactNode;\n};\n\nexport type CreateLazyErrorComponent<Resource, Context = never> = {\n <Custom extends object = {}>(\n render: (\n props: Custom & LazyResourceErrorProps<Resource>,\n ...context: ErrorHandlerContext<Context>\n ) => ReactNode,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n <Custom extends object = {}>(\n handlers: LazyErrorHandlers<Resource, Custom, Context>,\n ): ComponentType<Custom & LazyResourceErrorProps<Resource>>;\n};\n\n/** Internal factory defaults propagated to layouts without publishing metadata. */\nexport const lazyDefaultsSymbol = Symbol('lazyDefaults');\n\nexport const lazyStatesSymbol = Symbol('lazyStates');\n"],"mappings":";;AA2EA,MAAa,qBAAqB,OAAO,cAAc;AAEvD,MAAa,mBAAmB,OAAO,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jfdevelops/react-layout",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "A React library for creating layout components.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,9 +29,9 @@
29
29
  "dependencies": {
30
30
  "@jfdevelops/create-error": "0.2.0",
31
31
  "arktype": "2.2.8",
32
- "@jfdevelops/react-layout-composables": "0.3.1",
32
+ "@jfdevelops/react-layout-composables": "0.4.0",
33
33
  "@jfdevelops/react-layout-validator": "0.3.1",
34
- "@jfdevelops/react-layout-devtools-core": "0.3.0"
34
+ "@jfdevelops/react-layout-devtools-core": "0.4.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": ">=18",
@@ -59,7 +59,7 @@
59
59
  "unrun": "0.3.0",
60
60
  "vite": "8.0.10",
61
61
  "vitest": "4.1.5",
62
- "@jfdevelops/react-layout-composable-breadcrumb": "0.2.10"
62
+ "@jfdevelops/react-layout-composable-breadcrumb": "0.2.11"
63
63
  },
64
64
  "scripts": {
65
65
  "dev": "portless react-layout vite",
@@ -1,17 +0,0 @@
1
-
2
- //#region src/lazy/create-error-component.tsx
3
- /** Function inputs retain their identity; handler maps dispatch by error code. */
4
- const createLazyErrorComponent = (input) => {
5
- if (typeof input === "function") return input;
6
- const handlers = input;
7
- function LazyResourceErrorByCode(props) {
8
- const handler = handlers[props.error.code] ?? handlers.fallback;
9
- if (!handler) throw props.error;
10
- return handler(props);
11
- }
12
- return LazyResourceErrorByCode;
13
- };
14
-
15
- //#endregion
16
- exports.createLazyErrorComponent = createLazyErrorComponent;
17
- //# sourceMappingURL=create-error-component.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-error-component.cjs","names":[],"sources":["../../src/lazy/create-error-component.tsx"],"sourcesContent":["import type {\n CreateLazyErrorComponent,\n LazyErrorHandlers,\n LazyResourceErrorProps,\n} from './types';\n\n/** Function inputs retain their identity; handler maps dispatch by error code. */\nexport const createLazyErrorComponent: CreateLazyErrorComponent<string> = (\n input:\n | ((props: LazyResourceErrorProps) => React.ReactNode)\n | LazyErrorHandlers<string>,\n) => {\n if (typeof input === 'function') return input;\n const handlers = input;\n function LazyResourceErrorByCode(props: LazyResourceErrorProps) {\n const handler = handlers[props.error.code] ?? handlers.fallback;\n if (!handler) throw props.error;\n return handler(props as never);\n }\n return LazyResourceErrorByCode;\n};\n"],"mappings":";;;AAOA,MAAa,4BACX,UAGG;CACH,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,MAAM,WAAW;CACjB,SAAS,wBAAwB,OAA+B;EAC9D,MAAM,UAAU,SAAS,MAAM,MAAM,SAAS,SAAS;EACvD,IAAI,CAAC,SAAS,MAAM,MAAM;EAC1B,OAAO,QAAQ,KAAc;CAC/B;CACA,OAAO;AACT"}
@@ -1,16 +0,0 @@
1
- //#region src/lazy/create-error-component.tsx
2
- /** Function inputs retain their identity; handler maps dispatch by error code. */
3
- const createLazyErrorComponent = (input) => {
4
- if (typeof input === "function") return input;
5
- const handlers = input;
6
- function LazyResourceErrorByCode(props) {
7
- const handler = handlers[props.error.code] ?? handlers.fallback;
8
- if (!handler) throw props.error;
9
- return handler(props);
10
- }
11
- return LazyResourceErrorByCode;
12
- };
13
-
14
- //#endregion
15
- export { createLazyErrorComponent };
16
- //# sourceMappingURL=create-error-component.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-error-component.mjs","names":[],"sources":["../../src/lazy/create-error-component.tsx"],"sourcesContent":["import type {\n CreateLazyErrorComponent,\n LazyErrorHandlers,\n LazyResourceErrorProps,\n} from './types';\n\n/** Function inputs retain their identity; handler maps dispatch by error code. */\nexport const createLazyErrorComponent: CreateLazyErrorComponent<string> = (\n input:\n | ((props: LazyResourceErrorProps) => React.ReactNode)\n | LazyErrorHandlers<string>,\n) => {\n if (typeof input === 'function') return input;\n const handlers = input;\n function LazyResourceErrorByCode(props: LazyResourceErrorProps) {\n const handler = handlers[props.error.code] ?? handlers.fallback;\n if (!handler) throw props.error;\n return handler(props as never);\n }\n return LazyResourceErrorByCode;\n};\n"],"mappings":";;AAOA,MAAa,4BACX,UAGG;CACH,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,MAAM,WAAW;CACjB,SAAS,wBAAwB,OAA+B;EAC9D,MAAM,UAAU,SAAS,MAAM,MAAM,SAAS,SAAS;EACvD,IAAI,CAAC,SAAS,MAAM,MAAM;EAC1B,OAAO,QAAQ,KAAc;CAC/B;CACA,OAAO;AACT"}