Skip to content

Commit 1766c59

Browse files
committed
chore: improve playground
1 parent 70fdbee commit 1766c59

File tree

6 files changed

+99
-15
lines changed

6 files changed

+99
-15
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"unstorage": "catalog:deps",
6161
"vite": "catalog:build",
6262
"vite-plugin-inspect": "catalog:devtools",
63+
"vite-plugin-vue-tracer": "catalog:playground",
6364
"vitest": "catalog:testing",
6465
"vue": "catalog:frontend",
6566
"vue-tsc": "catalog:devtools"

packages/core/playground/vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import process from 'node:process'
22
import Vue from '@vitejs/plugin-vue'
3+
import UnoCSS from 'unocss/vite'
34
import { defineConfig } from 'vite'
5+
import Tracer from 'vite-plugin-vue-tracer'
46
// eslint-disable-next-line ts/ban-ts-comment
57
// @ts-ignore ignore the type error
68
import { DevToolsViteUI } from '../../vite/src/node'
@@ -29,6 +31,8 @@ export default defineConfig({
2931
builtinDevTools: false,
3032
}),
3133
DevToolsViteUI(),
34+
UnoCSS(),
35+
Tracer(),
3236
{
3337
name: 'local',
3438
devtools: {

packages/core/src/client/webcomponents/components/ViewIframe.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { DevToolsViewIframe } from '@vitejs/devtools-kit'
33
import type { CSSProperties } from 'vue'
44
import type { DevToolsDockState } from './DockProps'
55
import type { IframeManager } from './IframeManager'
6-
import { nextTick, onMounted, onUnmounted, useTemplateRef, watch, watchEffect } from 'vue'
6+
import { nextTick, onMounted, onUnmounted, ref, useTemplateRef, watch, watchEffect } from 'vue'
77
88
const props = defineProps<{
99
state?: DevToolsDockState
@@ -14,6 +14,7 @@ const props = defineProps<{
1414
iframeStyle?: CSSProperties
1515
}>()
1616
17+
const isLoading = ref(true)
1718
const viewFrame = useTemplateRef<HTMLDivElement>('viewFrame')
1819
1920
onMounted(() => {
@@ -26,6 +27,7 @@ onMounted(() => {
2627
holder.iframe.src = props.entry.url
2728
2829
holder.mount(viewFrame.value!)
30+
isLoading.value = false
2931
nextTick(() => {
3032
holder.update()
3133
})
@@ -57,7 +59,7 @@ onUnmounted(() => {
5759
ref="viewFrame"
5860
class="vite-devtools-view-iframe w-full h-full flex items-center justify-center"
5961
>
60-
<div class="op50 z--1">
62+
<div v-if="isLoading" class="op50 z--1">
6163
Loading iframe...
6264
</div>
6365
</div>

patches/@unocss__inspector.patch

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
diff --git a/dist/index.d.cts b/dist/index.d.cts
2+
new file mode 100644
3+
index 0000000000000000000000000000000000000000..dfda43ac9d13b9797ecf6ba74f37372095adbd47
4+
--- /dev/null
5+
+++ b/dist/index.d.cts
6+
@@ -0,0 +1,2 @@
7+
+export * from "/Users/antfu/i/unocss/packages-integrations/inspector/src/index.js";
8+
+export { default } from "/Users/antfu/i/unocss/packages-integrations/inspector/src/index.js";
9+
\ No newline at end of file
10+
diff --git a/dist/index.mjs b/dist/index.mjs
11+
index 0fb5d8feb0c3924850e0d1b01489aaf7099ec1e9..7dd9d9e00daf2ffc0e415f100d734fccfd28b622 100644
12+
--- a/dist/index.mjs
13+
+++ b/dist/index.mjs
14+
@@ -820,9 +820,9 @@ async function analyzer(modules, ctx) {
15+
16+
const _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
17+
function UnocssInspector(ctx) {
18+
+ const baseUrl = "__unocss";
19+
async function configureServer(server) {
20+
await ctx.ready;
21+
- const baseUrl = "__unocss";
22+
server.middlewares.use(`/${baseUrl}`, sirv(resolve(_dirname, "../dist/client"), {
23+
single: true,
24+
dev: true
25+
@@ -915,7 +915,18 @@ function UnocssInspector(ctx) {
26+
return {
27+
name: "unocss:inspector",
28+
apply: "serve",
29+
- configureServer
30+
+ configureServer,
31+
+ devtools: {
32+
+ setup(ctx2) {
33+
+ ctx2.docks.register({
34+
+ id: "unocss",
35+
+ title: "UnoCSS",
36+
+ icon: "https://unocss.dev/logo.svg",
37+
+ type: "iframe",
38+
+ url: `/${baseUrl}`
39+
+ });
40+
+ }
41+
+ }
42+
};
43+
}
44+
function getCircularReplacer() {
45+
diff --git a/package.json b/package.json
46+
index 7fcf740ef248ff716df3588302aa49e68839d9e3..28a9a284073fc89a17e5597813483424b4a2d8d0 100644
47+
--- a/package.json
48+
+++ b/package.json
49+
@@ -48,5 +48,8 @@
50+
"dev": "nr stub && vite",
51+
"update-post": "vite build",
52+
"test:attw": "attw --pack --config-path ../../.attw-esm-only.json"
53+
+ },
54+
+ "devDependencies": {
55+
+ "@vitejs/devtools-kit": "^0.0.0-alpha.10"
56+
}
57+
}

pnpm-lock.yaml

Lines changed: 20 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ packages:
22
- packages/*
33
- docs
44

5-
shamefullyHoist: true
6-
strictPeerDependencies: false
7-
shellEmulator: true
8-
ignoreWorkspaceRootCheck: true
5+
patchedDependencies:
6+
'@unocss/inspector': patches/@unocss__inspector.patch
97

108
catalogs:
119
build:
@@ -17,7 +15,6 @@ catalogs:
1715
esbuild: ^0.25.11
1816
magic-string: ^0.30.21
1917
nitropack: ^2.12.9
20-
# https://github.com/nuxt/nuxt/issues/33418
2118
nuxt: 4.1.2
2219
nuxt-mcp: ^0.2.5
2320
rolldown: ^1.0.0-beta.45
@@ -104,6 +101,8 @@ catalogs:
104101
inlined:
105102
'@antfu/utils': ^9.3.0
106103
stream-json: ^1.9.1
104+
playground:
105+
vite-plugin-vue-tracer: ^1.1.0
107106
testing:
108107
vitest: ^4.0.5
109108
types:
@@ -116,9 +115,18 @@ catalogs:
116115
'@types/split2': ^4.2.3
117116
'@types/stream-json': ^1.7.8
118117
'@types/ws': ^8.18.1
118+
119+
ignoreWorkspaceRootCheck: true
120+
119121
onlyBuiltDependencies:
120122
- '@parcel/watcher'
121123
- esbuild
122124
- rolldown
123125
- simple-git-hooks
124126
- unrs-resolver
127+
128+
shamefullyHoist: true
129+
130+
shellEmulator: true
131+
132+
strictPeerDependencies: false

0 commit comments

Comments
 (0)