deja-vue 0.1.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
@@ -2,6 +2,10 @@
2
2
 
3
3
  Declarative GSAP Animations for Vue 3.
4
4
 
5
+ ## Documentation
6
+
7
+ View the [full documentation here](https://fiadone.github.io/deja-vue/).
8
+
5
9
  ## Development
6
10
 
7
11
  - Install dependencies:
package/dist/index.d.ts CHANGED
@@ -37,7 +37,6 @@ interface NestableAnimation {
37
37
  }
38
38
  interface WrappableAnimation {
39
39
  group?: boolean;
40
- initiallyHidden?: boolean;
41
40
  tag?: string;
42
41
  }
43
42
  type BaseAnimation = ControllableAnimation & NestableAnimation & WrappableAnimation;
@@ -81,12 +80,12 @@ declare var __VLS_9$1: {
81
80
  animation: Animation;
82
81
  controlled: boolean;
83
82
  parent: Animation | null;
84
- ready: boolean;
83
+ progress: number;
85
84
  }, __VLS_11: {
86
85
  animation: Animation;
87
86
  controlled: boolean;
88
87
  parent: Animation | null;
89
- ready: boolean;
88
+ progress: number;
90
89
  };
91
90
  type __VLS_Slots$1 = {} & {
92
91
  default?: (props: typeof __VLS_9$1) => any;
@@ -97,7 +96,7 @@ declare const __VLS_base$1: _$vue.DefineComponent<TimelineAnimation, {
97
96
  animation: Animation;
98
97
  controlled: _$vue.ComputedRef<boolean>;
99
98
  parent: Animation | null;
100
- ready: _$vue.ShallowRef<boolean, boolean>;
99
+ progress: _$vue.ShallowRef<number, number>;
101
100
  }, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
102
101
  complete: (...args: any[]) => void;
103
102
  interrupt: (...args: any[]) => void;
@@ -114,7 +113,6 @@ declare const __VLS_base$1: _$vue.DefineComponent<TimelineAnimation, {
114
113
  onUpdate?: ((...args: any[]) => any) | undefined;
115
114
  }>, {
116
115
  toggle: boolean;
117
- initiallyHidden: boolean;
118
116
  tag: string;
119
117
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
120
118
  declare const __VLS_export$1: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
@@ -130,7 +128,7 @@ declare var __VLS_9: {
130
128
  animation: Animation;
131
129
  controlled: boolean;
132
130
  parent: Animation | null;
133
- ready: boolean;
131
+ progress: number;
134
132
  };
135
133
  type __VLS_Slots = {} & {
136
134
  default?: (props: typeof __VLS_9) => any;
@@ -145,11 +143,11 @@ type __VLS_WithSlots<T, S> = T & {
145
143
  };
146
144
  //#endregion
147
145
  //#region src/composables/useAnimation.d.ts
148
- 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): {
146
+ declare function useAnimation(wrapper: Readonly<ShallowRef<HTMLElement | null>>): {
149
147
  animation: Animation;
150
148
  controlled: _$vue.ComputedRef<boolean>;
151
149
  parent: Animation | null;
152
- ready: ShallowRef<boolean, boolean>;
150
+ progress: ShallowRef<number, number>;
153
151
  };
154
152
  //#endregion
155
153
  //#region src/composables/useAnimationControls.d.ts
@@ -163,4 +161,4 @@ declare function useAnimationNesting(child?: Animation | gsap.Callback | string,
163
161
  parent: Animation | null;
164
162
  };
165
163
  //#endregion
166
- export { ANIMATION_EVENTS, type 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 };
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,4 +1,4 @@
1
- import { Fragment, computed, createBlock, defineComponent, inject, nextTick, normalizeStyle, onMounted, onUnmounted, openBlock, provide, renderSlot, resolveDynamicComponent, shallowRef, toValue, unref, useTemplateRef, watch, withCtx } from "vue";
1
+ import { Fragment, computed, createBlock, defineComponent, getCurrentInstance, inject, nextTick, onMounted, onUnmounted, openBlock, provide, renderSlot, resolveDynamicComponent, shallowRef, toValue, unref, useTemplateRef, watch, withCtx } from "vue";
2
2
  import { gsap } from "gsap";
3
3
  //#region src/constants.ts
4
4
  const ANIMATION_EVENTS = [
@@ -61,7 +61,7 @@ var Animation = class extends EventBus {
61
61
  });
62
62
  (options ? Object.entries(options).filter(([key]) => key.startsWith("on")) : []).forEach(([key, fn]) => {
63
63
  const [firstChar, ...rest] = key.replace(/^on/, "");
64
- const event = `${firstChar.toLowerCase()}${rest.join()}`;
64
+ const event = `${firstChar.toLowerCase()}${rest.join("")}`;
65
65
  this.on(event, fn);
66
66
  });
67
67
  }
@@ -195,29 +195,39 @@ function useAnimationControls(animation, controls) {
195
195
  }
196
196
  //#endregion
197
197
  //#region src/composables/useAnimation.ts
198
- function useAnimation(wrapper, props, emit, options) {
199
- const animation = new Animation(options);
200
- const ready = shallowRef(false);
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);
201
208
  const { controlled } = useAnimationControls(animation, {
202
209
  progress: () => props.progress,
203
210
  toggle: () => props.toggle
204
211
  });
205
212
  const { parent } = useAnimationNesting(animation, props);
206
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
+ });
207
218
  onMounted(() => {
208
219
  if (wrapper.value) {
209
220
  const target = props.group ? wrapper.value.children : wrapper.value;
210
221
  const definition = "tweens" in props ? props.tweens || [] : props;
211
222
  animation.compose(target, definition);
212
223
  }
213
- ready.value = true;
214
224
  });
215
225
  onUnmounted(() => animation.dispose());
216
226
  return {
217
227
  animation,
218
228
  controlled,
219
229
  parent,
220
- ready
230
+ progress
221
231
  };
222
232
  }
223
233
  //#endregion
@@ -247,11 +257,6 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
247
257
  type: Boolean,
248
258
  required: false
249
259
  },
250
- initiallyHidden: {
251
- type: Boolean,
252
- required: false,
253
- default: true
254
- },
255
260
  tag: {
256
261
  type: String,
257
262
  required: false,
@@ -271,45 +276,35 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
271
276
  }
272
277
  },
273
278
  emits: [...ANIMATION_EVENTS],
274
- setup(__props, { expose: __expose, emit: __emit }) {
275
- const props = __props;
276
- const emit = __emit;
279
+ setup(__props, { expose: __expose }) {
277
280
  const wrapper = useTemplateRef("wrapper");
278
- const { animation, controlled, parent, ready } = useAnimation(wrapper, props, emit, {
279
- ...props.options,
280
- data: {
281
- ...props.options?.data,
282
- totalDuration: Number(props.duration)
283
- }
284
- });
285
- watch(() => props.duration, (duration) => animation.timeline.data.totalDuration = Number(duration));
281
+ const { animation, controlled, parent, progress } = useAnimation(wrapper);
282
+ provide(parentAnimationInjectionKey, animation);
286
283
  __expose({
287
284
  animation,
288
285
  controlled,
289
286
  parent,
290
- ready
287
+ progress
291
288
  });
292
- provide(parentAnimationInjectionKey, animation);
293
289
  return (_ctx, _cache) => {
294
290
  return __props.tweens ? (openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
295
291
  key: 0,
296
292
  ref_key: "wrapper",
297
- ref: wrapper,
298
- style: normalizeStyle(__props.initiallyHidden && !unref(ready) ? { visibility: "hidden" } : void 0)
293
+ ref: wrapper
299
294
  }, {
300
295
  default: withCtx(() => [renderSlot(_ctx.$slots, "default", {
301
296
  animation: unref(animation),
302
297
  controlled: unref(controlled),
303
298
  parent: unref(parent),
304
- ready: unref(ready)
299
+ progress: unref(progress)
305
300
  })]),
306
301
  _: 3
307
- }, 8, ["style"])) : renderSlot(_ctx.$slots, "default", {
302
+ }, 512)) : renderSlot(_ctx.$slots, "default", {
308
303
  key: 1,
309
304
  animation: unref(animation),
310
305
  controlled: unref(controlled),
311
306
  parent: unref(parent),
312
- ready: unref(ready)
307
+ progress: unref(progress)
313
308
  });
314
309
  };
315
310
  }
@@ -341,11 +336,6 @@ var Tween_default = /* @__PURE__ */ defineComponent({
341
336
  type: Boolean,
342
337
  required: false
343
338
  },
344
- initiallyHidden: {
345
- type: Boolean,
346
- required: false,
347
- default: true
348
- },
349
339
  tag: {
350
340
  type: String,
351
341
  required: false,
@@ -361,33 +351,30 @@ var Tween_default = /* @__PURE__ */ defineComponent({
361
351
  }
362
352
  },
363
353
  emits: [...ANIMATION_EVENTS],
364
- setup(__props, { expose: __expose, emit: __emit }) {
365
- const props = __props;
366
- const emit = __emit;
354
+ setup(__props, { expose: __expose }) {
367
355
  const wrapper = useTemplateRef("wrapper");
368
- const { animation, controlled, parent, ready } = useAnimation(wrapper, props, emit);
356
+ const { animation, controlled, parent, progress } = useAnimation(wrapper);
369
357
  __expose({
370
358
  animation,
371
359
  controlled,
372
360
  parent,
373
- ready
361
+ progress
374
362
  });
375
363
  return (_ctx, _cache) => {
376
364
  return openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
377
365
  ref_key: "wrapper",
378
- ref: wrapper,
379
- style: normalizeStyle(__props.initiallyHidden && !unref(ready) ? { visibility: "hidden" } : void 0)
366
+ ref: wrapper
380
367
  }, {
381
368
  default: withCtx(() => [renderSlot(_ctx.$slots, "default", {
382
369
  animation: unref(animation),
383
370
  controlled: unref(controlled),
384
371
  parent: unref(parent),
385
- ready: unref(ready)
372
+ progress: unref(progress)
386
373
  })]),
387
374
  _: 3
388
- }, 8, ["style"]);
375
+ }, 512);
389
376
  };
390
377
  }
391
378
  });
392
379
  //#endregion
393
- export { ANIMATION_EVENTS, Callback_default as Callback, PositionMarker_default as PositionMarker, Timeline_default as Timeline, Tween_default as Tween, parentAnimationInjectionKey, useAnimation, useAnimationControls, useAnimationNesting };
380
+ export { ANIMATION_EVENTS, Animation, Callback_default as Callback, PositionMarker_default as PositionMarker, Timeline_default as Timeline, Tween_default as Tween, parentAnimationInjectionKey, useAnimation, useAnimationControls, useAnimationNesting };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "deja-vue",
3
3
  "type": "module",
4
- "version": "0.1.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",
@@ -25,15 +25,16 @@
25
25
  },
26
26
  "scripts": {
27
27
  "build": "tsdown",
28
- "dev": "tsdown --watch && npm run play",
28
+ "dev": "tsdown --watch",
29
29
  "play": "vite",
30
30
  "test": "vitest",
31
31
  "typecheck": "vue-tsc --noEmit",
32
32
  "release": "bumpp",
33
- "prepublishOnly": "pnpm run build",
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",
@@ -43,16 +44,18 @@
43
44
  "@semantic-release/changelog": "^6.0.3",
44
45
  "@semantic-release/commit-analyzer": "^13.0.1",
45
46
  "@semantic-release/git": "^10.0.1",
46
- "@semantic-release/npm": "^12.0.2",
47
+ "@semantic-release/npm": "^13.1.5",
47
48
  "@semantic-release/release-notes-generator": "^14.1.0",
48
49
  "@tsdown/css": "^0.21.7",
49
50
  "@types/node": "^25.5.0",
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
- "semantic-release": "^24.2.9",
58
+ "semantic-release": "^25.0.3",
56
59
  "tsdown": "^0.21.7",
57
60
  "typescript": "^6.0.2",
58
61
  "unocss": "^66.6.8",