nanime 0.0.5 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +2 -1
  3. package/dist/runtime/app/components/transition/Slide.vue +2 -2
  4. package/dist/runtime/app/composables/useAnimatable.d.ts +1 -1
  5. package/dist/runtime/app/composables/useAnimatable.js +27 -16
  6. package/dist/runtime/app/composables/useAnimate.d.ts +2 -2
  7. package/dist/runtime/app/composables/useAnimate.js +27 -16
  8. package/dist/runtime/app/composables/useDraggable.js +1 -2
  9. package/dist/runtime/app/composables/useLayout.d.ts +1 -1
  10. package/dist/runtime/app/composables/useLayout.js +1 -1
  11. package/dist/runtime/app/composables/useSplitText.d.ts +9 -47
  12. package/dist/runtime/app/composables/useSplitText.js +3 -5
  13. package/dist/runtime/app/composables/useWaapiAnimate.d.ts +2 -2
  14. package/dist/runtime/app/composables/useWaapiAnimate.js +25 -13
  15. package/dist/runtime/app/utils/create-proxy.js +1 -1
  16. package/dist/runtime/app/utils/extract-props.d.ts +5 -0
  17. package/dist/runtime/app/utils/extract-props.js +13 -0
  18. package/dist/runtime/app/utils/normalize-targets.d.ts +1 -1
  19. package/dist/runtime/app/utils/normalize-targets.js +1 -1
  20. package/dist/runtime/app/utils/normalizers/instance-management.d.ts +5 -0
  21. package/dist/runtime/app/utils/normalizers/instance-management.js +10 -0
  22. package/dist/runtime/app/utils/normalizers/make-reffable.d.ts +1 -1
  23. package/dist/runtime/app/utils/normalizers/make-reffable.js +1 -1
  24. package/dist/runtime/app/utils/types.d.ts +1 -0
  25. package/dist/runtime/app/utils/types.js +0 -0
  26. package/package.json +7 -2
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.13.5 <5.0.0"
6
6
  },
7
- "version": "0.0.5",
7
+ "version": "0.0.8",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -48,8 +48,9 @@ const module$1 = defineNuxtModule({
48
48
  }
49
49
  _nuxt.options.alias[`#${__configKey}/composables`] = resolver.resolve("./runtime/app/composables");
50
50
  _nuxt.options.alias[`#${__configKey}/components`] = resolver.resolve("./runtime/app/components");
51
- _nuxt.options.alias[`#${__configKey}/utils`] = resolver.resolve("./runtime/app/utils");
51
+ _nuxt.options.alias[`#${__configKey}/types`] = resolver.resolve("./runtime/app/utils/types");
52
52
  _nuxt.options.alias[`#${__configKey}/easings`] = resolver.resolve("./runtime/app/utils/easings");
53
+ _nuxt.options.alias[`#${__configKey}/utils`] = resolver.resolve("./runtime/app/utils/index");
53
54
  }
54
55
  });
55
56
 
@@ -1,8 +1,8 @@
1
1
  <script setup>
2
- import { TransitionGroup, Transition } from "vue";
2
+ import { TransitionGroup, Transition, nextTick, unref, useTemplateRef, computed } from "vue";
3
3
  import { isStandardEase, isWaapiEase } from "./types";
4
4
  import { animate, utils, waapi } from "animejs";
5
- import { nextTick, unref, useAnimeLayout, useTemplateRef, computed } from "#imports";
5
+ import { useAnimeLayout } from "../../composables/useLayout";
6
6
  import { normalizeAxis, normalizeDuration, normalizeOffset } from "../../utils/transitions/normalizers";
7
7
  const props = defineProps({
8
8
  duration: { type: [Number, Array, Object], required: false, default: () => ({
@@ -1,4 +1,4 @@
1
- import { type MaybeRefOrGetter } from '#imports';
1
+ import { type MaybeRefOrGetter } from 'vue';
2
2
  import { normalizeAnimeTarget } from '../utils/normalize-targets.js';
3
3
  import type { AnimatableObject, AnimatableParams } from 'animejs';
4
4
  export declare function useAnimatable(target: Parameters<typeof normalizeAnimeTarget>[0], options?: MaybeRefOrGetter<AnimatableParams>): AnimatableObject;
@@ -1,21 +1,32 @@
1
1
  import { createAnimatable } from "animejs/animatable";
2
- import { tryOnScopeDispose, useMounted } from "@vueuse/core";
3
- import { shallowReactive, toValue, watchEffect } from "#imports";
2
+ import { toReactive, tryOnScopeDispose, useMounted } from "@vueuse/core";
3
+ import { shallowRef, toValue, watchEffect, nextTick } from "vue";
4
4
  import { normalizeAnimeTarget } from "../utils/normalize-targets.js";
5
+ import { AnimationComponentFlags, getAnimationComponentFlag } from "../utils/normalizers/instance-management.js";
5
6
  export function useAnimatable(target, options) {
7
+ const flag = getAnimationComponentFlag();
8
+ const animatable = shallowRef(createAnimatable({}, {}));
6
9
  const mounted = useMounted();
7
- const animatable = shallowReactive(createAnimatable({}, {}));
8
- let oldTarget;
9
- watchEffect(() => {
10
- if (!mounted.value) return;
11
- const targets = normalizeAnimeTarget(target);
12
- if (oldTarget === targets) return;
13
- oldTarget = targets;
14
- const newAnimatable = createAnimatable(targets, toValue(options) || {});
15
- Object.assign(animatable, newAnimatable);
16
- });
17
- tryOnScopeDispose(() => {
18
- animatable.revert();
19
- });
20
- return animatable;
10
+ if (flag === AnimationComponentFlags.Watchable) {
11
+ let oldTarget;
12
+ watchEffect(() => {
13
+ if (!mounted.value) return;
14
+ const targets = normalizeAnimeTarget(target);
15
+ if (oldTarget === targets) return;
16
+ oldTarget = targets;
17
+ const newAnimatable = createAnimatable(targets, toValue(options) || {});
18
+ animatable.value = newAnimatable;
19
+ });
20
+ tryOnScopeDispose(() => {
21
+ animatable.value.revert();
22
+ });
23
+ } else {
24
+ nextTick(() => {
25
+ const targets = normalizeAnimeTarget(target);
26
+ if (!targets) return;
27
+ const newAnimatable = createAnimatable(targets, toValue(options) || {});
28
+ animatable.value = newAnimatable;
29
+ });
30
+ }
31
+ return toReactive(animatable);
21
32
  }
@@ -1,5 +1,5 @@
1
- import { type MaybeRefOrGetter } from '#imports';
1
+ import { type MaybeRefOrGetter } from 'vue';
2
2
  import { normalizeAnimeTarget } from '../utils/normalize-targets.js';
3
3
  import type { AnimationParams } from 'animejs';
4
4
  import { type JSAnimation } from 'animejs/animation';
5
- export declare function useAnimate(target: Parameters<typeof normalizeAnimeTarget>[0], options?: MaybeRefOrGetter<AnimationParams>): JSAnimation;
5
+ export declare function useAnimate(target: Parameters<typeof normalizeAnimeTarget>[0], parameters?: MaybeRefOrGetter<AnimationParams>): JSAnimation;
@@ -1,22 +1,33 @@
1
1
  import { toReactive, tryOnScopeDispose, useMounted } from "@vueuse/core";
2
- import { shallowRef, toValue, watchEffect } from "#imports";
2
+ import { shallowRef, toValue, watchEffect, nextTick } from "vue";
3
3
  import { normalizeAnimeTarget } from "../utils/normalize-targets.js";
4
4
  import { animate } from "animejs/animation";
5
- export function useAnimate(target, options) {
6
- const mounted = useMounted();
5
+ import { AnimationComponentFlags, getAnimationComponentFlag } from "../utils/normalizers/instance-management.js";
6
+ export function useAnimate(target, parameters) {
7
+ const flag = getAnimationComponentFlag();
7
8
  const animation = shallowRef(animate({}, {}));
8
- let oldTarget;
9
- watchEffect(() => {
10
- if (!mounted.value) return;
11
- const targets = normalizeAnimeTarget(target);
12
- if (oldTarget === targets) return;
13
- if (animation.value) animation.value.revert();
14
- oldTarget = targets;
15
- const newAnimation = animate(targets, toValue(options) || {});
16
- animation.value = newAnimation;
17
- });
18
- tryOnScopeDispose(() => {
19
- animation.value?.revert();
20
- });
9
+ const mounted = useMounted();
10
+ if (flag === AnimationComponentFlags.Watchable) {
11
+ let oldTarget;
12
+ watchEffect(() => {
13
+ if (!mounted.value) return;
14
+ const targets = normalizeAnimeTarget(target);
15
+ if (oldTarget === targets) return;
16
+ if (animation.value) animation.value.revert();
17
+ oldTarget = targets;
18
+ const newAnimation = animate(targets, toValue(parameters) || {});
19
+ animation.value = newAnimation;
20
+ });
21
+ tryOnScopeDispose(() => {
22
+ animation.value?.revert();
23
+ });
24
+ } else {
25
+ nextTick(() => {
26
+ const targets = normalizeAnimeTarget(target);
27
+ if (!targets) return;
28
+ const newAnimation = animate(targets, toValue(parameters) || {});
29
+ animation.value = newAnimation;
30
+ });
31
+ }
21
32
  return toReactive(animation);
22
33
  }
@@ -1,5 +1,5 @@
1
1
  import { tryOnScopeDispose, useMounted } from "@vueuse/core";
2
- import { nextTick, shallowRef, toValue, watch, watchPostEffect } from "#imports";
2
+ import { nextTick, shallowRef, toValue, watch, watchPostEffect } from "vue";
3
3
  import { normalizeAnimeTarget, normalizeDraggableContainer, normalizeLayoutTarget } from "../utils/normalize-targets.js";
4
4
  import { createDraggable } from "animejs/draggable";
5
5
  import { createProxy } from "../utils/create-proxy.js";
@@ -56,7 +56,6 @@ export function useDraggable(target, options) {
56
56
  x: resolveAxis(options?.x),
57
57
  y: resolveAxis(options?.y)
58
58
  });
59
- console.log("initializing");
60
59
  dragController.value = dragEngine;
61
60
  },
62
61
  {
@@ -1,4 +1,4 @@
1
- import { type MaybeRef, type MaybeRefOrGetter } from '#imports';
1
+ import { type MaybeRef, type MaybeRefOrGetter } from 'vue';
2
2
  import { type AutoLayoutParams, type LayoutAnimationParams } from 'animejs/layout';
3
3
  import { normalizeLayoutTarget } from '../utils/normalize-targets.js';
4
4
  export declare function useAnimeLayout(target: MaybeRef<Parameters<typeof normalizeLayoutTarget>[0]>, options?: MaybeRefOrGetter<AutoLayoutParams>): {
@@ -1,4 +1,4 @@
1
- import { computed, shallowRef, toValue, watchEffect } from "#imports";
1
+ import { computed, shallowRef, toValue, watchEffect } from "vue";
2
2
  import { createLayout } from "animejs/layout";
3
3
  import { normalizeLayoutTarget } from "../utils/normalize-targets.js";
4
4
  import { extractNonFunctionProperties } from "../utils/extract-props.js";
@@ -1,50 +1,12 @@
1
- import { type MaybeRef, type MaybeRefOrGetter } from '#imports';
1
+ import { type ComputedRef, type MaybeRef, type MaybeRefOrGetter, type Ref } from 'vue';
2
2
  import { splitText, type TextSplitter } from 'animejs/text';
3
3
  import { normalizeSplitTextTarget } from '../utils/normalize-targets.js';
4
- export declare function useSplitText(target: MaybeRef<Parameters<typeof normalizeSplitTextTarget>[0]>, parameters?: MaybeRefOrGetter<Parameters<typeof splitText>[1]>): {
5
- lines: import("vue").ShallowRef<HTMLElement[], HTMLElement[]>;
6
- words: import("vue").ShallowRef<HTMLElement[], HTMLElement[]>;
7
- chars: import("vue").ShallowRef<HTMLElement[], HTMLElement[]>;
8
- properties: import("vue").ComputedRef<import("../utils/extract-props.js").NonFunctionProperties<{
9
- debug: boolean;
10
- includeSpaces: boolean;
11
- accessible: boolean;
12
- linesOnly: boolean;
13
- lineTemplate: string | false | import("animejs").SplitFunctionValue;
14
- wordTemplate: string | false | import("animejs").SplitFunctionValue;
15
- charTemplate: string | false | import("animejs").SplitFunctionValue;
16
- $target: HTMLElement;
17
- html: string;
18
- lines: any[];
19
- words: any[];
20
- chars: any[];
21
- effects: any[];
22
- effectsCleanups: any[];
23
- cache: string;
24
- ready: boolean;
25
- width: number;
26
- resizeTimeout: {
27
- close: () => NodeJS.Timeout;
28
- hasRef: () => boolean;
29
- ref: () => NodeJS.Timeout;
30
- refresh: () => NodeJS.Timeout;
31
- unref: () => NodeJS.Timeout;
32
- _onTimeout: (...args: any[]) => void;
33
- [Symbol.toPrimitive]: () => number;
34
- [Symbol.dispose]: () => void;
35
- };
36
- resizeObserver: {
37
- disconnect: () => void;
38
- observe: (target: Element, options?: ResizeObserverOptions) => void;
39
- unobserve: (target: Element) => void;
40
- };
41
- addEffect: (effect: (...args: any[]) => import("animejs").Tickable | (() => void)) => void | TextSplitter;
42
- revert: () => TextSplitter;
43
- splitNode: (node: Node) => void;
44
- split: (clearCache?: boolean) => TextSplitter;
45
- refresh: () => void;
46
- }> | undefined>;
47
- revert: () => TextSplitter | undefined;
48
- split: () => TextSplitter | undefined;
49
- refresh: () => void | undefined;
4
+ import { type NonFunctionProperties, type OnlyFunctionProperties } from '../utils/extract-props.js';
5
+ type SplitText = {
6
+ [x in 'lines' | 'words' | 'chars']: Ref<HTMLElement[]>;
7
+ } & {
8
+ properties: ComputedRef<NonFunctionProperties<TextSplitter> | undefined>;
9
+ methods: ComputedRef<OnlyFunctionProperties<TextSplitter> | undefined>;
50
10
  };
11
+ export declare function useSplitText(target: MaybeRef<Parameters<typeof normalizeSplitTextTarget>[0]>, parameters?: MaybeRefOrGetter<Parameters<typeof splitText>[1]>): SplitText;
12
+ export {};
@@ -1,7 +1,7 @@
1
- import { computed, nextTick, ref, shallowRef, toValue, watchEffect } from "#imports";
1
+ import { computed, nextTick, ref, shallowRef, toValue, watchEffect } from "vue";
2
2
  import { splitText } from "animejs/text";
3
3
  import { normalizeSplitTextTarget } from "../utils/normalize-targets.js";
4
- import { extractNonFunctionProperties } from "../utils/extract-props.js";
4
+ import { extractNonFunctionProperties, extractOnlyFunctionProperties } from "../utils/extract-props.js";
5
5
  import { tryOnScopeDispose, useMounted } from "@vueuse/core";
6
6
  export function useSplitText(target, parameters) {
7
7
  const mounted = useMounted();
@@ -41,8 +41,6 @@ export function useSplitText(target, parameters) {
41
41
  words,
42
42
  chars,
43
43
  properties: computed(() => splitter.value ? extractNonFunctionProperties(splitter.value) : void 0),
44
- revert: () => splitter.value?.revert(),
45
- split: () => splitter.value?.split(),
46
- refresh: () => splitter.value?.refresh()
44
+ methods: computed(() => splitter.value ? extractOnlyFunctionProperties(splitter.value) : void 0)
47
45
  };
48
46
  }
@@ -1,5 +1,5 @@
1
- import { type MaybeRefOrGetter } from '#imports';
1
+ import { type MaybeRefOrGetter } from 'vue';
2
2
  import type { WAAPIAnimationParams } from 'animejs';
3
3
  import { normalizeWaapiAnimeTarget } from '../utils/normalize-targets.js';
4
4
  import { type WAAPIAnimation } from 'animejs/waapi';
5
- export declare function useWaapiAnimate(target: Parameters<typeof normalizeWaapiAnimeTarget>[0], options?: MaybeRefOrGetter<WAAPIAnimationParams>): WAAPIAnimation;
5
+ export declare function useWaapiAnimate(target: Parameters<typeof normalizeWaapiAnimeTarget>[0], parameters?: MaybeRefOrGetter<WAAPIAnimationParams>): WAAPIAnimation;
@@ -1,19 +1,31 @@
1
1
  import { toReactive, tryOnScopeDispose, useMounted } from "@vueuse/core";
2
- import { shallowRef, toValue, watchEffect } from "#imports";
2
+ import { shallowRef, toValue, watchEffect, nextTick } from "vue";
3
3
  import { normalizeWaapiAnimeTarget } from "../utils/normalize-targets.js";
4
4
  import { waapi } from "animejs/waapi";
5
- export function useWaapiAnimate(target, options) {
6
- const mounted = useMounted();
5
+ import { AnimationComponentFlags, getAnimationComponentFlag } from "../utils/normalizers/instance-management.js";
6
+ export function useWaapiAnimate(target, parameters) {
7
+ const flag = getAnimationComponentFlag();
7
8
  const animation = shallowRef(waapi.animate([], {}));
8
- watchEffect(() => {
9
- const targets = normalizeWaapiAnimeTarget(target);
10
- if (!mounted.value || !targets) return;
11
- if (animation.value) animation.value.revert();
12
- const newAnimation = waapi.animate(targets, toValue(options) || {});
13
- animation.value = newAnimation;
14
- });
15
- tryOnScopeDispose(() => {
16
- animation.value?.revert();
17
- });
9
+ const mounted = useMounted();
10
+ if (flag === AnimationComponentFlags.Watchable) {
11
+ watchEffect(() => {
12
+ const targets = normalizeWaapiAnimeTarget(target);
13
+ if (!mounted.value || !targets) return;
14
+ if (animation.value) animation.value.revert();
15
+ const newAnimation = waapi.animate(targets, toValue(parameters) || {});
16
+ animation.value = newAnimation;
17
+ });
18
+ tryOnScopeDispose(() => {
19
+ animation.value?.revert();
20
+ });
21
+ } else {
22
+ nextTick(() => {
23
+ const targets = normalizeWaapiAnimeTarget(target);
24
+ if (!targets) return;
25
+ if (animation.value) animation.value.revert();
26
+ const newAnimation = waapi.animate(targets, toValue(parameters) || {});
27
+ animation.value = newAnimation;
28
+ });
29
+ }
18
30
  return toReactive(animation);
19
31
  }
@@ -1,4 +1,4 @@
1
- import { unref, isRef, reactive } from "#imports";
1
+ import { unref, isRef, reactive } from "vue";
2
2
  export function createProxy(objectRef) {
3
3
  const proxy = new Proxy({}, {
4
4
  get(_, p, receiver) {
@@ -3,4 +3,9 @@ type NonFunctionKeys<T> = {
3
3
  }[keyof T];
4
4
  export type NonFunctionProperties<T> = Pick<T, NonFunctionKeys<T>>;
5
5
  export declare function extractNonFunctionProperties<T extends object>(obj: T): NonFunctionProperties<T>;
6
+ type FunctionKeys<T> = {
7
+ [K in keyof T]: T[K] extends Function ? K : never;
8
+ }[keyof T];
9
+ export type OnlyFunctionProperties<T> = Pick<T, FunctionKeys<T>>;
10
+ export declare function extractOnlyFunctionProperties<T extends object>(obj: T): OnlyFunctionProperties<T>;
6
11
  export {};
@@ -11,3 +11,16 @@ export function extractNonFunctionProperties(obj) {
11
11
  }
12
12
  return result;
13
13
  }
14
+ export function extractOnlyFunctionProperties(obj) {
15
+ if (!obj || typeof obj !== "object") return {};
16
+ const result = {};
17
+ for (const key in obj) {
18
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
19
+ const value = obj[key];
20
+ if (typeof value === "function") {
21
+ result[key] = value;
22
+ }
23
+ }
24
+ }
25
+ return result;
26
+ }
@@ -1,4 +1,4 @@
1
- import { type MaybeRef } from '#imports';
1
+ import { type MaybeRef } from 'vue';
2
2
  import type { MaybeElementRef, VueInstance } from '@vueuse/core';
3
3
  import type { TargetsParam, DOMTargetsParam, DOMTargetSelector, DraggableParams } from 'animejs';
4
4
  type WaapiElementTargets = VueInstance | HTMLElement | HTMLElement[] | SVGElement | SVGElement[] | NodeList | string | null;
@@ -1,4 +1,4 @@
1
- import { isReactive, toValue } from "#imports";
1
+ import { isReactive, toValue } from "vue";
2
2
  function isVueInstance(value) {
3
3
  return value !== null && typeof value === "object" && "$el" in value;
4
4
  }
@@ -0,0 +1,5 @@
1
+ export declare enum AnimationComponentFlags {
2
+ Watchable = 0,
3
+ Instant = 1
4
+ }
5
+ export declare function getAnimationComponentFlag(): AnimationComponentFlags;
@@ -0,0 +1,10 @@
1
+ import { getCurrentInstance } from "vue";
2
+ export var AnimationComponentFlags = /* @__PURE__ */ ((AnimationComponentFlags2) => {
3
+ AnimationComponentFlags2[AnimationComponentFlags2["Watchable"] = 0] = "Watchable";
4
+ AnimationComponentFlags2[AnimationComponentFlags2["Instant"] = 1] = "Instant";
5
+ return AnimationComponentFlags2;
6
+ })(AnimationComponentFlags || {});
7
+ export function getAnimationComponentFlag() {
8
+ return getCurrentInstance() ? 0 /* Watchable */ : 1 /* Instant */;
9
+ }
10
+ ;
@@ -1,4 +1,4 @@
1
- import { type MaybeRefOrGetter } from '#imports';
1
+ import { type MaybeRefOrGetter } from 'vue';
2
2
  export type MaybeRefOrArgsGetter<T, Args> = MaybeRefOrGetter<T> | ((data: Args) => T);
3
3
  export type MakeRefable<T, K extends keyof T, Args> = {
4
4
  [P in keyof T]?: P extends K ? MaybeRefOrArgsGetter<T[P], Args> : T[P];
@@ -1,4 +1,4 @@
1
- import { toValue } from "#imports";
1
+ import { toValue } from "vue";
2
2
  export function normalizeReffable(value, args) {
3
3
  if (typeof value === "function") {
4
4
  return value(args);
@@ -0,0 +1 @@
1
+ export type { AnimationParams, TargetsParam, AutoLayoutParams, EasingParam, LayoutAnimationParams, WAAPIEasingParam, Draggable, DraggableAxisParam, DraggableParams, WAAPIAnimationParams, DOMTargetsParam, DOMTargetSelector, AnimatableObject, AnimatableParams, } from 'animejs';
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanime",
3
- "version": "0.0.5",
3
+ "version": "0.0.8",
4
4
  "description": "Nuxt module for animejs integration and transitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,6 +38,12 @@
38
38
  "defu": "^6.1.4",
39
39
  "vue": "^3.5.27"
40
40
  },
41
+ "peerDependencies": {
42
+ "@vueuse/core": "^13.0.0",
43
+ "animejs": "^4.3.5",
44
+ "defu": "^6.1.4",
45
+ "vue": "^3.5.0"
46
+ },
41
47
  "devDependencies": {
42
48
  "@nuxt/devtools": "^3.1.1",
43
49
  "@nuxt/eslint-config": "^1.13.0",
@@ -58,7 +64,6 @@
58
64
  "vue-tsc": "^3.2.4"
59
65
  },
60
66
  "scripts": {
61
- "postinstall": "lefthook install",
62
67
  "dev": "npm run dev:prepare && nuxt dev playground",
63
68
  "dev:build": "nuxt build playground",
64
69
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",