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 CHANGED
@@ -1 +1 @@
1
- "use client";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react/jsx-runtime"),e=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(r){super(r),this.digest="BAILOUT_TO_CLIENT_SIDE_RENDERING",this.name=o??"SekishoGuardError",s.add(this)}}function i(r){return"object"==typeof r&&null!==r&&s.has(r)}let c=n.createContext(null);function l({error:e,children:o}){let s=t.nullthrow(n.useContext(c),"<ErrorWrapper /> must be used within its corresponding container component");if(i(e)){let{fallback:t,fallbackComponent:n}=s;return n?r.jsx(n,{error:e}):t}return o}class a extends n.Component{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(i(e))return r.jsx(l,{error:e});throw e}}return[function(r){throw e.createStacklessError(()=>new u(r))},function({children:e,...t}){return r.jsx(c.Provider,{value:t,children:r.jsx(a,{children:e})})},l,i,u]};
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
- * Use this when you need the caught error object, e.g. to trigger a
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 t}from"foxact/create-stackless-error";import{nullthrow as e}from"foxact/nullthrow";import{useContext as o,createContext as n,Component as i}from"react";function s(s){let c=new WeakSet;class u extends Error{constructor(r){super(r),this.digest="BAILOUT_TO_CLIENT_SIDE_RENDERING",this.name=s??"SekishoGuardError",c.add(this)}}function l(r){return"object"==typeof r&&null!==r&&c.has(r)}let a=n(null);function f({error:t,children:n}){let i=e(o(a),"<ErrorWrapper /> must be used within its corresponding container component");if(l(t)){let{fallback:e,fallbackComponent:o}=i;return o?r(o,{error:t}):e}return n}class h extends i{constructor(r){super(r),this.state={error:null}}static getDerivedStateFromError(r){return{error:r}}render(){let t=this.state.error;if(null===t)return this.props.children;if(l(t))return r(f,{error:t});throw t}}return[function(r){throw t(()=>new u(r))},function({children:t,...e}){return r(a.Provider,{value:e,children:r(h,{children:t})})},f,l,u]}export{s as createSekisho};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sekisho",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Authentication and Access Control for any React app",
5
5
  "repository": {
6
6
  "type": "git",