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.
- package/dist/wrec-ssr.d.ts +1 -1
- package/dist/wrec-ssr.es.js +41 -52
- package/package.json +1 -1
package/dist/wrec-ssr.d.ts
CHANGED
package/dist/wrec-ssr.es.js
CHANGED
|
@@ -1,71 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Wrec as
|
|
3
|
-
import { WrecState as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
25
|
-
for (const [t,
|
|
13
|
+
const f = this.properties;
|
|
14
|
+
for (const [t, s] of Object.entries(f))
|
|
26
15
|
if (o[t] === void 0) {
|
|
27
|
-
const { value:
|
|
28
|
-
|
|
16
|
+
const { value: n } = s;
|
|
17
|
+
n !== void 0 && (o[t] = n);
|
|
29
18
|
}
|
|
30
|
-
function
|
|
19
|
+
function m(t) {
|
|
31
20
|
return new Function("return " + t).call(o);
|
|
32
21
|
}
|
|
33
|
-
function
|
|
34
|
-
const { attributes:
|
|
35
|
-
for (const [e,
|
|
36
|
-
if (
|
|
37
|
-
const r =
|
|
38
|
-
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:
|
|
41
|
-
|
|
42
|
-
if (e.nodeType ===
|
|
43
|
-
|
|
44
|
-
else if (e.nodeType ===
|
|
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 (
|
|
47
|
-
const
|
|
48
|
-
|
|
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
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
`),
|
|
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
|
-
<${
|
|
47
|
+
<${N}${u}>
|
|
59
48
|
<template shadowrootmode="open">
|
|
60
|
-
${
|
|
49
|
+
${v}
|
|
61
50
|
</template>
|
|
62
|
-
</${
|
|
51
|
+
</${N}>
|
|
63
52
|
`;
|
|
64
53
|
};
|
|
65
54
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
_ as Wrec,
|
|
56
|
+
j as WrecState,
|
|
68
57
|
C as createElement,
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
F as css,
|
|
59
|
+
D as html
|
|
71
60
|
};
|