From 63f7983d0a30bc4804ee527e52e68072ef3bf1aa Mon Sep 17 00:00:00 2001 From: Freddy Date: Mon, 18 Jul 2022 13:14:19 +0200 Subject: [PATCH] feat(import-wrappers): supports asynchronous loading of wrapped component --- .eslintrc.cjs | 3 + .../import-wrappers/HydrateNeverDemo.vue | 6 +- .../HydrateOnInteractionDemo.vue | 6 +- .../import-wrappers/HydrateWhenIdleDemo.vue | 6 +- .../HydrateWhenTriggeredDemo.vue | 4 +- .../HydrateWhenVisibleDemo.vue | 6 +- src/components/LazyHydrationWrapper.js | 118 +++++----- .../useHydrateOnInteraction.spec.js | 10 +- src/composables/useHydrateWhenIdle.spec.js | 10 +- .../useHydrateWhenTriggered.spec.js | 6 +- src/composables/useHydrateWhenVisible.spec.js | 11 +- src/composables/useLazyHydration.spec.js | 16 +- src/utils/create-hydration-wrapper.js | 148 ++++++++++-- src/utils/create-hydration-wrapper.spec.js | 216 ++++++++++++++++++ src/utils/helpers.js | 2 + src/utils/index.js | 2 + src/utils/traverse-children.js | 5 +- src/utils/traverse-children.spec.js | 6 +- src/wrappers/hydrate-never.js | 5 +- src/wrappers/hydrate-never.spec.js | 68 ++++++ src/wrappers/hydrate-on-interaction.js | 8 +- src/wrappers/hydrate-on-interaction.spec.js | 74 ++++++ src/wrappers/hydrate-when-idle.js | 8 +- src/wrappers/hydrate-when-idle.spec.js | 85 +++++++ src/wrappers/hydrate-when-triggered.js | 10 +- src/wrappers/hydrate-when-triggered.spec.js | 81 +++++++ src/wrappers/hydrate-when-visible.js | 8 +- src/wrappers/hydrate-when-visible.spec.js | 91 ++++++++ test/utils.js | 10 +- vite.config.js | 9 +- 30 files changed, 889 insertions(+), 149 deletions(-) create mode 100644 src/utils/create-hydration-wrapper.spec.js create mode 100644 src/utils/helpers.js create mode 100644 src/wrappers/hydrate-never.spec.js create mode 100644 src/wrappers/hydrate-on-interaction.spec.js create mode 100644 src/wrappers/hydrate-when-idle.spec.js create mode 100644 src/wrappers/hydrate-when-triggered.spec.js create mode 100644 src/wrappers/hydrate-when-visible.spec.js diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ae334ae..0ee4c14 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -11,6 +11,9 @@ module.exports = { node: true, 'vue/setup-compiler-macros': true, }, + globals: { + __DEV__: 'readonly', + }, rules: { 'prettier/prettier': 'error', 'import/no-extraneous-dependencies': ['error', { devDependencies: true }], diff --git a/demo/views/import-wrappers/HydrateNeverDemo.vue b/demo/views/import-wrappers/HydrateNeverDemo.vue index 8ded7e0..aa93b9b 100644 --- a/demo/views/import-wrappers/HydrateNeverDemo.vue +++ b/demo/views/import-wrappers/HydrateNeverDemo.vue @@ -1,11 +1,11 @@ diff --git a/demo/views/import-wrappers/HydrateWhenVisibleDemo.vue b/demo/views/import-wrappers/HydrateWhenVisibleDemo.vue index 27b3fe9..8275d27 100644 --- a/demo/views/import-wrappers/HydrateWhenVisibleDemo.vue +++ b/demo/views/import-wrappers/HydrateWhenVisibleDemo.vue @@ -1,11 +1,11 @@