@bouzu/shared 0.1.0 → 0.1.1

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 CHANGED
@@ -166,6 +166,7 @@ function toPoint(rect) {
166
166
  function isObject(val) {
167
167
  return Object.prototype.toString.call(val) === "[object Object]";
168
168
  }
169
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
169
170
 
170
171
  const Axis = {
171
172
  X: "x",
@@ -238,7 +239,7 @@ function registerRaf(handler, methods) {
238
239
  };
239
240
  }
240
241
 
241
- const perf = window?.performance ?? null;
242
+ const perf = isClient ? window?.performance ?? null : null;
242
243
  const perfNowFn = perf?.now ?? perf?.webkitNow ?? perf?.msNow ?? perf?.mozNow;
243
244
  const getTime = perfNowFn ? perfNowFn.bind(perf) : Date.now ?? (() => (/* @__PURE__ */ new Date()).getTime());
244
245
 
@@ -341,6 +342,7 @@ exports.getRectTopLeft = getRectTopLeft;
341
342
  exports.getRectTopRight = getRectTopRight;
342
343
  exports.getSizeByAxis = getSizeByAxis;
343
344
  exports.getTime = getTime;
345
+ exports.isClient = isClient;
344
346
  exports.isObject = isObject;
345
347
  exports.noop = noop;
346
348
  exports.registerRaf = registerRaf;
package/dist/index.d.cts CHANGED
@@ -65,6 +65,7 @@ declare function toSize(rect: Rect): Size;
65
65
  declare function toPoint(rect: Rect): Point;
66
66
 
67
67
  declare function isObject(val: unknown): val is Record<PropertyKey, any>;
68
+ declare const isClient: boolean;
68
69
 
69
70
  declare const Axis: {
70
71
  readonly X: "x";
@@ -120,4 +121,4 @@ declare const easeLinear: EaseFn;
120
121
  declare const easeOut: EaseFn;
121
122
  declare const easeOutCubic: EaseFn;
122
123
 
123
- export { Axis, type AxisValue, type CancelRaf, type EaseFn, type GetTimeFn, type Point, type Previous, type Rect, RectCorner, type RectCornerValue, type RegisterRafMethods, type RunTransitionOptions, type Size, type TransitionRunner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
124
+ export { Axis, type AxisValue, type CancelRaf, type EaseFn, type GetTimeFn, type Point, type Previous, type Rect, RectCorner, type RectCornerValue, type RegisterRafMethods, type RunTransitionOptions, type Size, type TransitionRunner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isClient, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
package/dist/index.d.mts CHANGED
@@ -65,6 +65,7 @@ declare function toSize(rect: Rect): Size;
65
65
  declare function toPoint(rect: Rect): Point;
66
66
 
67
67
  declare function isObject(val: unknown): val is Record<PropertyKey, any>;
68
+ declare const isClient: boolean;
68
69
 
69
70
  declare const Axis: {
70
71
  readonly X: "x";
@@ -120,4 +121,4 @@ declare const easeLinear: EaseFn;
120
121
  declare const easeOut: EaseFn;
121
122
  declare const easeOutCubic: EaseFn;
122
123
 
123
- export { Axis, type AxisValue, type CancelRaf, type EaseFn, type GetTimeFn, type Point, type Previous, type Rect, RectCorner, type RectCornerValue, type RegisterRafMethods, type RunTransitionOptions, type Size, type TransitionRunner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
124
+ export { Axis, type AxisValue, type CancelRaf, type EaseFn, type GetTimeFn, type Point, type Previous, type Rect, RectCorner, type RectCornerValue, type RegisterRafMethods, type RunTransitionOptions, type Size, type TransitionRunner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isClient, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
package/dist/index.d.ts CHANGED
@@ -65,6 +65,7 @@ declare function toSize(rect: Rect): Size;
65
65
  declare function toPoint(rect: Rect): Point;
66
66
 
67
67
  declare function isObject(val: unknown): val is Record<PropertyKey, any>;
68
+ declare const isClient: boolean;
68
69
 
69
70
  declare const Axis: {
70
71
  readonly X: "x";
@@ -120,4 +121,4 @@ declare const easeLinear: EaseFn;
120
121
  declare const easeOut: EaseFn;
121
122
  declare const easeOutCubic: EaseFn;
122
123
 
123
- export { Axis, type AxisValue, type CancelRaf, type EaseFn, type GetTimeFn, type Point, type Previous, type Rect, RectCorner, type RectCornerValue, type RegisterRafMethods, type RunTransitionOptions, type Size, type TransitionRunner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
124
+ export { Axis, type AxisValue, type CancelRaf, type EaseFn, type GetTimeFn, type Point, type Previous, type Rect, RectCorner, type RectCornerValue, type RegisterRafMethods, type RunTransitionOptions, type Size, type TransitionRunner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isClient, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
package/dist/index.mjs CHANGED
@@ -164,6 +164,7 @@ function toPoint(rect) {
164
164
  function isObject(val) {
165
165
  return Object.prototype.toString.call(val) === "[object Object]";
166
166
  }
167
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
167
168
 
168
169
  const Axis = {
169
170
  X: "x",
@@ -236,7 +237,7 @@ function registerRaf(handler, methods) {
236
237
  };
237
238
  }
238
239
 
239
- const perf = window?.performance ?? null;
240
+ const perf = isClient ? window?.performance ?? null : null;
240
241
  const perfNowFn = perf?.now ?? perf?.webkitNow ?? perf?.msNow ?? perf?.mozNow;
241
242
  const getTime = perfNowFn ? perfNowFn.bind(perf) : Date.now ?? (() => (/* @__PURE__ */ new Date()).getTime());
242
243
 
@@ -297,4 +298,4 @@ const easeLinear = (t) => t;
297
298
  const easeOut = (t) => Math.sin(t * Math.PI / 2);
298
299
  const easeOutCubic = (t) => 1 - (1 - t) ** 3;
299
300
 
300
- export { Axis, RectCorner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
301
+ export { Axis, RectCorner, checkAxis, checkLayoutInvalidate, checkPointEqual, checkPointEqualWithTolerance, checkPointOrigin, checkRectContains, checkRectContainsPoint, checkRectEqual, checkRectEqualPoint, checkRectEqualSize, checkRectIntersects, checkRectIntersectsByAxis, checkRectIntersectsX, checkRectIntersectsY, checkSizeEqual, clamp, clonePoint, cloneRect, createPoint, createRect, createSize, easeLinear, easeOut, easeOutCubic, execLastTick, getPointByAxis, getPointCenter, getPointDistance, getRectArea, getRectBottomLeft, getRectBottomRight, getRectCornerInOther, getRectMaxByAxis, getRectMaxX, getRectMaxY, getRectPointByRectCorner, getRectTopLeft, getRectTopRight, getSizeByAxis, getTime, isClient, isObject, noop, registerRaf, reverseAxis, runNoopTransition, runTransition, toPoint, toSize, updatePointByAxis, updateSizeByAxis, usePrevious };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bouzu/shared",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "author": "zhong666 <hi@zhong666.me>",
6
6
  "license": "MIT",