@jseeio/jsee 0.3.7 → 0.3.8
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/.claude/settings.local.json +9 -0
- package/AGENTS.md +37 -0
- package/CHANGELOG.md +71 -0
- package/CLAUDE.md +5 -0
- package/README.md +20 -41
- package/bin/jsee +1 -1
- package/dist/jsee.js +1 -1
- package/dist/jsee.runtime.js +1 -1
- package/jest-puppeteer.config.js +2 -1
- package/jest.unit.config.js +8 -0
- package/load/index.html +9 -4
- package/package.json +15 -13
- package/src/app.js +35 -11
- package/src/cli.js +662 -548
- package/src/main.js +348 -152
- package/src/utils.js +590 -3
- package/src/worker.js +42 -18
- package/templates/bulma-app.vue +3 -2
- package/templates/bulma-input.vue +22 -18
- package/templates/bulma-output.vue +72 -7
- package/templates/common-inputs.js +2 -13
- package/templates/common-outputs.js +57 -2
- package/templates/file-picker-base.vue +169 -0
- package/templates/file-picker.vue +318 -0
- package/test/fixtures/lodash-like.js +15 -0
- package/test/fixtures/upload-sample.csv +3 -0
- package/test/test-basic.test.js +286 -11
- package/test/unit/utils.test.js +519 -0
- package/webpack.config.js +1 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Project briefing for awesome agents
|
|
2
|
+
|
|
3
|
+
You are the most talented and experienced agent in the world, and you have been tasked with leading the development of JSEE, a powerful tool for automating the creation of interactive web applications.
|
|
4
|
+
|
|
5
|
+
## Philosophy
|
|
6
|
+
|
|
7
|
+
JSEE abstracts away the complexities of web development, allowing users to focus on their core logic and data. It provides a simple interface for defining inputs, outputs, and processing logic, and takes care of the rest. By leveraging modern web technologies like Vue.js and Web Workers, JSEE ensures that applications are responsive and efficient.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Style
|
|
11
|
+
|
|
12
|
+
Use **2-space indentation** and **semicolon-free** syntax. Use **single quotes** for strings. Preserve the existing style in the codebase, and avoid introducing new formatting styles or conventions.
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Repo map
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Definition of done
|
|
21
|
+
- Run: `npm run build` (or `npm run build-dev` during iteration)
|
|
22
|
+
- Run unit tests: `npm run test:unit` (fast, no browser needed)
|
|
23
|
+
- Run E2E tests: `npm run test:basic` (requires `http-server -p 8080` running)
|
|
24
|
+
- Add/adjust unit tests for core logic in `test/unit/`
|
|
25
|
+
|
|
26
|
+
## Constraints
|
|
27
|
+
- Don’t add new production dependencies without asking.
|
|
28
|
+
- Update the `README.md`, `CHANGELOG.md` and `index.html` with any user-facing changes or new features.
|
|
29
|
+
- Commit messages should be clear and descriptive, following the format: `feature|fix|test|docs: short description` (e.g., `feature: add new column type classification`). No multiline and EOF!
|
|
30
|
+
- Each change: for non-trivial changes, add comments, update docs (new features that can be used by users should be represented in `README.md` and `CHANGELOG.md`), run tests, commit with a clear message. For trivial changes (e.g., fixing typos), you can skip some steps but still ensure the change is well-documented in the commit message.
|
|
31
|
+
- A lot of apps depend on JSEE, so be mindful of backward compatibility. If a change is breaking, stop and ask for help. If you need to make a breaking change, update the version in `package.json` and clearly document the change in `CHANGELOG.md`.
|
|
32
|
+
- Ask for confirmation before each commit
|
|
33
|
+
|
|
34
|
+
## Conventions
|
|
35
|
+
- Formatting: no formatter is configured; preserve existing style (2-space indentation, semicolon-free, single quotes)
|
|
36
|
+
- Types: plain JavaScript with runtime type checks (`typeof`, `isNaN`) and counters
|
|
37
|
+
- Error handling: prefer tolerant stream processing (skip malformed lines, classify invalid/empty values as `missing`, degrade expensive stats for unsuitable columns instead of hard-failing)
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
### Bug fixes:
|
|
5
|
+
- Gate worker initialization with an `initialized` flag: only the first `{url|code}` payload initializes the worker, all later payloads are treated as execution input
|
|
6
|
+
### Features:
|
|
7
|
+
- Allow `progress(null)` to render an indeterminate top progress bar for stream-like tasks where total size is unknown
|
|
8
|
+
- Add `cancelCurrentRun()` runtime entrypoint and wire overlay Stop button with proper `click` handling for any active run
|
|
9
|
+
- Add worker cooperative cancel signal: `_cmd: 'cancel'` updates worker state and JS model context now exposes `ctx.isCancelled()`
|
|
10
|
+
- Add end-to-end `raw` file input mode: schema `inputs[].raw` now passes `File` objects / URL handles instead of loading full text into memory
|
|
11
|
+
- 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
|
|
12
|
+
|
|
13
|
+
## 0.3.8
|
|
14
|
+
### Bug fixes:
|
|
15
|
+
- Fix `run()` error handling: wrap in try/catch/finally so overlay and running state always reset on failure
|
|
16
|
+
- Add `.catch()` to fire-and-forget `run()` callers to prevent unhandled rejections
|
|
17
|
+
- Add worker execution timeout (default 30s, configurable via `model.timeout`) to prevent permanently frozen UI
|
|
18
|
+
- Fix `indexOf('json')` bug in `initSchema` — condition was inverted, `.json` was never appended
|
|
19
|
+
- Fix array type detection in auto-created outputs (`typeof` returns `'object'` for arrays)
|
|
20
|
+
- Fix `getName` for `async function` strings and guard against arrow functions crashing
|
|
21
|
+
- Fix broken string interpolation and remove leftover `console.log('1')` in utils.js
|
|
22
|
+
### Features:
|
|
23
|
+
- 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)
|
|
24
|
+
- Add run-concurrency guard: overlapping reactive/autorun calls are dropped, manual clicks are queued
|
|
25
|
+
- Move `getName` to utils.js for testability and reuse
|
|
26
|
+
- Add runtime `validateSchema()` checks and fail-fast on critical schema issues (`model`/`view` presence, input shape)
|
|
27
|
+
- Replace deprecated `node-sass` with `sass`, update `express`, `csv-parse`, and remove unused `element-plus`
|
|
28
|
+
### Testing:
|
|
29
|
+
- Add separate Jest config for unit tests (`jest.unit.config.js`, no browser needed)
|
|
30
|
+
- Add unit tests for utils.js: `isObject`, `sanitizeName`, `getUrl`, `delay`, `debounce`, `getName`, `getModelFuncJS`, `getModelFuncAPI`, `validateSchema`
|
|
31
|
+
- Add `npm run test:unit` script
|
|
32
|
+
|
|
33
|
+
## 0.3.4
|
|
34
|
+
### JSEE:
|
|
35
|
+
- [x] Add `columns` parameter to the `inputs`, `outputs` blocks (making it possible to create multi-column layouts, like simple dashboards)
|
|
36
|
+
- [x] Add `function` output type (for custom renderers which take a container element as an argument)
|
|
37
|
+
- [x] Add `dom-to-image` library for exporting dynamic output blocks to PNG
|
|
38
|
+
- [x] Support for inputs to be set with url parameters (e.g. `?input1=1&input2=2`)
|
|
39
|
+
### HTML Generator:
|
|
40
|
+
- [x] Add `latex` and table output in the markdown renderer
|
|
41
|
+
- [x] Cache `import` scripts to avoid multiple loads when `--fetch` is used
|
|
42
|
+
- [x] Infer `description` from the markdown and update html `<head>` with it
|
|
43
|
+
- [x] Update `social`, `org`, `ga` blocks
|
|
44
|
+
- [x] Small layout fixes
|
|
45
|
+
|
|
46
|
+
## 0.3.1
|
|
47
|
+
- [x] Add `download` method to jsee object
|
|
48
|
+
- [x] Add `bin` folder with `cmd.js` for easier project building
|
|
49
|
+
|
|
50
|
+
## 0.2.9
|
|
51
|
+
- [x] Add examples
|
|
52
|
+
- [x] Add imports
|
|
53
|
+
- [x] Add `caller` field to the model input (can be: `run`, `autorun` or a button name)
|
|
54
|
+
- [x] Add `title` field (for buttons rn)
|
|
55
|
+
- [x] If `display` field is `false` the input is not shown
|
|
56
|
+
- [x] If `autorun` is true, then actually autorun the model initially
|
|
57
|
+
|
|
58
|
+
## 0.2.8
|
|
59
|
+
- [x] Fix no input case
|
|
60
|
+
|
|
61
|
+
## 0.2.7
|
|
62
|
+
- [x] Show output when result is `0`
|
|
63
|
+
- [x] Updated style for buttons and inputs
|
|
64
|
+
|
|
65
|
+
## 0.2.6
|
|
66
|
+
- [x] Tests
|
|
67
|
+
- [x] Load schema from query (loader)
|
|
68
|
+
- [x] Reset button appears only after data change
|
|
69
|
+
- [x] Default input type (`string`)
|
|
70
|
+
- [x] Directly load code when running in a window (not code to text)
|
|
71
|
+
- [x] Passing code directly
|
package/CLAUDE.md
ADDED
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# JSEE
|
|
2
2
|
|
|
3
3
|
Minimal example:
|
|
4
4
|
```html
|
|
@@ -93,6 +93,10 @@ Extra blocks can be provided for further customization
|
|
|
93
93
|
- `object` (default) - Pass inputs wrapped in an object, i.e. `{'x': 1, 'y': 2}`
|
|
94
94
|
- `args` - Pass inputs as separate arguments
|
|
95
95
|
- `worker` (boolean) - If `true`, JSEE initializes a Web Worker to run the script
|
|
96
|
+
- For `container: 'object'`, model functions receive a second runtime context argument (`ctx`)
|
|
97
|
+
- `ctx.log(...args)` - Write runtime logs
|
|
98
|
+
- `ctx.progress(value)` - Report progress (`0..100` or `null` for indeterminate)
|
|
99
|
+
- `ctx.isCancelled()` - Check cooperative cancellation state (useful in long loops/streams)
|
|
96
100
|
- `render` - Custom rendering script. Instead of relying on JSEE for output visualization, you can provide a custom script that visualizes the results. That can be useful if you rely on custom libs for plotting.
|
|
97
101
|
- `design` - Design parameters
|
|
98
102
|
- `layout` - Layout for the model/input/output blocks. If it's empty and the JSEE container is not, JSEE uses inner HTML as a template. If the container is empty too, it uses the default `blocks` template.
|
|
@@ -108,57 +112,32 @@ Extra blocks can be provided for further customization
|
|
|
108
112
|
- `file` - File Input
|
|
109
113
|
- `action` or `button` - Button (its `name` will be passed as a `caller` to the model)
|
|
110
114
|
- `default` - Default value
|
|
115
|
+
- `raw` (boolean, file input only) - If `true`, pass the raw source to the model instead of reading text in the UI (`File` object for disk files or `{ kind: 'url', url: '...' }` for URL input)
|
|
116
|
+
- `stream` (boolean, file input only) - If `true`, pass an async iterable `ChunkedReader` to the model instead of raw source handles. Supports `for await (const chunk of reader)`, `await reader.text()`, `await reader.bytes()`, and `for await (const line of reader.lines())`. Works in both main-thread and worker execution.
|
|
111
117
|
- `outputs` - Outputs definition
|
|
112
118
|
- `name`* - Name of the output
|
|
113
119
|
- `type`* - Type. Possible types:
|
|
120
|
+
- `file` - File output (not displayer, but downloaded)
|
|
114
121
|
- `object` - JavaScript Object
|
|
115
122
|
- `html` or `svg` - SVG element
|
|
116
123
|
- `code` - Code block
|
|
117
124
|
- `function` - Render function. Rather than returning a value, a model returns a function that JSEE will call passing the container element.
|
|
125
|
+
- `blank` - Blank block (can be alternative to `function` and useful for custom renderers)
|
|
118
126
|
- `examples` - List of examples
|
|
119
|
-
- `autorun` (boolean, default: `false`) -
|
|
127
|
+
- `autorun` (boolean, default: `false`) - Run the model automatically on first load
|
|
128
|
+
- `reactive` (boolean, default: `false`) - Re-run the model on any input change (debounced). For per-input reactivity, set `reactive: true` on individual inputs instead
|
|
120
129
|
- `interval` (number, default: `0`) - Defines the interval between script evaluations (in milliseconds). If set to `0`, the script is evaluated only once.
|
|
130
|
+
- Runtime cancellation: call `jsee.cancelCurrentRun()` on the JSEE instance to request stop of the active run. Long-running models should check `ctx.isCancelled()` and return early.
|
|
131
|
+
- Schema validation - JSEE validates schema structure during initialization and logs warnings for non-critical issues (e.g. unknown input types, malformed aliases)
|
|
121
132
|
|
|
122
133
|
JSEE is a reactive branch of [StatSim](https://statsim.com)'s [Port](https://github.com/statsim/port). It's still work in progress. Expect API changes.
|
|
123
134
|
|
|
135
|
+
# CLI
|
|
136
|
+
- `--fetch` - Fetches JSEE code, models and their imports and generates a bundled HTML file
|
|
137
|
+
- `--cdn` - Use CDN for models (can be string with a base URL or boolean to infer from package.json). Model urls will be prefixed with the CDN URL. This helps with deployment to static hosts (e.g. GitHub Pages).
|
|
138
|
+
- `--execute` - Executes the model code on the server-side.
|
|
139
|
+
# Server-side execution
|
|
140
|
+
|
|
124
141
|
# Changelog
|
|
125
142
|
|
|
126
|
-
|
|
127
|
-
### JSEE:
|
|
128
|
-
- [x] Add `columns` parameter to the `inputs`, `outputs` blocks (making it possible to create multi-column layouts, like simple dashboards)
|
|
129
|
-
- [x] Add `function` output type (for custom renderers which take a container element as an argument)
|
|
130
|
-
- [x] Add `dom-to-image` library for exporting dynamic output blocks to PNG
|
|
131
|
-
- [x] Support for inputs to be set with url parameters (e.g. `?input1=1&input2=2`)
|
|
132
|
-
### HTML Generator:
|
|
133
|
-
- [x] Add `latex` and table output in the markdown renderer
|
|
134
|
-
- [x] Cache `import` scripts to avoid multiple loads when `--fetch` is used
|
|
135
|
-
- [x] Infer `description` from the markdown and update html `<head>` with it
|
|
136
|
-
- [x] Update `social`, `org`, `ga` blocks
|
|
137
|
-
- [x] Small layout fixes
|
|
138
|
-
|
|
139
|
-
## 0.3.1
|
|
140
|
-
- [x] Add `download` method to jsee object
|
|
141
|
-
- [x] Add `bin` folder with `cmd.js` for easier project building
|
|
142
|
-
|
|
143
|
-
## 0.2.9
|
|
144
|
-
- [x] Add examples
|
|
145
|
-
- [x] Add imports
|
|
146
|
-
- [x] Add `caller` field to the model input (can be: `run`, `autorun` or a button name)
|
|
147
|
-
- [x] Add `title` field (for buttons rn)
|
|
148
|
-
- [x] If `display` field is `false` the input is not shown
|
|
149
|
-
- [x] If `autorun` is true, then actually autorun the model initially
|
|
150
|
-
|
|
151
|
-
## 0.2.8
|
|
152
|
-
- [x] Fix no input case
|
|
153
|
-
|
|
154
|
-
## 0.2.7
|
|
155
|
-
- [x] Show output when result is `0`
|
|
156
|
-
- [x] Updated style for buttons and inputs
|
|
157
|
-
|
|
158
|
-
## 0.2.6
|
|
159
|
-
- [x] Tests
|
|
160
|
-
- [x] Load schema from query (loader)
|
|
161
|
-
- [x] Reset button appears only after data change
|
|
162
|
-
- [x] Default input type (`string`)
|
|
163
|
-
- [x] Directly load code when running in a window (not code to text)
|
|
164
|
-
- [x] Passing code directly
|
|
143
|
+
See `CHANGELOG.md`.
|
package/bin/jsee
CHANGED