Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsPi3141 committed Sep 23, 2024
0 parents commit a2fd6e6
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# GSAP Unlocker

Use GSAP club plugins anywhere

## Installation

First, install the npm package

```bash
npm install gsap-unlocker
```

Make sure you also have GSAP trial

```bash
npm install gsap gsap-trial
```

## Usage

Import `gsap-unlocker` in your project before importing GSAP

```js
import "gsap-unlocker";
import gsap from "gsap";
import { DrawSVGPlugin } from "gsap-trial/DrawSVGPlugin";
// other imports...
```
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "gsap-unlocker",
"version": "1.0.0",
"description": "Use GSAP club plugins anywhere",
"main": "src/index.ts",
"module": "dist/index.mjs",
"types": "dist/index.d.mts",
"files": ["dist"],
"scripts": {
"build": "tsup"
},
"keywords": ["gsap", "gsap-unlocker"],
"author": "ItsPi3141",
"license": "MIT",
"devDependencies": {
"tsup": "^8.3.0",
"typescript": "^5.6.2"
}
}
31 changes: 31 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const clubPlugins = [
"CustomBounce",
"CustomWiggle",
"DrawSVGPlugin",
"InertiaPlugin",
"GSDevTools",
"MorphSVGPlugin",
"MotionPathHelper",
"Physics2DPlugin",
"PhysicsPropsPlugin",
"ScrambleTextPlugin",
"ScrollSmoother",
"SplitText",
];

String.fromCharCode = new Proxy(String.fromCharCode, {
apply(target, thisArg, argumentsList) {
let shouldModify = false;
try {
new Function("''()")();
} catch (e) {
for (const plugin of clubPlugins) {
if (e.stack.toLowerCase().includes(plugin.toLowerCase())) {
shouldModify = true;
break;
}
}
}
return target.apply(thisArg, shouldModify ? [] : argumentsList);
},
});
11 changes: 11 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["src/index.ts"],
format: ["esm"],
minify: true,
dts: true,
splitting: false,
sourcemap: false,
clean: true,
});

0 comments on commit a2fd6e6

Please sign in to comment.