Skip to content
Open
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
12 changes: 10 additions & 2 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ renderer's test setup, `src/renderer/test-setup.mts`, enforces this: when React
logs one, the test that logged it fails with
`React updated X outside act()`.

It also fails a test on a function or `React.memo` component that sets
`defaultProps` (`X set defaultProps on a function or memo component`), which React 19 drops. In our
code, use default parameter values instead. From a dependency, upgrade it. If the
version that fixes it is ESM-only, the renderer can't `import` it while it
compiles to CommonJS; load it the way
`src/renderer/src/util/react_markdown/ReactMarkdown.tsx` loads
react-markdown.

The check is there because nothing else surfaces these warnings. Vitest's
default reporter hides a test's console output, so a run that logs dozens of
warnings still looks clean, and a passing CI log doesn't get read. The suite was
Expand Down Expand Up @@ -114,8 +122,8 @@ The usual sources:
- An update that lands after testing-library's cleanup fails the next test in
the file, or the file's `afterAll` after its last test, rather than the test
that caused it.
- Only `act()` warnings fail a test. The deprecation warnings still in the log
(`findDOMNode`, `defaultProps`, legacy `contextTypes`) come from older code:
- Only `act()` and `defaultProps` warnings fail a test. The deprecation warnings
still in the log (`findDOMNode`, legacy `contextTypes`) come from older code:
class components built on `ComponentEx` in `src/renderer/src/controls/`, and
old dependencies such as `react-bootstrap` 0.33. Clearing them means changing
that code, not the tests.
Expand Down
2 changes: 2 additions & 0 deletions packages/vortex-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
### Deprecated

- `IMainPageOptions.mdi` is deprecated in favour of `menuIcon: { path }`. It still works, as a `menuIcon` path
- The `react-markdown` 6 props that 9 dropped (`transformLinkUri`, `transformImageUri`, `linkTarget`, and the ones 6 had already deprecated, such as `renderers` and `source`) log a deprecation warning. `transformLinkUri` and `transformImageUri` still run, and `plugins` runs as `remarkPlugins`, as it did in 6; the rest are ignored - see the [react-markdown section of the migration guide](./docs/MIGRATION.md#vortex-2x-react-markdown-9)
- A filesystem path in a game info entry with `type: "url"` is deprecated in favour of `type: "path"`. It still opens as a path, in the game info popover and the game details dialog, and logs a warning naming the provider

### Changed

- React peer dependency upgraded to 18.3.1; `@types/react` and `@types/react-dom` peer dependencies are now 18. Extension source may need type-level fixes on next rebuild (explicit `children` props, removed type aliases) - see the [React 18 section of the migration guide](./docs/MIGRATION.md#vortex-2x-react-18)
- `react-markdown` supplied at runtime is now 9.1.0 instead of 6.0.3. Every way of importing 6 still works. Links only open if they go to a web page or an email address, images from network shares don't load, and remark or rehype plugins made for 6 are dropped when they throw. Custom components no longer get 6's `inline`, `level`, `ordered`, `index`, `checked` or `isHeader` props - see the [react-markdown section of the migration guide](./docs/MIGRATION.md#vortex-2x-react-markdown-9)
- `IExtensionContext` registration surfaces and `IMainPage` now use `React.FC` instead of the removed `React.StatelessComponent` (source-compatible)
- `registerReducer` checks its spec against the state at its path. A path the state interfaces don't declare, or a spec whose type doesn't match the slice, now fails the typecheck. Runtime behaviour is unchanged, and already-built extensions keep working. Declare your slice by augmenting the state interfaces - see the [reducer section of the migration guide](./docs/MIGRATION.md#vortex-2x-typed-registerreducer)
- `actions.showURL` takes all four arguments (`url`, `instructions`, `subscriber`, `skippable`); pass `undefined` for the ones you don't use. Previously only `url` was required. Runtime behaviour is unchanged
Expand Down
32 changes: 32 additions & 0 deletions packages/vortex-api/docs/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,35 @@ const interfaceReducer = util.actionsToPartialReducerSpec<
### Building the path at runtime

`registerReducer` needs the path as a literal, such as `["settings", "myExtension"]`, so it can look the slice up. A path held in a `string[]` variable fails the typecheck. Pass the literal at the call.

## Vortex 2.x: `react-markdown` 9

Vortex now supplies `react-markdown` **9.1.0** to extensions at runtime, in place of 6.0.3. If your extension bundles its own copy, nothing changes. If it uses Vortex's copy (`require("react-markdown")`, or an import your bundler leaves external), read on.

### What keeps working

- Every way of importing 6: `require`, `import ReactMarkdown from`, `import * as` and `import =`. You get a component that is also its own `.default`, and carries 9's other exports (`defaultUrlTransform`, `MarkdownAsync`, `MarkdownHooks`) and 6's `uriTransformer`. `MarkdownAsync` and `MarkdownHooks` filter links and images as the component does.
- `transformLinkUri` and `transformImageUri` still run, as 9's `urlTransform` would. They log a deprecation warning.
- `plugins` still runs, as `remarkPlugins`, unless you pass `remarkPlugins` too, as in 6. It logs a deprecation warning.

### What changes

- **Links only open if they go to a web page (`http`, `https`) or an email address (`mailto:`).** Any other link renders with no target and does nothing when clicked: app links (`steam:`, `nxm:`), `file:` and `tel:` links, relative links (`../run.exe`) and network paths (`//server/share`). This holds with your own `components.a` and your own `urlTransform` too: Vortex filters the URL after your transform runs.
- **Images from network shares don't load.** An image keeps its source if it's a web address, a `data:` address, or a file on the user's machine (`file:///C:/...`, or a relative path). `//host/share/x.png` and `file://host/share/x.png` render with no source.
- **Links lose their `title`** when you use the default link component.
- **6's removed props are ignored** and log a deprecation warning: `linkTarget`, `includeElementIndex`, `rawSourcePos`, `sourcePos`, and the ones 6 had already deprecated (`renderers`, `source`, `allowedTypes`, `disallowedTypes`, `allowNode`, `includeNodeIndex`, `escapeHtml`, `allowDangerousHtml`, `astPlugins`).

### What you need to change

| react-markdown 6 | react-markdown 9 |
| ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `linkTarget="_blank"` | `components={{ a: ... }}` |
| `transformLinkUri`, `transformImageUri` | `urlTransform={(url, key, node) => ...}` |
| `ReactMarkdown.uriTransformer` | `defaultUrlTransform` |
| `plugins` | `remarkPlugins` |
| `inline`, `level`, `ordered`, `index`, `checked` and `isHeader` props on a custom component | gone: use a component per tag (`h1`, `h2`, ...), or read the element from the `node` prop |
| remark and rehype plugins made for 6 | versions made for 9, such as `remark-gfm` 4 |

Plugins made for 6 (for example `remark-gfm` 1.x) throw under 9. Vortex runs your `remarkPlugins` and `rehypePlugins` on the markdown on their own first. If they throw, it shows the markdown without them and logs a warning, so tables and other syntax the plugin added show as plain text until you update it. It checks again whenever the markdown or the plugins change. An error from your own components isn't caught: it goes up to your error boundary, as it did in 6.

A custom component that reads a prop 9 no longer passes gets `undefined`: a `code` that checks `inline` renders inline code as a block, for example.
Loading