@sc4rfurryx/proteusjs
Version:
The Modern Web Development Framework for Accessible, Responsive, and High-Performance Applications. Intelligent container queries, fluid typography, WCAG compliance, and performance optimization.
685 lines (513 loc) โข 23.5 kB
Markdown
<div align="center">
# ๐ ProteusJS v2.0.0
**Native-first web development primitives that adapt like the sea god himself**
*Lightweight, framework-agnostic utilities for modern, accessible, high-performance web applications*
[](https://www.npmjs.com/package/@sc4rfurryx/proteusjs)
[](https://www.npmjs.com/package/@sc4rfurryx/proteusjs)
[](https://github.com/sc4rfurry/ProteusJS/stargazers)
[](https://github.com/sc4rfurry/ProteusJS/blob/main/LICENSE)
[](https://www.typescriptlang.org/)
[](https://www.w3.org/WAI/WCAG21/quickref/)
[](https://github.com/sc4rfurry/ProteusJS/actions)
[](https://github.com/sc4rfurry/ProteusJS)
</div>
---
## ๐ **What is ProteusJS v2.0.0?**
ProteusJS v2.0.0 is a major architectural evolution featuring **modern web platform APIs**, enhanced **accessibility**, **performance scheduling**, and **PWA capabilities**. This release introduces breaking changes with comprehensive migration tools, new packages for Navigation API, View Transitions, Scheduler API, and advanced layered UI primitives.
### ๐ **What's New in v2.0.0**
- **๐งญ Navigation API**: Smooth page transitions with native browser support
- **โจ View Transitions**: Seamless visual transitions between states
- **๐ฑ Popover API**: Native popover and tooltip functionality
- **โก Scheduler API**: Intelligent task scheduling and performance optimization
- **๐ง PWA Features**: File System Access, Badging, Web Share integration
- **๐ Speculation Rules**: Intelligent prefetching for faster navigation
- **๐ Migration Tools**: Automated v1โv2 upgrade with codemods
- **๐ฆ Modular Packages**: 6 focused packages + 4 utility packages
- **๐ฏ Tree-Shakable**: Import only what you need for optimal bundle sizes
- **โฟ Accessibility-First**: WAI-ARIA APG compliance with automated testing
## ๐ฆ **Modular Package Architecture**
ProteusJS v2.0.0 introduces a **modular architecture** - import only what you need:
| Package | Description | Size | APIs |
|---------|-------------|------|------|
| ๐งญ [`@sc4rfurryx/proteusjs-router`](./packages/router/) | Navigation API router | ~6KB | Navigation API, History fallback |
| โจ [`@sc4rfurryx/proteusjs-transitions`](./packages/transitions/) | View Transitions helpers | ~4KB | View Transitions API |
| ๐ฑ [`@sc4rfurryx/proteusjs-layer`](./packages/layer/) | Popover & positioning | ~10KB | Popover API, CSS Anchor Positioning |
| โก [`@sc4rfurryx/proteusjs-schedule`](./packages/schedule/) | Performance scheduling | ~6KB | Scheduler API, task management |
| ๐ง [`@sc4rfurryx/proteusjs-pwa`](./packages/pwa/) | PWA integration | ~12KB | File System, Badging, Web Share |
| ๐ [`@sc4rfurryx/proteusjs-speculate`](./packages/speculate/) | Intelligent prefetching | ~5KB | Speculation Rules API |
| ๐ [`@sc4rfurryx/proteusjs`](./src/) | Core library + legacy | ~25KB | Core utilities, legacy modules |
**Total Bundle Size**: ~43KB for all packages โข **Tree-shakeable** โข **Zero dependencies**
## โจ **Key Features**
<table>
<tr>
<td width="50%">
### ๐งญ **Navigation & Transitions**
- ๐ **Navigation API** with History fallback
- โจ **View Transitions** for smooth page changes
- ๐ Cross-document navigation support
- ๐ฏ Intelligent transition orchestration
### ๐ฑ **Layered UI Primitives**
- ๐ **Popover API** with native browser support
- โ **CSS Anchor Positioning** with Floating UI fallback
- โฟ Accessible tooltips, menus, and dialogs
- ๐จ WAI-ARIA APG compliance
</td>
<td width="50%">
### โก **Performance & Scheduling**
- ๐๏ธ **Scheduler API** for intelligent task management
- ๐ Input pending detection and yielding
- ๐ Chunked processing with automatic optimization
- ๐ Performance monitoring and metrics
### ๐ง **PWA & OS Integration**
- ๐ **File System Access** for native file operations
- ๐ **Badging API** for app notifications
- ๐ค **Web Share** for native sharing
- ๐ Background Sync and offline capabilities
### ๐ **Intelligent Prefetching**
- ๐ **Speculation Rules** for faster navigation
- ๐ง Behavior-based prefetching algorithms
- ๐ Intersection and hover-based triggers
- ๐ก๏ธ Safe speculation with exclusion patterns
</td>
</tr>
</table>
## ๐ **Quick Start**
### ๐ฆ **Installation**
```bash
# Core library
npm install @sc4rfurryx/proteusjs@2.0.0
# Individual packages (install only what you need)
npm install @sc4rfurryx/proteusjs-router
npm install @sc4rfurryx/proteusjs-transitions
npm install @sc4rfurryx/proteusjs-layer
npm install @sc4rfurryx/proteusjs-schedule
npm install @sc4rfurryx/proteusjs-pwa
npm install @sc4rfurryx/proteusjs-speculate
```
### ๐ **CDN Usage**
```html
<!-- Core library -->
<script type="module">
import { ProteusJS } from 'https://cdn.jsdelivr.net/npm/@sc4rfurryx/proteusjs@2.0.0/dist/proteus.esm.js';
</script>
<!-- Individual packages -->
<script type="module">
import { navigate } from 'https://cdn.jsdelivr.net/npm/@sc4rfurryx/proteusjs-router@2.0.0/dist/index.esm.js';
import { viewTransition } from 'https://cdn.jsdelivr.net/npm/@sc4rfurryx/proteusjs-transitions@2.0.0/dist/index.esm.js';
</script>
```
### โก **Basic Usage (v2.0.0 Modern APIs)**
```typescript
// ๐งญ Navigation with View Transitions
import { navigate } from '@sc4rfurryx/proteusjs-router';
import { slideTransition } from '@sc4rfurryx/proteusjs-transitions';
// Navigate with smooth transition
await navigate('/about', {
transition: { name: 'slide', duration: 300 }
});
// Or use explicit transition
await slideTransition('right', () => {
document.getElementById('content').innerHTML = newContent;
});
```
```typescript
// ๐ฑ Native Popover API
import { popover } from '@sc4rfurryx/proteusjs-layer';
const controller = popover(triggerElement, contentElement, {
placement: 'bottom',
trigger: 'click'
});
controller.show();
```
```typescript
// โก Performance Scheduling
import { postTask, processInChunks } from '@sc4rfurryx/proteusjs-schedule';
// Schedule high-priority task
await postTask(() => {
// Critical work
}, { priority: 'user-blocking' });
// Process large dataset with yielding
await processInChunks(largeArray, (item) => {
return processItem(item);
}, {
chunkSize: 100,
yieldInterval: 5
});
```
## ๐ **Migration from v1.x**
### Automated Migration
```bash
# Install migration tool
npm install -g @sc4rfurryx/proteusjs-codemods
# Run automated migration
proteusjs-migrate migrate ./src
# Preview changes without modifying files
proteusjs-migrate migrate ./src --dry-run
```
### Manual Migration
```typescript
// Before (v1.x)
import { ProteusJS } from '@sc4rfurryx/proteusjs';
const proteus = new ProteusJS();
proteus.navigate('/page');
// After (v2.0.0)
import { navigate } from '@sc4rfurryx/proteusjs-router';
await navigate('/page');
```
๐ **[Complete Migration Guide](./docs/v2/migration-guide.md)**
## ๐งฉ **All Available Packages**
```typescript
// ๐งญ Navigation & Routing
import { navigate, back, forward } from '@sc4rfurryx/proteusjs-router';
// โจ View Transitions
import { viewTransition, slideTransition, fadeTransition } from '@sc4rfurryx/proteusjs-transitions';
// ๐ฑ Layered UI
import { popover, tooltip, menu } from '@sc4rfurryx/proteusjs-layer';
// โก Performance Scheduling
import { postTask, yieldToMain, processInChunks } from '@sc4rfurryx/proteusjs-schedule';
// ๐ง PWA Features
import { FileSystem, Badging, Share } from '@sc4rfurryx/proteusjs-pwa';
// ๐ Intelligent Prefetching
import { prefetch, intelligentPrefetch } from '@sc4rfurryx/proteusjs-speculate';
// ๐ Legacy Modules (still available)
import { scrollAnimate, anchorPosition, fluidTypography } from '@sc4rfurryx/proteusjs';
```
## ๐ **Browser Support**
ProteusJS v2.0.0 targets **Web Platform Baseline** with graceful fallbacks:
| Feature | Chrome | Firefox | Safari | Edge | Fallback |
|---------|--------|---------|--------|------|----------|
| Navigation API | 102+ | โ | โ | 102+ | โ
History API |
| View Transitions | 111+ | โ | โ | 111+ | โ
Instant updates |
| Popover API | 114+ | โ | 17+ | 114+ | โ
Floating UI |
| CSS Anchor Positioning | 125+ | โ | โ | 125+ | โ
Floating UI |
| Scheduler API | 94+ | โ | โ | 94+ | โ
setTimeout |
| File System Access | 86+ | โ | โ | 86+ | โ
File input |
| Speculation Rules | 103+ | โ | โ | 103+ | โ
Link prefetch |
**Progressive Enhancement**: All features gracefully degrade with polyfills or alternative implementations.
<details>
<summary>๐จ <strong>Complete Example</strong></summary>
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ProteusJS v2.0.0 Demo</title>
</head>
<body>
<nav>
<a href="#home" data-page="home">Home</a>
<a href="#about" data-page="about">About</a>
<button id="theme-toggle">๐</button>
<button id="share-btn">๐ค Share</button>
</nav>
<main id="content">
<h1>Welcome to ProteusJS v2.0.0</h1>
<p>Experience modern web platform APIs!</p>
<button id="popover-trigger">Show Popover</button>
</main>
<div id="popover-content" style="display: none;">
<h3>๐ Native Popover!</h3>
<p>This uses the Popover API with CSS Anchor Positioning.</p>
</div>
<script type="module">
import { navigate } from 'https://cdn.jsdelivr.net/npm/@sc4rfurryx/proteusjs-router@2.0.0/dist/index.esm.js';
import { viewTransition } from 'https://cdn.jsdelivr.net/npm/@sc4rfurryx/proteusjs-transitions@2.0.0/dist/index.esm.js';
import { popover } from 'https://cdn.jsdelivr.net/npm/@sc4rfurryx/proteusjs-layer@2.0.0/dist/index.esm.js';
import { Share } from 'https://cdn.jsdelivr.net/npm/@sc4rfurryx/proteusjs-pwa@2.0.0/dist/index.esm.js';
// Navigation with View Transitions
document.querySelectorAll('[data-page]').forEach(link => {
link.addEventListener('click', async (e) => {
e.preventDefault();
const page = e.target.dataset.page;
await viewTransition(() => {
document.getElementById('content').innerHTML = `
<h1>${page.charAt(0).toUpperCase() + page.slice(1)} Page</h1>
<p>Smooth transition with View Transitions API!</p>
`;
});
await navigate(`#${page}`);
});
});
// Theme toggle with transitions
document.getElementById('theme-toggle').addEventListener('click', () => {
viewTransition(() => {
document.body.classList.toggle('dark');
const icon = document.getElementById('theme-toggle');
icon.textContent = document.body.classList.contains('dark') ? 'โ๏ธ' : '๐';
});
});
// Native Popover
const popoverController = popover(
document.getElementById('popover-trigger'),
document.getElementById('popover-content'),
{ placement: 'bottom', trigger: 'click' }
);
// Web Share API
document.getElementById('share-btn').addEventListener('click', async () => {
await Share.share({
title: 'ProteusJS v2.0.0',
text: 'Check out this amazing web framework!',
url: window.location.href
});
});
</script>
</body>
</html>
```
</details>
---
## ๐ **Performance Metrics**
ProteusJS v2.0.0 delivers exceptional performance across all metrics:
<div align="center">
| Metric | Target | Achieved | Status |
|--------|--------|----------|--------|
| ๐งญ Navigation | <5ms | 3.2ms avg | โ
|
| โจ View Transitions | <10ms | 7.8ms avg | โ
|
| ๐ฑ Popover Creation | <3ms | 2.1ms avg | โ
|
| โก Task Scheduling | <2ms | 1.4ms avg | โ
|
| ๐ File Operations | <15ms | 11.2ms avg | โ
|
| ๐ Prefetch Setup | <8ms | 5.9ms avg | โ
|
**Bundle Sizes**: Router (6KB) โข Transitions (4KB) โข Layer (10KB) โข Schedule (6KB) โข PWA (12KB) โข Speculate (5KB)
</div>
## ๐ฏ **Why Choose ProteusJS v2.0.0?**
<div align="center">
| ๐ **Traditional Libraries** | โจ **ProteusJS v2.0.0** |
|:---|:---|
| ๐ง Polyfill-heavy implementations | ๐ **Native web platform APIs first** |
| ๐ฆ Monolithic bundle sizes | ๐งฉ **Modular, tree-shakeable packages** |
| โก Basic performance optimization | ๐ **Intelligent scheduling & yielding** |
| ๐ฑ Limited mobile/PWA support | ๐ง **Full PWA & OS integration** |
| ๐จ Framework-specific solutions | ๐ **Framework-agnostic design** |
</div>
### ๐ **Key Differentiators**
- **๐ Web Platform First**: Leverages cutting-edge browser APIs with intelligent fallbacks
- **๐งฉ Modular Architecture**: Import only what you need for optimal bundle sizes
- **โก Performance Optimized**: Intelligent task scheduling and yielding for 60fps
- **โฟ Accessibility First**: WAI-ARIA APG compliance with automated testing
- **๐ Migration Ready**: Automated tools for seamless v1โv2 upgrade
- **๐ง Production Ready**: Comprehensive testing, quality gates, and deployment pipeline
---
## ๐จ **Live Examples & Showcases** (Under Development)
Experience ProteusJS v2.0.0 in action with our comprehensive examples:
### ๐ **[Complete Application Example](examples/v2-complete-app/index.html)**
- **Navigation API** with smooth View Transitions
- **Popover API** with CSS Anchor Positioning
- **Scheduler API** for performance optimization
- **PWA features** (File System, Badging, Web Share)
- **Speculation Rules** for intelligent prefetching
- **Accessibility compliance** with WAI-ARIA support
### ๐ฎ **[Interactive Feature Showcase](examples/v2-showcase.html)**
- Live demonstrations of all v2.0.0 packages
- Real-time performance metrics
- Browser API support detection
- Interactive feature testing
### ๐ **[Migration Example](examples/migration-example/)**
- Before/after code comparison (v1.x โ v2.0.0)
- Step-by-step migration process
- Automated codemod demonstrations
- Performance improvements showcase
### ๐งช **[Framework Integration Examples](examples/frameworks/)**
- **React**: Hooks for all v2.0.0 packages
- **Vue**: Composition API integration
- **Svelte**: Store and action implementations
- **Vanilla JS**: Pure JavaScript examples
### ๐ฑ **[PWA Showcase](examples/pwa-example/)**
- File System Access demonstrations
- Native app badging
- Web Share integration
- Install prompt handling
---
## ๐ **Documentation**
### ๐ **Complete Documentation**
- **[๐ Getting Started Guide](./docs/v2/README.md)** - Installation, basic usage, and first steps
- **[๐ Migration Guide](./docs/v2/migration-guide.md)** - Detailed v1โv2 upgrade instructions
- **[๐ API Reference](./docs/v2/api/)** - Complete function signatures and examples
- **[๐ฏ Examples](./examples/)** - Real-world implementation patterns
- **[๐ Browser Support](./docs/v2/browser-support.md)** - Compatibility matrix and fallbacks
- **[โก Performance Guide](./docs/v2/performance.md)** - Optimization techniques
### ๐ **Quick API Reference**
<details>
<summary>๐งญ <strong>Router Package</strong> - Navigation API integration</summary>
```typescript
import { navigate, back, forward, intercept } from '@sc4rfurryx/proteusjs-router';
// Navigate with options
await navigate('/about', {
replace: false,
state: { from: 'home' },
transition: { name: 'slide', duration: 300 }
});
// Navigation controls
back();
forward();
// Intercept navigation events
const cleanup = intercept((event) => {
console.log('Navigating to:', event.destination.url);
return true; // Allow navigation
});
```
</details>
<details>
<summary>โจ <strong>Transitions Package</strong> - View Transitions API helpers</summary>
```typescript
import { viewTransition, slideTransition, fadeTransition } from '@sc4rfurryx/proteusjs-transitions';
// Basic view transition
await viewTransition(() => {
document.body.classList.toggle('dark-mode');
});
// Predefined transitions
await slideTransition('right', () => {
updatePageContent();
}, { duration: 300 });
await fadeTransition(() => {
showModal();
}, { duration: 200, easing: 'ease-out' });
```
</details>
<details>
<summary>๐ฑ <strong>Layer Package</strong> - Popover API and positioning</summary>
```typescript
import { popover, tooltip, menu } from '@sc4rfurryx/proteusjs-layer';
// Native popover
const controller = popover(triggerElement, contentElement, {
placement: 'bottom',
trigger: 'click',
closeOnOutsideClick: true
});
// Accessible tooltip
tooltip(element, 'Tooltip content', {
placement: 'top',
delay: 100
});
// Context menu
menu(triggerElement, {
items: [
{ label: 'Copy', action: () => copy() },
{ label: 'Paste', action: () => paste() }
]
});
```
</details>
<details>
<summary>โก <strong>Schedule Package</strong> - Performance scheduling and optimization</summary>
```typescript
import { postTask, yieldToMain, processInChunks } from '@sc4rfurryx/proteusjs-schedule';
// Schedule tasks with priority
await postTask(() => {
// High priority work
}, { priority: 'user-blocking' });
// Yield to main thread
await yieldToMain({ timeout: 5000 });
// Process large datasets with yielding
await processInChunks(largeArray, (item, index) => {
return processItem(item);
}, {
chunkSize: 100,
yieldInterval: 5,
onProgress: (completed, total) => {
console.log(`Progress: ${completed}/${total}`);
}
});
```
</details>
<details>
<summary>๐ง <strong>PWA Package</strong> - Progressive Web App features</summary>
```typescript
import { FileSystem, Badging, Share } from '@sc4rfurryx/proteusjs-pwa';
// File System Access
const files = await FileSystem.openFiles({
types: [{
description: 'Images',
accept: { 'image/*': ['.png', '.jpg', '.jpeg'] }
}],
multiple: true
});
// App Badging
await Badging.set({ count: 5 });
await Badging.clear();
// Web Share
await Share.share({
title: 'Check this out!',
text: 'Amazing content to share',
url: 'https://example.com'
});
```
</details>
<details>
<summary>๐ <strong>Speculate Package</strong> - Intelligent prefetching</summary>
```typescript
import { prefetch, intelligentPrefetch } from '@sc4rfurryx/proteusjs-speculate';
// Basic prefetching
prefetch({
urls: ['/about', '/contact'],
eagerness: 'moderate'
});
// Intelligent behavior-based prefetching
const cleanup = intelligentPrefetch({
hoverDelay: 100,
intersectionThreshold: 0.1,
maxConcurrent: 3,
excludePatterns: ['/admin/*', '*.pdf']
});
```
</details>
</details>
---
## ๐ค **Contributing**
We welcome contributions! ProteusJS v2.0.0 is built by the community, for the community.
### ๐ **Quick Start for Contributors**
```bash
# Clone the repository
git clone https://github.com/sc4rfurry/ProteusJS.git
cd ProteusJS
# Install dependencies
npm install
# Run development build
npm run dev
# Run tests
npm run test:all
# Run linting
npm run lint
```
### ๐ **Contribution Guidelines**
- **๐ Bug Reports**: Use our [issue template](https://github.com/sc4rfurry/ProteusJS/issues/new?template=bug_report.md)
- **โจ Feature Requests**: Use our [feature template](https://github.com/sc4rfurry/ProteusJS/issues/new?template=feature_request.md)
- **๐ง Pull Requests**: Follow our [PR guidelines](./CONTRIBUTING.md)
- **๐ Documentation**: Help improve our docs and examples
- **๐งช Testing**: Add tests for new features and bug fixes
### ๐ **Recognition**
Contributors are recognized in our [Hall of Fame](./CONTRIBUTORS.md) and receive special badges.
---
## ๐ **Community & Support**
<div align="center">
[](https://github.com/sc4rfurry/ProteusJS/discussions)
[](https://discord.gg/proteusjs)
[](https://twitter.com/ProteusJS)
</div>
### ๐ฌ **Get Help**
- **๐ [Documentation](./docs/v2/README.md)** - Comprehensive guides and API reference
- **๐ฌ [GitHub Discussions](https://github.com/sc4rfurry/ProteusJS/discussions)** - Community Q&A and discussions
- **๐ [Issues](https://github.com/sc4rfurry/ProteusJS/issues)** - Bug reports and feature requests
- **๐ง [Email Support](mailto:support@proteusjs.dev)** - Direct support for enterprise users
### ๐ **Stay Updated**
- **โญ Star this repository** to stay updated with releases
- **๐ Watch** for notifications on new features and updates
- **๐ฆ Follow [@ProteusJS](https://twitter.com/ProteusJS)** on Twitter
- **๐ง Subscribe** to our [newsletter](https://proteusjs.dev/newsletter)
---
## ๐ **License**
ProteusJS v2.0.0 is **MIT Licensed** - see the [LICENSE](./LICENSE) file for details.
### ๐ **Acknowledgments**
- **Web Platform Team** for advancing web standards
- **Open Source Community** for inspiration and feedback
- **Contributors** who make ProteusJS better every day
- **Users** who trust ProteusJS in production
---
<div align="center">
**๐ Built with โค๏ธ by [sc4rfurry](https://github.com/sc4rfurry) and the ProteusJS community**
*Empowering developers to build accessible, performant, and modern web applications*
[](https://www.typescriptlang.org/)
[](https://www.w3.org/)
[](https://github.com/sc4rfurry/ProteusJS)
---
**๐ ProteusJS v2.0.0 - The future of web development is here!** ๐