Skip to content

Commit

Permalink
Merge branch 'release/release/0.11.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Aug 25, 2023
2 parents f4635b0 + 2b3b55d commit bb08daf
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 69 deletions.
10 changes: 5 additions & 5 deletions demos/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45"
"vue": "^3.3.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.2.0",
"@vue/compiler-sfc": "^3.2.45",
"@vitejs/plugin-vue": "^4.3.3",
"@vue/compiler-sfc": "^3.3.4",
"@vuedx/typecheck": "^0.7.6",
"@vuedx/typescript-plugin-vue": "^0.7.6",
"typescript": "^4.9.3",
"vite": "^3.2.4"
"typescript": "^5.2.2",
"vite": "^4.4.9"
}
}
2 changes: 1 addition & 1 deletion demos/vite/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineComponent({
</script>

<template>
<img alt="Vue logo" src="./assets/logo.png">
<img alt="Vue logo" src="./assets/logo.png" width="80">
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
</template>

Expand Down
54 changes: 3 additions & 51 deletions demos/vite/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,57 +25,9 @@ export default defineComponent({
</script>

<template>
<h1>{{ msg }}</h1>

<label>
<input v-model="useScriptSetup" type="checkbox"> Use
<code>&lt;script setup&gt;</code>
</label>
<label>
<input v-model="useTsPlugin" type="checkbox"> Provide types for
<code>*.vue</code> imports
</label>

<p>
Recommended IDE setup:
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
+
<template v-if="!useScriptSetup">
<a
href="https://marketplace.visualstudio.com/items?itemName=octref.vetur"
target="_blank"
>Vetur</a>
+
<a
href="https://marketplace.visualstudio.com/items?itemName=znck.vue-language-features"
target="_blank"
>Vue DX</a>
</template>
<template v-else>
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
</template>
</p>
<p v-if="useTsPlugin">
tsconfig setup:
<br>1. Install and add <code>@vuedx/typescript-plugin-vue</code> to
tsconfig plugins <br>2. Delete <code>src/shims-vue.d.ts</code> <br>3.
Open <code>src/main.ts</code> in VSCode <br>4. Open VSCode command input
<br>5. Search and run "Select TypeScript version" -> "Use workspace
version"
</p>
<button @click="count++">
count is: {{ count }}
</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.
</p>

<p>
<a href="https://vitejs.dev/guide/features.html" target="_blank">Vite Docs</a>
|
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
</p>
<p>In the console please type</p>
<p><code>localStorage.zeed = '*'</code></p>
<p>and reload, to see the logging.</p>
</template>

<style scoped>
Expand Down
25 changes: 24 additions & 1 deletion demos/vite/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { createApp } from 'vue'
// import { Logger } from 'zeed'
import { Logger } from '../../../src/index.browser'
import { Logger, LoggerConsoleHandler, getGlobalLogger } from '../../../src/index.browser'
import App from './App.vue'

if (!localStorage.zeed) {
getGlobalLogger().setHandlers([
LoggerConsoleHandler({
filter: '*'
})
])
console.info('\n\nThis is the fallback logging. Type `on()` to activate original browser logging.\n\n')
} else {
console.info('\n\nThis is the browser logging. Type `off()` to activate original fallback logging.\n\n')
}

// @ts-expect-error xxx
globalThis.on = function () {
localStorage.zeed = '*'
location.reload()
}

// @ts-expect-error xxx
globalThis.off = function () {
localStorage.zeed = ''
location.reload()
}

const log = Logger('app')
log('Hello World')

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed",
"type": "module",
"version": "0.11.4",
"version": "0.11.5",
"description": "🌱 Simple foundation library",
"author": {
"name": "Dirk Holtwick",
Expand Down Expand Up @@ -66,16 +66,16 @@
"release": "na version patch && na publish"
},
"devDependencies": {
"@antfu/eslint-config": "^0.39.8",
"@antfu/ni": "^0.21.5",
"@types/node": "^20.4.5",
"@antfu/eslint-config": "^0.41.0",
"@antfu/ni": "^0.21.6",
"@types/node": "^20.5.6",
"c8": "^8.0.1",
"cross-fetch": "^4.0.0",
"esbuild": "^0.18.17",
"eslint": "^8.46.0",
"tsup": "^7.1.0",
"typescript": "^5.1.6",
"vite": "^4.4.7",
"vitest": "^0.33.0"
"esbuild": "^0.19.2",
"eslint": "^8.47.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vitest": "^0.34.2"
}
}
5 changes: 5 additions & 0 deletions src/browser/log-browser-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { browserSelectColorByName } from '../common/log-colors'
import { parseLogLevel, useNamespaceFilter } from '../common/log-filter'
import { browserSupportsColors } from './log-colors'

/**
* Directly use console calls, this has the advantage to show the original source of the call
* i.e. it is possible to jump right into the code from the browser console logs. But other
* loggers will not work any more.
*/
export function LoggerBrowserSetupDebugFactory(opt: LogHandlerOptions = {}) {
const filter = opt.filter ?? localStorage.zeed ?? localStorage.debug
const styleFont = 'font-family: "JetBrains Mono", Menlo; font-size: 11px;'
Expand Down
3 changes: 2 additions & 1 deletion src/browser/log-context-browser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isEmpty } from '../common'
import { getGlobalLogger } from '../common/log'
import type { LogLevelAliasType, LoggerInterface } from '../common/log-base'
import { isBrowser } from '../common/platform'
Expand All @@ -6,7 +7,7 @@ import { LoggerBrowserSetupDebugFactory } from './log-browser-factory'

export function Logger(name?: string, level?: LogLevelAliasType): LoggerInterface {
return getGlobalLogger((context) => {
if (isBrowser()) {
if (isBrowser() && !isEmpty(localStorage.getItem('zeed'))) {
context.setHandlers([LoggerBrowserHandler()]) // Fallback for previously registered Loggers
context.setFactory(LoggerBrowserSetupDebugFactory({}))
}
Expand Down

0 comments on commit bb08daf

Please sign in to comment.