Skip to content

Commit

Permalink
fix: move all working code to runtime/ fixes (#4)
Browse files Browse the repository at this point in the history
fix: resolve runtime
  • Loading branch information
StevenJPx2 committed Jan 22, 2024
1 parent f870c50 commit 55f1791
Show file tree
Hide file tree
Showing 44 changed files with 58 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"dist"
],
"scripts": {
"prepack": "nuxi build-module",
"prepack": "nuxt-module-build build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxi build-module --stub && nuxi prepare playground",
"dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
"lint": "eslint .",
"test": "vitest run",
Expand Down Expand Up @@ -56,4 +56,4 @@
"vitepress-extras": "^0.1.2",
"vitest": "^0.33.0"
}
}
}
13 changes: 7 additions & 6 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ export default defineNuxtModule<ModuleOptions>({
// Default configuration options of the Nuxt module
defaults: {},
async setup() {
const resolver = createResolver(import.meta.url);
const { resolve } = createResolver(import.meta.url);
const resolveRuntime = (...path: string[]) => resolve("./runtime", ...path);

addPlugin(resolver.resolve("./functions/plugin"));
addPlugin(resolveRuntime("./functions/plugin"));

for (const path of fg.sync(
resolver.resolve("./functions/**/component.vue"),
resolveRuntime("./functions/**/component.vue"),
)) {
addComponent({
name: pascalCase(
relative(
resolver.resolve("./functions"),
resolveRuntime("./functions"),
path.split(sep).slice(-2, -1)[0],
)
.replace("component.vue", "")
Expand All @@ -44,8 +45,8 @@ export default defineNuxtModule<ModuleOptions>({
});
}

addImportsDir(resolver.resolve("./functions"));
addComponentsDir({ path: resolver.resolve("./components") });
addImportsDir(resolveRuntime("./functions"));
addComponentsDir({ path: resolveRuntime("./components") });

await installModule("nuxt-split-type", {});
await installModule("@vueuse/nuxt", {});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/runtime/directives.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { vAos } from "./functions/use-animate-on-scroll/directive";
export { vSplitAnimate } from "./functions/use-split-text-animation/directive";
export { vFromTo } from "./functions/use-gsap/directive";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import "gsap";

export type Direction = "bottom" | "top" | "left" | "right";
type EaseFunction =
| "power1"
| "power2"
| "power3"
| "power4"
| "back"
| "circ"
| "expo"
| "sine";

type ExpressiveEaseFunctions =
| "linear"
| "none"
| "elastic"
| "bounce"
| "rough"
| "slow"
| `steps(${number})`;

type EaseType = "in" | "out" | "inOut";

export type Ease =
| `${EaseFunction}.${EaseType}`
| EaseFunction
| ExpressiveEaseFunctions;

type EaseOption = {
/** The ease of the tween
* @remarks
* - `Ease` is a custom type that allows the LSP to infer the correct string values for `ease`
* - You can also pass a custom `gsap.EaseFunction`
* */
ease?: Ease | gsap.EaseFunction;
};

export type Simplify<T> = { [K in keyof T]: T[K] } & {};

/** Strongly typed TweenVars */
export type StrongTweenVars = gsap.TweenVars & EaseOption;

/** Strongly typed TimelineVars */
export type StrongTimelineVars = gsap.TimelineVars & EaseOption;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 55f1791

Please sign in to comment.