stillflow.engine 0.1.2 → 0.1.3

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
@@ -30,6 +30,9 @@ Also I think that **explicit reactivity is better than implicit reactivity**. So
30
30
  ## Quick Start
31
31
 
32
32
  ### Let's make some simple Todo application
33
+
34
+ For a starter you can play with (it)[https://codesandbox.io/p/sandbox/stillflow-engine-starter-3qv9mh]. Simple demonstration of the features of **Stillflow**.
35
+
33
36
  ```ts
34
37
  import { Stillflow, State, FenwickCollection, FlushableCollection, operators, adapters } from 'stillflow.engine'
35
38
 
@@ -1,5 +1,6 @@
1
1
  import { Compiler } from "./compile.js";
2
2
  import { transform } from "./transform.js";
3
+ const SF_CACHED_TEXTNODE = '__stillflow_cache_textnode__';
3
4
  const SF_LISTENED = '__stillflow_listened__';
4
5
  const SF_CONTEXT = '__stillflow_context__';
5
6
  const SF_CACHE = '__stillflow_cache__';
@@ -46,7 +47,14 @@ export class Appliers {
46
47
  const text = payload(context);
47
48
  const nodes = root[SF_CACHE];
48
49
  const element = nodes[id];
49
- element.firstChild.nodeValue = text;
50
+ let textnode = element[SF_CACHED_TEXTNODE];
51
+ if (textnode === undefined) {
52
+ textnode = element.firstChild;
53
+ element[SF_CACHED_TEXTNODE] = textnode;
54
+ }
55
+ if (textnode !== null) {
56
+ textnode.nodeValue = text;
57
+ }
50
58
  };
51
59
  }
52
60
  apply_properties(id, payload) {
@@ -77,7 +85,7 @@ export class Appliers {
77
85
  };
78
86
  }
79
87
  apply_iterate(id, payload) {
80
- const SPACE = " ";
88
+ const SPACE = String();
81
89
  const node = payload.each();
82
90
  const compiler = new Compiler();
83
91
  const appliers = new Appliers();
@@ -164,47 +172,30 @@ export class Appliers {
164
172
  }
165
173
  apply(template) {
166
174
  const { instructions, paths } = template;
167
- const appliers = {
168
- text: new Array(),
169
- iterate: new Array(),
170
- events: new Array(),
171
- properties: new Array(),
172
- conditional: new Array()
173
- };
175
+ const appliers = new Array(instructions.length);
176
+ let fill_index = 0;
174
177
  for (let index = 0; index < instructions.length; index++) {
175
178
  const instruction = instructions[index];
176
179
  const id = instruction.id;
177
180
  if (instruction.text !== undefined) {
178
- appliers.text.push(this.apply_text(id, instruction.text));
181
+ appliers[fill_index++] = this.apply_text(id, instruction.text);
179
182
  }
180
183
  if (instruction.iterate !== undefined) {
181
- appliers.iterate.push(this.apply_iterate(id, instruction.iterate));
184
+ appliers[fill_index++] = this.apply_iterate(id, instruction.iterate);
182
185
  }
183
186
  if (instruction.events !== undefined) {
184
- appliers.events.push(this.apply_events(id, instruction.events));
187
+ appliers[fill_index++] = this.apply_events(id, instruction.events);
185
188
  }
186
189
  if (instruction.properties !== undefined) {
187
- appliers.properties.push(this.apply_properties(id, instruction.properties));
190
+ appliers[fill_index++] = this.apply_properties(id, instruction.properties);
188
191
  }
189
192
  if (instruction.conditional !== undefined) {
190
- appliers.conditional.push(this.apply_conditional(id, instruction.conditional));
193
+ appliers[fill_index++] = this.apply_conditional(id, instruction.conditional);
191
194
  }
192
195
  }
193
196
  return (root, context) => {
194
197
  this.markup(root, paths);
195
- for (const applier of appliers.text) {
196
- applier(root, context);
197
- }
198
- for (const applier of appliers.events) {
199
- applier(root, context);
200
- }
201
- for (const applier of appliers.properties) {
202
- applier(root, context);
203
- }
204
- for (const applier of appliers.iterate) {
205
- applier(root, context);
206
- }
207
- for (const applier of appliers.conditional) {
198
+ for (const applier of appliers) {
208
199
  applier(root, context);
209
200
  }
210
201
  };
@@ -2,8 +2,8 @@ import { Stillflow, State, Batcher, operators, adapters, FlushableCollection, Fe
2
2
  import { buildData } from "./data.js";
3
3
  const { jsxdom, dom } = adapters;
4
4
  class BenchmarkApplicationController {
5
- _stillflow = new Stillflow(new State(), { strategy: site => requestAnimationFrame(site) });
6
- _clearing = new Batcher(site => requestIdleCallback(site));
5
+ _stillflow = new Stillflow(new State());
6
+ _clearing = new Batcher(site => site());
7
7
  _factory = this._stillflow.factory();
8
8
  _view;
9
9
  schedule_clear() {
@@ -13,7 +13,6 @@ class BenchmarkApplicationController {
13
13
  deselect() {
14
14
  this._view.selection.current_id = undefined;
15
15
  this._view.selection.previous_id = undefined;
16
- this._stillflow.commit();
17
16
  }
18
17
  create(count = 1000) {
19
18
  this.schedule_clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stillflow.engine",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A headless, transaction-based UI engine with AOT compilation.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",