@thi.ng/rdom 0.10.18 → 0.11.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 +9 -1
- package/README.md +3 -1
- package/dom.js +1 -1
- package/idgen.d.ts +4 -0
- package/idgen.js +3 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/klist.js +3 -2
- package/list.js +3 -2
- package/object.js +3 -2
- package/package.json +15 -12
- package/replace.js +3 -2
- package/sub.d.ts +12 -2
- package/sub.js +14 -4
- package/switch.d.ts +2 -0
- package/switch.js +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-04-08T11:09:50Z
|
|
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
|
+
## [0.11.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom@0.11.0) (2023-04-08)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add null check for $remove() ([db9d2a1](https://github.com/thi-ng/umbrella/commit/db9d2a1))
|
|
17
|
+
- add stream IDs for $list/$klist/$Sub/$SubA ([bfd4058](https://github.com/thi-ng/umbrella/commit/bfd4058))
|
|
18
|
+
- add $subWithID(), add IDs for various constructs ([404eacb](https://github.com/thi-ng/umbrella/commit/404eacb))
|
|
19
|
+
|
|
12
20
|
## [0.10.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom@0.10.0) (2022-11-30)
|
|
13
21
|
|
|
14
22
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -277,7 +277,7 @@ For Node.js REPL:
|
|
|
277
277
|
const rdom = await import("@thi.ng/rdom");
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 3.
|
|
280
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 3.88 KB
|
|
281
281
|
|
|
282
282
|
## Dependencies
|
|
283
283
|
|
|
@@ -312,7 +312,9 @@ A selection:
|
|
|
312
312
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rdom-lissajous.png" width="240"/> | rdom & hiccup-canvas interop test | [Demo](https://demo.thi.ng/umbrella/rdom-lissajous/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-lissajous) |
|
|
313
313
|
| | Full umbrella repo doc string search w/ paginated results | [Demo](https://demo.thi.ng/umbrella/rdom-search-docs/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-search-docs) |
|
|
314
314
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rdom-svg-nodes.png" width="240"/> | rdom powered SVG graph with draggable nodes | [Demo](https://demo.thi.ng/umbrella/rdom-svg-nodes/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-svg-nodes) |
|
|
315
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-sync.png" width="240"/> | Minimal rstream sync() example using rdom | [Demo](https://demo.thi.ng/umbrella/rstream-sync/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-sync) |
|
|
315
316
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/svg-resample.png" width="240"/> | SVG path parsing & dynamic resampling | [Demo](https://demo.thi.ng/umbrella/svg-resample/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/svg-resample) |
|
|
317
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/trace-bitmap.jpg" width="240"/> | Multi-layer vectorization & dithering of bitmap images | [Demo](https://demo.thi.ng/umbrella/trace-bitmap/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/trace-bitmap) |
|
|
316
318
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-channel-mixer.jpg" width="240"/> | rdom & WebGL-based image channel editor | [Demo](https://demo.thi.ng/umbrella/webgl-channel-mixer/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-channel-mixer) |
|
|
317
319
|
|
|
318
320
|
## API
|
package/dom.js
CHANGED
|
@@ -175,7 +175,7 @@ export const $addChild = (parent, child, idx = -1) => {
|
|
|
175
175
|
*
|
|
176
176
|
* @param el
|
|
177
177
|
*/
|
|
178
|
-
export const $remove = (el) => el.remove();
|
|
178
|
+
export const $remove = (el) => el && el.remove();
|
|
179
179
|
/**
|
|
180
180
|
* Migrates given element to `newParent`, following the same append or insertion
|
|
181
181
|
* logic as {@link $addChild}.
|
package/idgen.d.ts
ADDED
package/idgen.js
ADDED
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/klist.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { $compile } from "./compile.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
3
|
import { $moveTo } from "./dom.js";
|
|
4
|
-
import {
|
|
4
|
+
import { __nextID } from "./idgen.js";
|
|
5
|
+
import { $subWithID } from "./sub.js";
|
|
5
6
|
/**
|
|
6
7
|
* Similar to {@link $list}, however additionally uses keying to establish list
|
|
7
8
|
* item identities and uses these keys (and *only* these!) in a more complex
|
|
@@ -54,7 +55,7 @@ import { $sub } from "./sub.js";
|
|
|
54
55
|
* @param childCtor -
|
|
55
56
|
* @param keyFn -
|
|
56
57
|
*/
|
|
57
|
-
export const $klist = (src, tag, attribs, childCtor, keyFn) => $
|
|
58
|
+
export const $klist = (src, tag, attribs, childCtor, keyFn) => $subWithID(src, new KList(tag, attribs, childCtor, keyFn), __nextID("klist", src));
|
|
58
59
|
export class KList extends Component {
|
|
59
60
|
constructor(tag, attribs, ctor, keyFn = (_, i) => i) {
|
|
60
61
|
super();
|
package/list.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { $compile } from "./compile.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import {
|
|
3
|
+
import { __nextID } from "./idgen.js";
|
|
4
|
+
import { $subWithID } from "./sub.js";
|
|
4
5
|
/**
|
|
5
6
|
* Creates a generalized and dynamically updating list component from items of
|
|
6
7
|
* the given `src` stream.
|
|
@@ -48,7 +49,7 @@ import { $sub } from "./sub.js";
|
|
|
48
49
|
* @param ctor -
|
|
49
50
|
* @param equiv -
|
|
50
51
|
*/
|
|
51
|
-
export const $list = (src, tag, attribs, ctor, equiv) => $
|
|
52
|
+
export const $list = (src, tag, attribs, ctor, equiv) => $subWithID(src, new List(tag, attribs, ctor, equiv), __nextID("list", src));
|
|
52
53
|
export class List extends Component {
|
|
53
54
|
constructor(tag, attribs, ctor, equiv = (a, b) => a === b) {
|
|
54
55
|
super();
|
package/object.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fromObject } from "@thi.ng/rstream/object";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import {
|
|
3
|
+
import { __nextID } from "./idgen.js";
|
|
4
|
+
import { $subWithID } from "./sub.js";
|
|
4
5
|
/**
|
|
5
6
|
* Creates a control component wrapper with an internal stream setup for user
|
|
6
7
|
* defined keys in the given object. When this component is mounted, it will
|
|
@@ -73,7 +74,7 @@ export const $object = (src, opts, inner) => new $Object(src, opts, inner);
|
|
|
73
74
|
* @param opts -
|
|
74
75
|
* @param inner -
|
|
75
76
|
*/
|
|
76
|
-
export const $subObject = (src, opts, inner) => $
|
|
77
|
+
export const $subObject = (src, opts, inner) => $subWithID(src, $object(src.deref() || {}, opts, inner), __nextID("obj", src));
|
|
77
78
|
export class $Object extends Component {
|
|
78
79
|
constructor(src, opts, ctor) {
|
|
79
80
|
super();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rdom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
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",
|
|
@@ -35,22 +35,22 @@
|
|
|
35
35
|
"test": "testament test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.7.
|
|
39
|
-
"@thi.ng/checks": "^3.3.
|
|
40
|
-
"@thi.ng/errors": "^2.2.
|
|
41
|
-
"@thi.ng/hiccup": "^4.2.
|
|
42
|
-
"@thi.ng/paths": "^5.1.
|
|
43
|
-
"@thi.ng/prefixes": "^2.1.
|
|
44
|
-
"@thi.ng/rstream": "^
|
|
45
|
-
"@thi.ng/strings": "^3.4.
|
|
38
|
+
"@thi.ng/api": "^8.7.6",
|
|
39
|
+
"@thi.ng/checks": "^3.3.12",
|
|
40
|
+
"@thi.ng/errors": "^2.2.15",
|
|
41
|
+
"@thi.ng/hiccup": "^4.2.39",
|
|
42
|
+
"@thi.ng/paths": "^5.1.35",
|
|
43
|
+
"@thi.ng/prefixes": "^2.1.22",
|
|
44
|
+
"@thi.ng/rstream": "^8.0.0",
|
|
45
|
+
"@thi.ng/strings": "^3.4.4"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@microsoft/api-extractor": "^7.34.4",
|
|
49
|
-
"@thi.ng/testament": "^0.3.
|
|
49
|
+
"@thi.ng/testament": "^0.3.15",
|
|
50
50
|
"rimraf": "^4.4.1",
|
|
51
51
|
"tools": "^0.0.1",
|
|
52
52
|
"typedoc": "^0.23.28",
|
|
53
|
-
"typescript": "^5.0.
|
|
53
|
+
"typescript": "^5.0.4"
|
|
54
54
|
},
|
|
55
55
|
"keywords": [
|
|
56
56
|
"async",
|
|
@@ -101,6 +101,9 @@
|
|
|
101
101
|
"./event": {
|
|
102
102
|
"default": "./event.js"
|
|
103
103
|
},
|
|
104
|
+
"./idgen": {
|
|
105
|
+
"default": "./idgen.js"
|
|
106
|
+
},
|
|
104
107
|
"./klist": {
|
|
105
108
|
"default": "./klist.js"
|
|
106
109
|
},
|
|
@@ -139,5 +142,5 @@
|
|
|
139
142
|
],
|
|
140
143
|
"year": 2020
|
|
141
144
|
},
|
|
142
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "abcedd9e4e06a4b631f363610eec572f79b571c1\n"
|
|
143
146
|
}
|
package/replace.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { $compile } from "./compile.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import {
|
|
3
|
+
import { __nextID } from "./idgen.js";
|
|
4
|
+
import { $subWithID } from "./sub.js";
|
|
4
5
|
import { $wrapText } from "./wrap.js";
|
|
5
6
|
/**
|
|
6
7
|
* Similar to {@link $refresh}, but more basic/simple. Takes a reactive value
|
|
@@ -34,7 +35,7 @@ import { $wrapText } from "./wrap.js";
|
|
|
34
35
|
*
|
|
35
36
|
* @param src -
|
|
36
37
|
*/
|
|
37
|
-
export const $replace = (src) => $
|
|
38
|
+
export const $replace = (src) => $subWithID(src, new Replace(), __nextID("replace", src));
|
|
38
39
|
export class Replace extends Component {
|
|
39
40
|
async mount(parent, index, val) {
|
|
40
41
|
this.parent = parent;
|
package/sub.d.ts
CHANGED
|
@@ -28,10 +28,20 @@ import type { IComponent, IMountWithState, NumOrElement } from "./api.js";
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function $sub<T>(src: ISubscribable<T>, inner: IMountWithState<T>): IComponent<T>;
|
|
30
30
|
export declare function $sub(src: ISubscribable<any>, tag: string, attribs?: any): IComponent;
|
|
31
|
+
/**
|
|
32
|
+
* Version of {@link $sub} which supports specifying an rstream stream ID for
|
|
33
|
+
* the resulting subscription (useful for debugging/visualizing the reactive
|
|
34
|
+
* graph topology).
|
|
35
|
+
*
|
|
36
|
+
* @param src
|
|
37
|
+
* @param inner
|
|
38
|
+
* @param id
|
|
39
|
+
*/
|
|
40
|
+
export declare const $subWithID: <T>(src: ISubscribable<T>, inner: IMountWithState<T>, id: string) => IComponent<T>;
|
|
31
41
|
export declare class $Sub<T = any> extends Subscription<T, T> {
|
|
32
42
|
protected inner: IMountWithState<T | undefined>;
|
|
33
43
|
el?: Element;
|
|
34
|
-
constructor(inner: IMountWithState<T | undefined
|
|
44
|
+
constructor(inner: IMountWithState<T | undefined>, id?: string);
|
|
35
45
|
mount(parent: Element, index?: NumOrElement): Promise<Element>;
|
|
36
46
|
unmount(): Promise<void>;
|
|
37
47
|
update(x: T): void;
|
|
@@ -41,7 +51,7 @@ export declare class $SubA extends Subscription<any, any> {
|
|
|
41
51
|
protected comp: IComponent;
|
|
42
52
|
protected setter: Fn2<any, any, any>;
|
|
43
53
|
protected attr: any;
|
|
44
|
-
constructor(comp: IComponent, path: Path);
|
|
54
|
+
constructor(comp: IComponent, path: Path, id?: string);
|
|
45
55
|
next(a: any): void;
|
|
46
56
|
}
|
|
47
57
|
//# sourceMappingURL=sub.d.ts.map
|
package/sub.js
CHANGED
|
@@ -8,9 +8,19 @@ import { $wrapText } from "./wrap.js";
|
|
|
8
8
|
export function $sub(src, tag, attribs) {
|
|
9
9
|
return (src.subscribe(new $Sub(isString(tag) ? $wrapText(tag, attribs) : tag)));
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Version of {@link $sub} which supports specifying an rstream stream ID for
|
|
13
|
+
* the resulting subscription (useful for debugging/visualizing the reactive
|
|
14
|
+
* graph topology).
|
|
15
|
+
*
|
|
16
|
+
* @param src
|
|
17
|
+
* @param inner
|
|
18
|
+
* @param id
|
|
19
|
+
*/
|
|
20
|
+
export const $subWithID = (src, inner, id) => src.subscribe(new $Sub(inner, id));
|
|
11
21
|
export class $Sub extends Subscription {
|
|
12
|
-
constructor(inner) {
|
|
13
|
-
super(undefined, { id: `rdom$sub-${__nextID()}` });
|
|
22
|
+
constructor(inner, id) {
|
|
23
|
+
super(undefined, { id: id || `rdom$sub-${__nextID()}` });
|
|
14
24
|
this.inner = inner;
|
|
15
25
|
}
|
|
16
26
|
async mount(parent, index = -1) {
|
|
@@ -30,8 +40,8 @@ export class $Sub extends Subscription {
|
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
export class $SubA extends Subscription {
|
|
33
|
-
constructor(comp, path) {
|
|
34
|
-
super(undefined, { id: `rdom$
|
|
43
|
+
constructor(comp, path, id) {
|
|
44
|
+
super(undefined, { id: id || `rdom$attr-${__nextID()}` });
|
|
35
45
|
this.comp = comp;
|
|
36
46
|
this.attr = {};
|
|
37
47
|
this.setter = defSetterUnsafe(path);
|
package/switch.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export declare const $switch: <T>(src: ISubscribable<T>, keyFn: Fn<T, NumOrStrin
|
|
|
67
67
|
* `$compile`d and then getting re-mounted. See {@link $switch} for
|
|
68
68
|
* further details.
|
|
69
69
|
*
|
|
70
|
+
* Also see {@link $replace}.
|
|
71
|
+
*
|
|
70
72
|
* @example
|
|
71
73
|
* ```ts
|
|
72
74
|
* $refresh(fromInterval(1000), async (x) => ["div", {}, x])
|
package/switch.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { assert } from "@thi.ng/errors/assert";
|
|
2
2
|
import { $compile } from "./compile.js";
|
|
3
3
|
import { Component } from "./component.js";
|
|
4
|
-
import {
|
|
4
|
+
import { __nextID } from "./idgen.js";
|
|
5
|
+
import { $subWithID } from "./sub.js";
|
|
5
6
|
import { $wrapText } from "./wrap.js";
|
|
6
7
|
/**
|
|
7
8
|
* Reactive component wrapper to dynamically switch/replace itself with one of
|
|
@@ -55,7 +56,7 @@ import { $wrapText } from "./wrap.js";
|
|
|
55
56
|
* @param error -
|
|
56
57
|
* @param loader -
|
|
57
58
|
*/
|
|
58
|
-
export const $switch = (src, keyFn, ctors, error, loader) => $
|
|
59
|
+
export const $switch = (src, keyFn, ctors, error, loader) => $subWithID(src, new Switch(keyFn, ctors, error, loader), __nextID("switch", src));
|
|
59
60
|
/**
|
|
60
61
|
* Syntax sugar for {@link $switch} for cases when there's only a single
|
|
61
62
|
* component which should transition through its entire lifecycle for
|
|
@@ -68,6 +69,8 @@ export const $switch = (src, keyFn, ctors, error, loader) => $sub(src, new Switc
|
|
|
68
69
|
* `$compile`d and then getting re-mounted. See {@link $switch} for
|
|
69
70
|
* further details.
|
|
70
71
|
*
|
|
72
|
+
* Also see {@link $replace}.
|
|
73
|
+
*
|
|
71
74
|
* @example
|
|
72
75
|
* ```ts
|
|
73
76
|
* $refresh(fromInterval(1000), async (x) => ["div", {}, x])
|
|
@@ -78,7 +81,7 @@ export const $switch = (src, keyFn, ctors, error, loader) => $sub(src, new Switc
|
|
|
78
81
|
* @param error -
|
|
79
82
|
* @param loader -
|
|
80
83
|
*/
|
|
81
|
-
export const $refresh = (src, ctor, error, loader) => $
|
|
84
|
+
export const $refresh = (src, ctor, error, loader) => $subWithID(src, new Switch(() => 0, { 0: ctor }, error, loader), __nextID("refresh", src));
|
|
82
85
|
export class Switch extends Component {
|
|
83
86
|
constructor(keyFn, ctors, error = async (e) => $wrapText("span", {}, e), loader = async () => $wrapText("span", {
|
|
84
87
|
hidden: true,
|