@jseeio/jsee 0.3.8 → 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.
@@ -3,7 +3,10 @@
3
3
  "allow": [
4
4
  "Bash(npm run test:basic:*)",
5
5
  "Bash(npm run build-dev:*)",
6
- "Bash(npm run test:unit:*)"
6
+ "Bash(npm run test:unit:*)",
7
+ "Bash(find:*)",
8
+ "Bash(npx eslint:*)",
9
+ "Bash(npm run test:python:*)"
7
10
  ]
8
11
  }
9
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 CHANGED
@@ -30,6 +30,7 @@ Use **2-space indentation** and **semicolon-free** syntax. Use **single quotes**
30
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
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
32
  - Ask for confirmation before each commit
33
+ - Commit changes one at a time, with clear messages. Avoid large commits that combine multiple changes.
33
34
 
34
35
  ## Conventions
35
36
  - Formatting: no formatter is configured; preserve existing style (2-space indentation, semicolon-free, single quotes)
package/CHANGELOG.md CHANGED
@@ -3,14 +3,29 @@
3
3
  ## Unreleased
4
4
  ### Bug fixes:
5
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`)
6
16
  ### Features:
7
17
  - Allow `progress(null)` to render an indeterminate top progress bar for stream-like tasks where total size is unknown
8
18
  - Add `cancelCurrentRun()` runtime entrypoint and wire overlay Stop button with proper `click` handling for any active run
9
19
  - Add worker cooperative cancel signal: `_cmd: 'cancel'` updates worker state and JS model context now exposes `ctx.isCancelled()`
10
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
11
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)
12
27
 
13
- ## 0.3.8
28
+ ## 0.3.8 (2026-02-08)
14
29
  ### Bug fixes:
15
30
  - Fix `run()` error handling: wrap in try/catch/finally so overlay and running state always reset on failure
16
31
  - Add `.catch()` to fire-and-forget `run()` callers to prevent unhandled rejections
@@ -30,7 +45,7 @@
30
45
  - Add unit tests for utils.js: `isObject`, `sanitizeName`, `getUrl`, `delay`, `debounce`, `getName`, `getModelFuncJS`, `getModelFuncAPI`, `validateSchema`
31
46
  - Add `npm run test:unit` script
32
47
 
33
- ## 0.3.4
48
+ ## 0.3.4 (2024-11-19)
34
49
  ### JSEE:
35
50
  - [x] Add `columns` parameter to the `inputs`, `outputs` blocks (making it possible to create multi-column layouts, like simple dashboards)
36
51
  - [x] Add `function` output type (for custom renderers which take a container element as an argument)
@@ -43,11 +58,11 @@
43
58
  - [x] Update `social`, `org`, `ga` blocks
44
59
  - [x] Small layout fixes
45
60
 
46
- ## 0.3.1
61
+ ## 0.3.1 (2024-04-10)
47
62
  - [x] Add `download` method to jsee object
48
63
  - [x] Add `bin` folder with `cmd.js` for easier project building
49
64
 
50
- ## 0.2.9
65
+ ## 0.2.9 (2023-12-11)
51
66
  - [x] Add examples
52
67
  - [x] Add imports
53
68
  - [x] Add `caller` field to the model input (can be: `run`, `autorun` or a button name)
@@ -55,14 +70,14 @@
55
70
  - [x] If `display` field is `false` the input is not shown
56
71
  - [x] If `autorun` is true, then actually autorun the model initially
57
72
 
58
- ## 0.2.8
73
+ ## 0.2.8 (2021-12-29)
59
74
  - [x] Fix no input case
60
75
 
61
- ## 0.2.7
76
+ ## 0.2.7 (2021-12-29)
62
77
  - [x] Show output when result is `0`
63
78
  - [x] Updated style for buttons and inputs
64
79
 
65
- ## 0.2.6
80
+ ## 0.2.6 (2021-12-27)
66
81
  - [x] Tests
67
82
  - [x] Load schema from query (loader)
68
83
  - [x] Reset button appears only after data change
package/README.md CHANGED
@@ -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,6 +107,7 @@ 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}`
@@ -97,6 +117,9 @@ Extra blocks can be provided for further customization
97
117
  - `ctx.log(...args)` - Write runtime logs
98
118
  - `ctx.progress(value)` - Report progress (`0..100` or `null` for indeterminate)
99
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
100
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.
101
124
  - `design` - Design parameters
102
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.
@@ -112,9 +135,13 @@ Extra blocks can be provided for further customization
112
135
  - `file` - File Input
113
136
  - `action` or `button` - Button (its `name` will be passed as a `caller` to the model)
114
137
  - `default` - Default value
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)
115
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)
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.
117
- - `outputs` - Outputs definition
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
118
145
  - `name`* - Name of the output
119
146
  - `type`* - Type. Possible types:
120
147
  - `file` - File output (not displayer, but downloaded)
@@ -129,11 +156,23 @@ Extra blocks can be provided for further customization
129
156
  - `interval` (number, default: `0`) - Defines the interval between script evaluations (in milliseconds). If set to `0`, the script is evaluated only once.
130
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.
131
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`
132
166
 
133
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.
134
168
 
135
169
  # CLI
136
- - `--fetch` - Fetches JSEE code, models and their imports and generates a bundled HTML file
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
137
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).
138
177
  - `--execute` - Executes the model code on the server-side.
139
178
  # Server-side execution