@jseeio/jsee 0.3.7 → 0.3.9

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.
@@ -0,0 +1,12 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run test:basic:*)",
5
+ "Bash(npm run build-dev:*)",
6
+ "Bash(npm run test:unit:*)",
7
+ "Bash(find:*)",
8
+ "Bash(npx eslint:*)",
9
+ "Bash(npm run test:python:*)"
10
+ ]
11
+ }
12
+ }
package/.eslintrc.js ADDED
@@ -0,0 +1,38 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ node: true,
5
+ es2020: true,
6
+ jest: true,
7
+ },
8
+ parserOptions: {
9
+ ecmaVersion: 2020,
10
+ sourceType: 'module',
11
+ },
12
+ rules: {
13
+ // Match existing style: no semicolons, single quotes, 2-space indent
14
+ semi: ['warn', 'never'],
15
+ quotes: ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
16
+ indent: ['warn', 2, { SwitchCase: 1, ignoredNodes: ['TemplateLiteral *'] }],
17
+ 'no-unused-vars': ['warn', { args: 'none', varsIgnorePattern: '^_' }],
18
+ 'no-undef': 'error',
19
+ eqeqeq: ['warn', 'smart'],
20
+ 'no-eval': 'off', // intentional eval usage in main.js
21
+ },
22
+ globals: {
23
+ VERSION: 'readonly',
24
+ importScripts: 'readonly',
25
+ JSEE: 'readonly',
26
+ loadPyodide: 'readonly',
27
+ },
28
+ overrides: [
29
+ {
30
+ // Puppeteer tests use global `page` from jest-puppeteer
31
+ files: ['test/**/*.test.js'],
32
+ globals: {
33
+ page: 'readonly',
34
+ },
35
+ },
36
+ ],
37
+ ignorePatterns: ['dist/', 'node_modules/', 'apps/', 'tmp/', 'load/'],
38
+ }
package/AGENTS.md ADDED
@@ -0,0 +1,38 @@
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
+ - Commit changes one at a time, with clear messages. Avoid large commits that combine multiple changes.
34
+
35
+ ## Conventions
36
+ - Formatting: no formatter is configured; preserve existing style (2-space indentation, semicolon-free, single quotes)
37
+ - Types: plain JavaScript with runtime type checks (`typeof`, `isNaN`) and counters
38
+ - 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,86 @@
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
+ - Fix model type inference for URL-loaded JS: when `code` is present, infer `function` instead of treating `url` as API `post`
7
+ - 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
8
+ - Move `showdown-katex` and `katex` to runtime `dependencies` so `npx jsee` works without dev installs
9
+ - Fix `--fetch` bundling to include `schema.view` and `schema.render` blocks in addition to `schema.model`
10
+ - Fix `--fetch` import resolution for local relative JS imports and support object import entries (`{ url, ... }`)
11
+ - Fix CLI output path handling for absolute/relative `--outputs` values and remove duplicate final HTML write
12
+ - Fix `download()` method referencing undeclared `env` variable — now correctly uses `this`
13
+ - Fix `outputAsync()` referencing undeclared `delay` — now correctly uses `utils.delay`
14
+ - Fix CLI social links default case referencing undeclared `s` variable
15
+ - Remove dead `title` assignment in CLI `gen` function (already handled in `genHead`)
16
+ ### Features:
17
+ - Allow `progress(null)` to render an indeterminate top progress bar for stream-like tasks where total size is unknown
18
+ - Add `cancelCurrentRun()` runtime entrypoint and wire overlay Stop button with proper `click` handling for any active run
19
+ - Add worker cooperative cancel signal: `_cmd: 'cancel'` updates worker state and JS model context now exposes `ctx.isCancelled()`
20
+ - Add end-to-end `raw` file input mode: schema `inputs[].raw` now passes `File` objects / URL handles instead of loading full text into memory
21
+ - 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
22
+ - Preserve stream reader metadata (`name`, `size`, `type`) for file/URL sources and keep it available across downstream pipeline stages
23
+ - Auto-load file input URL query params on init (no extra Load click required)
24
+ - Add CLI `--runtime <auto|local|cdn|inline>` to control runtime source in generated HTML
25
+ - Add CLI `--help` flag with usage information and examples
26
+ - Add ESLint config matching project style (no semicolons, single quotes, 2-space indent)
27
+
28
+ ## 0.3.8 (2026-02-08)
29
+ ### Bug fixes:
30
+ - Fix `run()` error handling: wrap in try/catch/finally so overlay and running state always reset on failure
31
+ - Add `.catch()` to fire-and-forget `run()` callers to prevent unhandled rejections
32
+ - Add worker execution timeout (default 30s, configurable via `model.timeout`) to prevent permanently frozen UI
33
+ - Fix `indexOf('json')` bug in `initSchema` — condition was inverted, `.json` was never appended
34
+ - Fix array type detection in auto-created outputs (`typeof` returns `'object'` for arrays)
35
+ - Fix `getName` for `async function` strings and guard against arrow functions crashing
36
+ - Fix broken string interpolation and remove leftover `console.log('1')` in utils.js
37
+ ### Features:
38
+ - 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)
39
+ - Add run-concurrency guard: overlapping reactive/autorun calls are dropped, manual clicks are queued
40
+ - Move `getName` to utils.js for testability and reuse
41
+ - Add runtime `validateSchema()` checks and fail-fast on critical schema issues (`model`/`view` presence, input shape)
42
+ - Replace deprecated `node-sass` with `sass`, update `express`, `csv-parse`, and remove unused `element-plus`
43
+ ### Testing:
44
+ - Add separate Jest config for unit tests (`jest.unit.config.js`, no browser needed)
45
+ - Add unit tests for utils.js: `isObject`, `sanitizeName`, `getUrl`, `delay`, `debounce`, `getName`, `getModelFuncJS`, `getModelFuncAPI`, `validateSchema`
46
+ - Add `npm run test:unit` script
47
+
48
+ ## 0.3.4 (2024-11-19)
49
+ ### JSEE:
50
+ - [x] Add `columns` parameter to the `inputs`, `outputs` blocks (making it possible to create multi-column layouts, like simple dashboards)
51
+ - [x] Add `function` output type (for custom renderers which take a container element as an argument)
52
+ - [x] Add `dom-to-image` library for exporting dynamic output blocks to PNG
53
+ - [x] Support for inputs to be set with url parameters (e.g. `?input1=1&input2=2`)
54
+ ### HTML Generator:
55
+ - [x] Add `latex` and table output in the markdown renderer
56
+ - [x] Cache `import` scripts to avoid multiple loads when `--fetch` is used
57
+ - [x] Infer `description` from the markdown and update html `<head>` with it
58
+ - [x] Update `social`, `org`, `ga` blocks
59
+ - [x] Small layout fixes
60
+
61
+ ## 0.3.1 (2024-04-10)
62
+ - [x] Add `download` method to jsee object
63
+ - [x] Add `bin` folder with `cmd.js` for easier project building
64
+
65
+ ## 0.2.9 (2023-12-11)
66
+ - [x] Add examples
67
+ - [x] Add imports
68
+ - [x] Add `caller` field to the model input (can be: `run`, `autorun` or a button name)
69
+ - [x] Add `title` field (for buttons rn)
70
+ - [x] If `display` field is `false` the input is not shown
71
+ - [x] If `autorun` is true, then actually autorun the model initially
72
+
73
+ ## 0.2.8 (2021-12-29)
74
+ - [x] Fix no input case
75
+
76
+ ## 0.2.7 (2021-12-29)
77
+ - [x] Show output when result is `0`
78
+ - [x] Updated style for buttons and inputs
79
+
80
+ ## 0.2.6 (2021-12-27)
81
+ - [x] Tests
82
+ - [x] Load schema from query (loader)
83
+ - [x] Reset button appears only after data change
84
+ - [x] Default input type (`string`)
85
+ - [x] Directly load code when running in a window (not code to text)
86
+ - [x] Passing code directly
package/CLAUDE.md ADDED
@@ -0,0 +1,5 @@
1
+ See @AGENTS.md for the canonical project briefing.
2
+
3
+ Claude workflow:
4
+ - Explore in Plan Mode, then implement, then run tests.
5
+ - Prefer adding stable rules to AGENTS.md via PR.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Focus on code, not UI
1
+ # JSEE
2
2
 
3
3
  Minimal example:
4
4
  ```html
@@ -16,6 +16,25 @@ Minimal example:
16
16
 
17
17
  ↳ [Result](https://jsee.org/test/minimal1.html)
18
18
 
19
+ ## Installation
20
+
21
+ **Browser (CDN):**
22
+ ```html
23
+ <script src="https://cdn.jsdelivr.net/npm/@jseeio/jsee@latest/dist/jsee.runtime.js"></script>
24
+ ```
25
+
26
+ **npm (for CLI or Node.js projects):**
27
+ ```bash
28
+ npm install @jseeio/jsee
29
+ ```
30
+
31
+ **CLI (generate standalone apps):**
32
+ ```bash
33
+ npx @jseeio/jsee schema.json -o app.html
34
+ ```
35
+
36
+ Run `jsee --help` for all CLI options.
37
+
19
38
  ## JavaScript Execution Environment
20
39
 
21
40
  JSEE is a browser-based environment for processing tasks. It creates a graphical interface, executes code in a web worker or via API, bridges all pieces together into a user-friendly web app. In some cases, JSEE does all of that automatically, without any configuration. And when the configuration is required, it's just one JSON file with an [intuitive structure](#schema).
@@ -88,11 +107,19 @@ Extra blocks can be provided for further customization
88
107
  - `async-init`
89
108
  - `py`
90
109
  - `tf`
110
+ - Inference note: when `code` is present (including code loaded from a `.js` URL), JSEE treats the model as `function` unless `type` is explicitly set
91
111
  - `method` (string) - If `type` is `class`, `method` defines the name of the class method to call during evaluation
92
112
  - `container` (string) - How input values are passed to the function/method:
93
113
  - `object` (default) - Pass inputs wrapped in an object, i.e. `{'x': 1, 'y': 2}`
94
114
  - `args` - Pass inputs as separate arguments
95
115
  - `worker` (boolean) - If `true`, JSEE initializes a Web Worker to run the script
116
+ - For `container: 'object'`, model functions receive a second runtime context argument (`ctx`)
117
+ - `ctx.log(...args)` - Write runtime logs
118
+ - `ctx.progress(value)` - Report progress (`0..100` or `null` for indeterminate)
119
+ - `ctx.isCancelled()` - Check cooperative cancellation state (useful in long loops/streams)
120
+ - `timeout` (number, default: `30000`) - Worker execution timeout in milliseconds. Only applies when `worker: true`. Does not apply during model initialization (loading can be slow). If exceeded, the worker is terminated with an error
121
+ - `imports` (array) - Per-model imports loaded before this model's code executes. Accepts URLs as strings or objects `{ url: "..." }`. Top-level `imports` are moved to the first model internally
122
+ - `model` can also be an **array of model objects** to create a pipeline. Models execute sequentially — each receives the merged output of the previous one. First model defaults to `worker: true`, others to `worker: false`. Return `{ stop: true }` from any model to halt the pipeline early
96
123
  - `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
124
  - `design` - Design parameters
98
125
  - `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 +135,48 @@ Extra blocks can be provided for further customization
108
135
  - `file` - File Input
109
136
  - `action` or `button` - Button (its `name` will be passed as a `caller` to the model)
110
137
  - `default` - Default value
111
- - `outputs` - Outputs definition
138
+ - `alias` (string or array of strings) - Alternative names for URL parameter matching. E.g. `"alias": ["f", "file"]` allows `?f=value` or `?file=value` to set this input
139
+ - `display` (string) - Filtrex expression to conditionally show/hide this input. Evaluated against current input values. E.g. `"display": "mode == 'advanced'"` shows the input only when `mode` is `"advanced"`. Supports `len()` for string length
140
+ - `disabled` (boolean) - Disables the input in the UI. When combined with `reactive: true`, triggers an initial model run on page load (useful for server-populated values)
141
+ - `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)
142
+ - `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. Reader metadata (`reader.name`, `reader.size`, `reader.type`) is preserved and remains available in downstream pipeline models.
143
+ - URL params for file inputs (e.g. `?file=https://...`) auto-load on init, so bookmarkable links run without an extra Load click
144
+ - `outputs` - Outputs definition. Outputs also support `alias` (string) for matching model result keys by alternative names
112
145
  - `name`* - Name of the output
113
146
  - `type`* - Type. Possible types:
147
+ - `file` - File output (not displayer, but downloaded)
114
148
  - `object` - JavaScript Object
115
149
  - `html` or `svg` - SVG element
116
150
  - `code` - Code block
117
151
  - `function` - Render function. Rather than returning a value, a model returns a function that JSEE will call passing the container element.
152
+ - `blank` - Blank block (can be alternative to `function` and useful for custom renderers)
118
153
  - `examples` - List of examples
119
- - `autorun` (boolean, default: `false`) - Defines if the script should be evaluated on each input change event
154
+ - `autorun` (boolean, default: `false`) - Run the model automatically on first load
155
+ - `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
156
  - `interval` (number, default: `0`) - Defines the interval between script evaluations (in milliseconds). If set to `0`, the script is evaluated only once.
157
+ - 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.
158
+ - Schema validation - JSEE validates schema structure during initialization and logs warnings for non-critical issues (e.g. unknown input types, malformed aliases)
159
+ - `jsee.download(title)` - Downloads a self-contained HTML file that works offline. All external scripts are inlined and the schema/model/imports are cached. `title` defaults to `'output'`
160
+ - `page` (CLI only) - Page metadata for generated HTML:
161
+ - `title` (string) - Page title
162
+ - `url` (string) - Page URL
163
+ - `ga` (string) - Google Analytics measurement ID (e.g. `"G-XXXXXXXXXX"`)
164
+ - `social` (object) - Social media links: `twitter`, `github`, `facebook`, `linkedin`, `instagram`, `youtube` (values are usernames/handles)
165
+ - `org` (object) - Organization footer: `name`, `url`, `description`
121
166
 
122
167
  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
168
 
169
+ # CLI
170
+ - `--fetch` - Fetches JSEE runtime and bundles `model`/`view`/`render` blocks plus their imports into generated HTML
171
+ - `--runtime <auto|local|cdn|inline>` - Select runtime source for generated HTML
172
+ - `auto` (default): `inline` when `--fetch` is used, otherwise `cdn` for file output and `local` for dev server mode
173
+ - `local`: use `http://localhost:<port>/dist/...`
174
+ - `cdn`: use jsdelivr runtime URL
175
+ - `inline`: embed runtime code directly in HTML
176
+ - `--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).
177
+ - `--execute` - Executes the model code on the server-side.
178
+ # Server-side execution
179
+
124
180
  # Changelog
125
181
 
126
- ## 0.3.4
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
182
+ See `CHANGELOG.md`.
package/bin/jsee CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  const gen = require('../src/cli.js')
3
- gen(process.argv)
3
+ gen(process.argv.slice(2))