Skip to content

Commit 3cb2880

Browse files
authored
Add Next.js example and fix bugs (#17)
1 parent df488a7 commit 3cb2880

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4618
-85
lines changed

.changeset/config.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
"baseBranch": "main",
1414
"updateInternalDependencies": "patch",
1515
"ignore": [
16+
"classy-store-angular-example",
17+
"classy-store-nextjs-example",
1618
"classy-store-react-example",
17-
"classy-store-vue-example",
18-
"classy-store-svelte-example",
1919
"classy-store-solid-example",
20-
"classy-store-angular-example"
20+
"classy-store-svelte-example",
21+
"classy-store-vue-example"
2122
]
2223
}

.changeset/dry-islands-wink.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+
- ensure paused state update is deferred using queueMicrotask in history utils
6+
- prevent arrow functions bypassing proxy traps, add error isolation for listeners

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Enforced by Biome 2.4.0 (`biome.json` at repo root):
9292

9393
## Key Technical Facts
9494

95+
- **No arrow function methods:** Arrow function properties (`increment = () => {}`) have `this` lexically bound to the raw instance. `.bind()` is a no-op on arrow functions, so the GET trap cannot rebind `this` to the proxy. Mutations inside arrow functions bypass the SET trap entirely — no notifications, no reactivity. Always use prototype methods (`increment() {}`).
9596
- **Batching:** mutations are coalesced via `queueMicrotask`. Multiple synchronous writes (including array `push` which triggers multiple SET traps) produce a single subscriber notification.
9697
- **Internal state:** stored in a `WeakMap<proxy, StoreInternal>` — never on the user's object. Allows GC when a store is dereferenced.
9798
- **Non-proxyable types:** `Date`, `RegExp`, native `Map`, and native `Set` are treated as opaque values (internal slots can't be intercepted by Proxy). Use `reactiveMap()` and `reactiveSet()` for Map/Set semantics. Replace Date instances entirely to trigger updates.

bun.lock

Lines changed: 248 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/nextjs/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

examples/nextjs/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# @codebelt/classy-store Next.js Example
2+
3+
This is a Next.js example project demonstrating the usage of `@codebelt/classy-store` within a monorepo setup.
4+
5+
## Getting Started
6+
7+
First, run the development server:
8+
9+
```bash
10+
bun dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
16+
- Realtime Colors (realtimecolors.com) — great for light/dark pairs
17+
- Coolors (coolors.co) — shareable palette URLs
18+
- Tailwind Color Generator (uicolors.app)
19+
- Radix Colors (radix-ui.com/colors)
20+
- Shadcn Themes (ui.shadcn.com/themes)
21+
- Happy Hues (happyhues.co)
22+
- Color Hunt (colorhunt.co)

examples/nextjs/next.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type {NextConfig} from 'next';
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
reactCompiler: true,
6+
transpilePackages: ['@codebelt/classy-store'],
7+
};
8+
9+
export default nextConfig;

examples/nextjs/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "classy-store-nextjs-example",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "bun --bun next dev",
7+
"build": "bun --bun next build",
8+
"start": "bun --bun next start"
9+
},
10+
"dependencies": {
11+
"@codebelt/classy-store": "workspace:*",
12+
"next": "16.1.6",
13+
"react": "19.2.3",
14+
"react-dom": "19.2.3"
15+
},
16+
"devDependencies": {
17+
"@tailwindcss/postcss": "^4",
18+
"@types/node": "^20",
19+
"@types/react": "^19",
20+
"@types/react-dom": "^19",
21+
"babel-plugin-react-compiler": "1.0.0",
22+
"tailwindcss": "^4",
23+
"typescript": "^5"
24+
},
25+
"ignoreScripts": [
26+
"sharp",
27+
"unrs-resolver"
28+
],
29+
"trustedDependencies": [
30+
"sharp",
31+
"unrs-resolver"
32+
]
33+
}

examples/nextjs/postcss.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const config = {
2+
plugins: {
3+
'@tailwindcss/postcss': {},
4+
},
5+
};
6+
7+
export default config;
25.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)