File tree Expand file tree Collapse file tree 16 files changed +156
-9
lines changed Expand file tree Collapse file tree 16 files changed +156
-9
lines changed Original file line number Diff line number Diff line change 11<template >
2- <NuxtPage />
2+ <NuxtLayout >
3+ <NuxtPage />
4+ </NuxtLayout >
35</template >
Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import PKG from ' ../../../package.json'
3+ </script >
4+
5+ <template >
6+ <footer class =" p-8 flex justify-between items-center" >
7+ <a href =" https://github.com/unplugin/unplugin-turbo-console" target =" _blank" class =" flex items-center gap-1 text-gray-400 hover:text-gray-500 transition-colors" >
8+ <Icon name =" uil:github" class =" text-2xl" />
9+ Source Code
10+ </a >
11+
12+ <div class =" text-gray-400" >
13+ Version: {{ PKG.version }}
14+ </div >
15+ </footer >
16+ </template >
Original file line number Diff line number Diff line change 1+ <template >
2+ <main >
3+ <slot />
4+
5+ <app-footer />
6+ </main >
7+ </template >
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ const launchEditorServerResponse = ref<LaunchEditorServerResponse>()
1919async function init() {
2020 try {
2121 const position = window .location .hash .slice (1 )
22+ if (! position ) {
23+ throw new Error (' No position provided' )
24+ }
2225 const response = await $fetch <LaunchEditorServerResponse >(` /launchEditor?position=${(position )} ` )
2326 if (response .status !== ' success' ) {
2427 throw new Error (response .message || ' Unknown error' )
4245 </script >
4346
4447<template >
45- <main class =" h-screen w-screen p-8" >
48+ <main class =" w-screen p-8" >
4649 <div v-if =" requestState.status === 'pending'" class =" flex h-full justify-center" >
4750 <div class =" flex flex-col items-center gap-2" >
4851 <Icon name =" uil:spinner" class =" text-2xl animate-spin" />
Original file line number Diff line number Diff line change 11export function logJs ( ) {
2- console . log ( 'from js' ) // turbo-console-disable-line
2+ console . info ( 'from js' )
3+
4+ console . warn ( 'from js' )
5+
6+ console . error ( 'from js' )
7+
8+ console . log ( 'from js' )
9+
10+
311}
412
Original file line number Diff line number Diff line change 11export function logTs ( ) {
2- const a = '你好'
3- console . log ( a )
2+ const abc = '你4445jj5好'
3+ console . log ( abc )
4+
5+ const def = '你4445jj5好'
6+ console . log ( def )
7+
8+ // const ghi = '你4445jj5好'
9+ // console.log(ghi)
10+
11+ // const jkl = '你4445jj5好'
12+ // console.log(jkl)
13+
14+ const mno = '你4445jj5好'
15+ console . log ( mno )
16+
17+
418}
Original file line number Diff line number Diff line change 33
44export interface global { }
55
6+ interface ExpressionMeta {
7+ code : string
8+ method : string
9+ line : number
10+ column : number
11+ }
12+
613declare global {
714 import type { Peer } from 'crossws'
815
916 var TurboConsoleFilePathMap : Map < string , string >
17+ var TurboConsoleExpressionsMap : Map < string , ExpressionMeta [ ] >
1018 var UNPLUGIN_TURBO_CONSOLE_LAUNCH_SERVER : boolean
1119 var UNPLUGIN_TURBO_CONSOLE_PEERS_SET : Set < Peer > | undefined
1220}
Original file line number Diff line number Diff line change @@ -4,9 +4,12 @@ import { version } from '../../../package.json'
44export default defineEventHandler ( async ( ) => {
55 try {
66 const filePathMap = globalThis . TurboConsoleFilePathMap || new Map ( )
7+ const expressionsMap = globalThis . TurboConsoleExpressionsMap || new Map ( )
8+
79 return {
810 status : 'success' ,
911 filePathMap : Object . fromEntries ( filePathMap ) ,
12+ expressionsMap : Object . fromEntries ( expressionsMap ) ,
1013 version,
1114 }
1215 }
Original file line number Diff line number Diff line change @@ -5,11 +5,13 @@ export async function sfcCompiler(context: Context): Promise<CompileResult> {
55 try {
66 const { code } = context
77
8- const scriptRegex = / < s c r i p t (?: \s [ ^ > ] * ? l a n g = " ( [ ^ " ] * ) " ) ? \s * > ( [ \s \S ] * ?) < \/ s c r i p t > /
8+ const scriptRegex = / < s c r i p t \s * ( [ ^ > ] * ) > ( [ \s \S ] * ?) < \/ s c r i p t > /
99
1010 const match = scriptRegex . exec ( code )
1111 if ( match ) {
12- const lang = match [ 1 ] || 'js'
12+ const attrs = match [ 1 ] || ''
13+ const langMatch = attrs . match ( / l a n g = [ " ' ] ( [ ^ " ' ] * ) [ " ' ] / )
14+ const lang = langMatch ? langMatch [ 1 ] : 'js'
1315 const content = match [ 2 ]
1416 const offset = code . indexOf ( content )
1517 const line = offset ? code . substring ( 0 , offset ) . split ( '\n' ) . length - 1 : 0
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ export async function transform(context: Context) {
7575 return false
7676 }
7777
78+ const consoleMethod = ( node as any ) . callee . property . name
7879 const args = ( node as any ) . arguments
7980
8081 const argsStart = calculateStart ( compileResult . script , oxcMs . getLineColumnNumber ( args [ 0 ] . start ) )
@@ -90,6 +91,7 @@ export async function transform(context: Context) {
9091
9192 const { consoleString, _suffix } = genConsoleString ( {
9293 options,
94+ consoleMethod,
9395 originalLine,
9496 originalColumn,
9597 argType,
You can’t perform that action at this time.
0 commit comments