Skip to content

Commit 57eed42

Browse files
committed
docs: update v3.0 features documentation and fix edge.ts type error
1 parent 172d714 commit 57eed42

5 files changed

Lines changed: 69 additions & 3 deletions

File tree

documentation/content/API Reference/Core API Reference/Configuration Options.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ FlowOptions defines the complete configuration surface for Flow. Below are the d
161161
- throttle: number (milliseconds) to throttle execute() calls
162162
- optimisticResult: Static value or function(prevData, args) -> TData to immediately set success state
163163
- rollbackOnError: Boolean to control whether optimistic updates are rolled back on error (default: true)
164+
- dna: FlowDNAOptions for genetic auto-tuning
165+
- ambient: AmbientOptions for environmental intelligence (battery, network, etc.)
166+
- mesh: FlowMeshOptions for cross-tab distributed cache
167+
- autoThrottle: Stress monitoring (rage-click detection)
168+
- ghost: GhostOptions for background task queuing
169+
- purgatory: PurgatoryOptions for enforced undo periods
170+
- edge: EdgeOptions for runtime-aware (Cloudflare/Vercel) execution
164171

165172
Defaults are applied from constants when not provided.
166173

documentation/content/API Reference/Core API Reference/Type Definitions.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ This section documents the primary type definitions and their roles in the Flow
150150
- timeout?: number
151151
- optimisticResult?: TData | ((prevData: TData | null, args: TArgs) => TData)
152152
- rollbackOnError?: boolean
153+
- dna?: FlowDNAOptions
154+
- ambient?: AmbientOptions
155+
- mesh?: FlowMeshOptions
156+
- autoThrottle?: boolean
157+
- ghost?: GhostOptions
158+
- purgatory?: PurgatoryOptions
159+
- edge?: EdgeOptions
153160

154161
- Flow class generics
155162
- Purpose: Orchestrates asynchronous actions and manages UI states.
@@ -230,6 +237,13 @@ class FlowOptions~TData,TError,TArgs[]~ {
230237
+number|nil timeout
231238
+TData|((prevData,args)=>TData)|nil optimisticResult
232239
+boolean|nil rollbackOnError
240+
+FlowDNAOptions|nil dna
241+
+AmbientOptions|nil ambient
242+
+FlowMeshOptions|nil mesh
243+
+boolean|nil autoThrottle
244+
+GhostOptions|nil ghost
245+
+PurgatoryOptions|nil purgatory
246+
+EdgeOptions|nil edge
233247
}
234248
class Flow~TData,TError,TArgs[]~ {
235249
+constructor(action, options?)

documentation/content/Advanced Features/Advanced Features.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
8. [Monitoring and Debugging](#monitoring-and-debugging)
2828
9. [Performance Considerations](#performance-considerations)
2929
10. [Troubleshooting Guide](#troubleshooting-guide)
30-
11. [Conclusion](#conclusion)
31-
12. [Appendices](#appendices)
30+
11. [Next-Gen AI & Mesh Engine](#next-gen-ai--mesh-engine)
31+
12. [Conclusion](#conclusion)
32+
13. [Appendices](#appendices)
3233

3334
## Introduction
3435

@@ -455,6 +456,44 @@ Common issues and remedies:
455456
- [error-utils.ts](file://packages/core/src/error-utils.ts#L130-L143)
456457
- [useFlow.tsx](file://packages/react/src/useFlow.tsx#L227-L234)
457458

459+
## Next-Gen AI & Mesh Engine
460+
461+
AsyncFlowState v3.0 introduces an autonomous, self-optimizing layer that transforms how async state is managed in enterprise applications.
462+
463+
### Flow DNA (Genetic Auto-Tuning)
464+
465+
Flow DNA eliminates manual configuration by allowing flows to evolve their own settings based on production performance.
466+
467+
- **Performance Fingerprinting**: Flows record P95 latency and success/failure ratios.
468+
- **Genetic Evolution**: Periodically, the engine recalculates optimal `timeout`, `retry.delay`, and `staleTime`.
469+
- **Fitness Scoring**: Flows with high reliability and low latency are "rewarded" with tighter timeouts to improve responsiveness.
470+
471+
### Ambient Intelligence
472+
473+
Flows are now aware of the physical environment and device telemetry:
474+
475+
- **Network Awareness**: Automatically switches to compression or defers non-essential syncs on slow (2G/3G) connections.
476+
- **Battery Optimization**: Reduces polling frequency and background activity when the device is in low-power mode.
477+
- **CPU Pressure**: Monitors main-thread lag to determine if a flow should offload its work to a Web Worker.
478+
479+
### Flow Mesh (Cross-Tab Distributed Cache)
480+
481+
Built on the `BroadcastChannel` API, Flow Mesh creates a local P2P network between browser tabs.
482+
483+
- **Leader Election**: Tabs elect a "Leader" to perform network requests. "Followers" subscribe to the leader's results via the mesh.
484+
- **Deduplication**: Prevents the "Thundering Herd" problem where multiple open tabs fetch the same data simultaneously.
485+
- **Mesh Consensus**: Ensures all tabs see the same success/error state instantly.
486+
487+
### Emotional UX (Sentiment Analysis)
488+
489+
The engine monitors user interaction signals to adapt the flow's behavior:
490+
491+
- **Rage Click Detection**: Rapid, repeated clicks trigger a "Purgatory" gate (enforced undo period) to prevent data corruption.
492+
- **Hesitation Tracking**: Long pauses or erratic cursor movement near an action can trigger "Pre-warming" of the flow.
493+
- **Adaptive Throttling**: If a user appears frustrated (based on click frequency), the engine may increase retry delays to avoid further server pressure.
494+
495+
---
496+
458497
## Conclusion
459498

460499
AsyncFlowState’s advanced features—optimistic UI, progress tracking, robust form integration, global configuration, and performance controls—enable consistent, resilient, and user-friendly async interactions. By leveraging the core Flow engine and React helpers, teams can reduce boilerplate, avoid common pitfalls, and scale behavior across applications.

documentation/content/Getting Started.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ The repository is organized as a monorepo with multiple framework packages:
5757
- @asyncflowstate/svelte: Svelte Store reactivity integrations
5858
- @asyncflowstate/angular: Angular `BehaviorSubject` streaming logic
5959
- @asyncflowstate/solid: SolidJS fine-grained primitive mapping
60+
- @asyncflowstate/nuxt: Nuxt 3 native composables
61+
- @asyncflowstate/remix: Remix action & navigation integration
62+
- @asyncflowstate/astro: Astro server action adapters
6063

6164
Key directories and files:
6265

packages/core/src/utils/edge.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ export class EdgeDetector {
6767
}
6868

6969
// Node.js
70-
if (typeof process !== "undefined" && process.versions?.node) {
70+
if (
71+
typeof (globalThis as any).process !== "undefined" &&
72+
(globalThis as any).process.versions?.node
73+
) {
7174
return "node";
7275
}
7376

0 commit comments

Comments
 (0)