@tarsis/toolkit 0.4.0 → 0.4.2-beta.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/index.cjs +60 -201
- package/dist/index.js +29 -169
- package/dist/server.cjs +170 -0
- package/dist/server.d.ts +72 -0
- package/dist/server.js +143 -0
- package/dist/{index.css → toolkit.css} +482 -482
- package/package.json +11 -1
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ import { useDrag } from '@use-gesture/react';
|
|
|
10
10
|
import html2canvas from 'html2canvas';
|
|
11
11
|
import * as THREE from 'three';
|
|
12
12
|
import confetti from 'canvas-confetti';
|
|
13
|
+
import { noop } from './server.js';
|
|
14
|
+
export { BaseLogger, animationLogger, apiLogger, clearSession, componentLogger, eventLogger, getCurrentLogLevel, hookLogger, is, isDebugEnabled, isNonNullable, keys, logger, move, notReachable, setLogLevel, setRequestId, setSessionId, storageLogger, times, utilsLogger, values, wait } from './server.js';
|
|
13
15
|
import { Flipper, Flipped } from 'react-flip-toolkit';
|
|
14
16
|
import { Tooltip } from '@reach/tooltip';
|
|
15
17
|
import Bowser from 'bowser';
|
|
@@ -646,11 +648,11 @@ const BubblyParticlesButton = () => {
|
|
|
646
648
|
);
|
|
647
649
|
};
|
|
648
650
|
|
|
649
|
-
const root$4k = "
|
|
650
|
-
const button$o = "
|
|
651
|
-
const p = "
|
|
652
|
-
const text$z = "
|
|
653
|
-
const effects = "
|
|
651
|
+
const root$4k = "_root_ayg4k_1";
|
|
652
|
+
const button$o = "_button_ayg4k_13";
|
|
653
|
+
const p = "_p_ayg4k_26";
|
|
654
|
+
const text$z = "_text_ayg4k_26";
|
|
655
|
+
const effects = "_effects_ayg4k_240";
|
|
654
656
|
const styles$4H = {
|
|
655
657
|
root: root$4k,
|
|
656
658
|
button: button$o,
|
|
@@ -1900,148 +1902,6 @@ const styles$4y = {
|
|
|
1900
1902
|
content: content$p
|
|
1901
1903
|
};
|
|
1902
1904
|
|
|
1903
|
-
const move = (source, start, end) => {
|
|
1904
|
-
const item = source[start];
|
|
1905
|
-
const result = source.slice(0);
|
|
1906
|
-
result.splice(start, 1);
|
|
1907
|
-
result.splice(end, 0, item);
|
|
1908
|
-
return result;
|
|
1909
|
-
};
|
|
1910
|
-
|
|
1911
|
-
const times = (fn, size) => Array.from({ length: size }, (_, index) => fn(index));
|
|
1912
|
-
|
|
1913
|
-
const logRank = {
|
|
1914
|
-
silent: 0,
|
|
1915
|
-
error: 1,
|
|
1916
|
-
warn: 2,
|
|
1917
|
-
info: 3,
|
|
1918
|
-
debug: 4
|
|
1919
|
-
};
|
|
1920
|
-
const getEnvLogLevel = () => {
|
|
1921
|
-
if (typeof process === "undefined") return "info";
|
|
1922
|
-
const envLevel = process.env.LOG_LEVEL?.toLowerCase();
|
|
1923
|
-
return envLevel && Object.prototype.hasOwnProperty.call(logRank, envLevel) ? envLevel : "info";
|
|
1924
|
-
};
|
|
1925
|
-
let currentLevel = getEnvLogLevel();
|
|
1926
|
-
const setLogLevel = (level) => {
|
|
1927
|
-
if (Object.prototype.hasOwnProperty.call(logRank, level)) {
|
|
1928
|
-
currentLevel = level;
|
|
1929
|
-
}
|
|
1930
|
-
};
|
|
1931
|
-
const getTimestamp = () => {
|
|
1932
|
-
const now = /* @__PURE__ */ new Date();
|
|
1933
|
-
return now.toTimeString().split(" ")[0] + "." + now.getMilliseconds().toString().padStart(3, "0");
|
|
1934
|
-
};
|
|
1935
|
-
const shouldLog = (level) => {
|
|
1936
|
-
return logRank[level] <= logRank[currentLevel];
|
|
1937
|
-
};
|
|
1938
|
-
let sessionId = null;
|
|
1939
|
-
let requestId = null;
|
|
1940
|
-
const setSessionId = (id) => {
|
|
1941
|
-
sessionId = id;
|
|
1942
|
-
};
|
|
1943
|
-
const setRequestId = (id) => {
|
|
1944
|
-
requestId = id;
|
|
1945
|
-
};
|
|
1946
|
-
const clearSession = () => {
|
|
1947
|
-
sessionId = null;
|
|
1948
|
-
requestId = null;
|
|
1949
|
-
};
|
|
1950
|
-
const getSessionInfo = () => {
|
|
1951
|
-
const parts = [];
|
|
1952
|
-
if (sessionId) parts.push(`session:${sessionId}`);
|
|
1953
|
-
if (requestId) parts.push(`req:${requestId}`);
|
|
1954
|
-
return parts.length > 0 ? `[${parts.join("|")}]` : "";
|
|
1955
|
-
};
|
|
1956
|
-
class BaseLogger {
|
|
1957
|
-
prefix;
|
|
1958
|
-
emoji;
|
|
1959
|
-
constructor(prefix, emoji) {
|
|
1960
|
-
this.prefix = prefix;
|
|
1961
|
-
this.emoji = emoji;
|
|
1962
|
-
}
|
|
1963
|
-
log(level, emoji, msg, fn = console.log, data) {
|
|
1964
|
-
if (shouldLog(level)) {
|
|
1965
|
-
const sessionInfo = getSessionInfo();
|
|
1966
|
-
const logMessage = `[${getTimestamp()}] ${emoji} ${this.prefix ? `[${this.prefix}] ` : ""}${msg}${sessionInfo}`;
|
|
1967
|
-
fn(logMessage);
|
|
1968
|
-
if (data && shouldLog(level)) {
|
|
1969
|
-
console.dir(data, { depth: null });
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
info(msg, data) {
|
|
1974
|
-
this.log("info", this.emoji, msg, console.log, data);
|
|
1975
|
-
}
|
|
1976
|
-
debug(msg, data) {
|
|
1977
|
-
this.log("debug", this.emoji, msg, console.debug, data);
|
|
1978
|
-
}
|
|
1979
|
-
success(msg, data) {
|
|
1980
|
-
this.log("info", "✅", msg, console.log, data);
|
|
1981
|
-
}
|
|
1982
|
-
warn(msg, data) {
|
|
1983
|
-
this.log("warn", "⚠️", msg, console.warn, data);
|
|
1984
|
-
}
|
|
1985
|
-
error(msg, detail) {
|
|
1986
|
-
this.log("error", "❌", msg, console.error, detail);
|
|
1987
|
-
}
|
|
1988
|
-
scope(msg, data) {
|
|
1989
|
-
this.log("debug", "🔹", msg, console.debug, data);
|
|
1990
|
-
}
|
|
1991
|
-
dir(data) {
|
|
1992
|
-
if (shouldLog("debug")) {
|
|
1993
|
-
this.log("debug", "📦", "Object:", console.debug);
|
|
1994
|
-
console.dir(data, { depth: null });
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
time(label) {
|
|
1998
|
-
const start = performance.now();
|
|
1999
|
-
return {
|
|
2000
|
-
end: (data) => {
|
|
2001
|
-
const duration = performance.now() - start;
|
|
2002
|
-
this.info(`${label} completed in ${duration.toFixed(2)}ms`, data);
|
|
2003
|
-
}
|
|
2004
|
-
};
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
const logger = new BaseLogger("", "ℹ️");
|
|
2008
|
-
const componentLogger = new BaseLogger("Component", "🧩");
|
|
2009
|
-
const hookLogger = new BaseLogger("Hook", "🪝");
|
|
2010
|
-
const animationLogger = new BaseLogger("Animation", "🎬");
|
|
2011
|
-
const eventLogger = new BaseLogger("Event", "⚡");
|
|
2012
|
-
const apiLogger = new BaseLogger("API", "🌐");
|
|
2013
|
-
const storageLogger = new BaseLogger("Storage", "💾");
|
|
2014
|
-
const utilsLogger = new BaseLogger("Utils", "🔧");
|
|
2015
|
-
const getCurrentLogLevel = () => currentLevel;
|
|
2016
|
-
const isDebugEnabled = () => shouldLog("debug");
|
|
2017
|
-
|
|
2018
|
-
const noop = (..._args) => {
|
|
2019
|
-
};
|
|
2020
|
-
|
|
2021
|
-
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2022
|
-
|
|
2023
|
-
const is = (type) => (x) => Object(x) instanceof type;
|
|
2024
|
-
|
|
2025
|
-
const isNonNullable = (value) => value !== void 0 && value !== null;
|
|
2026
|
-
|
|
2027
|
-
const notReachable = (arg) => {
|
|
2028
|
-
throw new Error(`"${arg}" should never be reached`);
|
|
2029
|
-
};
|
|
2030
|
-
|
|
2031
|
-
const keys = (value) => {
|
|
2032
|
-
const primitiveKeys = Object.keys(
|
|
2033
|
-
value
|
|
2034
|
-
);
|
|
2035
|
-
const symbolKeys = Object.getOwnPropertySymbols(value).filter(
|
|
2036
|
-
(sym) => Object.getOwnPropertyDescriptor(value, sym)?.enumerable
|
|
2037
|
-
);
|
|
2038
|
-
return [...primitiveKeys, ...symbolKeys];
|
|
2039
|
-
};
|
|
2040
|
-
|
|
2041
|
-
const values = (input) => {
|
|
2042
|
-
return keys(input).map((key) => input[key]);
|
|
2043
|
-
};
|
|
2044
|
-
|
|
2045
1905
|
const chain = (...elements) => {
|
|
2046
1906
|
return elements.map((element, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2047
1907
|
/* @__PURE__ */ jsx("span", { children: element }),
|
|
@@ -3799,7 +3659,7 @@ const HeartFoldButton = () => {
|
|
|
3799
3659
|
};
|
|
3800
3660
|
|
|
3801
3661
|
const root$3Y = "_root_fusir_1";
|
|
3802
|
-
const process
|
|
3662
|
+
const process = "_process_fusir_29";
|
|
3803
3663
|
const success$3 = "_success_fusir_34";
|
|
3804
3664
|
const progress$1 = "_progress_fusir_63";
|
|
3805
3665
|
const tick$1 = "_tick_fusir_107";
|
|
@@ -3807,7 +3667,7 @@ const icons = "_icons_fusir_67";
|
|
|
3807
3667
|
const states = "_states_fusir_123";
|
|
3808
3668
|
const styles$4g = {
|
|
3809
3669
|
root: root$3Y,
|
|
3810
|
-
process: process
|
|
3670
|
+
process: process,
|
|
3811
3671
|
success: success$3,
|
|
3812
3672
|
progress: progress$1,
|
|
3813
3673
|
tick: tick$1,
|
|
@@ -4607,9 +4467,9 @@ const NeonButton = ({ className = "", ...rest }) => {
|
|
|
4607
4467
|
return /* @__PURE__ */ jsx("button", { type: "button", ...rest, className: cn(styles$49.root, className), children: "Neon" });
|
|
4608
4468
|
};
|
|
4609
4469
|
|
|
4610
|
-
const root$3R = "
|
|
4611
|
-
const i$1 = "
|
|
4612
|
-
const text$s = "
|
|
4470
|
+
const root$3R = "_root_1w6mm_2";
|
|
4471
|
+
const i$1 = "_i_1w6mm_22";
|
|
4472
|
+
const text$s = "_text_1w6mm_482";
|
|
4613
4473
|
const styles$48 = {
|
|
4614
4474
|
root: root$3R,
|
|
4615
4475
|
i: i$1,
|
|
@@ -6533,17 +6393,17 @@ const CONFIG$2 = {
|
|
|
6533
6393
|
"border-spot-opacity": 1,
|
|
6534
6394
|
"border-light-opacity": 1
|
|
6535
6395
|
};
|
|
6536
|
-
const cards$4 = [
|
|
6537
|
-
{
|
|
6538
|
-
id: crypto.randomUUID(),
|
|
6539
|
-
spread: gsap$1.utils.random(0, 1e3),
|
|
6540
|
-
outer: true,
|
|
6541
|
-
control: false,
|
|
6542
|
-
base: gsap$1.utils.random(0, 359)
|
|
6543
|
-
}
|
|
6544
|
-
];
|
|
6545
6396
|
const CardGlow = () => {
|
|
6546
6397
|
useGlowPointer();
|
|
6398
|
+
const cards = useMemo(() => [
|
|
6399
|
+
{
|
|
6400
|
+
id: `card-${Math.random().toString(36).substr(2, 9)}`,
|
|
6401
|
+
spread: gsap$1.utils.random(0, 1e3),
|
|
6402
|
+
outer: true,
|
|
6403
|
+
control: false,
|
|
6404
|
+
base: gsap$1.utils.random(0, 359)
|
|
6405
|
+
}
|
|
6406
|
+
], []);
|
|
6547
6407
|
useEffect(() => {
|
|
6548
6408
|
for (const key of Object.keys(CONFIG$2)) {
|
|
6549
6409
|
if (key === "card") {
|
|
@@ -6562,7 +6422,7 @@ const CardGlow = () => {
|
|
|
6562
6422
|
}
|
|
6563
6423
|
}
|
|
6564
6424
|
}, []);
|
|
6565
|
-
return /* @__PURE__ */ jsx("main", { className: styles$3D.root, children: cards
|
|
6425
|
+
return /* @__PURE__ */ jsx("main", { className: styles$3D.root, children: cards.map((card, index) => {
|
|
6566
6426
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: styles$3D.wrapper, children: /* @__PURE__ */ jsxs(
|
|
6567
6427
|
"article",
|
|
6568
6428
|
{
|
|
@@ -18561,11 +18421,11 @@ const ScrambledText = ({ children, reveal = false }) => {
|
|
|
18561
18421
|
);
|
|
18562
18422
|
};
|
|
18563
18423
|
|
|
18564
|
-
const root$_ = "
|
|
18565
|
-
const line = "
|
|
18566
|
-
const word$1 = "
|
|
18567
|
-
const link = "
|
|
18568
|
-
const letter = "
|
|
18424
|
+
const root$_ = "_root_1td1d_1";
|
|
18425
|
+
const line = "_line_1td1d_9";
|
|
18426
|
+
const word$1 = "_word_1td1d_14";
|
|
18427
|
+
const link = "_link_1td1d_18";
|
|
18428
|
+
const letter = "_letter_1td1d_22";
|
|
18569
18429
|
const styles$13 = {
|
|
18570
18430
|
root: root$_,
|
|
18571
18431
|
line: line,
|
|
@@ -24874,9 +24734,9 @@ const styles$E = {
|
|
|
24874
24734
|
|
|
24875
24735
|
const DIGITS = [0, 3, 4, 8, 7, 2];
|
|
24876
24736
|
const PROXIMITY_RADIUS = 200;
|
|
24877
|
-
const DISTANCE_MAPPER = gsap$1.utils.mapRange(250, 50, 0, 90);
|
|
24878
24737
|
const GlidingReveal = () => {
|
|
24879
24738
|
const codeRef = useRef(null);
|
|
24739
|
+
const DISTANCE_MAPPER = gsap$1.utils.mapRange(250, 50, 0, 90);
|
|
24880
24740
|
const update = useCallback((x, y) => {
|
|
24881
24741
|
if (!codeRef.current) return;
|
|
24882
24742
|
const CENTER_POINT = codeRef.current.getBoundingClientRect();
|
|
@@ -30418,4 +30278,4 @@ const ViewTransitionImageGallery = () => {
|
|
|
30418
30278
|
] });
|
|
30419
30279
|
};
|
|
30420
30280
|
|
|
30421
|
-
export { AccentShardCard, AcrobaticPreloader, ActivateButton, AdjoinedFilters, AirplaneAnimation, AlienSkeuomorphicLoaders, AnimatedBlendedCard, AnimatedHeroTitle, AnimatedHoverButton, AnimatedHoverGlowButton, AnimatedIconsNav, AnimatedShareMenu, ApertureVideo, Appearance, AreaLight, AuroraButton, AutoMasonryGrid, AvatarHover, BackgroundCircles, BackgroundSlider,
|
|
30281
|
+
export { AccentShardCard, AcrobaticPreloader, ActivateButton, AdjoinedFilters, AirplaneAnimation, AlienSkeuomorphicLoaders, AnimatedBlendedCard, AnimatedHeroTitle, AnimatedHoverButton, AnimatedHoverGlowButton, AnimatedIconsNav, AnimatedShareMenu, ApertureVideo, Appearance, AreaLight, AuroraButton, AutoMasonryGrid, AvatarHover, BackgroundCircles, BackgroundSlider, BlurVignette, BlurredBackground, BoldHamburger, BorderGradient, BorderLink, BouncyClock, BrandCard, BreakingProgress, BubblyParticlesButton, BulletsCarousel, BurningButton, ButtonHoverFill, ButtonShimmer, ButtonWithDot, CanOfDigits, CaptionCard, CardCarousel, CardDetails, CardGlow, CardMarquee, CardTile, ChaseLoader, Checkbox, ChequeredCard, Chips, ChromaticAberration, CircleDotsLoader, CircleLinesAnimation, CircleLink, CircleParticles, CircleTextHover, ClaymorphicHeart, ClearInput, ClickButtonParticles, ClickSpark, CollapseAnimation, ColorfulButtons, ComingSoonBadge, ComplexGradient, ConfettiButton, ContrastBackgroundText, Counter, CoverFlowGallery, CronRedirectPage, CubeLoader, CurtainRevealMenu, DDDButton, DDDHoverCard, DDDRangeSlider, DailClock, DarkMatterButton, DarkMatterMouseEffect, DaySwitch, DenseGrid, DetachedMenu, DialControl, DialFuturistic, Dock, DockButton, DockHas, DockMotion, DockY, DoubleArrowButton, DoubleArrowCollabButton, DoubleStateButton, DropdownMenu, Duck, DynamicIconButton, DynamicIsland, EchoClickButton, ElasticCards, ElasticCursor, ElectrifiedButton, ElectrifiedButtonGS, EmailInput, EmojiLayer, EndlessLoader, EnlightenedText, EnvelopeTile, Expand, FadeUp, FailedDownloadButton, FeedbackReactions, FigmaLogo, FileIcons, Fingerprint, FlipChips, FloatingLabelInput, FluidGooeyTextBackground, FootprintButton, ForwardArrowLink, FullScreenImageCarousel, Futuristic3DHoverMenu, GalaxyButton, GalleryReverseScroll, GlassIcon, GlassSwitch, GlideImageGallery, GlidingReveal, GlitterCard, GlowButton, GlowSlider, GlowingDropdown, GlowingInput, GlowingShadows, GlowingTabs, GlowingTabs2, GlowingText, GlowingTile, GoHoverButton, GodRaysButton, GooeyButton, GradientBorder, GradientGlowingTile, GrainyGradientText, GravityButton, Grid3DCards, GridAccordion, GridHover, GridViewTransition, HamburgerMusic, HamburgerX, Header, HeartFoldButton, HoldSubmitButton, HoverGlowButton, HoverTile, Hoverable3DCard, ITEMS$1 as ITEMS, Illumination, ImageCard, ImageClipping, IndeterminateCheckboxes, InfiniteLoader, InputFirework, Ios15Button, IosSwitch, JellyText, LandingXYScroll, LayeredComponents, LeaningCards, ListItemHover, LoaderGenerator, LoadingBook, LoadingWave, Lock, LoveGlow, MagicMouseEffect, MagicalText, MagneticButton, MagnifiedNavItems, MetalCircleController, MinimalisticGlassButton, MobileNavBar, MorphingSubmitButton, MotionClock, MotionDigits, MouseMoveGallery, MultiGradientBackground, MultiStageButton, MultipathSvgAnimation, NamedPointer, NavigationMenu, NeonButton, NeonToggleSwitch, NeumorphicAnalogClock, NeumorphicLogo, NeumorphicSlider, NeuromorphicToggle, NewsletterInput, NoisyButton, NotificationBell, OffTrackPreloader, OrbitalSubmitButton, PaintedLink, PaperPlanButton, ParallaxEmoji, ParallaxMenu, PasswordInput, PhotoCard$1 as PhotoCard, PhotoZoom, PianoNav, PieLoader, PinDropdown, PlayPauseButton, PlayPauseMusicButton, PolaroidStack, PositionHover, PredictionButton, ProductTile, ProfileCard, ProgressButton, PsychedelicButton, PulseInLoader, PulseOutLoader, QuickTimeClock, RadialMenu, RadialNavigation, RadioHopping, RadioParticles, RadioRolling, RaysBackground, RealisticSmoke, RegularLink, RepostButton, RevealImageAnimation, RhombusGallery, RingLoader, RotatedCardsCarousel, RoundScaleLoader, RubberButton, RunningButton, SchrodingerFormControls, ScrambledText, ScramblingLetters, ScrollCountdown, ScrollDrivenTextBlowOut, ScrollTextHighlight, ScrollTimeline, ScrollWithLight, Scroller, ScrollingTextReveal, SearchInput, SegmentedControls, SegmentedToggle, ShadowedCardsList, ShadowedClick, ShakingText, ShakyLine, ShapeSelection, ShimmerButton, ShimmeringBorderGradient, ShineAnimation, ShineCard, ShiningText, ShinyButton, SinglePopoverMenu, SkateboardPreloader, SkeuomorphicLikeButton, SlideIn, SlidingButton, SlidingIcon, SlidingImages, SlidingStepper, SmileyPreloader, SmokeTextDisappearance, SmoothScroll, SnowballPreloader, SolarEclipse, SparkleButton, SparklyButton, SpeechToText, SpinningClickAnimation, SplashCursor, SquircleAvatar, SquishButton, StackingCards, StaticSolarEclipse, StickyHeader, StickyList, StretchToggle, StretchyLoader, StrikethroughCheckbox, StrikethroughCheckboxes, StuntPreloader, SubtleBorderAnimation, SuccessLoader, SuccessLoadingButton, TabBarAnimation, TextImageHover, TextMorphing, TextOutline, TextShadow, Texture, ThanosDisappearEffect, ThanosDisappearEffectList, ThreadsLikeButton, ThreeDotsLoader, ThumbsUpButton, Ticker, TicklishButton, TimeCirclesLoader, TippingSwitch, Toasts, ToggleBubble, ToggleClipPath, TooltipRangeSlider, TranslucentBackdrop, TrickButton, TurbulenceFilter, UnderlinedLink, UnderlinedLink2, ViewTransitionAddToCard, ViewTransitionImageGallery, VoiceAnimation, WavyMenu, WebGLSmoke, WeightText, chain, getDockTooltipPosition, noop, useAnimatedText, useBowser, useDebounce, useEffectEvent, useLiveRef, useMatchMedia, useOklch, useOutsideClick, usePrevious, usePreviousRender, useRaf, useThrottle, useUniversalLayoutEffect, useWindowReady };
|
package/dist/server.cjs
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const move = (source, start, end) => {
|
|
6
|
+
const item = source[start];
|
|
7
|
+
const result = source.slice(0);
|
|
8
|
+
result.splice(start, 1);
|
|
9
|
+
result.splice(end, 0, item);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const times = (fn, size) => Array.from({ length: size }, (_, index) => fn(index));
|
|
14
|
+
|
|
15
|
+
const logRank = {
|
|
16
|
+
silent: 0,
|
|
17
|
+
error: 1,
|
|
18
|
+
warn: 2,
|
|
19
|
+
info: 3,
|
|
20
|
+
debug: 4
|
|
21
|
+
};
|
|
22
|
+
const getEnvLogLevel = () => {
|
|
23
|
+
if (typeof process === "undefined") return "info";
|
|
24
|
+
const envLevel = process.env.LOG_LEVEL?.toLowerCase();
|
|
25
|
+
return envLevel && Object.prototype.hasOwnProperty.call(logRank, envLevel) ? envLevel : "info";
|
|
26
|
+
};
|
|
27
|
+
let currentLevel = getEnvLogLevel();
|
|
28
|
+
const setLogLevel = (level) => {
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(logRank, level)) {
|
|
30
|
+
currentLevel = level;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const getTimestamp = () => {
|
|
34
|
+
const now = /* @__PURE__ */ new Date();
|
|
35
|
+
return now.toTimeString().split(" ")[0] + "." + now.getMilliseconds().toString().padStart(3, "0");
|
|
36
|
+
};
|
|
37
|
+
const shouldLog = (level) => {
|
|
38
|
+
return logRank[level] <= logRank[currentLevel];
|
|
39
|
+
};
|
|
40
|
+
let sessionId = null;
|
|
41
|
+
let requestId = null;
|
|
42
|
+
const setSessionId = (id) => {
|
|
43
|
+
sessionId = id;
|
|
44
|
+
};
|
|
45
|
+
const setRequestId = (id) => {
|
|
46
|
+
requestId = id;
|
|
47
|
+
};
|
|
48
|
+
const clearSession = () => {
|
|
49
|
+
sessionId = null;
|
|
50
|
+
requestId = null;
|
|
51
|
+
};
|
|
52
|
+
const getSessionInfo = () => {
|
|
53
|
+
const parts = [];
|
|
54
|
+
if (sessionId) parts.push(`session:${sessionId}`);
|
|
55
|
+
if (requestId) parts.push(`req:${requestId}`);
|
|
56
|
+
return parts.length > 0 ? `[${parts.join("|")}]` : "";
|
|
57
|
+
};
|
|
58
|
+
class BaseLogger {
|
|
59
|
+
prefix;
|
|
60
|
+
emoji;
|
|
61
|
+
constructor(prefix, emoji) {
|
|
62
|
+
this.prefix = prefix;
|
|
63
|
+
this.emoji = emoji;
|
|
64
|
+
}
|
|
65
|
+
log(level, emoji, msg, fn = console.log, data) {
|
|
66
|
+
if (shouldLog(level)) {
|
|
67
|
+
const sessionInfo = getSessionInfo();
|
|
68
|
+
const logMessage = `[${getTimestamp()}] ${emoji} ${this.prefix ? `[${this.prefix}] ` : ""}${msg}${sessionInfo}`;
|
|
69
|
+
fn(logMessage);
|
|
70
|
+
if (data && shouldLog(level)) {
|
|
71
|
+
console.dir(data, { depth: null });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
info(msg, data) {
|
|
76
|
+
this.log("info", this.emoji, msg, console.log, data);
|
|
77
|
+
}
|
|
78
|
+
debug(msg, data) {
|
|
79
|
+
this.log("debug", this.emoji, msg, console.debug, data);
|
|
80
|
+
}
|
|
81
|
+
success(msg, data) {
|
|
82
|
+
this.log("info", "✅", msg, console.log, data);
|
|
83
|
+
}
|
|
84
|
+
warn(msg, data) {
|
|
85
|
+
this.log("warn", "⚠️", msg, console.warn, data);
|
|
86
|
+
}
|
|
87
|
+
error(msg, detail) {
|
|
88
|
+
this.log("error", "❌", msg, console.error, detail);
|
|
89
|
+
}
|
|
90
|
+
scope(msg, data) {
|
|
91
|
+
this.log("debug", "🔹", msg, console.debug, data);
|
|
92
|
+
}
|
|
93
|
+
dir(data) {
|
|
94
|
+
if (shouldLog("debug")) {
|
|
95
|
+
this.log("debug", "📦", "Object:", console.debug);
|
|
96
|
+
console.dir(data, { depth: null });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
time(label) {
|
|
100
|
+
const start = performance.now();
|
|
101
|
+
return {
|
|
102
|
+
end: (data) => {
|
|
103
|
+
const duration = performance.now() - start;
|
|
104
|
+
this.info(`${label} completed in ${duration.toFixed(2)}ms`, data);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const logger = new BaseLogger("", "ℹ️");
|
|
110
|
+
const componentLogger = new BaseLogger("Component", "🧩");
|
|
111
|
+
const hookLogger = new BaseLogger("Hook", "🪝");
|
|
112
|
+
const animationLogger = new BaseLogger("Animation", "🎬");
|
|
113
|
+
const eventLogger = new BaseLogger("Event", "⚡");
|
|
114
|
+
const apiLogger = new BaseLogger("API", "🌐");
|
|
115
|
+
const storageLogger = new BaseLogger("Storage", "💾");
|
|
116
|
+
const utilsLogger = new BaseLogger("Utils", "🔧");
|
|
117
|
+
const getCurrentLogLevel = () => currentLevel;
|
|
118
|
+
const isDebugEnabled = () => shouldLog("debug");
|
|
119
|
+
|
|
120
|
+
const noop = (..._args) => {
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
124
|
+
|
|
125
|
+
const is = (type) => (x) => Object(x) instanceof type;
|
|
126
|
+
|
|
127
|
+
const isNonNullable = (value) => value !== void 0 && value !== null;
|
|
128
|
+
|
|
129
|
+
const notReachable = (arg) => {
|
|
130
|
+
throw new Error(`"${arg}" should never be reached`);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const keys = (value) => {
|
|
134
|
+
const primitiveKeys = Object.keys(
|
|
135
|
+
value
|
|
136
|
+
);
|
|
137
|
+
const symbolKeys = Object.getOwnPropertySymbols(value).filter(
|
|
138
|
+
(sym) => Object.getOwnPropertyDescriptor(value, sym)?.enumerable
|
|
139
|
+
);
|
|
140
|
+
return [...primitiveKeys, ...symbolKeys];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const values = (input) => {
|
|
144
|
+
return keys(input).map((key) => input[key]);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
exports.BaseLogger = BaseLogger;
|
|
148
|
+
exports.animationLogger = animationLogger;
|
|
149
|
+
exports.apiLogger = apiLogger;
|
|
150
|
+
exports.clearSession = clearSession;
|
|
151
|
+
exports.componentLogger = componentLogger;
|
|
152
|
+
exports.eventLogger = eventLogger;
|
|
153
|
+
exports.getCurrentLogLevel = getCurrentLogLevel;
|
|
154
|
+
exports.hookLogger = hookLogger;
|
|
155
|
+
exports.is = is;
|
|
156
|
+
exports.isDebugEnabled = isDebugEnabled;
|
|
157
|
+
exports.isNonNullable = isNonNullable;
|
|
158
|
+
exports.keys = keys;
|
|
159
|
+
exports.logger = logger;
|
|
160
|
+
exports.move = move;
|
|
161
|
+
exports.noop = noop;
|
|
162
|
+
exports.notReachable = notReachable;
|
|
163
|
+
exports.setLogLevel = setLogLevel;
|
|
164
|
+
exports.setRequestId = setRequestId;
|
|
165
|
+
exports.setSessionId = setSessionId;
|
|
166
|
+
exports.storageLogger = storageLogger;
|
|
167
|
+
exports.times = times;
|
|
168
|
+
exports.utilsLogger = utilsLogger;
|
|
169
|
+
exports.values = values;
|
|
170
|
+
exports.wait = wait;
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare const animationLogger: BaseLogger;
|
|
2
|
+
|
|
3
|
+
export declare const apiLogger: BaseLogger;
|
|
4
|
+
|
|
5
|
+
export declare class BaseLogger {
|
|
6
|
+
protected prefix: string;
|
|
7
|
+
protected emoji: string;
|
|
8
|
+
constructor(prefix: string, emoji: string);
|
|
9
|
+
private log;
|
|
10
|
+
info(msg: string, data?: unknown): void;
|
|
11
|
+
debug(msg: string, data?: unknown): void;
|
|
12
|
+
success(msg: string, data?: unknown): void;
|
|
13
|
+
warn(msg: string, data?: unknown): void;
|
|
14
|
+
error(msg: string, detail?: unknown): void;
|
|
15
|
+
scope(msg: string, data?: unknown): void;
|
|
16
|
+
dir<T>(data: T): void;
|
|
17
|
+
time(label: string): {
|
|
18
|
+
end: (data?: unknown) => void;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export declare const clearSession: () => void;
|
|
23
|
+
|
|
24
|
+
export declare const componentLogger: BaseLogger;
|
|
25
|
+
|
|
26
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
27
|
+
|
|
28
|
+
export declare const eventLogger: BaseLogger;
|
|
29
|
+
|
|
30
|
+
export declare const getCurrentLogLevel: () => LogLevel;
|
|
31
|
+
|
|
32
|
+
export declare const hookLogger: BaseLogger;
|
|
33
|
+
|
|
34
|
+
export declare const is: <T>(type: Constructor<T>) => (x: T) => boolean;
|
|
35
|
+
|
|
36
|
+
export declare const isDebugEnabled: () => boolean;
|
|
37
|
+
|
|
38
|
+
export declare const isNonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
39
|
+
|
|
40
|
+
export declare const keys: <T extends Record<string | number | symbol, any>>(value: T) => Array<`${keyof T & (string | number | boolean)}` | (keyof T & symbol)>;
|
|
41
|
+
|
|
42
|
+
export declare const logger: BaseLogger;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Advanced logger utility for the toolkit
|
|
46
|
+
* Provides consistent logging interface across components with emojis, session tracking, and performance timing
|
|
47
|
+
*/
|
|
48
|
+
export declare type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
|
|
49
|
+
|
|
50
|
+
export declare const move: <T>(source: T[], start: number, end: number) => T[];
|
|
51
|
+
|
|
52
|
+
export declare const noop: (..._args: unknown[]) => void;
|
|
53
|
+
|
|
54
|
+
export declare const notReachable: (arg: never) => never;
|
|
55
|
+
|
|
56
|
+
export declare const setLogLevel: (level: LogLevel) => void;
|
|
57
|
+
|
|
58
|
+
export declare const setRequestId: (id: string) => void;
|
|
59
|
+
|
|
60
|
+
export declare const setSessionId: (id: string) => void;
|
|
61
|
+
|
|
62
|
+
export declare const storageLogger: BaseLogger;
|
|
63
|
+
|
|
64
|
+
export declare const times: <T>(fn: (index: number) => T, size: number) => T[];
|
|
65
|
+
|
|
66
|
+
export declare const utilsLogger: BaseLogger;
|
|
67
|
+
|
|
68
|
+
export declare const values: <T extends Record<string | number | symbol, any>>(input: T) => Array<T[keyof T]>;
|
|
69
|
+
|
|
70
|
+
export declare const wait: (ms: number) => Promise<unknown>;
|
|
71
|
+
|
|
72
|
+
export { }
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const move = (source, start, end) => {
|
|
2
|
+
const item = source[start];
|
|
3
|
+
const result = source.slice(0);
|
|
4
|
+
result.splice(start, 1);
|
|
5
|
+
result.splice(end, 0, item);
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const times = (fn, size) => Array.from({ length: size }, (_, index) => fn(index));
|
|
10
|
+
|
|
11
|
+
const logRank = {
|
|
12
|
+
silent: 0,
|
|
13
|
+
error: 1,
|
|
14
|
+
warn: 2,
|
|
15
|
+
info: 3,
|
|
16
|
+
debug: 4
|
|
17
|
+
};
|
|
18
|
+
const getEnvLogLevel = () => {
|
|
19
|
+
if (typeof process === "undefined") return "info";
|
|
20
|
+
const envLevel = process.env.LOG_LEVEL?.toLowerCase();
|
|
21
|
+
return envLevel && Object.prototype.hasOwnProperty.call(logRank, envLevel) ? envLevel : "info";
|
|
22
|
+
};
|
|
23
|
+
let currentLevel = getEnvLogLevel();
|
|
24
|
+
const setLogLevel = (level) => {
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(logRank, level)) {
|
|
26
|
+
currentLevel = level;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const getTimestamp = () => {
|
|
30
|
+
const now = /* @__PURE__ */ new Date();
|
|
31
|
+
return now.toTimeString().split(" ")[0] + "." + now.getMilliseconds().toString().padStart(3, "0");
|
|
32
|
+
};
|
|
33
|
+
const shouldLog = (level) => {
|
|
34
|
+
return logRank[level] <= logRank[currentLevel];
|
|
35
|
+
};
|
|
36
|
+
let sessionId = null;
|
|
37
|
+
let requestId = null;
|
|
38
|
+
const setSessionId = (id) => {
|
|
39
|
+
sessionId = id;
|
|
40
|
+
};
|
|
41
|
+
const setRequestId = (id) => {
|
|
42
|
+
requestId = id;
|
|
43
|
+
};
|
|
44
|
+
const clearSession = () => {
|
|
45
|
+
sessionId = null;
|
|
46
|
+
requestId = null;
|
|
47
|
+
};
|
|
48
|
+
const getSessionInfo = () => {
|
|
49
|
+
const parts = [];
|
|
50
|
+
if (sessionId) parts.push(`session:${sessionId}`);
|
|
51
|
+
if (requestId) parts.push(`req:${requestId}`);
|
|
52
|
+
return parts.length > 0 ? `[${parts.join("|")}]` : "";
|
|
53
|
+
};
|
|
54
|
+
class BaseLogger {
|
|
55
|
+
prefix;
|
|
56
|
+
emoji;
|
|
57
|
+
constructor(prefix, emoji) {
|
|
58
|
+
this.prefix = prefix;
|
|
59
|
+
this.emoji = emoji;
|
|
60
|
+
}
|
|
61
|
+
log(level, emoji, msg, fn = console.log, data) {
|
|
62
|
+
if (shouldLog(level)) {
|
|
63
|
+
const sessionInfo = getSessionInfo();
|
|
64
|
+
const logMessage = `[${getTimestamp()}] ${emoji} ${this.prefix ? `[${this.prefix}] ` : ""}${msg}${sessionInfo}`;
|
|
65
|
+
fn(logMessage);
|
|
66
|
+
if (data && shouldLog(level)) {
|
|
67
|
+
console.dir(data, { depth: null });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
info(msg, data) {
|
|
72
|
+
this.log("info", this.emoji, msg, console.log, data);
|
|
73
|
+
}
|
|
74
|
+
debug(msg, data) {
|
|
75
|
+
this.log("debug", this.emoji, msg, console.debug, data);
|
|
76
|
+
}
|
|
77
|
+
success(msg, data) {
|
|
78
|
+
this.log("info", "✅", msg, console.log, data);
|
|
79
|
+
}
|
|
80
|
+
warn(msg, data) {
|
|
81
|
+
this.log("warn", "⚠️", msg, console.warn, data);
|
|
82
|
+
}
|
|
83
|
+
error(msg, detail) {
|
|
84
|
+
this.log("error", "❌", msg, console.error, detail);
|
|
85
|
+
}
|
|
86
|
+
scope(msg, data) {
|
|
87
|
+
this.log("debug", "🔹", msg, console.debug, data);
|
|
88
|
+
}
|
|
89
|
+
dir(data) {
|
|
90
|
+
if (shouldLog("debug")) {
|
|
91
|
+
this.log("debug", "📦", "Object:", console.debug);
|
|
92
|
+
console.dir(data, { depth: null });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
time(label) {
|
|
96
|
+
const start = performance.now();
|
|
97
|
+
return {
|
|
98
|
+
end: (data) => {
|
|
99
|
+
const duration = performance.now() - start;
|
|
100
|
+
this.info(`${label} completed in ${duration.toFixed(2)}ms`, data);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const logger = new BaseLogger("", "ℹ️");
|
|
106
|
+
const componentLogger = new BaseLogger("Component", "🧩");
|
|
107
|
+
const hookLogger = new BaseLogger("Hook", "🪝");
|
|
108
|
+
const animationLogger = new BaseLogger("Animation", "🎬");
|
|
109
|
+
const eventLogger = new BaseLogger("Event", "⚡");
|
|
110
|
+
const apiLogger = new BaseLogger("API", "🌐");
|
|
111
|
+
const storageLogger = new BaseLogger("Storage", "💾");
|
|
112
|
+
const utilsLogger = new BaseLogger("Utils", "🔧");
|
|
113
|
+
const getCurrentLogLevel = () => currentLevel;
|
|
114
|
+
const isDebugEnabled = () => shouldLog("debug");
|
|
115
|
+
|
|
116
|
+
const noop = (..._args) => {
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
120
|
+
|
|
121
|
+
const is = (type) => (x) => Object(x) instanceof type;
|
|
122
|
+
|
|
123
|
+
const isNonNullable = (value) => value !== void 0 && value !== null;
|
|
124
|
+
|
|
125
|
+
const notReachable = (arg) => {
|
|
126
|
+
throw new Error(`"${arg}" should never be reached`);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const keys = (value) => {
|
|
130
|
+
const primitiveKeys = Object.keys(
|
|
131
|
+
value
|
|
132
|
+
);
|
|
133
|
+
const symbolKeys = Object.getOwnPropertySymbols(value).filter(
|
|
134
|
+
(sym) => Object.getOwnPropertyDescriptor(value, sym)?.enumerable
|
|
135
|
+
);
|
|
136
|
+
return [...primitiveKeys, ...symbolKeys];
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const values = (input) => {
|
|
140
|
+
return keys(input).map((key) => input[key]);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export { BaseLogger, animationLogger, apiLogger, clearSession, componentLogger, eventLogger, getCurrentLogLevel, hookLogger, is, isDebugEnabled, isNonNullable, keys, logger, move, noop, notReachable, setLogLevel, setRequestId, setSessionId, storageLogger, times, utilsLogger, values, wait };
|