use-entity 0.0.1-alpha → 0.1.0-alpha

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/CLAUDE.md DELETED
@@ -1,111 +0,0 @@
1
- ---
2
- description: Use Bun instead of Node.js, npm, pnpm, or vite.
3
- globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
4
- alwaysApply: false
5
- ---
6
-
7
- Default to using Bun instead of Node.js.
8
-
9
- - Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10
- - Use `bun test` instead of `jest` or `vitest`
11
- - Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12
- - Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13
- - Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14
- - Use `bunx <package> <command>` instead of `npx <package> <command>`
15
- - Bun automatically loads .env, so don't use dotenv.
16
-
17
- ## APIs
18
-
19
- - `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
20
- - `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
21
- - `Bun.redis` for Redis. Don't use `ioredis`.
22
- - `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
23
- - `WebSocket` is built-in. Don't use `ws`.
24
- - Prefer `Bun.file` over `node:fs`'s readFile/writeFile
25
- - Bun.$`ls` instead of execa.
26
-
27
- ## Testing
28
-
29
- Use `bun test` to run tests.
30
-
31
- ```ts#index.test.ts
32
- import { test, expect } from "bun:test";
33
-
34
- test("hello world", () => {
35
- expect(1).toBe(1);
36
- });
37
- ```
38
-
39
- ## Frontend
40
-
41
- Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
42
-
43
- Server:
44
-
45
- ```ts#index.ts
46
- import index from "./index.html"
47
-
48
- Bun.serve({
49
- routes: {
50
- "/": index,
51
- "/api/users/:id": {
52
- GET: (req) => {
53
- return new Response(JSON.stringify({ id: req.params.id }));
54
- },
55
- },
56
- },
57
- // optional websocket support
58
- websocket: {
59
- open: (ws) => {
60
- ws.send("Hello, world!");
61
- },
62
- message: (ws, message) => {
63
- ws.send(message);
64
- },
65
- close: (ws) => {
66
- // handle close
67
- }
68
- },
69
- development: {
70
- hmr: true,
71
- console: true,
72
- }
73
- })
74
- ```
75
-
76
- HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
77
-
78
- ```html#index.html
79
- <html>
80
- <body>
81
- <h1>Hello, world!</h1>
82
- <script type="module" src="./frontend.tsx"></script>
83
- </body>
84
- </html>
85
- ```
86
-
87
- With the following `frontend.tsx`:
88
-
89
- ```tsx#frontend.tsx
90
- import React from "react";
91
- import { createRoot } from "react-dom/client";
92
-
93
- // import .css files directly and it works
94
- import './index.css';
95
-
96
- const root = createRoot(document.body);
97
-
98
- export default function Frontend() {
99
- return <h1>Hello, world!</h1>;
100
- }
101
-
102
- root.render(<Frontend />);
103
- ```
104
-
105
- Then, run index.ts
106
-
107
- ```sh
108
- bun --hot ./index.ts
109
- ```
110
-
111
- For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`.
package/biome.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
3
- "vcs": {
4
- "enabled": true,
5
- "clientKind": "git",
6
- "useIgnoreFile": true
7
- },
8
- "files": {
9
- "ignoreUnknown": false
10
- },
11
- "formatter": {
12
- "enabled": true,
13
- "indentStyle": "tab"
14
- },
15
- "linter": {
16
- "enabled": true,
17
- "rules": {
18
- "recommended": true
19
- }
20
- },
21
- "javascript": {
22
- "formatter": {
23
- "quoteStyle": "double"
24
- }
25
- },
26
- "assist": {
27
- "enabled": true,
28
- "actions": {
29
- "source": {
30
- "organizeImports": "on"
31
- }
32
- }
33
- }
34
- }
package/bun.lock DELETED
@@ -1,180 +0,0 @@
1
- {
2
- "lockfileVersion": 1,
3
- "configVersion": 1,
4
- "workspaces": {
5
- "": {
6
- "name": "use-entity",
7
- "devDependencies": {
8
- "@biomejs/biome": "2.3.11",
9
- "@happy-dom/global-registrator": "20.1.0",
10
- "@reduxjs/toolkit": "^2.0.0",
11
- "@tanstack/react-store": "0.8.0",
12
- "@testing-library/dom": "10.4.1",
13
- "@testing-library/jest-dom": "6.9.1",
14
- "@testing-library/react": "16.3.1",
15
- "@types/bun": "latest",
16
- "@types/react": "19.2.8",
17
- "@types/react-dom": "19.2.3",
18
- "lefthook": "2.0.15",
19
- "react": "^19.2.3",
20
- },
21
- "peerDependencies": {
22
- "@reduxjs/toolkit": "^2.0.0",
23
- "@tanstack/react-store": "0.8.0",
24
- "react": ">18.0.0",
25
- "typescript": "^5",
26
- },
27
- },
28
- },
29
- "packages": {
30
- "@adobe/css-tools": ["@adobe/css-tools@4.4.4", "", {}, "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg=="],
31
-
32
- "@babel/code-frame": ["@babel/code-frame@7.28.6", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-JYgintcMjRiCvS8mMECzaEn+m3PfoQiyqukOMCCVQtoJGYJw8j/8LBJEiqkHLkfwCcs74E3pbAUFNg7d9VNJ+Q=="],
33
-
34
- "@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.28.5", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
35
-
36
- "@babel/runtime": ["@babel/runtime@7.28.6", "", {}, "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA=="],
37
-
38
- "@biomejs/biome": ["@biomejs/biome@2.3.11", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.3.11", "@biomejs/cli-darwin-x64": "2.3.11", "@biomejs/cli-linux-arm64": "2.3.11", "@biomejs/cli-linux-arm64-musl": "2.3.11", "@biomejs/cli-linux-x64": "2.3.11", "@biomejs/cli-linux-x64-musl": "2.3.11", "@biomejs/cli-win32-arm64": "2.3.11", "@biomejs/cli-win32-x64": "2.3.11" }, "bin": { "biome": "bin/biome" } }, "sha512-/zt+6qazBWguPG6+eWmiELqO+9jRsMZ/DBU3lfuU2ngtIQYzymocHhKiZRyrbra4aCOoyTg/BmY+6WH5mv9xmQ=="],
39
-
40
- "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.3.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-/uXXkBcPKVQY7rc9Ys2CrlirBJYbpESEDme7RKiBD6MmqR2w3j0+ZZXRIL2xiaNPsIMMNhP1YnA+jRRxoOAFrA=="],
41
-
42
- "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.3.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-fh7nnvbweDPm2xEmFjfmq7zSUiox88plgdHF9OIW4i99WnXrAC3o2P3ag9judoUMv8FCSUnlwJCM1B64nO5Fbg=="],
43
-
44
- "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.3.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-l4xkGa9E7Uc0/05qU2lMYfN1H+fzzkHgaJoy98wO+b/7Gl78srbCRRgwYSW+BTLixTBrM6Ede5NSBwt7rd/i6g=="],
45
-
46
- "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.3.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-XPSQ+XIPZMLaZ6zveQdwNjbX+QdROEd1zPgMwD47zvHV+tCGB88VH+aynyGxAHdzL+Tm/+DtKST5SECs4iwCLg=="],
47
-
48
- "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.3.11", "", { "os": "linux", "cpu": "x64" }, "sha512-/1s9V/H3cSe0r0Mv/Z8JryF5x9ywRxywomqZVLHAoa/uN0eY7F8gEngWKNS5vbbN/BsfpCG5yeBT5ENh50Frxg=="],
49
-
50
- "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.3.11", "", { "os": "linux", "cpu": "x64" }, "sha512-vU7a8wLs5C9yJ4CB8a44r12aXYb8yYgBn+WeyzbMjaCMklzCv1oXr8x+VEyWodgJt9bDmhiaW/I0RHbn7rsNmw=="],
51
-
52
- "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.3.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-PZQ6ElCOnkYapSsysiTy0+fYX+agXPlWugh6+eQ6uPKI3vKAqNp6TnMhoM3oY2NltSB89hz59o8xIfOdyhi9Iw=="],
53
-
54
- "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.3.11", "", { "os": "win32", "cpu": "x64" }, "sha512-43VrG813EW+b5+YbDbz31uUsheX+qFKCpXeY9kfdAx+ww3naKxeVkTD9zLIWxUPfJquANMHrmW3wbe/037G0Qg=="],
55
-
56
- "@happy-dom/global-registrator": ["@happy-dom/global-registrator@20.1.0", "", { "dependencies": { "@types/node": "^20.0.0", "happy-dom": "^20.1.0" } }, "sha512-8c2dSLe7/Rdiq5mAZ8G6hZhx+mp3QzUp1sQD6dmTilLf4bz5X0AAHvBW3AcpcUYGBiTamB4EFuXXtWi5ZVqtRg=="],
57
-
58
- "@reduxjs/toolkit": ["@reduxjs/toolkit@2.11.2", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@standard-schema/utils": "^0.3.0", "immer": "^11.0.0", "redux": "^5.0.1", "redux-thunk": "^3.1.0", "reselect": "^5.1.0" }, "peerDependencies": { "react": "^16.9.0 || ^17.0.0 || ^18 || ^19", "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" }, "optionalPeers": ["react", "react-redux"] }, "sha512-Kd6kAHTA6/nUpp8mySPqj3en3dm0tdMIgbttnQ1xFMVpufoj+ADi8pXLBsd4xzTRHQa7t/Jv8W5UnCuW4kuWMQ=="],
59
-
60
- "@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
61
-
62
- "@standard-schema/utils": ["@standard-schema/utils@0.3.0", "", {}, "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g=="],
63
-
64
- "@tanstack/react-store": ["@tanstack/react-store@0.8.0", "", { "dependencies": { "@tanstack/store": "0.8.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-1vG9beLIuB7q69skxK9r5xiLN3ztzIPfSQSs0GfeqWGO2tGIyInZx0x1COhpx97RKaONSoAb8C3dxacWksm1ow=="],
65
-
66
- "@tanstack/store": ["@tanstack/store@0.8.0", "", {}, "sha512-Om+BO0YfMZe//X2z0uLF2j+75nQga6TpTJgLJQBiq85aOyZNIhkCgleNcud2KQg4k4v9Y9l+Uhru3qWMPGTOzQ=="],
67
-
68
- "@testing-library/dom": ["@testing-library/dom@10.4.1", "", { "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", "@types/aria-query": "^5.0.1", "aria-query": "5.3.0", "dom-accessibility-api": "^0.5.9", "lz-string": "^1.5.0", "picocolors": "1.1.1", "pretty-format": "^27.0.2" } }, "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg=="],
69
-
70
- "@testing-library/jest-dom": ["@testing-library/jest-dom@6.9.1", "", { "dependencies": { "@adobe/css-tools": "^4.4.0", "aria-query": "^5.0.0", "css.escape": "^1.5.1", "dom-accessibility-api": "^0.6.3", "picocolors": "^1.1.1", "redent": "^3.0.0" } }, "sha512-zIcONa+hVtVSSep9UT3jZ5rizo2BsxgyDYU7WFD5eICBE7no3881HGeb/QkGfsJs6JTkY1aQhT7rIPC7e+0nnA=="],
71
-
72
- "@testing-library/react": ["@testing-library/react@16.3.1", "", { "dependencies": { "@babel/runtime": "^7.12.5" }, "peerDependencies": { "@testing-library/dom": "^10.0.0", "@types/react": "^18.0.0 || ^19.0.0", "@types/react-dom": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-gr4KtAWqIOQoucWYD/f6ki+j5chXfcPc74Col/6poTyqTmn7zRmodWahWRCp8tYd+GMqBonw6hstNzqjbs6gjw=="],
73
-
74
- "@types/aria-query": ["@types/aria-query@5.0.4", "", {}, "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw=="],
75
-
76
- "@types/bun": ["@types/bun@1.3.6", "", { "dependencies": { "bun-types": "1.3.6" } }, "sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA=="],
77
-
78
- "@types/node": ["@types/node@20.19.29", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-YrT9ArrGaHForBaCNwFjoqJWmn8G1Pr7+BH/vwyLHciA9qT/wSiuOhxGCT50JA5xLvFBd6PIiGkE3afxcPE1nw=="],
79
-
80
- "@types/react": ["@types/react@19.2.8", "", { "dependencies": { "csstype": "^3.2.2" } }, "sha512-3MbSL37jEchWZz2p2mjntRZtPt837ij10ApxKfgmXCTuHWagYg7iA5bqPw6C8BMPfwidlvfPI/fxOc42HLhcyg=="],
81
-
82
- "@types/react-dom": ["@types/react-dom@19.2.3", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ=="],
83
-
84
- "@types/whatwg-mimetype": ["@types/whatwg-mimetype@3.0.2", "", {}, "sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA=="],
85
-
86
- "@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
87
-
88
- "ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
89
-
90
- "ansi-styles": ["ansi-styles@5.2.0", "", {}, "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA=="],
91
-
92
- "aria-query": ["aria-query@5.3.0", "", { "dependencies": { "dequal": "^2.0.3" } }, "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A=="],
93
-
94
- "bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="],
95
-
96
- "css.escape": ["css.escape@1.5.1", "", {}, "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg=="],
97
-
98
- "csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
99
-
100
- "dequal": ["dequal@2.0.3", "", {}, "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="],
101
-
102
- "dom-accessibility-api": ["dom-accessibility-api@0.5.16", "", {}, "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg=="],
103
-
104
- "happy-dom": ["happy-dom@20.1.0", "", { "dependencies": { "@types/node": "^20.0.0", "@types/whatwg-mimetype": "^3.0.2", "@types/ws": "^8.18.1", "whatwg-mimetype": "^3.0.0", "ws": "^8.18.3" } }, "sha512-ebvqjBqzenBk2LjzNEAzoj7yhw7rW/R2/wVevMu6Mrq3MXtcI/RUz4+ozpcOcqVLEWPqLfg2v9EAU7fFXZUUJw=="],
105
-
106
- "immer": ["immer@11.1.3", "", {}, "sha512-6jQTc5z0KJFtr1UgFpIL3N9XSC3saRaI9PwWtzM2pSqkNGtiNkYY2OSwkOGDK2XcTRcLb1pi/aNkKZz0nxVH4Q=="],
107
-
108
- "indent-string": ["indent-string@4.0.0", "", {}, "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg=="],
109
-
110
- "js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
111
-
112
- "lefthook": ["lefthook@2.0.15", "", { "optionalDependencies": { "lefthook-darwin-arm64": "2.0.15", "lefthook-darwin-x64": "2.0.15", "lefthook-freebsd-arm64": "2.0.15", "lefthook-freebsd-x64": "2.0.15", "lefthook-linux-arm64": "2.0.15", "lefthook-linux-x64": "2.0.15", "lefthook-openbsd-arm64": "2.0.15", "lefthook-openbsd-x64": "2.0.15", "lefthook-windows-arm64": "2.0.15", "lefthook-windows-x64": "2.0.15" }, "bin": { "lefthook": "bin/index.js" } }, "sha512-sl5rePO6UUOLKp6Ci+MMKOc86zicBaPUCvSw2Cq4gCAgTmxpxhIjhz7LOu2ObYerVRPpTq3gvzPTjI71UotjnA=="],
113
-
114
- "lefthook-darwin-arm64": ["lefthook-darwin-arm64@2.0.15", "", { "os": "darwin", "cpu": "arm64" }, "sha512-ygAqG/NzOgY9bEiqeQtiOmCRTtp9AmOd3eyrpEaSrRB9V9f3RHRgWDrWbde9BiHSsCzcbeY9/X2NuKZ69eUsNA=="],
115
-
116
- "lefthook-darwin-x64": ["lefthook-darwin-x64@2.0.15", "", { "os": "darwin", "cpu": "x64" }, "sha512-3wA30CzdSL5MFKD6dk7v8BMq7ScWQivpLbmIn3Pv67AaBavN57N/hcdGqOFnDDFI5WazVwDY7UqDfMIk5HZjEA=="],
117
-
118
- "lefthook-freebsd-arm64": ["lefthook-freebsd-arm64@2.0.15", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-FbYBBLVbX8BjdO+icN1t/pC3TOW3FAvTKv/zggBKNihv6jHNn/3s/0j2xIS0k0Pw9oOE7MVmEni3qp2j5vqHrQ=="],
119
-
120
- "lefthook-freebsd-x64": ["lefthook-freebsd-x64@2.0.15", "", { "os": "freebsd", "cpu": "x64" }, "sha512-udHMjh1E8TfC0Z7Y249XZMATJOyj1Jxlj9JoEinkoBvAsePFKDEQg5teuXuTGhjsHYpqVekfSvLNNfHKUUbbjw=="],
121
-
122
- "lefthook-linux-arm64": ["lefthook-linux-arm64@2.0.15", "", { "os": "linux", "cpu": "arm64" }, "sha512-1HAPmdYhfcOlubv63sTnWtW2rFuC+kT1MvC3JvdrS5V6zrOImbBSnYZMJX/Dd3w4pm0x2ZJb9T+uef8a0jUQkg=="],
123
-
124
- "lefthook-linux-x64": ["lefthook-linux-x64@2.0.15", "", { "os": "linux", "cpu": "x64" }, "sha512-Pho87mlNFH47zc4fPKzQSp8q9sWfIFW/KMMZfx/HZNmX25aUUTOqMyRwaXxtdAo/hNJ9FX4JeuZWq9Y3iyM5VA=="],
125
-
126
- "lefthook-openbsd-arm64": ["lefthook-openbsd-arm64@2.0.15", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-pet03Edlj1QeFUgxcIK1xu8CeZA+ejYplvPgdfe//69+vQFGSDaEx3H2mVx8RqzWfmMbijM2/WfkZXR2EVw3bw=="],
127
-
128
- "lefthook-openbsd-x64": ["lefthook-openbsd-x64@2.0.15", "", { "os": "openbsd", "cpu": "x64" }, "sha512-i+a364CcSAeIO5wQzLMHsthHt/v6n3XwhKmRq/VBzPOUv9KutNeF55yCE/6lvuvzwxpdEfBjh6cXPERC0yp98w=="],
129
-
130
- "lefthook-windows-arm64": ["lefthook-windows-arm64@2.0.15", "", { "os": "win32", "cpu": "arm64" }, "sha512-69u5GdVOT4QIxc2TK5ce0cTXLzwB55Pk9ZnnJNFf1XsyZTGcg9bUWYYTyD12CIIXbVTa0RVXIIrbU9UgP8O1AQ=="],
131
-
132
- "lefthook-windows-x64": ["lefthook-windows-x64@2.0.15", "", { "os": "win32", "cpu": "x64" }, "sha512-/zYEndCUgj8XK+4wvLYLRk3AcfKU6zWf2GHx+tcZ4K2bLaQdej4m+OqmQsVpUlF8N2tN9hfwlj1D50uz75LUuQ=="],
133
-
134
- "lz-string": ["lz-string@1.5.0", "", { "bin": { "lz-string": "bin/bin.js" } }, "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ=="],
135
-
136
- "min-indent": ["min-indent@1.0.1", "", {}, "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg=="],
137
-
138
- "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
139
-
140
- "pretty-format": ["pretty-format@27.5.1", "", { "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "react-is": "^17.0.1" } }, "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ=="],
141
-
142
- "react": ["react@19.2.3", "", {}, "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA=="],
143
-
144
- "react-dom": ["react-dom@19.2.3", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.3" } }, "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg=="],
145
-
146
- "react-is": ["react-is@17.0.2", "", {}, "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="],
147
-
148
- "redent": ["redent@3.0.0", "", { "dependencies": { "indent-string": "^4.0.0", "strip-indent": "^3.0.0" } }, "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg=="],
149
-
150
- "redux": ["redux@5.0.1", "", {}, "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w=="],
151
-
152
- "redux-thunk": ["redux-thunk@3.1.0", "", { "peerDependencies": { "redux": "^5.0.0" } }, "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw=="],
153
-
154
- "reselect": ["reselect@5.1.1", "", {}, "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w=="],
155
-
156
- "scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
157
-
158
- "strip-indent": ["strip-indent@3.0.0", "", { "dependencies": { "min-indent": "^1.0.0" } }, "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ=="],
159
-
160
- "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
161
-
162
- "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
163
-
164
- "use-sync-external-store": ["use-sync-external-store@1.6.0", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w=="],
165
-
166
- "whatwg-mimetype": ["whatwg-mimetype@3.0.0", "", {}, "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q=="],
167
-
168
- "ws": ["ws@8.19.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
169
-
170
- "@testing-library/jest-dom/dom-accessibility-api": ["dom-accessibility-api@0.6.3", "", {}, "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w=="],
171
-
172
- "@types/ws/@types/node": ["@types/node@25.0.8", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg=="],
173
-
174
- "bun-types/@types/node": ["@types/node@25.0.8", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg=="],
175
-
176
- "@types/ws/@types/node/undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
177
-
178
- "bun-types/@types/node/undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
179
- }
180
- }
package/bunfig.toml DELETED
@@ -1,2 +0,0 @@
1
- [test]
2
- preload = ["./happydom.ts", "./testing-library.ts"]
package/happydom.ts DELETED
@@ -1,3 +0,0 @@
1
- import { GlobalRegistrator } from "@happy-dom/global-registrator";
2
-
3
- GlobalRegistrator.register();
package/index.ts DELETED
@@ -1 +0,0 @@
1
- export { createEntityStore } from "./src/useEntity.ts";
package/lefthook.yml DELETED
@@ -1,5 +0,0 @@
1
- pre-commit:
2
- commands:
3
- check:
4
- glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
5
- run: npx @biomejs/biome check --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files}
package/matchers.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { TestingLibraryMatchers } from "@testing-library/jest-dom/matchers";
2
-
3
- declare module "bun:test" {
4
- interface Matchers<T>
5
- extends TestingLibraryMatchers<typeof expect.stringContaining, T> {}
6
- interface AsymmetricMatchers extends TestingLibraryMatchers {}
7
- }
@@ -1,271 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { act, renderHook } from "@testing-library/react";
3
- import { createEntityStore } from "../useEntity.ts";
4
-
5
- type TestEntity = { id: string; name: string };
6
-
7
- describe("useEntity", () => {
8
- test("exposes selectors for the initial state", () => {
9
- const initial: TestEntity[] = [
10
- { id: "1", name: "Alpha" },
11
- { id: "2", name: "Beta" },
12
- ];
13
- const { useEntity } = createEntityStore<TestEntity>(initial);
14
-
15
- const { result } = renderHook(() => useEntity());
16
-
17
- expect(result.current[0].all).toEqual(initial);
18
- expect(result.current[0].ids).toEqual(["1", "2"]);
19
- expect(result.current[0].byId("2")).toEqual({
20
- id: "2",
21
- name: "Beta",
22
- });
23
- });
24
-
25
- test("supports add and remove operations", () => {
26
- const { useEntity } = createEntityStore<TestEntity>();
27
- const { result } = renderHook(() => useEntity());
28
- const [, actions] = result.current;
29
-
30
- act(() => {
31
- actions.addOne({ id: "1", name: "Alpha" });
32
- actions.addMany([
33
- { id: "2", name: "Beta" },
34
- { id: "3", name: "Gamma" },
35
- ]);
36
- });
37
-
38
- expect(result.current[0].all).toHaveLength(3);
39
- expect([...result.current[0].ids].sort()).toEqual(["1", "2", "3"]);
40
-
41
- act(() => {
42
- actions.removeOne("2");
43
- actions.removeMany(["1", "3"]);
44
- });
45
-
46
- expect(result.current[0].all).toEqual([]);
47
-
48
- act(() => {
49
- actions.addOne({ id: "4", name: "Delta" });
50
- actions.removeAll();
51
- });
52
-
53
- expect(result.current[0].all).toEqual([]);
54
- });
55
-
56
- test("supports update and upsert operations", () => {
57
- const { useEntity } = createEntityStore<TestEntity>([
58
- { id: "1", name: "Alpha" },
59
- ]);
60
- const { result } = renderHook(() => useEntity());
61
- const [, actions] = result.current;
62
-
63
- act(() => {
64
- actions.updateOne({ id: "1", changes: { name: "Alpha+" } });
65
- });
66
-
67
- expect(result.current[0].byId("1")).toEqual({
68
- id: "1",
69
- name: "Alpha+",
70
- });
71
-
72
- act(() => {
73
- actions.upsertOne({ id: "2", name: "Beta" });
74
- actions.updateMany([
75
- { id: "1", changes: { name: "Alpha++" } },
76
- { id: "2", changes: { name: "Beta+" } },
77
- ]);
78
- actions.upsertMany({
79
- "2": { id: "2", name: "Beta++" },
80
- "3": { id: "3", name: "Gamma" },
81
- });
82
- });
83
-
84
- expect(result.current[0].byId("1")).toEqual({
85
- id: "1",
86
- name: "Alpha++",
87
- });
88
- expect(result.current[0].byId("2")).toEqual({
89
- id: "2",
90
- name: "Beta++",
91
- });
92
- expect(result.current[0].byId("3")).toEqual({
93
- id: "3",
94
- name: "Gamma",
95
- });
96
- });
97
-
98
- test("supports set operations and total/entities selectors", () => {
99
- const { useEntity } = createEntityStore<TestEntity>();
100
- const { result } = renderHook(() => useEntity());
101
- const [, actions] = result.current;
102
-
103
- act(() => {
104
- actions.setOne({ id: "1", name: "Alpha" });
105
- actions.setMany([
106
- { id: "2", name: "Beta" },
107
- { id: "3", name: "Gamma" },
108
- ]);
109
- });
110
-
111
- expect(result.current[0].total).toBe(3);
112
- expect(result.current[0].entities).toEqual({
113
- "1": { id: "1", name: "Alpha" },
114
- "2": { id: "2", name: "Beta" },
115
- "3": { id: "3", name: "Gamma" },
116
- });
117
-
118
- act(() => {
119
- actions.setAll([{ id: "4", name: "Delta" }]);
120
- });
121
-
122
- expect(result.current[0].all).toEqual([{ id: "4", name: "Delta" }]);
123
- expect(result.current[0].total).toBe(1);
124
- });
125
-
126
- test("returns undefined for missing entities", () => {
127
- const { useEntity } = createEntityStore<TestEntity>();
128
- const { result } = renderHook(() => useEntity());
129
-
130
- expect(result.current[0].byId("missing")).toBeUndefined();
131
- });
132
-
133
- test("ignores remove/update of missing entities", () => {
134
- const { useEntity } = createEntityStore<TestEntity>([
135
- { id: "1", name: "Alpha" },
136
- ]);
137
- const { result } = renderHook(() => useEntity());
138
- const [, actions] = result.current;
139
-
140
- act(() => {
141
- actions.removeOne("missing");
142
- actions.removeMany(["missing-a", "missing-b"]);
143
- actions.updateOne({ id: "missing", changes: { name: "Nope" } });
144
- actions.updateMany([{ id: "missing-2", changes: { name: "Nope 2" } }]);
145
- });
146
-
147
- expect(result.current[0].all).toEqual([{ id: "1", name: "Alpha" }]);
148
- });
149
-
150
- test("keeps selectors in sync after multiple operations", () => {
151
- const { useEntity } = createEntityStore<TestEntity>();
152
- const { result } = renderHook(() => useEntity());
153
- const [, actions] = result.current;
154
-
155
- act(() => {
156
- actions.addMany([
157
- { id: "1", name: "Alpha" },
158
- { id: "2", name: "Beta" },
159
- ]);
160
- actions.removeOne("1");
161
- actions.upsertOne({ id: "2", name: "Beta+" });
162
- actions.upsertMany({
163
- "3": { id: "3", name: "Gamma" },
164
- "4": { id: "4", name: "Delta" },
165
- });
166
- });
167
-
168
- expect([...result.current[0].ids].sort()).toEqual(["2", "3", "4"]);
169
- expect(result.current[0].byId("2")).toEqual({
170
- id: "2",
171
- name: "Beta+",
172
- });
173
- });
174
-
175
- test("selector full returns the full selector object", () => {
176
- const { useEntity } = createEntityStore<TestEntity>([
177
- { id: "1", name: "Alpha" },
178
- { id: "2", name: "Beta" },
179
- ]);
180
- const { result } = renderHook(() => useEntity("full"));
181
-
182
- expect(result.current[0].all).toEqual([
183
- { id: "1", name: "Alpha" },
184
- { id: "2", name: "Beta" },
185
- ]);
186
- expect(result.current[0].byId("2")).toEqual({ id: "2", name: "Beta" });
187
- });
188
-
189
- test("selector all returns array of entities", () => {
190
- const { useEntity } = createEntityStore<TestEntity>([
191
- { id: "1", name: "Alpha" },
192
- ]);
193
- const { result } = renderHook(() => useEntity("all"));
194
- const [, actions] = result.current;
195
-
196
- expect(result.current[0]).toEqual([{ id: "1", name: "Alpha" }]);
197
-
198
- act(() => {
199
- actions.addOne({ id: "2", name: "Beta" });
200
- });
201
-
202
- expect(result.current[0]).toEqual([
203
- { id: "1", name: "Alpha" },
204
- { id: "2", name: "Beta" },
205
- ]);
206
- });
207
-
208
- test("selector ids returns array of entity ids", () => {
209
- const { useEntity } = createEntityStore<TestEntity>([
210
- { id: "1", name: "Alpha" },
211
- { id: "2", name: "Beta" },
212
- ]);
213
- const { result } = renderHook(() => useEntity("ids"));
214
- const [, actions] = result.current;
215
-
216
- expect([...result.current[0]].sort()).toEqual(["1", "2"]);
217
-
218
- act(() => {
219
- actions.addOne({ id: "3", name: "Gamma" });
220
- });
221
-
222
- expect([...result.current[0]].sort()).toEqual(["1", "2", "3"]);
223
- });
224
-
225
- test("selector entities returns entity map", () => {
226
- const { useEntity } = createEntityStore<TestEntity>([
227
- { id: "1", name: "Alpha" },
228
- ]);
229
- const { result } = renderHook(() => useEntity("entities"));
230
- const [, actions] = result.current;
231
-
232
- expect(result.current[0]).toEqual({
233
- "1": { id: "1", name: "Alpha" },
234
- });
235
-
236
- act(() => {
237
- actions.addOne({ id: "2", name: "Beta" });
238
- });
239
-
240
- expect(result.current[0]).toEqual({
241
- "1": { id: "1", name: "Alpha" },
242
- "2": { id: "2", name: "Beta" },
243
- });
244
- });
245
-
246
- test("selector total returns total entity count", () => {
247
- const { useEntity } = createEntityStore<TestEntity>([
248
- { id: "1", name: "Alpha" },
249
- { id: "2", name: "Beta" },
250
- ]);
251
- const { result } = renderHook(() => useEntity("total"));
252
- const [, actions] = result.current;
253
-
254
- expect(result.current[0]).toBe(2);
255
-
256
- act(() => {
257
- actions.removeOne("1");
258
- });
259
-
260
- expect(result.current[0]).toBe(1);
261
- });
262
-
263
- test("defaults to full selector when no selector is provided", () => {
264
- const { useEntity } = createEntityStore<TestEntity>([
265
- { id: "1", name: "Alpha" },
266
- ]);
267
- const { result } = renderHook(() => useEntity());
268
-
269
- expect(result.current[0].all).toEqual([{ id: "1", name: "Alpha" }]);
270
- });
271
- });