@sc4rfurryx/proteusjs 1.0.0 โ 1.1.0
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/LICENSE +1 -1
- package/README.md +331 -77
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/react.d.ts +139 -0
- package/dist/adapters/react.esm.js +848 -0
- package/dist/adapters/react.esm.js.map +1 -0
- package/dist/adapters/svelte.d.ts +181 -0
- package/dist/adapters/svelte.esm.js +908 -0
- package/dist/adapters/svelte.esm.js.map +1 -0
- package/dist/adapters/vue.d.ts +205 -0
- package/dist/adapters/vue.esm.js +872 -0
- package/dist/adapters/vue.esm.js.map +1 -0
- package/dist/modules/a11y-audit.d.ts +39 -0
- package/dist/modules/a11y-audit.esm.js +509 -0
- package/dist/modules/a11y-audit.esm.js.map +1 -0
- package/dist/modules/a11y-primitives.d.ts +69 -0
- package/dist/modules/a11y-primitives.esm.js +445 -0
- package/dist/modules/a11y-primitives.esm.js.map +1 -0
- package/dist/modules/anchor.d.ts +29 -0
- package/dist/modules/anchor.esm.js +218 -0
- package/dist/modules/anchor.esm.js.map +1 -0
- package/dist/modules/container.d.ts +60 -0
- package/dist/modules/container.esm.js +194 -0
- package/dist/modules/container.esm.js.map +1 -0
- package/dist/modules/perf.d.ts +82 -0
- package/dist/modules/perf.esm.js +257 -0
- package/dist/modules/perf.esm.js.map +1 -0
- package/dist/modules/popover.d.ts +33 -0
- package/dist/modules/popover.esm.js +191 -0
- package/dist/modules/popover.esm.js.map +1 -0
- package/dist/modules/scroll.d.ts +43 -0
- package/dist/modules/scroll.esm.js +195 -0
- package/dist/modules/scroll.esm.js.map +1 -0
- package/dist/modules/transitions.d.ts +35 -0
- package/dist/modules/transitions.esm.js +120 -0
- package/dist/modules/transitions.esm.js.map +1 -0
- package/dist/modules/typography.d.ts +72 -0
- package/dist/modules/typography.esm.js +168 -0
- package/dist/modules/typography.esm.js.map +1 -0
- package/dist/proteus.cjs.js +2332 -12
- package/dist/proteus.cjs.js.map +1 -1
- package/dist/proteus.d.ts +561 -12
- package/dist/proteus.esm.js +2323 -12
- package/dist/proteus.esm.js.map +1 -1
- package/dist/proteus.esm.min.js +3 -3
- package/dist/proteus.esm.min.js.map +1 -1
- package/dist/proteus.js +2332 -12
- package/dist/proteus.js.map +1 -1
- package/dist/proteus.min.js +3 -3
- package/dist/proteus.min.js.map +1 -1
- package/package.json +61 -4
- package/src/adapters/react.ts +264 -0
- package/src/adapters/svelte.ts +321 -0
- package/src/adapters/vue.ts +268 -0
- package/src/index.ts +33 -6
- package/src/modules/a11y-audit/index.ts +608 -0
- package/src/modules/a11y-primitives/index.ts +554 -0
- package/src/modules/anchor/index.ts +257 -0
- package/src/modules/container/index.ts +230 -0
- package/src/modules/perf/index.ts +291 -0
- package/src/modules/popover/index.ts +238 -0
- package/src/modules/scroll/index.ts +251 -0
- package/src/modules/transitions/index.ts +145 -0
- package/src/modules/typography/index.ts +239 -0
- package/src/utils/version.ts +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
<div align="center">
|
2
2
|
|
3
|
-
# ๐ ProteusJS
|
3
|
+
# ๐ ProteusJS v1.1.0
|
4
4
|
|
5
|
-
**
|
5
|
+
**Native-first web development primitives that adapt like the sea god himself**
|
6
6
|
|
7
|
-
*
|
7
|
+
*Lightweight, framework-agnostic utilities for modern, accessible, high-performance web applications*
|
8
8
|
|
9
9
|
[](https://www.npmjs.com/package/@sc4rfurryx/proteusjs)
|
10
10
|
[](https://www.npmjs.com/package/@sc4rfurryx/proteusjs)
|
@@ -20,9 +20,18 @@
|
|
20
20
|
|
21
21
|
---
|
22
22
|
|
23
|
-
## ๐ **What is ProteusJS?**
|
23
|
+
## ๐ **What is ProteusJS v1.1.0?**
|
24
24
|
|
25
|
-
ProteusJS is a
|
25
|
+
ProteusJS v1.1.0 is a complete architectural transformation - from a monolithic framework to a collection of **native-first, tree-shakable modules** that wrap modern web platform features with great developer experience. Each module is lightweight (โค6KB gzipped), framework-agnostic, and designed for **performance**, **accessibility**, and **modern web standards**.
|
26
|
+
|
27
|
+
### ๐ **What's New in v1.1.0**
|
28
|
+
|
29
|
+
- **๐งฉ Modular Architecture**: Import only what you need with subpath exports
|
30
|
+
- **๐ Native-First**: Prefer web standards over JavaScript re-implementations
|
31
|
+
- **๐ฏ Tree-Shakable**: Each module is independently optimized
|
32
|
+
- **โก Performance-First**: Built-in Core Web Vitals optimizations
|
33
|
+
- **โฟ Accessibility-First**: WCAG compliance baked in, not bolted on
|
34
|
+
- **๐ง Framework Adapters**: React, Vue, and Svelte integrations
|
26
35
|
|
27
36
|
## โจ **Key Features**
|
28
37
|
|
@@ -80,40 +89,71 @@ pnpm add @sc4rfurryx/proteusjs
|
|
80
89
|
<script src="https://unpkg.com/@sc4rfurryx/proteusjs@latest/dist/proteus.min.js"></script>
|
81
90
|
```
|
82
91
|
|
83
|
-
### โก **Basic Usage**
|
92
|
+
### โก **Basic Usage (v1.1.0 Modular API)**
|
84
93
|
|
85
94
|
```typescript
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
md: '768px',
|
96
|
-
lg: '1024px'
|
97
|
-
}
|
95
|
+
// ๐งฉ Import only what you need (tree-shakable)
|
96
|
+
import { transition, navigate } from '@sc4rfurryx/proteusjs/transitions';
|
97
|
+
import { tether } from '@sc4rfurryx/proteusjs/anchor';
|
98
|
+
import { attach } from '@sc4rfurryx/proteusjs/popover';
|
99
|
+
import { boost } from '@sc4rfurryx/proteusjs/perf';
|
100
|
+
|
101
|
+
// ๐ฌ View Transitions
|
102
|
+
await transition(() => {
|
103
|
+
document.body.classList.toggle('dark-mode');
|
98
104
|
});
|
99
105
|
|
100
|
-
//
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
106
|
+
// โ Anchor Positioning
|
107
|
+
const controller = tether(floatingEl, {
|
108
|
+
anchor: anchorEl,
|
109
|
+
placement: 'bottom',
|
110
|
+
align: 'center'
|
105
111
|
});
|
106
112
|
|
107
|
-
//
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
cognitiveAccessibility: true
|
113
|
+
// ๐ญ Popover/Dialog
|
114
|
+
const popover = attach(triggerEl, panelEl, {
|
115
|
+
type: 'menu',
|
116
|
+
trapFocus: true
|
112
117
|
});
|
118
|
+
|
119
|
+
// โก Performance Boost
|
120
|
+
boost.contentVisibility('.lazy-content');
|
121
|
+
boost.speculate({ prerender: ['/next-page'] });
|
122
|
+
```
|
123
|
+
|
124
|
+
### ๐งฉ **All Available Modules**
|
125
|
+
|
126
|
+
```typescript
|
127
|
+
// ๐ฌ View Transitions API
|
128
|
+
import { transition, navigate } from '@sc4rfurryx/proteusjs/transitions';
|
129
|
+
|
130
|
+
// ๐ Scroll-driven Animations
|
131
|
+
import { scrollAnimate, scrollTimeline } from '@sc4rfurryx/proteusjs/scroll';
|
132
|
+
|
133
|
+
// โ CSS Anchor Positioning
|
134
|
+
import { tether, anchor } from '@sc4rfurryx/proteusjs/anchor';
|
135
|
+
|
136
|
+
// ๐ญ HTML Popover API
|
137
|
+
import { attach, dialog } from '@sc4rfurryx/proteusjs/popover';
|
138
|
+
|
139
|
+
// ๐ฆ Container Queries
|
140
|
+
import { defineContainer, observe } from '@sc4rfurryx/proteusjs/container';
|
141
|
+
|
142
|
+
// ๐ค Fluid Typography
|
143
|
+
import { fluidType, typeScale } from '@sc4rfurryx/proteusjs/typography';
|
144
|
+
|
145
|
+
// ๐ A11y Auditing (dev-only)
|
146
|
+
import { audit } from '@sc4rfurryx/proteusjs/a11y-audit';
|
147
|
+
|
148
|
+
// โฟ A11y Primitives
|
149
|
+
import { dialog, tooltip, combobox, tabs, menu } from '@sc4rfurryx/proteusjs/a11y-primitives';
|
150
|
+
|
151
|
+
// โก Performance Guardrails
|
152
|
+
import { boost } from '@sc4rfurryx/proteusjs/perf';
|
113
153
|
```
|
114
154
|
|
115
155
|
<details>
|
116
|
-
<summary>๐จ <strong>
|
156
|
+
<summary>๐จ <strong>Complete Example</strong></summary>
|
117
157
|
|
118
158
|
```html
|
119
159
|
<!DOCTYPE html>
|
@@ -121,23 +161,41 @@ proteus.enableAccessibility(document.body, {
|
|
121
161
|
<head>
|
122
162
|
<meta charset="UTF-8">
|
123
163
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
124
|
-
<title>ProteusJS Demo</title>
|
164
|
+
<title>ProteusJS v1.1.0 Demo</title>
|
125
165
|
</head>
|
126
166
|
<body>
|
127
|
-
<div class="container">
|
128
|
-
<h1>
|
129
|
-
<p>
|
167
|
+
<div class="hero-container">
|
168
|
+
<h1>Modern Web Development</h1>
|
169
|
+
<p>Native-first, accessible, performant.</p>
|
170
|
+
<button id="theme-toggle">Toggle Theme</button>
|
130
171
|
</div>
|
131
172
|
|
132
173
|
<script type="module">
|
133
|
-
import {
|
174
|
+
import { transition } from '@sc4rfurryx/proteusjs/transitions';
|
175
|
+
import { defineContainer } from '@sc4rfurryx/proteusjs/container';
|
176
|
+
import { fluidType } from '@sc4rfurryx/proteusjs/typography';
|
177
|
+
import { boost } from '@sc4rfurryx/proteusjs/perf';
|
178
|
+
|
179
|
+
// Container queries
|
180
|
+
defineContainer('.hero-container', {
|
181
|
+
name: 'hero',
|
182
|
+
type: 'inline-size'
|
183
|
+
});
|
184
|
+
|
185
|
+
// Fluid typography
|
186
|
+
const { css } = fluidType(1, 2.5, { lineHeight: 1.5 });
|
187
|
+
document.head.insertAdjacentHTML('beforeend', `<style>h1 { ${css} }</style>`);
|
134
188
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
189
|
+
// View transitions
|
190
|
+
document.getElementById('theme-toggle').addEventListener('click', () => {
|
191
|
+
transition(() => {
|
192
|
+
document.body.classList.toggle('dark-theme');
|
193
|
+
});
|
140
194
|
});
|
195
|
+
|
196
|
+
// Performance optimizations
|
197
|
+
boost.contentVisibility('.hero-container');
|
198
|
+
boost.speculate({ prefetch: ['/about', '/contact'] });
|
141
199
|
</script>
|
142
200
|
</body>
|
143
201
|
</html>
|
@@ -210,66 +268,262 @@ Experience ProteusJS in action with our comprehensive real-world examples:
|
|
210
268
|
## ๐ **API Documentation**
|
211
269
|
|
212
270
|
<details>
|
213
|
-
<summary
|
271
|
+
<summary>๐ฌ <strong>Transitions Module</strong></summary>
|
214
272
|
|
215
|
-
### `
|
216
|
-
|
273
|
+
### `transition(callback, options?)`
|
274
|
+
Wraps View Transitions API with fallbacks.
|
217
275
|
|
218
276
|
```typescript
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
}
|
231
|
-
}
|
277
|
+
import { transition, navigate } from '@sc4rfurryx/proteusjs/transitions';
|
278
|
+
|
279
|
+
// Basic transition
|
280
|
+
await transition(() => {
|
281
|
+
document.body.classList.toggle('dark-mode');
|
282
|
+
});
|
283
|
+
|
284
|
+
// Navigation with transition
|
285
|
+
await navigate('/new-page', {
|
286
|
+
fallback: 'fade',
|
287
|
+
duration: 300
|
232
288
|
});
|
233
289
|
```
|
234
290
|
|
235
291
|
</details>
|
236
292
|
|
237
293
|
<details>
|
238
|
-
<summary
|
294
|
+
<summary>โ <strong>Anchor Module</strong></summary>
|
239
295
|
|
240
|
-
### `
|
241
|
-
|
296
|
+
### `tether(floating, options)`
|
297
|
+
CSS Anchor Positioning with JS fallback.
|
242
298
|
|
243
299
|
```typescript
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
300
|
+
import { tether } from '@sc4rfurryx/proteusjs/anchor';
|
301
|
+
|
302
|
+
const controller = tether(floatingEl, {
|
303
|
+
anchor: anchorEl,
|
304
|
+
placement: 'bottom-start',
|
305
|
+
offset: 8,
|
306
|
+
flip: true,
|
307
|
+
shift: true
|
251
308
|
});
|
309
|
+
|
310
|
+
// Cleanup
|
311
|
+
controller.destroy();
|
252
312
|
```
|
253
313
|
|
254
314
|
</details>
|
255
315
|
|
256
316
|
<details>
|
257
|
-
<summary
|
317
|
+
<summary>๐ญ <strong>Popover Module</strong></summary>
|
258
318
|
|
259
|
-
### `
|
260
|
-
|
319
|
+
### `attach(trigger, panel, options)`
|
320
|
+
HTML Popover API with accessibility.
|
261
321
|
|
262
322
|
```typescript
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
323
|
+
import { attach } from '@sc4rfurryx/proteusjs/popover';
|
324
|
+
|
325
|
+
const popover = attach(triggerEl, panelEl, {
|
326
|
+
type: 'menu',
|
327
|
+
trigger: 'click',
|
328
|
+
trapFocus: true,
|
329
|
+
restoreFocus: true,
|
330
|
+
closeOnEscape: true
|
331
|
+
});
|
332
|
+
```
|
333
|
+
|
334
|
+
</details>
|
335
|
+
|
336
|
+
<details>
|
337
|
+
<summary>๐ฆ <strong>Container Module</strong></summary>
|
338
|
+
|
339
|
+
### `defineContainer(selector, options)`
|
340
|
+
Container queries with dev visualization.
|
341
|
+
|
342
|
+
```typescript
|
343
|
+
import { defineContainer } from '@sc4rfurryx/proteusjs/container';
|
344
|
+
|
345
|
+
defineContainer('.sidebar', {
|
346
|
+
name: 'sidebar',
|
347
|
+
type: 'inline-size'
|
348
|
+
});
|
349
|
+
|
350
|
+
// CSS: @container sidebar (min-width: 300px) { ... }
|
351
|
+
```
|
352
|
+
|
353
|
+
</details>
|
354
|
+
|
355
|
+
<details>
|
356
|
+
<summary>๐ค <strong>Typography Module</strong></summary>
|
357
|
+
|
358
|
+
### `fluidType(minRem, maxRem, options?)`
|
359
|
+
Generates CSS clamp() for fluid typography.
|
360
|
+
|
361
|
+
```typescript
|
362
|
+
import { fluidType } from '@sc4rfurryx/proteusjs/typography';
|
363
|
+
|
364
|
+
const { css } = fluidType(1, 2.5, {
|
365
|
+
minViewportPx: 320,
|
366
|
+
maxViewportPx: 1200,
|
367
|
+
lineHeight: 1.5
|
368
|
+
});
|
369
|
+
|
370
|
+
// Returns: font-size: clamp(1rem, 4vw + 0.5rem, 2.5rem); line-height: 1.5;
|
371
|
+
```
|
372
|
+
|
373
|
+
</details>
|
374
|
+
|
375
|
+
<details>
|
376
|
+
<summary>โฟ <strong>A11y Primitives Module</strong></summary>
|
377
|
+
|
378
|
+
### Headless accessibility patterns
|
379
|
+
|
380
|
+
```typescript
|
381
|
+
import { dialog, tooltip, combobox, tabs, menu } from '@sc4rfurryx/proteusjs/a11y-primitives';
|
382
|
+
|
383
|
+
// Modal dialog
|
384
|
+
const dialogController = dialog(dialogEl, {
|
385
|
+
modal: true,
|
386
|
+
trapFocus: true,
|
387
|
+
restoreFocus: true
|
388
|
+
});
|
389
|
+
|
390
|
+
// Accessible tooltip
|
391
|
+
const tooltipController = tooltip(triggerEl, tooltipEl, {
|
392
|
+
delay: 500,
|
393
|
+
placement: 'top'
|
394
|
+
});
|
395
|
+
|
396
|
+
// Keyboard-navigable tabs
|
397
|
+
const tabsController = tabs(tabsContainerEl);
|
398
|
+
```
|
399
|
+
|
400
|
+
</details>
|
401
|
+
|
402
|
+
<details>
|
403
|
+
<summary>โก <strong>Performance Module</strong></summary>
|
404
|
+
|
405
|
+
### `boost` object with performance utilities
|
406
|
+
|
407
|
+
```typescript
|
408
|
+
import { boost } from '@sc4rfurryx/proteusjs/perf';
|
409
|
+
|
410
|
+
// Content visibility optimization
|
411
|
+
boost.contentVisibility('.lazy-section', 'auto', {
|
412
|
+
containIntrinsicSize: '600px 400px'
|
413
|
+
});
|
414
|
+
|
415
|
+
// Resource priority hints
|
416
|
+
boost.fetchPriority('img.hero', 'high');
|
417
|
+
|
418
|
+
// Speculation rules
|
419
|
+
boost.speculate({
|
420
|
+
prerender: ['/pricing'],
|
421
|
+
prefetch: ['/blog'],
|
422
|
+
sameOriginOnly: true
|
423
|
+
});
|
424
|
+
|
425
|
+
// Yield to browser
|
426
|
+
await boost.yieldToBrowser();
|
427
|
+
```
|
428
|
+
|
429
|
+
</details>
|
430
|
+
|
431
|
+
---
|
432
|
+
|
433
|
+
## ๐ง **Framework Adapters**
|
434
|
+
|
435
|
+
<details>
|
436
|
+
<summary>โ๏ธ <strong>React Adapter</strong></summary>
|
437
|
+
|
438
|
+
```typescript
|
439
|
+
import { useTransition, usePopover, useAnchor } from '@sc4rfurryx/proteusjs/adapters/react';
|
440
|
+
|
441
|
+
function MyComponent() {
|
442
|
+
const [isTransitioning, startTransition] = useTransition();
|
443
|
+
|
444
|
+
const { triggerRef, panelRef, isOpen, toggle } = usePopover({
|
445
|
+
type: 'menu',
|
446
|
+
trapFocus: true
|
447
|
+
});
|
448
|
+
|
449
|
+
const { floatingRef, anchorRef } = useAnchor({
|
450
|
+
placement: 'bottom',
|
451
|
+
offset: 8
|
452
|
+
});
|
453
|
+
|
454
|
+
return (
|
455
|
+
<div>
|
456
|
+
<button
|
457
|
+
ref={triggerRef}
|
458
|
+
onClick={() => startTransition(() => toggle())}
|
459
|
+
>
|
460
|
+
Toggle Menu
|
461
|
+
</button>
|
462
|
+
<div ref={panelRef} hidden={!isOpen}>
|
463
|
+
Menu content
|
464
|
+
</div>
|
465
|
+
</div>
|
466
|
+
);
|
467
|
+
}
|
468
|
+
```
|
469
|
+
|
470
|
+
</details>
|
471
|
+
|
472
|
+
<details>
|
473
|
+
<summary>๐ข <strong>Vue Adapter</strong></summary>
|
474
|
+
|
475
|
+
```vue
|
476
|
+
<template>
|
477
|
+
<div>
|
478
|
+
<button @click="startTransition(() => toggle())">
|
479
|
+
Toggle Menu
|
480
|
+
</button>
|
481
|
+
<div v-show="isOpen" ref="panelRef">
|
482
|
+
Menu content
|
483
|
+
</div>
|
484
|
+
</div>
|
485
|
+
</template>
|
486
|
+
|
487
|
+
<script setup>
|
488
|
+
import { useTransition, usePopover } from '@sc4rfurryx/proteusjs/adapters/vue';
|
489
|
+
|
490
|
+
const { isTransitioning, startTransition } = useTransition();
|
491
|
+
const { triggerRef, panelRef, isOpen, toggle } = usePopover({
|
492
|
+
type: 'menu',
|
493
|
+
trapFocus: true
|
272
494
|
});
|
495
|
+
</script>
|
496
|
+
```
|
497
|
+
|
498
|
+
</details>
|
499
|
+
|
500
|
+
<details>
|
501
|
+
<summary>๐งก <strong>Svelte Adapter</strong></summary>
|
502
|
+
|
503
|
+
```svelte
|
504
|
+
<script>
|
505
|
+
import { proteusTransition, proteusPopover } from '@sc4rfurryx/proteusjs/adapters/svelte';
|
506
|
+
|
507
|
+
let isOpen = false;
|
508
|
+
</script>
|
509
|
+
|
510
|
+
<button
|
511
|
+
use:proteusTransition={{
|
512
|
+
callback: () => isOpen = !isOpen
|
513
|
+
}}
|
514
|
+
>
|
515
|
+
Toggle Menu
|
516
|
+
</button>
|
517
|
+
|
518
|
+
<div
|
519
|
+
use:proteusPopover={{
|
520
|
+
type: 'menu',
|
521
|
+
isOpen,
|
522
|
+
trapFocus: true
|
523
|
+
}}
|
524
|
+
>
|
525
|
+
Menu content
|
526
|
+
</div>
|
273
527
|
```
|
274
528
|
|
275
529
|
</details>
|