@jseeio/jsee 0.2.7 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,8 +1,21 @@
1
- ## [0.2.7]
1
+ # Changelog
2
+
3
+ ## 0.2.9
4
+ - [x] Add examples
5
+ - [x] Add imports
6
+ - [x] Add `caller` field to the model input (can be: `run`, `autorun` or a button name)
7
+ - [x] Add `title` field (for buttons rn)
8
+ - [x] If `display` field is `false` the input is not shown
9
+ - [x] If `autorun` is true, then actually autorun the model initially
10
+
11
+ ## 0.2.8
12
+ - [x] Fix no input case
13
+
14
+ ## 0.2.7
2
15
  - [x] Show output when result is `0`
3
16
  - [x] Updated style for buttons and inputs
4
17
 
5
- ## [<0.2.6]
18
+ ## 0.2.6
6
19
  - [x] Tests
7
20
  - [x] Load schema from query (loader)
8
21
  - [x] Reset button appears only after data change
package/README.md CHANGED
@@ -14,58 +14,76 @@ Minimal example:
14
14
  </html>
15
15
  ```
16
16
 
17
- ↳ [Result](https://jsee.org/test/minimal1.html) (if you see nothing, it's probably because today is Dec 29, and the CDN hasn't updated its cache yet)
17
+ ↳ [Result](https://jsee.org/test/minimal1.html)
18
18
 
19
- ## Execution environment
20
-
21
- 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).
19
+ ## JavaScript Execution Environment
22
20
 
21
+ 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).
23
22
 
24
23
  ## Inputs and outputs
25
24
 
26
25
  JSEE works best with functional tasks and one-way flow from inputs to outputs (i.e., inputs → processing → outputs). You can also extend it to more complex scenarios, like inputs → preprocessing → updated inputs → processing → outputs or inputs → processing → outputs → custom renderer. Even though many computational tasks have a functional form, some problems require more complex interactions between a user interface and code. For such cases, JSEE is probably too constrained. That makes it not as universal as R's [shiny](https://shiny.rstudio.com/) or Python's [streamlit](https://streamlit.io/).
27
26
 
28
-
29
27
  ## How it works
30
28
 
31
29
  Instead of dealing with raw HTML tags, input elements or charts, JSEE makes it possible to work on a higher level and describe only `inputs` and `outputs` in a JSON schema. It similarly handles code execution, by checking the `model` part of that JSON object. Those three parts are the most important for the future app. In many cases JSEE can generate a new schema automatically by analyzing the code alone. For example, it's possible to extract a list function arguments and use them as model inputs. When JSEE receives the JSON schema it creates a new Vue app based on it and initializes a new worker for code execution. The final app can take inputs from a user, parse files, load needed libraries, orchestrate communication between code and GUI, use Web Workers to run everything smoothly
32
30
 
33
- ```
31
+ ```text
34
32
  Schema Model Render*
35
- DEV ─► json js/py js
36
-
33
+ DEV -► json js/py js
34
+ | | |
37
35
  ┌──▼────────▼────────▼───┐
38
36
  │ new JSEE (...) │
39
- └──┬───────────────┬─────┘
40
-
41
- ┌──▼──┐ ┌──────▼─────┐ ◄┐ tf.js
42
- USER ◄─► │ GUI │ ◄─► │ Model │ ◄│ pyodide
43
- └─────┘ └────────────┘ ◄┘ wasm
37
+ └────────────────────────┘
38
+ | |
39
+ ┌──▼──┐ ┌──────▼─────┐ ◄~ tf.js
40
+ USER ◄-► │ GUI │ ◄-► │ Model │ ◄~ pyodide
41
+ └─────┘ └────────────┘ ◄~ wasm
44
42
  Vue³ WebWorker*
45
43
 
46
44
  * - optional
47
45
  ```
48
46
 
49
47
  JSEE takes a schema object that contains three main blocks:
48
+
50
49
  - `model` - describes a model/script/API (its location, is it a function or class, should it be called automatically on every GUI change or not)
51
50
  - `inputs` - list of inputs and their descriptions
52
51
  - `outputs` - list of outputs and their descriptions
53
52
 
54
- Two extra blocks can be provided for further customization
53
+ Extra blocks can be provided for further customization
54
+
55
55
  - `render` - visualization part (optional). Defines custom rendering code.
56
56
  - `design` - overall appearance (optional). Defines how the app looks overwriting defaults.
57
+ - `imports` - a list of urls (optional). Defines a list of scripts to load before the model is initialized.
58
+
59
+ ```json
60
+ "imports": [
61
+ "https://cdn.jsdelivr.net/npm/@tensorflow/tfjs",
62
+ "https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.js"
63
+ ]
64
+ ```
65
+
66
+ - `examples` - a list of examples (optional). Defines a list of examples that can be used to overwrite inputs.
67
+
68
+ ```json
69
+ "examples": [
70
+ { "input": "My name is Anton and I am" },
71
+ ]
72
+ ```
73
+
74
+ ## Playground
57
75
 
76
+ - [Codepen](https://codepen.io/jseeio/pen/NWayjJe)
58
77
 
59
- ### Schema
78
+ ## Schema
60
79
 
61
80
  - `model` - Contains main parameters of the model/script
62
81
  - `url` (string) - URL of a JS/Python script or POST/GET API
63
82
  - `code` (function) - It's possible to pass code directly to JSEE instead of using an URL
64
83
  - `name` (string) - Name of the executed object. Default value is taken from `url` or `code`
65
- - `autorun` (boolean, default - `false`) - Defines if the script should be evaluated on each input change event
66
- - `type` (string, default - `function`) - What kind of script is loaded. Influences how the code is initializated. Possible values:
84
+ - `type` (string, default - `function`) - What kind of script is loaded. Influences how the code is initializated. Possible values:
67
85
  - `function`
68
- - `class`
86
+ - `class`
69
87
  - `async-function`
70
88
  - `async-init`
71
89
  - `py`
@@ -79,7 +97,20 @@ Two extra blocks can be provided for further customization
79
97
  - `design` - Design parameters
80
98
  - `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.
81
99
  - `framework` - Design framework to use. If a JavaScript object with the same name is present in a global context, JSEE loads it too (using Vue's `use` method).
82
- - `inputs` - Inputs definition
100
+ - `inputs` - Inputs definition.
101
+ - `name`* - Name of the input
102
+ - `type`* - Type. Possible types:
103
+ - `int`, `float` or `number` - Number
104
+ - `string` - String
105
+ - `text` - Textarea
106
+ - `checkbox` or `bool` - Checkbox
107
+ - `select` or `categorical` - Select (one of many `options`)
108
+ - `file` - File Input
109
+ - `action` or `button` - Button (its `name` will be passed as a `caller` to the model)
110
+ - `default` - Default value
83
111
  - `outputs` - Outputs definition
112
+ - `examples` - List of examples
113
+ - `autorun` (boolean, default: `false`) - Defines if the script should be evaluated on each input change event
114
+ - `interval` (number, default: `0`) - Defines the interval between script evaluations (in milliseconds). If set to `0`, the script is evaluated only once.
84
115
 
85
116
  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.