@jarenjs/app 0.46.5 → 0.56.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/README.md CHANGED
@@ -40,6 +40,47 @@ const app = createApp({
40
40
  }, { node: document.getElementById('app') });
41
41
  ```
42
42
 
43
+ ### The same app, by code
44
+
45
+ `@jarenjs/linq/app` writes that document from typed builders — the
46
+ initial state derived from the state schema's defaults, the view the
47
+ JSLT pen's stylesheet, the actions captured over `$`/`$event`/`$payload`
48
+ and their patch pointers derived from the state shape — and answers the
49
+ state's JSON Schema beside it for `validateState`:
50
+
51
+ ```javascript
52
+ import { action, bind, defineApp, replace, transition } from '@jarenjs/linq/app';
53
+ import { rule } from '@jarenjs/linq/jslt';
54
+ import * as s from '@jarenjs/linq/schema';
55
+
56
+ const counter = defineApp({
57
+ state: s.object({ count: s.integer().default(0) }),
58
+ view: [rule('$', (v) => ['main', {},
59
+ ['h1', {}, 'Count: ', v.get('count')],
60
+ ['button', { on: { click: 'inc' } }, '+'],
61
+ ['button', { on: { click: bind('add', { payload: 10 }) } }, '+10'],
62
+ ])],
63
+ actions: {
64
+ inc: action((st) => transition({
65
+ patch: [replace((c) => c.get('count'), st.get('count').add(1))],
66
+ })),
67
+ add: action((st, x) => transition({
68
+ patch: [replace((c) => c.get('count'), st.get('count').add(x.payload))],
69
+ }), { payload: s.integer() }),
70
+ },
71
+ });
72
+
73
+ createApp(counter.document, { node: document.getElementById('app') });
74
+ ```
75
+
76
+ It is the same application — the test suite boots both and compares
77
+ them frame for frame. The mapping table, every refusal and the
78
+ member-name escape this example's `get('count')` spells are
79
+ [APP-PEN.md](../linq/docs/APP-PEN.md); this package depends on none of
80
+ it.
81
+
82
+ ## The view
83
+
43
84
  The view is a JSLT stylesheet: rules match state by location (JSONPath) and shape (JSON Schema, via `compileTypeTest`), bodies are query documents producing vnodes, and `$path`/`$root` are in scope — a rule rendering `/todos/3` can embed its own pointer in an event binding, which is why there are no payload-creator functions anywhere.
44
85
 
45
86
  ## Actions and transitions
@@ -38,6 +38,19 @@ valid per §2–§5. A **runtime** (the reference implementation is
38
38
  specified there, and MUST serialize dispatches per the transaction
39
39
  model of §8.
40
40
 
41
+ One producer ships in this repository: `@jarenjs/linq/app` writes these
42
+ documents from typed JavaScript builders — the state's initial value
43
+ derived from its schema's defaults, the view the JSLT pen's stylesheet,
44
+ actions captured over §3.1's three names, and patch pointers derived
45
+ from the state shape — with `defineApp()` refusing at build time what
46
+ §4 and §6 would otherwise report per dispatch. Its mapping table is
47
+ [APP-PEN.md](../../linq/docs/APP-PEN.md); §2's document below
48
+ and the `contract/catalog.load/start` action of
49
+ [CONTRACT-FORMAT §11.1](../../contract/docs/CONTRACT-FORMAT.md) are
50
+ rebuilt through it byte for byte by that package's test suite. Nothing
51
+ in this package depends on it: the format is the contract, and a
52
+ document written by hand is the same document.
53
+
41
54
  ## 2. The app document
42
55
 
43
56
  ```json
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jarenjs/app",
3
3
  "private": false,
4
- "version": "0.46.5",
4
+ "version": "0.56.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "types": "./dist/types/index.d.ts",
@@ -50,8 +50,8 @@
50
50
  "prepack": "npm run build:types"
51
51
  },
52
52
  "dependencies": {
53
- "@jarenjs/core": "^0.46.5",
54
- "@jarenjs/json": "^0.46.5",
55
- "@jarenjs/view": "^0.46.5"
53
+ "@jarenjs/core": "^0.56.0",
54
+ "@jarenjs/json": "^0.56.0",
55
+ "@jarenjs/view": "^0.56.0"
56
56
  }
57
57
  }