Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/absorb-mobile-subpath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-simplikit': patch
---

Absorb `@react-simplikit/mobile` into the `react-simplikit/mobile` subpath. Update imports from `@react-simplikit/mobile` to `react-simplikit/mobile`; the exported APIs are unchanged. The `@react-simplikit/mobile` npm package will be deprecated with a pointer to the new subpath after this release.
4 changes: 2 additions & 2 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

## Project

React hooks/components library. Monorepo: `packages/react-simplikit` + `packages/mobile`.
React hooks/components library. Monorepo with a single package: `packages/react-simplikit` (mobile web utilities under the `react-simplikit/mobile` subpath).

## Architecture

Unidirectional layers: `components → hooks → utils → _internal`
Core and mobile are independent packages. No cross-package dependencies.
Root exports must NOT import from `src/mobile`; `src/mobile` may use core utils and `_internal` (test infrastructure is exempt).

## Code Style

Expand Down
4 changes: 2 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

## Quick Reference

- Monorepo: `packages/react-simplikit` (react-simplikit) + `packages/mobile` (@react-simplikit/mobile)
- Monorepo: `packages/react-simplikit` (react-simplikit), with mobile web utilities under the `react-simplikit/mobile` subpath
- Architecture: `components → hooks → utils → _internal` (unidirectional, no circular imports)
- Core and mobile are independent packages — no cross-package dependencies
- Root exports must NOT import from `src/mobile`; `src/mobile` may use core utils and `_internal` (test infrastructure is exempt)

## Code Style Rules

Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./packages/react-simplikit/coverage/coverage-final.json,./packages/mobile/coverage/coverage-final.json
files: ./packages/react-simplikit/coverage/coverage-final.json

spec-compiled:
name: spec (react compiler compiled)
Expand Down Expand Up @@ -125,6 +125,10 @@ jobs:
- 'packages/*/src/hooks/**/!(*.spec|*.test).tsx'
- 'packages/*/src/utils/**/!(index|*.spec|*.test).ts'
- 'packages/*/src/utils/**/!(*.spec|*.test).tsx'
- 'packages/*/src/mobile/hooks/**/!(index|*.spec|*.test).ts'
- 'packages/*/src/mobile/hooks/**/!(*.spec|*.test).tsx'
- 'packages/*/src/mobile/utils/**/!(index|*.spec|*.test).ts'
- 'packages/*/src/mobile/utils/**/!(*.spec|*.test).tsx'

verify-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -338,15 +342,17 @@ jobs:
HAS_ERROR=0
FOUND=0

for pkg in packages/*/; do
ROOT_INDEX="${pkg}src/index.ts"
# Each scan root is an export barrel plus the impl dirs beneath it.
# src/mobile is a second root: its barrel is the ./mobile subpath entry.
for root in packages/*/src packages/*/src/mobile; do
ROOT_INDEX="$root/index.ts"

if [ ! -f "$ROOT_INDEX" ]; then
continue
fi

for dir in "${IMPL_DIRS[@]}"; do
for impl_dir in ${pkg}src/$dir/*/; do
for impl_dir in $root/$dir/*/; do
if [ ! -d "$impl_dir" ]; then
continue
fi
Expand Down Expand Up @@ -475,17 +481,14 @@ jobs:
run: |
yarn workspaces foreach -Apt --include 'packages/*' run build
CORE_TGZ=$(cd packages/react-simplikit && npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
MOBILE_TGZ=$(cd packages/mobile && npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
echo "CORE_TGZ=$RUNNER_TEMP/$CORE_TGZ" >> "$GITHUB_ENV"
echo "MOBILE_TGZ=$RUNNER_TEMP/$MOBILE_TGZ" >> "$GITHUB_ENV"

- name: Point examples at tarballs
run: |
for example in examples/with-vite examples/with-nextjs; do
jq --arg core "file:$CORE_TGZ" --arg mobile "file:$MOBILE_TGZ" \
jq --arg core "file:$CORE_TGZ" \
'.dependencies |= with_entries(
if .key == "react-simplikit" then .value = $core
elif .key == "@react-simplikit/mobile" then .value = $mobile
else . end)' \
"$example/package.json" > "$example/package.json.tmp"
mv "$example/package.json.tmp" "$example/package.json"
Expand Down
427 changes: 102 additions & 325 deletions .pnp.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .scripts/verify-pack/fixtures/consumer/cjs-consumer.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('node:assert');

const core = require('react-simplikit');
const mobile = require('@react-simplikit/mobile');
const mobile = require('react-simplikit/mobile');

assert.strictEqual(typeof core.useToggle, 'function');
assert.ok(core.ImpressionArea != null);
Expand Down
2 changes: 1 addition & 1 deletion .scripts/verify-pack/fixtures/consumer/esm-consumer.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert';

import { useNetworkStatus } from '@react-simplikit/mobile';
import { useNetworkStatus } from 'react-simplikit/mobile';
import { ImpressionArea, useToggle } from 'react-simplikit';

assert.strictEqual(typeof useToggle, 'function');
Expand Down
2 changes: 1 addition & 1 deletion .scripts/verify-pack/fixtures/consumer/types-consumer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useNetworkStatus } from '@react-simplikit/mobile';
import { useNetworkStatus } from 'react-simplikit/mobile';
import { useToggle } from 'react-simplikit';

type UseToggleReturn = ReturnType<typeof useToggle>;
Expand Down
14 changes: 8 additions & 6 deletions .scripts/verify-pack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ async function main() {
]);
} else {
for (const pkg of TARGET_PACKAGES) {
try {
const bytes = await measureImportCost(pkg.sizeEntry, consumerDir);
console.log(`[${pkg.name}] single-export import cost: ${bytes}B (limit ${pkg.sizeLimitBytes}B)`);
report(pkg.name, 'tree-shaking size gate', checkSizeLimit(bytes, pkg.sizeLimitBytes));
} catch (error) {
report(pkg.name, 'tree-shaking size gate', [describeExecError(error)]);
for (const gate of pkg.sizeGates) {
try {
const bytes = await measureImportCost(gate.entry, consumerDir);
console.log(`[${pkg.name}] ${gate.label} single-export import cost: ${bytes}B (limit ${gate.limitBytes}B)`);
report(pkg.name, `tree-shaking size gate (${gate.label})`, checkSizeLimit(bytes, gate.limitBytes));
} catch (error) {
report(pkg.name, `tree-shaking size gate (${gate.label})`, [describeExecError(error)]);
}
}
}
}
Expand Down
38 changes: 24 additions & 14 deletions .scripts/verify-pack/packages.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
export type TargetPackage = {
name: string;
dir: string;
sizeEntry: string;
export type SizeGate = {
// Names the gate in output: one package can carry several entry points now.
label: string;
entry: string;
// Per-module output means adding hooks never moves this number — only the
// measured export's own code or cross-module leakage does — so the budget can
// stay tight without taxing ordinary feature work. Set relative to the current
// measured size per package, not a shared flat ceiling.
sizeLimitBytes: number;
// measured size per entry, not a shared flat ceiling.
limitBytes: number;
};

export type TargetPackage = {
name: string;
dir: string;
sizeGates: SizeGate[];
};

export const TARGET_PACKAGES: TargetPackage[] = [
{
name: 'react-simplikit',
dir: 'packages/react-simplikit',
sizeEntry: `export { useToggle } from 'react-simplikit';`,
sizeLimitBytes: 256,
},
{
name: '@react-simplikit/mobile',
dir: 'packages/mobile',
sizeEntry: `export { useNetworkStatus } from '@react-simplikit/mobile';`,
sizeLimitBytes: 768,
sizeGates: [
{
label: 'root',
entry: `export { useToggle } from 'react-simplikit';`,
limitBytes: 256,
},
{
label: 'mobile subpath',
entry: `export { useNetworkStatus } from 'react-simplikit/mobile';`,
limitBytes: 768,
},
],
},
];
8 changes: 4 additions & 4 deletions .vitepress/locales.mts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ const routeDefinitions: RouteDefinition[] = [
localizedDestination: ':locale/core/utils/:util.md',
},
{
source: 'packages/mobile/src/hooks/:hook/:hook.md',
source: 'packages/react-simplikit/src/mobile/hooks/:hook/:hook.md',
destination: 'mobile/hooks/:hook.md',
localizedSource: 'packages/mobile/src/hooks/:hook/:locale/:hook.md',
localizedSource: 'packages/react-simplikit/src/mobile/hooks/:hook/:locale/:hook.md',
localizedDestination: ':locale/mobile/hooks/:hook.md',
},
{
source: 'packages/mobile/src/utils/:util/:util.md',
source: 'packages/react-simplikit/src/mobile/utils/:util/:util.md',
destination: 'mobile/utils/:util.md',
localizedSource: 'packages/mobile/src/utils/:util/:locale/:util.md',
localizedSource: 'packages/react-simplikit/src/mobile/utils/:util/:locale/:util.md',
localizedDestination: ':locale/mobile/utils/:util.md',
},
];
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/shared.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import path from 'path';

export const projectRoot = path.resolve(import.meta.dirname, '..');
export const corePackageRoot = path.join(projectRoot, 'packages/react-simplikit/src');
export const mobilePackageRoot = path.join(projectRoot, 'packages/mobile/src');
export const mobilePackageRoot = path.join(projectRoot, 'packages/react-simplikit/src/mobile');
export const docsRoot = path.join(projectRoot, 'docs');
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

## Project Overview

React utility hooks/components library. Monorepo with two packages:
React utility hooks/components library. Single package monorepo:

- `react-simplikit` (`packages/react-simplikit`) — Platform-independent React hooks & components
- `@react-simplikit/mobile` (`packages/mobile`) — Mobile web utilities (viewport, keyboard, layout)
- `react-simplikit/mobile` (`packages/react-simplikit/src/mobile`) — Mobile web utilities (viewport, keyboard, layout) as a subpath export

## Architecture

Expand All @@ -21,7 +21,7 @@ components → hooks → utils → _internal
- Components may use hooks, utils, \_internal
- Hooks may use utils, \_internal
- Utils may use \_internal only
- Core and mobile are independent packages — no cross-package dependencies
- Root exports must NOT import from `src/mobile`; `src/mobile` may use core utils and `_internal` (test infrastructure is exempt)

## File Structure

Expand Down
18 changes: 7 additions & 11 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

## Project Overview

React utility hooks/components library. Monorepo with two packages:
React utility hooks/components library. Single package monorepo:

- `react-simplikit` (`packages/react-simplikit`) — Platform-independent React hooks & components
- `@react-simplikit/mobile` (`packages/mobile`) — Mobile web utilities (viewport, keyboard, layout)
- `react-simplikit` (`packages/react-simplikit`) — Platform-independent React hooks & components at the root export, plus mobile web utilities (viewport, keyboard, layout) under the `react-simplikit/mobile` subpath (`src/mobile`)

## Development Quick Start

Expand All @@ -30,7 +29,7 @@ components → hooks → utils → _internal
- Hooks may use utils, \_internal
- Utils may use \_internal only
- \_internal has no internal dependencies
- Mobile may depend on core; core must NOT depend on mobile
- `src/mobile` may use core utils and `_internal`; root exports must NOT import from `src/mobile` (test infrastructure like `_internal/test-utils` is exempt)

## File Structure Convention

Expand Down Expand Up @@ -183,13 +182,10 @@ yarn changeset publish --tag canary # Requires npm login + OTP

```
packages/
├── core/ # react-simplikit
│ ├── src/ # Source (hooks, components, utils)
│ ├── dist/ # Build output (per-module, mirrors src/)
│ └── package.json
└── mobile/ # @react-simplikit/mobile
├── src/
├── dist/ # Build output (per-module, mirrors src/)
└── react-simplikit/ # react-simplikit
├── src/ # Source (hooks, components, utils)
│ └── mobile/ # Mobile web utilities (react-simplikit/mobile subpath)
├── dist/ # Build output (per-module, mirrors src/)
└── package.json
```

Expand Down
21 changes: 8 additions & 13 deletions README-ja_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

## パッケージ

| パッケージ | 説明 | バージョン |
| --------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | Universal hooks - 純粋な状態/ロジック用フック(プラットフォームに依存しない) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [@react-simplikit/mobile](./packages/mobile) | モバイル Web ユーティリティ(viewport、keyboard、scroll) | [![npm](https://img.shields.io/npm/v/@react-simplikit/mobile.svg)](https://www.npmjs.com/package/@react-simplikit/mobile) |
| パッケージ | 説明 | バージョン |
| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | Universal hooks - 純粋な状態/ロジック用フック、および `react-simplikit/mobile` サブパスのモバイル Web ユーティリティ | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |

> **注記**: `react-simplikit` は現在、Web とモバイル(React Native)の両方で動作する純粋な状態/ロジック用フックのみを提供する Universal Hook Library として維持されています。ブラウザ/プラットフォームに依存するフックは非推奨です。詳しくは [packages/react-simplikit/README-ja_jp.md](./packages/react-simplikit/README-ja_jp.md) を参照してください
> **注記**: `react-simplikit` のルート export は、Web とモバイル(React Native)の両方で動作する純粋な状態/ロジック用フックとして維持されます。モバイル Web ユーティリティ(viewport、keyboard、scroll)は `react-simplikit/mobile` サブパスとして提供され、非推奨となった `@react-simplikit/mobile` パッケージを置き換えます

## 特長

Expand All @@ -26,11 +25,8 @@
## インストール

```bash
# Core utilities
# 1 回のインストールで、ルート export のフックとモバイルサブパスの両方を利用できます
npm install react-simplikit

# Mobile web utilities
npm install @react-simplikit/mobile
```

## クイックスタート
Expand Down Expand Up @@ -64,10 +60,10 @@ function SearchInput() {

デバウンスされた関数は `.cancel()` を提供し、コンポーネントがアンマウントされると保留中の呼び出しは自動的にキャンセルされます。

### @react-simplikit/mobile
### react-simplikit/mobile

```tsx
import { useAvoidKeyboard, useBodyScrollLock } from '@react-simplikit/mobile';
import { useAvoidKeyboard, useBodyScrollLock } from 'react-simplikit/mobile';

function ChatInput() {
const { style } = useAvoidKeyboard();
Expand Down Expand Up @@ -95,8 +91,7 @@ function BodyScrollLock() {

```
packages/
├── core/ # react-simplikit (hooks, components, utils)
└── mobile/ # @react-simplikit/mobile (mobile web utilities)
└── react-simplikit/ # react-simplikit (hooks, components, utils; モバイル Web ユーティリティは src/mobile 配下)
```

## 貢献
Expand Down
21 changes: 8 additions & 13 deletions README-ko_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

## 패키지

| 패키지 | 설명 | 버전 |
| --------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | Universal hooks - 순수 상태/로직 훅 (플랫폼 독립적) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [@react-simplikit/mobile](./packages/mobile) | 모바일 웹 유틸리티 (viewport, keyboard, scroll) | [![npm](https://img.shields.io/npm/v/@react-simplikit/mobile.svg)](https://www.npmjs.com/package/@react-simplikit/mobile) |
| 패키지 | 설명 | 버전 |
| --------------------------------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | Universal hooks - 순수 상태/로직 훅과 `react-simplikit/mobile` 서브패스의 모바일 웹 유틸리티 | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |

> **참고**: `react-simplikit`은 이제 웹과 모바일(React Native)에서 모두 동작하는 순수 상태/로직 훅만을 제공하는 Universal Hook Library로 유지됩니다. 브라우저/플랫폼 종속 훅들은 Deprecated 처리됩니다. 자세한 내용은 [packages/react-simplikit/README-ko_kr.md](./packages/react-simplikit/README-ko_kr.md)를 참고하세요.
> **참고**: `react-simplikit`의 루트 export는 웹과 모바일(React Native)에서 모두 동작하는 순수 상태/로직 훅으로 유지됩니다. 모바일 웹 유틸리티(viewport, keyboard, scroll)는 `react-simplikit/mobile` 서브패스로 제공되며, 기존 `@react-simplikit/mobile` 패키지를 대체합니다.

## 특징

Expand All @@ -26,11 +25,8 @@
## 설치

```bash
# Core utilities
# One install covers both the root hooks and the mobile subpath
npm install react-simplikit

# Mobile web utilities
npm install @react-simplikit/mobile
```

## 빠른 시작
Expand Down Expand Up @@ -64,10 +60,10 @@ function SearchInput() {

디바운스된 함수는 `.cancel()` 메서드를 제공하고, 컴포넌트가 언마운트되면 대기 중인 호출을 자동으로 취소해요.

### @react-simplikit/mobile
### react-simplikit/mobile

```tsx
import { useAvoidKeyboard, useBodyScrollLock } from '@react-simplikit/mobile';
import { useAvoidKeyboard, useBodyScrollLock } from 'react-simplikit/mobile';

function ChatInput() {
const { style } = useAvoidKeyboard();
Expand Down Expand Up @@ -95,8 +91,7 @@ function BodyScrollLock() {

```
packages/
├── core/ # react-simplikit (hooks, components, utils)
└── mobile/ # @react-simplikit/mobile (mobile web utilities)
└── react-simplikit/ # react-simplikit (hooks, components, utils; 모바일 웹 유틸리티는 src/mobile)
```

## 기여하기
Expand Down
Loading
Loading