# NProgress: narrowly scoped indeterminate renderer

Upstream: https://github.com/rstacruz/nprogress

Pinned official release: **v0.2.0**. The release's package.json declares version
0.2.0 and license MIT. Copyright (c) 2013-2014 Rico Sta. Cruz.

Original sources (complete reference snapshots retained alongside the adapter):

- https://raw.githubusercontent.com/rstacruz/nprogress/v0.2.0/nprogress.js
- https://raw.githubusercontent.com/rstacruz/nprogress/v0.2.0/nprogress.css
- https://raw.githubusercontent.com/rstacruz/nprogress/v0.2.0/License.md
- Version metadata: https://raw.githubusercontent.com/rstacruz/nprogress/v0.2.0/package.json

`nprogress.original.js` and `nprogress.original.css` retain the complete upstream
source text, with line endings normalized. They are reference material, **not
loaded or executed by the application**. `LICENSE` retains the upstream MIT
notice. No dependency is installed and no CDN code executes at runtime.

## Actual reuse and changes

`nprogress.mjs` directly extracts and adapts upstream `render`, `remove`,
`isRendered`, `removeElement`, and the bar/peg template. `../../page-progress.css`
adapts the upstream click-through top bar and peg styling. This is a small DOM /
visual subsystem, not a claim to use all of NProgress or to reuse its scheduler.

EssayPilot modifications (2026-10-02):

- ESM factory with injected document and an owned node, rather than a UMD global,
  shared element ID, document busy class or configurable parent.
- Real indeterminate `progressbar` label, no numeric ARIA value and no spinner.
- Navy, two-pixel moving segment; reduced-motion uses a stationary segment.
- **Do not execute** `set/inc/trickle/done/promise/queue`, random percentages,
  original completion transitions, recursive timeouts or legacy CSS prefix
  detection. Page loading has no reliable numerical completion measurement.

The lifecycle/task-count wrapper in `../../page-progress.mjs` is EssayPilot's
implementation. It delays visibility by 180 ms, waits for every overlapping task,
ignores previous-route completions after reset, and removes the element and its
CSS animation immediately on completion/reset/dispose/hidden. Its sole timeout
is cancellable and revision-guarded. There are no rAF, queued animation callbacks
or simulated completion timers. BFCache pagehide suspends display but retains
unfinished tasks; pageshow delays display again only if those tasks remain.
Non-BFCache pagehide disposes the instance.

## Integration

Load `page-progress.css` once, then create one workspace-owned instance:

```js
const pageProgress = mountPageProgress({documentImpl: document, windowImpl: window});

async function navigate() {
  pageProgress.reset(); // Start a new route generation, not for every subtask.
  const complete = pageProgress.begin();
  try {
    await loadActualRouteModuleAndData();
  } finally {
    complete(); // Both success and failure end the loading indicator.
  }
}

// Multiple concurrent begin/finally pairs in the same route are supported.
// complete() is idempotent. It never changes data, selection, history or focus.
// Use reset for identity/route invalidation and dispose at workspace unmount.
```

Use this only around real route work, not sleeps, decorative delays, background
polling, word-search keystrokes or model-scoring percentage estimates. Existing
errors and page-level loading messages remain the source of detailed feedback.
