@tarsis/toolkit 0.5.1 → 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 };
@@ -2303,6 +2303,12 @@ class NativeAnimation extends WithPromise {
2303
2303
  super();
2304
2304
  this.finishedTime = null;
2305
2305
  this.isStopped = false;
2306
+ /**
2307
+ * Tracks a manually-set start time that takes precedence over WAAPI's
2308
+ * dynamic startTime. This is cleared when play() or time setter is called,
2309
+ * allowing WAAPI to take over timing.
2310
+ */
2311
+ this.manualStartTime = null;
2306
2312
  if (!options)
2307
2313
  return;
2308
2314
  const { element, name, keyframes, pseudoElement, allowFlatten = false, finalKeyframe, onComplete, } = options;
@@ -2338,6 +2344,7 @@ class NativeAnimation extends WithPromise {
2338
2344
  play() {
2339
2345
  if (this.isStopped)
2340
2346
  return;
2347
+ this.manualStartTime = null;
2341
2348
  this.animation.play();
2342
2349
  if (this.state === "finished") {
2343
2350
  this.updateFinished();
@@ -2401,6 +2408,7 @@ class NativeAnimation extends WithPromise {
2401
2408
  return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
2402
2409
  }
2403
2410
  set time(newTime) {
2411
+ this.manualStartTime = null;
2404
2412
  this.finishedTime = null;
2405
2413
  this.animation.currentTime = secondsToMilliseconds(newTime);
2406
2414
  }
@@ -2423,10 +2431,10 @@ class NativeAnimation extends WithPromise {
2423
2431
  : this.animation.playState;
2424
2432
  }
2425
2433
  get startTime() {
2426
- return Number(this.animation.startTime);
2434
+ return this.manualStartTime ?? Number(this.animation.startTime);
2427
2435
  }
2428
2436
  set startTime(newStartTime) {
2429
- this.animation.startTime = newStartTime;
2437
+ this.manualStartTime = this.animation.startTime = newStartTime;
2430
2438
  }
2431
2439
  /**
2432
2440
  * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
@@ -2488,7 +2496,7 @@ class NativeAnimationExtended extends NativeAnimation {
2488
2496
  */
2489
2497
  replaceTransitionType(options);
2490
2498
  super(options);
2491
- if (options.startTime) {
2499
+ if (options.startTime !== undefined) {
2492
2500
  this.startTime = options.startTime;
2493
2501
  }
2494
2502
  this.options = options;
@@ -2513,8 +2521,14 @@ class NativeAnimationExtended extends NativeAnimation {
2513
2521
  ...options,
2514
2522
  autoplay: false,
2515
2523
  });
2516
- const sampleTime = secondsToMilliseconds(this.finishedTime ?? this.time);
2517
- motionValue.setWithVelocity(sampleAnimation.sample(sampleTime - sampleDelta).value, sampleAnimation.sample(sampleTime).value, sampleDelta);
2524
+ /**
2525
+ * Use wall-clock elapsed time for sampling.
2526
+ * Under CPU load, WAAPI's currentTime may not reflect actual
2527
+ * elapsed time, causing incorrect sampling and visual jumps.
2528
+ */
2529
+ const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
2530
+ const delta = clamp(0, sampleDelta, sampleTime - sampleDelta);
2531
+ motionValue.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, sampleAnimation.sample(sampleTime).value, delta);
2518
2532
  sampleAnimation.stop();
2519
2533
  }
2520
2534
  }
@@ -9182,4 +9196,4 @@ const useWindowReady = () => {
9182
9196
  return ready;
9183
9197
  };
9184
9198
 
9185
- 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 };
@@ -2305,6 +2305,12 @@ class NativeAnimation extends WithPromise {
2305
2305
  super();
2306
2306
  this.finishedTime = null;
2307
2307
  this.isStopped = false;
2308
+ /**
2309
+ * Tracks a manually-set start time that takes precedence over WAAPI's
2310
+ * dynamic startTime. This is cleared when play() or time setter is called,
2311
+ * allowing WAAPI to take over timing.
2312
+ */
2313
+ this.manualStartTime = null;
2308
2314
  if (!options)
2309
2315
  return;
2310
2316
  const { element, name, keyframes, pseudoElement, allowFlatten = false, finalKeyframe, onComplete, } = options;
@@ -2340,6 +2346,7 @@ class NativeAnimation extends WithPromise {
2340
2346
  play() {
2341
2347
  if (this.isStopped)
2342
2348
  return;
2349
+ this.manualStartTime = null;
2343
2350
  this.animation.play();
2344
2351
  if (this.state === "finished") {
2345
2352
  this.updateFinished();
@@ -2403,6 +2410,7 @@ class NativeAnimation extends WithPromise {
2403
2410
  return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
2404
2411
  }
2405
2412
  set time(newTime) {
2413
+ this.manualStartTime = null;
2406
2414
  this.finishedTime = null;
2407
2415
  this.animation.currentTime = secondsToMilliseconds(newTime);
2408
2416
  }
@@ -2425,10 +2433,10 @@ class NativeAnimation extends WithPromise {
2425
2433
  : this.animation.playState;
2426
2434
  }
2427
2435
  get startTime() {
2428
- return Number(this.animation.startTime);
2436
+ return this.manualStartTime ?? Number(this.animation.startTime);
2429
2437
  }
2430
2438
  set startTime(newStartTime) {
2431
- this.animation.startTime = newStartTime;
2439
+ this.manualStartTime = this.animation.startTime = newStartTime;
2432
2440
  }
2433
2441
  /**
2434
2442
  * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
@@ -2490,7 +2498,7 @@ class NativeAnimationExtended extends NativeAnimation {
2490
2498
  */
2491
2499
  replaceTransitionType(options);
2492
2500
  super(options);
2493
- if (options.startTime) {
2501
+ if (options.startTime !== undefined) {
2494
2502
  this.startTime = options.startTime;
2495
2503
  }
2496
2504
  this.options = options;
@@ -2515,8 +2523,14 @@ class NativeAnimationExtended extends NativeAnimation {
2515
2523
  ...options,
2516
2524
  autoplay: false,
2517
2525
  });
2518
- const sampleTime = secondsToMilliseconds(this.finishedTime ?? this.time);
2519
- motionValue.setWithVelocity(sampleAnimation.sample(sampleTime - sampleDelta).value, sampleAnimation.sample(sampleTime).value, sampleDelta);
2526
+ /**
2527
+ * Use wall-clock elapsed time for sampling.
2528
+ * Under CPU load, WAAPI's currentTime may not reflect actual
2529
+ * elapsed time, causing incorrect sampling and visual jumps.
2530
+ */
2531
+ const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
2532
+ const delta = clamp(0, sampleDelta, sampleTime - sampleDelta);
2533
+ motionValue.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, sampleAnimation.sample(sampleTime).value, delta);
2520
2534
  sampleAnimation.stop();
2521
2535
  }
2522
2536
  }
@@ -9214,8 +9228,10 @@ exports.frameSteps = frameSteps;
9214
9228
  exports.getOptimisedAppearId = getOptimisedAppearId;
9215
9229
  exports.getValueTransition = getValueTransition$1;
9216
9230
  exports.has2DTranslate = has2DTranslate;
9231
+ exports.hasReducedMotionListener = hasReducedMotionListener;
9217
9232
  exports.hasScale = hasScale;
9218
9233
  exports.hasTransform = hasTransform;
9234
+ exports.initPrefersReducedMotion = initPrefersReducedMotion;
9219
9235
  exports.interpolate = interpolate;
9220
9236
  exports.isAnimationControls = isAnimationControls;
9221
9237
  exports.isBrowser = isBrowser;
@@ -9238,6 +9254,7 @@ exports.noop = noop;
9238
9254
  exports.optimizedAppearDataAttribute = optimizedAppearDataAttribute;
9239
9255
  exports.percent = percent;
9240
9256
  exports.pipe = pipe;
9257
+ exports.prefersReducedMotion = prefersReducedMotion;
9241
9258
  exports.progress = progress;
9242
9259
  exports.px = px;
9243
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.1",
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",
@@ -79,13 +70,13 @@
79
70
  "@use-gesture/react": "^10.3.1",
80
71
  "bowser": "^2.13.1",
81
72
  "canvas-confetti": "^1.9.4",
82
- "classnames": "^2.5.1",
73
+ "clsx": "^2.1.1",
83
74
  "flickity": "^2.3.0",
84
75
  "gsap": "^3.14.2",
85
76
  "howler": "^2.2.4",
86
77
  "html2canvas": "^1.4.1",
87
78
  "load-bmfont": "1.4.1",
88
- "motion": "^12.24.10",
79
+ "motion": "^12.24.11",
89
80
  "p5": "^2.0.5",
90
81
  "react-flip-toolkit": "^7.2.4",
91
82
  "react-icons": "^5.5.0",
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 };