-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c34b8a0
commit 8dfe3c8
Showing
30 changed files
with
195 additions
and
247 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@uni-helper/devtools-monorepo", | ||
"type": "module", | ||
"version": "0.1.0", | ||
"version": "0.0.0", | ||
"private": true, | ||
"packageManager": "[email protected]", | ||
"description": "devtools for uni", | ||
|
@@ -31,6 +31,7 @@ | |
"lint": "eslint .", | ||
"lint:fix": "eslint . --fix", | ||
"test": "vitest", | ||
"release": "bumpp -r", | ||
"preinstall": "npx only-allow pnpm", | ||
"postinstall": "npx simple-git-hooks" | ||
}, | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@uni-helper/devtools-client", | ||
"type": "module", | ||
"version": "0.1.0", | ||
"version": "0.0.1", | ||
"private": true, | ||
"packageManager": "[email protected]", | ||
"description": "uni-app 开发者工具客户端", | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<script setup lang="ts"> | ||
import Logo from '/icon.png' | ||
import Logo from '/loading_icon.png' | ||
</script> | ||
|
||
<template> | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup lang="ts"> | ||
import type { CustomTab } from '@vue/devtools-kit' | ||
const p = defineProps<{ | ||
tab: CustomTab | ||
iframeInline?: boolean | ||
}>() | ||
const props = toRefs(p) | ||
const tabName = computed(() => props.tab.value?.name) | ||
const iframeViewVisible = ref(true) | ||
watch(() => tabName.value, () => { | ||
iframeViewVisible.value = false | ||
setTimeout(() => { | ||
iframeViewVisible.value = true | ||
}, 100) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<template v-if="!tab"> | ||
<div flex="~ col" h-full items-center justify-center> | ||
<div flex="~ col gap2" mxa items-center> | ||
<div i-carbon-queued mb2 text-5xl op50 /> | ||
<p text-xl> | ||
Tab <code text-rose>{{ tabName }}</code> not found | ||
</p> | ||
<p mt8 animate-pulse> | ||
Redirecting to overview page... | ||
</p> | ||
</div> | ||
</div> | ||
</template> | ||
<template v-else-if="tab?.view?.type === 'iframe'"> | ||
<IframeView v-if="iframeViewVisible" :src="tab.view.src" :inline="iframeInline" /> | ||
</template> | ||
<template v-else-if="tab?.view?.type === 'vnode'"> | ||
<Component :is="tab.view.vnode" /> | ||
</template> | ||
<template v-else> | ||
<div> | ||
<NCard flex="~ col" h-full items-center justify-center> | ||
Unknown tab type {{ tab?.view }} | ||
</NCard> | ||
</div> | ||
</template> | ||
</template> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,54 @@ | ||
<script setup lang="ts"> | ||
defineProps<{ | ||
import { isUrlString } from '@vue/devtools-shared' | ||
import { VueIcIcon } from '@vue/devtools-ui' | ||
const props = withDefaults(defineProps<{ | ||
icon?: string | ||
title?: string | ||
}>() | ||
showTitle?: boolean | ||
fallback?: string | ||
}>(), { | ||
showTitle: true, | ||
}) | ||
const _icon = ref<string | undefined>(props.icon) | ||
watch(() => props.icon, (icon) => { | ||
_icon.value = icon | ||
}) | ||
function onLoadError() { | ||
_icon.value = props.fallback | ||
} | ||
// For custom-inspector icons, the prefix is 'custom-ic-' | ||
const CUSTOM_IC_ICON_PREFIX = 'custom-ic-' | ||
</script> | ||
|
||
<template> | ||
<img | ||
v-if="icon && (icon.startsWith('/') || icon.match(/^https?:/))" | ||
v-if="_icon && isUrlString(_icon)" | ||
:style="{ | ||
width: '1em', | ||
height: '1em', | ||
}" | ||
v-bind="$attrs" | ||
:src="icon" | ||
:src="_icon" | ||
:alt="title" | ||
@error="onLoadError" | ||
> | ||
<VueIcIcon | ||
v-else-if="_icon?.startsWith(CUSTOM_IC_ICON_PREFIX)" :name="_icon.slice(CUSTOM_IC_ICON_PREFIX.length)" | ||
v-bind="$attrs" :title="showTitle ? title : undefined" | ||
/> | ||
<div | ||
v-else | ||
:style="{ | ||
width: '1em', | ||
height: '1em', | ||
}" | ||
v-bind="$attrs" | ||
:class="icon || 'carbon-bring-forward'" | ||
:title="title" | ||
:class="_icon || 'i-carbon-bring-forward'" | ||
:title="showTitle ? title : undefined" | ||
/> | ||
</template> |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script setup lang="ts"> | ||
import type { CustomTab } from '@vue/devtools-kit' | ||
import type { ComputedRef } from 'vue' | ||
const route = useRoute() | ||
const router = useRouter() | ||
const { flattenedTabs } = useTabs() | ||
// @ts-expect-error name is defined in router | ||
const tabName = computed(() => route.params.name) | ||
const tab = computed(() => flattenedTabs.value.find(tab => tabName.value! === tab.name) || null!) as ComputedRef<CustomTab> | ||
onMounted(() => { | ||
if (!tab.value) { | ||
const timer = setTimeout(() => { | ||
if (tab.value) { | ||
clearTimeout(timer) | ||
return | ||
} | ||
router.replace('/overview') | ||
}, 2000) | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<CustomTabComponent :tab="tab" /> | ||
</template> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
{ | ||
"name": "@uni-helper/devtools-kit", | ||
"type": "module", | ||
"version": "0.1.0", | ||
"private": true, | ||
"version": "0.0.1", | ||
"packageManager": "[email protected]", | ||
"description": "devtools for uni", | ||
"author": "FliPPeDround <[email protected]>", | ||
|
@@ -44,9 +43,11 @@ | |
"scripts": { | ||
"build": "tsup", | ||
"stub": "tsup --watch", | ||
"test": "vitest" | ||
"prepublishOnly": "build", | ||
"release": "bumpp" | ||
}, | ||
"dependencies": { | ||
"@trpc/client": "10.45.2" | ||
"@trpc/client": "10.45.2", | ||
"@vue/devtools-kit": "^7.6.7" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
import type { CustomTab } from '@vue/devtools-kit' | ||
import { isUrlString } from '@vue/devtools-shared' | ||
import { createTrpc } from './trpc' | ||
|
||
function resolveIcon(icon?: string) { | ||
if (!icon) | ||
return | ||
if (icon.startsWith('baseline-')) { | ||
return `custom-ic-${icon}` | ||
} | ||
// devtools internal custom tab icons are starts with `i-` prefix, render as it is set in unocss safelist | ||
// or if it's a url | ||
if (icon.startsWith('i-') || isUrlString(icon)) | ||
return icon | ||
// for custom-tab, we use `custom-ic-` prefix | ||
return `custom-ic-baseline-${icon}` | ||
} | ||
|
||
export function addCustomTab(tab: CustomTab) { | ||
console.log('addCustomTab', tab) | ||
const trpc = createTrpc()! | ||
trpc.sendTab.subscribe(tab, { | ||
// @ts-expect-error type not important | ||
trpc.sendTab.subscribe({ | ||
...tab, | ||
icon: resolveIcon(tab.icon), | ||
}, { | ||
onComplete: () => {}, | ||
}) | ||
} |
Oops, something went wrong.