Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove reliance on top level await and external polyfill/helper #35

Merged
merged 9 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ await navigation.navigate("/").finished;
<details><summary>Polyfill Global Window Types</summary>

See [`@types/dom-navigation`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/dom-navigation/package.json) for a standardised type definition for the Navigation API
which can be utilised alongside this polyfill.
which can be utilised alongside this polyfill.

```bash
yarn add --dev @types/dom-navigation
Expand All @@ -219,4 +219,39 @@ This should then be included as a type in your `tsconfig.json`:
}
```

</details>

<details><summary>Polyfill Serializer</summary>

You may want to set a custom serializer to store state in history

The default serializer is [JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON)

In the past, a [structured clone like serializer](https://www.npmjs.com/package/@ungap/structured-clone) was used. This may be useful for you if
you're using native types rather than just JSON compatible values.

An example of making use of a custom serializer with the polyfill:

```typescript
import { setSerializer } from "@virtualstate/navigation/polyfill";
import { serialize, deserialize } from "@ungap/structured-clone";

setSerializer({
stringify(value) {
return serialize(value)
},
parse(value) {
return deserialize(value)
}
});
```

</details>

## What's Changed

<details><summary>Change Log</summary>

- (1.0.1-alpha.x) Updated default serializer for polyfill to JSON [#35](https://github.com/virtualstate/navigation/pull/35)

</details>
300 changes: 17 additions & 283 deletions example/polyfill-rollup.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading