@window-splitter/state 0.6.0 → 0.6.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/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.1",
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.1",
32
32
  "@testing-library/react": "^16.0.0",
33
33
  "@types/big.js": "^6.2.2",
34
34
  "@vitest/browser": "^3.1.2",
@@ -37,6 +37,7 @@
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"
@@ -44,7 +45,6 @@
44
45
  "dependencies": {
45
46
  "@react-spring/rafz": "^9.7.4",
46
47
  "big.js": "^6.2.1",
47
- "tiny-cookie": "^2.5.1",
48
48
  "tiny-invariant": "^1.3.3"
49
49
  },
50
50
  "tshy": {
@@ -78,5 +78,5 @@
78
78
  "window"
79
79
  ],
80
80
  "types": "./dist/commonjs/index.d.ts",
81
- "gitHead": "ebd20a0c93b75eeb8a219da6f74b89cf3b6aa70c"
81
+ "gitHead": "154109ef49adaa31627c1a62c93fd59bf700e29b"
82
82
  }
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as Cookies from "tiny-cookie";
2
1
  import { raf } from "@react-spring/rafz";
3
2
  import invariant from "tiny-invariant";
4
3
  import Big from "big.js";
@@ -382,6 +381,11 @@ export function getCursor(
382
381
  }
383
382
 
384
383
  export function prepareSnapshot(snapshot: GroupMachineContextValue) {
384
+ // convert from old format
385
+ if ("context" in snapshot) {
386
+ snapshot = snapshot.context as GroupMachineContextValue;
387
+ }
388
+
385
389
  if (!("items" in snapshot)) {
386
390
  return;
387
391
  }
@@ -1554,6 +1558,10 @@ function clearLastKnownSize(items: Item[]) {
1554
1558
  return items.map((i) => ({ ...i, lastKnownSize: undefined }));
1555
1559
  }
1556
1560
 
1561
+ function setCookie(name: string, jsonData: unknown) {
1562
+ document.cookie = `${name}=${encodeURIComponent(`${jsonData}`)};path=/;max-age=31536000`;
1563
+ }
1564
+
1557
1565
  // #endregion
1558
1566
 
1559
1567
  // #region Machine
@@ -1728,10 +1736,7 @@ export function groupMachine(
1728
1736
  if (context.autosaveStrategy === "localStorage") {
1729
1737
  localStorage.setItem(context.groupId, data);
1730
1738
  } else {
1731
- Cookies.set(context.groupId, data, {
1732
- path: "/",
1733
- "max-age": 31536000,
1734
- });
1739
+ setCookie(context.groupId, data);
1735
1740
  }
1736
1741
  },
1737
1742
  removeItem: (id: string) => {