Skip to content

Commit 29a0ac9

Browse files
committed
Merge remote-tracking branch 'origin/main' into vk/6a7c-loader-data-inva
2 parents b51d934 + d74ed94 commit 29a0ac9

File tree

7 files changed

+47
-7
lines changed

7 files changed

+47
-7
lines changed

docs/components/ChangelogContent.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 2026.01.29
2+
3+
Add encode option to Route interface for converting activity params to URL string params [`45fb7ba`](https://github.com/daangn/stackflow/commit/45fb7ba271b8aaf754d25c2a241e54bd15bdd2dc)
4+
5+
Released packages:
6+
- 📦 [@stackflow/plugin-history-sync@1.10.0](https://npmjs.com/package/@stackflow/plugin-history-sync/v/1.10.0)
7+
8+
---
9+
110
## 2026.01.07
211

312
Add an option to skip default history setup transition [`a7d0c01`](https://github.com/daangn/stackflow/commit/a7d0c01c171001e6d99432a1df2242ef8faca011)

docs/pages/api-references/plugins/plugin-basic-ui.ko.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const { Stack, useFlow } = stackflow({
2929
```
3030
### `basicUIPlugin` 옵션
3131
<APITable>
32-
| ---- | ---- | ---- |
3332
| | | |
33+
| ---- | ---- | ---- |
3434
| theme | `cupertino` \| `android` | 테마를 설정해요. |
3535
| rootClassName | `string`(optional) | 루트 클래스 이름을 설정해요. |
3636
| appBar | `AppBar`(optional) | 앱 바를 설정해요. |
@@ -49,8 +49,8 @@ const Something = () => {
4949
```
5050
### `appBar`
5151
<APITable>
52-
| ---- | ---- | ---- |
5352
| | | |
53+
| ---- | ---- | ---- |
5454
| backButton | `{ renderIcon?: () => ReactNode; ariaLabel?: string }` \| `{ render?: () => ReactNode }` | 뒤로가기 버튼을 설정해요. |
5555
| closeButton | `{ renderIcon?: () => ReactNode; ariaLabel?; string, onClick: (e) => void; }` \| `{ render?: () => ReactNode }` | 닫기 버튼을 설정해요. |
5656
</APITable>

extensions/plugin-history-sync/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @stackflow/plugin-history-sync
22

3+
## 1.10.0
4+
5+
### Minor Changes
6+
7+
- 45fb7ba: Add encode option to Route interface for converting activity params to URL string params
8+
39
## 1.9.0
410

511
### Minor Changes

extensions/plugin-history-sync/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stackflow/plugin-history-sync",
3-
"version": "1.9.0",
3+
"version": "1.10.0",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/daangn/stackflow.git",

extensions/plugin-history-sync/src/RouteLike.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export type Route<ComponentType> = {
99
decode?: (
1010
params: Record<string, string>,
1111
) => ComponentType extends ActivityComponentType<infer U> ? U : {};
12+
encode?: (
13+
params: ComponentType extends ActivityComponentType<infer U>
14+
? U
15+
: Record<string, any>,
16+
) => Record<string, string | undefined>;
1217
defaultHistory?: (
1318
params: Record<string, string>,
1419
) => HistoryEntry[] | DefaultHistoryDescriptor;

extensions/plugin-history-sync/src/makeTemplate.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,20 @@ test("makeTemplate - parse with given decode function", () => {
7676
articleId: 1234,
7777
});
7878
});
79+
80+
test("makeTemplate - fill with encode function using JSON.stringify for object params", () => {
81+
const template = makeTemplate({
82+
path: "/search",
83+
encode: (params) => ({
84+
filter: JSON.stringify(params.filter),
85+
}),
86+
});
87+
88+
expect(
89+
template.fill({
90+
filter: { category: "tech", tags: ["javascript", "react"] },
91+
}),
92+
).toEqual(
93+
"/search/?filter=%7B%22category%22%3A%22tech%22%2C%22tags%22%3A%5B%22javascript%22%2C%22react%22%5D%7D",
94+
);
95+
});

extensions/plugin-history-sync/src/makeTemplate.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface UrlPatternOptions {
4646
}
4747

4848
export function makeTemplate<T>(
49-
{ path, decode }: Route<T>,
49+
{ path, decode, encode }: Route<T>,
5050
urlPatternOptions?: UrlPatternOptions,
5151
) {
5252
const pattern = new UrlPattern(`${path}(/)`, urlPatternOptions);
@@ -58,11 +58,14 @@ export function makeTemplate<T>(
5858
: (pattern as any).names.length;
5959

6060
return {
61-
fill(params: { [key: string]: string | undefined }) {
62-
const pathname = pattern.stringify(params);
61+
fill(params: { [key: string]: any }) {
62+
const encodedParams: { [key: string]: string | undefined } = encode
63+
? encode(params as Parameters<typeof encode>[0])
64+
: params;
65+
const pathname = pattern.stringify(encodedParams);
6366
const pathParams = pattern.match(pathname);
6467

65-
const searchParamsMap = { ...params };
68+
const searchParamsMap = { ...encodedParams };
6669

6770
Object.keys(pathParams).forEach((key) => {
6871
delete searchParamsMap[key];

0 commit comments

Comments
 (0)