nuxt support - #97
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Implements the Nuxt module setup() logic: resolves the build version, injects the detection script/stylesheet via nuxt.options.app.head, adds the notification anchor through Nitro's render:html hook, and writes the version.json/inject.js/inject.css assets into Nitro's publicDir on nitro:build:public-assets. Disabled in dev and when no version resolves. Nitro's nitro:init/nitro:build:public-assets/render:html hooks are only typed via @nuxt/nitro-server (Nuxt 3.20+ only), so this casts nuxt.hook/ nitro.hooks.hook locally against nitropack/types and nuxt/app instead of depending on that package or augmenting NuxtHooks/NitroHooks globally — augmenting those types pulled webpack/postcss/etc. into the published .d.mts. Added @nuxt/schema and nitropack as devDependencies (needed to resolve the NuxtConfig/NuxtOptions augmentation and the Nitro type import under pnpm's strict isolation) and marked @nuxt/schema as deps.neverBundle in tsdown.config.ts to keep dist/index.d.mts small.
The render:html hook signature includes a second parameter (context with H3Event), but the cast type only declared the first parameter. Updated the cast to include the second parameter as optional with unknown type to match the real signature without introducing new dependencies. Also clarified in the comment that this is an intentionally narrowed local type to keep the package's .d.ts slim. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…of build-time nitro The previous implementation hooked `nitro:init` and registered `render:html` on that build-time `nitro` Hookable object. That hook target never receives HTML render requests, so the notification anchor `<div>` was silently never injected into the response body in SSR, SSG, or SPA output. `render:html` is only ever called on the runtime `nitroApp` instance created when the compiled server starts. Switch to generating a Nitro server plugin via `addTemplate` + `addServerPlugin`, which runs against the real runtime `nitroApp`.
…tion/nuxt Wire the nuxt module into example/nuxt and add Playwright e2e coverage for all three rendering modes (SSR via nuxt build/preview, SSG via nuxt generate, SPA via NUXT_SSR=false build/preview). Each mode runs the same shared assertion suite covering raw HTML injection, the version.json endpoint, the notification anchor in the DOM, and the update/dismiss interaction flow. nuxi preview doesn't support a custom nitro output dir, so the three modes build/serve sequentially against the shared default .output dir and port 3000. Not wired into CI, matching the existing vue-vite3 e2e suite which is also run manually only.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (21)
概要为 变更Nuxt 支持全链路
序列图sequenceDiagram
participant NuxtBuild as Nuxt 生产构建
participant Module as Nuxt Module setup()
participant Core as `@plugin-web-update-notification/core`
participant AppHead as app.head
participant NitroHook as Nitro render:html 钩子
participant PublicDir as publicDir
NuxtBuild->>Module: 调用 setup(options, nuxt)
Module->>Core: 读取 inject.js / inject.css 源码
Core-->>Module: 返回脚本与样式内容
Module->>Module: 生成版本号 + 计算内容哈希文件名
Module->>AppHead: 注入 script tag(data-id, data-v)+ link tag
Module->>NitroHook: 注册 render:html 钩子(通过 addTemplate)
NuxtBuild->>NitroHook: 渲染 HTML 时触发
NitroHook->>NitroHook: 向 bodyAppend 追加通知锚点 div
NuxtBuild->>Module: 触发 nitro:build:public-assets
Module->>PublicDir: 写入 version.json、inject.[hash].js、inject.[hash].css
代码审查工作量估算🎯 4 (Complex) | ⏱️ ~60 minutes 小诗
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit
发布说明
新功能
文档