sekisho 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/factory.cjs +1 -1
- package/dist/factory.d.ts +2 -3
- package/dist/factory.mjs +1 -1
- package/package.json +1 -1
package/dist/factory.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use client";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("foxact/create-stackless-error"),t=require("foxact/nullthrow"),n=require("react");exports.createSekisho=function(o){let s=new WeakSet;class u extends Error{constructor(e){super(e),this.digest="BAILOUT_TO_CLIENT_SIDE_RENDERING",this.name=o??"SekishoGuardError",s.add(this)}}function i(e){return"object"==typeof e&&null!==e&&s.has(e)}let l=n.createContext(null);function c({error:r,children:o}){let s=t.nullthrow(n.useContext(l),"<ErrorWrapper /> must be used within its corresponding container component");if(i(r)){let{fallback:t,fallbackComponent:n}=s;return n?e.jsx(n,{error:r}):t}return o}function a({children:r}){let{fallback:o,fallbackComponent:s}=t.nullthrow(n.useContext(l),"<ErrorWrapper /> must be used within its corresponding container component"),u=n.useMemo(()=>s?e.jsx(s,{error:null}):o,[o,s]);return e.jsx(n.Suspense,{fallback:u,children:r})}class h extends n.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}render(){let r=this.state.error;if(null===r)return this.props.children;if(i(r))return e.jsx(c,{error:r});throw r}}return[function(e){throw r.createStacklessError(()=>new u(e))},function({children:r,...t}){return e.jsx(l.Provider,{value:t,children:e.jsx(h,{children:e.jsx(a,{children:r})})})},c,i,u]};
|
package/dist/factory.d.ts
CHANGED
|
@@ -10,8 +10,7 @@ interface SekishoGuardError extends Error {
|
|
|
10
10
|
* - `fallback` — a static `ReactNode` rendered in place of children when the
|
|
11
11
|
* guard fires (access-control pattern).
|
|
12
12
|
* - `fallbackComponent` — a React component that receives `{ error }` as props.
|
|
13
|
-
*
|
|
14
|
-
* navigation side-effect (auth pattern).
|
|
13
|
+
* The `error` prop will only be `null` when the error is thrown in the server
|
|
15
14
|
*/
|
|
16
15
|
type SekishoContainerProps = React.PropsWithChildren & ({
|
|
17
16
|
fallback: React.ReactNode;
|
|
@@ -19,7 +18,7 @@ type SekishoContainerProps = React.PropsWithChildren & ({
|
|
|
19
18
|
} | {
|
|
20
19
|
fallback?: never;
|
|
21
20
|
fallbackComponent: React.ComponentType<{
|
|
22
|
-
error: SekishoGuardError;
|
|
21
|
+
error: SekishoGuardError | null;
|
|
23
22
|
}>;
|
|
24
23
|
});
|
|
25
24
|
/**
|
package/dist/factory.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r}from"react/jsx-runtime";import{createStacklessError as
|
|
1
|
+
"use client";import{jsx as r}from"react/jsx-runtime";import{createStacklessError as e}from"foxact/create-stackless-error";import{nullthrow as t}from"foxact/nullthrow";import{useContext as n,createContext as o,Component as i,useMemo as s,Suspense as c}from"react";function l(l){let u=new WeakSet;class a extends Error{constructor(r){super(r),this.digest="BAILOUT_TO_CLIENT_SIDE_RENDERING",this.name=l??"SekishoGuardError",u.add(this)}}function p(r){return"object"==typeof r&&null!==r&&u.has(r)}let f=o(null);function h({error:e,children:o}){let i=t(n(f),"<ErrorWrapper /> must be used within its corresponding container component");if(p(e)){let{fallback:t,fallbackComponent:n}=i;return n?r(n,{error:e}):t}return o}function d({children:e}){let{fallback:o,fallbackComponent:i}=t(n(f),"<ErrorWrapper /> must be used within its corresponding container component"),l=s(()=>i?r(i,{error:null}):o,[o,i]);return r(c,{fallback:l,children:e})}class m extends i{constructor(r){super(r),this.state={error:null}}static getDerivedStateFromError(r){return{error:r}}render(){let e=this.state.error;if(null===e)return this.props.children;if(p(e))return r(h,{error:e});throw e}}return[function(r){throw e(()=>new a(r))},function({children:e,...t}){return r(f.Provider,{value:t,children:r(m,{children:r(d,{children:e})})})},h,p,a]}export{l as createSekisho};
|