@tarsis/toolkit 0.5.2 → 0.5.3

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.
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
+ const jsxRuntime = require('react/jsx-runtime');
4
+ const React = require('react');
4
5
 
5
6
  const move = (source, start, end) => {
6
7
  const item = source[start];
@@ -142,18 +143,85 @@ const values = (input) => {
142
143
  return keys(input).map((key) => input[key]);
143
144
  };
144
145
 
146
+ const chain = (...elements) => {
147
+ return elements.map((element, index) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
148
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: element }),
149
+ index !== elements.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { children: " • " })
150
+ ] }, index));
151
+ };
152
+
153
+ function distance(x1, x2, y1, y2) {
154
+ const a = x1 - x2;
155
+ const b = y1 - y2;
156
+ return Math.hypot(a, b);
157
+ }
158
+ function lineEq(y2, y1, x2, x1, currentVal) {
159
+ const m = (y2 - y1) / (x2 - x1);
160
+ const b = y1 - m * x1;
161
+ return m * currentVal + b;
162
+ }
163
+ function lerp(a, b, n) {
164
+ return (1 - n) * a + n * b;
165
+ }
166
+
167
+ function delay(ms) {
168
+ return new Promise((resolve) => {
169
+ setTimeout(() => {
170
+ resolve(void 0);
171
+ }, ms);
172
+ });
173
+ }
174
+ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
175
+
176
+ function getPath(x, smoothing) {
177
+ const points = [
178
+ [2, 2],
179
+ [12 - x, 12 + x],
180
+ [22, 22]
181
+ ];
182
+ const calculateControlPoint = (current, previous, next, reverse) => {
183
+ const p = previous || current;
184
+ const n = next || current;
185
+ const o = {
186
+ length: Math.sqrt(Math.pow(n[0] - p[0], 2) + Math.pow(n[1] - p[1], 2)),
187
+ angle: Math.atan2(n[1] - p[1], n[0] - p[0])
188
+ };
189
+ const angle = o.angle + (reverse ? Math.PI : 0);
190
+ const length = o.length * smoothing;
191
+ return [
192
+ current[0] + Math.cos(angle) * length,
193
+ current[1] + Math.sin(angle) * length
194
+ ];
195
+ };
196
+ return points.reduce((acc, point, i, a) => {
197
+ if (i === 0) {
198
+ return `M ${point[0]},${point[1]}`;
199
+ }
200
+ const previous = a[i - 1];
201
+ const cp1 = calculateControlPoint(previous, a[i - 2], point, false);
202
+ const cp2 = calculateControlPoint(point, previous, a[i + 1], true);
203
+ return `${acc} C ${cp1[0]},${cp1[1]} ${cp2[0]},${cp2[1]} ${point[0]},${point[1]}`;
204
+ }, "");
205
+ }
206
+
145
207
  exports.BaseLogger = BaseLogger;
146
208
  exports.animationLogger = animationLogger;
147
209
  exports.apiLogger = apiLogger;
210
+ exports.chain = chain;
148
211
  exports.clearSession = clearSession;
149
212
  exports.componentLogger = componentLogger;
213
+ exports.delay = delay;
214
+ exports.distance = distance;
150
215
  exports.eventLogger = eventLogger;
151
216
  exports.getCurrentLogLevel = getCurrentLogLevel;
217
+ exports.getPath = getPath;
152
218
  exports.hookLogger = hookLogger;
153
219
  exports.is = is;
154
220
  exports.isDebugEnabled = isDebugEnabled;
155
221
  exports.isNonNullable = isNonNullable;
156
222
  exports.keys = keys;
223
+ exports.lerp = lerp;
224
+ exports.lineEq = lineEq;
157
225
  exports.logger = logger;
158
226
  exports.move = move;
159
227
  exports.noop = noop;
@@ -165,3 +233,4 @@ exports.storageLogger = storageLogger;
165
233
  exports.times = times;
166
234
  exports.utilsLogger = utilsLogger;
167
235
  exports.values = values;
236
+ exports.wait = wait;
@@ -1,3 +1,6 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Fragment } from 'react';
3
+
1
4
  const move = (source, start, end) => {
2
5
  const item = source[start];
3
6
  const result = source.slice(0);
@@ -138,4 +141,65 @@ const values = (input) => {
138
141
  return keys(input).map((key) => input[key]);
139
142
  };
140
143
 
141
- export { BaseLogger, animationLogger, apiLogger, clearSession, componentLogger, eventLogger, getCurrentLogLevel, hookLogger, is, isDebugEnabled, isNonNullable, keys, logger, move, noop, notReachable, setLogLevel, setRequestId, setSessionId, storageLogger, times, utilsLogger, values };
144
+ const chain = (...elements) => {
145
+ return elements.map((element, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
146
+ /* @__PURE__ */ jsx("span", { children: element }),
147
+ index !== elements.length - 1 && /* @__PURE__ */ jsx("span", { children: " • " })
148
+ ] }, index));
149
+ };
150
+
151
+ function distance(x1, x2, y1, y2) {
152
+ const a = x1 - x2;
153
+ const b = y1 - y2;
154
+ return Math.hypot(a, b);
155
+ }
156
+ function lineEq(y2, y1, x2, x1, currentVal) {
157
+ const m = (y2 - y1) / (x2 - x1);
158
+ const b = y1 - m * x1;
159
+ return m * currentVal + b;
160
+ }
161
+ function lerp(a, b, n) {
162
+ return (1 - n) * a + n * b;
163
+ }
164
+
165
+ function delay(ms) {
166
+ return new Promise((resolve) => {
167
+ setTimeout(() => {
168
+ resolve(void 0);
169
+ }, ms);
170
+ });
171
+ }
172
+ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
173
+
174
+ function getPath(x, smoothing) {
175
+ const points = [
176
+ [2, 2],
177
+ [12 - x, 12 + x],
178
+ [22, 22]
179
+ ];
180
+ const calculateControlPoint = (current, previous, next, reverse) => {
181
+ const p = previous || current;
182
+ const n = next || current;
183
+ const o = {
184
+ length: Math.sqrt(Math.pow(n[0] - p[0], 2) + Math.pow(n[1] - p[1], 2)),
185
+ angle: Math.atan2(n[1] - p[1], n[0] - p[0])
186
+ };
187
+ const angle = o.angle + (reverse ? Math.PI : 0);
188
+ const length = o.length * smoothing;
189
+ return [
190
+ current[0] + Math.cos(angle) * length,
191
+ current[1] + Math.sin(angle) * length
192
+ ];
193
+ };
194
+ return points.reduce((acc, point, i, a) => {
195
+ if (i === 0) {
196
+ return `M ${point[0]},${point[1]}`;
197
+ }
198
+ const previous = a[i - 1];
199
+ const cp1 = calculateControlPoint(previous, a[i - 2], point, false);
200
+ const cp2 = calculateControlPoint(point, previous, a[i + 1], true);
201
+ return `${acc} C ${cp1[0]},${cp1[1]} ${cp2[0]},${cp2[1]} ${point[0]},${point[1]}`;
202
+ }, "");
203
+ }
204
+
205
+ export { delay as A, BaseLogger as B, wait as C, getPath as D, setSessionId as a, setRequestId as b, clearSession as c, componentLogger as d, animationLogger as e, eventLogger as f, apiLogger as g, hookLogger as h, storageLogger as i, getCurrentLogLevel as j, isDebugEnabled as k, logger as l, move as m, noop as n, is as o, isNonNullable as p, notReachable as q, keys as r, setLogLevel as s, times as t, utilsLogger as u, values as v, chain as w, distance as x, lineEq as y, lerp as z };
@@ -9196,4 +9196,4 @@ const useWindowReady = () => {
9196
9196
  return ready;
9197
9197
  };
9198
9198
 
9199
- export { millisecondsToSeconds as $, buildHTMLStyles as A, buildSVGAttrs as B, isSVGTag as C, useConstant as D, isVariantNode as E, isAnimationControls as F, resolveVariantFromProps as G, scrapeMotionValuesFromProps$1 as H, scrapeMotionValuesFromProps as I, JSAnimation as J, optimizedAppearDataAttribute as K, warning as L, MotionConfigContext as M, invariant as N, warnOnce as O, HTMLVisualElement as P, resolveVariant as Q, animateTarget as R, SVGVisualElement as S, variantProps as T, isKeyframesTarget as U, variantPriorityOrder as V, mixNumber$1 as W, frameData as X, pipe as Y, cancelFrame as Z, secondsToMilliseconds as _, useBowser as a, progress as a0, clamp as a1, createBox as a2, measurePageBox as a3, convertBoxToBoundingBox as a4, convertBoundingBoxToBox as a5, addValueToWillChange as a6, animateMotionValue as a7, percent as a8, noop as a9, createScopedAnimate as aA, microtask as aa, addUniqueItem as ab, removeItem as ac, time as ad, px as ae, circOut as af, scalePoint as ag, SubscriptionManager as ah, isSVGElement as ai, isSVGSVGElement as aj, getValueTransition$1 as ak, frameSteps as al, hasTransform as am, translateAxis as an, transformBox as ao, hasScale as ap, applyBoxDelta as aq, has2DTranslate as ar, applyTreeDeltas as as, createDelta as at, motionValue as au, animateSingleValue as av, scaleCorrectors as aw, getOptimisedAppearId as ax, useMotionValue as ay, collectMotionValues as az, useDebounce as b, useUniversalLayoutEffect as c, useEffectEvent as d, useInterval as e, useLiveRef as f, useMatchMedia as g, useOklch as h, useOutsideClick as i, usePreviousState as j, usePreviousRender as k, useRaf as l, useThrottle as m, useTimeout as n, useWindowReady as o, isBrowser as p, isObject as q, resolveElements as r, interpolate as s, frame as t, useAnimatedText as u, isMotionValue as v, featureDefinitions as w, isControllingVariants as x, isVariantLabel as y, isForcedMotionValue as z };
9199
+ export { millisecondsToSeconds as $, isForcedMotionValue as A, buildHTMLStyles as B, buildSVGAttrs as C, isSVGTag as D, isVariantNode as E, isAnimationControls as F, resolveVariantFromProps as G, scrapeMotionValuesFromProps$1 as H, scrapeMotionValuesFromProps as I, JSAnimation as J, optimizedAppearDataAttribute as K, warning as L, MotionConfigContext as M, invariant as N, warnOnce as O, HTMLVisualElement as P, resolveVariant as Q, animateTarget as R, SVGVisualElement as S, variantProps as T, isKeyframesTarget as U, variantPriorityOrder as V, mixNumber$1 as W, frameData as X, pipe as Y, cancelFrame as Z, secondsToMilliseconds as _, useBowser as a, progress as a0, clamp as a1, createBox as a2, measurePageBox as a3, convertBoxToBoundingBox as a4, convertBoundingBoxToBox as a5, addValueToWillChange as a6, animateMotionValue as a7, percent as a8, noop as a9, hasReducedMotionListener as aA, initPrefersReducedMotion as aB, prefersReducedMotion as aC, createScopedAnimate as aD, microtask as aa, addUniqueItem as ab, removeItem as ac, time as ad, px as ae, circOut as af, scalePoint as ag, SubscriptionManager as ah, isSVGElement as ai, isSVGSVGElement as aj, getValueTransition$1 as ak, frameSteps as al, hasTransform as am, translateAxis as an, transformBox as ao, hasScale as ap, applyBoxDelta as aq, has2DTranslate as ar, applyTreeDeltas as as, createDelta as at, motionValue as au, animateSingleValue as av, scaleCorrectors as aw, getOptimisedAppearId as ax, useMotionValue as ay, collectMotionValues as az, useDebounce as b, useUniversalLayoutEffect as c, useEffectEvent as d, useInterval as e, useLiveRef as f, useMatchMedia as g, useOklch as h, useOutsideClick as i, usePreviousState as j, usePreviousRender as k, useRaf as l, useThrottle as m, useTimeout as n, useWindowReady as o, isBrowser as p, isObject as q, resolveElements as r, interpolate as s, frame as t, useAnimatedText as u, isMotionValue as v, useConstant as w, featureDefinitions as x, isControllingVariants as y, isVariantLabel as z };
@@ -9228,8 +9228,10 @@ exports.frameSteps = frameSteps;
9228
9228
  exports.getOptimisedAppearId = getOptimisedAppearId;
9229
9229
  exports.getValueTransition = getValueTransition$1;
9230
9230
  exports.has2DTranslate = has2DTranslate;
9231
+ exports.hasReducedMotionListener = hasReducedMotionListener;
9231
9232
  exports.hasScale = hasScale;
9232
9233
  exports.hasTransform = hasTransform;
9234
+ exports.initPrefersReducedMotion = initPrefersReducedMotion;
9233
9235
  exports.interpolate = interpolate;
9234
9236
  exports.isAnimationControls = isAnimationControls;
9235
9237
  exports.isBrowser = isBrowser;
@@ -9252,6 +9254,7 @@ exports.noop = noop;
9252
9254
  exports.optimizedAppearDataAttribute = optimizedAppearDataAttribute;
9253
9255
  exports.percent = percent;
9254
9256
  exports.pipe = pipe;
9257
+ exports.prefersReducedMotion = prefersReducedMotion;
9255
9258
  exports.progress = progress;
9256
9259
  exports.px = px;
9257
9260
  exports.removeItem = removeItem;
package/dist/utils.cjs CHANGED
@@ -2,38 +2,37 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const svg = require('./svg-Bi5ULzxB.cjs');
6
- const server = require('./server.cjs');
5
+ const svg = require('./svg-BT_esDTZ.cjs');
7
6
 
8
7
 
9
8
 
9
+ exports.BaseLogger = svg.BaseLogger;
10
+ exports.animationLogger = svg.animationLogger;
11
+ exports.apiLogger = svg.apiLogger;
10
12
  exports.chain = svg.chain;
13
+ exports.clearSession = svg.clearSession;
14
+ exports.componentLogger = svg.componentLogger;
11
15
  exports.delay = svg.delay;
12
16
  exports.distance = svg.distance;
17
+ exports.eventLogger = svg.eventLogger;
18
+ exports.getCurrentLogLevel = svg.getCurrentLogLevel;
13
19
  exports.getPath = svg.getPath;
20
+ exports.hookLogger = svg.hookLogger;
21
+ exports.is = svg.is;
22
+ exports.isDebugEnabled = svg.isDebugEnabled;
23
+ exports.isNonNullable = svg.isNonNullable;
24
+ exports.keys = svg.keys;
14
25
  exports.lerp = svg.lerp;
15
26
  exports.lineEq = svg.lineEq;
27
+ exports.logger = svg.logger;
28
+ exports.move = svg.move;
29
+ exports.noop = svg.noop;
30
+ exports.notReachable = svg.notReachable;
31
+ exports.setLogLevel = svg.setLogLevel;
32
+ exports.setRequestId = svg.setRequestId;
33
+ exports.setSessionId = svg.setSessionId;
34
+ exports.storageLogger = svg.storageLogger;
35
+ exports.times = svg.times;
36
+ exports.utilsLogger = svg.utilsLogger;
37
+ exports.values = svg.values;
16
38
  exports.wait = svg.wait;
17
- exports.BaseLogger = server.BaseLogger;
18
- exports.animationLogger = server.animationLogger;
19
- exports.apiLogger = server.apiLogger;
20
- exports.clearSession = server.clearSession;
21
- exports.componentLogger = server.componentLogger;
22
- exports.eventLogger = server.eventLogger;
23
- exports.getCurrentLogLevel = server.getCurrentLogLevel;
24
- exports.hookLogger = server.hookLogger;
25
- exports.is = server.is;
26
- exports.isDebugEnabled = server.isDebugEnabled;
27
- exports.isNonNullable = server.isNonNullable;
28
- exports.keys = server.keys;
29
- exports.logger = server.logger;
30
- exports.move = server.move;
31
- exports.noop = server.noop;
32
- exports.notReachable = server.notReachable;
33
- exports.setLogLevel = server.setLogLevel;
34
- exports.setRequestId = server.setRequestId;
35
- exports.setSessionId = server.setSessionId;
36
- exports.storageLogger = server.storageLogger;
37
- exports.times = server.times;
38
- exports.utilsLogger = server.utilsLogger;
39
- exports.values = server.values;
package/dist/utils.js CHANGED
@@ -1,2 +1 @@
1
- export { c as chain, b as delay, d as distance, g as getPath, a as lerp, l as lineEq, w as wait } from './svg-CoSCBw2u.js';
2
- export { BaseLogger, animationLogger, apiLogger, clearSession, componentLogger, eventLogger, getCurrentLogLevel, hookLogger, is, isDebugEnabled, isNonNullable, keys, logger, move, noop, notReachable, setLogLevel, setRequestId, setSessionId, storageLogger, times, utilsLogger, values } from './server.js';
1
+ export { B as BaseLogger, e as animationLogger, g as apiLogger, w as chain, c as clearSession, d as componentLogger, A as delay, x as distance, f as eventLogger, j as getCurrentLogLevel, D as getPath, h as hookLogger, o as is, k as isDebugEnabled, p as isNonNullable, r as keys, z as lerp, y as lineEq, l as logger, m as move, n as noop, q as notReachable, s as setLogLevel, b as setRequestId, a as setSessionId, i as storageLogger, t as times, u as utilsLogger, v as values, C as wait } from './svg-CQLdTbLk.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarsis/toolkit",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -28,16 +28,6 @@
28
28
  "default": "./dist/index.cjs"
29
29
  }
30
30
  },
31
- "./server": {
32
- "import": {
33
- "types": "./dist/server.d.ts",
34
- "default": "./dist/server.js"
35
- },
36
- "require": {
37
- "types": "./dist/server.d.ts",
38
- "default": "./dist/server.cjs"
39
- }
40
- },
41
31
  "./hooks": {
42
32
  "import": {
43
33
  "types": "./dist/hooks.d.ts",
@@ -62,6 +52,7 @@
62
52
  },
63
53
  "scripts": {
64
54
  "dev": "storybook dev -p 6006",
55
+ "start": "yarn dev",
65
56
  "test": "vitest run",
66
57
  "test:watch": "vitest",
67
58
  "test:ui": "vitest --ui",
package/dist/server.d.ts DELETED
@@ -1,70 +0,0 @@
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 { }
@@ -1,73 +0,0 @@
1
- 'use strict';
2
-
3
- const jsxRuntime = require('react/jsx-runtime');
4
- const React = require('react');
5
-
6
- const chain = (...elements) => {
7
- return elements.map((element, index) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
8
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: element }),
9
- index !== elements.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { children: " • " })
10
- ] }, index));
11
- };
12
-
13
- function distance(x1, x2, y1, y2) {
14
- const a = x1 - x2;
15
- const b = y1 - y2;
16
- return Math.hypot(a, b);
17
- }
18
- function lineEq(y2, y1, x2, x1, currentVal) {
19
- const m = (y2 - y1) / (x2 - x1);
20
- const b = y1 - m * x1;
21
- return m * currentVal + b;
22
- }
23
- function lerp(a, b, n) {
24
- return (1 - n) * a + n * b;
25
- }
26
-
27
- function delay(ms) {
28
- return new Promise((resolve) => {
29
- setTimeout(() => {
30
- resolve(void 0);
31
- }, ms);
32
- });
33
- }
34
- const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
35
-
36
- function getPath(x, smoothing) {
37
- const points = [
38
- [2, 2],
39
- [12 - x, 12 + x],
40
- [22, 22]
41
- ];
42
- const calculateControlPoint = (current, previous, next, reverse) => {
43
- const p = previous || current;
44
- const n = next || current;
45
- const o = {
46
- length: Math.sqrt(Math.pow(n[0] - p[0], 2) + Math.pow(n[1] - p[1], 2)),
47
- angle: Math.atan2(n[1] - p[1], n[0] - p[0])
48
- };
49
- const angle = o.angle + (reverse ? Math.PI : 0);
50
- const length = o.length * smoothing;
51
- return [
52
- current[0] + Math.cos(angle) * length,
53
- current[1] + Math.sin(angle) * length
54
- ];
55
- };
56
- return points.reduce((acc, point, i, a) => {
57
- if (i === 0) {
58
- return `M ${point[0]},${point[1]}`;
59
- }
60
- const previous = a[i - 1];
61
- const cp1 = calculateControlPoint(previous, a[i - 2], point, false);
62
- const cp2 = calculateControlPoint(point, previous, a[i + 1], true);
63
- return `${acc} C ${cp1[0]},${cp1[1]} ${cp2[0]},${cp2[1]} ${point[0]},${point[1]}`;
64
- }, "");
65
- }
66
-
67
- exports.chain = chain;
68
- exports.delay = delay;
69
- exports.distance = distance;
70
- exports.getPath = getPath;
71
- exports.lerp = lerp;
72
- exports.lineEq = lineEq;
73
- exports.wait = wait;
@@ -1,65 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Fragment } from 'react';
3
-
4
- const chain = (...elements) => {
5
- return elements.map((element, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
6
- /* @__PURE__ */ jsx("span", { children: element }),
7
- index !== elements.length - 1 && /* @__PURE__ */ jsx("span", { children: " • " })
8
- ] }, index));
9
- };
10
-
11
- function distance(x1, x2, y1, y2) {
12
- const a = x1 - x2;
13
- const b = y1 - y2;
14
- return Math.hypot(a, b);
15
- }
16
- function lineEq(y2, y1, x2, x1, currentVal) {
17
- const m = (y2 - y1) / (x2 - x1);
18
- const b = y1 - m * x1;
19
- return m * currentVal + b;
20
- }
21
- function lerp(a, b, n) {
22
- return (1 - n) * a + n * b;
23
- }
24
-
25
- function delay(ms) {
26
- return new Promise((resolve) => {
27
- setTimeout(() => {
28
- resolve(void 0);
29
- }, ms);
30
- });
31
- }
32
- const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
33
-
34
- function getPath(x, smoothing) {
35
- const points = [
36
- [2, 2],
37
- [12 - x, 12 + x],
38
- [22, 22]
39
- ];
40
- const calculateControlPoint = (current, previous, next, reverse) => {
41
- const p = previous || current;
42
- const n = next || current;
43
- const o = {
44
- length: Math.sqrt(Math.pow(n[0] - p[0], 2) + Math.pow(n[1] - p[1], 2)),
45
- angle: Math.atan2(n[1] - p[1], n[0] - p[0])
46
- };
47
- const angle = o.angle + (reverse ? Math.PI : 0);
48
- const length = o.length * smoothing;
49
- return [
50
- current[0] + Math.cos(angle) * length,
51
- current[1] + Math.sin(angle) * length
52
- ];
53
- };
54
- return points.reduce((acc, point, i, a) => {
55
- if (i === 0) {
56
- return `M ${point[0]},${point[1]}`;
57
- }
58
- const previous = a[i - 1];
59
- const cp1 = calculateControlPoint(previous, a[i - 2], point, false);
60
- const cp2 = calculateControlPoint(point, previous, a[i + 1], true);
61
- return `${acc} C ${cp1[0]},${cp1[1]} ${cp2[0]},${cp2[1]} ${point[0]},${point[1]}`;
62
- }, "");
63
- }
64
-
65
- export { lerp as a, delay as b, chain as c, distance as d, getPath as g, lineEq as l, wait as w };