diff --git a/package.json b/package.json index 0aecc0d..f3d5bf8 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@antfu/eslint-config": "^2.19.1", - "@types/node": "^20.12.12", + "@types/node": "^20.12.13", "eslint": "^9.3.0", "typescript": "^5.4.5", "vitepress": "^1.2.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ae3d67..9b42158 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,8 +25,8 @@ importers: specifier: ^2.19.1 version: 2.19.1(@vue/compiler-sfc@3.4.27)(eslint@9.3.0)(typescript@5.4.5) '@types/node': - specifier: ^20.12.12 - version: 20.12.12 + specifier: ^20.12.13 + version: 20.12.13 eslint: specifier: ^9.3.0 version: 9.3.0 @@ -35,7 +35,7 @@ importers: version: 5.4.5 vitepress: specifier: ^1.2.2 - version: 1.2.2(@algolia/client-search@4.23.3)(@types/node@20.12.12)(markdown-it-mathjax3@4.3.2)(postcss@8.4.38)(search-insights@2.14.0)(typescript@5.4.5) + version: 1.2.2(@algolia/client-search@4.23.3)(@types/node@20.12.13)(markdown-it-mathjax3@4.3.2)(postcss@8.4.38)(search-insights@2.14.0)(typescript@5.4.5) packages: @@ -215,8 +215,8 @@ packages: search-insights: optional: true - '@es-joy/jsdoccomment@0.43.0': - resolution: {integrity: sha512-Q1CnsQrytI3TlCB1IVWXWeqUIPGVEKGaE7IbVdt13Nq/3i0JESAkQQERrfiQkmlpijl+++qyqPgaS31Bvc1jRQ==} + '@es-joy/jsdoccomment@0.43.1': + resolution: {integrity: sha512-I238eDtOolvCuvtxrnqtlBaw0BwdQuYqK7eA6XIonicMdOOOb75mqdIzkGDUbS04+1Di007rgm9snFRNeVrOog==} engines: {node: '>=16'} '@esbuild/aix-ppc64@0.20.2': @@ -580,8 +580,8 @@ packages: '@types/ms@0.7.34': resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==} - '@types/node@20.12.12': - resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + '@types/node@20.12.13': + resolution: {integrity: sha512-gBGeanV41c1L171rR7wjbMiEpEI/l5XFQdLLfhr/REwpgDy/4U8y89+i8kRiLzDyZdOkXh+cRaTetUnCYutoXA==} '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -1147,8 +1147,8 @@ packages: domutils@2.8.0: resolution: {integrity: sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==} - electron-to-chromium@1.4.783: - resolution: {integrity: sha512-bT0jEz/Xz1fahQpbZ1D7LgmPYZ3iHVY39NcWWro1+hA2IvjiPeaXtfSqrQ+nXjApMvQRE2ASt1itSLRrebHMRQ==} + electron-to-chromium@1.4.786: + resolution: {integrity: sha512-i/A2UB0sxYViMN0M2zIotQFRIOt1jLuVXudACHBDiJ5gGuAUzf/crZxwlBTdA0O52Hy4CNtTzS7AKRAacs/08Q==} elkjs@0.9.3: resolution: {integrity: sha512-f/ZeWvW/BCXbhGEf1Ujp29EASo/lk1FDnETgNKwJrsVvGZhUWCZyg3xLJjAsxfOmt8KjswHmI5EwCQcPMpOYhQ==} @@ -1239,8 +1239,8 @@ packages: peerDependencies: eslint: ^8.56.0 || ^9.0.0-0 - eslint-plugin-jsdoc@48.2.6: - resolution: {integrity: sha512-GNk9jtpYmoEVeD/U6yYYmd6T8vSOoPs7CL8ZeX85iD8P3qifDdLQGze6+cw9boobDthmYnnxvIoHrhuSffj09g==} + eslint-plugin-jsdoc@48.2.7: + resolution: {integrity: sha512-fYj3roTnkFL9OFFTB129rico8lerC5G8Vp2ZW9SjO9RNWG0exVvI+i/Y8Bpm1ufjR0uvT38xtoab/U0Hp8Ybog==} engines: {node: '>=18'} peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 @@ -2516,7 +2516,7 @@ snapshots: eslint-plugin-command: 0.2.3(eslint@9.3.0) eslint-plugin-eslint-comments: 3.2.0(eslint@9.3.0) eslint-plugin-import-x: 0.5.1(eslint@9.3.0)(typescript@5.4.5) - eslint-plugin-jsdoc: 48.2.6(eslint@9.3.0) + eslint-plugin-jsdoc: 48.2.7(eslint@9.3.0) eslint-plugin-jsonc: 2.16.0(eslint@9.3.0) eslint-plugin-markdown: 5.0.0(eslint@9.3.0) eslint-plugin-n: 17.7.0(eslint@9.3.0) @@ -2615,7 +2615,7 @@ snapshots: transitivePeerDependencies: - '@algolia/client-search' - '@es-joy/jsdoccomment@0.43.0': + '@es-joy/jsdoccomment@0.43.1': dependencies: '@types/eslint': 8.56.10 '@types/estree': 1.0.5 @@ -2899,7 +2899,7 @@ snapshots: '@types/ms@0.7.34': {} - '@types/node@20.12.12': + '@types/node@20.12.13': dependencies: undici-types: 5.26.5 @@ -2992,9 +2992,9 @@ snapshots: '@typescript-eslint/types': 7.11.0 eslint-visitor-keys: 3.4.3 - '@vitejs/plugin-vue@5.0.4(vite@5.2.12(@types/node@20.12.12))(vue@3.4.27(typescript@5.4.5))': + '@vitejs/plugin-vue@5.0.4(vite@5.2.12(@types/node@20.12.13))(vue@3.4.27(typescript@5.4.5))': dependencies: - vite: 5.2.12(@types/node@20.12.12) + vite: 5.2.12(@types/node@20.12.13) vue: 3.4.27(typescript@5.4.5) '@vue/compiler-core@3.4.27': @@ -3168,7 +3168,7 @@ snapshots: browserslist@4.23.0: dependencies: caniuse-lite: 1.0.30001625 - electron-to-chromium: 1.4.783 + electron-to-chromium: 1.4.786 node-releases: 2.0.14 update-browserslist-db: 1.0.16(browserslist@4.23.0) @@ -3518,7 +3518,7 @@ snapshots: domelementtype: 2.3.0 domhandler: 4.3.1 - electron-to-chromium@1.4.783: {} + electron-to-chromium@1.4.786: {} elkjs@0.9.3: {} @@ -3605,7 +3605,7 @@ snapshots: eslint-plugin-command@0.2.3(eslint@9.3.0): dependencies: - '@es-joy/jsdoccomment': 0.43.0 + '@es-joy/jsdoccomment': 0.43.1 eslint: 9.3.0 eslint-plugin-es-x@7.6.0(eslint@9.3.0): @@ -3637,9 +3637,9 @@ snapshots: - supports-color - typescript - eslint-plugin-jsdoc@48.2.6(eslint@9.3.0): + eslint-plugin-jsdoc@48.2.7(eslint@9.3.0): dependencies: - '@es-joy/jsdoccomment': 0.43.0 + '@es-joy/jsdoccomment': 0.43.1 are-docs-informative: 0.0.2 comment-parser: 1.4.1 debug: 4.3.4 @@ -4790,23 +4790,23 @@ snapshots: spdx-correct: 3.2.0 spdx-expression-parse: 3.0.1 - vite@5.2.12(@types/node@20.12.12): + vite@5.2.12(@types/node@20.12.13): dependencies: esbuild: 0.20.2 postcss: 8.4.38 rollup: 4.18.0 optionalDependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 fsevents: 2.3.3 - vitepress@1.2.2(@algolia/client-search@4.23.3)(@types/node@20.12.12)(markdown-it-mathjax3@4.3.2)(postcss@8.4.38)(search-insights@2.14.0)(typescript@5.4.5): + vitepress@1.2.2(@algolia/client-search@4.23.3)(@types/node@20.12.13)(markdown-it-mathjax3@4.3.2)(postcss@8.4.38)(search-insights@2.14.0)(typescript@5.4.5): dependencies: '@docsearch/css': 3.6.0 '@docsearch/js': 3.6.0(@algolia/client-search@4.23.3)(search-insights@2.14.0) '@shikijs/core': 1.6.1 '@shikijs/transformers': 1.6.1 '@types/markdown-it': 14.1.1 - '@vitejs/plugin-vue': 5.0.4(vite@5.2.12(@types/node@20.12.12))(vue@3.4.27(typescript@5.4.5)) + '@vitejs/plugin-vue': 5.0.4(vite@5.2.12(@types/node@20.12.13))(vue@3.4.27(typescript@5.4.5)) '@vue/devtools-api': 7.2.1(vue@3.4.27(typescript@5.4.5)) '@vue/shared': 3.4.27 '@vueuse/core': 10.10.0(vue@3.4.27(typescript@5.4.5)) @@ -4815,7 +4815,7 @@ snapshots: mark.js: 8.11.1 minisearch: 6.3.0 shiki: 1.6.1 - vite: 5.2.12(@types/node@20.12.12) + vite: 5.2.12(@types/node@20.12.13) vue: 3.4.27(typescript@5.4.5) optionalDependencies: markdown-it-mathjax3: 4.3.2 diff --git a/src/docs/vue/effect.md b/src/docs/vue/effect.md index 3fe8e90..fb1a6e1 100644 --- a/src/docs/vue/effect.md +++ b/src/docs/vue/effect.md @@ -1,8 +1,8 @@ --- -title: effect 源码分析 +title: effect.ts 源码分析 --- -# effect 源码分析 +# effect.ts 源码分析 ## effect.ts 源码分析 diff --git a/src/docs/vue/reactive-effect.md b/src/docs/vue/reactive-effect.md index 6cd6851..3baf49e 100644 --- a/src/docs/vue/reactive-effect.md +++ b/src/docs/vue/reactive-effect.md @@ -1,8 +1,8 @@ --- -title: ReactiveEffect.ts 源码分析 +title: reactiveEffect.ts 源码分析 --- -# ReactiveEffect.ts 源码分析 +# reactiveEffect.ts 源码分析 ## track 函数 @@ -52,13 +52,13 @@ export const MAP_KEY_ITERATE_KEY = Symbol(__DEV__ ? 'Map key iterate' : '') export function track(target: object, type: TrackOpTypes, key: unknown) { if (shouldTrack && activeEffect) { let depsMap = targetMap.get(target) - if (!depsMap) + if (!depsMap) { targetMap.set(target, (depsMap = new Map())) - + } let dep = depsMap.get(key) - if (!dep) + if (!dep) { depsMap.set(key, (dep = createDep(() => depsMap!.delete(key)))) - + } trackEffect( activeEffect, dep, @@ -110,8 +110,9 @@ export function trigger( } else { // schedule runs for SET | ADD | DELETE - if (key !== void 0) + if (key !== void 0) { deps.push(depsMap.get(key)) + } // also run for iteration key on ADD | DELETE | Map.SET switch (type) { @@ -169,6 +170,7 @@ export function trigger( * @param key */ export function getDepFromReactive(object: any, key: string | number | symbol) { - return targetMap.get(object)?.get(key) + const depsMap = targetMap.get(object) + return depsMap && depsMap.get(key) } ```