ilha 0.8.5 → 0.9.1
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/README.md +77 -0
- package/dist/{index-BUonLJXu.d.ts → index-C0SWn9oq.d.ts} +49 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2121 -5
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js +3 -1
- package/dist/{jsx-runtime-DZl50XF-.d.ts → jsx-runtime-DBCAZ9YL.d.ts} +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +162 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JSX, r as jsxDEV, t as Fragment } from "./jsx-runtime-
|
|
1
|
+
import { a as JSX, r as jsxDEV, t as Fragment } from "./jsx-runtime-DBCAZ9YL.js";
|
|
2
2
|
export { Fragment, type JSX, jsxDEV };
|
package/dist/jsx-dev-runtime.js
CHANGED
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JSX, i as jsxs, n as jsx, r as jsxDEV, t as Fragment } from "./jsx-runtime-
|
|
2
|
-
export { Fragment, JSX, jsx, jsxDEV, jsxs };
|
|
1
|
+
import { a as JSX, i as jsxs, n as jsx, r as jsxDEV, t as Fragment } from "./jsx-runtime-DBCAZ9YL.js";
|
|
2
|
+
export { Fragment, type JSX, jsx, jsxDEV, jsxs };
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1 +1,162 @@
|
|
|
1
|
-
import{__ilhaJsxSlot
|
|
1
|
+
import { __ilhaJsxSlot, html, raw } from "./index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/jsx-runtime.ts
|
|
4
|
+
const RAW = Symbol.for("ilha.raw");
|
|
5
|
+
const SIGNAL_ACCESSOR = Symbol.for("ilha.signalAccessor");
|
|
6
|
+
const ISLAND = Symbol.for("ilha.island");
|
|
7
|
+
const ISLAND_CALL = Symbol.for("ilha.islandCall");
|
|
8
|
+
const RENDER_PART = Symbol.for("ilha.renderPart");
|
|
9
|
+
const SAFE_NAME_RE = /^[A-Za-z_:][A-Za-z0-9:._-]*$/;
|
|
10
|
+
const SAFE_BIND_LOCAL_RE = /^[A-Za-z][A-Za-z0-9]*$/;
|
|
11
|
+
const VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
12
|
+
"area",
|
|
13
|
+
"base",
|
|
14
|
+
"br",
|
|
15
|
+
"col",
|
|
16
|
+
"embed",
|
|
17
|
+
"hr",
|
|
18
|
+
"img",
|
|
19
|
+
"input",
|
|
20
|
+
"link",
|
|
21
|
+
"meta",
|
|
22
|
+
"param",
|
|
23
|
+
"source",
|
|
24
|
+
"track",
|
|
25
|
+
"wbr"
|
|
26
|
+
]);
|
|
27
|
+
const SAFE_CSS_PROP_RE = /^(-{2}[a-zA-Z][a-zA-Z0-9-]*|-?[a-zA-Z][a-zA-Z0-9-]*)$/;
|
|
28
|
+
const URL_ATTRS = /* @__PURE__ */ new Set([
|
|
29
|
+
"href",
|
|
30
|
+
"src",
|
|
31
|
+
"action",
|
|
32
|
+
"formaction",
|
|
33
|
+
"cite",
|
|
34
|
+
"data",
|
|
35
|
+
"poster"
|
|
36
|
+
]);
|
|
37
|
+
const SAFE_URL_RE = /^(?!javascript:|data:text\/html|data:text\/xml|data:application\/xhtml\+xml|data:image\/svg|vbscript:)/i;
|
|
38
|
+
function isSafeUrl(value) {
|
|
39
|
+
return SAFE_URL_RE.test(value.replace(/[\u0000-\u0020]/g, ""));
|
|
40
|
+
}
|
|
41
|
+
function isRawHtml(v) {
|
|
42
|
+
return !!(v && typeof v === "object" && RAW in v);
|
|
43
|
+
}
|
|
44
|
+
function isSignalAccessor(v) {
|
|
45
|
+
return typeof v === "function" && SIGNAL_ACCESSOR in v;
|
|
46
|
+
}
|
|
47
|
+
function isIsland(v) {
|
|
48
|
+
return typeof v === "function" && ISLAND in v;
|
|
49
|
+
}
|
|
50
|
+
function isIslandCall(v) {
|
|
51
|
+
if (v == null || typeof v !== "object" && typeof v !== "function") return false;
|
|
52
|
+
if (ISLAND_CALL in v) return true;
|
|
53
|
+
return typeof v === "object" && "island" in v && isIsland(v.island);
|
|
54
|
+
}
|
|
55
|
+
function normalizeClass(value) {
|
|
56
|
+
if (Array.isArray(value)) return value.filter(Boolean).join(" ");
|
|
57
|
+
if (value && typeof value === "object") return Object.entries(value).filter(([, enabled]) => Boolean(enabled)).map(([name]) => name).join(" ");
|
|
58
|
+
return String(value);
|
|
59
|
+
}
|
|
60
|
+
function normalizeJsxChildren(props, children) {
|
|
61
|
+
const propChildren = props && "children" in props ? props.children : void 0;
|
|
62
|
+
return (children.length > 0 ? children : propChildren === void 0 ? [] : [propChildren]).flat(1);
|
|
63
|
+
}
|
|
64
|
+
function normalizeJsxSlotKey(rawKey) {
|
|
65
|
+
const key = String(rawKey);
|
|
66
|
+
if (key.trim().length === 0) throw new Error("jsx key requires a non-empty string.");
|
|
67
|
+
if (key.includes(":")) throw new Error(`jsx key cannot contain the slot separator ":" (got "${key}").`);
|
|
68
|
+
return key;
|
|
69
|
+
}
|
|
70
|
+
function extractJsxSlotKey(props, keyArg) {
|
|
71
|
+
const fromProps = props?.key;
|
|
72
|
+
const rawKey = keyArg ?? (typeof fromProps === "string" || typeof fromProps === "number" ? fromProps : void 0);
|
|
73
|
+
if (rawKey == null) return void 0;
|
|
74
|
+
return normalizeJsxSlotKey(rawKey);
|
|
75
|
+
}
|
|
76
|
+
function serializeStyle(value) {
|
|
77
|
+
return Object.entries(value).map(([k, v]) => {
|
|
78
|
+
if (!SAFE_CSS_PROP_RE.test(k)) return "";
|
|
79
|
+
const prop = k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
80
|
+
const str = String(v);
|
|
81
|
+
if (/[<>{};]/.test(str) || /expression\(/i.test(str) || /javascript:/i.test(str)) return "";
|
|
82
|
+
return `${prop}:${str}`;
|
|
83
|
+
}).filter(Boolean).join(";");
|
|
84
|
+
}
|
|
85
|
+
function pushJsxAttr(chunks, values, name, value) {
|
|
86
|
+
if (value == null || value === false || name === "children" || name === "key") return;
|
|
87
|
+
if (name === "__proto__" || name === "constructor" || name === "prototype") return;
|
|
88
|
+
if (name.startsWith("bind:")) {
|
|
89
|
+
const [prefix, localName, ...rest] = name.split(":");
|
|
90
|
+
if (prefix !== "bind" || rest.length > 0 || !localName || !SAFE_BIND_LOCAL_RE.test(localName)) return;
|
|
91
|
+
if (!isSignalAccessor(value)) return;
|
|
92
|
+
chunks[chunks.length - 1] += ` ${prefix}:${localName}=`;
|
|
93
|
+
values.push(value);
|
|
94
|
+
chunks.push("");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!SAFE_NAME_RE.test(name)) return;
|
|
98
|
+
let safeName = name;
|
|
99
|
+
if (safeName === "className") safeName = "class";
|
|
100
|
+
if (safeName === "htmlFor") safeName = "for";
|
|
101
|
+
if (safeName.startsWith("on")) return;
|
|
102
|
+
if (safeName === "srcdoc") return;
|
|
103
|
+
if (safeName === "class") value = normalizeClass(value);
|
|
104
|
+
if (safeName === "style" && value && typeof value === "object") value = serializeStyle(value);
|
|
105
|
+
if ((URL_ATTRS.has(safeName) || /:(href|src|action|formaction|cite|data|poster)$/.test(safeName)) && !isSafeUrl(typeof value === "string" ? value : String(value))) return;
|
|
106
|
+
if (value === true) {
|
|
107
|
+
chunks[chunks.length - 1] += ` ${safeName}`;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
chunks[chunks.length - 1] += ` ${safeName}="`;
|
|
111
|
+
values.push(value);
|
|
112
|
+
chunks.push("\"");
|
|
113
|
+
}
|
|
114
|
+
function renderJsxElement(type, props, children) {
|
|
115
|
+
const chunks = [`<${type}`];
|
|
116
|
+
const values = [];
|
|
117
|
+
if (props) for (const [name, value] of Object.entries(props)) pushJsxAttr(chunks, values, name, value);
|
|
118
|
+
chunks[chunks.length - 1] += ">";
|
|
119
|
+
if (!VOID_ELEMENTS.has(type)) {
|
|
120
|
+
for (const child of children) {
|
|
121
|
+
values.push(child);
|
|
122
|
+
chunks.push("");
|
|
123
|
+
}
|
|
124
|
+
chunks[chunks.length - 1] += `</${type}>`;
|
|
125
|
+
}
|
|
126
|
+
return html(chunks, ...values);
|
|
127
|
+
}
|
|
128
|
+
function jsx(type, props, maybeKey, ...restChildren) {
|
|
129
|
+
const hasKeyArg = typeof maybeKey === "string" || typeof maybeKey === "number";
|
|
130
|
+
const keyFromArg = hasKeyArg ? maybeKey : void 0;
|
|
131
|
+
const normalizedChildren = normalizeJsxChildren(props, hasKeyArg || maybeKey === void 0 ? restChildren : [maybeKey, ...restChildren]);
|
|
132
|
+
if (typeof type === "function") {
|
|
133
|
+
const slotKey = extractJsxSlotKey(props, typeof keyFromArg === "string" || typeof keyFromArg === "number" ? keyFromArg : void 0);
|
|
134
|
+
const componentProps = {
|
|
135
|
+
...props,
|
|
136
|
+
...normalizedChildren.length > 0 ? { children: normalizedChildren } : {}
|
|
137
|
+
};
|
|
138
|
+
delete componentProps.key;
|
|
139
|
+
const out = type(Object.keys(componentProps).length ? componentProps : {});
|
|
140
|
+
if (isIslandCall(out)) {
|
|
141
|
+
if (slotKey !== void 0) out.key = slotKey;
|
|
142
|
+
return html`${out}`;
|
|
143
|
+
}
|
|
144
|
+
if (isRawHtml(out)) return out;
|
|
145
|
+
if (typeof out === "string" && isIsland(type)) return __ilhaJsxSlot(type, componentProps, slotKey);
|
|
146
|
+
if (typeof out === "string") return html`${out}`;
|
|
147
|
+
if (typeof out === "object" && out !== null && Object.getPrototypeOf(out) === Object.prototype && out[RENDER_PART] === true && typeof out.toString === "function") return raw(String(out));
|
|
148
|
+
return html`${out}`;
|
|
149
|
+
}
|
|
150
|
+
return renderJsxElement(type, props, normalizedChildren);
|
|
151
|
+
}
|
|
152
|
+
const jsxs = jsx;
|
|
153
|
+
function Fragment(props, ...children) {
|
|
154
|
+
const normalizedChildren = normalizeJsxChildren(props, children);
|
|
155
|
+
return html(["", ...normalizedChildren.map(() => "")], ...normalizedChildren);
|
|
156
|
+
}
|
|
157
|
+
function jsxDEV(type, props, maybeKey, _source, _self) {
|
|
158
|
+
return jsx(type, props, maybeKey);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
export { Fragment, jsx, jsxDEV, jsxs };
|