Skip to content

Commit

Permalink
fix(ui|git-changelog): missing configurations for @rive-app/canvas (#131
Browse files Browse the repository at this point in the history
)

Signed-off-by: Neko Ayaka <[email protected]>
  • Loading branch information
nekomeowww authored Mar 27, 2024
1 parent 087ae0f commit 8569935
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Rehype",
"resvg",
"unconfig",
"uncrypto"
"uncrypto",
"Nisekoi5"
],
"prettier.enable": false,
"editor.formatOnSave": false,
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { h } from 'vue'

import { NuLazyTeleportRiveCanvas } from '@nolebase/ui'
import { NolebasePluginSet, defineThemeUnconfig } from '@nolebase/unconfig-vitepress'

import IntegrationCard from './components/IntegrationCard.vue'
import HomeContent from './components/HomeContent.vue'
import RiveCanvas from './components/RiveCanvas.vue'

import 'virtual:uno.css'

Expand All @@ -16,7 +16,7 @@ export default defineThemeUnconfig({
slots: {
'layout-top': {
node: [
() => h(RiveCanvas),
() => h(NuLazyTeleportRiveCanvas),
],
},
},
Expand Down
75 changes: 75 additions & 0 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# `@nolebase/ui`

A collection of Vue components Nolebase uses.

> [!CAUTION] This package is in Alpha stage
>
> This package is still in the Alpha stage, and it is not recommended to use it in production. The API may change in the future, and there may be bugs in the current version. Please use it with caution.
> [!IMPORTANT] Before install
>
> Currently `@nolebase/ui` is still under development, and will be used by other [Nolebase Integrations](https://nolebase-integrations.ayaka.io) components now. There are a few configurations that needed to be configured if you would ever want to install `@nolebase/ui` as one of your dependencies:
>
> ### 1. Additional configurations for Vite
>
> #### 1.1 For users who imported `<NuLazyTeleportRiveCanvas />` component
>
> Since `<NuLazyTeleportRiveCanvas />` depends on `@rive-app/canvas`. If you also use Vite as your bundler, you will need to add the following configurations to your `vite.config.ts` file like this:
>
> ```typescript
> export default defineConfig(() => {
> return {
> optimizeDeps: {
> include: [
> // Add this line to your vite.config.ts
> '@nolebase/ui > @rive-app/canvas',
> ],
> },
> }
> })
> ```
>
> For more information about why configure this, please refer to the [Dep Optimization Options | Vite](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude) documentation.
>
> #### 1.2 For users who imported VitePress related components
>
> If you are using VitePress, you will need to add the following configurations to your `vite.config.ts` file like this:
>
> ```typescript
> export default defineConfig(() => {
> return {
> ssr: {
> noExternal: [
> // Add this line to your vite.config.ts
> '@nolebase/ui',
> ],
> },
> }
> })
> ```
>
> For more information about why configure this, please refer to the [Server-Side Rendering | Vite](https://vitejs.dev/guide/ssr.html#ssr-externals) documentation.
## Install
### Npm
```shell
npm i @nolebase/ui -D
```
### Yarn

```shell
yarn add @nolebase/ui -D
```

### Pnpm

```shell
pnpm add @nolebase/ui -D
```

## Documentation

Please refer to [UI Components](https://nolebase-integrations.ayaka.io/pages/en/ui/) for more information.
4 changes: 4 additions & 0 deletions packages/ui/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ export default defineBuildConfig({
],
declaration: true,
clean: true,
externals: [
'@rive-app/canvas',
'vue',
],
})
5 changes: 4 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nolebase/ui",
"type": "module",
"version": "1.25.12",
"version": "1.25.2",
"description": "A collection of Vue components Nolebase uses.",
"author": {
"name": "Nólëbase",
Expand Down Expand Up @@ -68,6 +68,9 @@
"peerDependencies": {
"vue": "^3.2.0"
},
"dependencies": {
"@rive-app/canvas": "^2.11.1"
},
"devDependencies": {
"@vue/tsconfig": "^0.5.1"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRoute } from 'vitepress'
import * as Rive from '@rive-app/canvas'
import type { Rive } from '@rive-app/canvas'
const route = useRoute()
const riveInstances = ref<Rive.Rive[]>([])
const riveInstances = ref<Rive[]>([])
const defaultCreateCanvasOptions = {
canvasWidth: 500,
Expand Down Expand Up @@ -126,7 +126,8 @@ async function renderRiveAsset() {
el.appendChild(canvas)
const r = new Rive.Rive({
const rive = await import('@rive-app/canvas')
const r = new rive.Rive({
canvas,
src: src.value,
autoplay: true,
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import type { App } from 'vue'

import NuButton from './components/NuButton.vue'
import NuVerticalTransition from './components/NuVerticalTransition.vue'
import NuLazyTeleportRiveCanvas from './components/NuLazyTeleportRiveCanvas.vue'

export {
NuButton,
NuVerticalTransition,
NuLazyTeleportRiveCanvas,
}

export function install(app: App): void {
app.component('NuButton', NuButton)
// Animations
app.component('NuLazyTeleportRiveCanvas', NuLazyTeleportRiveCanvas)
app.component('NuVerticalTransition', NuVerticalTransition)
}
5 changes: 5 additions & 0 deletions packages/vitepress-plugin-git-changelog/src/vite/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ export function GitChangelog(options: {
name: '@nolebase/vitepress-plugin-git-changelog',
config: () => ({
optimizeDeps: {
include: [
// @rive-app/canvas is a CJS/UMD module, so it needs to be included here
// for Vite to properly bundle it.
'@nolebase/vitepress-plugin-git-changelog > @nolebase/ui > @rive-app/canvas',
],
exclude: [
'@nolebase/vitepress-plugin-git-changelog/client',
],
Expand Down
Loading

0 comments on commit 8569935

Please sign in to comment.