Skip to content

Commit

Permalink
Merge pull request #35 from EisenbergEffect/main
Browse files Browse the repository at this point in the history
fix: remove reliance on top level await and external polyfill/helper
  • Loading branch information
fabiancook authored Oct 16, 2024
2 parents a2333a9 + 82b8d91 commit 2fb3801
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 671 deletions.
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

0 comments on commit 2fb3801

Please sign in to comment.