# Changelog

## 0.4.1
### Bug fixes:
- Fix relative import URLs (e.g. `dist/core.js`) resolving against CDN instead of page URL — now resolves against `window.location.href` so blob workers can load them correctly
- Gate worker initialization with an `initialized` flag: only the first `{url|code}` payload initializes the worker, all later payloads are treated as execution input
- Fix model type inference for URL-loaded JS: when `code` is present, infer `function` instead of treating `url` as API `post`
- Improve worker payload fallback diagnostics: if `postMessage` fails with File/Blob/binary payloads, throw a descriptive error instead of silently dropping data via JSON fallback
- Move `showdown-katex` and `katex` to runtime `dependencies` so `npx jsee` works without dev installs
- Fix `--fetch` bundling to include `schema.view` and `schema.render` blocks in addition to `schema.model`
- Fix `--fetch` import resolution for local relative JS imports and support object import entries (`{ url, ... }`)
- Fix `--fetch` bundling for bare-relative imports (e.g. `dist/core.js`, `css/app.css`) — use filesystem existence check instead of prefix heuristics, and fix `data-src` key mismatch by keeping raw import paths so `loadFromDOM` finds bundled code at runtime
- Fix CLI output path handling for absolute/relative `--outputs` values and remove duplicate final HTML write
- Fix `download()` method referencing undeclared `env` variable — now correctly uses `this`
- Fix `outputAsync()` referencing undeclared `delay` — now correctly uses `utils.delay`
- Fix CLI social links default case referencing undeclared `s` variable
- Remove dead `title` assignment in CLI `gen` function (already handled in `genHead`)
### Features:
- Allow `progress(null)` to render an indeterminate top progress bar for stream-like tasks where total size is unknown
- Add `cancelCurrentRun()` runtime entrypoint and wire overlay Stop button with proper `click` handling for any active run
- Add worker cooperative cancel signal: `_cmd: 'cancel'` updates worker state and JS model context now exposes `ctx.isCancelled()`
- Add end-to-end `raw` file input mode: schema `inputs[].raw` now passes `File` objects / URL handles instead of loading full text into memory
- Add file input stream mode (`inputs[].stream: true`) that wraps raw file/URL sources into async iterable `ChunkedReader` objects (zero-dep, supports `for await`, `.text()`, `.bytes()`, `.lines()`) in both worker and main-thread execution
- Preserve stream reader metadata (`name`, `size`, `type`) for file/URL sources and keep it available across downstream pipeline stages
- Auto-load file input URL query params on init (no extra Load click required)
- Add CSS-aware imports: `.css` entries in `imports` arrays are injected as `<link rel="stylesheet">` on the main thread and skipped in workers
- Add CLI `--runtime` to control runtime source: supports `auto|local|cdn|inline` modes plus custom URL/path values (e.g. `./node_modules/@jseeio/jsee/dist/jsee.js`)
- Add CLI `--help` flag with usage information and examples
- Add ESLint config matching project style (no semicolons, single quotes, 2-space indent)

## 0.3.8 (2026-02-08)
### Bug fixes:
- Fix `run()` error handling: wrap in try/catch/finally so overlay and running state always reset on failure
- Add `.catch()` to fire-and-forget `run()` callers to prevent unhandled rejections
- Add worker execution timeout (default 30s, configurable via `model.timeout`) to prevent permanently frozen UI
- Fix `indexOf('json')` bug in `initSchema` — condition was inverted, `.json` was never appended
- Fix array type detection in auto-created outputs (`typeof` returns `'object'` for arrays)
- Fix `getName` for `async function` strings and guard against arrow functions crashing
- Fix broken string interpolation and remove leftover `console.log('1')` in utils.js
### Features:
- Add `schema.reactive` option: re-run model on any input change (debounced 300ms). Distinct from `autorun` (first load only) and per-input `reactive` (individual input change)
- Add run-concurrency guard: overlapping reactive/autorun calls are dropped, manual clicks are queued
- Move `getName` to utils.js for testability and reuse
- Add runtime `validateSchema()` checks and fail-fast on critical schema issues (`model`/`view` presence, input shape)
- Replace deprecated `node-sass` with `sass`, update `express`, `csv-parse`, and remove unused `element-plus`
### Testing:
- Add separate Jest config for unit tests (`jest.unit.config.js`, no browser needed)
- Add unit tests for utils.js: `isObject`, `sanitizeName`, `getUrl`, `delay`, `debounce`, `getName`, `getModelFuncJS`, `getModelFuncAPI`, `validateSchema`
- Add `npm run test:unit` script

## 0.3.4 (2024-11-19)
### JSEE:
- [x] Add `columns` parameter to the `inputs`, `outputs` blocks (making it possible to create multi-column layouts, like simple dashboards)
- [x] Add `function` output type (for custom renderers which take a container element as an argument)
- [x] Add `dom-to-image` library for exporting dynamic output blocks to PNG
- [x] Support for inputs to be set with url parameters (e.g. `?input1=1&input2=2`)
### HTML Generator:
- [x] Add `latex` and table output in the markdown renderer
- [x] Cache `import` scripts to avoid multiple loads when `--fetch` is used
- [x] Infer `description` from the markdown and update html `<head>` with it
- [x] Update `social`, `org`, `ga` blocks
- [x] Small layout fixes

## 0.3.1 (2024-04-10)
- [x] Add `download` method to jsee object
- [x] Add `bin` folder with `cmd.js` for easier project building

## 0.2.9 (2023-12-11)
- [x] Add examples
- [x] Add imports
- [x] Add `caller` field to the model input (can be: `run`, `autorun` or a button name)
- [x] Add `title` field (for buttons rn)
- [x] If `display` field is `false` the input is not shown
- [x] If `autorun` is true, then actually autorun the model initially

## 0.2.8 (2021-12-29)
- [x] Fix no input case

## 0.2.7 (2021-12-29)
- [x] Show output when result is `0`
- [x] Updated style for buttons and inputs

## 0.2.6 (2021-12-27)
- [x] Tests
- [x] Load schema from query (loader)
- [x] Reset button appears only after data change
- [x] Default input type (`string`)
- [x] Directly load code when running in a window (not code to text)
- [x] Passing code directly
