This repository was archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpage.pc.mjs
123 lines (107 loc) · 2.65 KB
/
page.pc.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import React from "react";
const encode = (value) =>
value.replace(/['<>\u00A0-香<>\&]/gim, function (i) {
return "&#" + i.charCodeAt(0) + ";";
});
const flatten = (v) =>
v.reduce((ary, v) => {
if (Array.isArray(v)) {
ary.push(...flatten(v));
} else {
ary.push(v);
}
return ary;
}, []);
const VOID_TAGS = ["br", "img", "hr"];
const isVoid = (v) => VOID_TAGS.includes(v);
const createElement = (tag, attributes, ...children) => {
if (typeof tag === "function") {
return tag({ ...attributes, children });
}
const buffer = ["<" + tag + ""];
for (let key in attributes) {
let value = attributes[key];
if (key === "className") {
key = "class";
}
if (key === "ref") {
continue;
}
if (key === "style") {
value = stringifyStyle(value);
} else if (typeof value === "string") {
value = encode(value);
}
buffer.push(" " + key + '="' + value + '"');
}
if (isVoid(tag)) {
buffer.push("/>");
return buffer.join("");
}
buffer.push(">");
buffer.push(
flatten(children)
.filter((v) => v !== false && v != null)
.join("")
);
buffer.push("</" + tag + ">");
return buffer.join("");
};
const stringifyStyle = (value) =>
Object.entries(value)
.map(([key, value]) => key + ":" + value)
.join(";");
const Fragment = (props) => flatten(props.children).join("");
const _vanilla = {
createElement,
Fragment,
forwardRef: (v) => v,
memo: (v) => v,
};
function getDefault(module) {
return module.default || module;
}
function castStyle(value) {
var tov = typeof value;
if (tov === "object" || tov !== "string" || !value) return value;
return value
.trim()
.split(";")
.reduce(function (obj, keyValue) {
var kvp = keyValue.split(":");
var key = kvp[0];
var value = kvp[1];
if (!value || value === "undefined") return obj;
var trimmedValue = value.trim();
if (trimmedValue === "undefined" || !trimmedValue) return obj;
obj[key.trim()] = trimmedValue;
return obj;
}, {});
}
export const classNames = {};
var $$Default = _vanilla.memo(
_vanilla.forwardRef(function $$Default(props, ref) {
return _vanilla.createElement(
"html",
{
className: "_cee54446 _3ef4ccdc _pub-3ef4ccdc",
ref: ref,
},
_vanilla.createElement(
"head",
{
className: "_90b8db53 _3ef4ccdc _pub-3ef4ccdc",
},
props["head"]
),
_vanilla.createElement(
"body",
{
className: "_e7bfebc5 _3ef4ccdc _pub-3ef4ccdc",
},
props["children"]
)
);
})
);
export default $$Default;