Skip to content

Commit 46c0614

Browse files
authored
[refactor] merge Page containers into one Router component (#15)
1 parent 505fe31 commit 46c0614

File tree

8 files changed

+1526
-1596
lines changed

8 files changed

+1526
-1596
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- uses: pnpm/action-setup@v4
1616
with:
17-
version: 9
17+
version: 10
1818
- uses: actions/setup-node@v4
1919
with:
2020
node-version: 22

ReadMe.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,32 @@ https://web-cell.dev/cell-router/preview/
1313

1414
## Feature
1515

16-
- [x] `<iframe />`-like **Route Component** as a **Page Container**
16+
- [x] `<iframe />`-like **Route Component** as a **Page Container**
1717

18-
- [x] **Page Link** (support `<a />`, `<area />` & `<form />`)
18+
- [x] **Page Link** (support `<a />`, `<area />` & `<form />`)
1919

20-
- `<a href="route/path">Page title</a>`
21-
- `<a href="route/path" title="Page title">Example page</a>`
22-
- `<a href="#page-section">Page section</a>` (Scroll to an Anchor smoothly)
23-
- `<form method="get" action="route/path" />` (Form Data processed by `URLSearchParams`)
20+
- `<a href="route/path">Page title</a>`
21+
- `<a href="route/path" title="Page title">Example page</a>`
22+
- `<a href="#page-section">Page section</a>` (Scroll to an Anchor smoothly)
23+
- `<form method="get" action="route/path" />` (Form Data processed by `URLSearchParams`)
2424

25-
- [x] **Path Mode**: `location.hash` (default) & `history.pushState()`
25+
- [x] **Path Mode**: `location.hash` (default) & `history.pushState()`
2626

27-
- [x] **Async Loading** (based on `import()` ECMAScript syntax)
27+
- [x] **Async Loading** (based on `import()` ECMAScript syntax)
2828

29-
- [x] [View Transition API][7] based **Page Transition Animation**
29+
- [x] [View Transition API][7] based **Page Transition Animation**
30+
31+
## Version
32+
33+
| SemVer | status | WebCell | API | async page | page transition | nested router |
34+
| :------------------: | :----: | :-----: | :------------------------------: | :--------: | :-------------: | :-----------: |
35+
| `4.x` || `>=3.1` | HTML tags (+ JSON) ||||
36+
| `3.x` || `3.x` | HTML tags ||||
37+
| `2.x` || `2.x` | HTML tag + JSON ||||
38+
| `>=2.0.0-alpha.0 <2` || `2.x` | `abstract class` + JSON ||||
39+
| `1.x` || `1.x` | `abstract class` + ES decorators ||||
40+
| `>=0.9 <1.0` || `0.x` | `abstract class` + ES decorators ||||
41+
| `<0.9` || `0.x` | `class` + HTML tags ||||
3042

3143
## Installation
3244

@@ -70,7 +82,7 @@ npm install parcel @parcel/config-default @parcel/transformer-typescript-tsc -D
7082
```tsx
7183
import { DOMRenderer } from 'dom-renderer';
7284
import { FC } from 'web-cell';
73-
import { createRouter, PageProps } from 'cell-router';
85+
import { CellRouter, createRouter, PageProps } from 'cell-router';
7486

7587
const { Route, Link } = createRouter();
7688

@@ -93,14 +105,14 @@ new DOMRenderer().render(
93105
<Link to="test?a=1">Test</Link>
94106
<Link to="example/2">Example</Link>
95107
</nav>
96-
<main className="router">
108+
<CellRouter className="router">
97109
<Route
98110
path=""
99111
component={props => <div {...props}>Home Page</div>}
100112
/>
101113
<Route path="test" component={TestPage} />
102114
<Route path="example/:id" component={TestPage} />
103-
</main>
115+
</CellRouter>
104116
</>
105117
);
106118
```
@@ -122,7 +134,7 @@ new DOMRenderer().render(
122134
```tsx
123135
import { DOMRenderer } from 'dom-renderer';
124136
import { FC, lazy } from 'web-cell';
125-
import { createRouter, PageProps } from 'cell-router';
137+
import { CellRouter, createRouter, PageProps } from 'cell-router';
126138

127139
const { Route, Link } = createRouter();
128140

@@ -146,14 +158,14 @@ new DOMRenderer().render(
146158
<Link to="test?a=1">Test</Link>
147159
<Link to="example/2">Example</Link>
148160
</nav>
149-
<main className="router">
161+
<CellRouter className="router">
150162
<Route
151163
path=""
152164
component={props => <div {...props}>Home Page</div>}
153165
/>
154166
<Route path="test" component={TestPage} />
155167
<Route path="example/:id" component={AsyncPage} />
156-
</main>
168+
</CellRouter>
157169
</>
158170
);
159171
```

package.json

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cell-router",
3-
"version": "3.0.3",
3+
"version": "4.0.0",
44
"license": "LGPL-3.0",
55
"description": "Web Component Router based on WebCell & MobX",
66
"keywords": [
@@ -24,39 +24,47 @@
2424
"main": "dist/index.js",
2525
"module": "dist/index.esm.js",
2626
"dependencies": {
27-
"@swc/helpers": "^0.5.15",
27+
"@swc/helpers": "^0.5.17",
2828
"dom-renderer": "^2.6.2",
29-
"mobx": "^6.13.6",
29+
"mobx": "^6.13.7",
3030
"regenerator-runtime": "^0.14.1",
31-
"urlpattern-polyfill": "^10.0.0",
32-
"web-cell": "^3.0.3",
31+
"urlpattern-polyfill": "^10.1.0",
32+
"web-cell": "^3.1.0",
3333
"web-utility": "^4.4.3"
3434
},
3535
"devDependencies": {
36-
"@parcel/config-default": "~2.13.3",
37-
"@parcel/packager-ts": "~2.13.3",
38-
"@parcel/transformer-less": "~2.13.3",
39-
"@parcel/transformer-typescript-tsc": "~2.13.3",
40-
"@parcel/transformer-typescript-types": "~2.13.3",
36+
"@parcel/config-default": "~2.15.2",
37+
"@parcel/packager-ts": "~2.15.2",
38+
"@parcel/transformer-less": "~2.15.2",
39+
"@parcel/transformer-typescript-tsc": "~2.15.2",
40+
"@parcel/transformer-typescript-types": "~2.15.2",
4141
"@types/jest": "^29.5.14",
4242
"cross-env": "^7.0.3",
43-
"dotenv": "^16.4.7",
44-
"element-internals-polyfill": "^3.0.1",
43+
"dotenv": "^16.5.0",
44+
"element-internals-polyfill": "^3.0.2",
4545
"fs-match": "^1.7.3",
4646
"husky": "^9.1.7",
4747
"jest": "^29.7.0",
4848
"jest-environment-jsdom": "^29.7.0",
4949
"koapache": "^2.2.2",
50-
"lint-staged": "^15.4.3",
51-
"parcel": "~2.13.3",
50+
"lint-staged": "^16.1.1",
51+
"parcel": "~2.15.2",
5252
"prettier": "^3.5.3",
5353
"process": "^0.11.10",
54-
"puppeteer-core": "^24.4.0",
54+
"puppeteer-core": "^24.10.1",
5555
"rimraf": "^6.0.1",
56-
"ts-jest": "^29.2.6",
57-
"typedoc": "^0.27.9",
58-
"typedoc-plugin-mdn-links": "^5.0.1",
59-
"typescript": "~5.8.2"
56+
"ts-jest": "^29.4.0",
57+
"typedoc": "^0.28.5",
58+
"typedoc-plugin-mdn-links": "^5.0.2",
59+
"typescript": "~5.8.3"
60+
},
61+
"pnpm": {
62+
"onlyBuiltDependencies": [
63+
"@parcel/watcher",
64+
"@swc/core",
65+
"lmdb",
66+
"msgpackr-extract"
67+
]
6068
},
6169
"scripts": {
6270
"prepare": "husky && app-find chrome msedge firefox -c",

0 commit comments

Comments
 (0)