diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b5405c904e..1f6b3912a41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [2.22.2](https://github.com/varletjs/varlet/compare/v2.22.1...v2.22.2) (2024-02-03) + + +### Bug Fixes + +* fix defineProps limited to a type literal or a reference to a local interface and close [#1458](https://github.com/varletjs/varlet/issues/1458) ([64ba155](https://github.com/varletjs/varlet/commit/64ba155a5b3e2a9e828ed60dbb38b8d30b067070)) +* **index-bar:** init scroller when start to scroll for nuxt ([#1460](https://github.com/varletjs/varlet/issues/1460)) ([9b9ad8c](https://github.com/varletjs/varlet/commit/9b9ad8c35c15cc9fce14536d9f80ff14fe8592b7)) +* **index-bar:** recollect anchor name that is empty from anchors when length changes ([#1459](https://github.com/varletjs/varlet/issues/1459)) ([e61d046](https://github.com/varletjs/varlet/commit/e61d046b55e4e4e84822aec352d88737c1fac544)) +* **sticky:** init scroller when start scrolling to avoid the value of scroller becomes window for nuxt ([#1456](https://github.com/varletjs/varlet/issues/1456)) ([43637b9](https://github.com/varletjs/varlet/commit/43637b9d440ec7bdf601e3f0b1e89eef36ed86d5)) + + + ## [2.22.1](https://github.com/varletjs/varlet/compare/v2.22.0...v2.22.1) (2024-01-29) diff --git a/package.json b/package.json index 77fbebffc2e..c2242f5f3fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "2.22.1", + "version": "2.22.2", "scripts": { "preinstall": "npx only-allow pnpm", "postinstall": "simple-git-hooks", diff --git a/packages/varlet-cli/package.json b/packages/varlet-cli/package.json index 26728c5f253..05e32f53592 100644 --- a/packages/varlet-cli/package.json +++ b/packages/varlet-cli/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/cli", - "version": "2.22.1", + "version": "2.22.2", "type": "module", "description": "cli of varlet", "bin": { diff --git a/packages/varlet-cli/src/node/compiler/compileSFC.ts b/packages/varlet-cli/src/node/compiler/compileSFC.ts index 1af3eeb8daa..f9e38ce40b8 100644 --- a/packages/varlet-cli/src/node/compiler/compileSFC.ts +++ b/packages/varlet-cli/src/node/compiler/compileSFC.ts @@ -1,9 +1,17 @@ import fse from 'fs-extra' import hash from 'hash-sum' import { parse, resolve } from 'path' -import { parse as parseSFC, compileTemplate, compileStyle, compileScript as compileScriptSFC } from '@vue/compiler-sfc' +import { + parse as parseSFC, + compileTemplate, + compileStyle, + compileScript as compileScriptSFC, + registerTS, +} from '@vue/compiler-sfc' import { replaceExt, smartAppendFileSync } from '../shared/fsUtils.js' +import { CWD, SRC_DIR, ES_DIR } from '../shared/constant.js' import { compileScript, getScriptExtname } from './compileScript.js' +import ts from 'typescript' import { clearEmptyLine, compileLess, @@ -13,7 +21,9 @@ import { } from './compileStyle.js' import type { SFCStyleBlock } from '@vue/compiler-sfc' -const { readFile, writeFileSync } = fse +const { readFile, existsSync, readFileSync, writeFileSync } = fse + +registerTS(() => ts) const EXPORT = 'export default' const SFC = '__sfc__' @@ -49,6 +59,14 @@ export function injectRender(script: string, render: string): string { return script } +export function getFsPath(sfc: string, fsFile: string) { + if (fsFile === 'tsconfig.json' || fsFile.startsWith('node_modules')) { + return resolve(CWD, fsFile) + } + + return resolve(sfc.replace(ES_DIR, SRC_DIR), '..', fsFile) +} + export async function compileSFC(sfc: string) { const sources: string = await readFile(sfc, 'utf-8') const id = hash(sources) @@ -60,7 +78,14 @@ export async function compileSFC(sfc: string) { if (script || scriptSetup) { if (scriptSetup) { - const { content, bindings } = compileScriptSFC(descriptor, { id }) + const { content, bindings } = compileScriptSFC(descriptor, { + id, + // issue https://github.com/varletjs/varlet/issues/1458 + fs: { + fileExists: (file) => existsSync(getFsPath(sfc, file)), + readFile: (file) => readFileSync(getFsPath(sfc, file), 'utf-8'), + }, + }) scriptContent = content bindingMetadata = bindings } else { diff --git a/packages/varlet-eslint-config/package.json b/packages/varlet-eslint-config/package.json index d47b1f5ed5f..505e2c9999f 100644 --- a/packages/varlet-eslint-config/package.json +++ b/packages/varlet-eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/eslint-config", - "version": "2.22.1", + "version": "2.22.2", "description": "eslint config of varlet", "keywords": [ "eslint", diff --git a/packages/varlet-icons/package.json b/packages/varlet-icons/package.json index e972f7ce325..8c56ef79e88 100644 --- a/packages/varlet-icons/package.json +++ b/packages/varlet-icons/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/icons", - "version": "2.22.1", + "version": "2.22.2", "description": "Icons of varlet", "type": "module", "main": "dist/index.js", diff --git a/packages/varlet-shared/package.json b/packages/varlet-shared/package.json index 3733914a471..d2ad72938e5 100644 --- a/packages/varlet-shared/package.json +++ b/packages/varlet-shared/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/shared", - "version": "2.22.1", + "version": "2.22.2", "type": "module", "main": "lib/index.cjs", "module": "lib/index.js", diff --git a/packages/varlet-touch-emulator/package.json b/packages/varlet-touch-emulator/package.json index 311137a5e84..c45bc380e38 100644 --- a/packages/varlet-touch-emulator/package.json +++ b/packages/varlet-touch-emulator/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/touch-emulator", - "version": "2.22.1", + "version": "2.22.2", "description": "touch-emulator", "keywords": [ "emulator", diff --git a/packages/varlet-ui-playground/package.json b/packages/varlet-ui-playground/package.json index 0cbf71aa45e..587a74d2b72 100644 --- a/packages/varlet-ui-playground/package.json +++ b/packages/varlet-ui-playground/package.json @@ -1,7 +1,7 @@ { "name": "@varlet/ui-playground", "private": true, - "version": "2.22.1", + "version": "2.22.2", "description": "varlet ui playground", "type": "module", "keywords": [ diff --git a/packages/varlet-ui/package.json b/packages/varlet-ui/package.json index 2b920d314a0..cee0802c4fa 100644 --- a/packages/varlet-ui/package.json +++ b/packages/varlet-ui/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/ui", - "version": "2.22.1", + "version": "2.22.2", "description": "A material like components library", "main": "lib/varlet.cjs.js", "module": "es/index.mjs", diff --git a/packages/varlet-ui/src/index-bar/IndexBar.vue b/packages/varlet-ui/src/index-bar/IndexBar.vue index cad7db02b46..cd5724a75c0 100644 --- a/packages/varlet-ui/src/index-bar/IndexBar.vue +++ b/packages/varlet-ui/src/index-bar/IndexBar.vue @@ -67,16 +67,13 @@ export default defineComponent({ () => length.value, async () => { await doubleRaf() - indexAnchors.forEach(({ name }) => { - if (name.value) anchorNameList.value.push(name.value) - }) + anchorNameList.value = indexAnchors + .filter(({ name }) => name.value != null) + .map(({ name }) => name.value) as Array } ) - onSmartMounted(async () => { - await setScroller() - addScrollerListener() - }) + onSmartMounted(setupScroller) onBeforeUnmount(removeScrollerListener) @@ -170,17 +167,17 @@ export default defineComponent({ clickedName.value = '' } - async function setScroller() { - await doubleRaf() + function setupScroller() { scroller = getParentScroller(barEl.value as HTMLElement) - } - - function addScrollerListener() { - scroller!.addEventListener('scroll', handleScroll) + scroller.addEventListener('scroll', handleScroll) } function removeScrollerListener() { - scroller!.removeEventListener('scroll', handleScroll) + if (!scroller) { + return + } + + scroller.removeEventListener('scroll', handleScroll) } // expose diff --git a/packages/varlet-ui/src/sticky/Sticky.vue b/packages/varlet-ui/src/sticky/Sticky.vue index 2afef0f3c3b..90ba59c9927 100644 --- a/packages/varlet-ui/src/sticky/Sticky.vue +++ b/packages/varlet-ui/src/sticky/Sticky.vue @@ -62,7 +62,11 @@ export default defineComponent({ watch(() => props.disabled, resize) - onSmartMounted(addScrollListener) + onSmartMounted(async () => { + await doubleRaf() + setupScroller() + handleScroll() + }) onSmartUnmounted(removeScrollListener) @@ -114,11 +118,15 @@ export default defineComponent({ } } - function handleScroll() { - if (!scroller) { - return + function setupScroller() { + scroller = getParentScroller(stickyEl.value as HTMLElement) + + if (scroller !== window) { + scroller.addEventListener('scroll', handleScroll) } + } + function handleScroll() { // returns undefined when disabled = true const fixedParams = computeFixedParams() @@ -127,6 +135,14 @@ export default defineComponent({ } } + function removeScrollListener() { + if (!scroller || scroller === window) { + return + } + + scroller.removeEventListener('scroll', handleScroll) + } + // expose async function resize() { isFixed.value = false @@ -134,17 +150,6 @@ export default defineComponent({ computeFixedParams() } - async function addScrollListener() { - await doubleRaf() - scroller = getParentScroller(stickyEl.value as HTMLElement) - scroller !== window && scroller.addEventListener('scroll', handleScroll) - handleScroll() - } - - function removeScrollListener() { - scroller !== window && scroller.removeEventListener('scroll', handleScroll) - } - return { stickyEl, wrapperEl, diff --git a/packages/varlet-use/package.json b/packages/varlet-use/package.json index ea608bdd8ae..953e0154423 100644 --- a/packages/varlet-use/package.json +++ b/packages/varlet-use/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/use", - "version": "2.22.1", + "version": "2.22.2", "type": "module", "main": "lib/index.cjs", "module": "lib/index.js", diff --git a/packages/varlet-vite-plugins/package.json b/packages/varlet-vite-plugins/package.json index a054af1a31b..d55dde4ab64 100644 --- a/packages/varlet-vite-plugins/package.json +++ b/packages/varlet-vite-plugins/package.json @@ -1,6 +1,6 @@ { "name": "@varlet/vite-plugins", - "version": "2.22.1", + "version": "2.22.2", "type": "module", "description": "vite plugins of varlet", "main": "lib/index.js", diff --git a/packages/varlet-vscode-extension/package.json b/packages/varlet-vscode-extension/package.json index 30b5107aa64..d007961c155 100644 --- a/packages/varlet-vscode-extension/package.json +++ b/packages/varlet-vscode-extension/package.json @@ -6,7 +6,7 @@ "displayName": "varlet-vscode-extension", "description": "varlet extension for vscode", "publisher": "haoziqaq", - "version": "2.22.1", + "version": "2.22.2", "engines": { "vscode": "^1.56.0" },