Skip to content

Commit 4d371f4

Browse files
authored
refactor: restructure internal folder hierarchy and module imports (#1)
* feat: restructure React integration and package exports - Moved `useStore` to a dedicated React-specific entry point (`@codebelt/classy-store/react`). - Updated all internal tests and examples to reflect the new import path. - Adjusted `package.json` exports and added optional `react` peer dependency. - Renamed test files for clarity (`useStore` -> `react`). * refactor: restructure internal folder hierarchy and module imports - Organized `src` into feature-specific subdirectories (e.g., `core`, `react`, `snapshot`, `utils`). - Adjusted all imports to match the new folder structure. - Updated tests and documentation to reflect new paths. - Separated `shallowEqual` and moved it to a dedicated `equality` module with updated tests.
1 parent a59b442 commit 4d371f4

30 files changed

+225
-195
lines changed

.changeset/silent-peas-accept.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@codebelt/classy-store": patch
3+
---
4+
5+
restructure internal folder hierarchy and module imports
6+

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.15/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.0/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

examples/rendering/src/AsyncDemo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useStore} from '@codebelt/classy-store';
1+
import {useStore} from '@codebelt/classy-store/react';
22
import {Panel} from './Panel';
33
import {RenderBadge} from './RenderBadge';
44
import {postStore} from './stores';

examples/rendering/src/CollectionsDemo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useStore} from '@codebelt/classy-store';
1+
import {useStore} from '@codebelt/classy-store/react';
22
import {Panel} from './Panel';
33
import {RenderBadge} from './RenderBadge';
44
import {collectionStore} from './stores';

examples/rendering/src/KitchenSinkPersistDemo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useStore} from '@codebelt/classy-store';
1+
import {useStore} from '@codebelt/classy-store/react';
22
import {useEffect, useState} from 'react';
33
import {Panel} from './Panel';
44
import {kitchenSinkHandle, kitchenSinkStore} from './persistStores';

examples/rendering/src/ReactiveFundamentalsDemo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {store, useStore} from '@codebelt/classy-store';
1+
import {store} from '@codebelt/classy-store';
2+
import {useStore} from '@codebelt/classy-store/react';
23
import {useState} from 'react';
34
import {Panel} from './Panel';
45
import {RenderBadge} from './RenderBadge';

examples/rendering/src/SimplePersistDemo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useStore} from '@codebelt/classy-store';
1+
import {useStore} from '@codebelt/classy-store/react';
22
import {useState} from 'react';
33
import {Panel} from './Panel';
44
import {preferencesHandle, preferencesStore} from './persistStores';

examples/rendering/src/StructuralSharingDemo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {snapshot, subscribe, useStore} from '@codebelt/classy-store';
1+
import {snapshot, subscribe} from '@codebelt/classy-store';
2+
import {useStore} from '@codebelt/classy-store/react';
23
import {useEffect, useRef, useState} from 'react';
34
import {Panel} from './Panel';
45
import {documentStore} from './stores';

package.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codebelt/classy-store",
33
"version": "0.0.1",
4-
"description": "Class-based reactive state management for React — ES6 Proxy + immutable snapshots + useSyncExternalStore",
4+
"description": "Class-based reactive state management — ES6 Proxy + immutable snapshots",
55
"type": "module",
66
"main": "./dist/index.cjs",
77
"module": "./dist/index.mjs",
@@ -17,6 +17,16 @@
1717
"default": "./dist/index.cjs"
1818
}
1919
},
20+
"./react": {
21+
"import": {
22+
"types": "./dist/react/react.d.mts",
23+
"default": "./dist/react/react.mjs"
24+
},
25+
"require": {
26+
"types": "./dist/react/react.d.cts",
27+
"default": "./dist/react/react.cjs"
28+
}
29+
},
2030
"./utils": {
2131
"import": {
2232
"types": "./dist/utils/index.d.mts",
@@ -66,6 +76,11 @@
6676
"peerDependencies": {
6777
"react": ">=18.0.0"
6878
},
79+
"peerDependenciesMeta": {
80+
"react": {
81+
"optional": true
82+
}
83+
},
6984
"devDependencies": {
7085
"@biomejs/biome": "2.4.0",
7186
"@changesets/changelog-github": "0.5.2",
@@ -90,5 +105,6 @@
90105
"react",
91106
"hooks"
92107
],
93-
"license": "MIT"
108+
"license": "MIT",
109+
"sideEffects": false
94110
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {describe, expect, test} from 'bun:test';
2-
import {reactiveMap, reactiveSet, snapshot, store, subscribe} from './index';
2+
import {store, subscribe} from '../core/core';
3+
import {snapshot} from '../snapshot/snapshot';
4+
import {reactiveMap, reactiveSet} from './collections';
35

46
// ── helpers ───────────────────────────────────────────────────────────────────
57

0 commit comments

Comments
 (0)