-
- Router.go('overview')} />
- Router.go('about')} />
- Router.go('article', { id: 1 })} />
- Router.go('article', { id: 2 })} />
- Router.go('article', { id: 3 })} />
- Router.go('nested/overview')} />
+ go('overview')} />
+ go('about')} />
+ go('article', { id: 1 })} />
+ go('article', { id: 2 })} />
+ go('article', { id: 3 })} />
+ go('nested/overview')} />
diff --git a/demo/package.json b/demo/package.json
index 11f12c6..8c6aafb 100644
--- a/demo/package.json
+++ b/demo/package.json
@@ -1,16 +1,23 @@
{
- "papua": {
- "title": "epic-router Demo",
- "icon": "../logo.png",
- "publicPath": "/"
+ "name": "demo",
+ "scripts": {
+ "start": "rsbuild dev --open",
+ "types": "tsc"
},
"dependencies": {
- "epic-router": "^4.1.0",
+ "@rsbuild/core": "^0.6.8",
+ "@rsbuild/plugin-react": "^0.6.8",
+ "epic-state": "^0.6.0",
"exmpl": "^3.1.0",
- "papua": "^5.9.7",
- "preact": "^10.19.5"
+ "preact": "^10.19.5",
+ "typescript": "^5.4.5",
+ "zero-configuration": "^0.13.0"
},
"localDependencies": {
"epic-router": ".."
- }
+ },
+ "trustedDependencies": [
+ "zero-configuration"
+ ],
+ "type": "module"
}
diff --git a/demo/rspack.config.js b/demo/rspack.config.js
deleted file mode 100644
index b6eae27..0000000
--- a/demo/rspack.config.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// Configure preact transformer.
-export default (configuration) => {
- // NOTE react installed in parent folder will interfere.
- configuration.resolve.alias = {
- react: 'preact/compat',
- 'react-dom/test-utils': 'preact/test-utils',
- 'react-dom': 'preact/compat',
- 'react/jsx-runtime': 'preact/jsx-runtime',
- 'react/jsx-dev-runtime': 'preact/jsx-dev-runtime',
- }
-
- return configuration
-}
diff --git a/index.tsx b/index.tsx
index 0eece05..af833b2 100644
--- a/index.tsx
+++ b/index.tsx
@@ -1,10 +1,12 @@
import { state } from 'epic-state'
-import { connect } from 'epic-state/preact'
+import type { connect as preactConnect } from 'epic-state/preact'
import { createBrowserHistory, createMemoryHistory } from 'history'
import queryString from 'query-string'
+import type { ComponentPropsWithoutRef, JSX } from 'react'
import join from 'url-join'
-import type { JSX } from 'react'
-import type { Input, RouterState } from './types'
+import type { PageComponent, RouterState } from './types'
+
+let Router: RouterState = {} as RouterState
const createHistory = () => {
if (typeof window !== 'undefined' && process.env.NODE_ENV !== 'test') {
@@ -37,14 +39,14 @@ function Code({ children }: { children: string | string[] }) {
)
}
-function Error(message: JSX.Element) {
+function ErrorPage(message: JSX.Element): PageComponent {
return () =>