Commit Graph

348 Commits

Author SHA1 Message Date
8aa35a14fb chore(deps): update dependency p5 to v2 2025-04-29 11:56:25 +08:00
6b52b7e87c chore(deps): update lint dependencies 2025-04-28 20:02:41 +08:00
严浩
dd1af6964d feat(deps): add vite-plugin-image-tools dependency 2025-04-27 22:59:23 +08:00
0ceaa5a583 chore(deps): update dependency @intlify/unplugin-vue-i18n to ^6.0.8 2025-04-27 18:21:19 +08:00
608cd08ca5 chore(deps): update types 2025-04-25 20:22:47 +08:00
09e727dad5 chore(deps): update dependency tdesign-icons-vue-next to ^0.3.6 2025-04-24 10:39:43 +08:00
4d6380f141 chore(deps): update dependency eslint-plugin-perfectionist to ^4.12.2 2025-04-24 07:34:15 +08:00
11acb951d4 chore(deps): update dependency three to ^0.176.0 2025-04-23 18:15:02 +08:00
94472a4d8d chore(deps): update lint dependencies 2025-04-22 11:33:38 +08:00
74d4f87f4b chore(deps): update v0.x 2025-04-22 09:35:50 +08:00
67cee3b845 chore(deps): update lint dependencies to ^0.16.7 2025-04-22 09:35:13 +08:00
71b768b3a2 chore(deps): update devdependencies 2025-04-22 08:42:06 +08:00
2cc080c579 chore(deps): update vite packages 2025-04-21 13:40:13 +08:00
5354f942e6 chore(deps): update dependency @intlify/unplugin-vue-i18n to ^6.0.7 2025-04-21 10:36:33 +08:00
e0445a2737 chore(deps): update playwright packages 2025-04-21 01:45:58 +08:00
8e9e4ca392 chore(deps): update dependency @types/node to ^22.14.1 2025-04-20 23:25:18 +08:00
b85df83f8c chore(deps): update dependency @intlify/unplugin-vue-i18n to ^6.0.6 2025-04-20 12:06:24 +08:00
严浩
95d5087b5e feat: add Plotly.js usage page 2025-04-17 14:57:17 +08:00
42094e3571 chore(deps): update dependency @primeuix/themes to ^1.0.3 2025-04-16 21:46:04 +08:00
严浩
5766bb828e chore: update satellite.js to version 6.0.0 and improve position validation in calculations 2025-04-15 17:02:52 +08:00
严浩
22e5c31f58 SortableJS.page.vue 2025-04-15 14:17:43 +08:00
b43b076b9d chore(deps): update lint dependencies to ^0.16.6 2025-04-14 21:49:05 +08:00
d47c02f743 chore(deps): update dependency vite to ^6.2.6 2025-04-14 21:46:01 +08:00
391e4fcb85 chore(deps): update dependency unplugin-vue-components to ^28.5.0 2025-04-14 21:45:25 +08:00
1a4a169222 chore(deps): update dependency vite-plugin-static-copy to ^2.3.1 2025-04-09 20:18:16 +08:00
2cec135a8f chore(deps): update all non-major dependencies 2025-04-09 19:14:37 +08:00
严浩
1a7831c003 升级依赖 2025-04-08 15:48:43 +08:00
mini2024
9e8affc52d chore: 更新项目配置并添加 p5.js 粒子演示 2025-04-06 21:38:06 +08:00
mini2024
3cad491aac Merge remote-tracking branch 'origin/main' 2025-04-06 03:03:17 +08:00
mini2024
f77b63cb8c chore: 移除 @unocss/preset-rem-to-px 依赖 2025-04-06 03:03:07 +08:00
a42282212e chore(deps): update lint dependencies to ^0.16.4 (patch) (#175) [no ci]
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [eslint-plugin-oxlint](https://github.com/oxc-project/eslint-plugin-oxlint) | [`^0.16.3` -> `^0.16.4`](https://renovatebot.com/diffs/npm/eslint-plugin-oxlint/0.16.3/0.16.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/eslint-plugin-oxlint/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/eslint-plugin-oxlint/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/eslint-plugin-oxlint/0.16.3/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/eslint-plugin-oxlint/0.16.3/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [oxlint](https://oxc.rs) ([source](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint)) | [`^0.16.3` -> `^0.16.4`](https://renovatebot.com/diffs/npm/oxlint/0.16.3/0.16.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/oxlint/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/oxlint/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/oxlint/0.16.3/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/oxlint/0.16.3/0.16.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>oxc-project/eslint-plugin-oxlint (eslint-plugin-oxlint)</summary>

### [`v0.16.4`](https://github.com/oxc-project/eslint-plugin-oxlint/releases/tag/v0.16.4)

[Compare Source](https://github.com/oxc-project/eslint-plugin-oxlint/compare/v0.16.3...v0.16.4)

*No significant changes*

#####     [View changes on GitHub](https://github.com/oxc-project/eslint-plugin-oxlint/compare/v0.16.3...v0.16.4)

</details>

<details>
<summary>oxc-project/oxc (oxlint)</summary>

### [`v0.16.4`](https://github.com/oxc-project/oxc/releases/tag/oxlint_v0.16.4): oxlint v0.16.4

[Compare Source](https://github.com/oxc-project/oxc/compare/oxlint_v0.16.3...oxlint_v0.16.4)

#### \[0.16.4] - 2025-04-01

-   [`da6336c`](https://github.com/oxc-project/oxc/commit/da6336c) language_server: \[**BREAKING**] Remove `enable` configuration, the client should shutdown the server instead ([#&#8203;9990](https://github.com/oxc-project/oxc/issues/9990)) (Sysix)

##### Features

-   [`06e3db9`](https://github.com/oxc-project/oxc/commit/06e3db9) linter: Support `multipleFileExtensions` option for `unicorn/filename-case` ([#&#8203;10118](https://github.com/oxc-project/oxc/issues/10118)) (shulaoda)
-   [`dbe0e46`](https://github.com/oxc-project/oxc/commit/dbe0e46) linter: Support `ignore` option for `unicorn/filename-case` ([#&#8203;10107](https://github.com/oxc-project/oxc/issues/10107)) (shulaoda)

##### Bug Fixes

-   [`0a33e27`](https://github.com/oxc-project/oxc/commit/0a33e27) editor: Update `initializationOptions` for a possible restart ([#&#8203;10121](https://github.com/oxc-project/oxc/issues/10121)) (Sysix)
-   [`ac780a2`](https://github.com/oxc-project/oxc/commit/ac780a2) editor: Repair filewatchers when no custom config provided ([#&#8203;10104](https://github.com/oxc-project/oxc/issues/10104)) (Sysix)
-   [`4303ace`](https://github.com/oxc-project/oxc/commit/4303ace) editor: Dont send `didChangeConfiguration` request to the server when it is shutdown ([#&#8203;10084](https://github.com/oxc-project/oxc/issues/10084)) (Sysix)
-   [`07f2a25`](https://github.com/oxc-project/oxc/commit/07f2a25) editor: Enable regex parsing in language server ([#&#8203;10035](https://github.com/oxc-project/oxc/issues/10035)) (camchenry)
-   [`fcf7702`](https://github.com/oxc-project/oxc/commit/fcf7702) language_server: Start from a default oxlint configuration + SafeFix for nested configuration ([#&#8203;10043](https://github.com/oxc-project/oxc/issues/10043)) (Sysix)
-   [`aba3654`](https://github.com/oxc-project/oxc/commit/aba3654) linter: Span disable directive correctly on next line ([#&#8203;10141](https://github.com/oxc-project/oxc/issues/10141)) (Ulrich Stark 🦀)
-   [`2c80858`](https://github.com/oxc-project/oxc/commit/2c80858) linter: Enable multi-file analysis for nested configs ([#&#8203;10089](https://github.com/oxc-project/oxc/issues/10089)) (camchenry)

##### Performance

-   [`566be59`](https://github.com/oxc-project/oxc/commit/566be59) linter: Replace `phf_set` with `array` in `eslint/func-names` ([#&#8203;10119](https://github.com/oxc-project/oxc/issues/10119)) (shulaoda)
-   [`5e14fe9`](https://github.com/oxc-project/oxc/commit/5e14fe9) linter: Inline `PRE_DEFINE_VAR` and use `array` format ([#&#8203;10079](https://github.com/oxc-project/oxc/issues/10079)) (shulaoda)

##### Refactor

-   [`327be53`](https://github.com/oxc-project/oxc/commit/327be53) editor: `LanguageClient` can be undefined ([#&#8203;10112](https://github.com/oxc-project/oxc/issues/10112)) (Sysix)
-   [`5ec477c`](https://github.com/oxc-project/oxc/commit/5ec477c) editor: Make `onConfigChange` async ([#&#8203;10110](https://github.com/oxc-project/oxc/issues/10110)) (Sysix)
-   [`a278d73`](https://github.com/oxc-project/oxc/commit/a278d73) editor: Use warning background when the plugin is deactived ([#&#8203;10085](https://github.com/oxc-project/oxc/issues/10085)) (Sysix)
-   [`c0e5251`](https://github.com/oxc-project/oxc/commit/c0e5251) language_server: Set `null` as a default value for `configPath` ([#&#8203;10047](https://github.com/oxc-project/oxc/issues/10047)) (Sysix)
-   [`09c0ac6`](https://github.com/oxc-project/oxc/commit/09c0ac6) linter: Improve `unicorn/filename-case` ([#&#8203;10117](https://github.com/oxc-project/oxc/issues/10117)) (shulaoda)
-   [`d8e49a1`](https://github.com/oxc-project/oxc/commit/d8e49a1) linter: Compute lintable extensions at compile time ([#&#8203;10090](https://github.com/oxc-project/oxc/issues/10090)) (camchenry)
-   [`b3ec235`](https://github.com/oxc-project/oxc/commit/b3ec235) linter: Use items of `oxc_ast::ast` module directly ([#&#8203;10100](https://github.com/oxc-project/oxc/issues/10100)) (Ulrich Stark 🦀)
-   [`93e6c0b`](https://github.com/oxc-project/oxc/commit/93e6c0b) linter: Use `FormalParameter::has_modifier` to detect parameter properties ([#&#8203;10097](https://github.com/oxc-project/oxc/issues/10097)) (Ulrich Stark 🦀)

##### Testing

-   [`410b8d6`](https://github.com/oxc-project/oxc/commit/410b8d6) editor: Use debug build of the language server ([#&#8203;10083](https://github.com/oxc-project/oxc/issues/10083)) (Sysix)
-   [`500add0`](https://github.com/oxc-project/oxc/commit/500add0) editor: Add test for `oxc.fixAll` command ([#&#8203;10045](https://github.com/oxc-project/oxc/issues/10045)) (Sysix)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMzAuMSIsInVwZGF0ZWRJblZlciI6IjM5LjIzMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Reviewed-on: https://git.1-h.cc/examples/vue-ts-example/pulls/175
Co-authored-by: Renovate Bot <renovatebot@oo1.dev>
Co-committed-by: Renovate Bot <renovatebot@oo1.dev>
2025-04-06 01:44:29 +08:00
0344b51b40 chore(deps): update dependency typescript to ~5.8.3 2025-04-05 21:44:17 +08:00
bd4dd95c2a chore(deps): update dependency @primeuix/themes to ^1.0.1 2025-04-04 00:21:10 +08:00
严浩
2bc762a89b feat: 更新 ESLint 配置 2025-04-02 11:27:09 +08:00
9ed4c0bc6b chore(deps): update dependency primelocale to ^2.1.2 2025-04-02 10:01:34 +08:00
严浩
162f9a9a13 feat: 添加 vite-plugin-checker 插件,配置 ESLint 和 Vue 类型检查 2025-04-02 09:51:35 +08:00
严浩
8f2a77702b feat: InspiraUI 2025-04-01 11:55:16 +08:00
32bc83e16e chore(deps): update dependency vite to ^6.2.4 2025-03-31 18:35:50 +08:00
严浩
b16c038be9 feat: 删除 OrbPro 相关文件和依赖,清理代码库 2025-03-31 15:15:54 +08:00
严浩
334b2485f5 feat: 添加 InspiraUI 组件和模式背景功能,更新依赖项 2025-03-31 14:11:30 +08:00
mini2024
2fd7f2fcbc feat: 更新配置和依赖项,启用 oxc 插件,移除 cdnImport 插件 2025-03-31 00:55:50 +08:00
mini2024
0cc1730b2c feat: 更新依赖 2025-03-31 00:38:50 +08:00
mini2024
8d0ed93ee0 feat: 添加 InspiraUI 组件 2025-03-30 23:45:01 +08:00
严浩
4b109a0829 chore(deps): 更新多个依赖项版本 2025-03-28 09:58:16 +08:00
mini2024
ba91e845d5 帮我把 @unhead/vue 的版本升级到 v2.0.2
---
title: Migrate Your TypeScript App To Unhead v2
description: Learn about how to migrate to TypeScript Unhead v2 from v1.
navigation:
  title: Upgrade Guide
---

## Introduction

With the release of Unhead v2, we now have first-class support for other frameworks. However, this guide will focus on
the changes that affec TypeScript users.

The high-level of Unhead v2 was to remove deprecations and remove the implicit context implementation.

### Legacy Support

Unhead v2 is mostly fully backwards compatible with Unhead v1.

While not recommended, if upgrading is not possible for you, you can change your imports to the following:

```diff [TypeScript]
-import { createServerHead, useHead } from 'unhead'
+import { createServerHead, useHead } from 'unhead/legacy'
```

This will be removed in a future minor version, so you should lock your dependencies to the version that works for you.

## Client / Server Subpath Exports

🚦 Impact Level: Critical

**⚠️ Breaking Changes:**

- `createServerHead()`{lang="ts"} and `createHead()`{lang="ts"} exports from `unhead` are removed

The path where you import `createHead` from has been updated to be a subpath export.

Please follow the updated installation instructions or simply update the import to use the subpath.

**Client bundle:**

```diff
-import { createServerHead } from 'unhead'
+import { createHead } from 'unhead/client'

// avoids bundling server plugins
createHead()
```

**Server bundle:**

```diff
-import { createServerHead } from 'unhead'
+import { createHead } from 'unhead/server'

// avoids bundling server plugins
-createServerHead()
+createHead()
```

## Removed Implicit Context

🚦 Impact Level: Critical

**⚠️ Breaking Changes:**

- `getActiveHead()`{lang="ts"}, `activeHead`{lang="ts"} exports are removed

The implicit context implementation kept a global instance of Unhead available so that you could use the `useHead()`{lang="ts"} composables
anywhere in your application.

```ts
useHead({
  title: 'This just worked!'
})
```

While safe client side, this was a leaky abstraction server side and led to memory leaks in some cases.

In v2, the core composables no longer have access to the Unhead instance. Instead, you must pass the Unhead instance to the composables.

::note
Passing the instance is only relevant if you're importing from `unhead`. In JavaScript frameworks we tie the context to the framework itself so you
don't need to worry about this.
::

::code-group

```ts [TypeScript v2]
import { useHead } from 'unhead'

// example of getting the instance
const unheadInstance = useMyApp().unhead
useHead(unheadInstance, {
  title: 'Looks good'
})
```

```ts [TypeScript v1]
import { useHead } from 'unhead'

useHead({
  title: 'Just worked! But with SSR issues'
})
```

::

## Removed `vmid`, `hid`, `children`, `body`

🚦 Impact Level: High

For legacy support with Vue Meta we allowed end users to provide deprecated properties:  `vmid`, `hid`, `children` and `body`.

You must either update these properties to the appropriate replacement, remove them, or you can use the `DeprecationsPlugin`.

**Meta tags with `vmid`, `hid`**

These are already deduped magically so you can safely remove them there.

```diff
useHead({
  meta: [{
    name: 'description',
-   vmid: 'description'
-   hid: 'description'
  }]
})
```

**Other Tags with `vmid`, `hid`**

Use `key` if you need the deduplication feature. This is useful for tags that may change from server to client
rendering.

```diff
useHead({
  script: [{
-   vmid: 'my-key'
-   hid: 'my-key'
+   key: 'my-key',
  }]
})
```

**Using `children`**

The `children` key is a direct replacement of `innerHTML` which you should use instead.

::Caution
When migrating your code ensure that you're not dynamically setting `innerHTML` as this can lead to XSS vulnerabilities.
::

```diff
useHead({
  script: [
      {
-        children: '..'
+        innerHTML: '..'
      }
   ]
})
```

**Using `body`**

The `body` key should be updated to use the Tag Position feature.

```diff
useHead({
  script: [
      {
-        body: true
+        tagPosition: 'bodyClose'
      }
   ]
})
```

**Use Deprecations Plugin**

```ts
import { createHead } from 'unhead'
import { DeprecationsPlugin } from 'unhead/plugins'

const unhead = createHead({
  plugins: [DeprecationsPlugin]
})
```

## Opt-in Template Params & Tag Alias Sorting

🚦 Impact Level: High

To reduce the bundle size and improve performance, we've moved the template params and tag alias sorting to optional plugins.

If you'd like to continue using these, please opt-in to the plugins.

```ts
import { AliasSortingPlugin, TemplateParamsPlugin } from 'unhead/plugins'

createHead({
  plugins: [TemplateParamsPlugin, AliasSortingPlugin]
})
```

## Vue 2 Support

🚦 Impact Level: Critical

Unhead v2 no longer supports Vue v2. If you're using Vue v2, you will need to lock your dependencies to the latest v1 version of Unhead.

## Promise Input Support

🚦 Impact Level: Medium

If you have promises as input they will no longer be resolved, either await the promise before passing it along or register the optional promises plugin.

**Option 1: Await Promise**

```diff
useHead({
  link: [
    {
-     href: import('~/assets/MyFont.css?url'),
+     href: await import('~/assets/MyFont.css?url'),
      rel: 'stylesheet',
      type: 'text/css'
    }
  ]
})
```

**Option 2: Promise Plugin**

```ts
import { PromisePlugin } from 'unhead/plugins'

const unhead = createHead({
  plugins: [PromisePlugin]
})
```

## Updated `useScript()`{lang="ts"}

🚦 Impact Level: High

**⚠️ Breaking Changes:**

- Script instance is no longer augmented as a proxy and promise
- `script.proxy`{lang="ts"} is rewritten for simpler, more stable behavior
- `stub()`{lang="ts"} and runtime hook `script:instance-fn` are removed

**Replacing promise usage**

If you're using the script as a promise you should instead opt to use the `onLoaded()` functions.

```diff
const script = useScript()

-script.then(() => console.log('loaded')
+script.onLoaded(() => console.log('loaded'))
```

**Replacing proxy usage**

If you're accessing the underlying API directly from the script instance, you will now need to only access it from the `.proxy`.

```diff
const script = useScript('..', {
  use() { return { foo: [] } }
})

-script.foo.push('bar')
+script.proxy.foo.push('bar')
```

**Replacing `stub()`**

If you were using stub for anything you should replace this with either custom `use()` behavior.

```diff
const script = useScript('...', {
-  stub() { return { foo: import.meta.server ? [] : undefined } }
})

+script.proxy = {} // your own implementation
```

## Tag Sorting Updated

🚦 Impact Level: :UBadge{color="success" variant="subtle" size="sm" label="Low"}

An optional [Capo.js](https://rviscomi.github.io/capo.js/) plugin was added to Unhead, in v2 we make this the default sorting behavior.

::warning
As all head tags may be re-ordered this will break any snapshot tests that you have in place and in some rare cases may lead to performance regressions.
::

You can opt-out of Capo.js sorting by providing the option.

```ts
createHead({
  disableCapoSorting: true,
})
```

## Default SSR Tags

🚦 Impact Level: Low

When SSR Unhead will now insert important default tags for you:
- `<meta charset="utf-8">`
- `<meta name="viewport" content="width=device-width, initial-scale=1">`
- `<html lang="en">`

If you were previously relying on these being left empty, you may need to either disable them by using `disableDefaultTags` or insert tags
to override them.

```ts
import { createHead, useHead } from 'unhead/server'

// disable when creating the head instance
const head = createHead({
  disableDefaults: true,
})

useHead(head, {
  htmlAttrs: {
    lang: 'fr'
  }
})
```

## CJS Exports Removed

🚦 Impact Level: Low

CommonJS exports have been removed in favor of ESM only.

```diff
-const { createHead } = require('unhead/client')
+import { createHead } from 'unhead/client'
```

## Deprecated `@unhead/schema`

🚦 Impact Level: Low

The `@unhead/schema` package is now deprecated and will be removed in a future version. You should instead import
the schema from `unhead/types` or `unhead`.

```diff
-import { HeadTag } from '@unhead/schema'
+import { HeadTag } from 'unhead/types'
```
2025-03-28 00:06:28 +08:00
a6389aee36 chore(deps): update dependency eslint-plugin-oxlint to ^0.15.15 2025-03-26 20:32:09 +08:00
a05ca276ca chore(deps): update dependency eslint-plugin-unicorn to v58 2025-03-26 20:29:15 +08:00
严浩
fa8d02f08d feat: 移除 size-limit 依赖及相关工作流配置 2025-03-25 11:42:13 +08:00
严浩
68406f5681 feat: 添加 size-limit 依赖 2025-03-25 10:54:13 +08:00
a8a06c589c chore(deps): update unplugin packages 2025-03-24 03:14:23 +08:00