deja-vue 0.2.0 → 1.0.1

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Déjà Vue (beta)
1
+ # Déjà Vue
2
2
 
3
3
  Declarative GSAP Animations for Vue 3.
4
4
 
package/dist/index.d.ts CHANGED
@@ -57,25 +57,6 @@ type TweenAnimationDefinition = ({
57
57
  }) & Pick<NestableAnimation, 'position'>;
58
58
  type TweenAnimation = BaseAnimation & TweenAnimationDefinition;
59
59
  //#endregion
60
- //#region src/composables/useAnimation.d.ts
61
- declare function useAnimation(wrapper: Readonly<ShallowRef<HTMLElement | null>>, props: TimelineAnimation | TweenAnimation, emit: (event: typeof ANIMATION_EVENTS[number], timeline: gsap.core.Timeline) => void, options?: gsap.TimelineVars): {
62
- animation: Animation;
63
- controlled: _$vue.ComputedRef<boolean>;
64
- parent: Animation | null;
65
- ready: ShallowRef<boolean, boolean>;
66
- };
67
- //#endregion
68
- //#region src/composables/useAnimationControls.d.ts
69
- type AnimationControls<C = ControllableAnimation> = { [K in keyof C]?: MaybeRefOrGetter<C[K]> };
70
- declare function useAnimationControls(animation: Animation, controls: AnimationControls): {
71
- controlled: _$vue.ComputedRef<boolean>;
72
- };
73
- //#endregion
74
- //#region src/composables/useAnimationNesting.d.ts
75
- declare function useAnimationNesting(child?: Animation | gsap.Callback | string, options?: NestableAnimation): {
76
- parent: Animation | null;
77
- };
78
- //#endregion
79
60
  //#region src/components/Callback.vue.d.ts
80
61
  type __VLS_Props$1 = NestableAnimation & {
81
62
  fn: () => void;
@@ -99,12 +80,12 @@ declare var __VLS_9$1: {
99
80
  animation: Animation;
100
81
  controlled: boolean;
101
82
  parent: Animation | null;
102
- ready: boolean;
83
+ progress: number;
103
84
  }, __VLS_11: {
104
85
  animation: Animation;
105
86
  controlled: boolean;
106
87
  parent: Animation | null;
107
- ready: boolean;
88
+ progress: number;
108
89
  };
109
90
  type __VLS_Slots$1 = {} & {
110
91
  default?: (props: typeof __VLS_9$1) => any;
@@ -115,7 +96,7 @@ declare const __VLS_base$1: _$vue.DefineComponent<TimelineAnimation, {
115
96
  animation: Animation;
116
97
  controlled: _$vue.ComputedRef<boolean>;
117
98
  parent: Animation | null;
118
- ready: _$vue.ShallowRef<boolean, boolean>;
99
+ progress: _$vue.ShallowRef<number, number>;
119
100
  }, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
120
101
  complete: (...args: any[]) => void;
121
102
  interrupt: (...args: any[]) => void;
@@ -147,7 +128,7 @@ declare var __VLS_9: {
147
128
  animation: Animation;
148
129
  controlled: boolean;
149
130
  parent: Animation | null;
150
- ready: boolean;
131
+ progress: number;
151
132
  };
152
133
  type __VLS_Slots = {} & {
153
134
  default?: (props: typeof __VLS_9) => any;
@@ -161,4 +142,23 @@ type __VLS_WithSlots<T, S> = T & {
161
142
  };
162
143
  };
163
144
  //#endregion
145
+ //#region src/composables/useAnimation.d.ts
146
+ declare function useAnimation(wrapper: Readonly<ShallowRef<HTMLElement | null>>): {
147
+ animation: Animation;
148
+ controlled: _$vue.ComputedRef<boolean>;
149
+ parent: Animation | null;
150
+ progress: ShallowRef<number, number>;
151
+ };
152
+ //#endregion
153
+ //#region src/composables/useAnimationControls.d.ts
154
+ type AnimationControls<C = ControllableAnimation> = { [K in keyof C]?: MaybeRefOrGetter<C[K]> };
155
+ declare function useAnimationControls(animation: Animation, controls: AnimationControls): {
156
+ controlled: _$vue.ComputedRef<boolean>;
157
+ };
158
+ //#endregion
159
+ //#region src/composables/useAnimationNesting.d.ts
160
+ declare function useAnimationNesting(child?: Animation | gsap.Callback | string, options?: NestableAnimation): {
161
+ parent: Animation | null;
162
+ };
163
+ //#endregion
164
164
  export { ANIMATION_EVENTS, Animation, BaseAnimation, _default as Callback, ControllableAnimation, NestableAnimation, _default$1 as PositionMarker, _default$2 as Timeline, TimelineAnimation, _default$3 as Tween, TweenAnimation, TweenAnimationDefinition, WrappableAnimation, parentAnimationInjectionKey, useAnimation, useAnimationControls, useAnimationNesting };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
+ import { Fragment, computed, createBlock, defineComponent, getCurrentInstance, inject, nextTick, onMounted, onUnmounted, openBlock, provide, renderSlot, resolveDynamicComponent, shallowRef, toValue, unref, useTemplateRef, watch, withCtx } from "vue";
1
2
  import { gsap } from "gsap";
2
- import { Fragment, computed, createBlock, defineComponent, inject, nextTick, onMounted, onUnmounted, openBlock, provide, renderSlot, resolveDynamicComponent, shallowRef, toValue, unref, useTemplateRef, watch, withCtx } from "vue";
3
3
  //#region src/constants.ts
4
4
  const ANIMATION_EVENTS = [
5
5
  "complete",
@@ -103,23 +103,6 @@ var Animation = class extends EventBus {
103
103
  }
104
104
  };
105
105
  //#endregion
106
- //#region src/composables/useAnimationControls.ts
107
- function useAnimationControls(animation, controls) {
108
- const progress = computed(() => toValue(controls.progress));
109
- const toggle = computed(() => toValue(controls.toggle));
110
- const controlled = computed(() => typeof progress.value === "number" || typeof toggle.value === "boolean");
111
- if (controlled.value && toggle.value !== true) animation.timeline.pause();
112
- watch(progress, (value) => {
113
- if (typeof value !== "number") return;
114
- animation.timeline.progress(value);
115
- }, { immediate: true });
116
- watch(toggle, (value) => {
117
- if (typeof value !== "boolean") return;
118
- animation.timeline[value ? "play" : "reverse"]();
119
- });
120
- return { controlled };
121
- }
122
- //#endregion
123
106
  //#region src/composables/useAnimationNesting.ts
124
107
  function useAnimationNesting(child, options) {
125
108
  const parent = options?.parent === null ? null : options?.parent || inject(parentAnimationInjectionKey, null);
@@ -136,33 +119,6 @@ function useAnimationNesting(child, options) {
136
119
  return { parent };
137
120
  }
138
121
  //#endregion
139
- //#region src/composables/useAnimation.ts
140
- function useAnimation(wrapper, props, emit, options) {
141
- const animation = new Animation(options);
142
- const ready = shallowRef(false);
143
- const { controlled } = useAnimationControls(animation, {
144
- progress: () => props.progress,
145
- toggle: () => props.toggle
146
- });
147
- const { parent } = useAnimationNesting(animation, props);
148
- ANIMATION_EVENTS.forEach((event) => animation.on(event, () => emit(event, animation.timeline)));
149
- onMounted(() => {
150
- if (wrapper.value) {
151
- const target = props.group ? wrapper.value.children : wrapper.value;
152
- const definition = "tweens" in props ? props.tweens || [] : props;
153
- animation.compose(target, definition);
154
- }
155
- ready.value = true;
156
- });
157
- onUnmounted(() => animation.dispose());
158
- return {
159
- animation,
160
- controlled,
161
- parent,
162
- ready
163
- };
164
- }
165
- //#endregion
166
122
  //#region src/components/Callback.vue
167
123
  var Callback_default = /* @__PURE__ */ defineComponent({
168
124
  __name: "Callback",
@@ -221,6 +177,60 @@ var PositionMarker_default = /* @__PURE__ */ defineComponent({
221
177
  }
222
178
  });
223
179
  //#endregion
180
+ //#region src/composables/useAnimationControls.ts
181
+ function useAnimationControls(animation, controls) {
182
+ const progress = computed(() => toValue(controls.progress));
183
+ const toggle = computed(() => toValue(controls.toggle));
184
+ const controlled = computed(() => typeof progress.value === "number" || typeof toggle.value === "boolean");
185
+ if (controlled.value && toggle.value !== true) animation.timeline.pause();
186
+ watch(progress, (value) => {
187
+ if (typeof value !== "number") return;
188
+ animation.timeline.progress(value);
189
+ }, { immediate: true });
190
+ watch(toggle, (value) => {
191
+ if (typeof value !== "boolean") return;
192
+ animation.timeline[value ? "play" : "reverse"]();
193
+ });
194
+ return { controlled };
195
+ }
196
+ //#endregion
197
+ //#region src/composables/useAnimation.ts
198
+ function useAnimation(wrapper) {
199
+ const { props, emit } = getCurrentInstance();
200
+ const animation = new Animation("options" in props ? {
201
+ ...props.options,
202
+ data: {
203
+ ...props.options?.data,
204
+ totalDuration: Number(props.duration)
205
+ }
206
+ } : void 0);
207
+ const progress = shallowRef(0);
208
+ const { controlled } = useAnimationControls(animation, {
209
+ progress: () => props.progress,
210
+ toggle: () => props.toggle
211
+ });
212
+ const { parent } = useAnimationNesting(animation, props);
213
+ ANIMATION_EVENTS.forEach((event) => animation.on(event, () => emit(event, animation.timeline)));
214
+ animation.on("update", () => progress.value = animation.timeline.progress());
215
+ if ("duration" in props) watch(() => props.duration, (duration) => {
216
+ animation.timeline.data.totalDuration = Number(duration);
217
+ });
218
+ onMounted(() => {
219
+ if (wrapper.value) {
220
+ const target = props.group ? wrapper.value.children : wrapper.value;
221
+ const definition = "tweens" in props ? props.tweens || [] : props;
222
+ animation.compose(target, definition);
223
+ }
224
+ });
225
+ onUnmounted(() => animation.dispose());
226
+ return {
227
+ animation,
228
+ controlled,
229
+ parent,
230
+ progress
231
+ };
232
+ }
233
+ //#endregion
224
234
  //#region src/components/Timeline.vue
225
235
  var Timeline_default = /* @__PURE__ */ defineComponent({
226
236
  __name: "Timeline",
@@ -266,24 +276,15 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
266
276
  }
267
277
  },
268
278
  emits: [...ANIMATION_EVENTS],
269
- setup(__props, { expose: __expose, emit: __emit }) {
270
- const props = __props;
271
- const emit = __emit;
279
+ setup(__props, { expose: __expose }) {
272
280
  const wrapper = useTemplateRef("wrapper");
273
- const { animation, controlled, parent, ready } = useAnimation(wrapper, props, emit, {
274
- ...props.options,
275
- data: {
276
- ...props.options?.data,
277
- totalDuration: Number(props.duration)
278
- }
279
- });
280
- watch(() => props.duration, (duration) => animation.timeline.data.totalDuration = Number(duration));
281
+ const { animation, controlled, parent, progress } = useAnimation(wrapper);
281
282
  provide(parentAnimationInjectionKey, animation);
282
283
  __expose({
283
284
  animation,
284
285
  controlled,
285
286
  parent,
286
- ready
287
+ progress
287
288
  });
288
289
  return (_ctx, _cache) => {
289
290
  return __props.tweens ? (openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
@@ -295,7 +296,7 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
295
296
  animation: unref(animation),
296
297
  controlled: unref(controlled),
297
298
  parent: unref(parent),
298
- ready: unref(ready)
299
+ progress: unref(progress)
299
300
  })]),
300
301
  _: 3
301
302
  }, 512)) : renderSlot(_ctx.$slots, "default", {
@@ -303,7 +304,7 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
303
304
  animation: unref(animation),
304
305
  controlled: unref(controlled),
305
306
  parent: unref(parent),
306
- ready: unref(ready)
307
+ progress: unref(progress)
307
308
  });
308
309
  };
309
310
  }
@@ -350,16 +351,14 @@ var Tween_default = /* @__PURE__ */ defineComponent({
350
351
  }
351
352
  },
352
353
  emits: [...ANIMATION_EVENTS],
353
- setup(__props, { expose: __expose, emit: __emit }) {
354
- const props = __props;
355
- const emit = __emit;
354
+ setup(__props, { expose: __expose }) {
356
355
  const wrapper = useTemplateRef("wrapper");
357
- const { animation, controlled, parent, ready } = useAnimation(wrapper, props, emit);
356
+ const { animation, controlled, parent, progress } = useAnimation(wrapper);
358
357
  __expose({
359
358
  animation,
360
359
  controlled,
361
360
  parent,
362
- ready
361
+ progress
363
362
  });
364
363
  return (_ctx, _cache) => {
365
364
  return openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
@@ -370,7 +369,7 @@ var Tween_default = /* @__PURE__ */ defineComponent({
370
369
  animation: unref(animation),
371
370
  controlled: unref(controlled),
372
371
  parent: unref(parent),
373
- ready: unref(ready)
372
+ progress: unref(progress)
374
373
  })]),
375
374
  _: 3
376
375
  }, 512);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "deja-vue",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "1.0.1",
5
5
  "description": "Declarative GSAP Animations for Vue 3",
6
6
  "author": "Andrea 'Fiad' Fiadone <hello@fiad.one>",
7
7
  "license": "MIT",
@@ -33,7 +33,8 @@
33
33
  "prepublishOnly": "npm run build",
34
34
  "docs:dev": "vitepress dev docs",
35
35
  "docs:build": "vitepress build docs",
36
- "docs:preview": "vitepress preview docs"
36
+ "docs:preview": "vitepress preview docs",
37
+ "commit": "cz"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "gsap": "^3.0.0",
@@ -50,6 +51,8 @@
50
51
  "@vitejs/plugin-vue": "^6.0.5",
51
52
  "@vitest/browser-playwright": "^4.1.2",
52
53
  "bumpp": "^11.0.1",
54
+ "commitizen": "^4.3.1",
55
+ "cz-conventional-changelog": "^3.3.0",
53
56
  "gsap": "^3.15.0",
54
57
  "playwright": "^1.58.2",
55
58
  "semantic-release": "^25.0.3",