From 39aed1da465d853246707bf10f0ee62e2fd6808d Mon Sep 17 00:00:00 2001 From: zjxxxxxxxxx <954270063@qq.com> Date: Fri, 22 Sep 2023 16:32:23 +0800 Subject: [PATCH] fix: relative path match failure --- .changeset/six-taxis-cross.md | 5 + .changeset/tender-elephants-guess.md | 2 +- package.json | 3 - .../client/src/resolve/createVueResolver.ts | 10 +- packages/rollup/README.md | 30 +++--- packages/vite/README.md | 30 +++--- packages/webpack/README.md | 30 +++--- pnpm-lock.yaml | 101 ++---------------- 8 files changed, 73 insertions(+), 138 deletions(-) create mode 100644 .changeset/six-taxis-cross.md diff --git a/.changeset/six-taxis-cross.md b/.changeset/six-taxis-cross.md new file mode 100644 index 00000000..50617e5d --- /dev/null +++ b/.changeset/six-taxis-cross.md @@ -0,0 +1,5 @@ +--- +'@open-editor/client': patch +--- + +fix the relative path match failure diff --git a/.changeset/tender-elephants-guess.md b/.changeset/tender-elephants-guess.md index a461c9ee..a6a05356 100644 --- a/.changeset/tender-elephants-guess.md +++ b/.changeset/tender-elephants-guess.md @@ -2,4 +2,4 @@ '@open-editor/shared': patch --- -add type uilt 'isBol' +add type util 'isBol' diff --git a/package.json b/package.json index 30d0bacd..fc473c1c 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,6 @@ "@open-editor/client": "workspace:*", "@open-editor/server": "workspace:*", "@open-editor/shared": "workspace:*", - "@open-editor/rollup": "workspace:*", - "@open-editor/vite": "workspace:*", - "@open-editor/webpack": "workspace:*", "@rollup/plugin-commonjs": "^25.0.4", "@rollup/plugin-node-resolve": "^15.1.0", "@types/minimist": "^1.2.2", diff --git a/packages/client/src/resolve/createVueResolver.ts b/packages/client/src/resolve/createVueResolver.ts index a768d9c7..a74179ee 100644 --- a/packages/client/src/resolve/createVueResolver.ts +++ b/packages/client/src/resolve/createVueResolver.ts @@ -44,7 +44,7 @@ function resolveVueSource( if ( isStr(__source) && isValidFileName(__file) && - __file.endsWith(source.file) + ensureFileName(__file) === source.file ) { push(instance); @@ -75,7 +75,7 @@ function resolveVueSourceAnchor( let instance = debug.value; let element = debug.originalElement; - while (element && !getElementVueSource(element)) { + while (element && !isStr(getElementVueSource(element))) { element = element.parentElement!; } @@ -129,16 +129,16 @@ function parseVueSource(__source: string) { } let cacheIsVueSource: boolean | undefined; -function isVueSource(element: HTMLElement) { +function isVueSource(element?: HTMLElement | null) { if (isBol(cacheIsVueSource)) { return cacheIsVueSource; } while (element) { - if (getElementVueSource(element) != null) { + if (isStr(getElementVueSource(element))) { return (cacheIsVueSource = true); } - element = element.parentElement!; + element = element.parentElement; } return (cacheIsVueSource = false); diff --git a/packages/rollup/README.md b/packages/rollup/README.md index 4d5bd1c2..1d5c6490 100644 --- a/packages/rollup/README.md +++ b/packages/rollup/README.md @@ -31,17 +31,23 @@ export default defineConfig({ ## Configuration -The following show the default values of the configuration - ```ts -OpenEditor({ - // source root path - rootDir: process.cwd(), - - // render the toggle into the browser - displayToggle: false, - - // custom openEditor handler - onOpenEditor: undefined, -}); +interface Options { + /** + * source rootDir path + * + * @default process.cwd() + */ + rootDir?: string; + /** + * render the toggle into the browser + * + * @default false + */ + displayToggle?: boolean; + /** + * custom openEditor handler + */ + onOpenEditor?(file: string): void; +} ``` diff --git a/packages/vite/README.md b/packages/vite/README.md index 301a43f5..a361e054 100644 --- a/packages/vite/README.md +++ b/packages/vite/README.md @@ -31,17 +31,23 @@ export default defineConfig({ ## Configuration -The following show the default values of the configuration - ```ts -OpenEditor({ - // source root path - rootDir: process.cwd(), - - // render the toggle into the browser - displayToggle: false, - - // custom openEditor handler - onOpenEditor: undefined, -}); +interface Options { + /** + * source rootDir path + * + * @default process.cwd() + */ + rootDir?: string; + /** + * render the toggle into the browser + * + * @default false + */ + displayToggle?: boolean; + /** + * custom openEditor handler + */ + onOpenEditor?(file: string): void; +} ``` diff --git a/packages/webpack/README.md b/packages/webpack/README.md index b023f534..e73b244e 100644 --- a/packages/webpack/README.md +++ b/packages/webpack/README.md @@ -31,17 +31,23 @@ module.exports = { ## Configuration -The following show the default values of the configuration - ```ts -OpenEditor({ - // source root path - rootDir: process.cwd(), - - // render the toggle into the browser - displayToggle: false, - - // custom openEditor handler - onOpenEditor: undefined, -}); +interface Options { + /** + * source rootDir path + * + * @default process.cwd() + */ + rootDir?: string; + /** + * render the toggle into the browser + * + * @default false + */ + displayToggle?: boolean; + /** + * custom openEditor handler + */ + onOpenEditor?(file: string): void; +} ``` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1027e5d0..7e8b31ac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,21 +16,12 @@ importers: '@open-editor/client': specifier: workspace:* version: link:packages/client - '@open-editor/rollup': - specifier: workspace:* - version: link:packages/rollup '@open-editor/server': specifier: workspace:* version: link:packages/server '@open-editor/shared': specifier: workspace:* version: link:packages/shared - '@open-editor/vite': - specifier: workspace:* - version: link:packages/vite - '@open-editor/webpack': - specifier: workspace:* - version: link:packages/webpack '@rollup/plugin-commonjs': specifier: ^25.0.4 version: 25.0.4(rollup@3.28.1) @@ -218,7 +209,7 @@ importers: version: 7.22.11(@babel/core@7.22.10) '@open-editor/rollup': specifier: latest - version: 0.0.15 + version: link:../../packages/rollup '@rollup/plugin-babel': specifier: ^6.0.3 version: 6.0.3(@babel/core@7.22.10)(rollup@3.28.1) @@ -270,7 +261,7 @@ importers: version: 7.22.11(@babel/core@7.22.10) '@open-editor/rollup': specifier: latest - version: 0.0.15 + version: link:../../packages/rollup '@rollup/plugin-babel': specifier: ^6.0.3 version: 6.0.3(@babel/core@7.22.10)(rollup@3.28.1) @@ -316,7 +307,7 @@ importers: devDependencies: '@open-editor/vite': specifier: latest - version: 0.0.15 + version: link:../../packages/vite '@types/react': specifier: ^18.2.15 version: 18.2.21 @@ -341,7 +332,7 @@ importers: devDependencies: '@open-editor/vite': specifier: latest - version: 0.0.15 + version: link:../../packages/vite '@vitejs/plugin-vue': specifier: ^4.2.3 version: 4.2.3(vite@4.4.7)(vue@3.3.4) @@ -350,7 +341,7 @@ importers: version: 5.2.2 unplugin-vue-source: specifier: latest - version: 0.0.1-beta.0 + version: 0.0.1-beta.1 vite: specifier: ^4.4.5 version: 4.4.7(@types/node@20.5.6) @@ -359,7 +350,7 @@ importers: dependencies: '@open-editor/webpack': specifier: latest - version: 0.0.15 + version: link:../../packages/webpack '@types/node': specifier: 20.5.6 version: 20.5.6 @@ -393,7 +384,7 @@ importers: devDependencies: '@open-editor/webpack': specifier: latest - version: 0.0.15 + version: link:../../packages/webpack '@vue/cli-plugin-babel': specifier: ~5.0.0 version: 5.0.0(@vue/cli-service@5.0.1)(core-js@3.8.3)(esbuild@0.19.2)(vue@3.3.4) @@ -408,7 +399,7 @@ importers: version: 4.5.5 unplugin-vue-source: specifier: latest - version: 0.0.1-beta.0 + version: 0.0.1-beta.1 packages: /@aashutoshrathi/word-wrap@1.2.6: @@ -4536,71 +4527,6 @@ packages: fastq: 1.15.0 dev: true - /@open-editor/client@0.0.15: - resolution: - { - integrity: sha512-VOykBuxZ2+dmJwt+d0XY03vk6grwVtUxCdcEyvLOnGyQjVB1USyRIsCKI9KTVTzbgLK4AErniErPKXSZRCqfDg==, - } - dependencies: - '@open-editor/shared': 0.0.15 - - /@open-editor/rollup@0.0.15: - resolution: - { - integrity: sha512-C2D3BeY+4WItdvl5/kE7QxxgQnj1HyN1fKUd6uo9voVmNGHhcewsjCniFfekNqHTMa2YPSZ7iYYub19qduAmRw==, - } - dependencies: - '@open-editor/client': 0.0.15 - '@open-editor/server': 0.0.15 - '@open-editor/shared': 0.0.15 - transitivePeerDependencies: - - supports-color - dev: true - - /@open-editor/server@0.0.15: - resolution: - { - integrity: sha512-gNj5a64Shkt37oZQQqOdd5uEwKFmRLmk42ZpiZcXPiyPWVuRV72W45GiDMyD3jjtct+erlEW/QweiGbrF4v2HQ==, - } - dependencies: - '@open-editor/shared': 0.0.15 - connect: 3.7.0 - cors: 2.8.5 - launch-editor: 2.6.0 - transitivePeerDependencies: - - supports-color - - /@open-editor/shared@0.0.15: - resolution: - { - integrity: sha512-ABkp4M6GEZqYxmaL2SyKCYOD1E8QDZO2Sg0+AxlRfdeENGEIWBYeZJ6mlGnKVulkRh8JA2oll6s7HltnzXgoUg==, - } - - /@open-editor/vite@0.0.15: - resolution: - { - integrity: sha512-i88ErFZmvlFzFW2FdLr0YirivpO57SG8qlsSOPJurV0shtS163+m9sXuaXvh2yA0gxzZmsBi6mByiOG/3oAVdw==, - } - dependencies: - '@open-editor/client': 0.0.15 - '@open-editor/server': 0.0.15 - '@open-editor/shared': 0.0.15 - transitivePeerDependencies: - - supports-color - dev: true - - /@open-editor/webpack@0.0.15: - resolution: - { - integrity: sha512-/56V3pmvmsR34mJkfkPY2Nip+EmB+blk8GFfftru/negDv0ue8E2HPPfvTGdDGuyDytsyABIEa+cpSpHtyIB7Q==, - } - dependencies: - '@open-editor/client': 0.0.15 - '@open-editor/server': 0.0.15 - '@open-editor/shared': 0.0.15 - transitivePeerDependencies: - - supports-color - /@pkgjs/parseargs@0.11.0: resolution: { @@ -17042,17 +16968,6 @@ packages: } engines: { node: '>= 0.8' } - /unplugin-vue-source@0.0.1-beta.0: - resolution: - { - integrity: sha512-MB323wSlmltDH3IRsRpThj9V02RJUzODnCLlXxK2bBlqdfuyMBbDtvdUxnB08NYk5mkSOUWWG1VNXs2o3ZXpgQ==, - } - engines: { node: '>=14' } - dependencies: - magic-string: 0.30.3 - unplugin: 1.4.0 - dev: true - /unplugin-vue-source@0.0.1-beta.1: resolution: {