@thi.ng/rdom 1.5.0 → 1.5.1

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,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-07-03T08:50:04Z
3
+ - **Last updated**: 2024-07-06T12:02:19Z
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.
@@ -9,6 +9,14 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [1.5.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom@1.5.1) (2024-07-06)
13
+
14
+ #### 🩹 Bug fixes
15
+
16
+ - update $compile() handling of embedded functions ([#477](https://github.com/thi-ng/umbrella/issues/477)) ([5ac2831](https://github.com/thi-ng/umbrella/commit/5ac2831))
17
+ - add fn checks & branches to call embedded fn and compile its result
18
+ - update docs
19
+
12
20
  ## [1.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom@1.5.0) (2024-07-03)
13
21
 
14
22
  #### 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 189 standalone projects, maintained as part
10
+ > This is one of 188 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
@@ -315,7 +315,7 @@ Browser ESM import:
315
315
 
316
316
  [JSDelivr documentation](https://www.jsdelivr.com/)
317
317
 
318
- Package sizes (brotli'd, pre-treeshake): ESM: 4.24 KB
318
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.27 KB
319
319
 
320
320
  ## Dependencies
321
321
 
package/compile.d.ts CHANGED
@@ -13,6 +13,9 @@ import type { IComponent } from "./api.js";
13
13
  * instances
14
14
  * - [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html)
15
15
  * instances
16
+ * - functions embedded in hiccup, i.e. either:
17
+ * - `[fn, ...args]`
18
+ * - `["tag", {}, ... noArgFn ...]`
16
19
  *
17
20
  * Any other value type will be wrapped in a `<span>` element. Reactive
18
21
  * `ISubscribable` values can be used as element attributes or element
@@ -20,6 +23,10 @@ import type { IComponent } from "./api.js";
20
23
  * target attribute. If used as element body, the reactive value will be wrapped
21
24
  * using a {@link $sub} `<span>` with the value as its reactive body.
22
25
  *
26
+ * If given any of the supported embedded function forms, the function will be
27
+ * called with given args (or without) and the result passed back to
28
+ * `$compile()`.
29
+ *
23
30
  * **Important:** Use {@link $replace}, {@link $refresh} or {@link $switch} to
24
31
  * wrap any reactive values/subscriptions which produce actual HTML
25
32
  * elements/components/subtrees (in hiccup format). See docs for these functions
package/compile.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isArray } from "@thi.ng/checks/is-array";
2
2
  import { isAsyncIterable } from "@thi.ng/checks/is-async-iterable";
3
+ import { isFunction } from "@thi.ng/checks/is-function";
3
4
  import { isPlainObject } from "@thi.ng/checks/is-plain-object";
4
5
  import { isSubscribable } from "@thi.ng/rstream/checks";
5
6
  import { $async, $asyncA } from "./async.js";
@@ -7,7 +8,7 @@ import { isComponent, isElement } from "./checks.js";
7
8
  import { $el, $remove, $tree } from "./dom.js";
8
9
  import { $SubA, $sub } from "./sub.js";
9
10
  import { $wrapEl, $wrapText } from "./wrap.js";
10
- const $compile = (tree) => isArray(tree) ? __isComplexComponent(tree) ? __complexComponent(tree) : __basicComponent(tree) : isComponent(tree) ? tree : isSubscribable(tree) ? $sub(tree, "span") : isAsyncIterable(tree) ? $async(tree, "span") : tree instanceof Element ? $wrapEl(tree) : $wrapText("span", null, tree);
11
+ const $compile = (tree) => isArray(tree) ? isFunction(tree[0]) ? $compile(tree[0].apply(null, tree.slice(1))) : __isComplexComponent(tree) ? __complexComponent(tree) : __basicComponent(tree) : isComponent(tree) ? tree : isSubscribable(tree) ? $sub(tree, "span") : isAsyncIterable(tree) ? $async(tree, "span") : isFunction(tree) ? $compile(tree()) : tree instanceof Element ? $wrapEl(tree) : $wrapText("span", null, tree);
11
12
  const __walk = (f, x, path = []) => {
12
13
  if (isPlainObject(x)) {
13
14
  for (const k in x) {
@@ -26,7 +27,7 @@ const __isComplexComponent = (x) => {
26
27
  if (__isComplexComponent(x[i])) return true;
27
28
  }
28
29
  }
29
- return isSubscribable(x) || isAsyncIterable(x) || isComponent(x) || isElement(x);
30
+ return isSubscribable(x) || isAsyncIterable(x) || isComponent(x) || isFunction(x) || isElement(x);
30
31
  };
31
32
  const __complexComponent = (tree) => ({
32
33
  async mount(parent, index = -1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rdom",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,20 +37,20 @@
37
37
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
38
38
  },
39
39
  "dependencies": {
40
- "@thi.ng/api": "^8.11.4",
41
- "@thi.ng/checks": "^3.6.6",
42
- "@thi.ng/errors": "^2.5.9",
43
- "@thi.ng/hiccup": "^5.2.3",
44
- "@thi.ng/paths": "^5.1.83",
45
- "@thi.ng/prefixes": "^2.3.21",
46
- "@thi.ng/rstream": "^8.5.3",
47
- "@thi.ng/strings": "^3.7.35"
40
+ "@thi.ng/api": "^8.11.5",
41
+ "@thi.ng/checks": "^3.6.7",
42
+ "@thi.ng/errors": "^2.5.10",
43
+ "@thi.ng/hiccup": "^5.2.4",
44
+ "@thi.ng/paths": "^5.1.84",
45
+ "@thi.ng/prefixes": "^2.3.22",
46
+ "@thi.ng/rstream": "^8.5.4",
47
+ "@thi.ng/strings": "^3.7.36"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@microsoft/api-extractor": "^7.47.0",
51
- "esbuild": "^0.21.5",
52
- "typedoc": "^0.25.13",
53
- "typescript": "^5.5.2"
51
+ "esbuild": "^0.23.0",
52
+ "typedoc": "^0.26.3",
53
+ "typescript": "^5.5.3"
54
54
  },
55
55
  "keywords": [
56
56
  "async",
@@ -145,5 +145,5 @@
145
145
  ],
146
146
  "year": 2020
147
147
  },
148
- "gitHead": "4e1794f6c951adb73c27c3e6c08f7138d9445e8b\n"
148
+ "gitHead": "70f493d9ccc97c5df5dda7e808e96cd1691097fc\n"
149
149
  }