From ec0ce297f673171d7d9c6b6f9e7e1a36adb5f832 Mon Sep 17 00:00:00 2001 From: Nicolai Moraru Date: Fri, 26 Jul 2024 21:50:42 +0300 Subject: [PATCH] feat(checkpoints): add useCheckpoint composable --- .vscode/settings.json | 12 +- packages/private/docs/.vitepress/config.mts | 7 + .../.vitepress/theme/components/MyLayout.vue | 10 +- .../theme/components/VPSwitchStoreStyle.vue | 21 +-- .../theme/composables/useBodyClass.mts | 18 +++ .../docs/api/checkpoints/composables.md | 76 +++++++++++ .../private/docs/api/checkpoints/context.md | 122 ++++++++++++++++++ .../getting-started/connect-to-vuejs-app.md | 2 + .../docs/guide/usage-with-typescript.md | 7 +- packages/private/docs/package.json | 1 + .../src/@types/_internal/common.ts | 9 +- .../custom-store/checkpoints/composables.ts | 7 + .../@types/custom-store/checkpoints/index.ts | 1 + .../checkpoints/with-schemas/composables.ts | 7 + .../without-schemas/composables.ts | 7 + .../src/@types/custom-store/index.ts | 2 + .../default-store/checkpoints/composables.ts | 7 + .../@types/default-store/checkpoints/index.ts | 1 + .../checkpoints/with-schemas/composables.ts | 4 + .../without-schemas/composables.ts | 4 + .../src/@types/default-store/context.ts | 5 +- .../src/@types/default-store/index.ts | 2 + .../vue-tinybase/src/common/useListenable.ts | 6 +- .../vue-tinybase/src/common/useListener.ts | 8 +- .../checkpoints/composables.test.ts | 29 +++++ .../custom-store/checkpoints/composables.ts | 8 ++ .../custom-store/checkpoints/context.test.ts | 39 ++++++ .../src/custom-store/checkpoints/context.ts | 31 +++++ .../src/custom-store/checkpoints/index.ts | 1 + .../vue-tinybase/src/custom-store/lib.ts | 1 + .../src/custom-store/store/references.ts | 2 +- .../checkpoints/composables.test.ts | 31 +++++ .../default-store/checkpoints/composables.ts | 10 ++ .../default-store/checkpoints/context.test.ts | 34 +++++ .../src/default-store/checkpoints/context.ts | 19 +++ .../src/default-store/store/references.ts | 2 +- .../vue-tinybase/src/test-utils/store.ts | 20 ++- pnpm-lock.yaml | 24 +++- 38 files changed, 561 insertions(+), 36 deletions(-) create mode 100644 packages/private/docs/.vitepress/theme/composables/useBodyClass.mts create mode 100644 packages/private/docs/api/checkpoints/composables.md create mode 100644 packages/private/docs/api/checkpoints/context.md create mode 100644 packages/public/vue-tinybase/src/@types/custom-store/checkpoints/composables.ts create mode 100644 packages/public/vue-tinybase/src/@types/custom-store/checkpoints/index.ts create mode 100644 packages/public/vue-tinybase/src/@types/custom-store/checkpoints/with-schemas/composables.ts create mode 100644 packages/public/vue-tinybase/src/@types/custom-store/checkpoints/without-schemas/composables.ts create mode 100644 packages/public/vue-tinybase/src/@types/default-store/checkpoints/composables.ts create mode 100644 packages/public/vue-tinybase/src/@types/default-store/checkpoints/index.ts create mode 100644 packages/public/vue-tinybase/src/@types/default-store/checkpoints/with-schemas/composables.ts create mode 100644 packages/public/vue-tinybase/src/@types/default-store/checkpoints/without-schemas/composables.ts create mode 100644 packages/public/vue-tinybase/src/custom-store/checkpoints/composables.test.ts create mode 100644 packages/public/vue-tinybase/src/custom-store/checkpoints/composables.ts create mode 100644 packages/public/vue-tinybase/src/custom-store/checkpoints/context.test.ts create mode 100644 packages/public/vue-tinybase/src/custom-store/checkpoints/context.ts create mode 100644 packages/public/vue-tinybase/src/custom-store/checkpoints/index.ts create mode 100644 packages/public/vue-tinybase/src/default-store/checkpoints/composables.test.ts create mode 100644 packages/public/vue-tinybase/src/default-store/checkpoints/composables.ts create mode 100644 packages/public/vue-tinybase/src/default-store/checkpoints/context.test.ts create mode 100644 packages/public/vue-tinybase/src/default-store/checkpoints/context.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index c53688b..ed0cc91 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,15 @@ "vue.complete.casing.tags": "pascal", "typescript.preferences.importModuleSpecifier": "non-relative", "typescript.tsdk": "node_modules/typescript/lib", - "cSpell.words": ["composables", "Pinia", "Tinybase", "todos", "wildcarded"] + "cSpell.words": [ + "composables", + "Moraru", + "Pinia", + "pkgroll", + "Tinybase", + "todos", + "vitepress", + "vueuse", + "wildcarded" + ] } diff --git a/packages/private/docs/.vitepress/config.mts b/packages/private/docs/.vitepress/config.mts index 83f4410..a541b4d 100644 --- a/packages/private/docs/.vitepress/config.mts +++ b/packages/private/docs/.vitepress/config.mts @@ -37,6 +37,13 @@ export default defineConfig({ { text: 'Writable References', link: '/api/store/references' }, ], }, + { + text: 'Checkpoints', + items: [ + { text: 'Composables', link: '/api/checkpoints/composables' }, + { text: 'Context', link: '/api/checkpoints/context' }, + ], + }, { text: 'Common', items: [ diff --git a/packages/private/docs/.vitepress/theme/components/MyLayout.vue b/packages/private/docs/.vitepress/theme/components/MyLayout.vue index 2b10b9f..6ab1bdb 100644 --- a/packages/private/docs/.vitepress/theme/components/MyLayout.vue +++ b/packages/private/docs/.vitepress/theme/components/MyLayout.vue @@ -3,19 +3,27 @@ import { useRoute } from 'vitepress' import DefaultTheme from 'vitepress/theme' import VPSwitchStoreStyle from './VPSwitchStoreStyle.vue' import { computed } from 'vue' +import { useBodyClass } from '../composables/useBodyClass.mjs' +import { useLocalStorage } from '@vueuse/core' const { Layout } = DefaultTheme const route = useRoute() const isApiPage = computed(() => route.path.startsWith('/api')) + +const isDefaultStore = useLocalStorage('isDefaultStoreSelected', true) +useBodyClass(isDefaultStore, { + trueClass: 'default-store', + falseClass: 'custom-store', +})