@window-splitter/state 0.6.0 → 0.6.2

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@window-splitter/state",
4
4
  "sideEffects": false,
5
- "version": "0.6.0",
5
+ "version": "0.6.2",
6
6
  "description": "A state machine for a WAI-ARIA compliant window splitter",
7
7
  "homepage": "https://react-window-splitter-six.vercel.app",
8
8
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@internal/eslint-config": "0.6.0",
31
+ "@internal/eslint-config": "0.6.2",
32
32
  "@testing-library/react": "^16.0.0",
33
33
  "@types/big.js": "^6.2.2",
34
34
  "@vitest/browser": "^3.1.2",
@@ -37,15 +37,14 @@
37
37
  "framer-motion": "^11.3.28",
38
38
  "jsdom": "^24.1.1",
39
39
  "playwright": "^1.46.0",
40
+ "tiny-cookie": "^2.5.1",
40
41
  "tshy": "^3.0.2",
41
42
  "typescript": "^5.5.4",
42
43
  "vitest": "^3.1.2"
43
44
  },
44
45
  "dependencies": {
45
46
  "@react-spring/rafz": "^9.7.4",
46
- "big.js": "^6.2.1",
47
- "tiny-cookie": "^2.5.1",
48
- "tiny-invariant": "^1.3.3"
47
+ "big.js": "^6.2.1"
49
48
  },
50
49
  "tshy": {
51
50
  "exclude": [
@@ -78,5 +77,5 @@
78
77
  "window"
79
78
  ],
80
79
  "types": "./dist/commonjs/index.d.ts",
81
- "gitHead": "ebd20a0c93b75eeb8a219da6f74b89cf3b6aa70c"
80
+ "gitHead": "1cdb19a5abdd3dc65ea441057463e975fd0a8e26"
82
81
  }
package/src/index.ts CHANGED
@@ -1,6 +1,4 @@
1
- import * as Cookies from "tiny-cookie";
2
1
  import { raf } from "@react-spring/rafz";
3
- import invariant from "tiny-invariant";
4
2
  import Big from "big.js";
5
3
 
6
4
  // #region Constants
@@ -382,6 +380,11 @@ export function getCursor(
382
380
  }
383
381
 
384
382
  export function prepareSnapshot(snapshot: GroupMachineContextValue) {
383
+ // convert from old format
384
+ if ("context" in snapshot) {
385
+ snapshot = snapshot.context as GroupMachineContextValue;
386
+ }
387
+
385
388
  if (!("items" in snapshot)) {
386
389
  return;
387
390
  }
@@ -405,6 +408,12 @@ export function prepareSnapshot(snapshot: GroupMachineContextValue) {
405
408
  return snapshot;
406
409
  }
407
410
 
411
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
412
+ function invariant(condition: any, message: string): asserts condition {
413
+ if (condition) return;
414
+ throw new Error(message);
415
+ }
416
+
408
417
  /** Assert that the provided event is one of the accepted types */
409
418
  function isEvent<T extends GroupMachineEvent["type"]>(
410
419
  event: GroupMachineEvent,
@@ -1554,6 +1563,10 @@ function clearLastKnownSize(items: Item[]) {
1554
1563
  return items.map((i) => ({ ...i, lastKnownSize: undefined }));
1555
1564
  }
1556
1565
 
1566
+ function setCookie(name: string, jsonData: unknown) {
1567
+ document.cookie = `${name}=${encodeURIComponent(`${jsonData}`)};path=/;max-age=31536000`;
1568
+ }
1569
+
1557
1570
  // #endregion
1558
1571
 
1559
1572
  // #region Machine
@@ -1728,10 +1741,7 @@ export function groupMachine(
1728
1741
  if (context.autosaveStrategy === "localStorage") {
1729
1742
  localStorage.setItem(context.groupId, data);
1730
1743
  } else {
1731
- Cookies.set(context.groupId, data, {
1732
- path: "/",
1733
- "max-age": 31536000,
1734
- });
1744
+ setCookie(context.groupId, data);
1735
1745
  }
1736
1746
  },
1737
1747
  removeItem: (id: string) => {