wrec 0.22.2 → 0.22.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.
@@ -1,4 +1,4 @@
1
- export declare type ChangeListener = {
1
+ declare type ChangeListener = {
2
2
  changed: (statePath: string, componentProperty: string, newValue: unknown, oldValue: unknown, state: WrecState) => void;
3
3
  };
4
4
 
@@ -1,71 +1,60 @@
1
- import { HTMLElement as y, parse as H, NodeType as T, TextNode as M } from "node-html-parser";
2
- import { Wrec as R } from "./wrec.es.js";
3
- import { WrecState as I, createElement as C, css as D, html as F } from "./wrec.es.js";
4
- const b = "a-zA-Z_$", S = b + "0-9", h = `[${b}][${S}]*`, N = new RegExp(`this\\.${h}(\\.${h})*`), _ = 5, O = (c) => c.substring(_).split(".")[0];
5
- typeof window > "u" && !globalThis.HTMLElement && (globalThis.HTMLElement = y);
6
- typeof window > "u" && !globalThis.customElements && (globalThis.customElements = {
7
- get: (c) => {
8
- },
9
- getName: () => "",
10
- define: () => {
11
- },
12
- upgrade: () => {
13
- },
14
- whenDefined: () => Promise.reject(new Error("customElements is not available"))
15
- });
16
- R.ssr = function(o = {}) {
17
- let l = "";
18
- const m = Object.keys(o);
19
- m.sort();
20
- for (const t of m) {
21
- const n = this.getAttrName(t);
22
- l += ` ${n}="${o[t]}"`;
1
+ import { parse as S, NodeType as h, TextNode as O } from "node-html-parser";
2
+ import { Wrec as _ } from "./wrec.es.js";
3
+ import { WrecState as j, createElement as C, css as F, html as D } from "./wrec.es.js";
4
+ const $ = "a-zA-Z_$", w = $ + "0-9", T = `[${$}][${w}]*`, d = new RegExp(`this\\.${T}(\\.${T})*`), y = 5, A = (a) => a.substring(y).split(".")[0];
5
+ _.ssr = function(o = {}) {
6
+ let u = "";
7
+ const l = Object.keys(o);
8
+ l.sort();
9
+ for (const t of l) {
10
+ const s = this.getAttrName(t);
11
+ u += ` ${s}="${o[t]}"`;
23
12
  }
24
- const u = this.properties;
25
- for (const [t, n] of Object.entries(u))
13
+ const f = this.properties;
14
+ for (const [t, s] of Object.entries(f))
26
15
  if (o[t] === void 0) {
27
- const { value: s } = n;
28
- s !== void 0 && (o[t] = s);
16
+ const { value: n } = s;
17
+ n !== void 0 && (o[t] = n);
29
18
  }
30
- function f(t) {
19
+ function m(t) {
31
20
  return new Function("return " + t).call(o);
32
21
  }
33
- function E(t) {
34
- const { attributes: n } = t;
35
- for (const [e, i] of Object.entries(n))
36
- if (N.test(i)) {
37
- const r = f(i), a = O(e), v = u[a]?.value ?? "";
38
- r === v ? t.removeAttribute(e) : t.setAttribute(e, String(r));
22
+ function p(t) {
23
+ const { attributes: s } = t;
24
+ for (const [e, c] of Object.entries(s))
25
+ if (d.test(c)) {
26
+ const r = m(c), i = A(e), R = f[i]?.value ?? "";
27
+ r === R ? t.removeAttribute(e) : t.setAttribute(e, String(r));
39
28
  }
40
- const { childNodes: s } = t;
41
- s.forEach((e, i) => {
42
- if (e.nodeType === T.ELEMENT_NODE)
43
- E(e);
44
- else if (e.nodeType === T.COMMENT_NODE) {
29
+ const { childNodes: n } = t;
30
+ n.forEach((e, c) => {
31
+ if (e.nodeType === h.ELEMENT_NODE)
32
+ p(e);
33
+ else if (e.nodeType === h.COMMENT_NODE) {
45
34
  const r = e.textContent ?? "";
46
- if (N.test(r)) {
47
- const a = f(r);
48
- s[i] = new M(String(a));
35
+ if (d.test(r)) {
36
+ const i = m(r);
37
+ n[c] = new O(String(i));
49
38
  }
50
39
  }
51
40
  });
52
41
  }
53
- const g = this.buildHTML(), w = H(g, { comment: !0 }), { children: d } = w;
54
- d.forEach(E);
55
- const $ = d.map((t) => t.outerHTML).join(`
56
- `), p = this.elementName;
42
+ const b = this.buildHTML(), g = S(b, { comment: !0 }), { children: E } = g;
43
+ E.forEach(p);
44
+ const v = E.map((t) => t.outerHTML).join(`
45
+ `), N = this.elementName;
57
46
  return `
58
- <${p}${l}>
47
+ <${N}${u}>
59
48
  <template shadowrootmode="open">
60
- ${$}
49
+ ${v}
61
50
  </template>
62
- </${p}>
51
+ </${N}>
63
52
  `;
64
53
  };
65
54
  export {
66
- R as Wrec,
67
- I as WrecState,
55
+ _ as Wrec,
56
+ j as WrecState,
68
57
  C as createElement,
69
- D as css,
70
- F as html
58
+ F as css,
59
+ D as html
71
60
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "wrec",
3
3
  "description": "a small library that greatly simplifies building web components",
4
4
  "author": "R. Mark Volkmann",
5
- "version": "0.22.2",
5
+ "version": "0.22.3",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",