@thi.ng/hdom 9.4.34 → 9.4.36

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-05-08T18:24:32Z
3
+ - **Last updated**: 2024-06-29T09:28:36Z
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,13 @@ 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
+ ### [9.4.35](https://github.com/thi-ng/umbrella/tree/@thi.ng/hdom@9.4.35) (2024-06-21)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - split up internal normalizeTree() ([1fbca7b](https://github.com/thi-ng/umbrella/commit/1fbca7b))
17
+ - enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
18
+
12
19
  ### [9.4.14](https://github.com/thi-ng/umbrella/tree/@thi.ng/hdom@9.4.14) (2024-02-16)
13
20
 
14
21
  #### ♻️ Refactoring
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 192 standalone projects, maintained as part
10
+ > This is one of 189 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
  >
@@ -161,7 +161,7 @@ yarn install
161
161
  yarn start
162
162
  ```
163
163
 
164
- Package sizes (brotli'd, pre-treeshake): ESM: 3.48 KB
164
+ Package sizes (brotli'd, pre-treeshake): ESM: 3.49 KB
165
165
 
166
166
  ## Dependencies
167
167
 
package/diff.js CHANGED
@@ -20,7 +20,7 @@ const INDEX = (() => {
20
20
  }
21
21
  return res;
22
22
  })();
23
- const buildIndex = (n) => {
23
+ const __buildIndex = (n) => {
24
24
  if (n <= INDEX.length) {
25
25
  return INDEX.slice(0, n);
26
26
  }
@@ -75,13 +75,13 @@ const diffTree = (opts, impl, parent, prev, curr, child = 0) => {
75
75
  }
76
76
  const numEdits = edits.length;
77
77
  const prevLength = prev.length - 1;
78
- const equivKeys = extractEquivElements(edits);
79
- const offsets = buildIndex(prevLength + 1);
78
+ const equivKeys = __extractEquivElements(edits);
79
+ const offsets = __buildIndex(prevLength + 1);
80
80
  for (i = 2, ii = 6; ii < numEdits; i++, ii += 3) {
81
81
  status = edits[ii];
82
82
  if (!status) continue;
83
83
  if (status === -1) {
84
- diffDeleted(
84
+ __diffDeleted(
85
85
  opts,
86
86
  impl,
87
87
  el,
@@ -94,7 +94,7 @@ const diffTree = (opts, impl, parent, prev, curr, child = 0) => {
94
94
  prevLength
95
95
  );
96
96
  } else {
97
- diffAdded(
97
+ __diffAdded(
98
98
  opts,
99
99
  impl,
100
100
  el,
@@ -110,7 +110,7 @@ const diffTree = (opts, impl, parent, prev, curr, child = 0) => {
110
110
  val.apply(curr, [el, ...curr.__args]);
111
111
  }
112
112
  };
113
- const diffDeleted = (opts, impl, el, prev, curr, edits, ii, equivKeys, offsets, prevLength) => {
113
+ const __diffDeleted = (opts, impl, el, prev, curr, edits, ii, equivKeys, offsets, prevLength) => {
114
114
  const val = edits[ii + 2];
115
115
  if (isArray(val)) {
116
116
  let k = val[1].key;
@@ -122,13 +122,13 @@ const diffDeleted = (opts, impl, el, prev, curr, edits, ii, equivKeys, offsets,
122
122
  const idx = edits[ii + 1];
123
123
  releaseTree(val);
124
124
  impl.removeChild(el, offsets[idx]);
125
- incOffsets(offsets, prevLength, idx);
125
+ __incOffsets(offsets, prevLength, idx);
126
126
  }
127
127
  } else if (typeof val === STR) {
128
128
  impl.setContent(el, "");
129
129
  }
130
130
  };
131
- const diffAdded = (opts, impl, el, edits, ii, equivKeys, offsets, prevLength) => {
131
+ const __diffAdded = (opts, impl, el, edits, ii, equivKeys, offsets, prevLength) => {
132
132
  const val = edits[ii + 2];
133
133
  if (typeof val === STR) {
134
134
  impl.setContent(el, val);
@@ -137,16 +137,16 @@ const diffAdded = (opts, impl, el, edits, ii, equivKeys, offsets, prevLength) =>
137
137
  if (k === void 0 || equivKeys[k][0] === void 0) {
138
138
  const idx = edits[ii + 1];
139
139
  impl.createTree(opts, el, val, offsets[idx]);
140
- decOffsets(offsets, prevLength, idx);
140
+ __decOffsets(offsets, prevLength, idx);
141
141
  }
142
142
  }
143
143
  };
144
- const incOffsets = (offsets, j, idx) => {
144
+ const __incOffsets = (offsets, j, idx) => {
145
145
  for (; j > idx; j--) {
146
146
  offsets[j] = max(offsets[j] - 1, 0);
147
147
  }
148
148
  };
149
- const decOffsets = (offsets, j, idx) => {
149
+ const __decOffsets = (offsets, j, idx) => {
150
150
  for (; j >= idx; j--) {
151
151
  offsets[j]++;
152
152
  }
@@ -182,7 +182,7 @@ const releaseTree = (tree) => {
182
182
  }
183
183
  }
184
184
  };
185
- const extractEquivElements = (edits) => {
185
+ const __extractEquivElements = (edits) => {
186
186
  let k;
187
187
  let val;
188
188
  let ek;
package/dom.js CHANGED
@@ -6,7 +6,7 @@ import { ATTRIB_JOIN_DELIMS, SVG_TAGS } from "@thi.ng/hiccup/api";
6
6
  import { css } from "@thi.ng/hiccup/css";
7
7
  import { formatPrefixes } from "@thi.ng/hiccup/prefix";
8
8
  import { XML_SVG } from "@thi.ng/prefixes/xml";
9
- const maybeInitElement = (el, tree) => tree.__init && tree.__init.apply(tree.__this, [el, ...tree.__args]);
9
+ const __maybeInitElement = (el, tree) => tree.__init && tree.__init.apply(tree.__this, [el, ...tree.__args]);
10
10
  const createTree = (opts, impl, parent, tree, insert, init = true) => {
11
11
  if (isArray(tree)) {
12
12
  const tag = tree[0];
@@ -36,7 +36,7 @@ const createTree = (opts, impl, parent, tree, insert, init = true) => {
36
36
  createTree(opts, impl, el, tree[i], void 0, init);
37
37
  }
38
38
  }
39
- init && maybeInitElement(el, tree);
39
+ init && __maybeInitElement(el, tree);
40
40
  return el;
41
41
  }
42
42
  if (isNotStringAndIterable(tree)) {
@@ -72,7 +72,7 @@ const hydrateTree = (opts, impl, parent, tree, index = 0) => {
72
72
  index
73
73
  );
74
74
  }
75
- maybeInitElement(el, tree);
75
+ __maybeInitElement(el, tree);
76
76
  for (let a in attribs) {
77
77
  a[0] === "o" && a[1] === "n" && impl.setAttrib(el, a, attribs[a]);
78
78
  }
package/normalize.js CHANGED
@@ -27,7 +27,7 @@ const normalizeElement = (spec, keys) => {
27
27
  );
28
28
  return attribs.__skip && spec.length < 3 ? [name, attribs] : [name, attribs, ...spec.slice(hasAttribs ? 2 : 1)];
29
29
  };
30
- const normalizeTree = (opts, tree) => _normalizeTree(
30
+ const normalizeTree = (opts, tree) => __normalizeTree(
31
31
  tree,
32
32
  opts,
33
33
  opts.ctx,
@@ -35,60 +35,53 @@ const normalizeTree = (opts, tree) => _normalizeTree(
35
35
  opts.keys !== false,
36
36
  opts.span !== false
37
37
  );
38
- const _normalizeTree = (tree, opts, ctx, path, keys, span) => {
39
- if (tree == null) {
40
- return;
38
+ const __normalizeTree = (tree, opts, ctx, path, keys, span) => tree == null ? void 0 : isArray(tree) ? __normalizeArray(tree, opts, ctx, path, keys, span) : typeof tree === "function" ? __normalizeTree(tree(ctx), opts, ctx, path, keys, span) : typeof tree.toHiccup === "function" ? __normalizeTree(tree.toHiccup(opts.ctx), opts, ctx, path, keys, span) : typeof tree.deref === "function" ? __normalizeTree(tree.deref(), opts, ctx, path, keys, span) : span ? ["span", keys ? { key: path.join("-") } : {}, tree.toString()] : tree.toString();
39
+ const __normalizeArray = (tree, opts, ctx, path, keys, span) => {
40
+ if (tree.length === 0) return;
41
+ let norm, nattribs = tree[1], impl;
42
+ if (nattribs && (impl = nattribs.__impl) && (impl = impl.normalizeTree)) {
43
+ return impl(opts, tree);
41
44
  }
42
- if (isArray(tree)) {
43
- if (tree.length === 0) {
44
- return;
45
- }
46
- let norm, nattribs = tree[1], impl;
47
- if (nattribs && (impl = nattribs.__impl) && (impl = impl.normalizeTree)) {
48
- return impl(opts, tree);
49
- }
50
- const tag = tree[0];
51
- if (typeof tag === "function") {
52
- return _normalizeTree(
53
- tag.apply(null, [ctx, ...tree.slice(1)]),
54
- opts,
55
- ctx,
56
- path,
57
- keys,
58
- span
59
- );
60
- }
61
- if (typeof tag.render === "function") {
62
- const args = [ctx, ...tree.slice(1)];
63
- norm = _normalizeTree(
64
- tag.render.apply(tag, args),
65
- opts,
66
- ctx,
67
- path,
68
- keys,
69
- span
70
- );
71
- if (isArray(norm)) {
72
- norm.__this = tag;
73
- norm.__init = tag.init;
74
- norm.__release = tag.release;
75
- norm.__args = args;
76
- }
77
- return norm;
78
- }
79
- norm = normalizeElement(tree, keys);
80
- nattribs = norm[1];
81
- if (nattribs.__normalize === false) {
82
- return norm;
83
- }
84
- if (keys && nattribs.key === void 0) {
85
- nattribs.key = path.join("-");
45
+ const tag = tree[0];
46
+ if (typeof tag === "function") {
47
+ return __normalizeTree(
48
+ tag.apply(null, [ctx, ...tree.slice(1)]),
49
+ opts,
50
+ ctx,
51
+ path,
52
+ keys,
53
+ span
54
+ );
55
+ }
56
+ if (typeof tag.render === "function") {
57
+ const args = [ctx, ...tree.slice(1)];
58
+ norm = __normalizeTree(
59
+ tag.render.apply(tag, args),
60
+ opts,
61
+ ctx,
62
+ path,
63
+ keys,
64
+ span
65
+ );
66
+ if (isArray(norm)) {
67
+ norm.__this = tag;
68
+ norm.__init = tag.init;
69
+ norm.__release = tag.release;
70
+ norm.__args = args;
86
71
  }
87
- return norm.length > 2 ? normalizeChildren(norm, nattribs, opts, ctx, path, keys, span) : norm;
72
+ return norm;
73
+ }
74
+ norm = normalizeElement(tree, keys);
75
+ nattribs = norm[1];
76
+ if (nattribs.__normalize === false) {
77
+ return norm;
78
+ }
79
+ if (keys && nattribs.key === void 0) {
80
+ nattribs.key = path.join("-");
88
81
  }
89
- return typeof tree === "function" ? _normalizeTree(tree(ctx), opts, ctx, path, keys, span) : typeof tree.toHiccup === "function" ? _normalizeTree(tree.toHiccup(opts.ctx), opts, ctx, path, keys, span) : typeof tree.deref === "function" ? _normalizeTree(tree.deref(), opts, ctx, path, keys, span) : span ? ["span", keys ? { key: path.join("-") } : {}, tree.toString()] : tree.toString();
82
+ return norm.length > 2 ? __normalizeChildren(norm, nattribs, opts, ctx, path, keys, span) : norm;
90
83
  };
91
- const normalizeChildren = (norm, nattribs, opts, ctx, path, keys, span) => {
84
+ const __normalizeChildren = (norm, nattribs, opts, ctx, path, keys, span) => {
92
85
  const tag = norm[0];
93
86
  const res = [tag, nattribs];
94
87
  span = span && !NO_SPANS[tag];
@@ -98,7 +91,7 @@ const normalizeChildren = (norm, nattribs, opts, ctx, path, keys, span) => {
98
91
  const isarray = isArray(el);
99
92
  if (isarray && isArray(el[0]) || !isarray && isNotStringAndIterable(el)) {
100
93
  for (let c of el) {
101
- c = _normalizeTree(
94
+ c = __normalizeTree(
102
95
  c,
103
96
  opts,
104
97
  ctx,
@@ -112,7 +105,7 @@ const normalizeChildren = (norm, nattribs, opts, ctx, path, keys, span) => {
112
105
  k++;
113
106
  }
114
107
  } else {
115
- el = _normalizeTree(el, opts, ctx, path.concat(k), keys, span);
108
+ el = __normalizeTree(el, opts, ctx, path.concat(k), keys, span);
116
109
  if (el !== void 0) {
117
110
  res[j++] = el;
118
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hdom",
3
- "version": "9.4.34",
3
+ "version": "9.4.36",
4
4
  "description": "Lightweight vanilla ES6 UI component trees with customizable branch-local behaviors",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/hdom#readme",
13
+ "homepage": "https://thi.ng/hdom",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -39,21 +39,21 @@
39
39
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@thi.ng/api": "^8.11.2",
43
- "@thi.ng/checks": "^3.6.4",
44
- "@thi.ng/diff": "^5.1.69",
45
- "@thi.ng/equiv": "^2.1.58",
46
- "@thi.ng/errors": "^2.5.7",
47
- "@thi.ng/hiccup": "^5.2.1",
48
- "@thi.ng/logger": "^3.0.12",
49
- "@thi.ng/prefixes": "^2.3.19"
42
+ "@thi.ng/api": "^8.11.4",
43
+ "@thi.ng/checks": "^3.6.6",
44
+ "@thi.ng/diff": "^5.1.71",
45
+ "@thi.ng/equiv": "^2.1.60",
46
+ "@thi.ng/errors": "^2.5.9",
47
+ "@thi.ng/hiccup": "^5.2.3",
48
+ "@thi.ng/logger": "^3.0.14",
49
+ "@thi.ng/prefixes": "^2.3.21"
50
50
  },
51
51
  "devDependencies": {
52
- "@microsoft/api-extractor": "^7.43.2",
53
- "@thi.ng/atom": "^5.3.0",
54
- "esbuild": "^0.21.1",
52
+ "@microsoft/api-extractor": "^7.47.0",
53
+ "@thi.ng/atom": "^5.3.2",
54
+ "esbuild": "^0.21.5",
55
55
  "typedoc": "^0.25.13",
56
- "typescript": "^5.4.5"
56
+ "typescript": "^5.5.2"
57
57
  },
58
58
  "keywords": [
59
59
  "array",
@@ -131,5 +131,5 @@
131
131
  "status": "completed",
132
132
  "year": 2015
133
133
  },
134
- "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
134
+ "gitHead": "7b950c112fba0b2e7c450765b15624c3382f1354\n"
135
135
  }