gd-measurements 0.4.2 → 0.5.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.
@@ -1,2 +1,13 @@
1
1
  import { TPoint } from '../types/common';
2
+ /**
3
+ * Normalizes an offset prop to a `TPoint`.
4
+ *
5
+ * Components are typed, but plain JavaScript consumers can pass anything, so
6
+ * `{}`, `{ x: NaN }`, `null` or a string would otherwise reach SVG attributes
7
+ * as `NaN` and make the labels disappear. Every non-finite or missing
8
+ * coordinate falls back to `0`, and a non-finite scalar (like the numeric
9
+ * shorthand used for both axes) falls back to `{ x: 0, y: 0 }`.
10
+ *
11
+ * Returns a new object, so the input is never mutated or shared.
12
+ */
2
13
  export declare const getOffset: (point: number | TPoint) => TPoint;
@@ -0,0 +1 @@
1
+ export * from './number';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Guards numeric props that are declared as required numbers but can still be
3
+ * given invalid values from plain JavaScript consumers (`0`, `-1`, `NaN`,
4
+ * `Infinity`).
5
+ *
6
+ * Returns `fallback` when `value` is not a finite number and never returns
7
+ * less than `min`, so the math built on top of it stays meaningful
8
+ * (`width / 0` or `Array(-1)` would otherwise break the render).
9
+ */
10
+ export declare const numberAtLeast: (value: number | undefined, fallback: number, min: number) => number;
11
+ /**
12
+ * Same as `numberAtLeast`, but floors the result to an integer.
13
+ *
14
+ * Use it for counts (e.g. `subdivisions`), where `Array(length)` requires a
15
+ * non-negative integer and `0` would mean a division by zero.
16
+ */
17
+ export declare const intAtLeast: (value: number | undefined, fallback: number, min?: number) => number;
@@ -0,0 +1 @@
1
+ export * from './throttle';
@@ -0,0 +1,23 @@
1
+ export type TThrottled<TArgs extends unknown[]> = {
2
+ (...args: TArgs): void;
3
+ /** Cancels the pending trailing call. */
4
+ cancel: () => void;
5
+ /** Invokes the pending trailing call immediately. */
6
+ flush: () => void;
7
+ };
8
+ /**
9
+ * Dependency free replacement of `lodash.throttle` with the same default
10
+ * behaviour: the first call is invoked immediately (leading edge) and the last
11
+ * one within the `wait` window is invoked at its end (trailing edge).
12
+ *
13
+ * ```
14
+ * const update = throttle((value: number) => setValue(value), 250);
15
+ * update(1); // invoked now
16
+ * update(2); // invoked after 250ms
17
+ * update.cancel(); // drops the pending call, e.g. on unmount
18
+ * ```
19
+ * @param fn function to throttle
20
+ * @param wait minimum time in milliseconds between invocations
21
+ * @returns throttled function with `cancel` and `flush` helpers
22
+ */
23
+ export declare const throttle: <TArgs extends unknown[]>(fn: (...args: TArgs) => void, wait?: number) => TThrottled<TArgs>;
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "gd-measurements",
3
3
  "description": "Set of React components to add measurement means to your components for debugging purpose.",
4
- "version": "0.4.2",
4
+ "version": "0.5.0",
5
+ "type": "module",
5
6
  "main": "dist/gd-measurements.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "files": [
8
9
  "dist"
9
10
  ],
11
+ "sideEffects": [
12
+ "**/*.css"
13
+ ],
10
14
  "license": "MIT",
11
15
  "author": {
12
16
  "name": "Łukasz Grela",
@@ -19,8 +23,55 @@
19
23
  "bugs": {
20
24
  "url": "https://github.com/LukaszGrela/gd-measurements/issues"
21
25
  },
26
+ "scripts": {
27
+ "clean-package": "node scripts/clean-package.js",
28
+ "dev": "vite",
29
+ "build": "tsc --p ./tsconfig.lib.json && vite build --config vite.lib.config.ts",
30
+ "build-examples": "vite build --base=/gd-measurements/ --config vite.example.config.ts",
31
+ "lint": "eslint .",
32
+ "test": "vitest run",
33
+ "test:watch": "vitest",
34
+ "test:coverage": "vitest run --coverage",
35
+ "preview": "vite preview",
36
+ "prepack": "npm run build && npm run clean-package",
37
+ "postpack": "git checkout -- package.json && rm -rf package.json.backup",
38
+ "typecheck": "tsc --p ./tsconfig.lib.json && tsc --p ./tsconfig.app.json && tsc --p ./tsconfig.node.json"
39
+ },
40
+ "engines": {
41
+ "node": ">=20"
42
+ },
22
43
  "peerDependencies": {
23
- "lodash": "^4.17.21",
24
44
  "react": "^18.3.1 || ^19.1.1"
45
+ },
46
+ "devDependencies": {
47
+ "@eslint/js": "^9.33.0",
48
+ "@microsoft/api-extractor": "^7.60.1",
49
+ "@testing-library/jest-dom": "^6.7.0",
50
+ "@testing-library/react": "^16.3.0",
51
+ "@testing-library/user-event": "^14.6.1",
52
+ "@types/node": "^24.2.1",
53
+ "@types/react": "^19.1.10",
54
+ "@types/react-dom": "^19.1.7",
55
+ "@vitejs/plugin-react": "^5.0.0",
56
+ "@vitest/coverage-v8": "^5.1.1",
57
+ "@vitest/ui": "^5.1.1",
58
+ "eslint": "^10.7.0",
59
+ "eslint-plugin-react-hooks": "^7.1.1",
60
+ "eslint-plugin-react-refresh": "^0.5.3",
61
+ "globals": "^16.3.0",
62
+ "jsdom": "^26.1.0",
63
+ "react": "^18.3.1",
64
+ "react-dom": "^18.3.1",
65
+ "react-hook-form": "^7.66.1",
66
+ "sass": "^1.90.0",
67
+ "typescript": "~5.8.3",
68
+ "typescript-eslint": "^8.57.0",
69
+ "vite": "^7.1.2",
70
+ "vite-plugin-dts": "^5.0.3",
71
+ "vitest": "^5.1.1"
72
+ },
73
+ "overrides": {
74
+ "fast-uri": "^3.1.9",
75
+ "minimatch": "^11.0.9"
25
76
  }
26
77
  }