@trindtech/utils 1.2.0 → 1.4.0
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/dist/motion/components/canvas-scrub.d.ts +21 -0
- package/dist/motion/components/canvas-scrub.d.ts.map +1 -0
- package/dist/motion/components/canvas-scrub.js +80 -0
- package/dist/motion/components/canvas-scrub.js.map +1 -0
- package/dist/motion/components/count-up.d.ts +15 -0
- package/dist/motion/components/count-up.d.ts.map +1 -0
- package/dist/motion/components/count-up.js +35 -0
- package/dist/motion/components/count-up.js.map +1 -0
- package/dist/motion/components/horizontal-scroll.d.ts +11 -0
- package/dist/motion/components/horizontal-scroll.d.ts.map +1 -0
- package/dist/motion/components/horizontal-scroll.js +46 -0
- package/dist/motion/components/horizontal-scroll.js.map +1 -0
- package/dist/motion/components/logo-marquee.d.ts +17 -0
- package/dist/motion/components/logo-marquee.d.ts.map +1 -0
- package/dist/motion/components/logo-marquee.js +21 -0
- package/dist/motion/components/logo-marquee.js.map +1 -0
- package/dist/motion/components/navbar.d.ts +21 -0
- package/dist/motion/components/navbar.d.ts.map +1 -0
- package/dist/motion/components/navbar.js +32 -0
- package/dist/motion/components/navbar.js.map +1 -0
- package/dist/motion/components/parallax-section.d.ts +10 -0
- package/dist/motion/components/parallax-section.d.ts.map +1 -0
- package/dist/motion/components/parallax-section.js +18 -0
- package/dist/motion/components/parallax-section.js.map +1 -0
- package/dist/motion/components/reveal-on-scroll.d.ts +15 -0
- package/dist/motion/components/reveal-on-scroll.d.ts.map +1 -0
- package/dist/motion/components/reveal-on-scroll.js +21 -0
- package/dist/motion/components/reveal-on-scroll.js.map +1 -0
- package/dist/motion/components/stacked-cards.d.ts +15 -0
- package/dist/motion/components/stacked-cards.d.ts.map +1 -0
- package/dist/motion/components/stacked-cards.js +53 -0
- package/dist/motion/components/stacked-cards.js.map +1 -0
- package/dist/motion/components/text-reveal.d.ts +14 -0
- package/dist/motion/components/text-reveal.d.ts.map +1 -0
- package/dist/motion/components/text-reveal.js +38 -0
- package/dist/motion/components/text-reveal.js.map +1 -0
- package/dist/motion/components/video-scrub.d.ts +9 -0
- package/dist/motion/components/video-scrub.d.ts.map +1 -0
- package/dist/motion/components/video-scrub.js +40 -0
- package/dist/motion/components/video-scrub.js.map +1 -0
- package/dist/motion/index.d.ts +14 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +30 -0
- package/dist/motion/index.js.map +1 -0
- package/dist/motion/providers/motion-provider.d.ts +7 -0
- package/dist/motion/providers/motion-provider.d.ts.map +1 -0
- package/dist/motion/providers/motion-provider.js +11 -0
- package/dist/motion/providers/motion-provider.js.map +1 -0
- package/dist/motion/providers/smooth-scroll-provider.d.ts +7 -0
- package/dist/motion/providers/smooth-scroll-provider.d.ts.map +1 -0
- package/dist/motion/providers/smooth-scroll-provider.js +27 -0
- package/dist/motion/providers/smooth-scroll-provider.js.map +1 -0
- package/dist/motion/types.d.ts +3 -0
- package/dist/motion/types.d.ts.map +1 -0
- package/dist/motion/types.js +3 -0
- package/dist/motion/types.js.map +1 -0
- package/package.json +55 -1
- package/src/index.ts +0 -3
- package/src/mailer/index.ts +0 -87
- package/src/mailer/templates.ts +0 -48
- package/src/s3/index.ts +0 -241
- package/src/validators/countries.ts +0 -94
- package/src/validators/index.ts +0 -257
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.VideoScrub = VideoScrub;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const gsap_1 = __importDefault(require("gsap"));
|
|
11
|
+
const ScrollTrigger_1 = require("gsap/ScrollTrigger");
|
|
12
|
+
gsap_1.default.registerPlugin(ScrollTrigger_1.ScrollTrigger);
|
|
13
|
+
/** Scrub de vídeo mp4 — currentTime controlado pelo scroll */
|
|
14
|
+
function VideoScrub({ src, scrollHeight = "250vh", fallbackSrc }) {
|
|
15
|
+
const videoRef = (0, react_1.useRef)(null);
|
|
16
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
19
|
+
if (prefersReduced)
|
|
20
|
+
return;
|
|
21
|
+
const video = videoRef.current;
|
|
22
|
+
const init = () => {
|
|
23
|
+
gsap_1.default.to(video, {
|
|
24
|
+
currentTime: video.duration,
|
|
25
|
+
ease: "none",
|
|
26
|
+
scrollTrigger: {
|
|
27
|
+
trigger: containerRef.current,
|
|
28
|
+
start: "top top",
|
|
29
|
+
end: "bottom bottom",
|
|
30
|
+
scrub: 1,
|
|
31
|
+
invalidateOnRefresh: true,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
video.readyState >= 1 ? init() : video.addEventListener("loadedmetadata", init);
|
|
36
|
+
return () => ScrollTrigger_1.ScrollTrigger.getAll().forEach((t) => t.kill());
|
|
37
|
+
}, []);
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, style: { height: scrollHeight }, className: "relative", children: [fallbackSrc && ((0, jsx_runtime_1.jsx)("div", { className: "md:hidden sticky top-0 h-screen w-full", children: (0, jsx_runtime_1.jsx)("img", { src: fallbackSrc, alt: "", className: "h-full w-full object-cover" }) })), (0, jsx_runtime_1.jsx)("video", { ref: videoRef, src: src, muted: true, playsInline: true, preload: "auto", className: "hidden md:block sticky top-0 h-screen w-full object-cover", "aria-hidden": "true" })] }));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=video-scrub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-scrub.js","sourceRoot":"","sources":["../../../src/motion/components/video-scrub.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAcZ,gCA6CC;;AA1DD,iCAAyC;AACzC,gDAAuB;AACvB,sDAAkD;AAElD,cAAI,CAAC,cAAc,CAAC,6BAAa,CAAC,CAAA;AAQlC,8DAA8D;AAC9D,SAAgB,UAAU,CAAC,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,EAAE,WAAW,EAAS;IAC5E,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAA;IAC/C,MAAM,YAAY,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAA;IAEjD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAA;QACpF,IAAI,cAAc;YAAE,OAAM;QAE1B,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAQ,CAAA;QAC/B,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,cAAI,CAAC,EAAE,CAAC,KAAK,EAAE;gBACb,WAAW,EAAE,KAAK,CAAC,QAAQ;gBAC3B,IAAI,EAAE,MAAM;gBACZ,aAAa,EAAE;oBACb,OAAO,EAAE,YAAY,CAAC,OAAO;oBAC7B,KAAK,EAAE,SAAS;oBAChB,GAAG,EAAE,eAAe;oBACpB,KAAK,EAAE,CAAC;oBACR,mBAAmB,EAAE,IAAI;iBAC1B;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;QAC/E,OAAO,GAAG,EAAE,CAAC,6BAAa,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9D,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,iCAAK,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,EAAC,UAAU,aAC1E,WAAW,IAAI,CACd,gCAAK,SAAS,EAAC,wCAAwC,YACrD,gCAAK,GAAG,EAAE,WAAW,EAAE,GAAG,EAAC,EAAE,EAAC,SAAS,EAAC,4BAA4B,GAAG,GACnE,CACP,EACD,kCACE,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,GAAG,EACR,KAAK,QACL,WAAW,QACX,OAAO,EAAC,MAAM,EACd,SAAS,EAAC,2DAA2D,iBACzD,MAAM,GAClB,IACE,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { SmoothScrollProvider } from "./providers/smooth-scroll-provider";
|
|
2
|
+
export { MotionProvider } from "./providers/motion-provider";
|
|
3
|
+
export { RevealOnScroll } from "./components/reveal-on-scroll";
|
|
4
|
+
export { TextReveal } from "./components/text-reveal";
|
|
5
|
+
export { ParallaxSection } from "./components/parallax-section";
|
|
6
|
+
export { HorizontalScroll } from "./components/horizontal-scroll";
|
|
7
|
+
export { StackedCards } from "./components/stacked-cards";
|
|
8
|
+
export { CanvasScrub } from "./components/canvas-scrub";
|
|
9
|
+
export { VideoScrub } from "./components/video-scrub";
|
|
10
|
+
export { CountUp } from "./components/count-up";
|
|
11
|
+
export { LogoMarquee } from "./components/logo-marquee";
|
|
12
|
+
export { Navbar } from "./components/navbar";
|
|
13
|
+
export type { NavLink, NavbarCTA } from "./components/navbar";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/motion/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Navbar = exports.LogoMarquee = exports.CountUp = exports.VideoScrub = exports.CanvasScrub = exports.StackedCards = exports.HorizontalScroll = exports.ParallaxSection = exports.TextReveal = exports.RevealOnScroll = exports.MotionProvider = exports.SmoothScrollProvider = void 0;
|
|
4
|
+
// Providers
|
|
5
|
+
var smooth_scroll_provider_1 = require("./providers/smooth-scroll-provider");
|
|
6
|
+
Object.defineProperty(exports, "SmoothScrollProvider", { enumerable: true, get: function () { return smooth_scroll_provider_1.SmoothScrollProvider; } });
|
|
7
|
+
var motion_provider_1 = require("./providers/motion-provider");
|
|
8
|
+
Object.defineProperty(exports, "MotionProvider", { enumerable: true, get: function () { return motion_provider_1.MotionProvider; } });
|
|
9
|
+
// Components
|
|
10
|
+
var reveal_on_scroll_1 = require("./components/reveal-on-scroll");
|
|
11
|
+
Object.defineProperty(exports, "RevealOnScroll", { enumerable: true, get: function () { return reveal_on_scroll_1.RevealOnScroll; } });
|
|
12
|
+
var text_reveal_1 = require("./components/text-reveal");
|
|
13
|
+
Object.defineProperty(exports, "TextReveal", { enumerable: true, get: function () { return text_reveal_1.TextReveal; } });
|
|
14
|
+
var parallax_section_1 = require("./components/parallax-section");
|
|
15
|
+
Object.defineProperty(exports, "ParallaxSection", { enumerable: true, get: function () { return parallax_section_1.ParallaxSection; } });
|
|
16
|
+
var horizontal_scroll_1 = require("./components/horizontal-scroll");
|
|
17
|
+
Object.defineProperty(exports, "HorizontalScroll", { enumerable: true, get: function () { return horizontal_scroll_1.HorizontalScroll; } });
|
|
18
|
+
var stacked_cards_1 = require("./components/stacked-cards");
|
|
19
|
+
Object.defineProperty(exports, "StackedCards", { enumerable: true, get: function () { return stacked_cards_1.StackedCards; } });
|
|
20
|
+
var canvas_scrub_1 = require("./components/canvas-scrub");
|
|
21
|
+
Object.defineProperty(exports, "CanvasScrub", { enumerable: true, get: function () { return canvas_scrub_1.CanvasScrub; } });
|
|
22
|
+
var video_scrub_1 = require("./components/video-scrub");
|
|
23
|
+
Object.defineProperty(exports, "VideoScrub", { enumerable: true, get: function () { return video_scrub_1.VideoScrub; } });
|
|
24
|
+
var count_up_1 = require("./components/count-up");
|
|
25
|
+
Object.defineProperty(exports, "CountUp", { enumerable: true, get: function () { return count_up_1.CountUp; } });
|
|
26
|
+
var logo_marquee_1 = require("./components/logo-marquee");
|
|
27
|
+
Object.defineProperty(exports, "LogoMarquee", { enumerable: true, get: function () { return logo_marquee_1.LogoMarquee; } });
|
|
28
|
+
var navbar_1 = require("./components/navbar");
|
|
29
|
+
Object.defineProperty(exports, "Navbar", { enumerable: true, get: function () { return navbar_1.Navbar; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/motion/index.ts"],"names":[],"mappings":";;;AAAA,YAAY;AACZ,6EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAC7B,+DAA4D;AAAnD,iHAAA,cAAc,OAAA;AAEvB,aAAa;AACb,kEAA8D;AAArD,kHAAA,cAAc,OAAA;AACvB,wDAAqD;AAA5C,yGAAA,UAAU,OAAA;AACnB,kEAA+D;AAAtD,mHAAA,eAAe,OAAA;AACxB,oEAAiE;AAAxD,qHAAA,gBAAgB,OAAA;AACzB,4DAAyD;AAAhD,6GAAA,YAAY,OAAA;AACrB,0DAAuD;AAA9C,2GAAA,WAAW,OAAA;AACpB,wDAAqD;AAA5C,yGAAA,UAAU,OAAA;AACnB,kDAA+C;AAAtC,mGAAA,OAAO,OAAA;AAChB,0DAAuD;AAA9C,2GAAA,WAAW,OAAA;AACpB,8CAA4C;AAAnC,gGAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
}
|
|
4
|
+
/** Wraps app with MotionConfig — respeita prefers-reduced-motion automaticamente */
|
|
5
|
+
export declare function MotionProvider({ children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=motion-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-provider.d.ts","sourceRoot":"","sources":["../../../src/motion/providers/motion-provider.tsx"],"names":[],"mappings":"AAGA,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAMjD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MotionProvider = MotionProvider;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("motion/react");
|
|
7
|
+
/** Wraps app with MotionConfig — respeita prefers-reduced-motion automaticamente */
|
|
8
|
+
function MotionProvider({ children }) {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(react_1.MotionConfig, { reducedMotion: "user", children: children }));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=motion-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-provider.js","sourceRoot":"","sources":["../../../src/motion/providers/motion-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;AAQZ,wCAMC;;AAbD,wCAA2C;AAM3C,oFAAoF;AACpF,SAAgB,cAAc,CAAC,EAAE,QAAQ,EAAS;IAChD,OAAO,CACL,uBAAC,oBAAY,IAAC,aAAa,EAAC,MAAM,YAC/B,QAAQ,GACI,CAChB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smooth-scroll-provider.d.ts","sourceRoot":"","sources":["../../../src/motion/providers/smooth-scroll-provider.tsx"],"names":[],"mappings":"AAQA,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,IAAW,EAAE,EAAE,KAAK,2CAYpE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SmoothScrollProvider = SmoothScrollProvider;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const lenis_1 = __importDefault(require("lenis"));
|
|
11
|
+
const gsap_1 = require("gsap");
|
|
12
|
+
const ScrollTrigger_1 = require("gsap/ScrollTrigger");
|
|
13
|
+
gsap_1.gsap.registerPlugin(ScrollTrigger_1.ScrollTrigger);
|
|
14
|
+
function SmoothScrollProvider({ children, lerp = 0.08 }) {
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
const lenis = new lenis_1.default({ lerp, smoothWheel: true });
|
|
17
|
+
lenis.on("scroll", ScrollTrigger_1.ScrollTrigger.update);
|
|
18
|
+
gsap_1.gsap.ticker.add((time) => lenis.raf(time * 1000));
|
|
19
|
+
gsap_1.gsap.ticker.lagSmoothing(0);
|
|
20
|
+
return () => {
|
|
21
|
+
lenis.destroy();
|
|
22
|
+
gsap_1.gsap.ticker.remove((time) => lenis.raf(time * 1000));
|
|
23
|
+
};
|
|
24
|
+
}, [lerp]);
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=smooth-scroll-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smooth-scroll-provider.js","sourceRoot":"","sources":["../../../src/motion/providers/smooth-scroll-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAaZ,oDAYC;;AAxBD,iCAAiC;AACjC,kDAAyB;AACzB,+BAA2B;AAC3B,sDAAkD;AAElD,WAAI,CAAC,cAAc,CAAC,6BAAa,CAAC,CAAA;AAOlC,SAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,EAAS;IACnE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,IAAI,eAAK,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QACpD,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,6BAAa,CAAC,MAAM,CAAC,CAAA;QACxC,WAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAA;QACjD,WAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAC3B,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,OAAO,EAAE,CAAA;YACf,WAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAA;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACV,OAAO,2DAAG,QAAQ,GAAI,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/motion/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AACxD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/motion/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trindtech/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./motion": {
|
|
12
|
+
"types": "./dist/motion/index.d.ts",
|
|
13
|
+
"default": "./dist/motion/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./s3": {
|
|
16
|
+
"types": "./dist/s3/index.d.ts",
|
|
17
|
+
"default": "./dist/s3/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./mailer": {
|
|
20
|
+
"types": "./dist/mailer/index.d.ts",
|
|
21
|
+
"default": "./dist/mailer/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./validators": {
|
|
24
|
+
"types": "./dist/validators/index.d.ts",
|
|
25
|
+
"default": "./dist/validators/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
6
31
|
"publishConfig": {
|
|
7
32
|
"registry": "https://registry.npmjs.org",
|
|
8
33
|
"access": "public"
|
|
@@ -18,6 +43,35 @@
|
|
|
18
43
|
},
|
|
19
44
|
"devDependencies": {
|
|
20
45
|
"@types/node": "^25.3.3",
|
|
46
|
+
"@types/react": "^19.2.14",
|
|
21
47
|
"typescript": "^5.9.3"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@gsap/react": "^2.1.2",
|
|
51
|
+
"gsap": "^3.14.2",
|
|
52
|
+
"lenis": "^1.3.21",
|
|
53
|
+
"motion": "^12.38.0",
|
|
54
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
55
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependenciesMeta": {
|
|
58
|
+
"gsap": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"@gsap/react": {
|
|
62
|
+
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"motion": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"lenis": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"react": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"react-dom": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
22
76
|
}
|
|
23
77
|
}
|
package/src/index.ts
DELETED
package/src/mailer/index.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";
|
|
2
|
-
import { verificationTemplate, resetPasswordTemplate } from "./templates";
|
|
3
|
-
|
|
4
|
-
export interface MailerCredentials {
|
|
5
|
-
accessKeyId: string;
|
|
6
|
-
secretAccessKey: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface MailerConfig {
|
|
10
|
-
region: string;
|
|
11
|
-
from: string;
|
|
12
|
-
appName: string;
|
|
13
|
-
credentials: MailerCredentials;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface SendOptions {
|
|
17
|
-
to: string;
|
|
18
|
-
subject: string;
|
|
19
|
-
html: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function createMailer(config: MailerConfig) {
|
|
23
|
-
const client = new SESClient({
|
|
24
|
-
region: config.region,
|
|
25
|
-
credentials: {
|
|
26
|
-
accessKeyId: config.credentials.accessKeyId,
|
|
27
|
-
secretAccessKey: config.credentials.secretAccessKey,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
async function send({ to, subject, html }: SendOptions): Promise<void> {
|
|
32
|
-
const command = new SendEmailCommand({
|
|
33
|
-
Source: config.from,
|
|
34
|
-
Destination: {
|
|
35
|
-
ToAddresses: [to],
|
|
36
|
-
},
|
|
37
|
-
Message: {
|
|
38
|
-
Subject: {
|
|
39
|
-
Data: subject,
|
|
40
|
-
Charset: "UTF-8",
|
|
41
|
-
},
|
|
42
|
-
Body: {
|
|
43
|
-
Html: {
|
|
44
|
-
Data: html,
|
|
45
|
-
Charset: "UTF-8",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await client.send(command);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function sendVerificationEmail(
|
|
55
|
-
to: string,
|
|
56
|
-
code: string,
|
|
57
|
-
customTemplate?: (code: string, appName: string) => string
|
|
58
|
-
): Promise<void> {
|
|
59
|
-
const html = customTemplate
|
|
60
|
-
? customTemplate(code, config.appName)
|
|
61
|
-
: verificationTemplate(code, config.appName);
|
|
62
|
-
|
|
63
|
-
await send({
|
|
64
|
-
to,
|
|
65
|
-
subject: `Seu código de verificação — ${config.appName}`,
|
|
66
|
-
html,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function sendResetPasswordEmail(
|
|
71
|
-
to: string,
|
|
72
|
-
resetUrl: string,
|
|
73
|
-
customTemplate?: (resetUrl: string, appName: string) => string
|
|
74
|
-
): Promise<void> {
|
|
75
|
-
const html = customTemplate
|
|
76
|
-
? customTemplate(resetUrl, config.appName)
|
|
77
|
-
: resetPasswordTemplate(resetUrl, config.appName);
|
|
78
|
-
|
|
79
|
-
await send({
|
|
80
|
-
to,
|
|
81
|
-
subject: `Redefinição de senha — ${config.appName}`,
|
|
82
|
-
html,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return { send, sendVerificationEmail, sendResetPasswordEmail };
|
|
87
|
-
}
|
package/src/mailer/templates.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export function verificationTemplate(code: string, appName: string): string {
|
|
2
|
-
return `
|
|
3
|
-
<div style="font-family: sans-serif; max-width: 480px; margin: 0 auto;">
|
|
4
|
-
<h2>Verifique seu e-mail — ${appName}</h2>
|
|
5
|
-
<p>Use o código abaixo para confirmar seu cadastro:</p>
|
|
6
|
-
<div style="
|
|
7
|
-
font-size: 32px;
|
|
8
|
-
font-weight: bold;
|
|
9
|
-
letter-spacing: 8px;
|
|
10
|
-
padding: 16px;
|
|
11
|
-
background: #f4f4f4;
|
|
12
|
-
border-radius: 8px;
|
|
13
|
-
text-align: center;
|
|
14
|
-
">
|
|
15
|
-
${code}
|
|
16
|
-
</div>
|
|
17
|
-
<p style="color: #666; font-size: 13px; margin-top: 16px;">
|
|
18
|
-
Este código expira em 60 minutos. Não compartilhe com ninguém.
|
|
19
|
-
</p>
|
|
20
|
-
</div>
|
|
21
|
-
`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function resetPasswordTemplate(
|
|
25
|
-
resetUrl: string,
|
|
26
|
-
appName: string
|
|
27
|
-
): string {
|
|
28
|
-
return `
|
|
29
|
-
<div style="font-family: sans-serif; max-width: 480px; margin: 0 auto;">
|
|
30
|
-
<h2>Redefinição de senha — ${appName}</h2>
|
|
31
|
-
<p>Clique no botão abaixo para redefinir sua senha:</p>
|
|
32
|
-
<a href="${resetUrl}" style="
|
|
33
|
-
display: inline-block;
|
|
34
|
-
padding: 12px 24px;
|
|
35
|
-
background: #000;
|
|
36
|
-
color: #fff;
|
|
37
|
-
text-decoration: none;
|
|
38
|
-
border-radius: 6px;
|
|
39
|
-
margin: 16px 0;
|
|
40
|
-
">
|
|
41
|
-
Redefinir senha
|
|
42
|
-
</a>
|
|
43
|
-
<p style="color: #666; font-size: 13px;">
|
|
44
|
-
Este link expira em 1 hora. Se você não solicitou isso, ignore este e-mail.
|
|
45
|
-
</p>
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
}
|
package/src/s3/index.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
S3Client,
|
|
3
|
-
DeleteObjectCommand,
|
|
4
|
-
HeadObjectCommand,
|
|
5
|
-
} from "@aws-sdk/client-s3";
|
|
6
|
-
import { PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
|
|
7
|
-
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
8
|
-
|
|
9
|
-
// ─── Tipos ────────────────────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
export interface S3Config {
|
|
12
|
-
bucket: string;
|
|
13
|
-
region: string;
|
|
14
|
-
credentials: {
|
|
15
|
-
accessKeyId: string;
|
|
16
|
-
secretAccessKey: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface PresignedUploadOptions {
|
|
21
|
-
key: string;
|
|
22
|
-
contentType: string;
|
|
23
|
-
maxSizeBytes?: number;
|
|
24
|
-
expiresIn?: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface PresignedReadOptions {
|
|
28
|
-
key: string;
|
|
29
|
-
expiresIn?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const ALLOWED_IMAGE_TYPES = [
|
|
33
|
-
"image/jpeg",
|
|
34
|
-
"image/png",
|
|
35
|
-
"image/webp",
|
|
36
|
-
"image/gif",
|
|
37
|
-
];
|
|
38
|
-
const ALLOWED_DOCUMENT_TYPES = ["application/pdf"];
|
|
39
|
-
const ALLOWED_VIDEO_TYPES = ["video/mp4", "video/webm", "video/quicktime"];
|
|
40
|
-
|
|
41
|
-
export const ALLOWED_CONTENT_TYPES = [
|
|
42
|
-
...ALLOWED_IMAGE_TYPES,
|
|
43
|
-
...ALLOWED_DOCUMENT_TYPES,
|
|
44
|
-
...ALLOWED_VIDEO_TYPES,
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
const DEFAULT_MAX_SIZES: Record<string, number> = {
|
|
48
|
-
"image/jpeg": 10 * 1024 * 1024, // 10MB
|
|
49
|
-
"image/png": 10 * 1024 * 1024, // 10MB
|
|
50
|
-
"image/webp": 10 * 1024 * 1024, // 10MB
|
|
51
|
-
"image/gif": 10 * 1024 * 1024, // 10MB
|
|
52
|
-
"application/pdf": 50 * 1024 * 1024, // 50MB
|
|
53
|
-
"video/mp4": 500 * 1024 * 1024, // 500MB
|
|
54
|
-
"video/webm": 500 * 1024 * 1024, // 500MB
|
|
55
|
-
"video/quicktime": 500 * 1024 * 1024, // 500MB
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// ─── Client ───────────────────────────────────────────────────────────────────
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Cria e retorna um cliente S3 configurado.
|
|
62
|
-
* O bucket deve ser privado — todos os acessos são feitos via presigned URLs.
|
|
63
|
-
*/
|
|
64
|
-
export function createS3Client(config: S3Config) {
|
|
65
|
-
const client = new S3Client({
|
|
66
|
-
region: config.region,
|
|
67
|
-
credentials: {
|
|
68
|
-
accessKeyId: config.credentials.accessKeyId,
|
|
69
|
-
secretAccessKey: config.credentials.secretAccessKey,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// ─── Validação ──────────────────────────────────────────────────────────────
|
|
74
|
-
|
|
75
|
-
function validateContentType(contentType: string): void {
|
|
76
|
-
if (!ALLOWED_CONTENT_TYPES.includes(contentType)) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`Tipo de arquivo não permitido: ${contentType}. ` +
|
|
79
|
-
`Permitidos: ${ALLOWED_CONTENT_TYPES.join(", ")}`
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function validateKey(key: string): void {
|
|
85
|
-
// Previne path traversal
|
|
86
|
-
if (key.includes("..") || key.startsWith("/")) {
|
|
87
|
-
throw new Error("Chave de arquivo inválida.");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// ─── Presigned Upload URL ───────────────────────────────────────────────────
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Gera uma URL pré-assinada para upload direto no S3 (PUT).
|
|
95
|
-
* A URL expira em 15 minutos por padrão.
|
|
96
|
-
*
|
|
97
|
-
* @param options.key - Caminho do arquivo no bucket (ex: "avatars/user-123.jpg")
|
|
98
|
-
* @param options.contentType - MIME type do arquivo (ex: "image/jpeg")
|
|
99
|
-
* @param options.maxSizeBytes - Tamanho máximo em bytes (usa padrão por tipo se omitido)
|
|
100
|
-
* @param options.expiresIn - Tempo de expiração em segundos (padrão: 900 = 15min)
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* const { url, key } = await s3.getPresignedUploadUrl({
|
|
104
|
-
* key: 'avatars/user-123.jpg',
|
|
105
|
-
* contentType: 'image/jpeg',
|
|
106
|
-
* })
|
|
107
|
-
* // Frontend faz PUT para url com o arquivo no body
|
|
108
|
-
*/
|
|
109
|
-
async function getPresignedUploadUrl(
|
|
110
|
-
options: PresignedUploadOptions
|
|
111
|
-
): Promise<{
|
|
112
|
-
url: string;
|
|
113
|
-
key: string;
|
|
114
|
-
expiresIn: number;
|
|
115
|
-
}> {
|
|
116
|
-
const { key, contentType, expiresIn = 900 } = options;
|
|
117
|
-
|
|
118
|
-
validateKey(key);
|
|
119
|
-
validateContentType(contentType);
|
|
120
|
-
|
|
121
|
-
const maxSize = options.maxSizeBytes ?? DEFAULT_MAX_SIZES[contentType];
|
|
122
|
-
|
|
123
|
-
const command = new PutObjectCommand({
|
|
124
|
-
Bucket: config.bucket,
|
|
125
|
-
Key: key,
|
|
126
|
-
ContentType: contentType,
|
|
127
|
-
ContentLengthRange: maxSize ? [1, maxSize] : undefined,
|
|
128
|
-
} as ConstructorParameters<typeof PutObjectCommand>[0]);
|
|
129
|
-
|
|
130
|
-
const url = await getSignedUrl(client, command, { expiresIn });
|
|
131
|
-
|
|
132
|
-
return { url, key, expiresIn };
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// ─── Presigned Read URL ─────────────────────────────────────────────────────
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Gera uma URL pré-assinada para leitura de arquivo privado (GET).
|
|
139
|
-
* A URL expira em 1 hora por padrão.
|
|
140
|
-
*
|
|
141
|
-
* @param options.key - Caminho do arquivo no bucket
|
|
142
|
-
* @param options.expiresIn - Tempo de expiração em segundos (padrão: 3600 = 1h)
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* const { url } = await s3.getPresignedReadUrl({ key: 'avatars/user-123.jpg' })
|
|
146
|
-
*/
|
|
147
|
-
async function getPresignedReadUrl(options: PresignedReadOptions): Promise<{
|
|
148
|
-
url: string;
|
|
149
|
-
key: string;
|
|
150
|
-
expiresIn: number;
|
|
151
|
-
}> {
|
|
152
|
-
const { key, expiresIn = 3600 } = options;
|
|
153
|
-
|
|
154
|
-
validateKey(key);
|
|
155
|
-
|
|
156
|
-
const command = new GetObjectCommand({
|
|
157
|
-
Bucket: config.bucket,
|
|
158
|
-
Key: key,
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const url = await getSignedUrl(client, command, { expiresIn });
|
|
162
|
-
|
|
163
|
-
return { url, key, expiresIn };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// ─── Delete ─────────────────────────────────────────────────────────────────
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Remove um arquivo do bucket.
|
|
170
|
-
*
|
|
171
|
-
* @param key - Caminho do arquivo no bucket
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* await s3.remove('avatars/user-123.jpg')
|
|
175
|
-
*/
|
|
176
|
-
async function remove(key: string): Promise<void> {
|
|
177
|
-
validateKey(key);
|
|
178
|
-
|
|
179
|
-
await client.send(
|
|
180
|
-
new DeleteObjectCommand({
|
|
181
|
-
Bucket: config.bucket,
|
|
182
|
-
Key: key,
|
|
183
|
-
})
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// ─── Exists ─────────────────────────────────────────────────────────────────
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Verifica se um arquivo existe no bucket.
|
|
191
|
-
*
|
|
192
|
-
* @param key - Caminho do arquivo no bucket
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* const exists = await s3.exists('avatars/user-123.jpg')
|
|
196
|
-
*/
|
|
197
|
-
async function exists(key: string): Promise<boolean> {
|
|
198
|
-
validateKey(key);
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
await client.send(
|
|
202
|
-
new HeadObjectCommand({
|
|
203
|
-
Bucket: config.bucket,
|
|
204
|
-
Key: key,
|
|
205
|
-
})
|
|
206
|
-
);
|
|
207
|
-
return true;
|
|
208
|
-
} catch {
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// ─── Generate Key ───────────────────────────────────────────────────────────
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Gera uma chave única para o arquivo no bucket.
|
|
217
|
-
* Formato: {folder}/{uuid}-{timestamp}.{ext}
|
|
218
|
-
*
|
|
219
|
-
* @param folder - Pasta no bucket (ex: "avatars", "documentos")
|
|
220
|
-
* @param filename - Nome original do arquivo (ex: "foto.jpg")
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* const key = s3.generateKey('avatars', 'foto.jpg')
|
|
224
|
-
* // "avatars/a1b2c3d4-1234567890.jpg"
|
|
225
|
-
*/
|
|
226
|
-
function generateKey(folder: string, filename: string): string {
|
|
227
|
-
const ext = filename.split(".").pop()?.toLowerCase() ?? "bin";
|
|
228
|
-
const uuid = crypto.randomUUID();
|
|
229
|
-
const timestamp = Date.now();
|
|
230
|
-
return `${folder}/${uuid}-${timestamp}.${ext}`;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return {
|
|
234
|
-
getPresignedUploadUrl,
|
|
235
|
-
getPresignedReadUrl,
|
|
236
|
-
remove,
|
|
237
|
-
exists,
|
|
238
|
-
generateKey,
|
|
239
|
-
ALLOWED_CONTENT_TYPES,
|
|
240
|
-
};
|
|
241
|
-
}
|