@real-router/preact 0.15.0 → 0.15.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ssr.d.mts","names":[],"sources":["../../src/components/ClientOnly.tsx","../../src/components/ServerOnly.tsx","../../src/components/Await.tsx","../../src/components/Streamed.tsx","../../src/components/HttpStatusCode.tsx","../../src/utils/createHttpStatusSink.ts","../../src/components/HttpStatusProvider.tsx","../../src/hooks/useDeferred.tsx"],"mappings":";;;UAIiB,eAAA;EAAA,SACN,QAAA,EAAU,iBAAA;EAAA,SACV,QAAA,GAAW,iBAAiB;AAAA;AAAA,iBAGvB,UAAA,CAAA;EACd,QAAA;EACA;AAAA,GACC,eAAA,GAAkB,iBAAA;;;UCRJ,eAAA;EAAA,SACN,QAAA,EAAU,iBAAA;EAAA,SACV,QAAA,GAAW,iBAAiB;AAAA;AAAA,iBAGvB,UAAA,CAAA;EACd,QAAA;EACA;AAAA,GACC,eAAA,GAAkB,iBAAA;;;UC6CJ,UAAA;;WAEN,IAAA;EFvDqB;;EAAA,SE0DrB,QAAA,GAAW,KAAA,EAAO,CAAA,KAAM,iBAAiB;AAAA;;;;;AFxDb;AAGvC;;;;;;;;iBEqEgB,KAAA,aAAA,CAAA;EACd,IAAA;EACA;AAAA,GACC,UAAA,CAAW,CAAA,IAAK,iBAAA;;;UC7EF,aAAA;;WAEN,QAAA,EAAU,iBAAA;EAAA,SACV,QAAA,EAAU,iBAAiB;AAAA;;;;;;;AHDC;AAGvC;iBGSgB,QAAA,CAAA;EACd,QAAA;EACA;AAAA,GACC,aAAA,GAAgB,iBAAA;;;UCfF,mBAAA;;WAEN,IAAI;AAAA;;;;;;;;AJFwB;AAGvC;;;;;;;;;;;;;;;;AAGsC;;;;ACRtC;;;;;;;;;AAEuC;AAGvC;;;;;;;iBG+CgB,cAAA,CAAA;EACd;AAAA,GACC,mBAAA,GAAsB,iBAAA;;;;;;AJtDzB;;;;;;;;;AAEuC;AAGvC;;;;;;;UKWiB,cAAA;EACf,IAAI;AAAA;AAAA,iBAGU,oBAAA,CAAA,GAAwB,cAAc;;;UCjBrC,uBAAA;EAAA,SACN,IAAA,EAAM,cAAA;EAAA,SACN,QAAA,EAAU,iBAAiB;AAAA;AAAA,iBAGtB,kBAAA,CAAA;EACd,IAAA;EACA;AAAA,GACC,uBAAA,GAA0B,iBAAA;;;;;;ANX7B;;;;iBOcgB,WAAA,aAAA,CAAyB,GAAA,WAAc,OAAO,CAAC,CAAA"}
1
+ {"version":3,"file":"ssr.d.mts","names":[],"sources":["../../src/components/ClientOnly.tsx","../../src/components/ServerOnly.tsx","../../src/components/Await.tsx","../../src/components/Streamed.tsx","../../src/components/HttpStatusCode.tsx","../../src/utils/createHttpStatusSink.ts","../../src/components/HttpStatusProvider.tsx","../../src/hooks/useDeferred.tsx"],"mappings":";;;UAIiB,eAAA;EAAA,SACN,QAAA,EAAU,iBAAA;EAAA,SACV,QAAA,GAAW,iBAAiB;AAAA;AAAA,iBAGvB,UAAA;EACd,QAAA;EACA;AAAA,GACC,eAAA,GAAkB,iBAAA;;;UCRJ,eAAA;EAAA,SACN,QAAA,EAAU,iBAAA;EAAA,SACV,QAAA,GAAW,iBAAiB;AAAA;AAAA,iBAGvB,UAAA;EACd,QAAA;EACA;AAAA,GACC,eAAA,GAAkB,iBAAA;;;UC6CJ,UAAA;;WAEN,IAAA;EFvDqB;;EAAA,SE0DrB,QAAA,GAAW,KAAA,EAAO,CAAA,KAAM,iBAAiB;AAAA;;;;;AFxDb;AAGvC;;;;;;;;iBEqEgB,KAAA;EACd,IAAA;EACA;AAAA,GACC,UAAA,CAAW,CAAA,IAAK,iBAAA;;;UC7EF,aAAA;;WAEN,QAAA,EAAU,iBAAA;EAAA,SACV,QAAA,EAAU,iBAAiB;AAAA;;;;;;;AHDC;AAGvC;iBGSgB,QAAA;EACd,QAAA;EACA;AAAA,GACC,aAAA,GAAgB,iBAAA;;;UCfF,mBAAA;;WAEN,IAAI;AAAA;;;;;;;;AJFwB;AAGvC;;;;;;;;;;;;;;;;AAGsC;;;;ACRtC;;;;;;;;;AAEuC;AAGvC;;;;;;;iBG+CgB,cAAA;EACd;AAAA,GACC,mBAAA,GAAsB,iBAAA;;;;;;AJtDzB;;;;;;;;;AAEuC;AAGvC;;;;;;;UKWiB,cAAA;EACf,IAAI;AAAA;AAAA,iBAGU,oBAAA,IAAwB,cAAc;;;UCjBrC,uBAAA;EAAA,SACN,IAAA,EAAM,cAAA;EAAA,SACN,QAAA,EAAU,iBAAiB;AAAA;AAAA,iBAGtB,kBAAA;EACd,IAAA;EACA;AAAA,GACC,uBAAA,GAA0B,iBAAA;;;;;;ANX7B;;;;iBOcgB,WAAA,cAAyB,GAAA,WAAc,OAAO,CAAC,CAAA"}
package/dist/esm/ssr.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{t as e}from"./useRoute-BSPVVbLz.mjs";import{useContext as t,useEffect as n,useState as r}from"preact/hooks";import{createContext as i}from"preact";import{Suspense as a}from"preact/compat";import{jsx as o}from"preact/jsx-runtime";function s({children:e,fallback:t=null}){let[i,a]=r(!1);return n(()=>{a(!0)},[]),i?e:t}function c({children:e,fallback:t=null}){let[i,a]=r(!1);return n(()=>{a(!0)},[]),i?t:e}const l=new Promise(()=>{});function u(t){let{route:n}=e();return n.context.ssrDataDeferred?.[t]??l}function d(e){let t=e;return t.status===void 0?(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)}),t):t}function f({name:e,children:t}){let n=u(e),r=d(n);if(r.status===`fulfilled`)return t(r.value);throw r.status===`rejected`?r.reason:n}function p({fallback:e,children:t}){return o(a,{fallback:e,children:t})}const m=i(null);function h({sink:e,children:t}){return o(m.Provider,{value:e,children:t})}function g({code:e}){let n=t(m);return n&&(process.env.NODE_ENV!==`production`&&(!Number.isInteger(e)||e<100||e>999)&&console.error(`[real-router] <HttpStatusCode code={${String(e)}} /> received an invalid HTTP status code. Node's res.end() rejects values that are not an integer in [100, 999] — pass a real HTTP status (commonly 4xx/5xx).`),n.code=e),null}function _(){return{code:void 0}}export{f as Await,s as ClientOnly,g as HttpStatusCode,h as HttpStatusProvider,c as ServerOnly,p as Streamed,_ as createHttpStatusSink,u as useDeferred};
1
+ import{t as e}from"./useRoute-DdZuiE4J.mjs";import{useContext as t,useEffect as n,useState as r}from"preact/hooks";import{createContext as i}from"preact";import{Suspense as a}from"preact/compat";import{jsx as o}from"preact/jsx-runtime";function s({children:e,fallback:t=null}){let[i,a]=r(!1);return n(()=>{a(!0)},[]),i?e:t}function c({children:e,fallback:t=null}){let[i,a]=r(!1);return n(()=>{a(!0)},[]),i?t:e}const l=new Promise(()=>{});function u(t){let{route:n}=e();return n.context.ssrDataDeferred?.[t]??l}function d(e){let t=e;return t.status===void 0?(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)}),t):t}function f({name:e,children:t}){let n=u(e),r=d(n);if(r.status===`fulfilled`)return t(r.value);throw r.status===`rejected`?r.reason:n}function p({fallback:e,children:t}){return o(a,{fallback:e,children:t})}const m=i(null);function h({sink:e,children:t}){return o(m.Provider,{value:e,children:t})}function g({code:e}){let n=t(m);return n&&(process.env.NODE_ENV!==`production`&&(!Number.isInteger(e)||e<100||e>999)&&console.error(`[real-router] <HttpStatusCode code={${String(e)}} /> received an invalid HTTP status code. Node's res.end() rejects values that are not an integer in [100, 999] — pass a real HTTP status (commonly 4xx/5xx).`),n.code=e),null}function _(){return{code:void 0}}export{f as Await,s as ClientOnly,g as HttpStatusCode,h as HttpStatusProvider,c as ServerOnly,p as Streamed,_ as createHttpStatusSink,u as useDeferred};
2
2
  //# sourceMappingURL=ssr.mjs.map
@@ -1,2 +1,2 @@
1
1
  import{useContext as e}from"preact/hooks";import{createContext as t}from"preact";const n=t(null),r=t(null),i=t(null);function a(t,n){return()=>{let r=e(t);if(!r)throw Error(`${n} must be used within a RouterProvider`);return r}}const o=a(n,`useRoute`),s=()=>{let e=o();if(!e.route)throw Error(`useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?`);return e};export{a,r as i,i as n,n as r,s as t};
2
- //# sourceMappingURL=useRoute-BSPVVbLz.mjs.map
2
+ //# sourceMappingURL=useRoute-DdZuiE4J.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRoute-BSPVVbLz.mjs","names":[],"sources":["../../src/context.ts","../../src/hooks/useRoute.tsx"],"sourcesContent":["import { createContext } from \"preact\";\nimport { useContext } from \"preact/hooks\";\n\nimport type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\nimport type { Context } from \"preact\";\n\nexport const RouteContext = createContext<RouteContextType | null>(null);\n\nexport const RouterContext = createContext<Router | null>(null);\n\nexport const NavigatorContext = createContext<Navigator | null>(null);\n\nexport function createUseContextOrThrow<T>(\n context: Context<T | null>,\n hookName: string,\n): () => T {\n return () => {\n const value = useContext(context);\n\n if (!value) {\n throw new Error(`${hookName} must be used within a RouterProvider`);\n }\n\n return value;\n };\n}\n","import { createUseContextOrThrow, RouteContext } from \"../context\";\n\nimport type { RouteContext as RouteContextType } from \"../types\";\nimport type { Params, State } from \"@real-router/core\";\n\nconst useRouteContextOrThrow = createUseContextOrThrow(\n RouteContext,\n \"useRoute\",\n);\n\nexport const useRoute = <P extends Params = Params>(): Omit<\n RouteContextType<P>,\n \"route\"\n> & { route: State<P> } => {\n const routeContext = useRouteContextOrThrow();\n\n if (!routeContext.route) {\n throw new Error(\n \"useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?\",\n );\n }\n\n return routeContext as Omit<RouteContextType<P>, \"route\"> & {\n route: State<P>;\n };\n};\n"],"mappings":"iFAOA,MAAa,EAAe,EAAuC,IAAI,EAE1D,EAAgB,EAA6B,IAAI,EAEjD,EAAmB,EAAgC,IAAI,EAEpE,SAAgB,EACd,EACA,EACS,CACT,UAAa,CACX,IAAM,EAAQ,EAAW,CAAO,EAEhC,GAAI,CAAC,EACH,MAAU,MAAM,GAAG,EAAS,sCAAsC,EAGpE,OAAO,CACT,CACF,CCrBA,MAAM,EAAyB,EAC7B,EACA,UACF,EAEa,MAGc,CACzB,IAAM,EAAe,EAAuB,EAE5C,GAAI,CAAC,EAAa,MAChB,MAAU,MACR,mIACF,EAGF,OAAO,CAGT"}
1
+ {"version":3,"file":"useRoute-DdZuiE4J.mjs","names":[],"sources":["../../src/context.ts","../../src/hooks/useRoute.tsx"],"sourcesContent":["import { createContext } from \"preact\";\nimport { useContext } from \"preact/hooks\";\n\nimport type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\nimport type { Context } from \"preact\";\n\nexport const RouteContext = createContext<RouteContextType | null>(null);\n\nexport const RouterContext = createContext<Router | null>(null);\n\nexport const NavigatorContext = createContext<Navigator | null>(null);\n\nexport function createUseContextOrThrow<T>(\n context: Context<T | null>,\n hookName: string,\n): () => T {\n return () => {\n const value = useContext(context);\n\n if (!value) {\n throw new Error(`${hookName} must be used within a RouterProvider`);\n }\n\n return value;\n };\n}\n","import { createUseContextOrThrow, RouteContext } from \"../context\";\n\nimport type { RouteContext as RouteContextType } from \"../types\";\nimport type { Params, State } from \"@real-router/core\";\n\nconst useRouteContextOrThrow = createUseContextOrThrow(\n RouteContext,\n \"useRoute\",\n);\n\nexport const useRoute = <P extends Params = Params>(): Omit<\n RouteContextType<P>,\n \"route\"\n> & { route: State<P> } => {\n const routeContext = useRouteContextOrThrow();\n\n if (!routeContext.route) {\n throw new Error(\n \"useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?\",\n );\n }\n\n return routeContext as Omit<RouteContextType<P>, \"route\"> & {\n route: State<P>;\n };\n};\n"],"mappings":"iFAOA,MAAa,EAAe,EAAuC,IAAI,EAE1D,EAAgB,EAA6B,IAAI,EAEjD,EAAmB,EAAgC,IAAI,EAEpE,SAAgB,EACd,EACA,EACS,CACT,UAAa,CACX,IAAM,EAAQ,EAAW,CAAO,EAEhC,GAAI,CAAC,EACH,MAAU,MAAM,GAAG,EAAS,sCAAsC,EAGpE,OAAO,CACT,CACF,CCrBA,MAAM,EAAyB,EAC7B,EACA,UACF,EAEa,MAGc,CACzB,IAAM,EAAe,EAAuB,EAE5C,GAAI,CAAC,EAAa,MAChB,MAAU,MACR,mIACF,EAGF,OAAO,CAGT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/preact",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "commonjs",
5
5
  "description": "Preact integration for Real-Router",
6
6
  "main": "./dist/cjs/index.js",
@@ -64,9 +64,9 @@
64
64
  "license": "MIT",
65
65
  "sideEffects": false,
66
66
  "dependencies": {
67
- "@real-router/core": "^0.54.6",
68
- "@real-router/route-utils": "^0.2.2",
69
- "@real-router/sources": "^0.8.3"
67
+ "@real-router/route-utils": "^0.2.3",
68
+ "@real-router/core": "^0.56.0",
69
+ "@real-router/sources": "^0.8.5"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@testing-library/dom": "10.4.1",
@@ -75,7 +75,7 @@
75
75
  "@testing-library/user-event": "14.6.1",
76
76
  "preact": "10.29.2",
77
77
  "preact-render-to-string": "6.7.0",
78
- "@real-router/browser-plugin": "^0.17.4"
78
+ "@real-router/browser-plugin": "^0.17.6"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "preact": ">=10.28.0 || ^11.0.0-0"
@@ -8,6 +8,8 @@ import { Match, NotFound, Self } from "./components";
8
8
  import type { MatchProps, NotFoundProps, SelfProps } from "./types";
9
9
  import type { VNode, ComponentChildren } from "preact";
10
10
 
11
+ const MARKER_TYPES: ReadonlySet<unknown> = new Set([Match, Self, NotFound]);
12
+
11
13
  interface FallbackSlots {
12
14
  selfChildren: ComponentChildren;
13
15
  selfFallback: ComponentChildren | undefined;
@@ -40,11 +42,7 @@ export function collectElements(
40
42
  continue;
41
43
  }
42
44
 
43
- if (
44
- child.type === Match ||
45
- child.type === Self ||
46
- child.type === NotFound
47
- ) {
45
+ if (MARKER_TYPES.has(child.type)) {
48
46
  result.push(child);
49
47
  } else {
50
48
  collectElements(