@thi.ng/transducers-hdom 3.1.88 → 3.1.89

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/index.js +24 -58
  3. package/package.json +9 -6
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-09T19:12:04Z
3
+ - **Last updated**: 2023-12-11T10:07:09Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/index.js CHANGED
@@ -2,62 +2,28 @@ import { DEFAULT_IMPL } from "@thi.ng/hdom/default";
2
2
  import { resolveRoot } from "@thi.ng/hdom/resolve";
3
3
  import { derefContext } from "@thi.ng/hiccup/deref";
4
4
  import { scan } from "@thi.ng/transducers/scan";
5
- /**
6
- * Side-effecting & stateful transducer which receives {@link
7
- * @thi.ng/hdom} component trees, diffs each against previous value and applies
8
- * required changes to browser DOM starting at given root element.
9
- *
10
- * By default, incoming values are first normalized using hdom's
11
- * [`normalizeTree()`](https://docs.thi.ng/umbrella/hdom/functions/normalizeTree.html)
12
- * function and a copy of the given (optional) `ctx` object is provided to all
13
- * embedded component functions in the tree. If the `autoDerefKeys` option is
14
- * given, attempts to auto-expand/deref the given keys in the user supplied
15
- * context object (`ctx` option) prior to *each* tree normalization. All of
16
- * these values should implement the
17
- * [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html) interface
18
- * (e.g. atoms, cursors, views, rstreams etc.). This feature can be used to
19
- * define dynamic contexts linked to the main app state, e.g. using derived
20
- * views provided by [`thi.ng/atom`](https://thi.ng/atom).
21
- *
22
- * If the `hydrate` option is given, the first received tree is only used to
23
- * inject event listeners and initialize components with lifecycle
24
- * [`ILifecycle.init()`](https://docs.thi.ng/umbrella/hdom/interfaces/ILifecycle.html#init)
25
- * methods and expects an otherwise identical, pre-existing DOM. All succeeding
26
- * trees are diffed then as usual.
27
- *
28
- * This transducer is primarily intended for
29
- * [`thi.ng/rstream`](https://thi.ng/rstream) dataflow graph based applications,
30
- * where it can be used as final leaf subscription to reactively reflect UI
31
- * changes back to the user, without using the usual RAF update loop used by
32
- * hdom by default. In this setup, DOM updates will only be performed when the
33
- * stream this transducer is attached to emits new values (i.e. hdom component
34
- * trees).
35
- *
36
- * Please see here for further details:
37
- * [`start()`](https://docs.thi.ng/umbrella/hdom/functions/start.html)
38
- *
39
- * @param opts - hdom options
40
- */
41
- export const updateDOM = (opts = {}, impl = DEFAULT_IMPL) => {
42
- const _opts = { root: "app", ...opts };
43
- const root = resolveRoot(_opts.root, impl);
44
- return scan([
45
- () => [],
46
- (acc) => acc,
47
- (prev, curr) => {
48
- _opts.ctx = derefContext(opts.ctx, _opts.autoDerefKeys);
49
- curr = impl.normalizeTree(_opts, curr);
50
- if (curr != null) {
51
- if (_opts.hydrate) {
52
- impl.hydrateTree(_opts, root, curr);
53
- _opts.hydrate = false;
54
- }
55
- else {
56
- impl.diffTree(_opts, root, prev, curr, 0);
57
- }
58
- return curr;
59
- }
60
- return prev;
61
- },
62
- ]);
5
+ const updateDOM = (opts = {}, impl = DEFAULT_IMPL) => {
6
+ const _opts = { root: "app", ...opts };
7
+ const root = resolveRoot(_opts.root, impl);
8
+ return scan([
9
+ () => [],
10
+ (acc) => acc,
11
+ (prev, curr) => {
12
+ _opts.ctx = derefContext(opts.ctx, _opts.autoDerefKeys);
13
+ curr = impl.normalizeTree(_opts, curr);
14
+ if (curr != null) {
15
+ if (_opts.hydrate) {
16
+ impl.hydrateTree(_opts, root, curr);
17
+ _opts.hydrate = false;
18
+ } else {
19
+ impl.diffTree(_opts, root, prev, curr, 0);
20
+ }
21
+ return curr;
22
+ }
23
+ return prev;
24
+ }
25
+ ]);
26
+ };
27
+ export {
28
+ updateDOM
63
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/transducers-hdom",
3
- "version": "3.1.88",
3
+ "version": "3.1.89",
4
4
  "description": "Transducer based UI updater for @thi.ng/hdom",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -24,7 +24,9 @@
24
24
  "author": "Karsten Schmidt (https://thi.ng)",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && tsc --declaration",
27
+ "build": "yarn build:esbuild && yarn build:decl",
28
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
29
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
28
30
  "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
29
31
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
@@ -33,12 +35,13 @@
33
35
  "test": "bun test"
34
36
  },
35
37
  "dependencies": {
36
- "@thi.ng/hdom": "^9.3.31",
37
- "@thi.ng/hiccup": "^5.1.0",
38
- "@thi.ng/transducers": "^8.8.14"
38
+ "@thi.ng/hdom": "^9.4.0",
39
+ "@thi.ng/hiccup": "^5.1.1",
40
+ "@thi.ng/transducers": "^8.8.15"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@microsoft/api-extractor": "^7.38.3",
44
+ "esbuild": "^0.19.8",
42
45
  "rimraf": "^5.0.5",
43
46
  "tools": "^0.0.1",
44
47
  "typedoc": "^0.25.4",
@@ -77,5 +80,5 @@
77
80
  ],
78
81
  "year": 2018
79
82
  },
80
- "gitHead": "25f2ac8ff795a432a930119661b364d4d93b59a0\n"
83
+ "gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
81
84
  }