@thi.ng/hdom 8.2.32 → 9.0.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/CHANGELOG.md +187 -215
- package/README.md +28 -10
- package/default.d.ts +1 -1
- package/default.js +3 -3
- package/diff.d.ts +1 -1
- package/diff.js +3 -2
- package/dom.d.ts +1 -1
- package/dom.js +7 -3
- package/index.d.ts +9 -9
- package/index.js +9 -9
- package/logger.d.ts +1 -1
- package/logger.js +1 -1
- package/normalize.d.ts +1 -1
- package/normalize.js +7 -4
- package/package.json +62 -31
- package/render-once.d.ts +1 -1
- package/render-once.js +4 -4
- package/resolve.d.ts +3 -0
- package/{utils.js → resolve.js} +1 -1
- package/start.d.ts +1 -1
- package/start.js +4 -4
- package/lib/index.js +0 -632
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
- package/utils.d.ts +0 -3
package/README.md
CHANGED
|
@@ -90,8 +90,8 @@ Benefits:
|
|
|
90
90
|
- Default implementation supports CSS conversion from JS objects for
|
|
91
91
|
`style` attribs (also see:
|
|
92
92
|
[@thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup-css))
|
|
93
|
-
- Auto-expansion of embedded values / types which implement the [`IToHiccup`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/
|
|
94
|
-
[`IDeref`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/
|
|
93
|
+
- Auto-expansion of embedded values / types which implement the [`IToHiccup`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/hiccup.ts) or
|
|
94
|
+
[`IDeref`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/deref.ts)
|
|
95
95
|
interfaces (e.g. [atoms, cursors, derived views](https://github.com/thi-ng/umbrella/tree/develop/packages/atom), [streams](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream) etc.)
|
|
96
96
|
- Fast (see [benchmark examples](#benchmarks) below)
|
|
97
97
|
- Only ~6.2KB gzipped
|
|
@@ -119,12 +119,21 @@ Benefits:
|
|
|
119
119
|
yarn add @thi.ng/hdom
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
+
ES module import:
|
|
123
|
+
|
|
122
124
|
```html
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
<script type="module" src="https://cdn.skypack.dev/@thi.ng/hdom"></script>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
[Skypack documentation](https://docs.skypack.dev/)
|
|
129
|
+
|
|
130
|
+
For Node.js REPL:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
# with flag only for < v16
|
|
134
|
+
node --experimental-repl-await
|
|
125
135
|
|
|
126
|
-
|
|
127
|
-
<script src="https://unpkg.com/@thi.ng/hdom/lib/index.umd.js" crossorigin></script>
|
|
136
|
+
> const hdom = await import("@thi.ng/hdom");
|
|
128
137
|
```
|
|
129
138
|
|
|
130
139
|
You can use the
|
|
@@ -142,7 +151,7 @@ yarn install
|
|
|
142
151
|
yarn start
|
|
143
152
|
```
|
|
144
153
|
|
|
145
|
-
Package sizes (gzipped, pre-treeshake): ESM: 3.
|
|
154
|
+
Package sizes (gzipped, pre-treeshake): ESM: 3.70 KB
|
|
146
155
|
|
|
147
156
|
## Dependencies
|
|
148
157
|
|
|
@@ -152,6 +161,7 @@ Package sizes (gzipped, pre-treeshake): ESM: 3.62 KB / CJS: 3.72 KB / UMD: 3.66
|
|
|
152
161
|
- [@thi.ng/equiv](https://github.com/thi-ng/umbrella/tree/develop/packages/equiv)
|
|
153
162
|
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
|
|
154
163
|
- [@thi.ng/hiccup](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup)
|
|
164
|
+
- [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
|
|
155
165
|
- [@thi.ng/prefixes](https://github.com/thi-ng/umbrella/tree/develop/packages/prefixes)
|
|
156
166
|
|
|
157
167
|
## Usage examples
|
|
@@ -170,8 +180,16 @@ A selection:
|
|
|
170
180
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/hdom-canvas-clock.png" width="240"/> | Realtime analog clock demo | [Demo](https://demo.thi.ng/umbrella/hdom-canvas-clock/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-canvas-clock) |
|
|
171
181
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/hdom-canvas-particles.jpg" width="240"/> | 2D Bezier curve-guided particle system | [Demo](https://demo.thi.ng/umbrella/hdom-canvas-particles/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-canvas-particles) |
|
|
172
182
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/hdom-canvas/hdom-canvas-shapes-results.png" width="240"/> | Various hdom-canvas shape drawing examples & SVG conversion / export | [Demo](https://demo.thi.ng/umbrella/hdom-canvas-shapes/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-canvas-shapes) |
|
|
183
|
+
| | Custom dropdown UI component for hdom | [Demo](https://demo.thi.ng/umbrella/hdom-dropdown/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-dropdown) |
|
|
173
184
|
| | Custom dropdown UI component w/ fuzzy search | [Demo](https://demo.thi.ng/umbrella/hdom-dropdown-fuzzy/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-dropdown-fuzzy) |
|
|
185
|
+
| | Using custom hdom context for dynamic UI theming | [Demo](https://demo.thi.ng/umbrella/hdom-dyn-context/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-dyn-context) |
|
|
174
186
|
| | Using hdom in an Elm-like manner | [Demo](https://demo.thi.ng/umbrella/hdom-elm/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-elm) |
|
|
187
|
+
| | Higher-order component for rendering HTML strings | [Demo](https://demo.thi.ng/umbrella/hdom-inner-html/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-inner-html) |
|
|
188
|
+
| | Isolated, component-local DOM updates | [Demo](https://demo.thi.ng/umbrella/hdom-local-render/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-local-render) |
|
|
189
|
+
| | UI component w/ local state stored in hdom context | [Demo](https://demo.thi.ng/umbrella/hdom-localstate/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-localstate) |
|
|
190
|
+
| | Skipping UI updates for selected component(s) | [Demo](https://demo.thi.ng/umbrella/hdom-skip/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-skip) |
|
|
191
|
+
| | Skipping UI updates for nested component(s) | [Demo](https://demo.thi.ng/umbrella/hdom-skip-nested/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-skip-nested) |
|
|
192
|
+
| | Example for themed components proposal | [Demo](https://demo.thi.ng/umbrella/hdom-theme/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-theme) |
|
|
175
193
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/hdom-toggle.png" width="240"/> | Customizable slide toggle component demo | [Demo](https://demo.thi.ng/umbrella/hdom-toggle/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-toggle) |
|
|
176
194
|
| | Hiccup / hdom DOM hydration example | [Demo](https://demo.thi.ng/umbrella/hydrate-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hydrate-basics) |
|
|
177
195
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/imgui/imgui-all.png" width="240"/> | Canvas based Immediate Mode GUI components | [Demo](https://demo.thi.ng/umbrella/imgui/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/imgui) |
|
|
@@ -620,9 +638,9 @@ import { map, range } from "@thi.ng/transducers";
|
|
|
620
638
|
### Interface support
|
|
621
639
|
|
|
622
640
|
Any type implementing one of the
|
|
623
|
-
[`IToHiccup`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/
|
|
641
|
+
[`IToHiccup`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/hiccup.ts)
|
|
624
642
|
or
|
|
625
|
-
[`IDeref`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/
|
|
643
|
+
[`IDeref`](https://github.com/thi-ng/umbrella/tree/develop/packages/api/src/deref.ts)
|
|
626
644
|
or interfaces will be auto-expanded during tree normalization.
|
|
627
645
|
|
|
628
646
|
This currently includes the following types from other packages in this
|
|
@@ -944,7 +962,7 @@ The following functions are the core parts of the `HDOMImplementation`
|
|
|
944
962
|
interface, the abstraction layer used by hdom to support different
|
|
945
963
|
targets.
|
|
946
964
|
|
|
947
|
-
- [interface definition](https://
|
|
965
|
+
- [interface definition](https://docs.thi.ng/umbrella/hdom/interfaces/HDOMImplementation.html)
|
|
948
966
|
- [default implementation](https://github.com/thi-ng/umbrella/blob/develop/packages/hdom/src/default.ts)
|
|
949
967
|
|
|
950
968
|
### normalizeTree()
|
package/default.d.ts
CHANGED
package/default.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { diffTree } from "./diff";
|
|
2
|
-
import { createElement, createTextElement, createTree, getChild, hydrateTree, removeAttribs, removeChild, replaceChild, setAttrib, setContent, } from "./dom";
|
|
3
|
-
import { normalizeTree } from "./normalize";
|
|
1
|
+
import { diffTree } from "./diff.js";
|
|
2
|
+
import { createElement, createTextElement, createTree, getChild, hydrateTree, removeAttribs, removeChild, replaceChild, setAttrib, setContent, } from "./dom.js";
|
|
3
|
+
import { normalizeTree } from "./normalize.js";
|
|
4
4
|
/**
|
|
5
5
|
* Default target implementation to manipulate browser DOM.
|
|
6
6
|
*/
|
package/diff.d.ts
CHANGED
package/diff.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { SEMAPHORE } from "@thi.ng/api";
|
|
2
|
-
import { diffArray
|
|
1
|
+
import { SEMAPHORE } from "@thi.ng/api/api";
|
|
2
|
+
import { diffArray } from "@thi.ng/diff/array";
|
|
3
|
+
import { diffObject } from "@thi.ng/diff/object";
|
|
3
4
|
import { equiv as _equiv, equivArrayLike, equivMap, equivObject, equivSet, } from "@thi.ng/equiv";
|
|
4
5
|
const isArray = Array.isArray;
|
|
5
6
|
const max = Math.max;
|
package/dom.d.ts
CHANGED
package/dom.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { isArray as isa
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isArray as isa } from "@thi.ng/checks/is-array";
|
|
2
|
+
import { isNotStringAndIterable as isi } from "@thi.ng/checks/is-not-string-iterable";
|
|
3
|
+
import { isString as iss } from "@thi.ng/checks/is-string";
|
|
4
|
+
import { SVG_TAGS } from "@thi.ng/hiccup/api";
|
|
5
|
+
import { css } from "@thi.ng/hiccup/css";
|
|
6
|
+
import { formatPrefixes } from "@thi.ng/hiccup/prefix";
|
|
7
|
+
import { XML_SVG } from "@thi.ng/prefixes/xml";
|
|
4
8
|
const isArray = isa;
|
|
5
9
|
const isNotStringAndIterable = isi;
|
|
6
10
|
const isString = iss;
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./default";
|
|
3
|
-
export * from "./diff";
|
|
4
|
-
export * from "./dom";
|
|
5
|
-
export * from "./logger";
|
|
6
|
-
export * from "./normalize";
|
|
7
|
-
export * from "./render-once";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./default.js";
|
|
3
|
+
export * from "./diff.js";
|
|
4
|
+
export * from "./dom.js";
|
|
5
|
+
export * from "./logger.js";
|
|
6
|
+
export * from "./normalize.js";
|
|
7
|
+
export * from "./render-once.js";
|
|
8
|
+
export * from "./resolve.js";
|
|
9
|
+
export * from "./start.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./default";
|
|
3
|
-
export * from "./diff";
|
|
4
|
-
export * from "./dom";
|
|
5
|
-
export * from "./logger";
|
|
6
|
-
export * from "./normalize";
|
|
7
|
-
export * from "./render-once";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./default.js";
|
|
3
|
+
export * from "./diff.js";
|
|
4
|
+
export * from "./dom.js";
|
|
5
|
+
export * from "./logger.js";
|
|
6
|
+
export * from "./normalize.js";
|
|
7
|
+
export * from "./render-once.js";
|
|
8
|
+
export * from "./resolve.js";
|
|
9
|
+
export * from "./start.js";
|
package/logger.d.ts
CHANGED
package/logger.js
CHANGED
package/normalize.d.ts
CHANGED
package/normalize.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { isArray as isa
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isArray as isa } from "@thi.ng/checks/is-array";
|
|
2
|
+
import { isNotStringAndIterable as isi } from "@thi.ng/checks/is-not-string-iterable";
|
|
3
|
+
import { isPlainObject as iso } from "@thi.ng/checks/is-plain-object";
|
|
4
|
+
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
5
|
+
import { NO_SPANS, RE_TAG } from "@thi.ng/hiccup/api";
|
|
6
|
+
import { mergeEmmetAttribs } from "@thi.ng/hiccup/attribs";
|
|
4
7
|
const isArray = isa;
|
|
5
8
|
const isNotStringAndIterable = isi;
|
|
6
9
|
const isPlainObject = iso;
|
|
@@ -47,7 +50,7 @@ export const normalizeElement = (spec, keys) => {
|
|
|
47
50
|
if (tag === name && hasAttribs && (!keys || spec[1].key)) {
|
|
48
51
|
return spec;
|
|
49
52
|
}
|
|
50
|
-
attribs = mergeEmmetAttribs(hasAttribs ?
|
|
53
|
+
attribs = mergeEmmetAttribs(hasAttribs ? { ...spec[1] } : {}, match[2], match[3]);
|
|
51
54
|
return attribs.__skip && spec.length < 3
|
|
52
55
|
? [name, attribs]
|
|
53
56
|
: [name, attribs, ...spec.slice(hasAttribs ? 2 : 1)];
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hdom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"description": "Lightweight vanilla ES6 UI component trees with customizable branch-local behaviors",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"module": "./index.js",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"umd:main": "./lib/index.umd.js",
|
|
8
7
|
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
@@ -24,36 +24,29 @@
|
|
|
24
24
|
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn clean &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"build:test": "rimraf build && tsc -p test/tsconfig.json",
|
|
31
|
-
"build:check": "tsc --isolatedModules --noEmit",
|
|
32
|
-
"test": "mocha test",
|
|
33
|
-
"cover": "nyc mocha test && nyc report --reporter=lcov",
|
|
34
|
-
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
|
|
35
|
-
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
|
|
36
|
-
"doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf *.js *.d.ts *.map doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
37
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
31
|
+
"doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
|
|
32
|
+
"doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
|
|
33
|
+
"pub": "yarn build && yarn publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
42
35
|
},
|
|
43
36
|
"dependencies": {
|
|
44
|
-
"@thi.ng/api": "^
|
|
45
|
-
"@thi.ng/checks": "^
|
|
46
|
-
"@thi.ng/diff": "^
|
|
47
|
-
"@thi.ng/equiv": "^
|
|
48
|
-
"@thi.ng/errors": "^
|
|
49
|
-
"@thi.ng/hiccup": "^
|
|
50
|
-
"@thi.ng/
|
|
37
|
+
"@thi.ng/api": "^8.0.3",
|
|
38
|
+
"@thi.ng/checks": "^3.0.3",
|
|
39
|
+
"@thi.ng/diff": "^5.0.3",
|
|
40
|
+
"@thi.ng/equiv": "^2.0.3",
|
|
41
|
+
"@thi.ng/errors": "^2.0.3",
|
|
42
|
+
"@thi.ng/hiccup": "^4.0.3",
|
|
43
|
+
"@thi.ng/logger": "^1.0.3",
|
|
44
|
+
"@thi.ng/prefixes": "^2.0.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@thi.ng/atom": "^5.0.3",
|
|
48
|
+
"@thi.ng/testament": "^0.1.3"
|
|
51
49
|
},
|
|
52
|
-
"files": [
|
|
53
|
-
"*.js",
|
|
54
|
-
"*.d.ts",
|
|
55
|
-
"lib"
|
|
56
|
-
],
|
|
57
50
|
"keywords": [
|
|
58
51
|
"array",
|
|
59
52
|
"browser",
|
|
@@ -74,7 +67,45 @@
|
|
|
74
67
|
"publishConfig": {
|
|
75
68
|
"access": "public"
|
|
76
69
|
},
|
|
77
|
-
"
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=12.7"
|
|
72
|
+
},
|
|
73
|
+
"files": [
|
|
74
|
+
"*.js",
|
|
75
|
+
"*.d.ts"
|
|
76
|
+
],
|
|
77
|
+
"exports": {
|
|
78
|
+
".": {
|
|
79
|
+
"import": "./index.js"
|
|
80
|
+
},
|
|
81
|
+
"./api": {
|
|
82
|
+
"import": "./api.js"
|
|
83
|
+
},
|
|
84
|
+
"./default": {
|
|
85
|
+
"import": "./default.js"
|
|
86
|
+
},
|
|
87
|
+
"./diff": {
|
|
88
|
+
"import": "./diff.js"
|
|
89
|
+
},
|
|
90
|
+
"./dom": {
|
|
91
|
+
"import": "./dom.js"
|
|
92
|
+
},
|
|
93
|
+
"./logger": {
|
|
94
|
+
"import": "./logger.js"
|
|
95
|
+
},
|
|
96
|
+
"./normalize": {
|
|
97
|
+
"import": "./normalize.js"
|
|
98
|
+
},
|
|
99
|
+
"./render-once": {
|
|
100
|
+
"import": "./render-once.js"
|
|
101
|
+
},
|
|
102
|
+
"./resolve": {
|
|
103
|
+
"import": "./resolve.js"
|
|
104
|
+
},
|
|
105
|
+
"./start": {
|
|
106
|
+
"import": "./start.js"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
78
109
|
"thi.ng": {
|
|
79
110
|
"blog": [
|
|
80
111
|
{
|
|
@@ -88,5 +119,5 @@
|
|
|
88
119
|
],
|
|
89
120
|
"year": 2015
|
|
90
121
|
},
|
|
91
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "1fb38cac74d6c009d96855c28784a267a81badf1"
|
|
92
123
|
}
|
package/render-once.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HDOMImplementation, HDOMOpts } from "./api";
|
|
1
|
+
import type { HDOMImplementation, HDOMOpts } from "./api.js";
|
|
2
2
|
/**
|
|
3
3
|
* One-off hdom tree conversion & target DOM application. Takes same
|
|
4
4
|
* options as {@link start}, but performs no diffing and only creates or
|
package/render-once.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { derefContext } from "@thi.ng/hiccup";
|
|
2
|
-
import { DEFAULT_IMPL } from "./default";
|
|
3
|
-
import { resolveRoot } from "./
|
|
1
|
+
import { derefContext } from "@thi.ng/hiccup/deref";
|
|
2
|
+
import { DEFAULT_IMPL } from "./default.js";
|
|
3
|
+
import { resolveRoot } from "./resolve.js";
|
|
4
4
|
/**
|
|
5
5
|
* One-off hdom tree conversion & target DOM application. Takes same
|
|
6
6
|
* options as {@link start}, but performs no diffing and only creates or
|
|
@@ -12,7 +12,7 @@ import { resolveRoot } from "./utils";
|
|
|
12
12
|
* @param impl - hdom implementation
|
|
13
13
|
*/
|
|
14
14
|
export const renderOnce = (tree, opts = {}, impl = DEFAULT_IMPL) => {
|
|
15
|
-
opts =
|
|
15
|
+
opts = { root: "app", ...opts };
|
|
16
16
|
opts.ctx = derefContext(opts.ctx, opts.autoDerefKeys);
|
|
17
17
|
const root = resolveRoot(opts.root, impl);
|
|
18
18
|
tree = impl.normalizeTree(opts, tree);
|
package/resolve.d.ts
ADDED
package/{utils.js → resolve.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { isString } from "@thi.ng/checks";
|
|
1
|
+
import { isString } from "@thi.ng/checks/is-string";
|
|
2
2
|
export const resolveRoot = (root, impl) => isString(root) ? impl.getElementById(root) : root;
|
package/start.d.ts
CHANGED
package/start.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { derefContext } from "@thi.ng/hiccup";
|
|
2
|
-
import { DEFAULT_IMPL } from "./default";
|
|
3
|
-
import { resolveRoot } from "./
|
|
1
|
+
import { derefContext } from "@thi.ng/hiccup/deref";
|
|
2
|
+
import { DEFAULT_IMPL } from "./default.js";
|
|
3
|
+
import { resolveRoot } from "./resolve.js";
|
|
4
4
|
/**
|
|
5
5
|
* Takes an hiccup tree (array, function or component object w/ life
|
|
6
6
|
* cycle methods) and an optional object of DOM update options. Starts
|
|
@@ -46,7 +46,7 @@ import { resolveRoot } from "./utils";
|
|
|
46
46
|
* @param impl - hdom target implementation
|
|
47
47
|
*/
|
|
48
48
|
export const start = (tree, opts = {}, impl = DEFAULT_IMPL) => {
|
|
49
|
-
const _opts =
|
|
49
|
+
const _opts = { root: "app", ...opts };
|
|
50
50
|
let prev = [];
|
|
51
51
|
let isActive = true;
|
|
52
52
|
const root = resolveRoot(_opts.root, impl);
|